Beispiel #1
0
/**
 * 対象レスの対象フィールドから、検索ワードを取得する
 *
 * @return  string  検索ワード
 */
function _getReadFilterWord($host, $bbs, $key, $resnum, $field)
{
    $word = null;
    $aThread = new ThreadRead();
    $aThread->setThreadPathInfo($host, $bbs, $key);
    $aThread->readDat();
    $resar = $aThread->explodeDatLine($aThread->datlines[$resnum - 1]);
    $resar = array_map('trim', $resar);
    $resar = array_map('strip_tags', $resar);
    switch ($field) {
        case 'name':
            $word = $resar[0];
            break;
        case 'mail':
            $word = $resar[1];
            break;
        case 'date':
            $word = preg_replace("/^(.*)ID:([0-9a-zA-Z\\/\\.\\+]+)(.*)\$/", "\\1 \\3", $resar[2]);
            $word = preg_replace("/^.*(\\d{2,4}\\/\\d{1,2}\\/\\d{1,2}).*\$/", "\\1", $word);
            break;
        case 'id':
            $word = preg_replace("/^.*ID:([0-9a-zA-Z\\/\\.\\+]+).*\$/", "\\1", $resar[2]);
            break;
        case 'rres':
            $_GET['field'] = 'msg';
            $_GET['method'] = 'regex';
            //$word = '>' . $resnum . '[^\d]'; // [^\d-]
            //$word = "(>|>|<|<|)|〉|》|≫){1,2}\s*\.?(\d+,)*" . $resnum . "\D";
            require_once P2_LIB_DIR . '/ShowThread.php';
            $word = ShowThread::getAnchorRegex('%prefix%(.+%delimiter%)?' . $resnum . '(?!\\d|%range_delimiter%)');
    }
    return $word;
}
Beispiel #2
0
function _read_filter_setup()
{
    $host = $_GET['host'];
    $bbs = $_GET['bbs'];
    $key = $_GET['key'];
    $resnum = (int) $_GET['resnum'];
    $field = $_GET['field'];
    $aThread = new ThreadRead();
    $aThread->setThreadPathInfo($host, $bbs, $key);
    $aThread->readDat($aThread->keydat);
    $i = $resnum - 1;
    if (!($i >= 0 && $i < count($aThread->datlines) && isset($_GET['rf']) && is_array($_GET['rf']))) {
        P2Util::pushInfoHtml('<p>フィルタリングの指定が変です。</p>');
        unset($_GET['rf'], $_REQUEST['rf']);
        return;
    }
    $ares = $aThread->datlines[$i];
    $resar = $aThread->explodeDatLine($ares);
    $name = $resar[0];
    $mail = $resar[1];
    $date_id = $resar[2];
    $msg = $resar[3];
    $params = $_GET['rf'];
    $include = ResFilter::INCLUDE_NONE;
    $fields = explode(':', $field);
    $field = array_shift($fields);
    if (in_array('refs', $fields)) {
        $include |= ResFilter::INCLUDE_REFERENCES;
    }
    if (in_array('refed', $fields)) {
        $include |= ResFilter::INCLUDE_REFERENCED;
    }
    $params['field'] = $field;
    $params['include'] = $include;
    $resFilter = ResFilter::configure($params);
    $target = $resFilter->getTarget($ares, $resnum, $name, $mail, $date_id, $msg);
    if ($field == 'date') {
        $date_part = explode(' ', trim($target));
        $word = $date_part[0];
    } else {
        $word = $target;
    }
    $params['word'] = $word;
    $_REQUEST['rf'] = $params;
}
Beispiel #3
0
<a class="button" id="above" name="above" href="#bottom"{$_conf['k_accesskey_at']['bottom']}>{$_conf['k_accesskey_st']['bottom']}▼</a></div>

