예제 #1
0
파일: read_filter.php 프로젝트: poppen/p2
/**
 * 対象レスの対象フィールドから、検索ワードを取得する
 *
 * @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;
}
예제 #2
0
파일: ShowThread.php 프로젝트: poppen/p2
 /**
  * static
  * @access  public
  * @param   string  $pattern  ex)'/%full%/'
  * @return  string
  */
 function getAnchorRegex($pattern)
 {
     static $caches_ = array();
     if (!array_key_exists($pattern, $caches_)) {
         $caches_[$pattern] = strtr($pattern, ShowThread::getAnchorRegexParts());
         // 大差はないが compileMobile2chUriCallBack() のように preg_relplace_callback()してもいいかも。
     }
     return $caches_[$pattern];
 }
예제 #3
0
파일: ShowThreadK.php 프로젝트: poppen/p2
 /**
  * @constructor
  */
 function ShowThreadK(&$aThread)
 {
     parent::ShowThread($aThread);
     global $_conf;
     $this->url_handlers = array(array('this' => 'plugin_link2ch'), array('this' => 'plugin_linkMachi'), array('this' => 'plugin_linkJBBS'), array('this' => 'plugin_link2chKako'), array('this' => 'plugin_link2chSubject'), array('this' => 'plugin_linkReadCgi'));
     if ($_conf['k_use_picto']) {
         $this->url_handlers[] = array('this' => 'plugin_viewImage');
     }
     $this->url_handlers[] = array('this' => 'plugin_linkURL');
     $this->setBbsNonameName();
 }
예제 #4
0
 /**
  * @constructor
  */
 function ShowThreadPc(&$aThread)
 {
     parent::ShowThread($aThread);
     global $_conf;
     $this->url_handlers = array('plugin_link2ch', 'plugin_linkMachi', 'plugin_linkJBBS', 'plugin_link2chKako', 'plugin_link2chSubject');
     if ($_conf['preview_thumbnail']) {
         $this->url_handlers[] = 'plugin_viewImage';
     }
     $_conf['link_youtube'] and $this->url_handlers[] = 'plugin_linkYouTube';
     $_conf['link_niconico'] and $this->url_handlers[] = 'plugin_linkNicoNico';
     $this->url_handlers[] = 'plugin_linkURL';
 }
예제 #5
0
 /**
  * コンストラクタ
  */
 public function __construct($aThread, $matome = false)
 {
     parent::__construct($aThread, $matome);
     global $_conf;
     $this->_url_handlers = array('plugin_linkThread', 'plugin_link2chSubject');
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         $this->_url_handlers[] = 'plugin_imageCache2';
     } elseif ($_conf['preview_thumbnail']) {
         $this->_url_handlers[] = 'plugin_viewImage';
     }
     if ($_conf['link_youtube']) {
         $this->_url_handlers[] = 'plugin_linkYouTube';
     }
     if ($_conf['link_niconico']) {
         $this->_url_handlers[] = 'plugin_linkNicoNico';
     }
     $this->_url_handlers[] = 'plugin_linkURL';
     // サムネイル表示制限数を設定
     if (!isset($GLOBALS['pre_thumb_unlimited']) || !isset($GLOBALS['pre_thumb_limit'])) {
         if (isset($_conf['pre_thumb_limit']) && $_conf['pre_thumb_limit'] > 0) {
             $GLOBALS['pre_thumb_limit'] = $_conf['pre_thumb_limit'];
             $GLOBALS['pre_thumb_unlimited'] = FALSE;
         } else {
             $GLOBALS['pre_thumb_limit'] = NULL;
             // ヌル値だとisset()はFALSEを返す
             $GLOBALS['pre_thumb_unlimited'] = TRUE;
         }
     }
     $GLOBALS['pre_thumb_ignore_limit'] = FALSE;
     // アクティブモナー初期化
     if (P2_ACTIVEMONA_AVAILABLE) {
         ExpackLoader::initActiveMona($this);
     }
     // ImageCache2初期化
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         ExpackLoader::initImageCache($this);
     }
     // 非同期レスポップアップ・SPM初期化
     $js_id = sprintf('%u', crc32($this->thread->keydat));
     if ($this->_matome) {
         $this->asyncObjName = "t{$this->_matome}asp{$js_id}";
         $this->spmObjName = "t{$this->_matome}spm{$js_id}";
     } else {
         $this->asyncObjName = "asp{$js_id}";
         $this->spmObjName = "spm{$js_id}";
     }
 }
