다음 까페 게시판 목록 가져오기
컨텐츠 정보
- 34,099 조회
- 4 추천
- 목록
본문
다음 까페 게시판 목록 가져오기
<?php
function daum_cafe_info($cafe) {
$url = "http://cafe.daum.net/".$cafe;
$data = readURL($url);
preg_match_all("/<frame name=\\"down\\" id=\\"down\\" src=\\"(http\\:\\/\\/[a-z0-9]+\\.daum\\.net\\/)([a-zA-Z0-9\\:\\/\\._\\?]+)grpid=([a-zA-Z0-9]+)\\"/i",$data,$match);
$host = $match[1][0];
$link = $match[1][0].$match[2][0]."grpid=".$match[3][0];
$grpid = $match[3][0];
$data = readURL($link);
$result[title] = strstr($data,"<font size=\\"3\\" class=\\"cafetitle\\">");
$result[title] = substr($result[title],0,strpos($result[title],"</font>")+7);
$result[title] = strip_tags($result[title]);
$result[intro] = strstr($data,"<font class=\\"cafeintroduce\\">");
$result[intro] = substr($result[intro],0,strpos($result[intro],"</font>")+7);
$result[intro] = strip_tags($result[intro]);
$result[info] = strstr($data,"<font class=\\"cafetitle\\"> 회원수");
$result[info] = substr($result[info],0,strpos($result[info],"운영자</a>"));
$result[info] = strip_tags($result[info]);
$seek = strstr($data,"_c21_/bbs_menu?grpid=".$grpid);
$seek = substr($seek,0,strpos($seek,"log=")+4);
$link = $host.$seek;
$data = readURL($link);
$data = strstr($data,"<!-- 게시판 -->");
$data = substr($data,0,strpos($data,"<!-- 카페ON! -->"));
$temp = split("<td width=\\"155\\">",$data);
for ($i=1;$i<sizeof($temp);$i++) {
$href = strstr($temp[$i],"<a href=\\"javascript:parent.caller");
$href = substr($href,0,strpos($href,"</a>")+4);
$subject = strip_tags($href);
preg_match_all("/javascript\\:parent\\.caller\\(\'\\/(_c21_\\/bbs_list\\?grpid=[a-zA-Z0-9]+\\&fldid=[a-zA-Z0-9]+)\'\\)\\;/i",$href,$match);
$link = $host.$match[1][0];
$result[$i] = $subject."QQQQQ".$link;
}
return $result;
}
function daum_bbs_list($url) {
$data = readURL($url);
$data = strstr($data,"<!-- 게시판 -->");
$data = substr($data,0,strpos($data,"<!-- 검색 -->"));
$temp = split("<td bgcolor=\\"#ffffff\\" nowrap valign=\\"top\\" height=\\"22\\" align=\\"center\\"><font size=\\"-1\\">",$data);
for ($i=1;$i<sizeof($temp);$i++) {
$no = substr($temp[$i],0,strpos($temp[$i],"</font>"));
$head = strstr($temp[$i],"<td bgcolor=\\"#ffffff\\" nowrap valign=\\"top\\"><font size=\\"-1\\">");
$head = substr($head,0,strpos($head,"</td>")+5);
$head = strip_tags($head);
$href = strstr($temp[$i],"<a href=\\"/_c21_/bbs_read?grpid=");
$href = substr($href,0,strpos($href,"</a>")+4);
$subject = strip_tags($href);
$link = strstr($href,"/_c21_/bbs_read?grpid=");
$link = substr($link,0,strpos($link,"\\""));
$temp_url = parse_url($url);
$host = $temp_url[scheme]."://".$temp_url[host];
$link = $host.$link;
preg_match_all("/\\[[0-9]+\\]/i",$temp[$i],$match);
$comment = $match[0][0];
$name = strstr($temp[$i],"<a href=\\"javascript:goMember");
$name = substr($name,0,strpos($name,"</a>")+4);
$name = strip_tags($name);
$read = strstr($temp[$i],"<td bgcolor=\\"#ffffff\\" width=\\"40\\"");
$read = substr($read,0,strpos($read,"</td>")+5);
$read = strip_tags($read);
$date = strstr($temp[$i],"<td bgcolor=\\"#ffffff\\" width=\\"40\\" nowrap align=\\"right\\" valign=\\"top\\"><font size=\\"-1\\">");
$date = substr($date,0,strpos($date,"</td>")+5);
$date = strip_tags($date);
$result[] = $no."QQQQQ".$head."QQQQQ".$subject."QQQQQ".$link."QQQQQ".$comment."QQQQQ".$name."QQQQQ".$read."QQQQQ".$date;
}
return $result;
}
function readURL($url) {
$fp = @fopen($url,"rb");
$file = $fp;
settype($file, boolean);
if ($file) {
while (!feof($fp)) {
$tmp = fgets($fp, 1024);
$temp .= $tmp;
}
fclose($fp);
} else {
$temp = "";
}
return $temp;
}
$cafe = $_POST['cafe'];
$bbs = $_GET['bbs'];
$link = $_GET['link'];
echo"<p>Produced by <a href=\\"http://daum.net\\" target=\\"daum\\">DAUM</a>\\n".
"<form name=\\"CAFE\\" method=\\"post\\" action=\\"".$root[url]."/?CH=daum\\">\\n".
"<table width=\\"100%\\" height=\\"\\" align=\\"center\\">\\n".
"<tr>\\n".
"<td width=\\"100%\\" height=\\"\\" align=\\"left\\">\\n".
"<input type=\\"text\\" name=\\"cafe\\" value=\\"".$cafe."\\" size=\\"30\\">\\n".
"<input type=\\"submit\\" value=\\"가져오기\\">\\n".
"</td>\\n".
"</tr>\\n".
"</table>\\n".
"</form>\\n";
if ($cafe || (!$cafe && $_SESSION['cafe'])) {
if ($cafe) {
$data = daum_cafe_info($cafe);
session_start();
$_SESSION['cafe'] = $data;
}
if (!$cafe && $_SESSION['cafe']) $data = $_SESSION['cafe'];
$data[info] = str_replace("|","",$data[info]);
echo"<li><b>Title</b> : $data[title]\\n".
"<li><b>Introduce</b> : $data[intro]\\n".
"<li><b>Information</b> : $data[info]<p>\\n".
"<li><b>BBS list</b><p>\\n";
for ($i=1; $i<sizeof($data)-2; $i++) {
$temp = split("QQQQQ",$data[$i]);
$temp[1] = str_replace("?","AAAAA",$temp[1]);
$temp[1] = str_replace("&","BBBBB",$temp[1]);
echo"[$i] $temp[0] {<a href=\\"$root[url]/?CH=daum&bbs=$temp[0]&link=$temp[1]\\"><font color=\\"orange\\">list</font></a>}<br>\\n";
}
echo"<p>\\n";
}
if ($bbs) {
$link = str_replace("AAAAA","?",$link);
$link = str_replace("BBBBB","&",$link);
$data = daum_bbs_list($link);
if ($data) {
echo"<p><li><b>$bbs 게시판의 최근글</b><p>\\n".
"<table width=\\"100%\\" align=\\"center\\">\\n";
for ($i=0; $i<sizeof($data); $i++) {
$temp = split("QQQQQ",$data[$i]);
$temp[7] = str_replace(".","",$temp[7]);
echo"<tr>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" $temp[0]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" $temp[1]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" <a href=\\"$temp[3]\\" target=\\"daum\\">$temp[2] $temp[4]</a>\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" $temp[5]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"right\\">\\n".
" $temp[6]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"right\\">\\n".
" $temp[7]\\n".
"</td>\\n".
"</tr>";
} // for
echo "</table><p>\\n";
} else {
echo"<p><li><b>비공개 게시판입니다!</b> {<a href=\\"$link\\" target=\\"daum\\"><font color=\\"orange\\">login</font></a>}<p>\\n";
}
}
?>
<?php
function daum_cafe_info($cafe) {
$url = "http://cafe.daum.net/".$cafe;
$data = readURL($url);
preg_match_all("/<frame name=\\"down\\" id=\\"down\\" src=\\"(http\\:\\/\\/[a-z0-9]+\\.daum\\.net\\/)([a-zA-Z0-9\\:\\/\\._\\?]+)grpid=([a-zA-Z0-9]+)\\"/i",$data,$match);
$host = $match[1][0];
$link = $match[1][0].$match[2][0]."grpid=".$match[3][0];
$grpid = $match[3][0];
$data = readURL($link);
$result[title] = strstr($data,"<font size=\\"3\\" class=\\"cafetitle\\">");
$result[title] = substr($result[title],0,strpos($result[title],"</font>")+7);
$result[title] = strip_tags($result[title]);
$result[intro] = strstr($data,"<font class=\\"cafeintroduce\\">");
$result[intro] = substr($result[intro],0,strpos($result[intro],"</font>")+7);
$result[intro] = strip_tags($result[intro]);
$result[info] = strstr($data,"<font class=\\"cafetitle\\"> 회원수");
$result[info] = substr($result[info],0,strpos($result[info],"운영자</a>"));
$result[info] = strip_tags($result[info]);
$seek = strstr($data,"_c21_/bbs_menu?grpid=".$grpid);
$seek = substr($seek,0,strpos($seek,"log=")+4);
$link = $host.$seek;
$data = readURL($link);
$data = strstr($data,"<!-- 게시판 -->");
$data = substr($data,0,strpos($data,"<!-- 카페ON! -->"));
$temp = split("<td width=\\"155\\">",$data);
for ($i=1;$i<sizeof($temp);$i++) {
$href = strstr($temp[$i],"<a href=\\"javascript:parent.caller");
$href = substr($href,0,strpos($href,"</a>")+4);
$subject = strip_tags($href);
preg_match_all("/javascript\\:parent\\.caller\\(\'\\/(_c21_\\/bbs_list\\?grpid=[a-zA-Z0-9]+\\&fldid=[a-zA-Z0-9]+)\'\\)\\;/i",$href,$match);
$link = $host.$match[1][0];
$result[$i] = $subject."QQQQQ".$link;
}
return $result;
}
function daum_bbs_list($url) {
$data = readURL($url);
$data = strstr($data,"<!-- 게시판 -->");
$data = substr($data,0,strpos($data,"<!-- 검색 -->"));
$temp = split("<td bgcolor=\\"#ffffff\\" nowrap valign=\\"top\\" height=\\"22\\" align=\\"center\\"><font size=\\"-1\\">",$data);
for ($i=1;$i<sizeof($temp);$i++) {
$no = substr($temp[$i],0,strpos($temp[$i],"</font>"));
$head = strstr($temp[$i],"<td bgcolor=\\"#ffffff\\" nowrap valign=\\"top\\"><font size=\\"-1\\">");
$head = substr($head,0,strpos($head,"</td>")+5);
$head = strip_tags($head);
$href = strstr($temp[$i],"<a href=\\"/_c21_/bbs_read?grpid=");
$href = substr($href,0,strpos($href,"</a>")+4);
$subject = strip_tags($href);
$link = strstr($href,"/_c21_/bbs_read?grpid=");
$link = substr($link,0,strpos($link,"\\""));
$temp_url = parse_url($url);
$host = $temp_url[scheme]."://".$temp_url[host];
$link = $host.$link;
preg_match_all("/\\[[0-9]+\\]/i",$temp[$i],$match);
$comment = $match[0][0];
$name = strstr($temp[$i],"<a href=\\"javascript:goMember");
$name = substr($name,0,strpos($name,"</a>")+4);
$name = strip_tags($name);
$read = strstr($temp[$i],"<td bgcolor=\\"#ffffff\\" width=\\"40\\"");
$read = substr($read,0,strpos($read,"</td>")+5);
$read = strip_tags($read);
$date = strstr($temp[$i],"<td bgcolor=\\"#ffffff\\" width=\\"40\\" nowrap align=\\"right\\" valign=\\"top\\"><font size=\\"-1\\">");
$date = substr($date,0,strpos($date,"</td>")+5);
$date = strip_tags($date);
$result[] = $no."QQQQQ".$head."QQQQQ".$subject."QQQQQ".$link."QQQQQ".$comment."QQQQQ".$name."QQQQQ".$read."QQQQQ".$date;
}
return $result;
}
function readURL($url) {
$fp = @fopen($url,"rb");
$file = $fp;
settype($file, boolean);
if ($file) {
while (!feof($fp)) {
$tmp = fgets($fp, 1024);
$temp .= $tmp;
}
fclose($fp);
} else {
$temp = "";
}
return $temp;
}
$cafe = $_POST['cafe'];
$bbs = $_GET['bbs'];
$link = $_GET['link'];
echo"<p>Produced by <a href=\\"http://daum.net\\" target=\\"daum\\">DAUM</a>\\n".
"<form name=\\"CAFE\\" method=\\"post\\" action=\\"".$root[url]."/?CH=daum\\">\\n".
"<table width=\\"100%\\" height=\\"\\" align=\\"center\\">\\n".
"<tr>\\n".
"<td width=\\"100%\\" height=\\"\\" align=\\"left\\">\\n".
"<input type=\\"text\\" name=\\"cafe\\" value=\\"".$cafe."\\" size=\\"30\\">\\n".
"<input type=\\"submit\\" value=\\"가져오기\\">\\n".
"</td>\\n".
"</tr>\\n".
"</table>\\n".
"</form>\\n";
if ($cafe || (!$cafe && $_SESSION['cafe'])) {
if ($cafe) {
$data = daum_cafe_info($cafe);
session_start();
$_SESSION['cafe'] = $data;
}
if (!$cafe && $_SESSION['cafe']) $data = $_SESSION['cafe'];
$data[info] = str_replace("|","",$data[info]);
echo"<li><b>Title</b> : $data[title]\\n".
"<li><b>Introduce</b> : $data[intro]\\n".
"<li><b>Information</b> : $data[info]<p>\\n".
"<li><b>BBS list</b><p>\\n";
for ($i=1; $i<sizeof($data)-2; $i++) {
$temp = split("QQQQQ",$data[$i]);
$temp[1] = str_replace("?","AAAAA",$temp[1]);
$temp[1] = str_replace("&","BBBBB",$temp[1]);
echo"[$i] $temp[0] {<a href=\\"$root[url]/?CH=daum&bbs=$temp[0]&link=$temp[1]\\"><font color=\\"orange\\">list</font></a>}<br>\\n";
}
echo"<p>\\n";
}
if ($bbs) {
$link = str_replace("AAAAA","?",$link);
$link = str_replace("BBBBB","&",$link);
$data = daum_bbs_list($link);
if ($data) {
echo"<p><li><b>$bbs 게시판의 최근글</b><p>\\n".
"<table width=\\"100%\\" align=\\"center\\">\\n";
for ($i=0; $i<sizeof($data); $i++) {
$temp = split("QQQQQ",$data[$i]);
$temp[7] = str_replace(".","",$temp[7]);
echo"<tr>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" $temp[0]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" $temp[1]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" <a href=\\"$temp[3]\\" target=\\"daum\\">$temp[2] $temp[4]</a>\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"left\\">\\n".
" $temp[5]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"right\\">\\n".
" $temp[6]\\n".
"</td>\\n".
"<td width=\\"\\" align=\\"right\\">\\n".
" $temp[7]\\n".
"</td>\\n".
"</tr>";
} // for
echo "</table><p>\\n";
} else {
echo"<p><li><b>비공개 게시판입니다!</b> {<a href=\\"$link\\" target=\\"daum\\"><font color=\\"orange\\">login</font></a>}<p>\\n";
}
}
?>
관련자료
-
링크
댓글 0
등록된 댓글이 없습니다.