error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
#error_reporting(E_ALL & ~E_NOTICE );
ini_set( 'display_errors', "1" );
ini_set( 'display_startup_errors', "1" );
ini_set('session.use_cookies', '1');
session_cache_limiter('private, must-revalidate');
#session_cache_limiter('private_no_expire');
session_start();
// DEFINE一覧
include_once('../../sub_pgm/define.php');
//トラックバック用プログラム
$tb_html .= $entry_id;
#DBの初期処理
sub_db_start();
#テキストデータの場所
$file_txt = FILE_TXT;
#-----------------------------------------------------
$sql = "select entry_text from $file_txt where (`entry_blog_id` = '$blog_id') and (`entry_id` = '$entry_id') limit 1";
$result = mysql_query($sql);
$araycol = mysql_fetch_array( $result, MYSQL_ASSOC );
$html_data = $araycol[entry_text];
#コメントデータの場所
$file_cmt = FILE_CMT;
#-----------------------------------------------------
$sql = "select * from $file_cmt ";
$sql .= " where (comment_blog_id = '$blog_id') and (comment_entry_id = '$entry_id') and (comment_visible = '1') ";
$sql .= " order by comment_id ";
$result = mysql_query($sql);
while( $araycol = mysql_fetch_array( $result, MYSQL_ASSOC ) ){
$com_author[] = $araycol['comment_author'];
$com_email[] = $araycol['comment_email'];
$com_text[] = str_replace("\n", "
", $araycol['comment_text']);
$com_url[] = $araycol['comment_url'];
$com_date[] = $araycol['comment_created_on'];
}
#トラバデータの場所
$file_trb = FILE_TRB;
#-----------------------------------------------------
$sql = "select * from $file_trb ";
$sql .= " where (tbping_blog_id = '$blog_id') and (tbping_tb_id = '$entry_id') and (tbping_visible = '1') ";
$sql .= " order by tbping_id ";
$result = mysql_query($sql);
while( $araycol = mysql_fetch_array( $result, MYSQL_ASSOC ) ){
$tb_text[] = $araycol['tbping_excerpt'];
$tb_url[] = $araycol['tbping_source_url'];
$tb_blog_name[] = $araycol['tbping_blog_name'];
$tb_title[] = $araycol['tbping_title'];
$tb_date[] = $araycol['tbping_created_on'];
}
//-----------------------------------------------------
//SUB DBの初期処理
//-----------------------------------------------------
function sub_db_start(){
$db_name = DF_DB_NAME;
$db_id = DF_DB_ID;
$db_pass = DF_DB_PASS;
$host_name = DF_DB_HOST;
$con = mysql_connect ($host_name, $db_id, $db_pass) or sub_error_page(MSG_DB_OUT);
if ( $con == $FALSE ) {
sub_error_page(MSG_DB_OUT);
}
mysql_select_db($db_name);
mysql_query("SET NAMES utf8");
return $con;
}
?>
//-----------------------------------------------------
//SUB URLが404かどうかを判断する(1のとき、404)
//-----------------------------------------------------
function sub_sonota_url_chk($hp_ad) {
$ret_value = 0;
$head = get_http_header($hp_ad);
$response = $head['Status-Code'];
# if (
# substr($response, 0, 1) != '1' &&
# substr($response, 0, 1) != '2' &&
# substr($response, 0, 1) != '3'
# )
switch($response){
case 'HTML':
$ret_value = 0;
break;
default:
//リンク切れ
$ret_value = 1;
break;
}
# echo "$hp_ad
";
# echo "response,$response
";
return $ret_value;
}
//-----------------------------------------------------
//SUB URLがエラーかどうかを判断する(1のとき、エラー)
//-----------------------------------------------------
function sub_sonota_url_chk_test($hp_ad) {
$ret_value = 0;
$head = get_http_header($hp_ad);
$response = $head['Status-Code'];
# if (
# substr($response, 0, 1) != '1' &&
# substr($response, 0, 1) != '2' &&
# substr($response, 0, 1) != '3'
# )
switch($response){
# case '400':
# case '401':
# case '403':
case '404':
case '420':
case '421':
case '500':
case '503':
//リンク切れ
$ret_value = 1;
break;
default:
$ret_value = 0;
}
# echo "$hp_ad
";
# echo "response,$response
";
return $ret_value;
}
//-----------------------------------------------------
//SUB URLからヘッダーを取得
//-----------------------------------------------------
function get_http_header( $target ) {
// URIから各情報を取得
$info = parse_url( $target );
$scheme = $info['scheme'];
$host = $info['host'];
$port = $info['port'];
$path = $info['path'];
// ポートが空の時はデフォルトの80にします。
if( ! $port ) {
$port = 80;
}
// リクエストフィールドを制作。
$msg_req = "HEAD " . $path . " HTTP/1.0\r\n";
$msg_req .= "Host: $host\r\n";
$msg_req .=
"User-Agent: H2C/1.0\r\n";
$msg_req .= "\r\n";
// スキームがHTTPの時のみ実行
if ( $scheme == 'http' ) {
$status = array();
// 指定ホストに接続。
if ( $handle = @fsockopen( $host, $port, $errno, $errstr, 1 ) ) {
fputs ( $handle, $msg_req );
if ( socket_set_timeout( $handle, 3 ) ) {
$line = 0;
while( ! feof( $handle) ) {
// 1行めはステータスライン
if( $line == 0 ) {
$temp_stat =
explode( ' ', fgets( $handle, 4096 ) );
$status['HTTP-Version'] =
array_shift( $temp_stat );
$status['Status-Code'] = array_shift( $temp_stat );
$status['Reason-Phrase'] =
implode( ' ', $temp_stat );
// 2行目以降はコロンで分割してそれぞれ代入
} else {
$temp_stat =
explode( ':', fgets( $handle, 4096 ) );
$name = array_shift( $temp_stat );
// 通常:の後に1文字半角スペースがあるので除去
$status[ $name ] =
substr( implode( ':', $temp_stat ), 1);
}
$line++;
}
} else {
$status['HTTP-Version'] = '---';
$status['Status-Code'] = '902';
$status['Reason-Phrase'] = "No Response";
}
fclose ( $handle );
} else {
$status['HTTP-Version'] = '---';
$status['Status-Code'] = '901';
$status['Reason-Phrase'] = "Unable To Connect";
}
} else {
$status['HTTP-Version'] = '---';
$status['Status-Code'] = '903';
$status['Reason-Phrase'] = "Not HTTP Request";
}
return $status;
}
?>