예제 #6
0
 /**
  * @constructor
  */
 function ShowThreadK(&$aThread)
 {
     parent::ShowThread($aThread);
     global $_conf;
     $this->url_handlers = array(array('this' => 'plugin_link2ch'), array('this' => 'plugin_linkMachi'), array('this' => 'plugin_linkJBBS'), array('this' => 'plugin_link2chKako'), array('this' => 'plugin_link2chSubject'));
     if ($_conf['k_use_picto']) {
         $this->url_handlers[] = array('this' => 'plugin_viewImage');
     }
     $_conf['link_youtube'] and $this->url_handlers[] = array('this' => 'plugin_linkYouTube');
     $_conf['link_niconico'] and $this->url_handlers[] = array('this' => 'plugin_linkNicoNico');
     $this->url_handlers[] = array('this' => 'plugin_linkURL');
     if (empty($_conf['k_bbs_noname_name'])) {
         require_once P2_LIB_DIR . '/SettingTxt.php';
         $st = new SettingTxt($this->thread->host, $this->thread->bbs);
         !empty($st->setting_array['BBS_NONAME_NAME']) and $this->BBS_NONAME_NAME = $st->setting_array['BBS_NONAME_NAME'];
     }
 }
예제 #7
0
 /**
  * アンカーの構成要素(正規表現パーツの配列)を返す
  *
  * @param   void
  * @return  string
  */
 private static function _getAnchorRegexParts()
 {
     if (!is_null(self::$_anchorRegexParts)) {
         return self::$_anchorRegexParts;
     }
     $anchor = array();
     // アンカーの構成要素(正規表現パーツの配列)
     // 空白文字
     $anchor_space = '(?:[ ]| )';
     //$anchor[' '] = '';
     // アンカー引用子 >>
     $anchor['prefix'] = "(?:(?:>|>|<|<|〉){1,2}|(?:\\)){2}|》|≫){$anchor_space}*\\.?";
     // 数字
     $anchor['a_digit'] = '(?:\\d|0|1|2|3|4|5|6|7|8|9)';
     /*
     $anchor[0] = '(?:0|0)';
     $anchor[1] = '(?:1|1)';
     $anchor[2] = '(?:2|2)';
     $anchor[3] = '(?:3|3)';
     $anchor[4] = '(?:4|4)';
     $anchor[5] = '(?:5|5)';
     $anchor[6] = '(?:6|6)';
     $anchor[7] = '(?:7|7)';
     $anchor[8] = '(?:8|8)';
     $anchor[9] = '(?:9|9)';
     */
     // 範囲指定子
     // -|‐|ー = HYPHEN-MINUS | HYPHEN | KATAKANA-HIRAGANA PROLONGED SOUND MARK
     $anchor['range_delimiter'] = '(?:-|\\x81\\x5d|\\x81\\x5b)';
     // [\\-\\x{2010}\\x{30fc}]
     // 列挙指定子
     $anchor['delimiter'] = "{$anchor_space}?(?:[\\.,=+]|、|・|=|,){$anchor_space}?";
     // あぼーん用アンカー引用子
     //$anchor['prefix_abon'] = ">{1,2}{$anchor_space}?";
     // レス番号
     $anchor['a_num'] = sprintf('%s{1,4}', $anchor['a_digit']);
     // レス範囲
     /*
     $anchor['a_range'] = sprintf('%s(?:%s%s)?',
         $anchor['a_num'], $anchor['range_delimiter'], $anchor['a_num']
     );
     */
     $anchor['a_range'] = sprintf('%s(?:%s(?:%s)?%s)?', $anchor['a_num'], $anchor['range_delimiter'], $anchor['prefix'], $anchor['a_num']);
     // レス範囲の列挙
     $anchor['ranges'] = sprintf('%s(?:%s%s)*(?!%s)', $anchor['a_range'], $anchor['delimiter'], $anchor['a_range'], $anchor['a_digit']);
     // レス番号の列挙
     $anchor['nums'] = sprintf('%s(?:%s%s)*(?!%s)', $anchor['a_num'], $anchor['delimiter'], $anchor['a_num'], $anchor['a_digit']);
     // アンカー全体
     $anchor['full'] = sprintf('(%s)(%s)', $anchor['prefix'], $anchor['ranges']);
     // getAnchorRegex() の strtr() 置換用にkeyを '%key%' に変換する
     foreach ($anchor as $k => $v) {
         $anchor['%' . $k . '%'] = $v;
         unset($anchor[$k]);
     }
     self::$_anchorRegexParts = $anchor;
     return self::$_anchorRegexParts;
 }
