Exemplo n.º 1
0
 /**
  * 必死チェッカー対応板を読み込む
  * 自動で読み込まれるので通常は実行する必要はない
  */
 function load()
 {
     global $_conf;
     // include_once P2_LIB_DIR . '/p2util.class.php';
     $url = 'http://hissi.org/menu.html';
     $path = P2Util::cacheFileForDL($url);
     // メニューのキャッシュ時間の10倍キャッシュ
     P2UtilWiki::cacheDownload($url, $path, $_conf['menu_dl_interval'] * 36000);
     $file = @file_get_contents($path);
     preg_match_all('{<a href=http://hissi\\.org/read\\.php/(\\w+?)/>.+?</a><br>}', $file, $boards);
     $this->boards = $boards[1];
 }
Exemplo n.º 2
0
 /**
  * 必死チェッカー対応板を読み込む
  * 自動で読み込まれるので通常は実行する必要はない
  */
 public function load()
 {
     global $_conf;
     $path = P2Util::cacheFileForDL($this->menuUrl);
     // メニューのキャッシュ時間の10倍キャッシュ
     P2UtilWiki::cacheDownload($this->menuUrl, $path, $_conf['menu_dl_interval'] * 36000);
     $this->boards = array();
     $file = @file_get_contents($path);
     if ($file) {
         if (preg_match_all($this->readPattern, $file, $boards)) {
             $this->boards = $boards[1];
         }
     }
 }
Exemplo n.º 3
0
 /**
  * みみずん対応板を読み込む
  */
 public function load($type)
 {
     global $_conf;
     // 対応板の取得
     switch ($type) {
         case 0:
             $url = 'http://mimizun.com/search/2chlive.html';
             $path = $_conf['cache_dir'] . '/search.mimizun.com/2chlive.html';
             $match = '{<input type="checkbox" name="idxname" value="_(.+?)">}';
             break;
         case 1:
             $url = 'http://mimizun.com/search/2ch.html';
             $path = $_conf['cache_dir'] . '/search.mimizun.com/2ch.html';
             $match = '{<input type="checkbox" name="idxname" value="(.+?)">}';
             break;
     }
     // キャッシュ用ディレクトリが無ければ作成
     FileCtl::mkdir_for($path);
     // メニューのキャッシュ時間の10倍キャッシュ
     P2UtilWiki::cacheDownload($url, $path, $_conf['menu_dl_interval'] * 36000);
     $file = @file_get_contents($path);
     preg_match_all($match, $file, $boards);
     return $boards[1];
 }
Exemplo n.º 4
0
 /**
  * NGあぼーんチェック
  */
 public function ngAbornCheck($code, $resfield, $ic = false)
 {
     global $ngaborns;
     //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('ngAbornCheck()');
     if (isset($ngaborns[$code]['data']) && is_array($ngaborns[$code]['data'])) {
         // +Wiki:BEあぼーん
         if ($code == 'aborn_be' || $code == 'ng_be') {
             // プロフィールIDを抜き出す
             if (preg_match('/BE:(\\d+)/', $resfield, $matches)) {
                 $beId = P2UtilWiki::calcBeId((int) $matches[1]);
                 if ($beId === 0) {
                     return false;
                 }
                 $resfield = (string) $beId;
             } else {
                 return false;
             }
         }
         $bbs = $this->thread->bbs;
         $title = $this->thread->ttitle_hc;
         foreach ($ngaborns[$code]['data'] as $k => $v) {
             // 板チェック
             if (isset($v['bbs']) && in_array($bbs, $v['bbs']) == false) {
                 continue;
             }
             // タイトルチェック
             if (isset($v['title']) && stripos($title, $v['title']) === false) {
                 continue;
             }
             // ワードチェック
             // 正規表現
             if ($v['regex']) {
                 $re_method = $v['regex'];
                 /*if ($re_method($v['word'], $resfield, $matches)) {
                       $this->ngAbornUpdate($code, $k);
                       //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()');
                       return p2h($matches[0]);
                   }*/
                 if ($re_method($v['word'], $resfield)) {
                     $this->ngAbornUpdate($code, $k);
                     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()');
                     return $v['cond'];
                 }
                 // +Wiki:BEあぼーん(完全一致)
             } elseif ($code == 'aborn_be' || $code == 'ng_be') {
                 if ($resfield == $v['word']) {
                     $this->ngAbornUpdate($code, $k);
                     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()');
                     return $v['cond'];
                 }
                 // 大文字小文字を無視
             } elseif ($ic || $v['ignorecase']) {
                 if (stripos($resfield, $v['word']) !== false) {
                     $this->ngAbornUpdate($code, $k);
                     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()');
                     return $v['cond'];
                 }
                 // 単純に文字列が含まれるかどうかをチェック
             } else {
                 if (strpos($resfield, $v['word']) !== false) {
                     $this->ngAbornUpdate($code, $k);
                     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()');
                     return $v['cond'];
                 }
             }
         }
     }
     //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()');
     return false;
 }
Exemplo n.º 5
0
 /**
  * Wiki:そのURLにアクセスできるか確認する
  */
 function isURLAccessible($url, $timeout = 7)
 {
     $code = P2UtilWiki::getResponseCode($url);
     return $code == 200 || $code == 206 ? true : false;
 }
Exemplo n.º 6
0
}
if ($popup == 1 || $_conf['expack.spm.ngaborn_confirm'] == 0) {
    $_GET['popup'] = 2;
    $aThread = new ThreadRead();
    $aThread->setThreadPathInfo($host, $bbs, $key);
    $aThread->readDat($aThread->keydat);
    $resar = $aThread->explodeDatLine($aThread->datlines[$resnum - 1]);
    $resar = array_map('trim', $resar);
    $resar = array_map('strip_tags', $resar);
    if (preg_match('/ID: ?([^ ]+?)(?= |$)/', $resar[2], $idar)) {
        $aborn_id = $idar[1];
    } else {
        $aborn_id = '';
    }
    // +Wiki:BEあぼーん
    $aborn_be = preg_match('/BE:(\\d+)/', $resar[2], $idar) ? P2UtilWiki::calcBeId($idar[1]) : '';
    if ($_conf['expack.spm.ngaborn_confirm'] == 0 && !isset($aborn_str)) {
        if ($mode == 'aborn_res') {
            $aborn_str = $host . '/' . $bbs . '/' . $key . '/' . $resnum;
        } elseif (strpos($mode, '_name') !== false) {
            $aborn_str = $resar[0];
        } elseif (strpos($mode, '_mail') !== false) {
            $aborn_str = $resar[1];
        } elseif (strpos($mode, '_id') !== false) {
            $aborn_str = $aborn_id;
        } elseif (strpos($mode, '_msg') !== false) {
            $popup = 1;
            // +Wiki:BEあぼーん
        } elseif (strstr($mode, '_be')) {
            $aborn_str = $aborn_be;
        }
Exemplo n.º 7
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();
                } else {
                    if (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' or 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->data 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 = htmlspecialchars($_GET['kakolog'] . '.html', ENT_QUOTES);
                    $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 = htmlspecialchars($_GET['kakolog'] . '.html', ENT_QUOTES);
            $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;
    }