/** * コンストラクタ */ public function __construct($host, $bbs) { $this->host = $host; $this->bbs = $bbs; $this->storage = 'file'; $this->subject_file = P2Util::datDirOfHostBbs($host, $bbs) . 'subject.txt'; $this->subject_url = 'http://' . $host . '/' . $bbs . '/subject.txt'; // したらばのlivedoor移転に対応。読込先をlivedoorとする。 $this->subject_url = P2Util::adjustHostJbbs($this->subject_url); // subject.txtをダウンロード&セットする $this->dlAndSetSubject(); }
// }}} // {{{ HTTPヘッダ P2Util::header_nocache(); header('Content-Type: text/plain; charset=UTF-8'); // }}} // {{{ 初期化 $post_param_keys = array('bbs', 'key', 'time', 'FROM', 'mail', 'MESSAGE', 'subject', 'submit'); $post_internal_keys = array('host', 'sub', 'popup', 'rescount', 'ttitle_en'); foreach ($post_param_keys as $pk) { ${$pk} = isset($_POST[$pk]) ? mb_convert_encoding($_POST[$pk], 'CP932', 'UTF-8') : ''; } foreach ($post_internal_keys as $pk) { ${$pk} = isset($_POST[$pk]) ? $_POST[$pk] : ''; } // したらばのlivedoor移転に対応。post先をlivedoorとする。 $host = P2Util::adjustHostJbbs($host); // machibbs、JBBS@したらば なら if (P2Util::isHostMachiBbs($host) or P2Util::isHostJbbsShitaraba($host)) { /* compact() と array_combine() でPOSTする値の配列を作るので、 $post_param_keys と $post_send_keys の値の順序は揃える! */ //$post_param_keys = array('bbs', 'key', 'time', 'FROM', 'mail', 'MESSAGE', 'subject', 'submit'); $post_send_keys = array('BBS', 'KEY', 'TIME', 'NAME', 'MAIL', 'MESSAGE', 'SUBJECT', 'submit'); // 2ch } else { $post_send_keys = $post_param_keys; } $post = array_combine($post_send_keys, compact($post_param_keys)); unset($post['submit']); // }}} // {{{ execute $post_backup_key = PostDataStore::getKeyForBackup($host, $bbs, $key, !empty($_REQUEST['newthread']));
/** * 元スレURLを返す * * @param bool $force_pc trueなら携帯モードでもPC用の元スレURLを返す * @param string $ls レス表示番号or範囲。nullならlsプロパティを使う * 掲示板によっては無視される場合もある * @return string 元スレURL */ public function getMotoThread($force_pc = false, $ls = null) { global $_conf; if ($force_pc) { $mobile = false; } elseif ($_conf['iphone']) { $mobile = false; } elseif ($_conf['ktai']) { $mobile = true; } else { $mobile = false; } if ($ls === null) { $ls = $this->ls; } // 2ch系 if (P2Util::isHost2chs($this->host)) { // PC if (!$mobile) { $motothre_url = "http://{$this->host}/test/read.cgi/{$this->bbs}/{$this->key}/{$ls}"; // 携帯 } else { if (P2Util::isHostBbsPink($this->host)) { //$motothre_url = "http://{$this->host}/test/r.i/{$this->bbs}/{$this->key}/{$ls}"; $motothre_url = "http://speedo.ula.cc/test/r.so/{$this->host}/{$this->bbs}/{$this->key}/{$ls}"; } else { $mail = rawurlencode($_conf['my_mail']); // c.2chはl指定に非対応なので、代わりにn $ls = substr($ls, 0, 1) == 'l' ? 'n' : $ls; $motothre_url = "http://c.2ch.net/test/--3!mail={$mail}/{$this->bbs}/{$this->key}/{$ls}"; } } // まちBBS } elseif (P2Util::isHostMachiBbs($this->host)) { if ($mobile) { $motothre_url = "http://{$this->host}/bbs/read.pl?IMODE=TRUE&BBS={$this->bbs}&KEY={$this->key}"; } else { $motothre_url = "http://{$this->host}/bbs/read.cgi/{$this->bbs}/{$this->key}/{$ls}"; } // まちびねっと } elseif (P2Util::isHostMachiBbsNet($this->host)) { $motothre_url = "http://{$this->host}/test/read.cgi?bbs={$this->bbs}&key={$this->key}"; if ($mobile) { $motothre_url .= '&imode=true'; } // JBBSしたらば } elseif (P2Util::isHostJbbsShitaraba($this->host)) { list($host, $category) = explode('/', P2Util::adjustHostJbbs($this->host), 2); $bbs_cgi = $mobile ? 'i.cgi' : 'read.cgi'; $motothre_url = "http://{$host}/bbs/{$bbs_cgi}/{$category}/{$this->bbs}/{$this->key}/{$ls}"; // その他 } else { $motothre_url = "http://{$this->host}/test/read.cgi/{$this->bbs}/{$this->key}/{$ls}"; } return $motothre_url; }
/** * したらばJBBSの rawmode.cgi を読んで、datに保存する(2ch風に整形) */ function shitarabaDownload(ThreadRead $aThread) { $GLOBALS['machi_latest_num'] = ''; // {{{ 既得datの取得レス数が適性かどうかを念のためチェック if (file_exists($aThread->keydat)) { $dls = FileCtl::file_read_lines($aThread->keydat); if (!$dls || sizeof($dls) != $aThread->gotnum) { // echo 'bad size!<br>'; unlink($aThread->keydat); $aThread->gotnum = 0; } } else { $aThread->gotnum = 0; } // }}} if ($aThread->gotnum == 0) { $file_append = false; $START = 1; } else { $file_append = true; $START = $aThread->gotnum + 1; } // JBBS@したらば if (P2Util::isHostJbbsShitaraba($aThread->host)) { // したらばのlivedoor移転に対応。読込先をlivedoorとする。 $host = P2Util::adjustHostJbbs($aThread->host); list($host, $category, ) = explode('/', $host); $machiurl = "http://{$host}/bbs/rawmode.cgi/{$category}/{$aThread->bbs}/{$aThread->key}/{$START}-"; } $tempfile = $aThread->keydat . '.dat.temp'; FileCtl::mkdirFor($tempfile); $machiurl_res = P2Util::fileDownload($machiurl, $tempfile); if ($machiurl_res->isError()) { $aThread->diedat = true; return false; } // {{{ したらばならEUCをSJISに変換 if (P2Util::isHostJbbsShitaraba($aThread->host)) { $temp_data = FileCtl::file_read_contents($tempfile); $temp_data = mb_convert_encoding($temp_data, 'CP932', 'CP51932'); if (FileCtl::file_write_contents($tempfile, $temp_data) === false) { p2die('cannot write file.'); } } // }}} $mlines = FileCtl::file_read_lines($tempfile); // 一時ファイルを削除する unlink($tempfile); // ↓rawmode.cgiではこれは出ないだろう /* // (JBBS)ERROR!: スレッドがありません。過去ログ倉庫にもありません。 if (stripos($mlines[0], 'ERROR') === 0) { $aThread->getdat_error_msg_ht .= $mlines[0]; $aThread->diedat = true; return false; } */ // {{{ DATを書き込む if ($mdatlines = shitarabaDatTo2chDatLines($mlines)) { $file_append = $file_append ? FILE_APPEND : 0; $cont = ''; for ($i = $START; $i <= $GLOBALS['machi_latest_num']; $i++) { if ($mdatlines[$i]) { $cont .= $mdatlines[$i]; } else { $cont .= "あぼーん<>あぼーん<>あぼーん<>あぼーん<>\n"; } } if (FileCtl::file_write_contents($aThread->keydat, $cont, $file_append) === false) { p2die('cannot write file.'); } } // }}} $aThread->isonline = true; return true; }