Beispiel #1
0
    /**
     * 2chのdatを取得できなかった原因を返す
     *
     * @return  string エラーメッセージ(原因がわからない場合は空で返す)
     */
    public function get2chDatError($code = null)
    {
        global $_conf;
        // ホスト移転検出で変更したホストを元に戻す
        if (!empty($this->old_host)) {
            $this->host = $this->old_host;
            $this->old_host = null;
        }
        $reason = null;
        if ($code == '302') {
            $body203 = $this->_get2ch203Body();
            if ($body203 !== false && preg_match('/過去ログ ★/', $body203)) {
                $this->getdat_error_body = $body203;
                if (preg_match('/このスレッドは過去ログ倉庫に格.{1,2}されています/', $body203)) {
                    $reason = 'datochi';
                    $this->setDatochiResiduums();
                } elseif (preg_match('{http://[^/]+/[^/]+/kako/\\d+(/\\d+)?/(\\d+)\\.html}', $body203, $matches)) {
                    $reason = 'kakohtml';
                }
            }
        }
        $read_url = "http://{$this->host}/test/read.cgi/{$this->bbs}/{$this->key}/";
        // {{{ read.cgi からHTMLを取得
        $read_response_html = '';
        if (!$reason) {
            $wap_ua = new WapUserAgent();
            $wap_ua->setAgent($_conf['p2ua']);
            // ここは、"Monazilla/" をつけるとNG
            $wap_ua->setTimeout($_conf['http_conn_timeout'], $_conf['http_read_timeout']);
            $wap_req = new WapRequest();
            $wap_req->setUrl($read_url);
            if ($_conf['proxy_use']) {
                $wap_req->setProxy($_conf['proxy_host'], $_conf['proxy_port']);
            }
            $wap_res = $wap_ua->request($wap_req);
            if ($wap_res->isError()) {
                $url_t = P2Util::throughIme($wap_req->url);
                $info_msg_ht = "<p class=\"info-msg\">Error: {$wap_res->code} {$wap_res->message}<br>";
                $info_msg_ht .= "rep2 info: <a href=\"{$url_t}\"{$_conf['ext_win_target_at']}>{$wap_req->url}</a> に接続できませんでした。</p>";
                P2Util::pushInfoHtml($info_msg_ht);
            } else {
                $read_response_html = $wap_res->content;
            }
            unset($wap_ua, $wap_req, $wap_res);
        }
        // }}}
        // {{{ 取得したHTML($read_response_html)を解析して、原因を見つける
        $dat_response_status = '';
        $dat_response_msg = '';
        $kakosoko_match = "/このスレッドは過去ログ倉庫に格.{1,2}されています/";
        $naidesu_match = "/<title>そんな板orスレッドないです。<\\/title>/";
        $error3939_match = "{<title>2ちゃんねる error 3939</title>}";
        // 過去ログ倉庫でhtml化の時(他にもあるかも、よく知らない)
        //<a href="http://qb5.2ch.net/sec2chd/kako/1091/10916/1091634596.html">
        //<a href="../../../../mac/kako/1004/10046/1004680972.html">
        //$kakohtml_match = "{<a href=\"\.\./\.\./\.\./\.\./([^/]+/kako/\d+(/\d+)?/(\d+)).html\">}";
        $kakohtml_match = "{/([^/]+/kako/\\d+(/\\d+)?/(\\d+)).html\">}";
        $waithtml_match = "/html化されるのを待っているようです。/";
        //
        // <title>がこのスレッドは過去ログ倉庫に
        //
        if ($reason === 'datochi' || preg_match($kakosoko_match, $read_response_html, $matches)) {
            $dat_response_status = "このスレッドは過去ログ倉庫に格納されています。";
            //if (file_exists($_conf['idpw2ch_php']) || file_exists($_conf['sid2ch_php'])) {
            $marutori_ht = " [<a href=\"{$_conf['read_php']}?host={$this->host}&amp;bbs={$this->bbs}&amp;key={$this->key}&amp;ls={$this->ls}&amp;maru=true{$_conf['k_at_a']}\">●IDでrep2に取り込む</a>]";
            //} else {
            //    $marutori_ht = " [<a href=\"login2ch.php\" target=\"subject\">●IDログイン</a>]";
            //}
            // +Wiki
            if ($_GET['plugin']) {
                $datPlugin = new DatPluginCtl();
                $datPlugin->load();
                foreach ($datPlugin->getData() as $v) {
                    if (preg_match('{' . $v['match'] . '}', $read_url)) {
                        $replace = @preg_replace('{' . $v['match'] . '}', $v['replace'], $read_url);
                        $code = P2UtilWiki::getResponseCode($replace);
                        if ($code == 200) {
                            $code = '○' . $code;
                        } else {
                            $code = '×' . $code;
                        }
                        $plugin_ht .= "    <option value=\"{$replace}\">{$code}:{$v['title']}</option>\n";
                    }
                }
                if ($plugin_ht) {
                    $plugin_ht = '<select size=1 name="kakolog">' . $plugin_ht . '</select>';
                } else {
                    $plugin_ht = '<input type="text" name="kakolog" size="64">';
                }
                $plugin_ht .= 'から<input type="submit" name="kakoget" value="取得">';
            } else {
                $plugin_ht = '<input type="submit" name="plugin" value="DATを探す">';
            }
            $plugin_ht = <<<EOP
<form method="get" action="{$_conf['read_php']}">
    <input type="hidden" name="host" value="{$this->host}">
    <input type="hidden" name="bbs" value="{$this->bbs}">
    <input type="hidden" name="key" value="{$this->key}">
    <input type="hidden" name="ls" value="{$this->ls}">
    <input type="hidden" name="kakoget" value="2">
    {$_conf['k_input_ht']}
{$plugin_ht}
</form>
EOP;
            $moritori_ht = $this->_generateMoritapoDatLink();
            $dat_response_msg = "<p>2ch info - このスレッドは過去ログ倉庫に格納されています。{$marutori_ht}{$moritori_ht}{$plugin_ht}</p>";
            //
            // <title>がそんな板orスレッドないです。or error 3939
            //
        } elseif ($reason === 'kakohtml' or preg_match($naidesu_match, $read_response_html, $matches) || preg_match($error3939_match, $read_response_html, $matches)) {
            if ($reason === 'kakohtml' or preg_match($kakohtml_match, $read_response_html, $matches)) {
                if ($reason === 'kakohtml') {
                    preg_match('{/([^/]+/kako/\\d+(/\\d+)?/(\\d+)).html}', $this->getdat_error_body, $matches);
                }
                $dat_response_status = "隊長! 過去ログ倉庫で、html化されたスレッドを発見しました。";
                $kakolog_uri = "http://{$this->host}/{$matches[1]}";
                $kakolog_url_en = rawurlencode($kakolog_uri);
                $read_kako_url = "{$_conf['read_php']}?host={$this->host}&amp;bbs={$this->bbs}&amp;key={$this->key}&amp;ls={$this->ls}&amp;kakolog={$kakolog_url_en}&amp;kakoget=1";
                $dat_response_msg = "<p>2ch info - 隊長! 過去ログ倉庫で、<a href=\"{$kakolog_uri}.html\"{$_conf['bbs_win_target_at']}>スレッド {$matches[3]}.html</a> を発見しました。 [<a href=\"{$read_kako_url}\">rep2に取り込んで読む</a>]</p>";
            } elseif (preg_match($waithtml_match, $read_response_html, $matches)) {
                $dat_response_status = "隊長! スレッドはhtml化されるのを待っているようです。";
                $marutori_ht = " [<a href=\"{$_conf['read_php']}?host={$this->host}&amp;bbs={$this->bbs}&amp;key={$this->key}&amp;ls={$this->ls}&amp;maru=true{$_conf['k_at_a']}\">●IDでrep2に取り込む</a>]";
                $moritori_ht = $this->_generateMoritapoDatLink();
                $dat_response_msg = "<p>2ch info - 隊長! スレッドはhtml化されるのを待っているようです。{$marutori_ht}{$moritori_ht}</p>";
            } else {
                if (!empty($_GET['kakolog'])) {
                    $dat_response_status = 'そんな板orスレッドないです。';
                    $kako_html_url = p2h($_GET['kakolog'] . '.html');
                    $kakolog_query = rawurlencode($_GET['kakolog']);
                    $read_kako_url = "{$_conf['read_php']}?host={$this->host}&amp;bbs={$this->bbs}&amp;key={$this->key}&amp;ls={$this->ls}&amp;kakolog={$kakolog_query}&amp;kakoget=1";
                    $dat_response_msg = '<p>2ch info - そんな板orスレッドないです。</p>';
                    $dat_response_msg .= "<p><a href=\"{$kako_html_url}\"{$_conf['bbs_win_target_at']}>{$kako_html_url}</a> [<a href=\"{$read_kako_url}\">rep2にログを取り込んで読む</a>]</p>";
                } else {
                    $dat_response_status = 'そんな板orスレッドないです。';
                    $dat_response_msg = '<p>2ch info - そんな板orスレッドないです。</p>';
                }
            }
            // 原因が分からない場合でも、とりあえず過去ログ取り込みのリンクを維持している。と思う。あまり覚えていない 2005/2/27 aki
        } elseif (!empty($_GET['kakolog'])) {
            $dat_response_status = '';
            $kako_html_url = p2h($_GET['kakolog'] . '.html');
            $kakolog_query = rawurlencode($_GET['kakolog']);
            $read_kako_url = "{$_conf['read_php']}?host={$this->host}&amp;bbs={$this->bbs}&amp;key={$this->key}&amp;ls={$this->ls}&amp;kakolog={$kakolog_query}&amp;kakoget=1";
            $dat_response_msg = "<p><a href=\"{$kako_html_url}\"{$_conf['bbs_win_target_at']}>{$kako_html_url}</a> [<a href=\"{$read_kako_url}\">rep2にログを取り込んで読む</a>]</p>";
        }
        // }}}
        return $dat_response_msg;
    }
