GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — p2-php/post.php at 11271101a7aa345ff1b6a67b91cae8e2dec3de8b · unpush/p2-php Expand file tree/ Copy pathpost.phpMore file actions 740 lines (615 loc) · 22.2 KB / Copy pathpost.phpFile metadata and controls740 lines (615 loc) · 22.2 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 <?php /* p2 - レス書き込み */ include_once './conf/conf.inc.php'; require_once P2_LIB_DIR . '/dataphp.class.php'; require_once P2_LIB_DIR . '/filectl.class.php'; $_login->authorize(); // ユーザ認証 if (!empty($_conf['disable_res'])) { P2Util::printSimpleHtml('p2 error: 書き込み機能は無効です。'); die(''); } // 引数エラー if (empty($_POST['host'])) { P2Util::printSimpleHtml('p2 error: 引数の指定が変です'); die(''); } if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId()) { P2Util::printSimpleHtml('p2 error: 不正なポストです'); die(''); } if ($_conf['expack.aas.enabled'] && !empty($_POST['PREVIEW_AAS'])) { include 'aas.php'; exit; } //================================================================ // 変数 //================================================================ $newtime = date('gis'); $post_keys = array( 'FROM','mail','MESSAGE', 'bbs','key','time', 'host','popup','rescount', 'subject','submit', 'sub', 'ttitle_en'); foreach ($post_keys as $pk) { ${$pk} = (isset($_POST[$pk])) ? $_POST[$pk] : ''; } if (!isset($ttitle)) { if ($ttitle_en) { $ttitle = base64_decode($ttitle_en); } elseif ($subject) { $ttitle = $subject; } else { $ttitle = ''; } } //$MESSAGE = rtrim($MESSAGE); // {{{ ソースコードがきれいに再現されるように変換 if (!empty($_POST['fix_source'])) { // タブをスペースに $MESSAGE = tab2space($MESSAGE); // 特殊文字を実体参照に $MESSAGE = htmlspecialchars($MESSAGE, ENT_QUOTES); // 自動URLリンク回避 $MESSAGE = str_replace('tp://', 'tp://', $MESSAGE); // 行頭のスペースを実体参照に $MESSAGE = preg_replace('/^ /m', ' ', $MESSAGE); // 二つ続くスペースの一つ目を実体参照に $MESSAGE = preg_replace('/(?<! ) /', ' ', $MESSAGE); // 奇数回スペースがくり返すときの仕上げ $MESSAGE = preg_replace('/(?<= ) /', ' ', $MESSAGE); } // }}} // {{{ クッキーの読み込み $cookie_file = P2Util::cachePathForCookie($host); if ($cookie_cont = @file_get_contents($cookie_file)) { $p2cookies = unserialize($cookie_cont); if ($p2cookies['expires']) { if (time() > strtotime($p2cookies['expires'])) { // 期限切れなら破棄 // echo "<p>期限切れのクッキーを削除しました</p>"; unlink($cookie_file); unset($cookie_cont, $p2cookies); } } } // }}} // したらばのlivedoor移転に対応。post先をlivedoorとする。 $host = P2Util::adjustHostJbbs($host); // machibbs、JBBS@したらば なら if (P2Util::isHostMachiBbs($host) or P2Util::isHostJbbsShitaraba($host)) { $bbs_cgi = "/bbs/write.cgi"; // JBBS@したらば なら if (P2Util::isHostJbbsShitaraba($host)) { $bbs_cgi = "../../bbs/write.cgi"; preg_match("/(\w+)$/", $host, $ar); $dir = $ar[1]; $dir_k = "DIR"; } $submit_k = "submit"; $bbs_k = "BBS"; $key_k = "KEY"; $time_k = "TIME"; $FROM_k = "NAME"; $mail_k = "MAIL"; $MESSAGE_k = "MESSAGE"; $subject_k = "SUBJECT"; // 2ch } else { if ($sub) { $bbs_cgi = "/test/{$sub}bbs.cgi"; } else { $bbs_cgi = "/test/bbs.cgi"; } $submit_k = "submit"; $bbs_k = "bbs"; $key_k = "key"; $time_k = "time"; $FROM_k = "FROM"; $mail_k = "mail"; $MESSAGE_k = "MESSAGE"; $subject_k = "subject"; } $post_cache = array('bbs' => $bbs, 'key' => $key, 'time' => $time, 'FROM' => $FROM, 'mail' => $mail, 'MESSAGE' => $MESSAGE, 'subject' =>$subject); // submit は書き込むで固定してしまう(Beで書き込むの場合もあるため) $submit = '書き込む'; if (!empty($_POST['newthread'])) { $post = array($submit_k => $submit, $bbs_k => $bbs, $subject_k => $subject, $time_k => $time, $FROM_k => $FROM, $mail_k => $mail, $MESSAGE_k => $MESSAGE); if (P2Util::isHostJbbsShitaraba($host)) { $post[$dir_k] = $dir; } $location_ht = "{$_conf['subject_php']}?host={$host}&bbs={$bbs}{$_conf['k_at_a']}"; } else { $post = array($submit_k => $submit, $bbs_k => $bbs, $key_k => $key, $time_k => $time, $FROM_k => $FROM, $mail_k => $mail, $MESSAGE_k => $MESSAGE); if (P2Util::isHostJbbsShitaraba($host)) { $post[$dir_k] = $dir; } $location_ht = "{$_conf['read_php']}?host={$host}&bbs={$bbs}&key={$key}&ls={$rescount}-&refresh=1&nt={$newtime}{$_conf['k_at_a']}#r{$rescount}"; } // {{{ 2chで●ログイン中ならsid追加 if (!empty($_POST['maru']) and P2Util::isHost2chs($host) && file_exists($_conf['sid2ch_php'])) { // ログイン後、24時間以上経過していたら自動再ログイン if (file_exists($_conf['idpw2ch_php']) and @filemtime($_conf['sid2ch_php']) < time() - 60*60*24) { include_once P2_LIB_DIR . '/login2ch.inc.php'; login2ch(); } include $_conf['sid2ch_php']; $post['sid'] = $SID2ch; } // }}} // 2006/05/27 新仕様? $post['suka'] = 'pontan'; if (!empty($_POST['newthread'])) { $ptitle = "p2 - 新規スレッド作成"; } else { $ptitle = "p2 - レス書き込み"; } //================================================================ // 書き込み処理 //================================================================ //============================================= // ポスト実行 //============================================= $posted = postIt($host, $bbs, $key, $post); //============================================= // cookie 保存 //============================================= FileCtl::make_datafile($cookie_file, $_conf['p2_perm']); // なければ生成 if ($p2cookies) {$cookie_cont = serialize($p2cookies);} if ($cookie_cont) { if (FileCtl::file_write_contents($cookie_file, $cookie_cont) === false) { die("Error: cannot write file."); } } //============================================= // スレ立て成功なら、subjectからkeyを取得 //============================================= if (!empty($_POST['newthread']) && $posted) { sleep(1); $key = getKeyInSubject(); } //============================================= // key.idx 保存 //============================================= // <> を外す。。 $tag_rec['FROM'] = str_replace('<>', '', $FROM); $tag_rec['mail'] = str_replace('<>', '', $mail); // 名前とメール、空白時は P2NULL を記録 $tag_rec_n['FROM'] = ($tag_rec['FROM'] == '') ? 'P2NULL' : $tag_rec['FROM']; $tag_rec_n['mail'] = ($tag_rec['mail'] == '') ? 'P2NULL' : $tag_rec['mail']; if ($host && $bbs && $key) { $idx_host_dir = P2Util::idxDirOfHost($host); $keyidx = $idx_host_dir . '/' . $bbs . '/' . $key . '.idx'; // 読み込み if ($keylines = @file($keyidx)) { $akeyline = explode('<>', rtrim($keylines[0])); } $sar = array($akeyline[0], $akeyline[1], $akeyline[2], $akeyline[3], $akeyline[4], $akeyline[5], $akeyline[6], $tag_rec_n['FROM'], $tag_rec_n['mail'], $akeyline[9], $akeyline[10], $akeyline[11], $akeyline[12]); P2Util::recKeyIdx($keyidx, $sar); // key.idxに記録 } //============================================= // 書き込み履歴 //============================================= if (empty($posted)) { exit; } if ($host && $bbs && $key) { $rh_idx = $_conf['pref_dir'] . '/p2_res_hist.idx'; FileCtl::make_datafile($rh_idx, $_conf['res_write_perm']); // なければ生成 $lines = @file($rh_idx); $neolines = array(); // {{{ 最初に重複要素を削除しておく if (is_array($lines)) { foreach ($lines as $line) { $line = rtrim($line); $lar = explode('<>', $line); if ($lar[1] == $key) { continue; } // 重複回避 if (!$lar[1]) { continue; } // keyのないものは不正データ $neolines[] = $line; } } // }}} // 新規データ追加 $newdata = "$ttitle<>$key<><><><><><>".$tag_rec['FROM'].'<>'.$tag_rec['mail']."<><>$host<>$bbs"; array_unshift($neolines, $newdata); while (sizeof($neolines) > $_conf['res_hist_rec_num']) { array_pop($neolines); } // {{{ 書き込む $temp_file = $rh_idx . '.tmp'; if ($neolines) { $cont = ''; foreach ($neolines as $l) { $cont .= $l . "\n"; } $write_file = strstr(PHP_OS, 'WIN') ? $rh_idx : $temp_file; if (FileCtl::file_write_contents($write_file, $cont) === false) { die('p2 error: cannot write file. ' . __FUNCTION__ . '()'); } if (!strstr(PHP_OS, 'WIN')) { if (!rename($write_file, $rh_idx)) { die("p2 error: " . __FUNCTION__ . "(): cannot rename file."); } } } // }}} } //============================================= // 書き込みログ記録 //============================================= if ($_conf['res_write_rec']) { // データPHP形式(p2_res_hist.dat.php, タブ区切り)の書き込み履歴を、dat形式(p2_res_hist.dat, <>区切り)に変換する P2Util::transResHistLogPhpToDat(); $date_and_id = date("y/m/d H:i"); $message = htmlspecialchars($MESSAGE, ENT_NOQUOTES); $message = preg_replace("/\r?\n/", "<br>", $message); FileCtl::make_datafile($_conf['p2_res_hist_dat'], $_conf['res_write_perm']); // なければ生成 $resnum = ''; if (!empty($_POST['newthread'])) { $resnum = 1; } else { if ($rescount) { $resnum = $rescount + 1; } } // 新規データ $newdata = $tag_rec['FROM'].'<>'.$tag_rec['mail']."<>$date_and_id<>$message<>$ttitle<>$host<>$bbs<>$key<>$resnum"; // まずタブを全て外して(2chの書き込みではタブは削除される 2004/12/13) $newdata = str_replace("\t", '', $newdata); // <>をタブに変換して //$newdata = str_replace('<>', "\t", $newdata); $cont = $newdata."\n"; // 書き込み処理 if (FileCtl::file_write_contents($_conf['p2_res_hist_dat'], $cont, FILE_APPEND) === false) { trigger_error('p2 error: 書き込みログの保存に失敗しました', E_USER_WARNING); // これは実際は表示されないけれども //$_info_msg_ht .= "<p>p2 error: 書き込みログの保存に失敗しました</p>"; } } //=========================================================== // 関数 //=========================================================== /** * レスを書き込む * * @return boolean 書き込み成功なら true、失敗なら false */ function postIt($host, $bbs, $key, $post) { global $_conf, $post_result, $post_error2ch, $p2cookies, $popup, $rescount, $ttitle_en, $STYLE; global $bbs_cgi, $post_cache; $method = "POST"; $bbs_cgi_url = "http://" . $host. $bbs_cgi; $URL = parse_url($bbs_cgi_url); // URL分解 if (isset($URL['query'])) { // クエリー $URL['query'] = "?".$URL['query']; } else { $URL['query'] = ""; } // プロキシ if ($_conf['proxy_use']) { $send_host = $_conf['proxy_host']; $send_port = $_conf['proxy_port']; $send_path = $bbs_cgi_url; } else { $send_host = $URL['host']; $send_port = $URL['port']; $send_path = $URL['path'] . $URL['query']; } if (!$send_port) { $send_port = 80; } // デフォルトを80 $request = $method." ".$send_path." HTTP/1.0\r\n"; $request .= "Host: ".$URL['host']."\r\n"; $add_user_info = "; p2-client-ip: {$_SERVER['REMOTE_ADDR']}"; $httpua_fmt = "Monazilla/1.00 (%s/%s; expack-%s%s)"; $httpua = sprintf($httpua_fmt, $_conf['p2name'], $_conf['p2version'], $_conf['p2expack'], $add_user_info); $request .= "User-Agent: ".$httpua."\r\n"; $request .= 'Referer: http://'.$URL['host'].'/'."\r\n"; // クライアントのIPを送信するp2独自のヘッダ $request .= "p2-Client-IP: ".$_SERVER['REMOTE_ADDR']."/\r\n"; // クッキー $cookies_to_send = ""; if ($p2cookies) { foreach ($p2cookies as $cname => $cvalue) { if ($cname != 'expires') { $cookies_to_send .= " {$cname}={$cvalue};"; } } } // be.2ch.net 認証クッキー if (P2Util::isHostBe2chNet($host) || !empty($_REQUEST['submit_beres'])) { $cookies_to_send .= ' MDMD='.$_conf['be_2ch_code'].';'; // be.2ch.netの認証コード(パスワードではない) $cookies_to_send .= ' DMDM='.$_conf['be_2ch_mail'].';'; // be.2ch.netの登録メールアドレス } if (!$cookies_to_send) { $cookies_to_send = ' ;'; } $request .= 'Cookie:'.$cookies_to_send."\r\n"; //$request .= 'Cookie: PON='.$SPID.'; NAME='.$FROM.'; MAIL='.$mail."\r\n"; $request .= "Connection: Close\r\n"; // {{{ POSTの時はヘッダを追加して末尾にURLエンコードしたデータを添付 if (strtoupper($method) == "POST") { $post_enc = array(); while (list($name, $value) = each($post)) { // したらば or be.2ch.netなら、EUCに変換 if (P2Util::isHostJbbsShitaraba($host) || P2Util::isHostBe2chNet($host)) { $value = mb_convert_encoding($value, 'eucJP-win', 'SJIS-win'); } $post_enc[] = $name."=".urlencode($value); } $postdata = implode("&", $post_enc); $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; $request .= "Content-Length: ".strlen($postdata)."\r\n"; $request .= "\r\n"; $request .= $postdata; } else { $request .= "\r\n"; } // }}} // 書き込みを一時的に保存 $failed_post_file = P2Util::getFailedPostFilePath($host, $bbs, $key); $cont = serialize($post_cache); DataPhp::writeDataPhp($failed_post_file, $cont, $_conf['res_write_perm']); // WEBサーバへ接続 $fp = fsockopen($send_host, $send_port, $errno, $errstr, $_conf['fsockopen_time_limit']); if (!$fp) { showPostMsg(false, "サーバ接続エラー: $errstr ($errno)<br>p2 Error: 板サーバへの接続に失敗しました", false); return false; } //echo '<h4>$request</h4><p>' . $request . "</p>"; //for debug fputs($fp, $request); while (!feof($fp)) { if ($start_here) { while (!feof($fp)) { $wr .= fread($fp, 164000); } $response = $wr; break; } else { $l = fgets($fp, 164000); //echo $l ."<br>"; // for debug $response_header_ht .= $l."<br>"; // クッキーキタ if (preg_match("/Set-Cookie: (.+?)\r\n/", $l, $matches)) { //echo "<p>".$matches[0]."</p>"; // $cgroups = explode(";", $matches[1]); if ($cgroups) { foreach ($cgroups as $v) { if (preg_match("/(.+)=(.*)/", $v, $m)) { $k = ltrim($m[1]); if ($k != "path") { $p2cookies[$k] = $m[2]; } } } } if ($p2cookies) { unset($cookies_to_send); foreach ($p2cookies as $cname => $cvalue) { if ($cname != "expires") { $cookies_to_send .= " {$cname}={$cvalue};"; } } $newcokkies = "Cookie:{$cookies_to_send}\r\n"; $request = preg_replace("/Cookie: .*?\r\n/", $newcokkies, $request); } // 転送は書き込み成功と判断 } elseif (preg_match("/^Location: /", $l, $matches)) { $post_seikou = true; } if ($l == "\r\n") { $start_here = true; } } } fclose($fp); // be.2ch.net or JBBSしたらば 文字コード変換 EUC→SJIS if (P2Util::isHostBe2chNet($host) || P2Util::isHostJbbsShitaraba($host)) { $response = mb_convert_encoding($response, 'SJIS-win', 'eucJP-win'); //<META http-equiv="Content-Type" content="text/html; charset=EUC-JP"> $response = preg_replace("{(<head>.*<META http-equiv=\"Content-Type\" content=\"text/html; charset=)EUC-JP(\">.*</head>)}is", "$1Shift_JIS$2", $response); } $kakikonda_match = "/<title>.*(書きこみました|■ 書き込みました ■|書き込み終了 - SubAll BBS).*<\/title>/is"; $cookie_kakunin_match = "/<!-- 2ch_X:cookie -->|<title>■ 書き込み確認 ■<\/title>|>書き込み確認。</"; if (eregi("(<.+>)", $response, $matches)) { $response = $matches[1]; } // カキコミ成功 if (preg_match($kakikonda_match, $response, $matches) or $post_seikou) { $reload = empty($_POST['from_read_new']); showPostMsg(true, '書きこみが終わりました。', $reload); // 投稿失敗記録を削除 if (file_exists($failed_post_file)) { unlink($failed_post_file); } return true; //$response_ht = htmlspecialchars($response, ENT_QUOTES); //echo "<pre>{$response_ht}</pre>"; // cookie確認(post再チャレンジ) } elseif (preg_match($cookie_kakunin_match, $response, $matches)) { $htm['more_hidden_post'] = ''; $more_hidden_keys = array('newthread', 'submit_beres', 'from_read_new', 'maru', 'csrfid', 'k', 'b'); foreach ($more_hidden_keys as $hk) { if (isset($_POST[$hk])) { $value_hd = htmlspecialchars($_POST[$hk], ENT_QUOTES); $htm['more_hidden_post'] .= "<input type=\"hidden\" name=\"{$hk}\" value=\"{$value_hd}\">\n"; } } $form_pattern = '/<form method=\"?POST\"? action=\"?\\.\\.\\/test\\/(sub)?bbs\\.cgi(?:\\?guid=ON)?\"?>/i'; $form_replace = <<<EOFORM <form method="POST" action="./post.php" accept-charset="{$_conf['accept_charset']}"> <input type="hidden" name="_hint" value="◎◇"> <input type="hidden" name="host" value="{$host}"> <input type="hidden" name="popup" value="{$popup}"> <input type="hidden" name="rescount" value="{$rescount}"> <input type="hidden" name="ttitle_en" value="{$ttitle_en}"> <input type="hidden" name="sub" value="\$1"> {$htm['more_hidden_post']} EOFORM; $response = preg_replace($form_pattern, $form_replace, $response); $h_b = explode("</head>", $response); // HTMLプリント echo $h_b[0]; if (!$_conf['ktai']) { echo <<<EOP <link rel="stylesheet" href="css.php?css=style&skin={$skin_en}" type="text/css"> <link rel="stylesheet" href="css.php?css=post&skin={$skin_en}" type="text/css">\n EOP; } if ($popup) { $mado_okisa = explode(',', $STYLE['post_pop_size']); $mado_okisa_x = $mado_okisa[0]; $mado_okisa_y = $mado_okisa[1] + 200; echo <<<EOSCRIPT <script type="text/javascript"> <!-- resizeTo({$mado_okisa_x},{$mado_okisa_y}); // --> </script> EOSCRIPT; } echo "</head>"; echo $h_b[1]; return false; // その他はレスポンスをそのまま表示 } else { $response = ereg_replace('こちらでリロードしてください。<a href="\.\./[a-z]+/index\.html"> GO! </a><br>', "", $response); echo $response; return false; } } /** * 書き込み処理結果表示する * * @return void */ function showPostMsg($isDone, $result_msg, $reload) { global $_conf, $location_ht, $popup, $STYLE, $ttitle; global $_info_msg_ht; // プリント用変数 =============== if (!$_conf['ktai']) { $class_ttitle = ' class="thre_title"'; } $ttitle_ht = "<b{$class_ttitle}>{$ttitle}</b>"; // 2005/03/01 aki: jigブラウザに対応するため、& ではなく & で // 2005/04/25 rsk: <script>タグ内もCDATAとして扱われるため、&にしてはいけない $location_noenc = preg_replace("/&/", "&", $location_ht); if ($popup) { $popup_ht = <<<EOJS <script type="text/javascript"> <!-- opener.location.href="{$location_noenc}"; var delay= 3*1000; setTimeout("window.close()", delay); // --> </script> EOJS; } else { $meta_refresh_ht = <<<EOP <meta http-equiv="refresh" content="1;URL={$location_noenc}"> EOP; } // プリント ============== echo $_conf['doctype']; echo <<<EOHEADER <html lang="ja"> <head> {$_conf['meta_charset_ht']} <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> {$_conf['extra_headers_ht']} <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> {$meta_refresh_ht} EOHEADER; if ($isDone) { echo " <title>p2 - 書きこみました。</title>"; } else { echo " <title>{$ptitle}</title>"; } if (!$_conf['ktai']) { echo <<<EOP <link rel="stylesheet" href="css.php?css=style&skin={$skin_en}" type="text/css"> <link rel="stylesheet" href="css.php?css=post&skin={$skin_en}" type="text/css">\n EOP; if ($popup) { echo <<<EOSCRIPT <script type="text/javascript"> <!-- resizeTo({$STYLE['post_pop_size']}); // --> </script> EOSCRIPT; } if ($reload) { echo $popup_ht; } } else { $kakunin_ht = <<<EOP <p><a href="{$location_ht}">確認</a></p> EOP; } echo "</head>\n"; echo "<body{$_conf['k_colors']}>\n"; echo $_info_msg_ht; $_info_msg_ht = ""; echo <<<EOP <p>{$ttitle_ht}</p> <p>{$result_msg}</p> {$kakunin_ht} </body> </html> EOP; } /** * subjectからkeyを取得する * * @return string|false */ function getKeyInSubject() { global $host, $bbs, $ttitle; require_once P2_LIB_DIR . '/SubjectTxt.class.php'; $aSubjectTxt =& new SubjectTxt($host, $bbs); foreach ($aSubjectTxt->subject_lines as $l) { if (strstr($l, $ttitle)) { if (preg_match("/^([0-9]+)\.(dat|cgi)(,|<>)(.+) ?(\(|()([0-9]+)(\)|))/", $l, $matches)) { return $key = $matches[1]; } } } return false; } /** * 整形を維持しながら、タブをスペースに置き換える * * @return string */ function tab2space($in_str, $tabwidth = 4, $crlf = "\n") { $out_str = ''; $lines = preg_split('/\r\n|\r|\n/', $in_str); $ln = count($lines); for ($i = 0; $i < $ln; $i++) { $parts = explode("\t", rtrim($lines[$i])); $pn = count($parts); for ($j = 0; $j < $pn; $j++) { if ($j == 0) { $l = $parts[$j]; } else { //$t = $tabwidth - (strlen($l) % $tabwidth); $sn = $tabwidth - (mb_strwidth($l) % $tabwidth); // UTF-8でも全角文字幅を2とカウントする for ($k = 0; $k < $sn; $k++) { $l .= ' '; } $l .= $parts[$j]; } } $out_str .= $l; if ($i + 1 < $ln) { $out_str .= $crlf; } } return $out_str; } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |