--- rep2ex-080917-0800/rep2/lib/ShowThread.php 2008-09-15 02:25:52.000000000 +0900 +++ rep2/lib/ShowThread.php 2009-02-11 16:29:38.000000000 +0900 @@ -8,33 +8,11 @@ // {{{ ShowThread + abstract class ShowThread { // {{{ constants - const LINK_REGEX = '{ -(?P(<[Aa][ ].+?>)(.*?)()) # リンク(PCREの特性上、必ずこのパターンを最初に試行する) -| -(?: - (?P # 引用 - ((?:>|>){1,2}[ ]?) # 引用符 - ( - (?:[1-9]\\d{0,3}) # 1つ目の番号 - (?: - (?:[ ]?(?:[,=]|、)[ ]?[1-9]\\d{0,3})+ # 連続 - | - -(?:[1-9]\\d{0,3})? # 範囲 - )? - ) - (?=\\D|$) - ) # 引用ここまで -| # PHP 5.3縛りにするなら、↓の\'のエスケープを外し、NOWDOCにする - (?P(ftp|h?t?tps?)://([0-9A-Za-z][\\w;/?:@=&$\\-_.+!*\'(),#%\\[\\]^~]+)) # URL - ([^\\s<>]*) # URLの直後、タグorホワイトスペースが現れるまでの文字列 -| - (?PID:[ ]?([0-9A-Za-z/.+]{8,11})(?=[^0-9A-Za-z/.+]|$)) # ID(8,10桁 +PC/携帯識別フラグ) -) -}x'; // }}} // {{{ properties @@ -52,12 +30,21 @@ protected $_aborn_nums; // あぼーんレス番号を格納する配列 protected $_ng_nums; // NGレス番号を格納する配列 + protected $_highlight_nums; // ハイライトレス番号を格納する配列 public $thread; // スレッドオブジェクト public $activeMona; // アクティブモナー・オブジェクト public $am_enabled = false; // アクティブモナーが有効か否か + protected $anchor_prefix; // アンカー引用子の正規表現 + protected $anchor_prefix_abon; // あぼーん用アンカー引用子の正規表現 + + protected $anchor_num; // アンカー先の正規表現 + protected $anchor_range; // アンカー先範囲の正規表現 + + protected $LINK_REGEX; // リンク検出用正規表現 + // }}} // {{{ constructor @@ -92,6 +79,36 @@ $this->_aborn_nums = array(); $this->_ng_nums = array(); + $this->_highlight_nums = array(); + + $anchor_space='(?:[ ]| )'; // アンカー用空白文字の正規表現 + $this->anchor_prefix="(?:>|>|<|<|)|》|≫){1,2}{$anchor_space}?"; // アンカー引用子の正規表現 + $this->anchor_prefix_abon=">{1,2}{$anchor_space}?"; // あぼーん用アンカー引用子の正規表現 + + $this->anchor_num='[1-9]\\d{0,3}'; // アンカー先の正規表現 + $this->anchor_range="{$this->anchor_num}(?:(?:-|‐){$this->anchor_num})?"; + + $this->LINK_REGEX = "{ +(?P(<[Aa][ ].+?>)(.*?)()) # リンク(PCREの特性上、必ずこのパターンを最初に試行する) +| +(?: + (?P # 引用[5] + ({$this->anchor_prefix}) # 引用符[6] + ( + {$this->anchor_range} # 1つ目の番号範囲 + (?:{$anchor_space}?(?:[,=]|、|・){$anchor_space}? # 連続 + {$this->anchor_range} # 2つ目以降の番号範囲 + )* + ) + (?=\\D|$) + ) # 引用ここまで +| # PHP 5.3縛りにするなら、↓の\'のエスケープを外し、NOWDOCにする + (?P(ftp|h?t?tps?)://([0-9A-Za-z][\\w;/?:@=&$\\-_.+!*\'(),#%\\[\\]^~]+)) # URL + ([^\\s<>]*) # URLの直後、タグorホワイトスペースが現れるまでの文字列 +| + (?PID:[ ]?([0-9A-Za-z/.+]{8,11})(?=[^0-9A-Za-z/.+]|$)) # ID(8,10桁 +PC/携帯識別フラグ) +) +}x"; } // }}} @@ -486,7 +503,7 @@ */ public function transLink($str) { - return preg_replace_callback(self::LINK_REGEX, array($this, 'link_callback'), $str); + return preg_replace_callback($this->LINK_REGEX, array($this, 'link_callback'), $str); } // }}} @@ -513,6 +530,8 @@ $s['id'] = $s[12]; } + $following = ''; + // マッチしたサブパターンに応じて分岐 // リンク if ($s['link']) { @@ -525,10 +544,10 @@ // 引用 } elseif ($s['quote']) { - if (strpos($s[7], '-') !== false) { - return $this->quote_res_range_callback(array($s['quote'], $s[6], $s[7])); - } - return preg_replace_callback('/((?:>|>)+ ?)?([1-9]\\d{0,3})(?=\\D|$)/', +// if (strpos($s[7], '-') !== false) { +// return $this->quote_res_range_callback(array($s['quote'], $s[6], $s[7])); +// } + return preg_replace_callback("/({$this->anchor_prefix})?({$this->anchor_range})(?=\\D|$)/", array($this, 'quote_res_callback'), $s['quote']); // http or ftp のURL @@ -580,7 +599,12 @@ //HostCheck::isAddrPrivate($purl['host']) || P2Util::isHostExample($purl['host'])) { - return $orig; + return $orig . $following; + } + + //pita.st 複数画像対応 + if ($_conf['expack.ic2.enabled'] && preg_match('{^https?://[^\.]+?.pita.st/+?}i', $url) ) { + return $this->pita_expansion($url); } // URLを処理 @@ -595,7 +619,7 @@ } } - return $orig; + return $orig . $following; } // }}}