From 6f9729d03d045b668869e863a6daccb3730e47b7 Mon Sep 17 00:00:00 2001 From: 208 Date: Sun, 26 Jul 2020 17:41:42 +0900 Subject: [PATCH 01/36] =?UTF-8?q?=E6=9D=BF=E3=83=AA=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=AEhttps=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix http://egg.5ch.net/test/read.cgi/software/1581552388/213 --- lib/BrdMenu.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/BrdMenu.php b/lib/BrdMenu.php index e19ac251c..09b637dbb 100644 --- a/lib/BrdMenu.php +++ b/lib/BrdMenu.php @@ -50,7 +50,7 @@ public function setBrdMatch($brdName) if (preg_match('/(html?|cgi)$/', $brdName)) { $this->format = 'html'; $this->cate_match = '{(.+)
.*$}i'; - $this->ita_match = '{^(.+)(
)?$}i'; + $this->ita_match = '{^(.+)(
)?$}i'; // brd形式 } else { $this->format = 'brd'; From 59c5e3d3977b4663e1daf20f0b205bde82916316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Sun, 26 Jul 2020 17:41:44 +0900 Subject: [PATCH 02/36] =?UTF-8?q?tGrep=20=E3=82=B9=E3=83=AC=E3=82=BF?= =?UTF-8?q?=E3=82=A4=E6=A4=9C=E7=B4=A2=E3=81=AB=E6=A4=9C=E7=B4=A2=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=83=93=E3=82=B9=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 讀懃エ「繧オ繝シ繝薙せ蛻繧頑崛縺医ョ霑ス蜉 * ff5ch.syoboi.jp繧オ繝昴シ繝医ョ霑ス蜉 * find.5ch.net繧オ繝昴シ繝医ョ霑ス蜉 --- conf/conf_user_def_ex.inc.php | 10 +++++ lib/menu.inc.php | 2 +- rep2/dig2ch.php | 2 +- rep2/edit_conf_user.php | 1 + rep2/ff5ch.php | 77 +++++++++++++++++++++++++++++++++++ rep2/find5ch.php | 76 ++++++++++++++++++++++++++++++++++ rep2/tgrepc.php | 19 ++++++--- 7 files changed, 180 insertions(+), 7 deletions(-) create mode 100644 rep2/ff5ch.php create mode 100644 rep2/find5ch.php diff --git a/conf/conf_user_def_ex.inc.php b/conf/conf_user_def_ex.inc.php index 7e584ce58..cddbfbd8d 100644 --- a/conf/conf_user_def_ex.inc.php +++ b/conf/conf_user_def_ex.inc.php @@ -66,6 +66,16 @@ $conf_user_def['expack.tgrep.recent2_num'] = 10; // (10) $conf_user_rules['expack.tgrep.recent2_num'] = array('notIntExceptMinusToDef'); +// 検索に使用する検索エンジン +$conf_user_def['expack.tgrep.engine'] = '4'; +$conf_user_sel['expack.tgrep.engine'] = array( + '0' => sprintf('tGrep (%s)', parse_url($_conf['expack.tgrep_url'], PHP_URL_HOST)), // tGrep(互換)サービス + '1' => 'dig (dig.5ch.net)', // もうずっとサービス停止中 + '2' => 're.Find2ch (refind2ch.org)', // https://refind2ch.org/about + '3' => '5chスレタイ検索 (ff5ch.syoboi.jp)', // http://z.syoboi.jp/web/ff2ch/ + '4' => '5ちゃんねるスレタイ検索 (find.5ch.net)', // http://find.5ch.net/ +); + // }}} // {{{ スマートポップアップメニュー diff --git a/lib/menu.inc.php b/lib/menu.inc.php index 0878ac119..65c084287 100644 --- a/lib/menu.inc.php +++ b/lib/menu.inc.php @@ -368,7 +368,7 @@ function chMenuColor(idnum){  ログイン管理
 設定管理
 datのインポート