예제 #8
0
 /**
  * レスフィルタを適用する
  *
  * @param ShowThread $aShowThread
  * @return array
  */
 public function apply(ShowThread $aShowThread)
 {
     $aThread = $aShowThread->thread;
     $failure = $this->match == self::MATCH_ON ? false : true;
     $count = count($aThread->datlines);
     $datlines = array_fill(0, $count, null);
     $hit_nums = array();
     //        $res_nums = array();
     $check_refs = $this->include & self::INCLUDE_REFERENCES ? true : false;
     $check_refed = $this->include & self::INCLUDE_REFERENCED ? true : false;
     // {{{ 1パス目 (マッチングと参照レス検出)
     if ($this->field == self::FIELD_NUMBER && $this->method == self::METHOD_JUST && $this->match == self::MATCH_ON) {
         // レス番号完全一致は特別扱い
         $n = (int) $this->word;
         if ($n > 0 && $n <= $count) {
             $i = $n - 1;
             $ares = $aThread->datlines[$i];
             $datlines[$i] = $ares;
             $hit_nums[] = $i;
             if ($check_refs || $check_refed) {
                 list($name, $mail, $date_id, $msg) = $aThread->explodeDatLine($ares);
                 foreach ($aShowThread->checkQuoteResNums($n, $name, $msg, $check_refs, $check_refed, false) as $rn) {
                     $ri = $rn - 1;
                     if ($datlines[$ri] === null) {
                         $datlines[$ri] = $aThread->datlines[$ri];
                         $hit_nums[] = $ri;
                     }
                 }
             }
             /*
                             if ($check_refed) {
                                 $res_nums[] = $n;
                             }
             */
         }
     } else {
         // 通常のマッチング
         foreach ($aThread->datlines as $i => $ares) {
             $n = $i + 1;
             list($name, $mail, $date_id, $msg) = $aThread->explodeDatLine($ares);
             if (($id = $aThread->ids[$n]) !== null) {
                 $date_id = str_replace($aThread->idp[$n] . $id, "ID:{$id}", $date_id);
             }
             $target = $this->getTarget($ares, $n, $name, $mail, $date_id, $msg);
             if (!$target) {
                 continue;
             }
             if ($this->_match($target, $n, $failure)) {
                 if ($datlines[$i] === null) {
                     $datlines[$i] = $ares;
                     $hit_nums[] = $i;
                 }
                 if ($check_refs || $check_refed) {
                     foreach ($aShowThread->checkQuoteResNums($n, $name, $msg, $check_refs, $check_refed, false) as $rn) {
                         $ri = $rn - 1;
                         if ($datlines[$ri] === null) {
                             $datlines[$ri] = $aThread->datlines[$ri];
                             $hit_nums[] = $ri;
                         }
                     }
                 }
                 /*
                                     if ($check_refed) {
                                         $res_nums[] = $n;
                                     }
                 */
             }
         }
     }
     // }}}
     // {{{ 2パス目 (マッチしたレスへの参照)
     /*
             if (count($res_nums)) {
                 $pattern = ShowThread::getAnchorRegex(
                     '%prefix%(.+%delimiter%)?(?:' . implode('|', $res_nums) . ')(?!\\d|%range_delimiter%)'
                 );
                 foreach ($aThread->datlines as $i => $ares) {
                     if ($datlines[$i] === null) {
                         list(, , , $msg) = $aThread->explodeDatLine($ares);
                         if (StrCtl::filterMatch($pattern, $msg, false)) {
                             $datlines[$i] = $aThread->datlines[$i];
                             $hit_nums[] = $i;
                         }
                     }
                 }
             }
     */
     // }}}
     $hits = count($hit_nums);
     if ($hits) {
         $this->hits += $hits;
         $this->last_hit_resnum = max($hit_nums);
     }
     return $datlines;
 }
