Example #1
0
 /**
  * @access  protected
  * @return  void
  */
 function setBbsNonameName()
 {
     $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;
         }
     }
 }
Example #2
0
 /**
  * SETTING.TXT をダウンロードして、パースして、キャッシュする
  *
  * @access  public
  * @return  true|null|false  成功|更新なし(キャッシュ)|失敗
  */
 function downloadSettingTxt()
 {
     global $_conf;
     $perm = $_conf['dl_perm'] ? $_conf['dl_perm'] : 0606;
     FileCtl::mkdirFor($this->setting_txt);
     // 板ディレクトリが無ければ作る
     $modified = null;
     if (file_exists($this->setting_srd) && file_exists($this->setting_txt)) {
         // 更新しない場合は、その場で抜けてしまう
         if (!empty($_GET['norefresh']) || isset($_REQUEST['word'])) {
             return null;
             // キャッシュが新しい場合も抜ける
         } elseif ($this->isSettingSrdCacheFresh()) {
             return null;
         }
         $modified = gmdate('D, d M Y H:i:s', filemtime($this->setting_txt)) . ' GMT';
     }
     // DL
     /*
     // PHP5
     if (!class_exists('HTTP_Request', false)) {
         require 'HTTP/Request.php';
     }
     */
     require_once 'HTTP/Request.php';
     $params = array();
     $params['timeout'] = $_conf['fsockopen_time_limit'];
     if ($_conf['proxy_use']) {
         $params['proxy_host'] = $_conf['proxy_host'];
         $params['proxy_port'] = $_conf['proxy_port'];
     }
     $req = new HTTP_Request($this->url, $params);
     $modified && $req->addHeader('If-Modified-Since', $modified);
     $req->addHeader('User-Agent', 'Monazilla/1.00 (' . $_conf['p2uaname'] . '/' . $_conf['p2version'] . ')');
     $response = $req->sendRequest();
     $error_msg = null;
     if (PEAR::isError($response)) {
         $error_msg = $response->getMessage();
     } else {
         $code = $req->getResponseCode();
         if ($code == 302) {
             // ホストの移転を追跡
             require_once P2_LIB_DIR . '/BbsMap.php';
             $new_host = BbsMap::getCurrentHost($this->host, $this->bbs);
             if ($new_host != $this->host) {
                 $aNewSettingTxt = new SettingTxt($new_host, $this->bbs);
                 return $aNewSettingTxt->downloadSettingTxt();
             }
         }
         if (!($code == 200 || $code == 206 || $code == 304)) {
             //var_dump($req->getResponseHeader());
             $error_msg = $code;
         }
     }
     // DLエラー
     if (strlen($error_msg)) {
         P2Util::pushInfoHtml(sprintf('<div>Error: %s<br>p2 info - %s に接続できませんでした。</div>', hs($error_msg), P2View::tagA(P2Util::throughIme($this->url), hs($this->url), array('target' => $_conf['ext_win_target']))));
         touch($this->setting_txt);
         // DL失敗した場合(404)も touch する
         touch($this->setting_srd);
         return false;
     }
     $body = $req->getResponseBody();
     // DL成功して かつ 更新されていたら保存
     if ($body && $code != 304) {
         // したらば or be.2ch.net ならEUCをSJISに変換
         if (P2Util::isHostJbbsShitaraba($this->host) || P2Util::isHostBe2chNet($this->host)) {
             $body = mb_convert_encoding($body, 'SJIS-win', 'eucJP-win');
         }
         if (false === FileCtl::filePutRename($this->setting_txt, $body)) {
             die('Error: cannot write file');
         }
         chmod($this->setting_txt, $perm);
         // パースして
         if (!$this->setSettingArrayFromSettingTxt()) {
             return false;
         }
         // srd保存する
         if (!$this->saveSettingSrd($this->setting_array)) {
             return false;
         }
     } else {
         // touchすることで更新インターバルが効くので、しばらく再チェックされなくなる
         touch($this->setting_txt);
         // 同時にキャッシュもtouchしないと、setting_txtとsetting_srdで更新時間がずれて、
         // 毎回ここまで処理が来る(サーバへのヘッダリクエストが飛ぶ)場合がある。
         touch($this->setting_srd);
     }
     return true;
 }
Example #3
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));
     //}
 }
