Beispiel #1
0
/**
 * スレッドを指定する
 *
 * @return  array|false
 */
function _detectThread()
{
    global $_conf;
    $ls = null;
    $url = null;
    // スレURLの直接指定
    if (($url = geti($_GET['nama_url'])) || ($url = geti($_GET['url']))) {
        $url = trim($url);
        // 2ch or pink http://choco.2ch.net/test/read.cgi/event/1027770702/
        if (preg_match('{http://([^/]+\\.(2ch\\.net|bbspink\\.com|machibbs\\.com|machi\\.to))/test/read\\.cgi/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = geti($matches[5]);
            // c-docomo c-au c-other http://c-au.2ch.net/test/--3!mail=sage/operate/1159594301/519-n
        } elseif (preg_match('{http://((c-docomo|c-au|c-other)\\.2ch\\.net)/test/([^/]+)/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $m)) {
            require_once P2_LIB_DIR . '/BbsMap.php';
            if ($mapped_host = BbsMap::get2chHostByBbs($m[4])) {
                $host = $mapped_host;
                $bbs = $m[4];
                $key = $m[5];
                $ls = geti($m[6]);
            }
            // 2ch, pink, vip2ch.com 過去ログhtml - http://pc.2ch.net/mac/kako/1015/10153/1015358199.html
        } elseif (preg_match('{(http://([^/]+\\.(2ch\\.net|bbspink\\.com|vip2ch\\.com))(/[^/]+)?/([^/]+)/kako/\\d+(/\\d+)?/(\\d+)).html}', $url, $matches)) {
            $host = $matches[2];
            $bbs = $matches[5];
            $key = $matches[7];
            $kakolog_uri = $matches[1];
            $_GET['kakolog'] = $kakolog_uri;
            // 新まちBBS http://tohoku.machi.to/bbs/read.cgi/touhoku/1179407635/l50
        } elseif (preg_match('{http://([^/]+\\.(2ch\\.net|bbspink\\.com|machibbs\\.com|machi\\.to))/bbs/read\\.cgi/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = geti($matches[5]);
            // (旧)まちBBS http://kanto.machibbs.com/bbs/read.pl?BBS=kana&KEY=1034515019
        } elseif (preg_match('{http://([^/]+\\.machibbs\\.com|[^/]+\\.machi\\.to)/bbs/read\\.(pl|cgi)\\?BBS=([^&]+)&KEY=([0-9]+)(&START=([0-9]+))?(&END=([0-9]+))?[^\\"]*}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = geti($matches[6]) . '-' . geti($matches[8]);
            // したらばJBBS(旧まちBBSと類似形式)
        } elseif (preg_match('{http://((jbbs\\.livedoor\\.jp|jbbs\\.livedoor.com|jbbs\\.shitaraba\\.com)(/[^/]+)?)/bbs/read\\.(pl|cgi)\\?BBS=([^&]+)&KEY=([0-9]+)(&START=([0-9]+))?(&END=([0-9]+))?[^"]*}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[5];
            $key = $matches[6];
            $ls = geti($matches[8]) . '-' . geti($matches[10]);
            // したらばJBBS(2ch類似形式) http://jbbs.livedoor.com/bbs/read.cgi/computer/2999/1081177036/-100
        } elseif (preg_match('{http://(jbbs\\.livedoor\\.jp|jbbs\\.livedoor.com|jbbs\\.shitaraba\\.com)/bbs/read\\.cgi/(\\w+)/(\\d+)/(\\d+)/((\\d+)?-(\\d+)?)?[^"]*}', $url, $matches)) {
            $host = $matches[1] . '/' . $matches[2];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = geti($matches[5]);
            // チャットちゃんねる http://cha2.net/cgi-bin/test/read.cgi/anitoku/1241688251/l50
        } elseif (preg_match('{http://(cha2\\.net)/cgi-bin/test/read\\.cgi/(\\w+)/(\\d+)/?([^/]+)?}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[2];
            $key = $matches[3];
            $ls = geti($matches[4]);
            // 外部板 read.cgi 形式 http://ex14.vip2ch.com/test/read.cgi/operate/1161701941/
        } elseif (preg_match('{http://([^/]+)/test/read\\.cgi/(\\w+)/(\\d+)/?([^/]+)?}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[2];
            $key = $matches[3];
            $ls = geti($matches[4]);
        }
    } else {
        !empty($_GET['host']) and $host = $_GET['host'];
        // "pc.2ch.net"
        !empty($_POST['host']) and $host = $_POST['host'];
        isset($_GET['bbs']) and $bbs = $_GET['bbs'];
        // "php"
        isset($_POST['bbs']) and $bbs = $_POST['bbs'];
        isset($_GET['key']) and $key = $_GET['key'];
        // "1022999539"
        isset($_POST['key']) and $key = $_POST['key'];
        !empty($_GET['ls']) and $ls = $_GET['ls'];
        // "all"
        !empty($_POST['ls']) and $ls = $_POST['ls'];
    }
    if (empty($host) || !isset($bbs) || !isset($key)) {
        $err = $_conf['read_php'] . ' スレッドの指定が変です。';
        $msg = null;
        if ($url) {
            if (preg_match('/^http/', $url)) {
                $msg = sprintf('<a href="%1$s">%1$s</a>', hs($url));
            } else {
                $msg = hs($url);
            }
        }
        p2die($err, $msg);
    }
    if (P2Validate::host($host) || P2Validate::bbs($bbs) || P2Validate::key($key)) {
        p2die('不正な引数です');
    }
    return array($host, $bbs, $key, $ls);
}
Beispiel #2
0
/**
 * スレッドを指定する
 *
 * @return  array|false
 */
function detectThread()
{
    global $_conf;
    $ls = null;
    // スレURLの直接指定
    if ((isset($_GET['nama_url']) and $url = $_GET['nama_url']) || (isset($_GET['url']) and $url = $_GET['url'])) {
        $url = trim($url);
        // 2ch or pink - http://choco.2ch.net/test/read.cgi/event/1027770702/
        if (preg_match('{http://([^/]+\\.(2ch\\.net|bbspink\\.com))/test/read\\.cgi/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = $matches[5];
            // c-docomo c-au c-other http://c-au.2ch.net/test/--3!mail=sage/operate/1159594301/519-n
        } elseif (preg_match('{http://((c-docomo|c-au|c-other)\\.2ch\\.net)/test/([^/]+)/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $m)) {
            require_once P2_LIB_DIR . '/BbsMap.class.php';
            if ($mapped_host = BbsMap::get2chHostByBbs($m[4])) {
                $host = $mapped_host;
                $bbs = $m[4];
                $key = $m[5];
                $ls = $m[6];
            }
            // 2ch or pink 過去ログhtml - http://pc.2ch.net/mac/kako/1015/10153/1015358199.html
        } elseif (preg_match("/(http:\\/\\/([^\\/]+\\.(2ch\\.net|bbspink\\.com))(\\/[^\\/]+)?\\/([^\\/]+)\\/kako\\/\\d+(\\/\\d+)?\\/(\\d+)).html/", $url, $matches)) {
            //2ch pink 過去ログhtml
            $host = $matches[2];
            $bbs = $matches[5];
            $key = $matches[7];
            $kakolog_uri = $matches[1];
            $_GET['kakolog'] = urlencode($kakolog_uri);
            // まち&したらばJBBS - http://kanto.machibbs.com/bbs/read.pl?BBS=kana&KEY=1034515019
        } elseif (preg_match("/http:\\/\\/([^\\/]+\\.machibbs\\.com|[^\\/]+\\.machi\\.to)\\/bbs\\/read\\.(pl|cgi)\\?BBS=([^&]+)&KEY=([0-9]+)(&START=([0-9]+))?(&END=([0-9]+))?[^\"]*/", $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = $matches[6] . "-" . $matches[8];
        } elseif (preg_match("{http://((jbbs\\.livedoor\\.jp|jbbs\\.livedoor.com|jbbs\\.shitaraba\\.com)(/[^/]+)?)/bbs/read\\.(pl|cgi)\\?BBS=([^&]+)&KEY=([0-9]+)(&START=([0-9]+))?(&END=([0-9]+))?[^\"]*}", $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[5];
            $key = $matches[6];
            $ls = $matches[8] . "-" . $matches[10];
            // したらばJBBS http://jbbs.livedoor.com/bbs/read.cgi/computer/2999/1081177036/-100
        } elseif (preg_match("{http://(jbbs\\.livedoor\\.jp|jbbs\\.livedoor.com|jbbs\\.shitaraba\\.com)/bbs/read\\.cgi/(\\w+)/(\\d+)/(\\d+)/((\\d+)?-(\\d+)?)?[^\"]*}", $url, $matches)) {
            $host = $matches[1] . "/" . $matches[2];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = $matches[5];
        }
    } else {
        !empty($_GET['host']) and $host = $_GET['host'];
        // "pc.2ch.net"
        !empty($_POST['host']) and $host = $_POST['host'];
        isset($_GET['bbs']) and $bbs = $_GET['bbs'];
        // "php"
        isset($_POST['bbs']) and $bbs = $_POST['bbs'];
        isset($_GET['key']) and $key = $_GET['key'];
        // "1022999539"
        isset($_POST['key']) and $key = $_POST['key'];
        !empty($_GET['ls']) and $ls = $_GET['ls'];
        // "all"
        !empty($_POST['ls']) and $ls = $_POST['ls'];
    }
    if (empty($host) || !isset($bbs) || !isset($key)) {
        $htm['url'] = htmlspecialchars($url, ENT_QUOTES);
        $msg = "p2 - {$_conf['read_php']}: スレッドの指定が変です。<br>" . "<a href=\"{$htm['url']}\">" . $htm['url'] . "</a>";
        P2Util::printSimpleHtml($msg);
        die;
        return false;
    }
    return array($host, $bbs, $key, $ls);
}