示例#1
0
文件: setFav.func.php 项目: poppen/p2
/**
 * お気にスレをセットする関数
 *
 * $setfav は、'0'(解除), '1'(追加), 'top', 'up', 'down', 'bottom'
 *
 * @access  public
 * @return  boolean
 */
function setFav($host, $bbs, $key, $setfav)
{
    global $_conf;
    if (P2Validate::host($host) || P2Validate::bbs($bbs) || P2Validate::key($key)) {
        return false;
    }
    // スレッド.idx 記録
    $data = _setFavToKeyIdx($host, $bbs, $key, $setfav);
    $newlines = array();
    $before_line_num = 0;
    if (false === FileCtl::make_datafile($_conf['favlist_file'], $_conf['favlist_perm'])) {
        return false;
    }
    if (false === ($favlines = file($_conf['favlist_file']))) {
        return false;
    }
    // 最初に重複要素を削除しておく
    if (!empty($favlines)) {
        $i = -1;
        foreach ($favlines as $line) {
            $i++;
            $line = rtrim($line);
            $lar = explode('<>', $line);
            // 重複回避
            if ($lar[1] == $key && $lar[11] == $bbs) {
                $before_line_num = $i;
                // 移動前の行番号をセット
                continue;
                // keyのないものは不正データなのでスキップ
            } elseif (!$lar[1]) {
                continue;
            } elseif (P2Validate::host($lar[10]) || P2Validate::bbs($lar[11]) || P2Validate::key($lar[1])) {
                continue;
            } else {
                $newlines[] = $line;
            }
        }
    }
    if (!empty($GLOBALS['brazil'])) {
        //$newlines = _removeLargeFavlistData($newlines);
    }
    // 記録データ設定
    if ($setfav) {
        $newdata = implode('<>', array(geti($data[0]), $key, geti($data[2]), geti($data[3]), geti($data[4]), geti($data[5]), 1, geti($data[7]), geti($data[8]), geti($data[9]), $host, $bbs));
        require_once P2_LIB_DIR . '/getSetPosLines.func.php';
        $rec_lines = getSetPosLines($newlines, $newdata, $before_line_num, $setfav);
    } else {
        $rec_lines = $newlines;
    }
    if (false === file_put_contents($_conf['favlist_file'], $rec_lines ? implode("\n", $rec_lines) . "\n" : '', LOCK_EX)) {
        trigger_error(sprintf('file_put_contents(%s)', $_conf['favlist_file']), E_USER_WARNING);
        return false;
    }
    // お気にスレ共有
    _setFavRank($host, $bbs, $key, $setfav, geti($data[0]));
    return true;
}
示例#2
0
文件: info_i.php 项目: poppen/p2
//================================================================
// 変数設定
//================================================================
isset($_GET['host']) and $host = $_GET['host'];
// "pc.2ch.net"
isset($_GET['bbs']) and $bbs = $_GET['bbs'];
// "php"
isset($_GET['key']) and $key = $_GET['key'];
// "1022999539"
$ttitle_en = isset($_GET['ttitle_en']) ? $_GET['ttitle_en'] : null;
// $_GET['popup'] 0(false), 1(true), 2(true, クローズタイマー付)
// 以下どれか一つがなくてもダメ出し
if (!$host || !isset($bbs) || !isset($key)) {
    p2die('引数が正しくありません。(host or bbs or key)');
}
if (P2Validate::host($host) || P2Validate::bbs($bbs) || P2Validate::key($key)) {
    p2die('不正な引数です。(host or bbs or key)');
}
$title_msg = '';
$info_msg = '';
//================================================================
// 特別な前処理
//================================================================
// {{{ 削除
if (!empty($_GET['dele'])) {
    $r = deleteLogs($host, $bbs, array($key));
    if (!$r) {
        $title_msg = "× ログ削除失敗";
        $info_msg = "× ログ削除失敗";
    } elseif ($r == 1) {
        $title_msg = "○ ログ削除完了";
示例#3
0
文件: read.php 项目: poppen/p2
/**
 * スレッドを指定する
 *
 * @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);
}
示例#4
0
文件: post_form_i.php 项目: poppen/p2
    p2die('host が指定されていません');
}
$host = $_GET['host'];
$bbs = geti($_GET['bbs']);
$key = geti($_GET['key']);
$rescount = (int) geti($_GET['rescount'], 1);
$popup = (int) geti($_GET['popup'], 0);
if (!($itaj = P2Util::getItaName($host, $bbs))) {
    $itaj = $bbs;
}
$ttitle_en = isset($_GET['ttitle_en']) ? $_GET['ttitle_en'] : '';
$ttitle_hs = null;
if (strlen($ttitle_en)) {
    $ttitle_hs = hs(P2Util::htmlEntityDecodeLite(base64_decode($ttitle_en)));
}
if (P2Validate::host($host) || $bbs && P2Validate::bbs($bbs) || $key && P2Validate::key($key)) {
    p2die('不正な引数です');
}
$keyidx = P2Util::getKeyIdxFilePath($host, $bbs, $key);
// フォームのオプション読み込み
require_once P2_LIB_DIR . '/post_options_loader.inc.php';
// 表示指定
$class_ttitle = '';
$target_read = '';
$sub_size_at = '';
if (!$_conf['ktai']) {
    $class_ttitle = ' class="thre_title"';
    $target_read = ' target="read"';
    $sub_size_at = ' size="40"';
}
// {{{ スレ立てなら