Beispiel #2
0
/*
    p2 - DAT取得プラグイン編集インタフェース
*/
require_once __DIR__ . '/../init.php';
require_once P2_LIB_DIR . '/wiki/DatPluginCtl.php';
$_login->authorize();
// ユーザ認証
if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) {
    if (!isset($_POST['csrfid']) || $_POST['csrfid'] != P2Util::getCsrfId()) {
        die('p2 error: 不正なポストです');
    }
}
//=====================================================================
// 前処理
//=====================================================================
$datPluginCtl = new DatPluginCtl();
// [保存]ボタン
if (!empty($_POST['submit_save'])) {
    if ($datPluginCtl->save($_POST['dat']) !== false) {
        $_info_msg_ht .= '<p>○設定を更新保存しました</p>';
    } else {
        $_info_msg_ht .= '<p>×設定を更新保存できませんでした</p>';
    }
    // [リストを空にする]ボタン
} elseif (!empty($_POST['submit_default'])) {
    if ($datPluginCtl->clear()) {
        $_info_msg_ht .= '<p>○リストを空にしました</p>';
    } else {
        $_info_msg_ht .= '<p>×リストを空にできませんでした</p>';
    }
}
Beispiel #3
0
    p2 - DAT取得プラグイン編集インタフェース
*/
include_once './conf/conf.inc.php';
require_once P2_LIB_DIR . '/FileCtl.php';
require_once P2_LIB_DIR . '/wiki/datpluginctl.class.php';
$_login->authorize();
// ユーザ認証
if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) {
    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId()) {
        die('p2 error: 不正なポストです');
    }
}
//=====================================================================
// 前処理
//=====================================================================
$datplugin = new DatPluginCtl();
// [保存]ボタン
if (!empty($_POST['submit_save'])) {
    if ($datplugin->save($_POST['dat']) !== FALSE) {
        $_info_msg_ht .= "<p>○設定を更新保存しました</p>";
    } else {
        $_info_msg_ht .= "<p>×設定を更新保存できませんでした</p>";
    }
    // [リストを空にする]ボタン
} elseif (!empty($_POST['submit_default'])) {
    if ($datplugin->clear()) {
        $_info_msg_ht .= "<p>○リストを空にしました</p>";
    } else {
        $_info_msg_ht .= "<p>×リストを空にできませんでした</p>";
    }
}