예제 #9
0
 /**
  * コンストラクタ
  */
 public function __construct(ThreadRead $aThread, $matome = false)
 {
     parent::__construct($aThread, $matome);
     global $_conf, $STYLE;
     if ($_conf['iphone']) {
         $this->respopup_at = ' onclick="return iResPopUp(this, event);"';
         $this->target_at = ' target="_blank"';
         $this->check_st = 'check';
     }
     $this->_url_handlers = array('plugin_linkThread', 'plugin_link2chSubject');
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         $this->_url_handlers[] = 'plugin_imageCache2';
     } elseif ($_conf['mobile.use_picto']) {
         $this->_url_handlers[] = 'plugin_viewImage';
     }
     if ($_conf['mobile.link_youtube']) {
         $this->_url_handlers[] = 'plugin_linkYouTube';
     }
     $this->_url_handlers[] = 'plugin_linkURL';
     if (!$_conf['mobile.bbs_noname_name']) {
         $st = new SettingTxt($this->thread->host, $this->thread->bbs);
         $st->setSettingArray();
         if (array_key_exists('BBS_NONAME_NAME', $st->setting_array)) {
             $BBS_NONAME_NAME = $st->setting_array['BBS_NONAME_NAME'];
             if (strlen($BBS_NONAME_NAME)) {
                 $this->_nanashiName = $BBS_NONAME_NAME;
             }
         }
     }
     if (P2Util::isHost2chs($aThread->host)) {
         $this->_kushiYakiName = ' </b>[—\{}@{}@{}-]<b> ';
     }
     if ($_conf['mobile.date_zerosuppress']) {
         $this->_dateIdPattern = '~^(?:' . date('Y|y') . ')/(?:0(\\d)|(\\d\\d))?(?:(/)0)?~';
         $this->_dateIdReplace = '$1$2$3';
     } else {
         $this->_dateIdPattern = '~^(?:' . date('Y|y') . ')/~';
         $this->_dateIdReplace = '';
     }
     // 連続する改行の置換文字列を設定
     /*
     if ($_conf['mobile.strip_linebreaks']) {
         $ngword_color = $GLOBALS['STYLE']['mobile_read_ngword_color'];
         if (strpos($ngword_color, '\\') === false && strpos($ngword_color, '$') === false) {
             $this->_lineBreaksReplace = " <br><s><font color=\"{$ngword_color}\">***</font></s><br> ";
         } else {
             $this->_lineBreaksReplace = ' <br><s>***</s><br> ';
         }
     } else {
         $this->_lineBreaksReplace = null;
     }
     */
     // サムネイル表示制限数を設定
     if (!isset($GLOBALS['pre_thumb_unlimited']) || !isset($GLOBALS['expack.ic2.pre_thumb_limit_k'])) {
         if (isset($_conf['expack.ic2.pre_thumb_limit_k']) && $_conf['expack.ic2.pre_thumb_limit_k'] > 0) {
             $GLOBALS['pre_thumb_limit_k'] = $_conf['expack.ic2.pre_thumb_limit_k'];
             $GLOBALS['pre_thumb_unlimited'] = false;
         } else {
             $GLOBALS['pre_thumb_limit_k'] = null;
             // ヌル値だとisset()はFALSEを返す
             $GLOBALS['pre_thumb_unlimited'] = true;
         }
     }
     $GLOBALS['pre_thumb_ignore_limit'] = false;
     // アクティブモナー初期化
     if (P2_ACTIVEMONA_AVAILABLE) {
         ExpackLoader::initActiveMona($this);
     }
     // ImageCache2初期化
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         ExpackLoader::initImageCache($this);
     }
     // AAS 初期化
     if (P2_AAS_AVAILABLE) {
         ExpackLoader::initAAS($this);
     }
     // SPM初期化
     //if ($this->_matome) {
     //    $this->spmObjName = sprintf('t%dspm%u', $this->_matome, crc32($this->thread->keydat));
     //} else {
     $this->spmObjName = sprintf('spm%u', crc32($this->thread->keydat));
     //}
 }
