프리이미지
사이트 내 전체검색

위젯중 특정 문자 치환하기 (외부게시판 긁어오기)

페이지 정보

작성일15-09-16 15:35

본문

/themes/enfold/template-builder.php 

 

 

$content = apply_filters('the_content', $content);

$content = apply_filters('avf_template_builder_content', $content);

if (get_the_ID()==1108) {

$tmpname="$_SERVER[DOCUMENT_ROOT]/tmp/board.01.tmp";

if ($_GET[recalc] || !is_file($tmpname) || filemtime($tmpname)<time()-5*60) {

@include "$_SERVER[DOCUMENT_ROOT]/ar.int.contents.php";

fflush();

clearstatcache();

}

 

for($i=1;$i<=4;$i++) {

$content=str_replace("{board_0$i}",@file_get_contents($tmpname),$content);

}

}

echo $content;

 

 

 

 

ar.int.contents.php 내용은..

 

 

 

<?

 

if (!function_exists('get_content_url_fsock')) {

 

function get_content_url_fsock($url) {

$url=str_ireplace("http://","",$url);

if (!strstr($url,'/')) $url.="/";

$pos=strpos($url,"/");

$host=substr($url,0,$pos);

$turl=substr($url,$pos);

$fp = fsockopen($host, 80, $errno, $errstr, 5);   

if(!$fp) {   

return "fsockopen Error";   

} else {   

fputs($fp, "GET ".$turl." HTTP/1.0\r\n");   

fputs($fp, "Host: ".$host."\r\n");   

fputs($fp,"User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36\r\n");

fputs($fp, "\r\n");  

$is_body=false;

while(!feof($fp)) { // 파일 포인터의 끝까지    

$temp = fgets($fp, 4096); // 한줄씩 읽습니다   

//echo "$is_body $temp";

if ($is_body) $contents.= $temp; 

if ($temp=="\r\n") $is_body=true;

}   

fclose($fp);   

return $contents;

}

 

 

 

 

 

}

if (!function_exists('get_content_url')) {

function get_content_url($url)

{

$ch = curl_init();

 

curl_setopt ($ch, CURLOPT_URL, $url);

curl_setopt ($ch, CURLOPT_HEADER, 0);

 

ob_start();

 

curl_exec ($ch);

curl_close ($ch);

$string = ob_get_contents();

 

ob_end_clean();

return $string;     

}

}

 

$file=basename(__FILE__);

$path="$_SERVER[DOCUMENT_ROOT]/tmp";

if (!is_dir($path)) mkdir($path,0777);

if ($show_proc) echo "<xmp>";

for($i=1;$i<=5;$i++) {

$tmp_filename="$_SERVER[DOCUMENT_ROOT]/tmp/board.0$i.tmp";

$url="http://가져올 사이트 /ar.get_latest.php?bo_table=$i";

if ($show_proc) echo $url;

$buff=get_content_url_fsock($url);

file_put_contents($tmp_filename,$buff);

chmod($tmp_filename,0777);

if ($show_proc) echo "$tmp_filename\n$buff\n\n";

 

}

 

?>

게시물 검색