-  find.2ch.net +  find.5ch.net \n EOP; diff --git a/rep2/dig2ch.php b/rep2/dig2ch.php index 555ecd784..47372358c 100644 --- a/rep2/dig2ch.php +++ b/rep2/dig2ch.php @@ -9,7 +9,7 @@ function dig2chsearch($query) //$query_q = preg_replace('/(\s+)/' , '\+' ,$query_arry['q']); $query_arry['q'] = urlencode($query_arry['q']); - $url = $_conf['test.dig2ch_url'] . '?AndOr=' . $query_arry['AndOr'] . '&maxResult=' . $query_arry['maxResult'] . '&atLeast=1&Sort=' . $query_arry['Sort'] . '&Link=1&Bbs=all&924=' . $query_arry['924'] . '&json=1&keywords=' . $query_arry['q']; + $url = 'https://dig.5ch.net/' . '?AndOr=' . $query_arry['AndOr'] . '&maxResult=' . $query_arry['maxResult'] . '&atLeast=1&Sort=' . $query_arry['Sort'] . '&Link=1&Bbs=all&924=' . $query_arry['924'] . '&json=1&keywords=' . $query_arry['q']; try { $req = P2Commun::createHTTPRequest ($url, HTTP_Request2::METHOD_GET); diff --git a/rep2/edit_conf_user.php b/rep2/edit_conf_user.php index 19a0a031e..e247e03ff 100644 --- a/rep2/edit_conf_user.php +++ b/rep2/edit_conf_user.php @@ -606,6 +606,7 @@ array('expack.tgrep.quicksearch', '一発検索'), array('expack.tgrep.recent_num', '検索履歴を記録する数(記録しない:0)'), array('expack.tgrep.recent2_num', 'サーチボックスに検索履歴を記録する数、Safari専用(記録しない:0)'), + array('expack.tgrep.engine', '検索に使用する検索エンジン') ); printEditConfGroupHtml($groupname, $conflist, $flags); } diff --git a/rep2/ff5ch.php b/rep2/ff5ch.php new file mode 100644 index 000000000..efb37939a --- /dev/null +++ b/rep2/ff5ch.php @@ -0,0 +1,77 @@ +setHeader('Referer', $referer); + + $response = P2Commun::getHTTPResponse($req); + + $code = $response->getStatus(); + if ($code != 200) { + p2die("HTTP Error - {$code}"); + } + + $body = $response->getBody(); + } catch (Exception $e) { + p2die($e->getMessage()); + } + + // FIXME 多少の構造変化に耐えられるような正規表現へ修正 + $re = '/(?P.+)<\/a> \((?\d+)\)<\/span>\s*(?.+)<\/a>\s*(?.+)<\/span>\s*<\/li>/m'; + + preg_match_all($re, $body, $threads, PREG_SET_ORDER); + + $result = array(); + $boards = array(); + $hits = array(); + $names = array(); + + $now = strtotime($response->getHeader('Date')); + + foreach ($threads as $n => $t) { + $host = parse_url($t['thread_url'], PHP_URL_HOST); + $thread_key = array_slice(explode('/', $t['thread_url']), -2, 1)[0]; + $bbs = array_slice(explode('/', $t['board_url']), -2, 1)[0]; + $created_at = strtotime($t['created_at'] . ' +0900'); + $dayres = intval($t['thread_res_count']) / ($now - $created_at) * 86400; + + $result['threads'][$n] = new stdClass; + $result['threads'][$n]->title = $t['thread_name']; + $result['threads'][$n]->host = $host; + $result['threads'][$n]->bbs = $bbs; + $result['threads'][$n]->tkey = $thread_key; + $result['threads'][$n]->resnum = $t['thread_res_count']; + $result['threads'][$n]->ita = $t['board_name']; + $result['threads'][$n]->dayres = $dayres; + + $bkey = md5($host . '-' . $bbs . '-' . $t['board_name']); + if (!isset($boards[$bkey])) { + $board = new stdClass; + $board->host = $host; + $board->bbs = $bbs; + $names[$bkey] = $board->name = $t['board_name']; + $hits[$bkey] = $board->hits = 1; + $boards[$bkey] = $board; + } else { + $hits[$bkey] = ++$boards[$bkey]->hits; + $names[$bkey] = $boards[$bkey]->name; + } + } + + $result['modified'] = $response->getHeader('Date'); + $result['profile']['regex'] = '/(' . $q . ')/i'; + $result['profile']['hits'] = count($threads); + array_multisort($hits, SORT_DESC, $names, $boards); + $result['profile']['boards'] = $boards; + + return $result; +} diff --git a/rep2/find5ch.php b/rep2/find5ch.php new file mode 100644 index 000000000..8ea6e5413 --- /dev/null +++ b/rep2/find5ch.php @@ -0,0 +1,76 @@ +setHeader('Referer', $referer); + + $response = P2Commun::getHTTPResponse($req); + + $code = $response->getStatus(); + if ($code != 200) { + p2die("HTTP Error - {$code}"); + } + + $body = $response->getBody(); + } catch (Exception $e) { + p2die($e->getMessage()); + } + + mb_convert_variables('SHIFT-JIS', 'UTF-8', $body); + + // FIXME 多少の構造変化に耐えられるような正規表現へ修正 + $re = '~
\n?\n?\n?\n?
\n?\n?
(?.+)
\n?
(?P.+)/日
\n?
~m'; + preg_match_all($re, $body, $threads, PREG_SET_ORDER); + + mb_convert_variables('UTF-8', 'SHIFT-JIS', $threads); + + $result = array(); + $boards = array(); + $hits = array(); + $names = array(); + + foreach ($threads as $n => $t) { + $host = parse_url($t['thread_url'], PHP_URL_HOST); + $thread_key = array_slice(explode('/', $t['thread_url']), -1, 1)[0]; + $bbs = array_slice(explode('/', $t['board_url']), -2, 1)[0]; + + $result['threads'][$n] = new stdClass; + $result['threads'][$n]->title = $t['thread_name']; + $result['threads'][$n]->host = $host; + $result['threads'][$n]->bbs = $bbs; + $result['threads'][$n]->tkey = $thread_key; + $result['threads'][$n]->resnum = $t['thread_res_count']; + $result['threads'][$n]->ita = $t['board_name']; + $result['threads'][$n]->dayres = $t['thread_dayres']; + + $bkey = md5($host . '-' . $bbs . '-' . $t['board_name']); + if (!isset($boards[$bkey])) { + $board = new stdClass; + $board->host = $host; + $board->bbs = $bbs; + $names[$bkey] = $board->name = $t['board_name']; + $hits[$bkey] = $board->hits = 1; + $boards[$bkey] = $board; + } else { + $hits[$bkey] = ++$boards[$bkey]->hits; + $names[$bkey] = $boards[$bkey]->name; + } + } + + $result['modified'] = $response->getHeader('Date'); + $result['profile']['regex'] = '/(' . $q . ')/i'; + $result['profile']['hits'] = count($threads); + array_multisort($hits, SORT_DESC, $names, $boards); + $result['profile']['boards'] = $boards; + + return $result; +} diff --git a/rep2/tgrepc.php b/rep2/tgrepc.php index 3ab668323..91c2a4d2f 100644 --- a/rep2/tgrepc.php +++ b/rep2/tgrepc.php @@ -351,7 +351,7 @@ function tgrep_search($query) { global $_conf; - if (!$_conf['test.search_dig2ch']) { + if ($_conf['expack.tgrep.engine'] === "0") { $client = new HTTP_Client(); $client->setDefaultHeader('User-Agent', 'p2-tgrep-client'); $code = $client->get($_conf['expack.tgrep_url'] . '?' . $query); @@ -366,11 +366,20 @@ function tgrep_search($query) p2die('Error: 検索結果の展開に失敗しました。'); } return $result; - } else { -// require_once './dig2ch.php'; -// return dig2chsearch($query); // 追加 + } elseif ($_conf['expack.tgrep.engine'] === "1") { + require_once './dig2ch.php'; + return dig2chsearch($query); + } elseif ($_conf['expack.tgrep.engine'] === "2") { require_once './refind2ch.php'; - return refind2ch_search($query); // 追加 + return refind2ch_search($query); + } elseif ($_conf['expack.tgrep.engine'] === "3") { + require_once './ff5ch.php'; + return ff5ch_search($query); + } elseif ($_conf['expack.tgrep.engine'] === "4") { + require_once './find5ch.php'; + return find5ch_search($query); + } else { + p2die('Error: 未知の検索エンジンが指定されました。tGrepの設定から選択してください。'); } } From b207a001ebdbac050470fa2b3e3263945d241448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Sun, 26 Jul 2020 17:41:46 +0900 Subject: [PATCH 03/36] =?UTF-8?q?PHP=208=E3=82=B5=E3=83=9D=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=AE=E3=81=9F=E3=82=81=E3=81=AE=E6=94=B9=E4=BF=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 蟒豁「縺輔l縺滄未謨ー縺ョ鄂ョ縺肴鋤縺 * 蟒豁「縺輔l縺滓ァ区枚縺ョ鄂ョ縺肴鋤縺 * 螟画焚縺ョ蛻晄悄蛹 * 繝ゥ繧、繝悶Λ繝ェ縺ョ繧「繝繝励ョ繝シ繝 --- composer.json | 74 ++++++++++++++++++++------------- conf/conf_user_def.inc.php | 4 +- lib/FileCtl.php | 4 +- lib/LastmodifyTxt.php | 1 + lib/Login.php | 2 +- lib/Session.php | 2 +- lib/SettingTxt.php | 6 +-- lib/ShowThreadPc.php | 14 +++++-- lib/StrCtl.php | 2 +- lib/SubjectTxt.php | 2 +- lib/UA.php | 2 +- lib/bootstrap.php | 22 +++++++++- lib/emoji.inc.php | 2 +- lib/expack/ExpackLoader.php | 2 +- lib/expack/tgrep/view_x.inc.php | 14 +++---- lib/fontconfig.inc.php | 2 + lib/live/live_view_ctl.inc.php | 1 + lib/login_first.inc.php | 2 +- lib/post_form_options.inc.php | 2 +- lib/read_header.inc.php | 4 +- lib/sb_print.inc.php | 2 + lib/wiki/ReplaceImageUrlCtl.php | 1 + rep2/edit_conf_user.php | 2 +- rep2/edit_user_font.php | 2 +- rep2/editpref.php | 16 +++---- rep2/ic2.php | 7 ++-- rep2/ic2_getter.php | 2 +- rep2/ic2_manager.php | 2 +- rep2/ic2_setter.php | 2 +- rep2/ic2_viewtable.php | 2 +- rep2/info_sp.php | 4 +- rep2/iv2.php | 4 +- rep2/live_frame.php | 2 + rep2/post.php | 4 +- rep2/read_copy_k.php | 2 +- rep2/read_new.php | 4 +- 36 files changed, 142 insertions(+), 80 deletions(-) diff --git a/composer.json b/composer.json index 4714155ec..6f13e1e12 100644 --- a/composer.json +++ b/composer.json @@ -8,37 +8,55 @@ "url": "https://pear.php.net" }, { - "type": "vcs", - "url": "https://github.com/open774/quickform" + "type": "git", + "url": "https://github.com/openpsa/quickform.git" + }, + { + "type": "git", + "url": "https://github.com/mikoim/html_template_flexy.git" } ], "require": { - "php": ">=5.3.6", - "rsky/pear-core-min": "dev-master", - "rsky/pear-pager": ">=2.4.9beta2", - "rsky/pear-html_template_flexy": ">=1.3.13alpha6", - "pear-pear.php.net/benchmark": "1.2.9", - "pear-pear.php.net/cache_lite": "1.7.15", - "pear-pear.php.net/db": "1.7.14", - "pear-pear.php.net/db_dataobject": "1.11.2", - "pear-pear.php.net/date": "1.4.7", - "pear-pear.php.net/file": "1.4.1", - "pear-pear.php.net/file_util": "1.0.0", - "pear-pear.php.net/html_common": "1.2.5", - "2ch774/quickform": "dev-master", - "pear-pear.php.net/http_request2": "2.2.1", - "pear-pear.php.net/net_socket": "1.0.10", - "pear-pear.php.net/net_url": "1.0.15", - "pear-pear.php.net/net_url2": "2.1.1", - "pear-pear.php.net/net_useragent_mobile": "1.0.0", - "pear-pear.php.net/validate": "0.8.5", - "pear-pear.php.net/var_dump": "1.0.4", - "pear-pear.php.net/xml_parser": "1.3.4", - "pear-pear.php.net/xml_rss": "1.0.2", - "symfony/console": "2.2.*", - "symfony/yaml": "2.2.*", + "php": ">=5.5", + "ext-curl": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-pcre": "*", + "ext-pdo": "*", + "ext-phar": "*", + "ext-session": "*", + "ext-spl": "*", + "ext-xml": "*", + "ext-zlib": "*", "jakeasmith/http_build_url": "1.0.*", - "dropbox/dropbox-sdk": "dev-master" - + "openpsa/quickform": "dev-master", + "pear-pear.php.net/benchmark": "1.2.*", + "pear-pear.php.net/cache_lite": "1.*", + "pear-pear.php.net/date": "1.4.*", + "pear-pear.php.net/db": "1.10.*", + "pear-pear.php.net/db_dataobject": "1.11.*", + "pear-pear.php.net/file": "1.4.*", + "pear-pear.php.net/file_util": "1.0.*", + "pear-pear.php.net/http_request2": "2.3.*", + "pear-pear.php.net/net_socket": "1.2.*", + "pear-pear.php.net/net_url": "1.0.*", + "pear-pear.php.net/net_url2": "2.2.*", + "pear-pear.php.net/net_useragent_mobile": "1.0.*", + "pear-pear.php.net/pager": "2.5.*", + "pear-pear.php.net/validate": "0.8.*", + "pear-pear.php.net/var_dump": "1.0.*", + "pear-pear.php.net/xml_parser": "1.3.*", + "pear-pear.php.net/xml_rss": "1.1.*", + "pear/html_template_flexy": "dev-master", + "symfony/console": "5.1.*", + "symfony/yaml": "5.1.*" + }, + "suggest": { + "ext-exif": "Needed to show Exif in IC2", + "ext-pdo_mysql": "Needed to use MySQL in IC2", + "ext-pdo_pgsql": "Needed to use PostgreSQL in IC2", + "ext-pdo_sqlite": "Needed to use SQLite in IC2" } } diff --git a/conf/conf_user_def.inc.php b/conf/conf_user_def.inc.php index acefca2f0..34bb94443 100644 --- a/conf/conf_user_def.inc.php +++ b/conf/conf_user_def.inc.php @@ -37,9 +37,9 @@ 必要なければ、無指定("")にする。 */ // ("http://azlucky.s25.xrea.com/2chboard/bbsmenu.html") // 2ch + 外部BBS -// ("http://menu.2ch.net/bbsmenu.html") // 2ch基本 +// ("https://menu.5ch.net/bbsmenu.html") // 2ch基本 -$conf_user_def['brdfile_online'] = "http://azlucky.s25.xrea.com/2chboard/bbsmenu.html"; +$conf_user_def['brdfile_online'] = "https://menu.5ch.net/bbsmenu.html"; $conf_user_rules['brdfile_online'] = array('emptyToDef', 'invalidUrlToDef'); // }}} diff --git a/lib/FileCtl.php b/lib/FileCtl.php index b502454de..fec39b825 100644 --- a/lib/FileCtl.php +++ b/lib/FileCtl.php @@ -335,7 +335,9 @@ static public function file_read_lines($filename, $flags = 0, $context = null) if (($flags & FILE_IGNORE_NEW_LINES) && $lines && strlen($lines[0]) && substr($lines[0], -1) == "\r") { - $lines = array_map(create_function('$l', 'return rtrim($l, "\\r");'), $lines); + $lines = array_map(function ($l) { + return rtrim($l, "\\r"); + }, $lines); if ($flags & FILE_SKIP_EMPTY_LINES) { $lines = array_filter($lines, 'strlen'); } diff --git a/lib/LastmodifyTxt.php b/lib/LastmodifyTxt.php index d2b4437f8..abcb64b97 100644 --- a/lib/LastmodifyTxt.php +++ b/lib/LastmodifyTxt.php @@ -95,6 +95,7 @@ public function downloadLastmodify() $response = P2Commun::getHTTPResponse($req); $code = $response->getStatus(); + $body = ''; if ($code == 302) { // ホストの移転を追跡 $new_host = P2HostMgr::getCurrentHost($this->host, $this->bbs); diff --git a/lib/Login.php b/lib/Login.php index a8157e45a..b97c4673b 100644 --- a/lib/Login.php +++ b/lib/Login.php @@ -302,7 +302,7 @@ private function _authCheck() // }}} - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); // {{{ フォームからログインした時 diff --git a/lib/Session.php b/lib/Session.php index cb0f63908..53422e5a3 100644 --- a/lib/Session.php +++ b/lib/Session.php @@ -256,7 +256,7 @@ private function _checkUA() { // {{{ docomoはUTN時にUA後部が変わるので機種名で検証する - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); if ($mobile->isDoCoMo()) { $mobile_b = Net_UserAgent_Mobile::factory($_SESSION[$this->sess_array]['ua']); if ($mobile_b->getModel() == $mobile->getModel()) { diff --git a/lib/SettingTxt.php b/lib/SettingTxt.php index 027131616..60e5fefa7 100644 --- a/lib/SettingTxt.php +++ b/lib/SettingTxt.php @@ -109,8 +109,8 @@ public function downloadSettingTxt() $code = $response->getStatus(); if ($code == 302) { // ホストの移転を追跡 - $new_host = P2HostMgr::getCurrentHost($this->host, $this->bbs); - if ($new_host != $this->host) { + $new_host = P2HostMgr::getCurrentHost($this->_host, $this->_bbs); + if ($new_host != $this->_host) { $aNewSettingTxt = new SettingTxt($new_host, $this->_bbs); return $aNewSettingTxt->downloadSettingTxt(); } @@ -118,7 +118,7 @@ public function downloadSettingTxt() //var_dump($req->getResponseHeader()); $body = $response->getBody(); // したらば or be.2ch.net ならEUCをSJISに変換 - if (P2HostMgr::isHostJbbsShitaraba($this->host) || P2HostMgr::isHostBe2chs($this->host)) { + if (P2HostMgr::isHostJbbsShitaraba($this->_host) || P2HostMgr::isHostBe2chs($this->_host)) { $body = mb_convert_encoding($body, 'CP932', 'CP51932'); } if (FileCtl::file_write_contents($this->_setting_txt, $body) === false) { diff --git a/lib/ShowThreadPc.php b/lib/ShowThreadPc.php index bf66e50e6..5eebfdd77 100644 --- a/lib/ShowThreadPc.php +++ b/lib/ShowThreadPc.php @@ -1389,6 +1389,7 @@ public function plugin_replaceImageUrl($url, $purl, $str) $serial++; $thumb_id = 'thumbs' . $serial . $this->thumb_id_suffix; $tmp_thumb = './img/ic_load.png'; + $result = ''; $icdb = new ImageCache2_DataObject_Images(); @@ -1429,6 +1430,8 @@ public function plugin_replaceImageUrl($url, $purl, $str) // サムネイルが作成されていているときは画像を直接読み込む if (file_exists($this->thumbnailer->thumbPath($icdb->size, $icdb->md5, $icdb->mime))) { $thumb_url = $this->thumbnailer->thumbUrl($icdb->size, $icdb->md5, $icdb->mime); + $update = null; + // 自動スレタイメモ機能がONでスレタイが記録されていないときはDBを更新 if (!is_null($this->img_memo) && strpos($icdb->memo, $this->img_memo) === false){ $update = new ImageCache2_DataObject_Images(); @@ -1568,7 +1571,9 @@ public function getResColorJs() $backlinks = $this->getQuotebacksJson(); $colors = array(); $backlink_colors = join(',', - array_map(create_function('$x', 'return "\'{$x}\'";'), + array_map(function ($x) { + return "\'{$x}\'"; + }, explode(',', $_conf['backlink_coloring_track_colors'])) ); $prefix = $this->_matome ? "t{$this->_matome}" : ''; @@ -1642,8 +1647,11 @@ public function getIdColorJs() } $hissiCount = $_conf['coloredid.rate.hissi.times']; $mark_colors = join(',', - array_map(create_function('$x', 'return "\'{$x}\'";'), - explode(',', $_conf['coloredid.marking.colors'])) + array_map(function ($x) { + return "\'{$x}\'"; + }, + explode(',', $_conf['coloredid.marking.colors']) + ) ); $fontstyle_bold = empty($STYLE['fontstyle_bold']) ? 'normal' : $STYLE['fontstyle_bold']; $fontweight_bold = empty($STYLE['fontweight_bold']) ? 'normal' : $STYLE['fontweight_bold']; diff --git a/lib/StrCtl.php b/lib/StrCtl.php index 57a331a51..35ce7f961 100644 --- a/lib/StrCtl.php +++ b/lib/StrCtl.php @@ -230,7 +230,7 @@ static public function getKigouPattern($no_escape = false) //$kigou['han'] = array('`', '\(', '\)', '\?', '#', '%', '@', '>', '\!', '\*', '\+', '&'); if ($no_escape) { - $kigou['han'] = array_map(create_function('$str', 'return ltrim($str, "\\\\");'), $kigou['han']); + $kigou['han'] = array_map(function($str){return ltrim($str, "\\\\");}, $kigou['han']); /* foreach ($kigou['han'] as $k => $v) { $kigou['han'][$k] = ltrim($v, '\\'); diff --git a/lib/SubjectTxt.php b/lib/SubjectTxt.php index f45edbba1..0337d45cf 100644 --- a/lib/SubjectTxt.php +++ b/lib/SubjectTxt.php @@ -100,7 +100,7 @@ public function downloadSubject() $modified && $req->setHeader("If-Modified-Since", $modified); $response = P2Commun::getHTTPResponse($req); - + $body = ''; $code = $response->getStatus(); if ($code == 302) { // ホストの移転を追跡 diff --git a/lib/UA.php b/lib/UA.php index e098c8cff..3beea7d7a 100644 --- a/lib/UA.php +++ b/lib/UA.php @@ -364,7 +364,7 @@ static public function getNet_UserAgent_Mobile($ua = null) if (!is_null($ua)) { $nuam = Net_UserAgent_Mobile::factory($ua); } else { - $nuam = Net_UserAgent_Mobile::singleton(); + $nuam = (new Net_UserAgent_Mobile)->singleton(); } if (PEAR::isError($nuam)) { diff --git a/lib/bootstrap.php b/lib/bootstrap.php index 2e44b29b0..5401b2a9f 100644 --- a/lib/bootstrap.php +++ b/lib/bootstrap.php @@ -4,6 +4,26 @@ * conf/conf.inc.php の p2_init() から読み込まれる。 */ +/** + * PHP 8で廃止された関数を呼び出す輩のためのパッチ + * HTTP_Request2 + * Bug #23839 get_magic_quotes_runtime() is deprecated + * https://pear.php.net/bugs/bug.php?id=23839 + **/ +if (version_compare(PHP_VERSION, '8') > 0) { + function set_magic_quotes_runtime($new_setting) { + throw new Exception('とうの昔に廃止されましたよ'); + } + + function get_magic_quotes_runtime() { + return false; + } + + function get_magic_quotes_gpc() { + return false; + } +} + p2_rewrite_vars_for_proxy(); // {{{ ユーザー設定 読込 @@ -156,7 +176,7 @@ $_conf['use_cookies'] = true; $userAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; -$mobile = Net_UserAgent_Mobile::singleton($userAgent); +$mobile = (new Net_UserAgent_Mobile)->singleton($userAgent); // iPhone, iPod Touch or Android if (UA::isIPhoneGroup($userAgent)) { diff --git a/lib/emoji.inc.php b/lib/emoji.inc.php index 71f8197ea..6551493a6 100644 --- a/lib/emoji.inc.php +++ b/lib/emoji.inc.php @@ -43,7 +43,7 @@ function p2_get_emoji(Net_UserAgent_Mobile_Common $mobile = null) ); if (!$mobile) { - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); $cache = true; } diff --git a/lib/expack/ExpackLoader.php b/lib/expack/ExpackLoader.php index b766887ee..65154d392 100644 --- a/lib/expack/ExpackLoader.php +++ b/lib/expack/ExpackLoader.php @@ -218,7 +218,7 @@ static public function initAAS($aShowThread) if ($_conf['iphone']) { $aShowThread->aas_rotate = '↻'; } elseif ($_conf['ktai']) { - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); /** * @link http://www.nttdocomo.co.jp/service/imode/make/content/pictograph/ * @link http://www.au.kddi.com/ezfactory/tec/spec/3.html diff --git a/lib/expack/tgrep/view_x.inc.php b/lib/expack/tgrep/view_x.inc.php index 800642748..edf6cb57f 100644 --- a/lib/expack/tgrep/view_x.inc.php +++ b/lib/expack/tgrep/view_x.inc.php @@ -67,13 +67,13 @@ } usort($boards, - create_function('$a, $b', - 'if (($c = $b->hits - $a->hits) != 0) { - return $c; - } - return strcasecmp($a->name, $b->name);' - ) - ); + function ($a, $b) { + if (($c = $b->hits - $a->hits) != 0) { + return $c; + } + return strcasecmp($a->name, $b->name); + } + ); foreach ($boards as $board) { printf('
  • %s' . diff --git a/lib/fontconfig.inc.php b/lib/fontconfig.inc.php index c9f56dd75..5892472ab 100644 --- a/lib/fontconfig.inc.php +++ b/lib/fontconfig.inc.php @@ -50,6 +50,8 @@ function p2_fontconfig_apply_custom() global $STYLE, $_conf, $skin_en, $skin_uniq; if ($_conf['expack.skin.enabled']) { + $current_fontconfig = null; + if (isset($_conf['expack.am.fontfamily'])) { $_conf['expack.am.fontfamily.orig'] = $_conf['expack.am.fontfamily']; } else { diff --git a/lib/live/live_view_ctl.inc.php b/lib/live/live_view_ctl.inc.php index 4ec2b3189..6a2187175 100755 --- a/lib/live/live_view_ctl.inc.php +++ b/lib/live/live_view_ctl.inc.php @@ -64,6 +64,7 @@ // [これにレス] の方法 if ($_GET['live']) { + $res_dblclc = ""; $ttitle_en_q ="&ttitle_en=".UrlSafeBase64::encode($this->thread->ttitle); // 内容をダブルクリック if ($_conf['live.res_button'] >= 1) { diff --git a/lib/login_first.inc.php b/lib/login_first.inc.php index dcd439722..d18350850 100644 --- a/lib/login_first.inc.php +++ b/lib/login_first.inc.php @@ -57,7 +57,7 @@ function printLoginFirst(Login $_login) //============================================== // 補助認証 //============================================== - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); $keep_login_checked = ' checked'; if (isset($_POST['submit_new']) || isset($_POST['submit_member'])) { diff --git a/lib/post_form_options.inc.php b/lib/post_form_options.inc.php index de5649ef9..aafb45ab2 100644 --- a/lib/post_form_options.inc.php +++ b/lib/post_form_options.inc.php @@ -133,7 +133,7 @@ function setHiddenValue(button) { // {{{ textareaの属性 // 参考 クラシック COLS='60' ROWS='8' -$mobile = Net_UserAgent_Mobile::singleton(); +$mobile = (new Net_UserAgent_Mobile)->singleton(); $wrap_at = ''; // wrap属性はW3C HTML 4.01仕様に存在しない $name_size_at = ''; $mail_size_at = ''; diff --git a/lib/read_header.inc.php b/lib/read_header.inc.php index 17ac2f8d0..3ad3b5626 100755 --- a/lib/read_header.inc.php +++ b/lib/read_header.inc.php @@ -225,8 +225,9 @@ EOP; // +live 実況表示 html popup 切換 +$live_view_popup = ''; if ($_conf['live.view_type'] > 1 ) { - $live_view_popup = live_; + $live_view_popup = 'live_'; } if ($_conf['iframe_popup_type'] == 1) { @@ -306,6 +307,7 @@ } $onload_script = ''; +$onUnload_script = ''; if ($_conf['bottom_res_form']) { echo "\t\n"; diff --git a/lib/sb_print.inc.php b/lib/sb_print.inc.php index 90c0ad617..8968ba318 100644 --- a/lib/sb_print.inc.php +++ b/lib/sb_print.inc.php @@ -456,11 +456,13 @@ function sb_print($aThreadList) // +live 実況ボタンの処理 // +live 実況中ic2のサムネイル作成をonoff + $live_ic2_off = ''; if ($_conf['expack.ic2.enabled'] && (!$_conf['live.ic2_onoff'])) { $live_ic2_off = "onclick=\"javascript:parent.menu.ic2_menu_switch(0);\""; } // +live スレのリンク先を実況に書き換える + $thre_addtag = ''; if($_conf['live.livebbs_forcelive']==1&&$livebbs_bool) { $thre_addtag = $live_ic2_off."target=\"_blank\""; $thre_url = $live_url; diff --git a/lib/wiki/ReplaceImageUrlCtl.php b/lib/wiki/ReplaceImageUrlCtl.php index 01c2321a5..f4a762610 100644 --- a/lib/wiki/ReplaceImageUrlCtl.php +++ b/lib/wiki/ReplaceImageUrlCtl.php @@ -174,6 +174,7 @@ public function replaceImageUrl($url) $this->setup(); $src = false; + $return = []; if (array_key_exists($url, $this->onlineCache)) { return $this->onlineCache[$url]; diff --git a/rep2/edit_conf_user.php b/rep2/edit_conf_user.php index e247e03ff..63359586e 100644 --- a/rep2/edit_conf_user.php +++ b/rep2/edit_conf_user.php @@ -252,7 +252,7 @@ 板リストをオンラインURLから自動で読み込む。 指定先は menu.html 形式、2channel.brd 形式のどちらでもよい。
    -2ch基本
    http://menu.2ch.net/bbsmenu.html
    +2ch基本 https://menu.5ch.net/bbsmenu.html
    2ch + 外部BBS http://azlucky.s25.xrea.com/2chboard/bbsmenu.html', P2_EDIT_CONF_USER_LONGTEXT), ); diff --git a/rep2/edit_user_font.php b/rep2/edit_user_font.php index 329fceaa7..215c3a118 100644 --- a/rep2/edit_user_font.php +++ b/rep2/edit_user_font.php @@ -11,7 +11,7 @@ require_once P2_LIB_DIR . '/fontconfig.inc.php'; -$_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); +$_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'templateDir' => './skin', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'fontconfig', diff --git a/rep2/editpref.php b/rep2/editpref.php index e5449971e..aaad29039 100644 --- a/rep2/editpref.php +++ b/rep2/editpref.php @@ -100,19 +100,19 @@ } elseif (isset($_POST['delete']) && isset($_POST['submit'])) { // 履歴の削除処理 switch ($_POST['delete']) { - case cookie: + case 'cookie': // cookie - $delflag = CookieDataStore::clear() === flase ? false : true; + $delflag = CookieDataStore::clear() === false ? false : true; break; - case matome: + case 'matome': // 新着まとめ読み - $delflag = MatomeCacheList::trim(0) === flase ? false : true; + $delflag = MatomeCacheList::trim(0) === false ? false : true; break; - case recent: + case 'recent': // 最近読んだスレ $delflag = deleteFile($_conf['recent_idx']); break; - case reshist: + case 'reshist': // 書込履歴 if(deleteFile($_conf['res_hist_idx']) && deleteFile($_conf['res_hist_dat']) && @@ -120,13 +120,13 @@ $delflag = true; } break; - case autong: + case 'autong': if(deleteFile($_conf['pref_dir'] . '/p2_aborn_auto.txt') && deleteFile($_conf['pref_dir'] . '/p2_ng_auto.txt') ) { $delflag = true; } break; - case boardlist: + case 'boardlist': $cachefile = P2Util::cacheFileForDL($_conf['brdfile_online']); if(deleteFile($_conf['cache_dir'] . '/host_bbs_map.txt') && deleteFile($cachefile) && diff --git a/rep2/ic2.php b/rep2/ic2.php index c950ee9a1..a63739975 100644 --- a/rep2/ic2.php +++ b/rep2/ic2.php @@ -509,7 +509,8 @@ public function __destruct() $record->insert(); } -$is_anigif = false; $is_gif_caution == false; +$is_anigif = false; +$is_gif_caution = false; if (($ini['Thumbdeco']['anigif'] || $ini['Thumbdeco']['gifcaution']) && $params['mime'] == 'image/gif') { $is_anigif = check_anigif($newfile); if ($ini['Thumbdeco']['gifcaution']) { @@ -722,7 +723,7 @@ function ic2_display($url, $params) 'q' => $ini["Thumb{$thumb}"]['quality'], 'r' => '0', ); - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); $qa = 'size=3 maxlength=3'; if ($mobile->isDoCoMo()) { $qa .= ' istyle=4'; @@ -752,7 +753,7 @@ function ic2_display($url, $params) $qf->addElement('submit', 'o'); // FlexyとQurickForm_Rendererの初期化 - $_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); + $_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'locale' => 'ja', 'charset' => 'Shift_JIS', diff --git a/rep2/ic2_getter.php b/rep2/ic2_getter.php index d77364374..c0b1b620c 100644 --- a/rep2/ic2_getter.php +++ b/rep2/ic2_getter.php @@ -136,7 +136,7 @@ $qfe['close'] = $qf->addElement('button', 'close', null, $_attr_close); // Flexy -$_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); +$_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'locale' => 'ja', 'charset' => 'Shift_JIS', diff --git a/rep2/ic2_manager.php b/rep2/ic2_manager.php index 62b0bbbaa..5480cf938 100644 --- a/rep2/ic2_manager.php +++ b/rep2/ic2_manager.php @@ -36,7 +36,7 @@ } // テンプレートエンジン初期化 -$_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); +$_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'locale' => 'ja', 'charset' => 'Shift_JIS', diff --git a/rep2/ic2_setter.php b/rep2/ic2_setter.php index e07d3baa8..512ab7912 100644 --- a/rep2/ic2_setter.php +++ b/rep2/ic2_setter.php @@ -121,7 +121,7 @@ // }}} // {{{ output -$_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); +$_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'locale' => 'ja', 'charset' => 'Shift_JIS', diff --git a/rep2/ic2_viewtable.php b/rep2/ic2_viewtable.php index b19d251b3..f1bace946 100644 --- a/rep2/ic2_viewtable.php +++ b/rep2/ic2_viewtable.php @@ -65,7 +65,7 @@ // }}} // {{{ 出力 -$_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); +$_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'locale' => 'ja', 'charset' => 'Shift_JIS', diff --git a/rep2/info_sp.php b/rep2/info_sp.php index e34e2dc2b..78e40487d 100644 --- a/rep2/info_sp.php +++ b/rep2/info_sp.php @@ -109,7 +109,9 @@ if (file_exists($path) && ($data = FileCtl::file_read_lines($path))) { $data = array_map('trim', $data); - $data = array_filter($data, create_function('$v', 'return ($v !== "");')); + $data = array_filter($data, function ($v) { + return ($v !== ""); + }); array_unshift($data, $aborn_str); $data = array_unique($data); } else { diff --git a/rep2/iv2.php b/rep2/iv2.php index 934ff30b3..c0dc0fed8 100644 --- a/rep2/iv2.php +++ b/rep2/iv2.php @@ -282,7 +282,7 @@ $qf->addRule('thumbtype', 'invalid thumbtype.', 'arrayKeyExists', $_thumbtype); // Flexy -$_flexy_options = &PEAR5::getStaticProperty('HTML_Template_Flexy', 'options'); +$_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( 'locale' => 'ja', 'charset' => 'Shift_JIS', @@ -1054,7 +1054,7 @@ function iv2_sqlite_unix2date($ts) $flexy->setData('limelight_header', $limelight_header); $flexy->output(); } elseif ($list_template == 'iv2i.tpl.html') { - $mobile = Net_UserAgent_Mobile::singleton(); + $mobile = (new Net_UserAgent_Mobile)->singleton(); $elements = $flexy->getElements(); if ($mobile->isDoCoMo()) { $elements['page']->setAttributes('istyle="4"'); diff --git a/rep2/live_frame.php b/rep2/live_frame.php index 1c5f9a8a7..6915722a6 100755 --- a/rep2/live_frame.php +++ b/rep2/live_frame.php @@ -30,6 +30,7 @@ $live_read = "live_read.php"; $live_q = "&live=1"; +$offline_q = ''; if ($_GET['offline']) { $offline_l = isset($_GET['offline']) ? $_GET['offline'] : ''; $offline_q = "&offline=" . $offline_l; @@ -37,6 +38,7 @@ $live_q = "&live=0"; } +$word_q = ''; if ($_GET['word']) { $word_l = isset($_GET['word']) ? $_GET['word'] : ''; $method_l = isset($_GET['method']) ? $_GET['method'] : ''; diff --git a/rep2/post.php b/rep2/post.php index f27c50afc..4e9bcf97b 100644 --- a/rep2/post.php +++ b/rep2/post.php @@ -212,7 +212,7 @@ PostDataStore::set($post_backup_key, $post_cache); // cookie 読み込み -$cookie_key = $_login->user_u . '/' . P2Util::normalizeHostName(P2HostMgr::isHostBbsPink($host) ? 'www.bbspink.com' : P2HostMgr::isHost2chs($host) ? 'www.2ch.net' : $host); // 忍法帳対応 +$cookie_key = $_login->user_u . '/' . P2Util::normalizeHostName(P2HostMgr::isHostBbsPink($host) ? 'www.bbspink.com' : P2HostMgr::isHost2chs($host) ? 'www.5ch.net' : $host); // 忍法帳対応 if ($p2cookies = CookieDataStore::get($cookie_key)) { if (is_array($p2cookies)) { if (array_key_exists('expires', $p2cookies)) { @@ -425,7 +425,7 @@ function postIt($host, $bbs, $key, $post) } // POSTする内容 - while (list($name, $value) = each($post)) { + foreach ($post as $name => $value) { // したらば or be.2ch.netなら、EUCに変換 if (P2HostMgr::isHostJbbsShitaraba($host) || P2HostMgr::isHostBe2chs($host)) { diff --git a/rep2/read_copy_k.php b/rep2/read_copy_k.php index 89ac1f603..043672fb5 100644 --- a/rep2/read_copy_k.php +++ b/rep2/read_copy_k.php @@ -102,7 +102,7 @@ javascript:(function(){for (var j=0;jsingleton(); if ($mobile->isAirHPhone()) { $kyopon_size = ' rows="10" cols="34"'; } diff --git a/rep2/read_new.php b/rep2/read_new.php index 9be0b2ac5..4b517ed49 100755 --- a/rep2/read_new.php +++ b/rep2/read_new.php @@ -148,8 +148,9 @@ EOHEADER; // +live 実況表示 html popup 切換 +$live_view_popup = ''; if ($_conf['live.view_type'] > 1 ) { - $live_view_popup = live_; + $live_view_popup = 'live_'; } if ($_conf['iframe_popup_type'] == 1) { @@ -217,7 +218,6 @@ $fade = empty($_GET['fade']) ? 'false' : 'true'; $onload_script .= "gFade = {$fade};"; $bodyadd = ' onclick="hideHtmlPopUp(event);"'; -EOP; } if ($_conf['backlink_coloring_track']) { From cadf6817ef3182306041abdddd67ca2bc6e6a180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Sun, 26 Jul 2020 17:41:48 +0900 Subject: [PATCH 04/36] =?UTF-8?q?ImageCache2=20PEAR::DB=E3=81=8B=E3=82=89P?= =?UTF-8?q?DO=E3=81=B8=E7=A7=BB=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 7 +- conf/conf_ic2.inc.php | 8 +- .../ImageCache2/Console/Command/Setup.php | 305 ++++++++---------- .../ImageCache2/DataObject/BlackList.php | 21 +- lib/expack/ImageCache2/DataObject/Common.php | 64 +--- lib/expack/ImageCache2/DataObject/Errors.php | 74 +++-- lib/expack/ImageCache2/DataObject/Images.php | 38 +-- lib/expack/ImageCache2/DatabaseManager.php | 56 +--- lib/expack/ImageCache2/Thumbnailer.php | 22 +- lib/expack/ImageCache2/bootstrap.php | 16 +- lib/expack/ic2_getcount.inc.php | 13 +- rep2/ic/.gitignore | 1 - rep2/ic2.php | 2 +- rep2/ic2_manager.php | 61 ++-- rep2/ic2_viewtable.php | 9 +- rep2/iv2.php | 27 +- 16 files changed, 291 insertions(+), 433 deletions(-) delete mode 100644 rep2/ic/.gitignore diff --git a/composer.json b/composer.json index 6f13e1e12..68b61d5af 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,10 @@ "type": "git", "url": "https://github.com/openpsa/quickform.git" }, + { + "type": "git", + "url": "https://github.com/roojs/PDO_DataObject.git" + }, { "type": "git", "url": "https://github.com/mikoim/html_template_flexy.git" @@ -35,8 +39,6 @@ "pear-pear.php.net/benchmark": "1.2.*", "pear-pear.php.net/cache_lite": "1.*", "pear-pear.php.net/date": "1.4.*", - "pear-pear.php.net/db": "1.10.*", - "pear-pear.php.net/db_dataobject": "1.11.*", "pear-pear.php.net/file": "1.4.*", "pear-pear.php.net/file_util": "1.0.*", "pear-pear.php.net/http_request2": "2.3.*", @@ -50,6 +52,7 @@ "pear-pear.php.net/xml_parser": "1.3.*", "pear-pear.php.net/xml_rss": "1.1.*", "pear/html_template_flexy": "dev-master", + "roojs/pdo_dataobject": "dev-master", "symfony/console": "5.1.*", "symfony/yaml": "5.1.*" }, diff --git a/conf/conf_ic2.inc.php b/conf/conf_ic2.inc.php index 7e244c00e..16ac46894 100644 --- a/conf/conf_ic2.inc.php +++ b/conf/conf_ic2.inc.php @@ -10,11 +10,11 @@ $_conf['expack.ic2.general.cacheuri'] = './ic'; // DSN (DBに接続するためのデータソース名) -// @link http://jp.pear.php.net/manual/ja/package.database.db.intro-dsn.php +// @link https://roojs.github.io/PDO_DataObject/docs/index.html#config // 例) -// MySQL: 'mysqli://username:password@localhost:3306/database' +// MySQL: 'mysql://username:password@localhost:3306/database?charset=utf8' // PostgreSQL: 'pgsql://username:password@localhost:5432/database' -// SQLite2: 'sqlite:///' . $_conf['db_dir'] . '/imgcache.sqlite' +// SQLite: 'sqlite:/' . $_conf['db_dir'] . '/imgcache.sqlite' // 注1: username,password,databaseは実際のものと読み替える。 // 注2: MySQL,PosrgreSQLでは予めデータベースを作っておく。 $_conf['expack.ic2.general.dsn'] = ""; @@ -141,7 +141,7 @@ // エラーログにある画像はダウンロードを試みない (no:0;yes:1) $_conf['expack.ic2.getter.checkerror'] = 1; -// デフォルトでURL+.htmlの偽リファラを送る (no:0;yes:1) +// デフォルトでURLの偽リファラを送る (no:0;yes:1) $_conf['expack.ic2.getter.sendreferer'] = 0; // sendreferer = 0 のとき、例外的にリファラを送るホスト(カンマ区切り) diff --git a/lib/expack/ImageCache2/Console/Command/Setup.php b/lib/expack/ImageCache2/Console/Command/Setup.php index 623e685f6..fa386063f 100644 --- a/lib/expack/ImageCache2/Console/Command/Setup.php +++ b/lib/expack/ImageCache2/Console/Command/Setup.php @@ -2,20 +2,19 @@ namespace ImageCache2\Console\Command; +use ImageCache2_DataObject_Common; +use PDOException; use Symfony\Component\Console\Command\Command as sfConsoleCommand; -use Symfony\Component\Console\Input\InputArgument, - Symfony\Component\Console\Input\InputOption, - Symfony\Component\Console\Input\InputInterface, - Symfony\Component\Console\Output\OutputInterface, - Symfony\Component\Console\Formatter\OutputFormatterStyle; -use PEAR; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; require_once P2EX_LIB_DIR . '/ImageCache2/bootstrap.php'; class Setup extends sfConsoleCommand { - const PG_TRGM_GIST = 'gist'; - const PG_TRGM_GIN = 'gin'; + const PG_TRGM_GIST = 'gist'; + const PG_TRGM_GIN = 'gin'; // {{{ properties @@ -35,7 +34,7 @@ class Setup extends sfConsoleCommand private $pgTrgm; /** - * @var DB_common + * @var ImageCache2_DataObject_Common */ private $db; @@ -47,7 +46,7 @@ class Setup extends sfConsoleCommand /** * @var string */ - private $serialPriamryKey; + private $serialPrimaryKey; /** * @var string @@ -55,7 +54,7 @@ class Setup extends sfConsoleCommand private $tableExtraDefs; /** - * @var int + * @var string */ private $findTableStatement; @@ -73,12 +72,12 @@ class Setup extends sfConsoleCommand protected function configure() { $this - ->setName('setup') - ->setDescription('Setups ImageCache2 environment') - ->setDefinition(array( - new InputOption('check-only', null, InputOption::VALUE_NONE, 'Don\'t execute anything'), - new InputOption('pg-trgm', null, InputOption::VALUE_REQUIRED, 'Enable gist or gin 3-gram index'), - )); + ->setName('setup') + ->setDescription('Setups ImageCache2 environment') + ->setDefinition(array( + new InputOption('check-only', null, InputOption::VALUE_NONE, 'Don\'t execute anything'), + new InputOption('pg-trgm', null, InputOption::VALUE_REQUIRED, 'Enable gist or gin 3-gram index'), + )); } /** @@ -96,12 +95,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $result = $this->connect(); if ($result) { $this->info('Database: OK'); - $this->serialPriamryKey = $result[0]; + $this->serialPrimaryKey = $result[0]; $this->tableExtraDefs = $result[1]; $this->createTables(); $this->createIndexes(); } } + + return 0; } /** @@ -158,6 +159,27 @@ private function checkConfiguration() return $result; } + private function comment($message) + { + $this->output->writeln("{$message}"); + } + + // {{{ post connect methods + + private function error($message) + { + if ($this->dryRun) { + $this->output->writeln("{$message}"); + } else { + throw new \Exception($message); + } + } + + private function info($message) + { + $this->output->writeln("{$message}"); + } + /** * @return array */ @@ -171,39 +193,28 @@ private function connect() $phptype = strtolower($matches[1]); } - if (!in_array($phptype, array('mysql', 'mysqli', 'pgsql', 'sqlite'))) { - $this->error('Supports only MySQL, PostgreSQL and SQLite2.'); + if (!in_array($phptype, array('mysql', 'pgsql', 'sqlite'))) { + $this->error('Supports only MySQL, PostgreSQL and SQLite.'); return null; } - if (!extension_loaded($phptype)) { + if (!extension_loaded('pdo_' . $phptype)) { $this->error("Extension '{$phptype}' is not loaded."); return null; } - $db = \DB::connect($dsn); - if (PEAR::isError($db)) { - $this->error($db->getMessage()); - return null; - } - - $this->db = $db; + $this->db = new ImageCache2_DataObject_Common(); return $this->postConnect($phptype); } - // {{{ post connect methods - private function postConnect($phptype) { $result = null; switch ($phptype) { case 'mysql': - $result = $this->postConnectMysql(false); - break; - case 'mysqli': - $result = $this->postConnectMysql(true); + $result = $this->postConnectMysql(); break; case 'pgsql': $result = $this->postConnectPgsql(); @@ -216,14 +227,16 @@ private function postConnect($phptype) return $result; } - private function postConnectMysql($mysqli) + // }}} + // {{{ methods to create table + + private function postConnectMysql() { - $serialPriamryKey = 'INTEGER PRIMARY KEY AUTO_INCREMENT'; + $serialPrimaryKey = 'INTEGER PRIMARY KEY AUTO_INCREMENT'; $tableExtraDefs = ' TYPE=MyISAM'; - $db = $this->db; - $result = $db->getRow("SHOW VARIABLES LIKE 'version'", - array(), DB_FETCHMODE_ORDERED); + $db = $this->db->PDO(); + $result = $db->query("SHOW VARIABLES LIKE 'version'")->fetch(); if (is_array($result)) { $version = $result[1]; if (version_compare($version, '4.1.2', 'ge')) { @@ -231,73 +244,34 @@ private function postConnectMysql($mysqli) } } - if (!$this->dryRun) { - if ($mysqli && function_exists('mysqli_set_charset')) { - mysqli_set_charset($db->connection, 'utf8'); - } elseif (!$mysqli && function_exists('mysql_set_charset')) { - mysql_set_charset('utf8', $db->connection); - } else { - $db->query('SET NAMES utf8'); - } - } - - $stmt = $db->prepare('SHOW TABLES LIKE ?'); - if (PEAR::isError($stmt)) { - $this->error($stmt->getMessage()); - return null; - } - $this->findTableStatement = $stmt; - $this->findIndexFormat = 'SHOW INDEX FROM %s WHERE Key_name LIKE ?'; + $this->findTableStatement = "SHOW TABLES LIKE ?"; + $this->findIndexFormat = "SHOW INDEX FROM %s WHERE Key_name LIKE ?"; - return array($serialPriamryKey, $tableExtraDefs); + return array($serialPrimaryKey, $tableExtraDefs); } private function postConnectPgsql() { - $serialPriamryKey = 'SERIAL PRIMARY KEY'; + $serialPrimaryKey = 'SERIAL PRIMARY KEY'; $tableExtraDefs = ''; - $db = $this->db; - - if (!$this->dryRun) { - if (function_exists('pg_set_client_encoding')) { - pg_set_client_encoding($db->connection, 'UNICODE'); - } else { - $db->query("SET CLIENT_ENCODING TO 'UNICODE'"); - } - } - - $stmt = $db->prepare("SELECT relname FROM pg_class WHERE relkind = 'r' AND relname = ?"); - if (PEAR::isError($stmt)) { - $this->error($stmt->getMessage()); - return null; - } - $this->findTableStatement = $stmt; + $this->findTableStatement = "SELECT relname FROM pg_class WHERE relkind = 'r' AND relname = ?"; $this->findIndexFormat = "SELECT relname FROM pg_class WHERE relkind = 'i' AND relname = ?"; - return array($serialPriamryKey, $tableExtraDefs); + return array($serialPrimaryKey, $tableExtraDefs); } private function postConnectSqlite() { - $serialPriamryKey = 'INTEGER PRIMARY KEY'; + $serialPrimaryKey = 'INTEGER PRIMARY KEY'; $tableExtraDefs = ''; - $db = $this->db; - - $stmt = $db->prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name= ?"); - if (PEAR::isError($stmt)) { - $this->error($stmt->getMessage()); - return null; - } + $this->findTableStatement = "SELECT name FROM sqlite_master WHERE type = 'table' AND name= ?"; $this->findIndexFormat = "SELECT name FROM sqlite_master WHERE type = 'index' AND name= ?"; - return array($serialPriamryKey, $tableExtraDefs); + return array($serialPrimaryKey, $tableExtraDefs); } - // }}} - // {{{ methods to create table - private function createTables() { $imagesTable = $this->config['General']['table']; @@ -325,14 +299,45 @@ private function createTables() private function findTable($tableName) { - $result = $this->db->execute($this->findTableStatement, array($tableName)); - if (PEAR::isError($result)) { - $this->error($result->getMessage()); + $db = $this->db->PDO(); + try { + $stmt = $db->prepare($this->findTableStatement); + $stmt->execute([$tableName]); + return count($stmt->fetchAll()) > 0; + } catch (PDOException $e) { + $this->error($e->getMessage()); return false; } - return $result->numRows() > 0; } + private function createImagesTable($tableName) + { + $quotedTableName = $this->db->quoteIdentifier($tableName); + $sql = <<serialPrimaryKey}, + "uri" VARCHAR (255), + "host" VARCHAR (255), + "name" VARCHAR (255), + "size" INTEGER NOT NULL, + "md5" CHAR (32) NOT NULL, + "width" SMALLINT NOT NULL, + "height" SMALLINT NOT NULL, + "mime" VARCHAR (50) NOT NULL, + "time" INTEGER NOT NULL, + "rank" SMALLINT NOT NULL DEFAULT 0, + "memo" TEXT +){$this->tableExtraDefs}; +SQL; + if ($this->db->db_class === 'mysql') { // MySQL 8.0.2からRANKは予約語 https://dev.mysql.com/doc/refman/8.0/en/keywords.html + $sql = str_replace('"', '`', $sql); + } + return $this->doCreateTable($tableName, $sql); + } + + // }}} + // {{{ methods to create index + private function doCreateTable($tableName, $sql) { if ($this->dryRun) { @@ -340,9 +345,10 @@ private function doCreateTable($tableName, $sql) return true; } - $result = $this->db->query($sql); - if (PEAR::isError($result)) { - $this->error($result->getMessage()); + try { + $this->db->PDO()->query($sql); + } catch (PDOException $e) { + $this->error($e->getMessage()); return false; } @@ -350,28 +356,6 @@ private function doCreateTable($tableName, $sql) return true; } - private function createImagesTable($tableName) - { - $quotedTableName = $this->db->quoteIdentifier($tableName); - $sql = <<serialPriamryKey}, - uri VARCHAR (255), - host VARCHAR (255), - name VARCHAR (255), - size INTEGER NOT NULL, - md5 CHAR (32) NOT NULL, - width SMALLINT NOT NULL, - height SMALLINT NOT NULL, - mime VARCHAR (50) NOT NULL, - time INTEGER NOT NULL, - rank SMALLINT NOT NULL DEFAULT 0, - memo TEXT -){$this->tableExtraDefs}; -SQL; - return $this->doCreateTable($tableName, $sql); - } - private function createErrorLogTable($tableName) { $quotedTableName = $this->db->quoteIdentifier($tableName); @@ -391,7 +375,7 @@ private function createBlackListTable($tableName) $quotedTableName = $this->db->quoteIdentifier($tableName); $sql = <<serialPriamryKey}, + id {$this->serialPrimaryKey}, uri VARCHAR (255), size INTEGER NOT NULL, md5 CHAR (32) NOT NULL, @@ -401,9 +385,6 @@ private function createBlackListTable($tableName) return $this->doCreateTable($tableName, $sql); } - // }}} - // {{{ methods to create index - private function createIndexes() { $imagesTable = $this->config['General']['table']; @@ -436,7 +417,7 @@ private function createIndexes() } } - if (strcasecmp(get_class($this->db), 'db_pgsql') === 0) { + if ($this->db->db_class === 'pgsql') { $pgTrgm = $this->pgTrgm; if ($pgTrgm === self::PG_TRGM_GIST || $pgTrgm === self::PG_TRGM_GIN) { @@ -445,29 +426,47 @@ private function createIndexes() $this->info("Index '{$indexName}' already exists"); } else { $this->doCreatePgTrgmIndex($pgTrgm, $indexName, - $imagesTable, 'memo'); + $imagesTable, 'memo'); } } } } + // }}} + // {{{ console output methods + + private function findIndex($indexName, $tableName) + { + $db = $this->db->PDO(); + $sql = sprintf($this->findIndexFormat, $this->db->quoteIdentifier($tableName)); + try { + $stmt = $db->prepare($sql); + $stmt->execute([$indexName]); + return count($stmt->fetchAll()) > 0; + } catch (PDOException $e) { + $this->error($e->getMessage()); + return false; + } + } + private function doCreateIndex($indexName, $tableName, array $fieldNames) { $db = $this->db; $callback = array($db, 'quoteIdentifier'); $sql = sprintf('CREATE INDEX %s ON %s (%s);', - $db->quoteIdentifier($indexName), - $db->quoteIdentifier($tableName), - implode(', ', array_map($callback, $fieldNames))); + $db->quoteIdentifier($indexName), + $db->quoteIdentifier($tableName), + implode(', ', array_map($callback, $fieldNames))); if ($this->dryRun) { $this->comment($sql); return true; } - $result = $db->query($sql); - if (PEAR::isError($result)) { - $this->error($result->getMessage()); + try { + $this->db->PDO()->query($sql); + } catch (PDOException $e) { + $this->error($e->getMessage()); return false; } @@ -480,19 +479,20 @@ private function doCreatePgTrgmIndex($indexType, $indexName, $tableName, $fieldN { $db = $this->db; $sql = sprintf('CREATE INDEX %2$s ON %3$s USING %1$s (%4$s %1$s_trgm_ops);', - $indexType, - $db->quoteIdentifier($indexName), - $db->quoteIdentifier($tableName), - $db->quoteIdentifier($fieldName)); + $indexType, + $db->quoteIdentifier($indexName), + $db->quoteIdentifier($tableName), + $db->quoteIdentifier($fieldName)); if ($this->dryRun) { $this->comment($sql); return true; } - $result = $db->query($sql); - if (PEAR::isError($result)) { - $this->error($result->getMessage()); + try { + $this->db->PDO()->query($sql); + } catch (PDOException $e) { + $this->error($e->getMessage()); return false; } @@ -501,40 +501,5 @@ private function doCreatePgTrgmIndex($indexType, $indexName, $tableName, $fieldN return true; } - private function findIndex($indexName, $tableName) - { - $db = $this->db; - $sql = sprintf($this->findIndexFormat, - $db->quoteIdentifier($tableName)); - $result = $db->query($sql, array($indexName)); - if (PEAR::isError($result)) { - $this->error($result->getMessage()); - return false; - } - return $result->numRows() > 0; - } - - // }}} - // {{{ console output methods - - private function info($message) - { - $this->output->writeln("{$message}"); - } - - private function comment($message) - { - $this->output->writeln("{$message}"); - } - - private function error($message) - { - if ($this->dryRun) { - $this->output->writeln("{$message}"); - } else { - throw new \Exception($message); - } - } - // }}} } diff --git a/lib/expack/ImageCache2/DataObject/BlackList.php b/lib/expack/ImageCache2/DataObject/BlackList.php index b7f8c14f4..68f1b0924 100644 --- a/lib/expack/ImageCache2/DataObject/BlackList.php +++ b/lib/expack/ImageCache2/DataObject/BlackList.php @@ -4,6 +4,13 @@ class ImageCache2_DataObject_BlackList extends ImageCache2_DataObject_Common { + public $__table; // テーブル名 + public $id; // INTEGER not_null primary + public $uri; // CHARACTER VARYING + public $size; // INTEGER not_null + public $md5; // CHARACTER not_null + public $type; // SMALLINT not_null + // {{{ constants const NOMORE = 0; @@ -19,20 +26,6 @@ public function __construct() $this->__table = $this->_ini['General']['blacklist_table']; } - // }}} - // {{{ table() - - public function table() - { - return array( - 'id' => DB_DATAOBJECT_INT, - 'uri' => DB_DATAOBJECT_STR, - 'size' => DB_DATAOBJECT_INT, - 'md5' => DB_DATAOBJECT_STR, - 'type' => DB_DATAOBJECT_INT, - ); - } - // }}} // {{{ keys() diff --git a/lib/expack/ImageCache2/DataObject/Common.php b/lib/expack/ImageCache2/DataObject/Common.php index 2322ffe0b..85b796ae8 100644 --- a/lib/expack/ImageCache2/DataObject/Common.php +++ b/lib/expack/ImageCache2/DataObject/Common.php @@ -5,13 +5,11 @@ /** * @abstract */ -class ImageCache2_DataObject_Common extends DB_DataObject +class ImageCache2_DataObject_Common extends PDO_DataObject { // {{{ properties - - protected $_db; protected $_ini; - + public $db_class; // }}} // {{{ constcurtor @@ -20,52 +18,10 @@ class ImageCache2_DataObject_Common extends DB_DataObject */ public function __construct() { - static $set_to_utf8 = false; - + parent::__construct(); // 設定の読み込み - $ini = ic2_loadconfig(); - $this->_ini = $ini; - if (!$ini['General']['dsn']) { - p2die('DSNが設定されていません。'); - } - - // データベースへ接続 - $this->_database_dsn = $ini['General']['dsn']; - $this->_db = $this->getDatabaseConnection(); - if (DB::isError($this->_db)) { - p2die($this->_db->getMessage()); - } - - // クライアントの文字セットに UTF-8 を指定 - if (!$set_to_utf8) { - if (preg_match('/^(\w+)(?:\((\w+)\))?:/', $this->_database_dsn, $m)) { - $driver = strtolower($m[1]); - } else { - $driver = 'unknown'; - } - - switch ($driver) { - case 'mysql': - case 'mysqli': - if ($driver == 'mysql' && function_exists('mysql_set_charset')) { - mysql_set_charset('utf8', $this->_db->connection); - } elseif ($driver == 'mysqli' && function_exists('mysqli_set_charset')) { - mysqli_set_charset($this->_db->connection, 'utf8'); - } else { - $this->_db->query("SET NAMES utf8"); - } - break; - case 'pgsql': - if (function_exists('pg_set_client_encoding')) { - pg_set_client_encoding($this->_db->connection, 'UNICODE'); - } else { - $this->_db->query("SET CLIENT_ENCODING TO 'UNICODE'"); - } - break; - } - - $set_to_utf8 = true; - } + $this->_ini = ic2_loadconfig(); + $this->db_class = explode(':', $this->_ini['General']['dsn'])[0]; } // }}} @@ -76,10 +32,10 @@ public function __construct() */ public function whereAddQuoted($key, $cmp, $value, $logic = 'AND') { - $types = $this->table(); - $col = $this->_db->quoteIdentifier($key); - if ($types[$key] != DB_DATAOBJECT_INT) { - $value = $this->_db->quoteSmart($value); + $types = $this->tableColumns(); + $col = $this->quoteIdentifier($key); + if ($types[$key] != PDO_DataObject::INT) { + $value = $this->PDO()->quote($value); } $cond = sprintf('%s %s %s', $col, $cmp, $value); return $this->whereAdd($cond, $logic); @@ -103,7 +59,7 @@ public function orderByArray(array $sort) continue; } } - $k = $this->_db->quoteIdentifier($k); + $k = $this->quoteIdentifier($k); if (!$d || strtoupper($d) == 'DESC') { $order[] = $k . ' DESC'; } else { diff --git a/lib/expack/ImageCache2/DataObject/Errors.php b/lib/expack/ImageCache2/DataObject/Errors.php index 88c2d0709..65428c74b 100644 --- a/lib/expack/ImageCache2/DataObject/Errors.php +++ b/lib/expack/ImageCache2/DataObject/Errors.php @@ -4,6 +4,12 @@ class ImageCache2_DataObject_Errors extends ImageCache2_DataObject_Common { + public $__table; // テーブル名 + public $uri; // CHARACTER VARYING + public $errcode; // CHARACTER VARYING not_null + public $errmsg; // TEXT + public $occured; // INTEGER not_null + // {{{ constcurtor public function __construct() @@ -12,19 +18,6 @@ public function __construct() $this->__table = $this->_ini['General']['error_table']; } - // }}} - // {{{ table() - - public function table() - { - return array( - 'uri' => DB_DATAOBJECT_STR, - 'errcode' => DB_DATAOBJECT_STR, - 'errmsg' => DB_DATAOBJECT_STR, - 'occured' => DB_DATAOBJECT_INT, - ); - } - // }}} // {{{ keys() @@ -36,35 +29,46 @@ public function keys() // }}} // {{{ ic2_errlog_lotate() + /** + * ログの総数がerror_log_numを超えたら古いログから切り詰める + */ public function ic2_errlog_lotate() { $ini = ic2_loadconfig(); $error_log_num = $ini['General']['error_log_num']; if ($error_log_num > 0) { - $q_table = $this->_db->quoteIdentifier($this->__table); - $sql1 = 'SELECT COUNT(*) FROM ' . $q_table; - $sql2 = 'SELECT MIN(occured) FROM ' . $q_table; - $sql3 = 'DELETE FROM ' . $q_table . ' WHERE occured = '; - - while (($r1 = $this->_db->getOne($sql1)) > $error_log_num) { - if (DB::isError($r1)) { - return $r1; - } - $r2 = $this->_db->getOne($sql2); - if (DB::isError($r2)) { - return $r2; - } - $r3 = $this->_db->query($sql3 . $r2); - if (DB::isError($r3)) { - return $r3; - } - if ($this->_db->affectedRows() == 0) { - break; - } + $db = $this->PDO(); + $table = $this->__table; + + $getLogRows = function () use ($db, $table) { + $stmt = $db->prepare('SELECT COUNT(*) FROM ' . $this->quoteIdentifier($table)); + $stmt->execute(); + return $stmt->fetch()[0]; + }; + + $getRemovalLogs = function ($limit) use ($db, $table) { + $stmt = $db->prepare('SELECT ' . $this->quoteIdentifier('occured') . ' FROM ' . $this->quoteIdentifier($table) . ' ORDER BY ' . $this->quoteIdentifier('occured') . ' LIMIT :num;'); + $stmt->bindValue(':num', $limit, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->fetchAll(PDO::FETCH_COLUMN); + }; + + $deleteLog = function ($occured) use ($db, $table) { + $stmt = $db->prepare('DELETE FROM ' . $this->quoteIdentifier($table) . ' WHERE ' . $this->quoteIdentifier('occured') . ' = :occured;'); + $stmt->bindValue('occured', $occured, PDO::PARAM_INT); + $stmt->execute(); + return $stmt->rowCount(); + }; + + $num = $getLogRows() - $error_log_num; + if ($num <= 0) { + return; } + foreach ($getRemovalLogs($num) as $occured) { + $deleteLog($occured); + } } - return DB_OK; } // }}} @@ -72,7 +76,7 @@ public function ic2_errlog_lotate() public function ic2_errlog_clean() { - return $this->_db->query('DELETE FROM ' . $this->_db->quoteIdentifier($this->__table)); + return $this->PDO()->query('DELETE FROM ' . $this->quoteIdentifier($this->__table)); } // }}} diff --git a/lib/expack/ImageCache2/DataObject/Images.php b/lib/expack/ImageCache2/DataObject/Images.php index a38470554..8e17e8ca2 100644 --- a/lib/expack/ImageCache2/DataObject/Images.php +++ b/lib/expack/ImageCache2/DataObject/Images.php @@ -4,6 +4,20 @@ class ImageCache2_DataObject_Images extends ImageCache2_DataObject_Common { + public $__table; // テーブル名 + public $id; // INTEGER not_null primary + public $uri; // CHARACTER VARYING + public $host; // CHARACTER VARYING + public $name; // CHARACTER VARYING + public $size; // INTEGER not_null + public $md5; // CHARACTER not_null + public $width; // SMALLINT not_null + public $height; // SMALLINT not_null + public $mime; // CHARACTER VARYING not_null + public $time; // INTEGER not_null + public $rank; // SMALLINT not_null + public $memo; // TEXT + // {{{ constants const OK = 0; @@ -21,30 +35,6 @@ public function __construct() $this->__table = $this->_ini['General']['table']; } - // }}} - // {{{ table() - - public function table() - { - return array( - 'id' => DB_DATAOBJECT_INT, - 'uri' => DB_DATAOBJECT_STR, - 'host' => DB_DATAOBJECT_STR, - 'name' => DB_DATAOBJECT_STR, - 'size' => DB_DATAOBJECT_INT, - 'md5' => DB_DATAOBJECT_STR, - 'width' => DB_DATAOBJECT_INT, - 'height' => DB_DATAOBJECT_INT, - 'mime' => DB_DATAOBJECT_STR, - 'time' => DB_DATAOBJECT_INT, - 'rank' => DB_DATAOBJECT_INT, - 'memo' => DB_DATAOBJECT_STR, - ); - } - - // }}} - // {{{ keys() - public function keys() { return array('uri'); diff --git a/lib/expack/ImageCache2/DatabaseManager.php b/lib/expack/ImageCache2/DatabaseManager.php index eb4b251aa..a615ec0f7 100644 --- a/lib/expack/ImageCache2/DatabaseManager.php +++ b/lib/expack/ImageCache2/DatabaseManager.php @@ -24,12 +24,7 @@ static public function update($updated) // トランザクションの開始 $ta = new ImageCache2_DataObject_Images(); - $db = $ta->getDatabaseConnection(); - if ($db->phptype == 'pgsql') { - $ta->query('BEGIN'); - } elseif ($db->phptype == 'sqlite') { - $db->query('BEGIN;'); - } + $ta->PDO()->beginTransaction(); // 画像データを更新 foreach ($updated as $id => $data) { @@ -56,11 +51,7 @@ static public function update($updated) } // トランザクションのコミット - if ($db->phptype == 'pgsql') { - $ta->query('COMMIT'); - } elseif ($db->phptype == 'sqlite') { - $db->query('COMMIT;'); - } + $ta->PDO()->commit(); } // }}} @@ -93,12 +84,7 @@ static public function remove($target, $to_blacklist = false) // トランザクションの開始 $ta = new ImageCache2_DataObject_Images(); - $db = $ta->getDatabaseConnection(); - if ($db->phptype == 'pgsql') { - $ta->query('BEGIN'); - } elseif ($db->phptype == 'sqlite') { - $db->query('BEGIN;'); - } + $ta->PDO()->beginTransaction(); // 画像を削除 $parent_dir = dirname($ini['General']['cachedir']) . DIRECTORY_SEPARATOR; @@ -159,7 +145,7 @@ static public function remove($target, $to_blacklist = false) while ($remover->fetch()) { // ブラックリスト送りにする if ($to_blacklist) { - $blacklist = clone $_blacklist; + $blacklist = new ImageCache2_DataObject_BlackList(); $blacklist->uri = $remover->uri; $blacklist->insert(); } @@ -170,11 +156,7 @@ static public function remove($target, $to_blacklist = false) } // トランザクションのコミット - if ($db->phptype == 'pgsql') { - $ta->query('COMMIT'); - } elseif ($db->phptype == 'sqlite') { - $db->query('COMMIT;'); - } + $ta->PDO()->commit(); return $removed_files; } @@ -191,16 +173,15 @@ static public function setRank($target, $rank) return; } if (!is_array($target)) { - if (is_integer($updated) || ctype_digit($updated)) { - $id = (int)$updated; + if (is_integer($target) || ctype_digit($target)) { + $id = (int)$target; if ($id > 0) { - $updated = array($id); + $target = array($id); } else { return; } } else { P2Util::pushInfoHtml('

    WARNING! ImageCache2_DatabaseManager::setRank(): 不正な引数

    '); - return $removed_files; } } @@ -224,27 +205,22 @@ static public function addMemo($target, $memo) return; } if (!is_array($target)) { - if (is_integer($updated) || ctype_digit($updated)) { - $id = (int)$updated; + if (is_integer($target) || ctype_digit($target)) { + $id = (int)$target; if ($id > 0) { - $updated = array($id); + $target = array($id); } else { return; } } else { P2Util::pushInfoHtml('

    WARNING! ImageCache2_DatabaseManager::addMemo(): 不正な引数

    '); - return $removed_files; + return; } } // トランザクションの開始 $ta = new ImageCache2_DataObject_Images(); - $db = $ta->getDatabaseConnection(); - if ($db->phptype == 'pgsql') { - $ta->query('BEGIN'); - } elseif ($db->phptype == 'sqlite') { - $db->query('BEGIN;'); - } + $db = $ta->PDO()->beginTransaction(); // メモに指定文字列が含まれていなければ更新 foreach ($target as $id) { @@ -265,11 +241,7 @@ static public function addMemo($target, $memo) } // トランザクションのコミット - if ($db->phptype == 'pgsql') { - $ta->query('COMMIT'); - } elseif ($db->phptype == 'sqlite') { - $db->query('COMMIT;'); - } + $ta->PDO()->commit(); } // }}} diff --git a/lib/expack/ImageCache2/Thumbnailer.php b/lib/expack/ImageCache2/Thumbnailer.php index 2e3ca186c..74ab2d5cd 100644 --- a/lib/expack/ImageCache2/Thumbnailer.php +++ b/lib/expack/ImageCache2/Thumbnailer.php @@ -24,7 +24,7 @@ class ImageCache2_Thumbnailer // }}} // {{{ properties - public $db; // @var object PEAR DB_{phptype}のインスタンス + public $db; // @var object PDO_DataObjectのインスタンス public $ini; // @var array ImageCache2の設定 public $mode; // @var int サムネイルの種類 public $cachedir; // @var string ImageCache2のキャッシュ保存ディレクトリ @@ -106,13 +106,6 @@ public function __construct($mode = self::SIZE_DEFAULT, array $dynamic_options = // 設定 $this->ini = ic2_loadconfig(); - // データベースに接続 - $icdb = new ImageCache2_DataObject_Images(); - $this->db = $icdb->getDatabaseConnection(); - if (DB::isError($this->db)) { - $this->error($this->db->getMessage()); - } - // サムネイルモード判定 $dpr = $mode & self::DPR_MASK; $mode = $mode & ~self::DPR_MASK; @@ -583,7 +576,7 @@ public function dirID($size = null, $md5 = null, $mime = null) if ($size && $md5 && $mime) { $icdb = new ImageCache2_DataObject_Images(); $icdb->whereAddQUoted('size', '=', $size); - $icdb->whereAddQuoted('md5', '=', $md5); + $icdb->whereAddQuoted('md5', '=', $md5); $icdb->whereAddQUoted('mime', '=', $mime); $icdb->orderByArray(array('id' => 'ASC')); if ($icdb->find(true)) { @@ -591,11 +584,12 @@ public function dirID($size = null, $md5 = null, $mime = null) return str_pad(ceil($icdb->id / 1000), 5, 0, STR_PAD_LEFT); } } - $sql = 'SELECT MAX(' . $this->db->quoteIdentifier('id') . ') + 1 FROM ' - . $this->db->quoteIdentifier($this->ini['General']['table']) . ';'; - $nextid = $this->db->getOne($sql); - if (DB::isError($nextid) || !$nextid) { - $nextid = 1; + $icdb = new ImageCache2_DataObject_Images(); + $icdb->select(sprintf('MAX(%s) + 1 as id', $icdb->quoteIdentifier('id'))); + if ($icdb->find(true)) { + $nextid = $icdb->id; + } else { + p2die('DBに登録された画像の枚数を数えられませんでした'); } return str_pad(ceil($nextid / 1000), 5, 0, STR_PAD_LEFT); } diff --git a/lib/expack/ImageCache2/bootstrap.php b/lib/expack/ImageCache2/bootstrap.php index 4fe97f088..32a62a961 100644 --- a/lib/expack/ImageCache2/bootstrap.php +++ b/lib/expack/ImageCache2/bootstrap.php @@ -49,15 +49,13 @@ function ic2_loadconfig() $ini[$cat][$name] = $_conf[$key]; } - // DB_DataObjectの設定 - $_dao_options = &PEAR::getStaticProperty('DB_DataObject', 'options'); - if (!is_array($_dao_options)) { - $_dao_options = array(); - } - $_dao_options['database'] = $ini['General']['dsn']; - $_dao_options['debug'] = false; - $_dao_options['quote_identifiers'] = true; - $_dao_options['db_driver'] = 'DB'; + // PDO_DataObjectの設定 + PDO_DataObject::config([ + 'database' => $ini['General']['dsn'], + 'quote_identifiers' => true, + 'proxy'=>true, + 'debug'=>false + ]); } return $ini; diff --git a/lib/expack/ic2_getcount.inc.php b/lib/expack/ic2_getcount.inc.php index 37e6307b7..98b5eef93 100644 --- a/lib/expack/ic2_getcount.inc.php +++ b/lib/expack/ic2_getcount.inc.php @@ -15,8 +15,7 @@ function getIC2ImageCount($key, $threshold = null) { $icdb->whereAddQuoted('rank', '>=', $threshold); } - $db = $icdb->getDatabaseConnection(); - $db_class = strtolower(get_class($db)); + $db_class = $icdb->db_class; $keys = explode(' ', $icdb->uniform($key, 'CP932')); foreach ($keys as $k) { $operator = 'LIKE'; @@ -29,7 +28,7 @@ function getIC2ImageCount($key, $threshold = null) { if (strpos($k, '%') !== false || strpos($k, '_') !== false) { // SQLite2はLIKE演算子の右辺でバックスラッシュによるエスケープや // ESCAPEでエスケープ文字を指定することができないのでGLOB演算子を使う - if ($db_class == 'db_sqlite') { + if ($db_class == 'sqlite') { if (strpos($k, '*') !== false || strpos($k, '?') !== false) { throw new InvalidArgumentException('「%または_」と「*または?」が混在するキーワードは使えません。'); } else { @@ -47,10 +46,10 @@ function getIC2ImageCount($key, $threshold = null) { $icdb->whereAddQuoted('memo', $operator, $expr); } - $sql = sprintf('SELECT COUNT(*) FROM %s %s', $db->quoteIdentifier($ini['General']['table']), $icdb->_query['condition']); - $all = $db->getOne($sql); - if (DB::isError($all)) { - throw new InvalidArgumentException($all->getMessage()); + try { + $all = $icdb->count('*'); + } catch (PDOException $e) { + p2die($e->getMessage()); } return $all; } diff --git a/rep2/ic/.gitignore b/rep2/ic/.gitignore deleted file mode 100644 index 72e8ffc0d..000000000 --- a/rep2/ic/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/rep2/ic2.php b/rep2/ic2.php index a63739975..69e297e49 100644 --- a/rep2/ic2.php +++ b/rep2/ic2.php @@ -339,7 +339,7 @@ public function __destruct() } } if ($send_referer) { - $referer = $uri . '.html'; + $referer = $uri; } } diff --git a/rep2/ic2_manager.php b/rep2/ic2_manager.php index 5480cf938..2a1a6f959 100644 --- a/rep2/ic2_manager.php +++ b/rep2/ic2_manager.php @@ -29,12 +29,6 @@ $viewer_cache_exists = false; } -// データベースに接続 -$db = DB::connect($ini['General']['dsn']); -if (DB::isError($db)) { - p2die($db->getMessage()); -} - // テンプレートエンジン初期化 $_flexy_options = &PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $_flexy_options = array( @@ -50,6 +44,9 @@ // }}} // {{{ データベース操作・ファイル削除 +$icdc = new ImageCache2_DataObject_Common(); +$db = $icdc->PDO(); + if (isset($_POST['action'])) { switch ($_POST['action']) { @@ -58,7 +55,7 @@ case 'dropAborn': if ($_POST['action'] == 'dropZero') { // ランク=0 の画像を削除する - $where = $db->quoteIdentifier('rank') . ' = 0'; + $where = $db->quote('rank') . ' = 0'; if (isset($_POST['dropZeroLimit'])) { // 取得した期間を限定 switch ($_POST['dropZeroSelectTime']) { @@ -72,7 +69,7 @@ if ($expires !== null) { $operator = ($_POST['dropZeroSelectType'] == 'within') ? '>' : '<'; $where .= sprintf(' AND %s %s %d', - $db->quoteIdentifier('time'), + $icdc->quoteIdentifier('time'), $operator, time() - $expires); } @@ -81,22 +78,22 @@ $to_blacklist = !empty($_POST['dropZeroToBlackList']); } else { // あぼーん画像を削除し、ブラックリストに登録する - $where = $db->quoteIdentifier('rank') . ' < 0'; + $where = $icdc->quoteIdentifier('rank') . ' < 0'; $to_blacklist = true; } - $sql = sprintf('SELECT %s FROM %s WHERE %s;', - $db->quoteIdentifier('id'), - $db->quoteIdentifier($ini['General']['table']), + $sql = sprintf('SELECT %s FROM %s WHERE %s', + $icdc->quoteIdentifier('id'), + $icdc->quoteIdentifier($ini['General']['table']), $where); - $result = $db->getAll($sql, null, DB_FETCHMODE_ORDERED | DB_FETCHMODE_FLIPPED); - if (DB::isError($result)) { - P2Util::pushInfoHtml($result->getMessage()); - break; + try { + $result = $db->query($sql)->fetchAll(PDO::FETCH_COLUMN); + } catch (PDOException $e) { + P2Util::pushInfoHtml($e->getMessage()); } + if ($result) { - $target = $result[0]; - $removed_files = ImageCache2_DatabaseManager::remove($target, $to_blacklist); + $removed_files = ImageCache2_DatabaseManager::remove($result, $to_blacklist); } else { $removed_files = array(); } @@ -147,33 +144,33 @@ // エラーログを消去する case 'clearErrorLog': - $result = $db->query('DELETE FROM ' . $db->quoteIdentifier($ini['General']['error_table'])); - if (DB::isError($result)) { - P2Util::pushInfoHtml($result->getMessage()); - } else { + try { + $result = $db->query('DELETE FROM ' . $icdc->quoteIdentifier($ini['General']['error_table'])); P2Util::pushInfoHtml('

    エラーログを消去しました。

    '); + } catch (PDOException $e) { + P2Util::pushInfoHtml($e->getMessage()); } break; // ブラックリストを消去する case 'clearBlackList': - $result = $db->query('DELETE FROM ' . $db->quoteIdentifier($ini['General']['blacklist_table'])); - if (DB::isError($result)) { - P2Util::pushInfoHtml($result->getMessage()); - } else { + try { + $result = $db->query('DELETE FROM ' . $icdc->quoteIdentifier($ini['General']['blacklist_table'])); P2Util::pushInfoHtml('

    ブラックリストを消去しました。

    '); + } catch (PDOException $e) { + P2Util::pushInfoHtml($e->getMessage()); } break; // データベースを最適化する case 'optimizeDB': // SQLite2 の画像キャッシュデータベースをVACUUM - if ($db->dsn['phptype'] == 'sqlite') { - $result = $db->query('VACUUM'); - if (DB::isError($result)) { - P2Util::pushInfoHtml($result->getMessage()); - } else { + if ($icdc->db_class === 'sqlite') { + try { + $result = $db->query('VACUUM'); P2Util::pushInfoHtml('

    画像データベースを最適化しました。

    '); + } catch (PDOException $e) { + P2Util::pushInfoHtml($e->getMessage()); } } @@ -209,7 +206,7 @@ $flexy->setData('doctype', $_conf['doctype']); $flexy->setData('extra_headers', $_conf['extra_headers_ht']); $flexy->setData('extra_headers_x', $_conf['extra_headers_xht']); -if ($db->dsn['phptype'] == 'sqlite' || $viewer_cache_exists) { +if ($icdc->db_class === 'sqlite' || $viewer_cache_exists) { $flexy->setData('enable_optimize_db', true); } else { $flexy->setData('enable_optimize_db', false); diff --git a/rep2/ic2_viewtable.php b/rep2/ic2_viewtable.php index f1bace946..ec5e33ce5 100644 --- a/rep2/ic2_viewtable.php +++ b/rep2/ic2_viewtable.php @@ -47,16 +47,11 @@ p2die('ImageCache2 - 不正なクエリ'); } -$db = $table->getDatabaseConnection(); if (isset($_POST['clean'])) { - $sql = 'DELETE FROM ' . $db->quoteIdentifier($table->__table); - $result = $db->query($sql); - if (DB::isError($result)) { - p2die($result->getMessage()); - } + $result = (new ImageCache2_DataObject_Errors())->ic2_errlog_clean(); } elseif (isset($_POST['delete']) && isset($_POST['target']) && is_array($_POST['target'])) { foreach ($_POST['target'] as $target) { - $delete = clone $table; + $delete = new ImageCache2_DataObject_Errors(); $delete->uri = $target; $delete->delete(); } diff --git a/rep2/iv2.php b/rep2/iv2.php index c0dc0fed8..bfdf4d333 100644 --- a/rep2/iv2.php +++ b/rep2/iv2.php @@ -176,8 +176,8 @@ // DB_DataObjectを継承したDAO $icdb = new ImageCache2_DataObject_Images(); -$db = $icdb->getDatabaseConnection(); -$db_class = strtolower(get_class($db)); +$db = $icdb->PDO(); +$db_class = $icdb->db_class; if ($ini['Viewer']['cache']) { $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], @@ -203,11 +203,8 @@ $kvs->optimize(); // SQLiteならVACUUMを実行 - if ($db_class == 'db_sqlite') { + if ($db_class == 'sqlite') { $result = $db->query('VACUUM'); - if (DB::isError($result)) { - p2die($result->getMessage()); - } } } @@ -436,7 +433,7 @@ if (strpos($k, '%') !== false || strpos($k, '_') !== false) { // SQLite2はLIKE演算子の右辺でバックスラッシュによるエスケープや // ESCAPEでエスケープ文字を指定することができないのでGLOB演算子を使う - if ($db_class == 'db_sqlite') { + if ($db_class == 'sqlite') { if (strpos($k, '*') !== false || strpos($k, '?') !== false) { p2die('ImageCache2 Warning', '「%または_」と「*または?」が混在するキーワードは使えません。'); } else { @@ -468,7 +465,7 @@ $_find_duplicated = 0; // 試験的パラメータ、登録レコード数がこれ以上の画像のみを抽出 if ($_find_unique || $_find_duplicated > 1) { $subq = 'SELECT ' . (($sort == 'ASC') ? 'MIN' : 'MAX') . '(id) FROM '; - $subq .= $db->quoteIdentifier($ini['General']['table']); + $subq .= $icdb->quoteIdentifier($ini['General']['table']); if (isset($keywords)) { // サブクエリ内でフィルタリングするので親クエリのWHERE句をパクってきてリセット $subq .= $icdb->_query['condition']; @@ -578,11 +575,7 @@ //$db->setFetchMode(DB_FETCHMODE_ORDERED); //$all = (int)$icdb->count('*', true); //$db->setFetchMode(DB_FETCHMODE_ASSOC); -$sql = sprintf('SELECT COUNT(*) FROM %s %s', $db->quoteIdentifier($ini['General']['table']), $icdb->_query['condition']); -$all = (int)$db->getOne($sql); -if (DB::isError($all)) { - p2die($all->getMessage()); -} +$all = $icdb->count('*'); // マッチするレコードがなかったらエラーを表示、レコードがあれば表示用オブジェクトに値を代入 if ($all === 0) { @@ -759,7 +752,7 @@ $orderBy = '(width * height) ' . $sort; } } elseif ($order == 'date_uri' || $order == 'date_uri2') { - if ($db_class == 'db_sqlite') { + if ($db_class == 'sqlite') { /* function iv2_sqlite_unix2date($ts) { @@ -771,16 +764,16 @@ function iv2_sqlite_unix2date($ts) $time2date = 'php(\'date\', \'Ymd\', "time")'; } else { // 32400 = 9*60*60 (時差補正) - $time2date = sprintf('floor((%s + 32400) / 86400)', $db->quoteIdentifier('time')); + $time2date = sprintf('floor((%s + 32400) / 86400)', $icdb->quoteIdentifier('time')); } - $orderBy = sprintf('%s %s, %s ', $time2date, $sort, $db->quoteIdentifier('uri')); + $orderBy = sprintf('%s %s, %s ', $time2date, $sort, $icdb->quoteIdentifier('uri')); if ($order == 'date_uri') { $orderBy .= $sort; } else { $orderBy .= ($sort == 'ASC') ? 'DESC' : 'ASC'; } } else { - $orderBy = $db->quoteIdentifier($order) . ' ' . $sort; + $orderBy = $icdb->quoteIdentifier($order) . ' ' . $sort; } $orderBy .= ' , id ' . $sort; $icdb->orderBy($orderBy); From 325d7397982d4570d3895c59bc2e340e78e53686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Sun, 26 Jul 2020 17:41:50 +0900 Subject: [PATCH 05/36] =?UTF-8?q?Wikipedia=E3=81=B8=E3=81=AE=E8=87=AA?= =?UTF-8?q?=E5=8B=95=E3=83=AA=E3=83=B3=E3=82=AF=E3=81=8C=E5=8B=95=E3=81=8F?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ShowThreadPc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ShowThreadPc.php b/lib/ShowThreadPc.php index 5eebfdd77..5126a9018 100644 --- a/lib/ShowThreadPc.php +++ b/lib/ShowThreadPc.php @@ -560,7 +560,7 @@ public function transMsg($msg, $mynum) $msg = $this->transLink($msg); // Wikipedia記法への自動リンク - if ($_conf['_linkToWikipeida']) { + if ($_conf['link_wikipedia']) { $msg = $this->_wikipediaFilter($msg); } From 0f46b9b9acb67f95a5d0b86590d532e05cd71f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Sun, 26 Jul 2020 17:41:51 +0900 Subject: [PATCH 06/36] =?UTF-8?q?=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB?= =?UTF-8?q?=E3=83=88=E5=90=8D=E3=81=AB=E5=90=AB=E3=81=BE=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E3=81=B8=E3=82=A2=E3=83=B3=E3=82=AB=E3=83=BC?= =?UTF-8?q?=E3=81=8C=E5=BC=B5=E3=82=89=E3=82=8C=E3=82=8B=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix http://egg.5ch.net/test/read.cgi/software/1581552388/507 --- lib/ShowThread.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ShowThread.php b/lib/ShowThread.php index b73ed9dd1..65f523765 100644 --- a/lib/ShowThread.php +++ b/lib/ShowThread.php @@ -1538,9 +1538,27 @@ public function getQuoteResNumsName($name) return false; } + // HTMLタグを除去 + $name = strip_tags(trim($name)); + + // デフォルトの名無し名を除去 + if (isset($this->_nanashiName)) { + $name = str_replace($this->_nanashiName, "", $name); + } + + /* + * ワッチョイを除去 + * (ワッチョイW a897-sa51) + * (スッップ Ad38-g1G2 [11.11.11.11 [上級国民]]) + */ + $name = preg_replace('/\(.+ .{4}-.{4}( \[.+])?\)/', '', $name, 1); + // トリップを除去 $name = preg_replace('/◆.*/', '', $name, 1); - $name = strip_tags($name); + + if (strlen($name) == 0) { + return false; + } /* //if (preg_match('/[0-9]+/', $name, $m)) { From 6116bfd17f7491db525dc9a5728a7b18286aa369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 08:59:59 +0900 Subject: [PATCH 07/36] =?UTF-8?q?data=E3=81=8C=E7=A9=BA=E3=81=AE=E3=81=A8?= =?UTF-8?q?=E3=81=8D=E3=81=AB=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 68b61d5af..1b43ae1d9 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,10 @@ { "type": "git", "url": "https://github.com/mikoim/html_template_flexy.git" + }, + { + "type": "git", + "url": "https://github.com/mikoim/php8-File.git" } ], "require": { @@ -39,8 +43,6 @@ "pear-pear.php.net/benchmark": "1.2.*", "pear-pear.php.net/cache_lite": "1.*", "pear-pear.php.net/date": "1.4.*", - "pear-pear.php.net/file": "1.4.*", - "pear-pear.php.net/file_util": "1.0.*", "pear-pear.php.net/http_request2": "2.3.*", "pear-pear.php.net/net_socket": "1.2.*", "pear-pear.php.net/net_url": "1.0.*", @@ -51,6 +53,7 @@ "pear-pear.php.net/var_dump": "1.0.*", "pear-pear.php.net/xml_parser": "1.3.*", "pear-pear.php.net/xml_rss": "1.1.*", + "pear/file": "dev-master", "pear/html_template_flexy": "dev-master", "roojs/pdo_dataobject": "dev-master", "symfony/console": "5.1.*", From cfb8bf3bab51c364a041e25d44250b101d506897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 09:01:35 +0900 Subject: [PATCH 08/36] =?UTF-8?q?=E3=82=B9=E3=83=AC=E3=83=83=E3=83=89?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=8C=E7=A9=BA=E3=81=AE=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AB=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ThreadList.php | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/ThreadList.php b/lib/ThreadList.php index ccac14013..dd211a092 100644 --- a/lib/ThreadList.php +++ b/lib/ThreadList.php @@ -128,30 +128,23 @@ public function readList() //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('readList()'); + $lines = array(); + switch ($this->spmode) { // ローカルの履歴ファイル 読み込み case 'recent': - if ($lines = FileCtl::file_read_lines($_conf['recent_idx'])) { - //P2Util::pushInfoHtml('

    履歴は空っぽです

    '); - //return false; - } + $lines = FileCtl::file_read_lines($_conf['recent_idx']); break; // ローカルの書き込み履歴ファイル 読み込み case 'res_hist': - if ($lines = FileCtl::file_read_lines($_conf['res_hist_idx'])) { - //P2Util::pushInfoHtml('

    書き込み履歴は空っぽです

    '); - //return false; - } + $lines = FileCtl::file_read_lines($_conf['res_hist_idx']); break; //ローカルのお気にファイル 読み込み case 'fav': - if ($lines = FileCtl::file_read_lines($_conf['favlist_idx'])) { - //P2Util::pushInfoHtml('

    お気にスレは空っぽです

    '); - //return false; - } + $lines = FileCtl::file_read_lines($_conf['favlist_idx']); break; // お気に板をまとめて読み込み @@ -181,7 +174,6 @@ public function readList() } } - $lines = array(); $i = 0; foreach ($favitas as $ita) { @@ -323,7 +315,7 @@ public function readList() //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('readList()'); - return $lines; + return is_array($lines) ? $lines : array(); } // }}} From 25e7e816c9baa729229bcd211796ca541432a835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 09:02:23 +0900 Subject: [PATCH 09/36] =?UTF-8?q?=E3=82=B9=E3=83=AC=E3=83=83=E3=83=89?= =?UTF-8?q?=E3=81=8Cdat=E8=90=BD=E3=81=A1=E3=81=97=E3=81=9F=E6=99=82?= =?UTF-8?q?=E3=81=AB=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ThreadRead.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ThreadRead.php b/lib/ThreadRead.php index 0e045addb..defcf2771 100644 --- a/lib/ThreadRead.php +++ b/lib/ThreadRead.php @@ -35,6 +35,7 @@ class ThreadRead extends Thread { public function __construct() { parent::__construct (); $this->getdat_error_msg_ht = ""; + $this->datochi_residuums = array(); } // }}} From 42c95286be5a8c2bdddbe6ebe03b62301784f967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 09:03:49 +0900 Subject: [PATCH 10/36] =?UTF-8?q?=E5=BB=83=E6=AD=A2=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9F=E6=A7=8B=E6=96=87=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rep2/post.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rep2/post.php b/rep2/post.php index 4e9bcf97b..6dc39a84b 100644 --- a/rep2/post.php +++ b/rep2/post.php @@ -212,7 +212,7 @@ PostDataStore::set($post_backup_key, $post_cache); // cookie 読み込み -$cookie_key = $_login->user_u . '/' . P2Util::normalizeHostName(P2HostMgr::isHostBbsPink($host) ? 'www.bbspink.com' : P2HostMgr::isHost2chs($host) ? 'www.5ch.net' : $host); // 忍法帳対応 +$cookie_key = $_login->user_u . '/' . P2Util::normalizeHostName(P2HostMgr::isHostBbsPink($host) ? 'www.bbspink.com' : (P2HostMgr::isHost2chs($host) ? 'www.5ch.net' : $host)); // 忍法帳対応 if ($p2cookies = CookieDataStore::get($cookie_key)) { if (is_array($p2cookies)) { if (array_key_exists('expires', $p2cookies)) { From c6cc9ecc032f4b25d190fa12bea7b759332b8e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 11:17:04 +0900 Subject: [PATCH 11/36] =?UTF-8?q?GD=E3=81=A7=E3=82=B5=E3=83=A0=E3=83=8D?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=81=8C=E7=94=9F=E6=88=90=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 1 + lib/Thumbnailer/Gd.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1b43ae1d9..a90e2c86a 100644 --- a/composer.json +++ b/composer.json @@ -61,6 +61,7 @@ }, "suggest": { "ext-exif": "Needed to show Exif in IC2", + "ext-gd": "Needed to use GD in IC2", "ext-pdo_mysql": "Needed to use MySQL in IC2", "ext-pdo_pgsql": "Needed to use PostgreSQL in IC2", "ext-pdo_sqlite": "Needed to use SQLite in IC2" diff --git a/lib/Thumbnailer/Gd.php b/lib/Thumbnailer/Gd.php index ca526741d..e424b9298 100644 --- a/lib/Thumbnailer/Gd.php +++ b/lib/Thumbnailer/Gd.php @@ -116,8 +116,10 @@ protected function _convert($source, $size) case '.jpg': $src = imagecreatefromjpeg($source); break; case '.png': $src = imagecreatefrompng($source); break; case '.gif': $src = imagecreatefromgif($source); break; + default: + $src = false; } - if (!is_resource($src)) { + if (!$src) { $error = PEAR::raiseError("Failed to load the image. ({$source})"); return $error; } From 5c1af139407df5db9ad00651052b7232bf1b702f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 11:55:04 +0900 Subject: [PATCH 12/36] =?UTF-8?q?Git=E3=81=AE=E5=B7=AE=E5=88=86=E3=82=92Sh?= =?UTF-8?q?ift-JIS=E3=81=A8=E3=81=97=E3=81=A6=E6=89=B1=E3=81=86=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..603f68158 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +**.html diff=sjis +**.inc diff=sjis +**.php diff=sjis +**.txt diff=sjis From 663f66cb656a8a93e7b427a4fb7123782d1a39d0 Mon Sep 17 00:00:00 2001 From: junk2ool Date: Sun, 5 Jul 2020 10:29:59 +0900 Subject: [PATCH 13/36] =?UTF-8?q?=E3=82=B9=E3=83=9E=E3=83=9B=E3=81=A7?= =?UTF-8?q?=E5=90=8D=E5=89=8D=E6=AC=84=E3=81=AB=E7=BD=AE=E6=8F=9B=E3=83=AF?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=81=8C=E5=83=8D=E3=81=8B=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ShowThreadI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ShowThreadI.php b/lib/ShowThreadI.php index 0e505b10b..e6e525196 100644 --- a/lib/ShowThreadI.php +++ b/lib/ShowThreadI.php @@ -391,7 +391,7 @@ public function transRes($ares, $i, $pattern = null) */ public function transName($name) { - $name = strip_tags($name); + $name = strtr($name, array('' => '', '' => '')); // トリップやホスト付きなら分解する if (($pos = strpos($name, '◆')) !== false) { From ffcad34d22c61b45a24f3e62eb32171a0aee5ea7 Mon Sep 17 00:00:00 2001 From: junk2ool Date: Sun, 5 Jul 2020 11:03:25 +0900 Subject: [PATCH 14/36] =?UTF-8?q?host=E9=81=95=E3=81=84=E3=81=A7bbs?= =?UTF-8?q?=E3=81=A8key=E3=81=8C=E5=90=8C=E3=81=98=E3=82=B9=E3=83=AC?= =?UTF-8?q?=E3=81=8C=E3=81=8A=E6=B0=97=E3=81=AB=E5=85=A5=E3=82=8A=E7=99=BB?= =?UTF-8?q?=E9=8C=B2=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84=E3=81=AE=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/setfav.inc.php | 2 +- lib/setpalace.inc.php | 2 +- rep2/live_read.php | 2 +- rep2/read.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/setfav.inc.php b/lib/setfav.inc.php index aa6563dce..2a31b3437 100644 --- a/lib/setfav.inc.php +++ b/lib/setfav.inc.php @@ -98,7 +98,7 @@ function setFav($host, $bbs, $key, $setfav, $ttitle = null, $setnum = null) $i++; $lar = explode('<>', $l); // 重複回避 - if ($lar[1] == $key && $lar[11] == $bbs) { + if ($lar[1] == $key && $lar[11] == $bbs && $lar[10] == $host) { $before_line_num = $i; // 移動前の行番号をセット $was_set = true; continue; diff --git a/lib/setpalace.inc.php b/lib/setpalace.inc.php index 8e978c7de..a683d4f7a 100644 --- a/lib/setpalace.inc.php +++ b/lib/setpalace.inc.php @@ -55,7 +55,7 @@ function setPal($host, $bbs, $key, $setpal, $ttitle = null) $i++; $lar = explode('<>', $l); // 重複回避 - if ($lar[1] == $key && $lar[11] == $bbs) { + if ($lar[1] == $key && $lar[11] == $bbs && $lar[10] == $host) { $pal_attayo = true; $before_line_num = $i; // 移動前の行番号をセット continue; diff --git a/rep2/live_read.php b/rep2/live_read.php index a03e8e17f..41c446998 100755 --- a/rep2/live_read.php +++ b/rep2/live_read.php @@ -402,7 +402,7 @@ function recRecent($data) $lar = explode('<>', $l); $data_ar = explode('<>', $data); if (!$lar[1] || !strlen($lar[11])) { continue; } // 不正データを削除 - if ($lar[1] == $data_ar[1] && $lar[11] == $data_ar[11]) { continue; } // key, bbsで重複回避 + if ($lar[1] == $data_ar[1] && $lar[11] == $data_ar[11] && $lar[10] == $data_ar[10]) { continue; } // key, bbsで重複回避 $neolines[] = $l; } } diff --git a/rep2/read.php b/rep2/read.php index 5e0939882..b5366f8b2 100644 --- a/rep2/read.php +++ b/rep2/read.php @@ -522,7 +522,7 @@ function recRecent($data) $lar = explode('<>', $l); $data_ar = explode('<>', $data); if (!$lar[1] || !strlen($lar[11])) { continue; } // 不正データを削除 - if ($lar[1] == $data_ar[1] && $lar[11] == $data_ar[11]) { continue; } // key, bbsで重複回避 + if ($lar[1] == $data_ar[1] && $lar[11] == $data_ar[11] && $lar[10] == $data_ar[10]) { continue; } // key, bbsで重複回避 $neolines[] = $l; } } From c0419042ca85d4251ec1c4e9023c0bcc74d75dfb Mon Sep 17 00:00:00 2001 From: junk2ool Date: Sun, 5 Jul 2020 11:07:12 +0900 Subject: [PATCH 15/36] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=83=A9?= =?UTF-8?q?=E6=BC=8F=E3=82=8C=E9=98=B2=E6=AD=A2=E5=AF=BE=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/conf.inc.php b/conf/conf.inc.php index d037ef844..9dd7d3874 100644 --- a/conf/conf.inc.php +++ b/conf/conf.inc.php @@ -292,6 +292,8 @@ function p2_init() include P2_LIB_DIR . '/bootstrap.php'; } +header("Referrer-Policy: no-referrer"); + // }}} /* From 6d62951715aea00815510b684e586ebe9e8336ba Mon Sep 17 00:00:00 2001 From: junk2ool Date: Sun, 5 Jul 2020 11:22:35 +0900 Subject: [PATCH 16/36] =?UTF-8?q?2ch=5Fssl.subject=E3=81=8C=E5=8A=B9?= =?UTF-8?q?=E3=81=84=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/P2CurlMulti.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/P2CurlMulti.php b/lib/P2CurlMulti.php index 4ad2fc0ac..f1fbb6d75 100644 --- a/lib/P2CurlMulti.php +++ b/lib/P2CurlMulti.php @@ -34,7 +34,11 @@ private function add($subjects, $force = false) { foreach ($subjects as $key => $subject) { list($host, $bbs) = explode("_", $key); - $url = "http://{$host}/{$bbs}/subject.txt"; + if ($_conf['2ch_ssl.subject']) { + $url = "https://{$host}/{$bbs}/subject.txt"; + } else { + $url = "http://{$host}/{$bbs}/subject.txt"; + } $file = P2Util::datDirOfHostBbs($host, $bbs) . 'subject.txt'; $isOldFile[$key] = false; From be98ce4754f324f2c5096f682bafca4fa8147812 Mon Sep 17 00:00:00 2001 From: junk2ool Date: Fri, 24 Jul 2020 19:55:10 +0900 Subject: [PATCH 17/36] =?UTF-8?q?>>1=20=E3=82=92=E3=81=82=E3=81=BC?= =?UTF-8?q?=E3=83=BC=E3=82=93=E3=81=AE=E5=AF=BE=E8=B1=A1=E5=A4=96=E3=81=AB?= =?UTF-8?q?=E3=81=99=E3=82=8B=20=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf_user_def.inc.php | 4 ++++ lib/ShowThread.php | 5 +++++ rep2/edit_conf_user.php | 1 + 3 files changed, 10 insertions(+) diff --git a/conf/conf_user_def.inc.php b/conf/conf_user_def.inc.php index 34bb94443..b92938bbf 100644 --- a/conf/conf_user_def.inc.php +++ b/conf/conf_user_def.inc.php @@ -379,6 +379,10 @@ $conf_user_def['ngaborn_purge_aborn'] = 0; // (0) $conf_user_rad['ngaborn_purge_aborn'] = array('1' => 'はい', '0' => 'いいえ'); +// >>1 をあぼーんの対象外にする(する:1, しない:0) +$conf_user_def['ngaborn_exclude_one'] = 0; // (0) +$conf_user_rad['ngaborn_exclude_one'] = array('1' => 'する', '0' => 'しない'); + // }}} // {{{ 2ch API diff --git a/lib/ShowThread.php b/lib/ShowThread.php index 65f523765..b0aeea268 100644 --- a/lib/ShowThread.php +++ b/lib/ShowThread.php @@ -681,6 +681,11 @@ protected function _ngAbornCheck($i, $name, $mail, $date_id, $id, $msg, $nong = $info = array(); $type = self::NG_NONE; + // >>1 をあぼーんの対象外にする + if ($_conf['ngaborn_exclude_one'] && $i == 1) { + return $type; + } + // {{{ 頻出IDチェック if ($this->_ngaborn_frequent && $id && $this->thread->idcount[$id] >= $_conf['ngaborn_frequent_num']) { diff --git a/rep2/edit_conf_user.php b/rep2/edit_conf_user.php index 63359586e..ce8ea5ac8 100644 --- a/rep2/edit_conf_user.php +++ b/rep2/edit_conf_user.php @@ -357,6 +357,7 @@ array('ngaborn_chain_all', '表示範囲外のレスも連鎖NG/あぼーん/ハイライトの対象にする
    (処理を軽くするため、デフォルトではしない)'), array('ngaborn_daylimit', 'この期間、NG/あぼーん/ハイライトにHITしなければ、登録ワードを自動的に外す (日数)'), array('ngaborn_purge_aborn', 'あぼーんレスは不可視divブロックも描画しない'), + array('ngaborn_exclude_one', '>>1 をあぼーんの対象外にする'), ); printEditConfGroupHtml($groupname, $conflist, $flags); } From 620d238dc4bf8ca3400412ac935b2b5ae4f4d4f6 Mon Sep 17 00:00:00 2001 From: junk2ool Date: Tue, 11 Aug 2020 21:12:49 +0900 Subject: [PATCH 18/36] =?UTF-8?q?ip2host=E3=82=92=E5=8F=96=E3=82=8A?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E6=8B=A1=E5=BC=B5=E3=83=91=E3=83=83=E3=82=AF?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=81=A7=E8=A8=AD=E5=AE=9A=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf_user_def.inc.php | 5 + conf/conf_user_def_ip2host.inc.php | 45 ++++++++ lib/expack/ip2host.inc.php | 171 ++++++++++++++++++++++++++++ lib/read_footer.inc.php | 5 + lib/read_footer_i.inc.php | 5 + rep2/edit_conf_user.php | 19 ++++ rep2/ip2host.php | 172 +++++++++++++++++++++++++++++ 7 files changed, 422 insertions(+) create mode 100644 conf/conf_user_def_ip2host.inc.php create mode 100644 lib/expack/ip2host.inc.php create mode 100644 rep2/ip2host.php diff --git a/conf/conf_user_def.inc.php b/conf/conf_user_def.inc.php index b92938bbf..8d3469754 100644 --- a/conf/conf_user_def.inc.php +++ b/conf/conf_user_def.inc.php @@ -627,7 +627,12 @@ include P2_CONFIG_DIR . '/conf_user_def_live.inc.php'; // }}} +// {{{ ip2host +include P2_CONFIG_DIR . '/conf_user_def_ip2host.inc.php'; + +// }}} + /* * Local Variables: * mode: php diff --git a/conf/conf_user_def_ip2host.inc.php b/conf/conf_user_def_ip2host.inc.php new file mode 100644 index 000000000..9ae009d38 --- /dev/null +++ b/conf/conf_user_def_ip2host.inc.php @@ -0,0 +1,45 @@ + 'sessionStorage(ブラウザ側)', + '1' => 'localStorage(ブラウザ側)', + '2' => 'ファイル(サーバー側)', +); + +// }}} + +// {{{ 書き換えのタイミング + +// 書き換えのタイミング(スレ表示時に一括書き換え:0, 画面スクロールで書き換え:1) +$conf_user_def['ip2host.replace.type'] = 0; // (0) +$conf_user_sel['ip2host.replace.type'] = array( + '0' => 'スレ表示時に一括書き換え', + '1' => '画面スクロールで書き換え', +); + +// }}} + +// {{{ ip2hostの設定 + +// ip2hostを使用するか +$conf_user_def['ip2host.enabled'] = 0; // (0) +$conf_user_rad['ip2host.enabled'] = array('1' => 'する', '0' => 'しない'); + +// キャッシュの上限数 +$conf_user_def['ip2host.cache.size'] = 500; // (500) +$conf_user_rules['ip2host.cache.size'] = array('emptyToDef', 'notIntExceptMinusToDef'); + +// 逆引き後のあぼーん処理をするか +$conf_user_def['ip2host.aborn.enabled'] = 1; // (1) +$conf_user_rad['ip2host.aborn.enabled'] = array('1' => 'する', '0' => 'しない'); + +// }}} diff --git a/lib/expack/ip2host.inc.php b/lib/expack/ip2host.inc.php new file mode 100644 index 000000000..6e4ed67f2 --- /dev/null +++ b/lib/expack/ip2host.inc.php @@ -0,0 +1,171 @@ +hostしてあぼーん +echo << + let web_storage = 0; + +IP2HOST; +echo " let scroll_replace = ".$_conf['ip2host.replace.type'].";\n"; +//if ($_conf['ip2host.replace.type'] == 0) { +// echo " let scroll_replace = 0;"; +//} else { +// echo " let scroll_replace = 1;"; +//} +echo << scroll_top && header_top < scroll_top + wh)) { + let res_header_tmp = res_header.clone(); + res_header_tmp.find('b').text(''); + let ip_addr = res_header_tmp.html().match(/.+? \[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})[\]| ]/); + if (ip_addr == null) { + return true; + }; + + replace_html(ip_addr[1], st, res_header); + } + }); + } + + function replace_html(ip_addr, st, res_header) { + let param = {}; + let ip2host_url = 'ip2host.php'; + let host = null; + + // 名前欄のあぼーん処理を適用 する:1 しない:0\n +IP2HOST; +echo " let aborn = ".$_conf['ip2host.aborn.enabled'].";\n"; +echo << ip_cache_size) { + st.clear(); + } else { + host = st.getItem(ip_addr); + } + } else { + param['cache_size'] = ip_cache_size; + } + if (host === null) { + param['action'] = 'GetHost'; + } else { + param['action'] = 'AbornHost'; + } + param['ip'] = ip_addr; + param['aborn'] = aborn; + param['host'] = host;\n +IP2HOST; + echo " param['bbs'] = '".$bbs."';\n"; + echo " param['title'] = '".$ttitle_en."';\n"; +echo <<\n +IP2HOST; + +// }}} + +/* + * Local Variables: + * mode: php + * coding: cp932 + * tab-width: 4 + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ +// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker: diff --git a/lib/read_footer.inc.php b/lib/read_footer.inc.php index daeaa3527..b7475c873 100644 --- a/lib/read_footer.inc.php +++ b/lib/read_footer.inc.php @@ -196,6 +196,11 @@ function startlive() { LIVE; } +// ip2host +if ($_conf['ip2host.enabled']) { + include P2EX_LIB_DIR . '/ip2host.inc.php'; +} + // ==== echo ''; diff --git a/lib/read_footer_i.inc.php b/lib/read_footer_i.inc.php index 229cb6a60..5783bb21f 100644 --- a/lib/read_footer_i.inc.php +++ b/lib/read_footer_i.inc.php @@ -189,6 +189,11 @@ EOS; } +// ip2host +if ($_conf['ip2host.enabled']) { + include P2EX_LIB_DIR . '/ip2host.inc.php'; +} + echo ''; /* diff --git a/rep2/edit_conf_user.php b/rep2/edit_conf_user.php index ce8ea5ac8..4d8b910c9 100644 --- a/rep2/edit_conf_user.php +++ b/rep2/edit_conf_user.php @@ -867,6 +867,25 @@ printEditConfGroupHtml($groupname, $conflist, $flags); } +// }}} +// {{{ expack - ip2host + +$groupname = 'ip2host'; +$groups[] = $groupname; +$flags = getGroupShowFlags($groupname); +if ($flags & P2_EDIT_CONF_USER_SKIPPED) { + $keep_old = true; +} else { + $conflist = array( + array('ip2host.enabled', 'ip2hostを利用'), + array('ip2host.replace.type', '書き換えのタイミング'), + array('ip2host.cache.type', 'キャッシュ方法'), + array('ip2host.cache.size', 'キャッシュの上限数'), + array('ip2host.aborn.enabled', '逆引き後のあぼーん処理'), + ); + printEditConfGroupHtml($groupname, $conflist, $flags); +} + // }}} // }}} diff --git a/rep2/ip2host.php b/rep2/ip2host.php new file mode 100644 index 000000000..893d0f738 --- /dev/null +++ b/rep2/ip2host.php @@ -0,0 +1,172 @@ + 0) { + if (!empty($ip_cache) && array_key_exists($ip, $ip_cache)) { + //echo 'cache '; + $host = $ip_cache[$ip]; + } else { + // キャッシュの上限を超えたら古いものから10個消す + while (count($ip_cache) > $ip_cache_size) { + for ($i = 0; $i < 10; $i++) { + array_shift($ip_cache); + } + } + // キャッシュの上限を超えたら全部消す場合はこっち + //if (count($ip_cache) > $ip_cache_size) { + // $ip_cache = array(); + //} + + $host = gethostbyaddr($ip); + $ip_cache[$ip] = $host; + + if ($fp_lock = lock($lock_file)) { + if ($fp = fopen($cache_file, "w")) { + foreach ($ip_cache as $key => $value) { + fwrite($fp, $key.','.$value."\n"); + } + fclose($fp); + } + fclose($fp_lock); + } + } + } else { + $host = gethostbyaddr($ip); + } +} else if ($action === 'AbornHost') { + if (!$host = filter_input(INPUT_GET, 'host')) { + return; + } +} else { + return; +} +if (!$bbs = filter_input(INPUT_GET, 'bbs')) { + return; +} + +if (!$title = filter_input(INPUT_GET, 'title')) { + return; +} + +if (!$aborn = filter_input(INPUT_GET, 'aborn')) { + $aborn = 0; +} + +if ($aborn && ngAbornCheck('aborn_name', $host, $bbs, UrlSafeBase64::decode($title)) !== false) { + if ($action === 'GetHost') { + echo $host.','; + } + echo 'aborn'; +} else { + echo $host; +} + +// キャッシュファイルの排他ロック用 +function lock($lock_file) +{ + if (!$fp = fopen($lock_file, "a")) return false; + + for ($i = 0; $i < 60; $i++) { + if (flock($fp, LOCK_EX | LOCK_NB)) { + return $fp; + } else { + usleep(500000); // 0.5秒 * 60回遅延 + } + } + fclose($fp); + + return false; +} + +// {{{ ngAbornCheck() + +/** + * NGあぼーんチェック + * lib/ShowThread.phpから引っこ抜いてあぼーん判定だけに + */ +function ngAbornCheck($code, $resfield, $bbs, $title, $ic = false) +{ + $ngaborns = NgAbornCtl::loadNgAborns(); + + //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('ngAbornCheck()'); + + if (isset($ngaborns[$code]['data']) && is_array($ngaborns[$code]['data'])) { + foreach ($ngaborns[$code]['data'] as $k => $v) { + // 板チェック + if (isset($v['bbs']) && in_array($bbs, $v['bbs']) == false) { + continue; + } + + // タイトルチェック + if (isset($v['title']) && stripos($title, $v['title']) === false) { + continue; + } + + // ワードチェック + // 正規表現 + if ($v['regex']) { + $re_method = $v['regex']; + /*if ($re_method($v['word'], $resfield, $matches)) { + $this->ngAbornUpdate($code, $k); + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()'); + return p2h($matches[0]); + }*/ + if ($re_method($v['word'], $resfield)) { + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()'); + return $v['cond']; + } + // 大文字小文字を無視 + } elseif ($ic || $v['ignorecase']) { + if (stripos($resfield, $v['word']) !== false) { + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()'); + return $v['cond']; + } + // 単純に文字列が含まれるかどうかをチェック + } else { + if (strpos($resfield, $v['word']) !== false) { + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()'); + return $v['cond']; + } + } + } + } + + //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('ngAbornCheck()'); + return false; +} + +// }}} + +?> From 89ed199acfdf891e355595af7428e2903c23e7fb Mon Sep 17 00:00:00 2001 From: junk2ool Date: Tue, 11 Aug 2020 21:22:59 +0900 Subject: [PATCH 19/36] =?UTF-8?q?=E6=9B=B8=E3=81=8D=E8=BE=BC=E3=81=BF?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E3=81=AB=E4=B8=80=E6=99=82?= =?UTF-8?q?=E7=9A=84=E3=81=AA=E3=83=97=E3=83=AD=E3=82=AD=E3=82=B7=E3=81=AE?= =?UTF-8?q?=E3=82=AA=E3=83=B3=E3=82=AA=E3=83=95=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/post_form.inc.php | 1 + lib/post_form_options.inc.php | 16 ++++++++++++++++ rep2/post.php | 22 +++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/post_form.inc.php b/lib/post_form.inc.php index e47ebce8a..3308a6ff1 100644 --- a/lib/post_form.inc.php +++ b/lib/post_form.inc.php @@ -119,6 +119,7 @@ {$htm['src_fix']} {$htm['block_submit']} {$htm['table_break2']} +{$htm['proxy']} {$htm['beres']} {$htm['p2res']} diff --git a/lib/post_form_options.inc.php b/lib/post_form_options.inc.php index aafb45ab2..492fd1e6d 100644 --- a/lib/post_form_options.inc.php +++ b/lib/post_form_options.inc.php @@ -17,6 +17,7 @@ $hd['subject'] = ''; $hd['beres_checked'] = ''; $hd['p2res_checked'] = ''; +$hd['proxy_checked'] = ''; $htm['beres'] = ''; $htm['p2res'] = ''; @@ -28,6 +29,7 @@ $htm['options_k'] = ''; $htm['subject'] = ''; $htm['resform_ttitle'] = ''; +$htm['proxy'] = ''; $htm['disable_js'] = << @@ -110,6 +112,11 @@ function setHiddenValue(button) { } } +// proxy +if ($_conf['proxy_use']) { + $hd['proxy_checked'] = ' checked'; +} + // }}} // {{{ 名前とメールの最終調整 @@ -179,6 +186,15 @@ function setHiddenValue(button) { . ''; } +// }}} +// {{{ Proxy チェックボックス + +// Proxy +if ($_conf['proxy_host']) { + $htm['proxy'] = '' + . ''; +} + // }}} // {{{ 書き込みブロック用チェックボックス diff --git a/rep2/post.php b/rep2/post.php index 6dc39a84b..dd83d45d8 100644 --- a/rep2/post.php +++ b/rep2/post.php @@ -36,7 +36,7 @@ $post_param_keys = array('bbs', 'key', 'time', 'FROM', 'mail', 'MESSAGE', 'subject', 'submit'); $post_internal_keys = array('host', 'sub', 'popup', 'rescount', 'ttitle_en'); -$post_optional_keys = array('newthread', 'beres', 'p2res', 'from_read_new', 'maru', 'csrfid'); +$post_optional_keys = array('newthread', 'beres', 'p2res', 'from_read_new', 'maru', 'csrfid', 'proxy'); $post_p2_flag_keys = array('b', 'p2_post_confirm_cookie'); foreach ($post_param_keys as $pk) { @@ -230,8 +230,24 @@ $p2cookies = null; } -// 直接書き込み -$posted = postIt($host, $bbs, $key, $post); +if ($_conf['proxy_host']) { + // 一時的にプロキシのオンオフを切り替えて書き込み + global $_conf; + + $bak_proxy_use = $_conf['proxy_use']; + if (empty($_REQUEST['proxy']) || !$_REQUEST['proxy']) { + // proxyをオフで書き込み + $_conf['proxy_use'] = 0; + } else { + // proxyをオンで書き込み + $_conf['proxy_use'] = 1; + } + $posted = postIt($host, $bbs, $key, $post); + $_conf['proxy_use'] = $bak_proxy_use; +} else { + // 直接書き込み + $posted = postIt($host, $bbs, $key, $post); +} // cookie 保存 if ($p2cookies) { From 72c38bdb29957863736ac56831fa2153af188272 Mon Sep 17 00:00:00 2001 From: junk2ool Date: Thu, 20 Aug 2020 18:33:36 +0900 Subject: [PATCH 20/36] =?UTF-8?q?SSL=E3=81=A7=E3=81=AE=E6=9B=B8=E3=81=8D?= =?UTF-8?q?=E8=BE=BC=E3=81=BF=E6=99=82=E3=81=ABReferer=E3=82=82https?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rep2/post.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rep2/post.php b/rep2/post.php index dd83d45d8..9c4a4eab8 100644 --- a/rep2/post.php +++ b/rep2/post.php @@ -415,7 +415,11 @@ function postIt($host, $bbs, $key, $post) $req = P2Commun::createHTTPRequest ($bbs_cgi_url,HTTP_Request2::METHOD_POST); // ヘッダ - $req->setHeader('Referer', "http://{$host}/{$bbs}/{$key}/"); + if (P2HostMgr::isHost2chs($host) && ! P2HostMgr::isHostBbsPink($host) && $_conf['2ch_ssl.post']) { + $req->setHeader('Referer', "https://{$host}/{$bbs}/{$key}/"); + } else { + $req->setHeader('Referer', "http://{$host}/{$bbs}/{$key}/"); + } // クッキー if ($p2cookies) { From 20654a426c599b02dcb2de49c68af296111f96bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 12:32:33 +0900 Subject: [PATCH 21/36] =?UTF-8?q?README=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 56 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c5d93a93e..3594f1fad 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,19 @@ 迢ャ閾ェ縺ョ謾ケ濶ッ繧り。後▲縺ヲ縺縺セ縺吶 -* [繧ケ繧ッ繝ェ繝シ繝ウ繧キ繝ァ繝繝](https://open774.github.io/p2-php/screenshots.html) -* [Wiki](https://github.com/open774/p2-php/wiki) -* **[FAQ](https://github.com/open774/p2-php/wiki/FAQ) 繧ケ繝ャ縺ォ譖ク縺丞燕縺ォ縺九i縺ェ繧峨★遒コ隱** +- [繧ケ繧ッ繝ェ繝シ繝ウ繧キ繝ァ繝繝](https://open774.github.io/p2-php/screenshots.html) +- [Wiki](https://github.com/open774/p2-php/wiki) +- [p2Wiki](http://akid.s17.xrea.com/p2puki/index.phtml) +- **[FAQ](https://github.com/open774/p2-php/wiki/FAQ) 繧ケ繝ャ縺ォ譖ク縺丞燕縺ォ縺九i縺ェ繧峨★遒コ隱** ### 荳サ縺ェ霑ス蜉讖溯ス 蜷讖溯ス縺ョ隱ャ譏弱ッdoc繝繧」繝ャ繧ッ繝医Μ縺ョREADME繝輔ぃ繧、繝ォ繧定ヲ九※縺上□縺輔>縲 * cron縺ィ縺九〒譛霑題ェュ繧薙□繧ケ繝ャ縺ェ縺ゥ縺ョdat繧奪L蜃コ譚・繧九せ繧ッ繝ェ繝励ヨ霑ス蜉 -
     php scripts/fetch-dat.php --mode 繝「繝シ繝峨r荳縺、謖螳(fav recent res_hist)
    +```shell +php scripts/fetch-dat.php --mode 繝「繝シ繝峨r荳縺、謖螳(fav recent res_hist) +``` * 蜷咲┌縺励′遽遨エ縺ォ縺ェ繧区攸縺ォ蜷咲┌縺励〒譖ク縺崎セシ繧縺ィ縺阪↓隴ヲ蜻翫r蜃コ縺呎ゥ溯ス繧定ソス蜉 * NG縺ゅ⊂繝シ繧薙ョ蟇セ雎。縺ォ縺ェ縺」縺溘Ξ繧ケ縺ョID繧定ェ蜍慕噪縺ォNG縺ゅ⊂繝シ繧薙☆繧区ゥ溯ス繧定ソス蜉 * 縲瑚ィュ螳夂ョ。逅縲阪°繧峨く繝」繝繧キ繝・繝サ螻・豁エ縺ョ豸亥悉縺ァ縺阪k讖溯ス繧定ソス蜉 @@ -33,19 +36,31 @@ ### Git & Composer縺ァ 1. 譛ャ菴薙rclone -
    git clone git://github.com/open774/p2-php.git
    -  cd p2-php
    + +```shell +git clone git://github.com/open774/p2-php.git +cd p2-php +``` 2. 萓晏ュ倥Λ繧、繝悶Λ繝ェ繧偵ム繧ヲ繝ウ繝ュ繝シ繝 -
    curl -O http://getcomposer.org/composer.phar
    -  php -d detect_unicode=0 composer.phar install
    + +笞ク **PEAR繧オ繝昴シ繝医′蟒豁「縺輔l縺櫃omposer 2.x縺ァ縺ッ蜍穂ス懊@縺セ縺帙s** 笞ク + +```shell +curl -O https://getcomposer.org/download/1.10.19/composer.phar +php -d detect_unicode=0 composer.phar install +``` 3. Web繧オ繝シ繝舌′譖ク縺崎セシ繧√k繧医≧縺ォ繝繧」繝ャ繧ッ繝医Μ縺ョ繧「繧ッ繧サ繧ケ讓ゥ繧偵そ繝繝 - (CGI/suEXECI繧ГLI/Built-in web server縺ァ縺ッ荳崎ヲ) -
    chmod 0777 data/* rep2/ic
    +(CGI/suEXECI繧ГLI/Built-in web server縺ァ縺ッ荳崎ヲ) + +```shell +chmod 0777 data/* rep2/ic +``` ## 蜍穂ス懃腸蠅 + Linux(openSUSE Leap)縺ョPHP7+Apache縺ァ蜍穂ス懃「コ隱阪@縺ヲ縺縺セ縺吶 PHP5.6莉・髯阪〒蜍輔¥縺ッ縺壹〒縺吶′縲 ̄HP7.*謗ィ螂ィ縺ァ縺吶 PHP7縺ァ縺ョ荳榊キ蜷井ソョ豁」繧貞━蜈医☆繧九◆繧∫ェ∫┯PHP5.x縺ョ繧オ繝昴シ繝医′邨ゅo繧句庄閭ス諤ァ縺後≠繧翫∪縺吶 @@ -54,26 +69,28 @@ PHP7縺ァ縺ョ荳榊キ蜷井ソョ豁」繧貞━蜈医☆繧九◆繧∫ェ∫┯PHP5.x縺ョ繧オ繝昴シ繝医′邨 菴輔°繧ィ繝ゥ繝シ縺悟コ縺溘i縺後s縺ー縺」縺ヲ迺ー蠅繧呈紛縺医※縺上□縺輔>縲 - php scripts/p2cmd.php check - +```shell +php scripts/p2cmd.php check +``` ## Built-in web server縺ァ菴ソ縺」縺ヲ縺ソ繧 (PHP 5.4+) -PHP 5.4縺ョ譁ー讖溯ス縲ー繝薙Ν繝医う繝ウ繧ヲ繧ァ繝悶し繝シ繝舌シ](http://docs.php.net/manual/ja/features.commandline.webserver.php)縺ァ邁。蜊倥↓隧ヲ縺帙∪縺吶 +PHP 5.4縺ョ譁ー讖溯ス縲ー繝薙Ν繝医う繝ウ繧ヲ繧ァ繝悶し繝シ繝舌シ](http://docs.php.net/manual/ja/features.commandline.webserver.php) 縺ァ邁。蜊倥↓隧ヲ縺帙∪縺吶 莉・荳九ョ繧医≧縺ォ縺吶k縺ィ縲仝eb繧オ繝シ繝舌シ縺ョ險ュ螳壹r縺励↑縺上※繧 `http://localhost:8080/` 縺ァrep2繧剃スソ縺医∪縺吶**(Windows縺ァ繧!)** - cd rep2 - php -S localhost:8080 web.php +```shell +cd rep2 +php -S localhost:8080 web.php +``` moriyoshi++ - ## 逕サ蜒上r閾ェ蜍輔〒菫晏ュ倥@縺溘> 繧ケ繝ャ縺ォ雋シ繧峨l縺ヲ縺繧狗判蜒上r閾ェ蜍輔〒菫晏ュ倥☆繧区ゥ溯ス縲**ImageCache2**縺後≠繧翫∪縺吶 -see also [doc/ImageCache2/README.txt](https://github.com/open774/p2-php/blob/master/doc/ImageCache2/README.txt), [doc/ImageCache2/INSTALL.txt](https://github.com/open774/p2-php/blob/master/doc/ImageCache2/INSTALL.txt) +see also [doc/ImageCache2/README.txt](doc/ImageCache2/README.txt), [doc/ImageCache2/INSTALL.txt](doc/ImageCache2/INSTALL.txt) ### 貅門y @@ -93,7 +110,6 @@ see also [doc/ImageCache2/README.txt](https://github.com/open774/p2-php/blob/mas * PHP 5.4縺ァ縺ッSQLite2縺後し繝昴シ繝医&繧後↑縺上↑縺」縺溘ョ縺ァ縲!mageCache2繧剃スソ縺縺溘>縺ィ縺阪ッMySQL縺輝ostgreSQL縺悟ソ隕√〒縺吶 * 繝帙せ繝医↓`localhost`繧呈欠螳壹@縺ヲ謗・邯壹〒縺阪↑縺縺ィ縺阪ッ縲∽サ」繧上j縺ォ`127.0.0.1`縺ォ縺励※縺ソ縺ヲ縺上□縺輔>縲 - ## 險ュ螳壹r螟峨∴縺溘> 邏ー縺九>謖吝虚縺ョ螟画峩縺ッ `繝。繝九Η繝シ > 險ュ螳夂ョ。逅 > 繝ヲ繝シ繧カ繝シ險ュ螳夂キィ髮` 縺九i陦後∴縺セ縺吶 @@ -128,7 +144,6 @@ Web繝悶Λ繧ヲ繧カ縺九i螟画峩縺ァ縺阪↑縺鬆逶ョ縺ッ [conf/conf_admin.inc.php](https php -d detect_unicode=0 composer.phar self-update php -d detect_unicode=0 composer.phar update - ## Authors & Contributors * **aki** *(original)* http://akid.s17.xrea.com/ @@ -142,7 +157,6 @@ Web繝悶Λ繧ヲ繧カ縺九i螟画峩縺ァ縺阪↑縺鬆逶ョ縺ッ [conf/conf_admin.inc.php](https * **dgg712** https://github.com/dgg712/p2-php * **2ch p2/rep2繧ケ繝ャ縺ョ>>1-1000** - ## License -see [LICENSE.txt](https://github.com/rsky/p2-php/blob/master/LICENSE.txt) +see [LICENSE.txt](LICENSE.txt) From 70ab58d74a51b7b7e01262f120d16703fbf7f673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 12:36:54 +0900 Subject: [PATCH 22/36] =?UTF-8?q?IC2=E3=81=AE=E7=94=BB=E5=83=8F=E3=82=AD?= =?UTF-8?q?=E3=83=A3=E3=83=83=E3=82=B7=E3=83=A5=E3=82=92=E9=99=A4=E5=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rep2/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 rep2/.gitignore diff --git a/rep2/.gitignore b/rep2/.gitignore new file mode 100644 index 000000000..49c8f5990 --- /dev/null +++ b/rep2/.gitignore @@ -0,0 +1 @@ +ic From f46047797599182ff52a3189a84bd0212da7b70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Fri, 15 Jan 2021 06:52:51 +0900 Subject: [PATCH 23/36] =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=83=AA=E3=82=B9=E3=83=88=E3=81=AB=E7=99=BB=E9=8C=B2=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=81=AA=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/expack/ImageCache2/DatabaseManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/expack/ImageCache2/DatabaseManager.php b/lib/expack/ImageCache2/DatabaseManager.php index a615ec0f7..4bc2f48f7 100644 --- a/lib/expack/ImageCache2/DatabaseManager.php +++ b/lib/expack/ImageCache2/DatabaseManager.php @@ -147,6 +147,8 @@ static public function remove($target, $to_blacklist = false) if ($to_blacklist) { $blacklist = new ImageCache2_DataObject_BlackList(); $blacklist->uri = $remover->uri; + $blacklist->size = $remover->size; + $blacklist->md5 = $remover->md5; $blacklist->insert(); } // テーブルから抹消 From 8bcd4fdc4e7399621424e421bdd448fb04e452c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Fri, 15 Jan 2021 13:13:55 +0900 Subject: [PATCH 24/36] =?UTF-8?q?SQLite=E3=81=A7=E7=94=BB=E5=83=8F?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rep2/ic2_manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rep2/ic2_manager.php b/rep2/ic2_manager.php index 2a1a6f959..727310b2f 100644 --- a/rep2/ic2_manager.php +++ b/rep2/ic2_manager.php @@ -55,7 +55,7 @@ case 'dropAborn': if ($_POST['action'] == 'dropZero') { // ランク=0 の画像を削除する - $where = $db->quote('rank') . ' = 0'; + $where = $icdc->quoteIdentifier('rank') . ' = 0'; if (isset($_POST['dropZeroLimit'])) { // 取得した期間を限定 switch ($_POST['dropZeroSelectTime']) { From 13fced392c63584116fecc7dd3efee3bb367c1ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Mon, 11 Jan 2021 12:33:13 +0900 Subject: [PATCH 25/36] Bump version to 200101.0000 --- conf/conf.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/conf.inc.php b/conf/conf.inc.php index 9dd7d3874..82e0524ba 100644 --- a/conf/conf.inc.php +++ b/conf/conf.inc.php @@ -7,7 +7,7 @@ // バージョン情報 $_conf = array( 'p2name' => 'rep2-expack_allinone', // rep2の名前 - 'p2version' => '180705.1300', // rep2のバージョン + 'p2version' => '200101.0000', // rep2のバージョン ); $_conf['p2ua'] = "{$_conf['p2name']}/{$_conf['p2version']}"; From 7a75743925f89e64ada6e4d1a0720d0954896dc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Tue, 6 Apr 2021 03:56:13 +0900 Subject: [PATCH 26/36] update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3594f1fad..8bdd28c2d 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ -サソ# rep2 expack 蜈ィ驛ィ蜈・繧 by open774 +サソ# rep2 expack 蜈ィ驛ィ蜈・繧 by シ按エ繝サマ峨サシ スス * rep2-expack https://github.com/rsky/p2-php * rep2-expack +live https://github.com/pluslive/p2-php * rep2-expack test https://github.com/orzisun/p2-php +* rep2-expack https://github.com/open774/p2-php +* rep2-expack https://github.com/junk2ool/p2-php 荳願ィ倥d繧ケ繝ャ縺ォ荳翫£繧峨l縺滉ソョ豁」繧貞叙繧願セシ繧薙〒蜈ィ驛ィ蜈・繧翫r逶ョ謖縺咎裸骰九ヰ繝シ繧ク繝ァ繝ウ縺ァ縺吶 -迢ャ閾ェ縺ョ謾ケ濶ッ繧り。後▲縺ヲ縺縺セ縺吶 +縺薙ョ繝ェ繝昴ず繝医Μ縺ォ縺ッrep2繧単HP 8.x縺ァ蜍輔°縺吶◆繧√ョ繝代ャ繝√′蜷ォ縺セ繧後※縺縺セ縺吶 - [繧ケ繧ッ繝ェ繝シ繝ウ繧キ繝ァ繝繝](https://open774.github.io/p2-php/screenshots.html) - [Wiki](https://github.com/open774/p2-php/wiki) From 0bcffbd82a290a3e9d5e3628a3714e2b35ff39cc Mon Sep 17 00:00:00 2001 From: junk2ool Date: Tue, 2 Mar 2021 22:48:55 +0900 Subject: [PATCH 27/36] =?UTF-8?q?=E3=82=B5=E3=83=AD=E3=82=B2=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=9A=E3=82=A2=E3=81=AE=E6=95=B0=E5=80=A4=E6=96=87?= =?UTF-8?q?=E5=AD=97=E5=8F=82=E7=85=A7=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=82=8B=E7=B5=B5=E6=96=87=E5=AD=97=E3=81=8C=E6=96=87?= =?UTF-8?q?=E5=AD=97=E5=8C=96=E3=81=91=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/P2Util.php | 25 +++++++++++++++++++++++++ lib/ShowThreadI.php | 3 +++ lib/ShowThreadK.php | 3 +++ lib/ShowThreadPc.php | 3 +++ lib/Thread.php | 2 ++ lib/ThreadList.php | 2 ++ 6 files changed, 38 insertions(+) diff --git a/lib/P2Util.php b/lib/P2Util.php index 60a53fedd..da5b94ae6 100644 --- a/lib/P2Util.php +++ b/lib/P2Util.php @@ -1979,6 +1979,31 @@ function checkRoninExpiration() return true; } + // }}} + // {{{ replaceNumericalSurrogatePair() + + /** + * 文字列内にサロゲートペアの数値文字参照があれば結合した数値文字参照に置き換える + * + * @access public + * @param string $str + * @return string + */ + static public function replaceNumericalSurrogatePair($str) + { + // 55296-56319 と 56320-57343 の範囲の組み合わせなので xxxx;xxxx; で絞って探す + return preg_replace_callback('/&#(5[5-6]\\d{3});&#(5[6-7]\\d{3});/', + function ($matches) { + // サロゲートペアの範囲なら合成した数値文字参照にして置き換え + if ($matches[1] >= 0xD800 && $matches[1] <= 0xDBFF && $matches[2] >= 0xDC00 && $matches[2] <= 0xDFFF) { + return sprintf("&#%d;", (($matches[1] & 0x3FF) << 10) + ($matches[2] & 0x3FF) + 0x10000); + } + // 範囲外はそのまま + return $matches[0]; + }, + $str); + } + // }}} // {{{ debug() /* diff --git a/lib/ShowThreadI.php b/lib/ShowThreadI.php index e6e525196..40670e5f4 100644 --- a/lib/ShowThreadI.php +++ b/lib/ShowThreadI.php @@ -445,6 +445,9 @@ public function transMsg($msg, $mynum) $msg = preg_replace('/&(?=[^;])/', '&', $msg); } + // サロゲートペアの数値文字参照を変換 + $msg = P2Util::replaceNumericalSurrogatePair($msg); + // &補正 $msg = preg_replace('/&(?!#?\\w+;)/', '&', $msg); diff --git a/lib/ShowThreadK.php b/lib/ShowThreadK.php index 8ee0d726b..f9da4760a 100644 --- a/lib/ShowThreadK.php +++ b/lib/ShowThreadK.php @@ -439,6 +439,9 @@ public function transMsg($msg, $mynum) $msg = preg_replace('/&(?=[^;])/', '&', $msg); } + // サロゲートペアの数値文字参照を変換 + $msg = P2Util::replaceNumericalSurrogatePair($msg); + // &補正 $msg = preg_replace('/&(?!#?\\w+;)/', '&', $msg); diff --git a/lib/ShowThreadPc.php b/lib/ShowThreadPc.php index 5126a9018..b65395283 100644 --- a/lib/ShowThreadPc.php +++ b/lib/ShowThreadPc.php @@ -530,6 +530,9 @@ public function transMsg($msg, $mynum) $msg = preg_replace('/&(?=[^;])/', '&', $msg); } + // サロゲートペアの数値文字参照を変換 + $msg = P2Util::replaceNumericalSurrogatePair($msg); + // &補正 $msg = preg_replace('/&(?!#?\\w+;)/', '&', $msg); diff --git a/lib/Thread.php b/lib/Thread.php index 41f030b94..e2f3a36b8 100644 --- a/lib/Thread.php +++ b/lib/Thread.php @@ -202,6 +202,8 @@ public function getTtitleHd() $this->_ttitle_hd = p2h($this->ttitle, false); // [隔離病棟]などをデコード $this->_ttitle_hd = str_replace('</mark>', '', str_replace('<mark>', '', $this->_ttitle_hd)); + // サロゲートペアの数値文字参照を変換 + $this->_ttitle_hd = P2Util::replaceNumericalSurrogatePair($this->_ttitle_hd); } return $this->_ttitle_hd; } diff --git a/lib/ThreadList.php b/lib/ThreadList.php index dd211a092..fcf7c6ade 100644 --- a/lib/ThreadList.php +++ b/lib/ThreadList.php @@ -288,6 +288,8 @@ public function readList() $threads[$matches[2]]['key'] = $matches[1]; // スレッドID $threads[$matches[2]]['title'] = $matches[3]; // title + // サロゲートペアの数値文字参照を変換 + $threads[$matches[2]]['title'] = P2Util::replaceNumericalSurrogatePair($threads[$matches[2]]['title']); $threads[$matches[2]]['rc'] = $matches[4]; // rescount $threads[$matches[2]]['param'] = implode('<>',array_fill(0, 5, '')); // lastmodify.txt に含まれないスレを表示できるように From df12603bd2ac57e42274a9643668b279e80c747d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Tue, 6 Apr 2021 04:02:45 +0900 Subject: [PATCH 28/36] =?UTF-8?q?IC2:=20UNIX=20domain=20socket=E3=81=AE?= =?UTF-8?q?=E5=85=B7=E4=BD=93=E4=BE=8B=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf_ic2.inc.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/conf_ic2.inc.php b/conf/conf_ic2.inc.php index 16ac46894..3d1a8d4f0 100644 --- a/conf/conf_ic2.inc.php +++ b/conf/conf_ic2.inc.php @@ -12,9 +12,10 @@ // DSN (DBに接続するためのデータソース名) // @link https://roojs.github.io/PDO_DataObject/docs/index.html#config // 例) -// MySQL: 'mysql://username:password@localhost:3306/database?charset=utf8' -// PostgreSQL: 'pgsql://username:password@localhost:5432/database' -// SQLite: 'sqlite:/' . $_conf['db_dir'] . '/imgcache.sqlite' +// MySQL: 'mysql://username:password@localhost:3306/database?charset=utf8' +// MySQL (via UNIX domain socket): 'mysql://username:password@localhost/database?charset=utf8;unix_socket=/run/mysqld/mysqld.sock' +// PostgreSQL: 'pgsql://username:password@localhost:5432/database' +// SQLite: 'sqlite:/' . $_conf['db_dir'] . '/imgcache.sqlite' // 注1: username,password,databaseは実際のものと読み替える。 // 注2: MySQL,PosrgreSQLでは予めデータベースを作っておく。 $_conf['expack.ic2.general.dsn'] = ""; From 61c4eac7edb3ebbb551c51c7568ee5ee59e1600d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Tue, 4 May 2021 16:52:13 +0900 Subject: [PATCH 29/36] =?UTF-8?q?IC2:=20PHP=208.0.5=E3=81=A7=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/wiki/ReplaceImageUrlCtl.php | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/wiki/ReplaceImageUrlCtl.php b/lib/wiki/ReplaceImageUrlCtl.php index f4a762610..a7b83516d 100644 --- a/lib/wiki/ReplaceImageUrlCtl.php +++ b/lib/wiki/ReplaceImageUrlCtl.php @@ -38,7 +38,6 @@ public function load() { global $_conf; - $lines = array(); $path = $_conf['pref_dir'].'/'.$this->filename; if ($lines = @file($path)) { foreach ($lines as $l) { @@ -52,17 +51,13 @@ public function load() continue; } $ar = array( - 'match' => $lar[0], // 対象文字列 + 'match' => $lar[0], // 対象文字列 'replace' => $lar[1], // 置換文字列 - 'referer' => $lar[2], // リファラ - 'extract' => $lar[3], // EXTRACT - 'source' => $lar[4], // EXTRACT正規表現 - 'recheck' => $lar[5], // EXTRACTしたページを次回もチェックしたいか - 'ident' => $lar[6], // 置換結果の画像URLに対する正規 - // 表現。指定されている場合はこれ - // でマッチした文字列で前回キャッ - // シュと比較し、同一であれば同じ - // 画像と見做す + 'referer' => count($lar) > 2 ? $lar[2] : '', // リファラ + 'extract' => count($lar) > 3 ? $lar[3] : '', // EXTRACT + 'source' => count($lar) > 4 ? $lar[4] : '', // EXTRACT正規表現 + 'recheck' => count($lar) > 5 ? $lar[5] : '', // EXTRACTしたページを次回もチェックしたいか + 'ident' => count($lar) > 6 ? $lar[6] : '', // 置換結果の画像URLに対する正規表現。指定されている場合はこれでマッチした文字列で前回キャッシュと比較し、同一であれば同じ画像と見做す ); $this->data[] = $ar; @@ -180,7 +175,7 @@ public function replaceImageUrl($url) return $this->onlineCache[$url]; } - if ($this->cacheData[$url]) { + if (array_key_exists($url, $this->cacheData)) { if ($_conf['wiki.replaceimageurl.extract_cache'] == 1) { // キャッシュがあればそれを返す return $this->_reply($url, $this->cacheData[$url]['data']); @@ -225,7 +220,7 @@ public function replaceImageUrl($url) } /* plugin_imageCache2で処理させるためコメントアウト ← plugin_imageCache2を削除する為復活 by 2ch774*/ // ヒットしなかった場合 - if (!$return[0]) { + if (count($return) === 0) { // 画像っぽいURLの場合 if (preg_match('{^https?://.+?\\.(jpe?g|gif|png)$}i', $url)) { $return[0]['url'] = $url; From a43ddca480848e5c8ebf1fa2f4025083023cabcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=88=C2=B4=E3=83=BB=CF=89=E3=83=BB=EF=BC=89=20?= =?UTF-8?q?=EF=BD=BD?= Date: Tue, 4 May 2021 16:54:27 +0900 Subject: [PATCH 30/36] =?UTF-8?q?=E6=9C=AA=E5=AE=9A=E7=BE=A9=E5=A4=89?= =?UTF-8?q?=E6=95=B0=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/conf_user_def.inc.php | 3 +++ lib/ResFilter.php | 14 +++++--------- lib/ShowThread.php | 8 ++++---- lib/ShowThreadPc.php | 4 ++-- lib/color/coloredIdStyle0.inc.php | 17 ++++++----------- lib/expack/tgrep/view.inc.php | 8 ++++---- lib/live/default_view.inc.php | 2 +- lib/live/live_header.inc.php | 2 +- lib/live/live_post_form.inc.php | 5 +++++ lib/live/live_view.inc.php | 4 ++-- lib/live/live_view_ctl.inc.php | 10 +++++----- lib/menu.inc.php | 2 +- lib/post_form.inc.php | 2 ++ lib/post_form_options.inc.php | 5 +++-- lib/read_footer.inc.php | 5 +++-- lib/read_header.inc.php | 7 ++++--- lib/wiki/ReplaceWordCtl.php | 4 +--- rep2/edit_conf_user.php | 1 + rep2/live_control.php | 2 +- rep2/live_frame.php | 4 ++-- rep2/live_post_form.php | 2 +- rep2/read.php | 12 ++++++------ 22 files changed, 63 insertions(+), 60 deletions(-) diff --git a/conf/conf_user_def.inc.php b/conf/conf_user_def.inc.php index 8d3469754..e73c4fdb1 100644 --- a/conf/conf_user_def.inc.php +++ b/conf/conf_user_def.inc.php @@ -317,6 +317,9 @@ // IDに色を付ける $conf_user_def['coloredid.enable'] = 1; $conf_user_rad['coloredid.enable'] = array('1' => 'する', '0' => 'しない'); +// 色の変換結果を表示 +$conf_user_def['coloredid.debug'] = 0; +$conf_user_rad['coloredid.debug'] = array('1' => 'する', '0' => 'しない'); // 画面表示時にIDに着色しておく条件 $conf_user_def['coloredid.rate.type'] = 3; $conf_user_rad['coloredid.rate.type'] = array('0' => 'しない', '1' => '出現数', '2' => 'スレ内トップ10', '3' => 'スレ内平均以上'); diff --git a/lib/ResFilter.php b/lib/ResFilter.php index e63083226..685fee208 100644 --- a/lib/ResFilter.php +++ b/lib/ResFilter.php @@ -165,15 +165,11 @@ static public function getWord($callback = null, array $params = array()) */ static public function configure(array $params) { - $level = error_reporting(E_ALL & ~E_NOTICE); - - $word = $params['word']; - $field = $params['field']; - $method = $params['method']; - $match = $params['match']; - $include = $params['include']; - - error_reporting($level); + $word = array_key_exists('word', $params) ? $params['word'] : ''; + $field = array_key_exists('word', $params) ? $params['word'] : ''; + $method = array_key_exists('method', $params) ? $params['method'] : ''; + $match = array_key_exists('match', $params) ? $params['match'] : ''; + $include = array_key_exists('include', $params) ? $params['include'] : ''; self::$_instance = new ResFilter($word, $field, $method, $match, $include); diff --git a/lib/ShowThread.php b/lib/ShowThread.php index b0aeea268..1cb91b36d 100644 --- a/lib/ShowThread.php +++ b/lib/ShowThread.php @@ -1119,7 +1119,7 @@ public function transLink($str) */ public function transLinkDo(array $s) { - if ($s['url']) { + if (array_key_exists('url', $_GET) && $s['url']) { // sha1で囲んだ方が多少速くなるが低確率で衝突する $key = sha1(serialize($s)); // キャッシュしてない場合 @@ -1180,8 +1180,8 @@ private function _transLinkDo(array $s) } $url = preg_replace('/^t?(tps?)$/', 'ht$1', $s[9]) . '://' . $s[10]; $str = $s['url']; - $following = $s[11]; - if (strlen($following) > 0) { + $following = array_key_exists(11, $s) ? $s[11] : ''; + if ($following !== '') { // ウィキペディア日本語版のURLで、SJISの2バイト文字の上位バイト // (0x81-0x9F,0xE0-0xEF)が続くとき if (P2HostMgr::isUrlWikipediaJa($url)) { @@ -1653,7 +1653,7 @@ protected function _makeQuotes() // NGあぼーんチェック if (($id = $this->thread->ids[$num + 1]) !== null) { - $date_id = str_replace($this->thread->idp[$num] . $id, 'ID:' . $id, $date_id); + $date_id = str_replace($this->thread->idp[$num + 1] . $id, 'ID:' . $id, $date_id); } $ng_type = $this->_ngAbornCheck($num + 1, strip_tags($name), $mail, $date_id, $id, $msg); if ($ng_type == self::ABORN) { diff --git a/lib/ShowThreadPc.php b/lib/ShowThreadPc.php index b65395283..11558b4bb 100644 --- a/lib/ShowThreadPc.php +++ b/lib/ShowThreadPc.php @@ -48,7 +48,7 @@ public function __construct($aThread, $matome = false) ); // +live (live.bbs_noname) 用 - if ($_GET['live']) { + if (array_key_exists('live', $_GET) && $_GET['live']) { if (empty($_conf['live.bbs_noname'])) { require_once P2_LIB_DIR . '/SettingTxt.php'; $st = new SettingTxt($this->thread->host, $this->thread->bbs); @@ -1379,7 +1379,7 @@ public function plugin_replaceImageUrl($url, $purl, $str) $url = $purl[0]; $replaced = $replaceImageUrlCtl->replaceImageUrl($url); - if (!$replaced[0]) { + if (count($replaced) === 0) { return false; } diff --git a/lib/color/coloredIdStyle0.inc.php b/lib/color/coloredIdStyle0.inc.php index f2b007ed6..01a90b00f 100644 --- a/lib/color/coloredIdStyle0.inc.php +++ b/lib/color/coloredIdStyle0.inc.php @@ -109,13 +109,11 @@ function coloredIdStyle0($id, $count) } // CSSで色をつける - $idstr2=preg_split('/:/',$idstr,2); // コロンでID文字列を分割 - $idstr2[0].=':'; $uline=$STYLE['a_underline_none']==1 ? '' : "text-decoration:underline;"; $bcolor=array(); $LCh=array(); for ($i=0;$i60) {$bcolor[$i].="color:#000;";} else //if ($LCh[$i][0]<40) @@ -137,8 +134,7 @@ function coloredIdStyle0($id, $count) $uline.="text-decoration:blink;"; } - // $colorprint=1; // 1にすると、色の変換結果が表示される - if ($colorprint) { + if ($_conf['coloredid.debug']) { $debug = ''; for ($i=0;$i<1;$i++) { switch ($rgb[$i]['type']) { @@ -167,15 +163,14 @@ function coloredIdStyle0($id, $count) if ($B>255 || $B<0) {$B="{$B}";} $debug.= ",(R={$R},G={$G},B={$B}),{$rgb[$i]['color']}"; } - // $idstr2[1].= join(",",$rgb[0]); return array( - (isset($rgb[1]) ? "{$bcolor[1]}{$border}{$uline}" : ''), - "{$bcolor[0]}{$border}{$uline}", + (isset($rgb[1]) ? "{$bcolor[1]}{$uline}" : ''), + "{$bcolor[0]}{$uline}", $debug); } else { return array( - (isset($rgb[1]) ? "{$bcolor[1]}{$border}{$uline}" : ''), - "{$bcolor[0]}{$border}{$uline}"); + (isset($rgb[1]) ? "{$bcolor[1]}{$uline}" : ''), + "{$bcolor[0]}{$uline}"); } } diff --git a/lib/expack/tgrep/view.inc.php b/lib/expack/tgrep/view.inc.php index 1a3081950..5d8fda620 100644 --- a/lib/expack/tgrep/view.inc.php +++ b/lib/expack/tgrep/view.inc.php @@ -67,10 +67,10 @@ function moveSubject(href, serachWord, query) {
    /> - - - - + + + +
    diff --git a/lib/live/default_view.inc.php b/lib/live/default_view.inc.php index b102be925..35dda5770 100755 --- a/lib/live/default_view.inc.php +++ b/lib/live/default_view.inc.php @@ -27,7 +27,7 @@ } // レスボタン -if ($_GET['live']) { +if (array_key_exists('live', $_GET) && $_GET['live']) { $tores .= "$res_button"; } diff --git a/lib/live/live_header.inc.php b/lib/live/live_header.inc.php index 7da5bcf21..9c5545e32 100755 --- a/lib/live/live_header.inc.php +++ b/lib/live/live_header.inc.php @@ -20,7 +20,7 @@ } //} -if ($_GET['live']) { +if (array_key_exists('live', $_GET) && $_GET['live']) { echo <<