예제 #10
0
/*****************************************************************************/

$edit_structure_object = Request::option('edit_structure_object');
if ($view == "resources"){
    require_once $RELATIVE_PATH_RESOURCES . '/views/ShowThread.class.php';


    if ($edit_structure_object) {
        echo"<form method=\"POST\" action=\"".URLHelper::getLink()."\">";
        echo CSRFProtection::tokenTag();
    }

    $range_id = $user->id;

    $resUser=new ResourcesUserRoots($range_id);
    $thread=new ShowThread();

    $roots=$resUser->getRoots();
    if (is_array($roots)) {
        foreach ($roots as $a) {
            $thread->showThreadLevel($a);
        }
        echo "<br>&nbsp;";
    } else {
        echo "</td></tr>";
        $msg->displayMsg(12);
    }

    if ($edit_structure_object) {
        echo "</form>";
    }
예제 #11
-1
 /**
  * コンストラクタ
  */
 public function __construct($aThread, $matome = false)
 {
     parent::__construct($aThread, $matome);
     global $_conf;
     $this->_url_handlers = array('plugin_linkThread', 'plugin_link2chSubject');
     // +Wiki
     if (isset($GLOBALS['linkPluginCtl'])) {
         $this->_url_handlers[] = 'plugin_linkPlugin';
     }
     if (isset($GLOBALS['replaceImageUrlCtl'])) {
         $this->_url_handlers[] = 'plugin_replaceImageUrl';
     }
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         $this->_url_handlers[] = 'plugin_imageCache2';
     } elseif ($_conf['preview_thumbnail']) {
         $this->_url_handlers[] = 'plugin_viewImage';
     }
     if ($_conf['link_youtube']) {
         $this->_url_handlers[] = 'plugin_linkYouTube';
     }
     if ($_conf['link_niconico']) {
         $this->_url_handlers[] = 'plugin_linkNicoNico';
     }
     $this->_url_handlers[] = 'plugin_linkURL';
     // imepitaのURLを加工してImageCache2させるプラグインを登録
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         $this->addURLHandler(array($this, 'plugin_imepitaToImageCache2'));
     }
     // サムネイル表示制限数を設定
     if (!isset($GLOBALS['pre_thumb_unlimited']) || !isset($GLOBALS['pre_thumb_limit'])) {
         if (isset($_conf['pre_thumb_limit']) && $_conf['pre_thumb_limit'] > 0) {
             $GLOBALS['pre_thumb_limit'] = $_conf['pre_thumb_limit'];
             $GLOBALS['pre_thumb_unlimited'] = false;
         } else {
             $GLOBALS['pre_thumb_limit'] = null;
             // ヌル値だとisset()はfalseを返す
             $GLOBALS['pre_thumb_unlimited'] = true;
         }
     }
     $GLOBALS['pre_thumb_ignore_limit'] = false;
     // アクティブモナー初期化
     if (P2_ACTIVEMONA_AVAILABLE) {
         ExpackLoader::initActiveMona($this);
     }
     // ImageCache2初期化
     if (P2_IMAGECACHE_AVAILABLE == 2) {
         ExpackLoader::initImageCache($this);
     }
     // 非同期レスポップアップ・SPM初期化
     $js_id = sprintf('%u', crc32($this->thread->keydat));
     if ($this->_matome) {
         $this->asyncObjName = "t{$this->_matome}asp{$js_id}";
         $this->spmObjName = "t{$this->_matome}spm{$js_id}";
     } else {
         $this->asyncObjName = "asp{$js_id}";
         $this->spmObjName = "spm{$js_id}";
     }
     // 名無し初期化
     $this->setBbsNonameName();
 }