Example #4
0
 /**
  * SETTING.TXT をダウンロードして、パースして、キャッシュする
  *
  * @return boolean 実行成否
  */
 public function downloadSettingTxt()
 {
     global $_conf;
     // まちBBS・したらば は SETTING.TXT が存在しないものとする
     if (P2Util::isHostMachiBbs($this->_host) || P2Util::isHostJbbsShitaraba($this->_host)) {
         return false;
     }
     FileCtl::mkdirFor($this->_setting_txt);
     // 板ディレクトリが無ければ作る
     if (file_exists($this->_setting_srd) && file_exists($this->_setting_txt)) {
         // 更新しない場合は、その場で抜けてしまう
         if (!empty($_GET['norefresh']) || isset($_REQUEST['word'])) {
             return true;
             // キャッシュが新しい場合も抜ける
         } elseif ($this->isCacheFresh()) {
             return true;
         }
         $modified = http_date(filemtime($this->_setting_txt));
     } else {
         $modified = false;
     }
     // DL
     $params = array();
     $params['timeout'] = $_conf['http_conn_timeout'];
     $params['readTimeout'] = array($_conf['http_read_timeout'], 0);
     if ($_conf['proxy_use']) {
         $params['proxy_host'] = $_conf['proxy_host'];
         $params['proxy_port'] = $_conf['proxy_port'];
     }
     $req = new HTTP_Request($this->_url, $params);
     $modified && $req->addHeader('If-Modified-Since', $modified);
     $req->addHeader('User-Agent', "Monazilla/1.00 ({$_conf['p2ua']})");
     $response = $req->sendRequest();
     if (PEAR::isError($response)) {
         $error_msg = $response->getMessage();
     } else {
         $code = $req->getResponseCode();
         if ($code == 302) {
             // ホストの移転を追跡
             $new_host = BbsMap::getCurrentHost($this->_host, $this->_bbs);
             if ($new_host != $this->_host) {
                 $aNewSettingTxt = new SettingTxt($new_host, $this->_bbs);
                 $body = $aNewSettingTxt->downloadSettingTxt();
                 return true;
             }
         }
         if (!($code == 200 || $code == 206 || $code == 304)) {
             //var_dump($req->getResponseHeader());
             $error_msg = $code;
         }
     }
     // DLエラー
     if (isset($error_msg) && strlen($error_msg) > 0) {
         $url_t = P2Util::throughIme($this->_url);
         $info_msg_ht = "<p class=\"info-msg\">Error: {$error_msg}<br>";
         $info_msg_ht .= "rep2 info: <a href=\"{$url_t}\"{$_conf['ext_win_target_at']}>{$this->_url}</a> に接続できませんでした。</p>";
         P2Util::pushInfoHtml($info_msg_ht);
         touch($this->_setting_txt);
         // DL失敗した場合も touch
         return false;
     }
     $body = $req->getResponseBody();
     // DL成功して かつ 更新されていたら保存
     if ($body && $code != '304') {
         // したらば or be.2ch.net ならEUCをSJISに変換
         if (P2Util::isHostJbbsShitaraba($this->_host) || P2Util::isHostBe2chNet($this->_host)) {
             $body = mb_convert_encoding($body, 'CP932', 'CP51932');
         }
         if (FileCtl::file_write_contents($this->_setting_txt, $body) === false) {
             p2die('cannot write file');
         }
         // パースしてキャッシュを保存する
         if (!$this->cacheParsedSettingTxt()) {
             return false;
         }
     } else {
         // touchすることで更新インターバルが効くので、しばらく再チェックされなくなる
         touch($this->_setting_txt);
         // 同時にキャッシュもtouchしないと、_setting_txtと_setting_srdで更新時間がずれ、
         // 毎回ここまで処理が来る(サーバへのヘッダリクエストが飛ぶ)場合がある。
         touch($this->_setting_srd);
     }
     return true;
 }
Example #5
0
    if ($_conf['editor_srcfix'] == 1 || $_conf['editor_srcfix'] == 2 && preg_match('/pc\\d+\\.2ch\\.net/', $host)) {
        $htm['src_fix'] = <<<EOP
<input type="checkbox" id="fix_source" name="fix_source" value="1"><label for="fix_source">src</label>
EOP;
    }
}
// }}}
// {{{ 書き込みプレビュー
$htm['dpreview_onoff'] = '';
$htm['dpreview_amona'] = '';
$htm['dpreview'] = '';
$htm['dpreview2'] = '';
if (!$_conf['ktai'] && $_conf['expack.editor.dpreview']) {
    $_dpreview_noname = 'null';
    if (P2Util::isHost2chs($host)) {
        $_dpreview_st = new SettingTxt($host, $bbs);
        $_dpreview_st->setSettingArray();
        if (!empty($_dpreview_st->setting_array['BBS_NONAME_NAME'])) {
            $_dpreview_noname = $_dpreview_st->setting_array['BBS_NONAME_NAME'];
            $_dpreview_noname = '"' . StrCtl::toJavaScript($_dpreview_noname) . '"';
        }
    }
    $_dpreview_hide = 'false';
    if ($_conf['expack.editor.dpreview'] == 2) {
        if (P2Util::isBrowserSafariGroup() && basename($_SERVER['SCRIPT_NAME']) != 'post_form.php') {
            $_dpreview_hide = 'true';
        }
        $_dpreview_pos = 'dpreview2';
    } else {
        $_dpreview_pos = 'dpreview';
    }