岩手日報NewsWEBが連休中にリニューアル

突然、右フレームに表示されなくなったので、急遽調査して対処!
あまり頻繁には変えないでください、お願いします。

<?php
/**
 * Template Name: Get IWATE nippo
 *
 * A custom page template .
 *
 * The "Template Name:" bit above allows this to be selectable
 * from a dropdown menu on the edit page screen.
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */

$data = $_GET['data'];
$site = "岩手日報";
	$base = "http://www.iwate-np.co.jp/";
	$time = "";
	$table = put_dict($base."cgi-bin/../",'<!--岩手のニュース見出し一覧-->','<!-- 被災地/スポーツ/経済 -->','-0');

	if (mb_substr($table,6,3)=="YPE") {
		echo ("<script type='text/javascript'>location.reload(true);</script>");
		exit (0);
	}
	echo ("<head><base href='".$base."'>\n");
?>
<style type="text/css">
<!--
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.st1 { font-size:xx-small; }
.rightMenu{
        width:100%;
}
.rightMenu p.title{
        FONT-SIZE: 12px;
        font-weight: bold;
        color:#330000;
        margin:0;
        padding:3px 5px 3px 10px;
        border:solid 1px #cccccc;
        background-image : url(/s/title.gif);
        background-repeat:no-repeat;
        background-position:3px 5px;
        background-color:#EAEAEA;
        line-height:100%;
}
.news-title{
        font-size: 10px;
       line-height: 130%;
        margin-bottom:15px;
        padding:0px;
        border:solid 1px #CCCCCC;
        border-top:none;
        background-color:#FCFCCC;
}
.news-title:hover{
       FONT-SIZE: 16px;
}
.news-title div{
         padding:0 0 0 15px;
}
.news-title a{
        color:#3f72ff;
/*        color:#364979;
        color:#045271;*/
        margin-bottom: 5px;
	text-decoration:none;
}
.news-title a:visited{
	color:navy;
	text-decoration:none;
}
.news-title a:hover{
	text-decoration: underline;
}
--></style>
	</head>
	<body style="margin-left:-10px; position:relative;"><font color=#b22222><b>
<?php
    echo("&nbsp;&nbsp;".$site.' <a href="/" target="_NEW">'."WebNews</a></font>&nbsp;<font size=-1>&nbsp;&nbsp;".$time."\n<div style='line-height:5px'></div>".$table."</body></html>");

function put_dict($url,$from ,$to, $ton)
{
// print $url."<br>";
    $table = "";
    $pos = 8000;

    $response = wp_remote_get($url, array( 'timeout' => 8, 'user-agent' => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36", 'sslverify' => false));
    if(is_wp_error($response)) {
    // wp_dieで、エラーメッセージを表示し、WordPressの処理を中断する
	    wp_die(esc_html($response->get_error_message()));
    }
    $html_header = 'text/html';
    if(!isset($response['headers']['content-type']) || substr($response['headers']['content-type'],0,9) != $html_header) {
	echo($response['headers']['content-type']);
	wp_die('ヘッダー情報がHTMLではありません。');
    }
    $body = mb_convert_encoding ($response['body'],"utf-8","auto");
	$pos = mb_strpos($body,$from,$pos);
	 if ($pos === false) { return($table.$body); }
	$pos2 = mb_strpos($body,$to,$pos+30);
	 if ($pos2 === false) print "<br>strpos2がfalseを返しました。<br>";
	if (substr($ton,0,1)=="+") {
		$pos2 += mb_strlen($to);
		if (strlen($ton)>1) $pos2 += substr($ton,1);
	}
	else $pos2 += $ton;
    $body = str_replace("<a href","<a target='_NEW' href",
		 mb_substr($body,$pos,$pos2-$pos));
//    $time = mb_substr($body,mb_strpos($body,'<TD align="right">',0)+36,24);
    return (div_cut($body));
}
function div_cut($str) {
    global $time;
	if ($str=="") return "";
	$pos = strpos($str,'<div class="title-right">');
	if ($pos === false) return $str;
	$pos2 = strpos($str,'</div>',$pos);
	if ($pos2 === false) return $str;
	if ($time=="") $time = substr($str,$pos+25,$pos2-$pos-25);
	return substr($str,0,$pos).div_cut(substr($str,$pos2+6));
}
?>
カテゴリー: テスト パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です