EOP;
    P2Util::printInfoHtml();
}
//==============================================================
// それぞれの行解析
//==============================================================
$linesize = sizeof($lines);
$subject_txts = array();
for ($x = 0; $x < $linesize; $x++) {
    if (isset($GLOBALS['rnum_all_range']) and $GLOBALS['rnum_all_range'] <= 0) {
        break;
    }
    $l = $lines[$x];
    $aThread = new ThreadRead();
    $aThread->torder = $x + 1;
    // データ読み込み
    if ($aThreadList->spmode) {
        switch ($aThreadList->spmode) {
            case "recent":
                // 履歴
                $aThread->getThreadInfoFromExtIdxLine($l);
                break;
            case "res_hist":
                // 書き込み履歴
                $aThread->getThreadInfoFromExtIdxLine($l);
                break;
            case "fav":
                // お気に
                $aThread->getThreadInfoFromExtIdxLine($l);
Beispiel #4
0
 /**
  * レスデータを集計して$this->_quote_toと$this->_quote_fromに保存.
  */
 protected function _make_quotes()
 {
     global $_conf;
     $this->_quote_to = array();
     $this->_quote_from = array();
     if (!$this->thread->datlines) {
         return;
     }
     foreach ($this->thread->datlines as $num => $line) {
         list($name, $mail, $date_id, $msg) = $this->thread->explodeDatLine($line);
         // NGあぼーんチェック
         if (($id = $this->thread->ids[$num + 1]) !== null) {
             $date_id = str_replace($this->thread->idp[$i] . $id, 'ID:' . $id, $date_id);
         }
         $ng_type = $this->_ngAbornCheck($num + 1, strip_tags($name), $mail, $date_id, $id, $msg);
         if ($ng_type == self::ABORN) {
             continue;
         }
         // 名前
         if ($nmatches = $this->getQuoteResNumsName($name)) {
             foreach ($nmatches as $a_quote_res_num) {
                 if ($a_quote_res_num) {
                     if (!array_key_exists($a_quote_res_num, $this->_quote_from) || $this->_quote_from[$a_quote_res_num] === null) {
                         $this->_quote_from[$a_quote_res_num] = array();
                     }
                     if (!in_array($num + 1, $this->_quote_from[$a_quote_res_num])) {
                         $this->_quote_from[$a_quote_res_num][] = $num + 1;
                     }
                     if (!array_key_exists($num + 1, $this->_quote_to) || $this->_quote_to[$num + 1] === null) {
                         $this->_quote_to[$num + 1] = array();
                     }
                     if (!in_array($a_quote_res_num, $this->_quote_to[$num + 1])) {
                         $this->_quote_to[$num + 1][] = $a_quote_res_num;
                     }
                 }
             }
         }
         // >>1のリンクをいったん外す
         // <a href="../test/read.cgi/accuse/1001506967/1" target="_blank">&gt;&gt;1</a>
         $msg = preg_replace('{<[Aa] .+?>(&gt;&gt;[1-9][\\d\\-]*)</[Aa]>}', '$1', $msg);
         if (!preg_match_all(self::getAnchorRegex('/%full%/'), $msg, $out, PREG_PATTERN_ORDER)) {
             continue;
         }
         foreach ($out[2] as $numberq) {
             if (!preg_match_all(self::getAnchorRegex('/(?:%prefix%)?(%a_range%)/'), $numberq, $anchors, PREG_PATTERN_ORDER)) {
                 continue;
             }
             foreach ($anchors[1] as $anchor) {
                 if (preg_match(self::getAnchorRegex('/(%a_num%)%range_delimiter%(?:%prefix%)?(%a_num%)/'), $anchor, $matches)) {
                     $from = intval(mb_convert_kana($matches[1], 'n'));
                     $to = intval(mb_convert_kana($matches[2], 'n'));
                     if ($from < 1 || $to < 1 || $from > $to || $to - $from + 1 > sizeof($this->thread->datlines)) {
                         continue;
                     }
                     if ($_conf['backlink_list_range_anchor_limit'] != 0) {
                         if ($to - $from >= $_conf['backlink_list_range_anchor_limit']) {
                             continue;
                         }
                     }
                     for ($i = $from; $i <= $to; $i++) {
                         if ($i > sizeof($this->thread->datlines)) {
                             break;
                         }
                         if ($_conf['backlink_list_future_anchor'] == 0) {
                             if ($i >= $num + 1) {
                                 continue;
                             }
                             // レス番号以降のアンカーは無視する
                         }
                         if (!array_key_exists($i, $this->_quote_from) || $this->_quote_from[$i] === null) {
                             $this->_quote_from[$i] = array();
                         }
                         if (!in_array($num + 1, $this->_quote_from[$i])) {
                             $this->_quote_from[$i][] = $num + 1;
                         }
                     }
                 } else {
                     if (preg_match(self::getAnchorRegex('/(%a_num%)/'), $anchor, $matches)) {
                         $quote_num = intval(mb_convert_kana($matches[1], 'n'));
                         if (!array_key_exists($num + 1, $this->_quote_to) || $this->_quote_to[$num + 1] === null) {
                             $this->_quote_to[$num + 1] = array();
                         }
                         if (!in_array($quote_num, $this->_quote_to[$num + 1])) {
                             $this->_quote_to[$num + 1][] = $quote_num;
                         }
                         if ($_conf['backlink_list_future_anchor'] == 0) {
                             if ($quote_num >= $num + 1) {
                                 continue;
                             }
                             // レス番号以降のアンカーは無視する
                         }
                         if (!array_key_exists($quote_num, $this->_quote_from) || $this->_quote_from[$quote_num] === null) {
                             $this->_quote_from[$quote_num] = array();
                         }
                         if (!in_array($num + 1, $this->_quote_from[$quote_num])) {
                             $this->_quote_from[$quote_num][] = $num + 1;
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #5
0
$moto_link = '';
//=====================================================
// スレッド情報
//=====================================================
$host = $_GET['host'];
$bbs = $_GET['bbs'];
$key = $_GET['key'];
$resid = $_GET['copy'];
$quote = !empty($_GET['inyou']);
if (isset($_SERVER['HTTP_REFERER'])) {
    $back_link = '<a href="' . htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES) . '" title="戻る">戻る</a> ';
}
//=================================================
// レス読み込み
//=================================================
$aThread = new ThreadRead();
$aThread->setThreadPathInfo($host, $bbs, $key);
if (file_exists($aThread->keydat)) {
    // スレッド情報
    $aThread->readDat($aThread->keydat);
    $one = $aThread->explodeDatLine($aThread->datlines[0]);
    $ttitle = trim($one[4]);
    $ttitle_en = UrlSafeBase64::encode($ttitle);
    $ttitle_ht = htmlspecialchars($ttitle, ENT_QUOTES);
    $url_txt = $aThread->getMotoThread(true);
    $url_k_txt = $aThread->getMotoThread();
    if ($quote) {
        $url_txt .= $resid;
        $url_k_txt .= $resid;
    }
    if ($url_txt != $url_k_txt) {
Beispiel #6
0
?>
の新まとめ</h1>
</div>
<?php 
P2Util::printInfoHtml();
//==============================================================
// それぞれの行解析
//==============================================================
$online_num = 0;
$linesize = sizeof($lines);
for ($x = 0; $x < $linesize; $x++) {
    if (isset($GLOBALS['rnum_all_range']) and $GLOBALS['rnum_all_range'] <= 0) {
        break;
    }
    $l = $lines[$x];
    $aThread = new ThreadRead();
    $aThread->torder = $x + 1;
    // ラインデータ読み込み
    $aThread->setThreadInfoFromLineWithThreadList($l, $aThreadList, $setItaj = false);
    // hostもbbsも不明ならスキップ
    if (!($aThread->host && $aThread->bbs)) {
        unset($aThread);
        continue;
    }
    $aThread->setThreadPathInfo($aThread->host, $aThread->bbs, $aThread->key);
    $aThread->getThreadInfoFromIdx();
    // 既得スレッドデータをidxから取得
    // 新着のみ(for subject)
    if (!$aThreadList->spmode and $sb_view == "shinchaku" and !isset($GLOBALS['word'])) {
        if ($aThread->unum < 1) {
            unset($aThread);
Beispiel #7
0
    // ボタンが押されていたなら、ファイルに設定を保存
    if (isset($_REQUEST['submit_filter'])) {
        // !isset($_REQUEST['idpopup'])
        if (empty($GLOBALS['popup_filter'])) {
            FileCtl::make_datafile($cachefile, $_conf['p2_perm']);
            if (false === file_put_contents($cachefile, serialize($GLOBALS['res_filter']), LOCK_EX)) {
                die("Error: cannot write file.");
            }
        }
    }
}
// }}}
//==================================================================
// メイン
//==================================================================
$aThread = new ThreadRead();
// lsのセット
if (!empty($ls)) {
    $aThread->ls = strip_tags(mb_convert_kana($ls, 'a'));
}
// {{{ idxの読み込み
// hostを分解してidxファイルのパスを求める
if (!isset($aThread->keyidx)) {
    $aThread->setThreadPathInfo($host, $bbs, $key);
}
// 板ディレクトリが無ければ作る
// FileCtl::mkdirFor($aThread->keyidx);
$aThread->itaj = P2Util::getItaName($host, $bbs);
if (!$aThread->itaj) {
    $aThread->itaj = $aThread->bbs;
}
Beispiel #8
0
    $target_read_at = ' target="read"';
    $target_sb_at = ' target="sbject"';
} else {
    $target_edit_at = '';
    $target_read_at = '';
    $target_sb_at = '';
}
//=====================================================
// データファイルの読み書き
//=====================================================
if (preg_match('/^(aborn|ng)_/', $mode)) {
    $path = $_conf['pref_dir'] . '/p2_' . $mode . '.txt';
}
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;
Beispiel #9
0
/**
 * オフライン購読用データを生成する
 *
 * @param   string  $host;
 * @param   string  $bbs;
 * @param   int     $key
 * @param   int     $from
 * @return  bool
 */
function httpcmd_make_offline_data($host, $bbs, $key, $from)
{
    if (!is_numeric($from) || ($from = intval($from)) < 1) {
        return false;
    }
    $data = array();
    $aThread = new ThreadRead();
    $aThread->setThreadPathInfo($host, $bbs, $key);
    return false;
}
Beispiel #10
0
require_once 'conf/conf.inc.php';
require_once P2_LIB_DIR . '/Thread.php';
require_once P2_LIB_DIR . '/ThreadRead.php';
$_login->authorize();
// ユーザ認証
$host = geti($_GET['host']);
$bbs = geti($_GET['bbs']);
$key = geti($_GET['key']);
$resid = $GLOBALS['_read_copy_resnum'];
$quote = !empty($_GET['inyou']);
$back_link_atag = '';
if (isset($_SERVER['HTTP_REFERER'])) {
    $back_link_atag = P2View::tagA($_SERVER['HTTP_REFERER'], hs('戻る'), array('title' => '戻る'));
}
// レス読み込み
$aThread = new ThreadRead();
$aThread->setThreadPathInfo($host, $bbs, $key);
$aThread->ls = $resid;
$moto_url = '';
$moto_url_k = '';
$post_link_atag = '';
$moto_link_atag = '';
$name_txt = '';
$mail_txt = '';
$date_txt = '';
$msg_txt = '';
$id_txt = '';
$id_ht = '';
$form_id = P2_REQUEST_ID;
if (!file_exists($aThread->keydat)) {
    p2die('スレッドの指定が変です。');
/**
 * @return  array
 */
function _getExplodedDatLine($host, $bbs, $key, $resnum)
{
    require_once P2_LIB_DIR . '/Thread.php';
    require_once P2_LIB_DIR . '/ThreadRead.php';
    $ThreadRead = new ThreadRead();
    $ThreadRead->setThreadPathInfo($host, $bbs, $key);
    $ThreadRead->readDat($ThreadRead->keydat);
    $explodedDatLine = $ThreadRead->explodeDatLine($ThreadRead->datlines[$resnum - 1]);
    return array_map('trim', $explodedDatLine);
}
Beispiel #12
0
        if (empty($popup_filter) && isset($_REQUEST['submit_filter'])) {
            $resFilter->save();
        }
    }
} else {
    $resFilter = ResFilter::restore();
}
//=================================================
// あぼーん&NGワード設定読み込み
//=================================================
$GLOBALS['ngaborns'] = NgAbornCtl::loadNgAborns();
//==================================================================
// メイン
//==================================================================
if (!isset($aThread)) {
    $aThread = new ThreadRead();
}
// lsのセット
if (!empty($ls)) {
    $aThread->ls = mb_convert_kana($ls, 'a');
}
//==========================================================
// idxの読み込み
//==========================================================
// hostを分解してidxファイルのパスを求める
if (!isset($aThread->keyidx)) {
    $aThread->setThreadPathInfo($host, $bbs, $key);
}
// 板ディレクトリが無ければ作る
// FileCtl::mkdirFor($aThread->keyidx);
$aThread->itaj = P2Util::getItaName($host, $bbs);
Beispiel #13
0
    $params = array('host' => 'string', 'bbs' => 'string', 'key' => 'int', 'resnum' => 'int');
    foreach ($params as $name => $type) {
        if (isset($_GET[$name])) {
            ${$name} = $_GET[$name];
            settype(${$name}, $type);
        } else {
            $errors[] = 'レスの特定に必要な値が足りません。';
            break;
        }
    }
    $inline = !empty($_GET['inline']);
    $rotate = !empty($_GET['rotate']);
}
// レス読み込み
if (empty($errors) && $_SERVER['REQUEST_METHOD'] != 'POST') {
    $aThread = new ThreadRead();
    $aThread->setThreadPathInfo($host, $bbs, $key);
    if (!$aThread->readDat()) {
        $errors[] = 'datが読み込めませんでした。';
    } else {
        $offset = $resnum - 1;
        if (!isset($aThread->datlines[$offset])) {
            $errors[] = 'このスレッドの >>' . $resnum . ' は存在していないか、取得していません。';
        } else {
            $parts = $aThread->explodeDatLine($aThread->datlines[$offset]);
            $text = $parts[3];
            $text = strip_tags($text, '<br><hr>');
            $text = preg_replace('/\\s*<br[^<>]*>\\s*/i', "\n", $text);
            $text = preg_replace('/\\s*<hr[^<>]*>\\s*/i', "\n------------------------\n", $text);
            $text = trim($text);
        }
Beispiel #14
0
//================================================================
$newtime = date('gis');
// 同じリンクをクリックしても再読込しない仕様に対抗するダミークエリー
//$_today = date('y/m/d');
if (empty($_GET['host']) || empty($_GET['bbs']) || empty($_GET['key']) || empty($_GET['ls'])) {
    p2die('レスの指定が変です。');
}
$host = $_GET['host'];
$bbs = $_GET['bbs'];
$key = $_GET['key'];
$mode = isset($_GET['q']) ? (int) $_GET['q'] : 0;
$_conf['ktai'] = FALSE;
//==================================================================
// メイン
//==================================================================
$aThread = new ThreadRead();
//==========================================================
// idxの読み込み
//==========================================================
// hostを分解してidxファイルのパスを求める
if (!isset($aThread->keyidx)) {
    $aThread->setThreadPathInfo($host, $bbs, $key);
}
// 板ディレクトリが無ければ作る
//FileCtl::mkdirFor($aThread->keyidx);
$aThread->itaj = P2Util::getItaName($host, $bbs);
if (!$aThread->itaj) {
    $aThread->itaj = $aThread->bbs;
}
// idxファイルがあれば読み込む
if ($lines = FileCtl::file_read_lines($aThread->keyidx, FILE_IGNORE_NEW_LINES)) {
Beispiel #15
0
if ($_GET['img']) {
    if ($stalker->isEnabled()) {
        header("Content-Type: image/png");
        readfile(P2_PLUGIN_DIR . '/stalker/stalker.png');
    } else {
        header("Content-Type: image/gif");
        readfile('./img/spacer.gif');
    }
    exit;
} else {
    if ($stalker->isEnabled()) {
        $id = null;
        if (!empty($_GET['id'])) {
            $id = $_GET['id'];
        } elseif (!empty($_GET['key']) && !empty($_GET['resnum'])) {
            $aThread = new ThreadRead();
            $aThread->setThreadPathInfo($_GET['host'], $_GET['bbs'], $_GET['key']);
            $aThread->readDat();
            $resnum = $_GET['resnum'];
            if (isset($aThread->datlines[$resnum - 1])) {
                $ares = $aThread->datlines[$resnum - 1];
                $resar = $aThread->explodeDatLine($ares);
                $m = array();
                if (preg_match('<(ID: ?| )([0-9A-Za-z/.+]{8,11})(?=[^0-9A-Za-z/.+]|$)>', $resar[2], $m)) {
                    $id = $m[2];
                }
            }
        }
        if ($id) {
            $stalker->id = $id;
        } else {
Beispiel #16
0
 /**
  * コンストラクタ
  */
 protected function __construct(ThreadRead $aThread, $matome = false)
 {
     global $_conf;
     // スレッドオブジェクトを登録
     $this->thread = $aThread;
     // まとめ読みモードか否か
     if ($matome) {
         $this->_matome = ++self::$_matome_count;
     } else {
         $this->_matome = false;
     }
     $this->_url_handlers = array();
     $this->_user_url_handlers = array();
     $this->_ngaborn_frequent = 0;
     if ($_conf['ngaborn_frequent']) {
         if ($_conf['ngaborn_frequent_dayres'] == 0) {
             $this->_ngaborn_frequent = $_conf['ngaborn_frequent'];
         } elseif ($this->thread->setDayRes() && $this->thread->dayres < $_conf['ngaborn_frequent_dayres']) {
             $this->_ngaborn_frequent = $_conf['ngaborn_frequent'];
         }
     }
     $this->_has_ngaborns = false;
     $this->_aborn_nums = array();
     $this->_ng_nums = array();
     if (P2Util::isHostBbsPink($this->thread->host)) {
         $this->_redirector = self::REDIRECTOR_PINKTOWER;
     } elseif (P2Util::isHost2chs($this->thread->host)) {
         $this->_redirector = self::REDIRECTOR_IMENU;
     } elseif (P2Util::isHostMachiBbs($this->thread->host)) {
         $this->_redirector = self::REDIRECTOR_MACHIBBS;
     } else {
         $this->_redirector = self::REDIRECTOR_NONE;
     }
     $this->_quote_res_nums = array();
     $this->_quote_res_nums_checked = array();
     $this->_quote_res_nums_done = array();
 }