//g_review
$ver = "0.5";
//copyright 2005 Golbed
//http://golbed.main.jp/
//初期設定
//タイトル
$title = "ずす的review";
//戻り先URL
$home_url = "../";
//アソシエイトID
$amz_id = "zusublog-22";
//コメントを受け付ける
//on = 1
//off = 0
$comment = '0';
//投稿可能文字数(全角)
$comment_len = "400";
//other reviewの★の色
$star_color = "#FF0000";
//other_reviewの表示順
//上から新しい順 = 0
//上から古い順 = 1
$or_order = "0";
//初期設定ここまで。
//////////////////////////////////////
$data_dir = "./data/";
if($_GET['select'] && !$_GET['o_review']){
load_review($title,$data_dir,$ver,$home_url,$amz_id,$comment,$star_color,$or_order);
exit;
}
if($_GET['o_review'] == '1'){
other_review($_GET['select'],$comment_len);
exit;
}
if($_POST['write_o_review'] == '1'){
write_o_review($comment_len);
exit;
}
$new_data = file($data_dir."new.dat");
$r_data = file($data_dir."r_data.dat");
foreach($new_data as $each){
$new_topic .= $each ."
";
}
foreach($r_data as $each){
$ex_r_data = explode('<>',$each);
if($ex_r_data[6] == 1){
$ex_r_data[0] = rtrim($ex_r_data[0]);
$title_sort .= $ex_r_data[0] . "<>";
}
}
//50音sort
$ex_title_sort = explode('<>',$title_sort);
array_multisort($ex_title_sort,SORT_ASC);
foreach($ex_title_sort as $each){
if($each){
$encode_title = rawurlencode($each);
$list_title .= "
" .$each . '
';
}
}
$list_title = "";
$top_html = print <<
$title
$title
■ what's new
$new_topic
■ review title
$list_title
| |
- g_review ver.$ver Script by Golbed - |
|
EOF;
exit;
//'
//レビュー表示
function load_review($title,$data_dir,$ver,$home_url,$amz_id,$comment,$star_color,$or_order){
$r_data = file($data_dir."r_data.dat");
$decode_title = rawurldecode($_GET['select']);
foreach($r_data as $each){
$ex_r_data = explode('<>',$each);
$ex_r_data[0] = rtrim($ex_r_data[0]);
if($decode_title == $ex_r_data[0] && $ex_r_data[6] == 1){
$select_title = $ex_r_data[0];
$select_asin = $ex_r_data[1];
$select_img = $ex_r_data[2];
$select_item_data = $ex_r_data[3];
$select_review_data = $ex_r_data[4];
$select_save_date = $ex_r_data[5];
break;
}
}
if(!$select_title){
error("タイトルが見つからないか、現在は非公開になっています。");
}
//ASINから画像を取得。
if($select_asin && $select_img == ""){
$amz_img = get_amz_img($select_asin);
$amz_url = "http://www.amazon.co.jp/exec/obidos/ASIN/" . $select_asin .'/'. $amz_id ."/ref=nosim";
$output_img = <<
Amazon.co.jpで詳細をみる
EOF;
}else if($select_asin && $select_img){
$amz_url = "http://www.amazon.co.jp/exec/obidos/ASIN/" . $select_asin .'/'. $amz_id ."/ref=nosim";
$output_img = <<
Amazon.co.jpで詳細をみる
EOF;
}else if(!$select_asin && $select_img){
$output_img = <<
EOF;
}
//item_dataの出力判定
if($select_item_data !== ""){
$select_item_data = <<
$select_item_data
|
EOF;
}
//other review受け付け
if($comment == '1'){
$or_data = file($data_dir."or_data.dat");
if(!$or_order){
$or_data = array_reverse($or_data);
}
foreach($or_data as $each){
$ex_or_data = explode('<>',$each);
$ex_or_data[0] = rtrim($ex_or_data[0]);
if($decode_title == $ex_or_data[0]){
$or_title = $ex_or_data[1];
$or_mail = $ex_or_data[2];
$or_name = $ex_or_data[3];
$or_comment = $ex_or_data[4];
$or_point = $ex_or_data[5];
$or_date = $ex_or_data[6];
if($or_mail){
$or_mailto = "$or_name";
}else{
$or_mailto = $or_name;
}
for($p = 0;$p < 5;$p++){
if($or_point > $p){
$point_temp .= "★";
}else{
$point_temp .= "☆";
}
}
$or_html .= <<$or_title name:$or_mailto $or_date
$point_temp - $or_comment
EOF;
$or_mail = "";
$point_temp = "";
}
}
if(!$or_html){
$or_tempurl = rawurlencode($decode_title);
$or_html = "Other Reviewはまだありません。
";
}else{
$or_tempurl = rawurlencode($decode_title);
}
$comment_html = <<
■Other Review |
$or_html ■新規投稿する |
EOF;
}else{
$comment_html = "";
}
$review_html = print <<
$title
$title
$select_title
$output_img
$select_item_data
■Review |
$select_review_data |
$comment_html
| |
- g_review ver.$ver Script by Golbed - |
|
EOF;
exit;
}
//ASINから画像を取得する
function get_amz_img($asin){
$img_data = 'http://images-jp.amazon.com/images/P/' . $asin . '.09.MZZZZZZZ.jpg';
$image_size = getimagesize($img_data);
if($image_size[0] == 1){
$img_data = "http://images-jp.amazon.com/images/G/09/x-locale/detail/thumb-no-image.gif";
}
return($img_data);
}
function other_review($post_or_title,$comment_len){
$post_temptitle = rawurlencode($post_or_title);
$other_review_html = print <<
$post_or_title Review投稿
EOF;
exit;
}
function write_o_review($comment_len){
if(strlen($_POST['por_comment']) > ($comment_len * 2)){
echo "文字数が多すぎます";
exit;
}
if(!$_POST['por_name']){
echo "名前を入力して下さい";
exit;
}else if(!$_POST['por_comment']){
echo "本文を入力して下さい";
exit;
}
if(!$_POST['por_title']){
$_POST['por_title'] = "no title";
}
//magic_quotes_gpc
if (get_magic_quotes_gpc()) {
$_POST['write_o_title'] = stripslashes($_POST['write_o_title']);
$_POST['por_title'] = stripslashes($_POST['por_title']);
$_POST['por_mail'] = stripslashes($_POST['por_mail']);
$_POST['por_name'] = stripslashes($_POST['por_name']);
$_POST['por_comment'] = stripslashes($_POST['por_comment']);
}
$_POST['por_comment'] = str_replace( "\r\n", "\r", $_POST['por_comment']);
$_POST['por_comment'] = str_replace( "\r", "\n", $_POST['por_comment']);
//いろいろ処理
$_POST['por_title'] = str_replace('<','<',$_POST['por_title']);
$_POST['por_title'] = str_replace('>','>',$_POST['por_title']);
$_POST['por_title'] = str_replace("\'",''',$_POST['por_title']);
$_POST['por_title'] = str_replace("\"",'"',$_POST['por_title']);
$_POST['por_title'] = str_replace("\n",'
',$_POST['por_title']);
$_POST['por_mail'] = str_replace('<','<',$_POST['por_mail']);
$_POST['por_mail'] = str_replace('>','>',$_POST['por_mail']);
$_POST['por_mail'] = str_replace("\'",''',$_POST['por_mail']);
$_POST['por_mail'] = str_replace("\"",'"',$_POST['por_mail']);
$_POST['por_mail'] = str_replace("\n",'
',$_POST['por_mail']);
$_POST['por_name'] = str_replace('<','<',$_POST['por_name']);
$_POST['por_name'] = str_replace('>','>',$_POST['por_name']);
$_POST['por_name'] = str_replace("\'",''',$_POST['por_name']);
$_POST['por_name'] = str_replace("\"",'"',$_POST['por_name']);
$_POST['por_name'] = str_replace("\n",'
',$_POST['por_name']);
$_POST['por_comment'] = str_replace('<','<',$_POST['por_comment']);
$_POST['por_comment'] = str_replace('>','>',$_POST['por_comment']);
$_POST['por_comment'] = str_replace("\'",''',$_POST['por_comment']);
$_POST['por_comment'] = str_replace("\"",'"',$_POST['por_comment']);
$_POST['por_comment'] = str_replace("\n",'
',$_POST['por_comment']);
//日付取得
$gmt = time()+9*3600;
$gmt_format = gmdate("Y/m/d H:i", $gmt);
//REMOTE_HOST取得
$env_host = getenv('REMOTE_ADDR');
$dec_por_title = rawurldecode($_POST['write_o_title']);
mt_srand(microtime()*100000);
$token = md5(uniqid(mt_rand(),1));
lockdir('or_data.dat');
$load_file = file('data/or_data.dat');
foreach($load_file as $each){
$each = rtrim($each);
$write_temp .= $each."\n";
}
$write_temp .= $dec_por_title . "<>" .$_POST['por_title'] ."<>". $_POST['por_mail']."<>". $_POST['por_name']."<>". $_POST['por_comment'] ."<>". $_POST['por_point'] ."<>".$gmt_format."<>". $env_host."<>".$token;
$fp = fopen('data/or_data.dat','w');
fwrite($fp,$write_temp);
fclose($fp);
unlockdir('or_data.dat');
refresh_html($dec_por_title);
exit;
}
function refresh_html($jump_url) {
$jump_url = rawurlencode($jump_url);
$html = print <<