/** * フォームから送られてきたワードをマッチ関数に適合させる * * @static * @access public * @return string $word_fm 適合パターン。SJISで返す。 */ function wordForMatch($word, $method = 'regex') { $word_fm = $word; // 「そのまま」でなければ、全角空白を半角空白に矯正 if ($method != 'just') { $word_fm = mb_convert_kana($word_fm, 's'); } $word_fm = trim($word_fm); $word_fm = htmlspecialchars($word_fm, ENT_NOQUOTES); if (in_array($method, array('and', 'or', 'just'))) { // preg_quote()で2バイト目が0x5B("[")の"ー"なども変換されてしまうので // UTF-8にしてから正規表現の特殊文字をエスケープ $word_fm = mb_convert_encoding($word_fm, 'UTF-8', 'SJIS-win'); if (P2_MBREGEX_AVAILABLE == 1) { $word_fm = preg_quote($word_fm); } else { $word_fm = preg_quote($word_fm, '/'); } $word_fm = mb_convert_encoding($word_fm, 'SJIS-win', 'UTF-8'); // 他、regex(正規表現)なら } else { $word_fm = str_replace('/', '\\/', $word_fm); $tmp_pattern = '/' . mb_convert_encoding($word_fm, 'UTF-8', 'SJIS-win') . '/u'; if (false === @preg_match($tmp_pattern, '.')) { P2Util::pushInfoHtml(sprintf('p2 warning: フィルタ語句の正規表\現に誤りがあります "%s"', hs($word_fm))); $word_fm = ''; } if (P2_MBREGEX_AVAILABLE == 0) { $word_fm = str_replace('/', '\\/', $word_fm); } // 末尾のワイルドカードは除去してしまう $word_fm = rtrim($word_fm, '.+*'); } return $word_fm; }
/** * チェックした書き込み記事を削除する * * @access public * @return boolean */ function deleMsg($checked_hists) { global $_conf; if (!($reslines = file($_conf['p2_res_hist_dat']))) { p2die(sprintf('%s を開けませんでした', $_conf['p2_res_hist_dat'])); return false; } $reslines = array_map('rtrim', $reslines); // ファイルの下に記録されているものが新しいので逆順にする $reslines = array_reverse($reslines); $neolines = array(); // チェックして整えて if ($reslines) { $rmnums = _getRmNums($checked_hists, $reslines); $neolines = _rmLine($rmnums, $reslines); P2Util::pushInfoHtml("<p>p2 info: " . count($rmnums) . "件のレス記事を削除しました</p>"); } if (is_array($neolines)) { // 行順を戻す $neolines = array_reverse($neolines); $cont = ""; if ($neolines) { $cont = implode("\n", $neolines) . "\n"; } // 書き込み処理 if (false === FileCtl::filePutRename($_conf['p2_res_hist_dat'], $cont)) { $errmsg = sprintf('p2 error: %s(), FileCtl::filePutRename() failed.', __FUNCTION__); trigger_error($errmsg, E_USER_WARNING); return false; } } return true; }
/** * subject.txtの並列ダウンロードを実行する * * @param string $mode * @param array $_conf * @return bool */ public static function fetchSubjectTxt($mode, array $_conf) { // コマンド生成 $args = array(escapeshellarg($_conf['expack.php_cli_path'])); if ($_conf['expack.dl_pecl_http']) { $args[] = '-d'; $args[] = 'extension=' . escapeshellarg('http.' . PHP_SHLIB_SUFFIX); } $args[] = escapeshellarg(P2_CLI_DIR . DIRECTORY_SEPARATOR . 'fetch-subject-txt.php'); switch ($mode) { case 'fav': case 'recent': case 'res_hist': case 'merge_favita': $args[] = sprintf('--mode=%s', $mode); break; default: return false; } if ($_conf['expack.misc.multi_favs']) { switch ($mode) { case 'fav': $args[] = sprintf('--set=%d', $_conf['m_favlist_set']); break; case 'merge_favita': $args[] = sprintf('--set=%d', $_conf['m_favita_set']); break; } } // 標準エラー出力を標準出力にリダイレクト $args[] = '2>&1'; $command = implode(' ', $args); //P2Util::pushInfoHtml('<p>' . htmlspecialchars($command, ENT_QUOTES) . '</p>'); // 実行 $pipe = popen($command, 'r'); if (!is_resource($pipe)) { p2die('コマンドを実行できませんでした。', $command); } $output = ''; while (!feof($pipe)) { $output .= fgets($pipe); } $status = pclose($pipe); if ($status != 0) { P2Util::pushInfoHtml(sprintf('<p>%s(): ERROR(%d)</p>', __METHOD__, $status)); } if ($output !== '') { if ($status == 2) { P2Util::pushInfoHtml($output); } else { P2Util::pushInfoHtml('<p>' . nl2br(htmlspecialchars($output, ENT_QUOTES)) . '</p>'); } } return $status == 0; }
function _read_filter_setup() { $host = $_GET['host']; $bbs = $_GET['bbs']; $key = $_GET['key']; $resnum = (int) $_GET['resnum']; $field = $_GET['field']; $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); $aThread->readDat($aThread->keydat); $i = $resnum - 1; if (!($i >= 0 && $i < count($aThread->datlines) && isset($_GET['rf']) && is_array($_GET['rf']))) { P2Util::pushInfoHtml('<p>フィルタリングの指定が変です。</p>'); unset($_GET['rf'], $_REQUEST['rf']); return; } $ares = $aThread->datlines[$i]; $resar = $aThread->explodeDatLine($ares); $name = $resar[0]; $mail = $resar[1]; $date_id = $resar[2]; $msg = $resar[3]; $params = $_GET['rf']; $include = ResFilter::INCLUDE_NONE; $fields = explode(':', $field); $field = array_shift($fields); if (in_array('refs', $fields)) { $include |= ResFilter::INCLUDE_REFERENCES; } if (in_array('refed', $fields)) { $include |= ResFilter::INCLUDE_REFERENCED; } $params['field'] = $field; $params['include'] = $include; $resFilter = ResFilter::configure($params); $target = $resFilter->getTarget($ares, $resnum, $name, $mail, $date_id, $msg); if ($field == 'date') { $date_part = explode(' ', trim($target)); $word = $date_part[0]; } else { $word = $target; } $params['word'] = $word; $_REQUEST['rf'] = $params; }
/** * チェックした書き込み記事を削除する */ function deleMsg($checked_hists) { global $_conf; $lock = new P2Lock($_conf['res_hist_dat'], false); // 読み込んで $reslines = FileCtl::file_read_lines($_conf['res_hist_dat'], FILE_IGNORE_NEW_LINES); if ($reslines === false) { p2die("{$_conf['res_hist_dat']} を開けませんでした"); } // ファイルの下に記録されているものが新しいので逆順にする $reslines = array_reverse($reslines); $neolines = array(); // チェックして整えて if ($reslines) { $n = 1; foreach ($reslines as $ares) { $rar = explode("<>", $ares); // 番号と日付が一致するかをチェックする if (checkMsgID($checked_hists, $n, $rar[2])) { $rmnums[] = $n; // 削除する番号を登録 } $n++; } $neolines = rmLine($rmnums, $reslines); P2Util::pushInfoHtml('<p>p2 info: ' . count($rmnums) . '件のレス記事を削除しました</p>'); } if (is_array($neolines)) { // 行順を戻す $neolines = array_reverse($neolines); $cont = ""; if ($neolines) { $cont = implode("\n", $neolines) . "\n"; } // 書き込む if (FileCtl::file_write_contents($_conf['res_hist_dat'], $cont) === false) { p2die('cannot write file.'); } } }
/** * brdファイルを生成する * * @access public * @return string|false 成功したら生成したbrdファイルのパスを返す */ function makeBrdFile($cachefile) { global $_conf; $cont = ''; $data = file($cachefile); $this->setBrdMatch($cachefile); // パターンマッチ形式を登録 $this->setBrdList($data); // カテゴリーと板をセット if ($this->categories) { foreach ($this->categories as $cate) { if ($cate->num > 0) { $cont .= $cate->name . "\t0\n"; foreach ($cate->menuitas as $mita) { $cont .= "\t{$mita->host}\t{$mita->bbs}\t{$mita->itaj}\n"; } } } } if (!$cont) { // 2008/07/14 なぜここでこんな条件が必要だったのか不明。コメントアウトしてみる。 //if (strlen($GLOBALS['word']) > 0) { P2Util::pushInfoHtml(sprintf("<p>p2 error: %s から板メニューを生成することはできませんでした。</p>\n", hs($cachefile))); //} unlink($cachefile); return false; } $p2brdfile = BrdCtl::getP2BrdFile($cachefile); if (false === FileCtl::make_datafile($p2brdfile, $_conf['p2_perm'])) { return false; } if (false === FileCtl::filePutRename($p2brdfile, $cont)) { die(sprintf('p2 error: %s を更新できませんでした', hs($p2brdfile))); return false; } return $p2brdfile; }
/** * お気に入りセットリストを更新する * * @return boolean 更新に成功したらTRUE, 失敗したらFALSE */ function updateFavSetList() { global $_conf; if (file_exists($_conf['expack.misc.favset_file'])) { $setlist_titles = FavSetManager::getFavSetTitles(); } else { FileCtl::make_datafile($_conf['expack.misc.favset_file']); } if (empty($setlist_titles)) { $setlist_titles = array(); } $setlist_names = array('m_favlist_set', 'm_favita_set', 'm_rss_set'); foreach ($setlist_names as $setlist_name) { if (isset($_POST["{$setlist_name}_titles"]) && is_array($_POST["{$setlist_name}_titles"])) { $setlist_titles[$setlist_name] = array(); for ($i = 0; $i <= $_conf['expack.misc.favset_num']; $i++) { if (!isset($_POST["{$setlist_name}_titles"][$i])) { $setlist_titles[$setlist_name][$i] = ''; continue; } $newname = trim($_POST["{$setlist_name}_titles"][$i]); $newname = preg_replace('/\\r\\n\\t/', ' ', $newname); $newname = htmlspecialchars($newname, ENT_QUOTES); $setlist_titles[$setlist_name][$i] = $newname; } } } $newdata = serialize($setlist_titles); if (FileCtl::file_write_contents($_conf['expack.misc.favset_file'], $newdata) === FALSE) { P2Util::pushInfoHtml("<p>p2 error: {$_conf['expack.misc.favset_file']} にお気に入りセット設定を書き込めませんでした。"); return FALSE; } return TRUE; }
<?php /** * rep2 - タイトルページ */ require_once __DIR__ . '/../init.php'; $_login->authorize(); // ユーザ認証 //========================================================= // 変数 //========================================================= if (!empty($GLOBALS['pref_dir_realpath_failed_msg'])) { P2Util::pushInfoHtml('<p>' . $GLOBALS['pref_dir_realpath_failed_msg'] . '</p>'); } $p2web_url_r = P2Util::throughIme($_conf['p2web_url']); $expack_url_r = P2Util::throughIme($_conf['expack.web_url']); $expack_dl_url_r = P2Util::throughIme($_conf['expack.download_url']); $expack_hist_url_r = P2Util::throughIme($_conf['expack.history_url']); // {{{ データ保存ディレクトリのパーミッションの注意を喚起する P2Util::checkDirWritable($_conf['dat_dir']); $checked_dirs[] = $_conf['dat_dir']; // チェック済みのディレクトリを格納する配列に // まだチェックしていなければ if (!in_array($_conf['idx_dir'], $checked_dirs)) { P2Util::checkDirWritable($_conf['idx_dir']); $checked_dirs[] = $_conf['idx_dir']; } if (!in_array($_conf['pref_dir'], $checked_dirs)) { P2Util::checkDirWritable($_conf['pref_dir']); $checked_dirs[] = $_conf['pref_dir']; }
$setter->whereAddQuoted('mime', '=', $finder->mime); if ($setter->update()) { $code = 1; } else { $code = 0; } } if ($remove) { $orig_info_msg_ht = P2Util::getInfoHtml(); $removed_files = IC2_DatabaseManager::remove(array($finder->id), $rank < 0); if ($code != 0 && !P2Util::hasInfoHtml()) { $code = 1; } else { $code = 0; } P2Util::pushInfoHtml($orig_info_msg_ht); } } echo $code; exit; // }}} /* * 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:
$id_txt = preg_replace('/^.*ID: ?([0-9A-Za-z\\/.+?]+)([.,]|†)?.*$/', 'ID:$1', $resar[2]); $id_ht = "<input type=\"text\" name=\"id_txt\" value=\"{$id_txt}\"><br>"; } else { $date_txt = $resar[2]; } $msg_txt = trim(strip_tags($resar[3], '<br>')); if ($quote) { $msg_txt = ">>{$resid}\r\n> " . preg_replace('/ *<br[^>]*> */i', "\n> ", $msg_txt); } else { $msg_txt = preg_replace('/ *<br[^>]*> */i', "\n", $msg_txt); } } else { P2Util::pushInfoHtml('<p>p2 error: レス番号の指定が変です。</p>'); } } else { P2Util::pushInfoHtml('<p>p2 error: スレッドの指定が変です。</p>'); } $msg_len = mb_strlen($msg_txt); $len = $GLOBALS['_conf']['mobile.copy_divide_len'] ? $GLOBALS['_conf']['mobile.copy_divide_len'] : 10000; $msg_txts = array(); for ($i = 0; $i < $msg_len; $i += $len) { $msg_txts[] = mb_substr($msg_txt, $i, $len); } //===================================================== // コピー用フォームを表示 //===================================================== $action_ht = htmlspecialchars($_SERVER['SCRIPT_NAME'] . '?host=' . $_GET['host'] . '&bbs=' . $_GET['bbs'] . '&key=' . $_GET['key'] . '©=' . $_GET['copy'], ENT_QUOTES); // willcom はtextareaのサイズが小さいと使いにくいらしい /* JavaScriptにしてしまった方がいいかも? javascript:(function(){for (var j=0;j<document.forms.length;j++){for (var i=0;i<document.forms[j].elements.length;i++) {k=document.forms[j].elements[i];if(k.type=="textarea"){k.rows=10;k.cols=34;}}}})();
} else { P2Util::pushInfoHtml('<p>エラー: URLに連番のプレースホルダ(<samp>%s</samp>)またはパターン(<samp>[from-to]</samp>)が含まれていないか、両方が含まれています。</p>'); $execDL = false; $isError = true; } // 範囲を検証 if (isset($serial) && $serial['from'] >= $serial['to']) { P2Util::pushInfoHtml('<p>エラー: 連番の終りの番号は始まりの番号より大きくないといけません。</p>'); $execDL = false; $isError = true; $serial = null; } // 連番なし } else { if (strpos($params['uri'], '%s') !== false || preg_match($serial_pattern, $params['uri'], $from_to)) { P2Util::pushInfoHtml('<p>エラー: 連番にチェックが入っていませんが、URLに連番ダウンロード用の文字列が含まれています。</p>'); $execDL = false; $isError = true; } $qfe['from']->updateAttributes('disabled="disabled"'); $qfe['to']->updateAttributes('disabled="disabled"'); $qfe['padding']->updateAttributes('disabled="disabled"'); $serial = null; } } else { $qfe['from']->updateAttributes('disabled="disabled"'); $qfe['to']->updateAttributes('disabled="disabled"'); $qfe['padding']->updateAttributes('disabled="disabled"'); } // }}} // {{{ generate
/** * SETTING.TXT をダウンロードして、パースして、キャッシュする * * @access public * @return true|null|false 成功|更新なし(キャッシュ)|失敗 */ function downloadSettingTxt() { global $_conf; $perm = $_conf['dl_perm'] ? $_conf['dl_perm'] : 0606; FileCtl::mkdirFor($this->setting_txt); // 板ディレクトリが無ければ作る $modified = null; if (file_exists($this->setting_srd) && file_exists($this->setting_txt)) { // 更新しない場合は、その場で抜けてしまう if (!empty($_GET['norefresh']) || isset($_REQUEST['word'])) { return null; // キャッシュが新しい場合も抜ける } elseif ($this->isSettingSrdCacheFresh()) { return null; } $modified = gmdate('D, d M Y H:i:s', filemtime($this->setting_txt)) . ' GMT'; } // DL /* // PHP5 if (!class_exists('HTTP_Request', false)) { require 'HTTP/Request.php'; } */ require_once 'HTTP/Request.php'; $params = array(); $params['timeout'] = $_conf['fsockopen_time_limit']; if ($_conf['proxy_use']) { $params['proxy_host'] = $_conf['proxy_host']; $params['proxy_port'] = $_conf['proxy_port']; } $req = new HTTP_Request($this->url, $params); $modified && $req->addHeader('If-Modified-Since', $modified); $req->addHeader('User-Agent', 'Monazilla/1.00 (' . $_conf['p2uaname'] . '/' . $_conf['p2version'] . ')'); $response = $req->sendRequest(); $error_msg = null; if (PEAR::isError($response)) { $error_msg = $response->getMessage(); } else { $code = $req->getResponseCode(); if ($code == 302) { // ホストの移転を追跡 require_once P2_LIB_DIR . '/BbsMap.php'; $new_host = BbsMap::getCurrentHost($this->host, $this->bbs); if ($new_host != $this->host) { $aNewSettingTxt = new SettingTxt($new_host, $this->bbs); return $aNewSettingTxt->downloadSettingTxt(); } } if (!($code == 200 || $code == 206 || $code == 304)) { //var_dump($req->getResponseHeader()); $error_msg = $code; } } // DLエラー if (strlen($error_msg)) { P2Util::pushInfoHtml(sprintf('<div>Error: %s<br>p2 info - %s に接続できませんでした。</div>', hs($error_msg), P2View::tagA(P2Util::throughIme($this->url), hs($this->url), array('target' => $_conf['ext_win_target'])))); touch($this->setting_txt); // DL失敗した場合(404)も touch する touch($this->setting_srd); return false; } $body = $req->getResponseBody(); // DL成功して かつ 更新されていたら保存 if ($body && $code != 304) { // したらば or be.2ch.net ならEUCをSJISに変換 if (P2Util::isHostJbbsShitaraba($this->host) || P2Util::isHostBe2chNet($this->host)) { $body = mb_convert_encoding($body, 'SJIS-win', 'eucJP-win'); } if (false === FileCtl::filePutRename($this->setting_txt, $body)) { die('Error: cannot write file'); } chmod($this->setting_txt, $perm); // パースして if (!$this->setSettingArrayFromSettingTxt()) { return false; } // srd保存する if (!$this->saveSettingSrd($this->setting_array)) { return false; } } else { // touchすることで更新インターバルが効くので、しばらく再チェックされなくなる touch($this->setting_txt); // 同時にキャッシュもtouchしないと、setting_txtとsetting_srdで更新時間がずれて、 // 毎回ここまで処理が来る(サーバへのヘッダリクエストが飛ぶ)場合がある。 touch($this->setting_srd); } return true; }
$a_mode .= '<title>' . $a_tt . '</title>'; } $newdata .= $a_mode . $a_word . "\t" . $a_time . "\t" . $a_hits . "\n"; } if (FileCtl::file_write_contents($path, $newdata) !== FALSE) { P2Util::pushInfoHtml('<p>○設定を更新保存しました</p>'); } else { P2Util::pushInfoHtml('<p>×設定を更新保存できませんでした</p>'); } // }}} // {{{ ■デフォルトに戻すボタンが押されていたら } elseif (!empty($_POST['submit_default'])) { if (@unlink($path)) { P2Util::pushInfoHtml('<p>○リストを空にしました</p>'); } else { P2Util::pushInfoHtml('<p>×リストを空にできませんでした</p>'); } } // }}} // {{{ リスト読み込み $formdata = array(); if ($lines = FileCtl::file_read_lines($path, FILE_IGNORE_NEW_LINES)) { $i = 0; foreach ($lines as $l) { $lar = explode("\t", $l); if (strlen($lar[0]) == 0) { continue; } $ar = array('cond' => $lar[0], 'word' => $lar[0], 'ht' => isset($lar[1]) ? $lar[1] : '--', 'hn' => isset($lar[2]) ? (int) $lar[2] : 0, 're' => '', 'ic' => '', 'bbs' => '', 'tt' => ''); // 板縛り if (preg_match('!<bbs>(.+?)</bbs>!', $ar['word'], $matches)) {
/** * カンマ区切り+@区切りのリストからお気に板をセットする * * @param string $list * @param int|null $setnum * @return bool */ function setFavItaByList($list, $setnum = null) { global $_conf; // 記録データ設定 $rec_lines = array(); foreach (explode(',', $list) as $aList) { list($host, $bbs, $itaj_en) = explode('@', $aList); $rec_lines[] = "\t{$host}\t{$bbs}\t" . UrlSafeBase64::decode($itaj_en); } $script = <<<EOJS <script type="text/javascript"> //<![CDATA[ if (parent.menu) { parent.menu.location.href = '{$_conf['menu_php']}?nr=1'; } //]]> </script> EOJS; P2Util::pushInfoHtml($script); $cont = ''; if (!empty($rec_lines)) { foreach ($rec_lines as $l) { $cont .= $l . "\n"; } } // 書き込む if (FileCtl::file_write_contents(setFavItaGetBrdPath($setnum), $cont) === false) { p2die('cannot write file.'); } return true; }
/** * 最初のログイン画面を表示する */ function printLoginFirst(Login $_login) { global $STYLE, $_conf; global $_login_failed_flag, $_p2session; global $skin_en; // {{{ データ保存ディレクトリのパーミッションの注意を喚起する P2Util::checkDirWritable($_conf['dat_dir']); $checked_dirs[] = $_conf['dat_dir']; // チェック済みのディレクトリを格納する配列に if (!in_array($_conf['idx_dir'], $checked_dirs)) { P2Util::checkDirWritable($_conf['idx_dir']); $checked_dirs[] = $_conf['idx_dir']; } if (!in_array($_conf['pref_dir'], $checked_dirs)) { P2Util::checkDirWritable($_conf['pref_dir']); $checked_dirs[] = $_conf['pref_dir']; } // }}} // 前処理 $_login->checkAuthUserFile(); clearstatcache(); //========================================================= // 書き出し用変数 //========================================================= $ptitle = 'rep2'; $myname = basename($_SERVER['SCRIPT_NAME']); $auth_sub_input_ht = ""; $body_ht = ""; $p_str = array('user' => 'ユーザ', 'password' => 'パスワード'); // 携帯用表示文字列全角→半角変換 if ($_conf['ktai'] && function_exists('mb_convert_kana')) { foreach ($p_str as $k => $v) { $p_str[$k] = mb_convert_kana($v, 'rnsk'); } } //============================================== // 補助認証 //============================================== $mobile = Net_UserAgent_Mobile::singleton(); // {{{ docomo iモードID認証 if ($mobile->isDoCoMo()) { /** * @link http://www.nttdocomo.co.jp/service/imode/make/content/ip/index.html#imodeid */ if (($UID = $mobile->getUID()) !== null) { // HTTPかつguid=ONでリクエストされない限りここに来ることはない if (file_exists($_conf['auth_imodeid_file'])) { include $_conf['auth_imodeid_file']; if (isset($registed_imodeid) && $registed_imodeid == $UID) { $auth_sub_input_ht = 'iモードID OK : ユーザ名だけでログインできます。<br>'; } } } if ($auth_sub_input_ht == '') { if (empty($_SERVER['HTTPS'])) { $regist_imodeid_chedked = ' checked'; $regist_docomo_chedked = ''; } else { $regist_imodeid_chedked = ''; $regist_docomo_chedked = ' checked'; } $auth_sub_input_ht = <<<EOP <input type="hidden" name="ctl_regist_imodeid" value="1"> <input type="hidden" name="ctl_regist_docomo" value="1"> <input type="checkbox" name="regist_imodeid" value="1"{$regist_imodeid_chedked}>iモードIDで認証を登録<br> <input type="checkbox" name="regist_docomo" value="1"{$regist_docomo_chedked}>端末IDで認証を登録<br> EOP; } // }}} // {{{ EZweb サブスクライバID認証 } elseif ($mobile->isEZweb()) { /** * @link http://www.au.kddi.com/ezfactory/tec/spec/4_4.html */ if (($UID = $mobile->getUID()) !== null) { if (file_exists($_conf['auth_ez_file'])) { include $_conf['auth_ez_file']; if (isset($registed_ez) && $registed_ez == $UID) { $auth_sub_input_ht = '端末ID OK : ユーザ名だけでログインできます。<br>'; } } } if ($auth_sub_input_ht == '') { $auth_sub_input_ht = <<<EOP <input type="hidden" name="ctl_regist_ez" value="1"> <input type="checkbox" name="regist_ez" value="1" checked>端末IDで認証を登録<br> EOP; } // }}} // {{{ SoftBank 端末シリアル番号認証 } elseif ($mobile->isSoftBank()) { /** * パケット対応機 要ユーザID通知ONの設定 * @link http://creation.mb.softbank.jp/web/web_ua_about.html */ if (($SN = $mobile->getSerialNumber()) !== null) { if (file_exists($_conf['auth_jp_file'])) { include $_conf['auth_jp_file']; if (isset($registed_jp) && $registed_jp == $SN) { $auth_sub_input_ht = '端末ID OK : ユーザ名だけでログインできます。<br>'; } } } if ($auth_sub_input_ht == '') { $auth_sub_input_ht = <<<EOP <input type="hidden" name="ctl_regist_jp" value="1"> <input type="checkbox" name="regist_jp" value="1" checked>端末IDで認証を登録<br> EOP; } // }}} // {{{ Cookie認証 } else { $regist_cookie_checked = ' checked'; if (isset($_POST['submit_new']) || isset($_POST['submit_member'])) { if ($_POST['regist_cookie'] != '1') { $regist_cookie_checked = ''; } } $ignore_cip_checked = ''; if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) { if (geti($_POST['ignore_cip']) == '1') { $ignore_cip_checked = ' checked'; } } else { if (geti($_COOKIE['ignore_cip']) == '1') { $ignore_cip_checked = ' checked'; } } $auth_sub_input_ht = '<input type="hidden" name="ctl_regist_cookie" value="1">' . sprintf('<input type="checkbox" id="regist_cookie" name="regist_cookie" value="1"%s><label for="regist_cookie">ログイン情報をCookieに保存する(推奨)</label><br>', $regist_cookie_checked) . sprintf('<input type="checkbox" id="ignore_cip" name="ignore_cip" value="1"%s><label for="ignore_cip">Cookie認証時にIPの同一性をチェックしない</label><br>', $ignore_cip_checked); } // }}} // ログインフォームからの指定 if (!empty($GLOBALS['brazil'])) { $add_mail = '.,@-'; } else { $add_mail = ''; } if (preg_match("/^[0-9A-Za-z_{$add_mail}]+\$/", $_login->user_u)) { $hd['form_login_id'] = htmlspecialchars($_login->user_u, ENT_QUOTES); } elseif (!empty($_POST['form_login_id']) && preg_match("/^[0-9A-Za-z_{$add_mail}]+\$/", $_POST['form_login_id'])) { $hd['form_login_id'] = htmlspecialchars($_POST['form_login_id'], ENT_QUOTES); } else { $hd['form_login_id'] = ''; } if (!empty($_POST['form_login_pass']) && preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_pass'])) { $hd['form_login_pass'] = htmlspecialchars($_POST['form_login_pass'], ENT_QUOTES); } else { $hd['form_login_pass'] = ''; } // docomoの固有端末認証 $docomo_auth_ht = ''; if ($mobile->isDoCoMo()) { if (file_exists($_conf['auth_imodeid_file']) && empty($_SERVER['HTTPS'])) { $docomo_auth_ht .= sprintf('<p><a href="%s?auth_type=imodeid&user=%s&guid=ON">iモードID認証</a></p>', $myname, rawurldecode($_login->user_u)); } if (file_exists($_conf['auth_docomo_file'])) { $docomo_auth_ht .= sprintf('<p><a href="%s?auth_type=utn&user=%s" utn>端末ID認証</a></p>', $myname, rawurldecode($_login->user_u)); } } // docomoならpasswordにしない if ($mobile->isDoCoMo()) { $type = 'text'; $utn = ' utn'; } else { $type = 'password'; $utn = ''; } // {{{ ログイン用フォームを生成 $hd['REQUEST_URI'] = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); if ($mobile->isDoCoMo()) { if (strpos($hd['REQUEST_URI'], '?') === false) { $hd['REQUEST_URI'] .= '?guid=ON'; } else { $hd['REQUEST_URI'] .= '&guid=ON'; } } if (file_exists($_conf['auth_user_file'])) { $submit_ht = '<input type="submit" name="submit_member" value="ユーザログイン">'; } else { $submit_ht = '<input type="submit" name="submit_new" value="新規登録">'; } if ($_conf['ktai']) { //$k_roman_input_at = ' istyle="3" format="*m" mode="alphabet"'; $k_roman_input_at = ' istyle="3" format="*x" mode="alphabet"'; $k_input_size_at = ''; } else { $k_roman_input_at = ''; $k_input_size_at = ' size="32"'; } $login_form_ht = <<<EOP {$docomo_auth_ht} <form id="login" method="POST" action="{$hd['REQUEST_URI']}" target="_self"{$utn}> {$_conf['k_input_ht']} {$p_str['user']}: <input type="text" name="form_login_id" value="{$hd['form_login_id']}"{$k_roman_input_at}{$k_input_size_at}><br> {$p_str['password']}: <input type="{$type}" name="form_login_pass" value="{$hd['form_login_pass']}"{$k_roman_input_at}><br> {$auth_sub_input_ht} <br> {$submit_ht} </form> EOP; // }}} //================================================================= // 新規ユーザ登録処理 //================================================================= if (!file_exists($_conf['auth_user_file']) && !$_login_failed_flag and !empty($_POST['submit_new']) && !empty($_POST['form_login_id']) && !empty($_POST['form_login_pass'])) { // {{{ 入力エラーをチェック、判定 if (!preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_id']) || !preg_match('/^[0-9A-Za-z_]+$/', $_POST['form_login_pass'])) { P2Util::pushInfoHtml("<p class=\"info-msg\">rep2 error: 「{$p_str['user']}」名と「{$p_str['password']}」は半角英数字で入力して下さい。</p>"); $show_login_form_flag = true; // }}} // {{{ 登録処理 } else { $_login->makeUser($_POST['form_login_id'], $_POST['form_login_pass']); // 新規登録成功 $hd['form_login_id'] = htmlspecialchars($_POST['form_login_id'], ENT_QUOTES); $body_ht .= "<p class=\"info-msg\">○ 認証{$p_str['user']}「{$hd['form_login_id']}」を登録しました</p>"; $body_ht .= "<p><a href=\"{$myname}?form_login_id={$hd['form_login_id']}{$_conf['k_at_a']}\">rep2 start</a></p>"; $_login->setUser($_POST['form_login_id']); $_login->pass_x = sha1($_POST['form_login_pass']); // セッションが利用されているなら、セッションを更新 if (isset($_p2session)) { // ユーザ名とパスXを更新 $_SESSION['login_user'] = $_login->user_u; $_SESSION['login_pass_x'] = $_login->pass_x; } // 要求があれば、補助認証を登録 $_login->registCookie(); $_login->registKtaiId(); } // }}} // {{{ ログインエラーがある } else { if (isset($_POST['form_login_id']) || isset($_POST['form_login_pass'])) { $info_msg_ht = '<p class="info-msg">'; if (!$_POST['form_login_id']) { $info_msg_ht .= "rep2 error: 「{$p_str['user']}」が入力されていません。<br>"; } if (!$_POST['form_login_pass']) { $info_msg_ht .= "rep2 error: 「{$p_str['password']}」が入力されていません。"; } $info_msg_ht .= '</p>'; P2Util::pushInfoHtml($info_msg_ht); } $show_login_form_flag = true; } // }}} //========================================================= // HTMLプリント //========================================================= P2Util::header_nocache(); echo $_conf['doctype']; echo <<<EOP <html lang="ja"> <head> <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> {$_conf['extra_headers_ht']} <title>{$ptitle}</title> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"> EOP; if (!$_conf['ktai']) { echo <<<EOP <style type="text/css"> /* <![CDATA[ */ EOP; include P2_STYLE_DIR . '/style_css.inc'; include P2_STYLE_DIR . '/login_first_css.inc'; echo <<<EOP /* ]]> */ </style> EOP; } echo "</head><body>\n"; echo "<h3>{$ptitle}</h3>\n"; // 情報表示 P2Util::printInfoHtml(); echo $body_ht; if (!empty($show_login_form_flag)) { echo $login_form_ht; } echo '</body></html>'; return true; }
} } } flock($fp, LOCK_UN); fclose($fp); $script = <<<EOJS <script type="text/javascript"> //<![CDATA[ if (parent.menu) { parent.menu.location.href = '{$_conf['menu_php']}?nr=1'; } //]]> </script> EOJS; P2Util::pushInfoHtml($script); unset($site, $xml, $atom, $m, $matches, $fp); return; } } $setrss = isset($_REQUEST['setrss']) ? trim($_REQUEST['setrss']) : ''; $xml = isset($_REQUEST['xml']) ? trim($_REQUEST['xml']) : ''; $site = isset($_REQUEST['site']) ? trim($_REQUEST['site']) : ''; $site_en = isset($_REQUEST['site_en']) ? trim($_REQUEST['site_en']) : ''; $atom = empty($_REQUEST['atom']) ? 0 : 1; // feedスキームをhttpスキームで置換 $xml = preg_replace('|^feed://|', 'http://', $xml); // RSSのタイトル設定 if ($site === '') { if ($site_en !== '') { $site = UrlSafeBase64::decode($site_en);
require_once 'Net/UserAgent/Mobile.php'; p2_rewrite_vars_for_proxy(); // {{{ ユーザー設定 読込 // ユーザー設定があれば読み込む if (file_exists($_conf['conf_user_file'])) { if ($cont = file_get_contents($_conf['conf_user_file'])) { $conf_user = unserialize($cont); } else { $conf_user = null; } // 何らかの理由でユーザー設定ファイルが壊れていたら if (!is_array($conf_user)) { if (defined('P2_CLI_RUN')) { p2die("ユーザー設定ファイル {$dispname} が読み込めなかったか、壊れています。"); } elseif (unlink($_conf['conf_user_file'])) { P2Util::pushInfoHtml('<p>ユーザー設定ファイルが壊れていたので削除しました。</p>'); $conf_user = array(); } else { $dispname = '$_conf[\'pref_dir\']/' . basename($_conf['conf_user_file']); p2die("壊れているユーザー設定ファイル {$dispname} を削除できませんでした。"); } } // ユーザー設定のバージョンをチェック if (array_key_exists('.', $conf_user) && preg_match('/^\\d{6}\\.\\d{4}$/', $conf_user['.'])) { $config_version = $conf_user['.']; } else { $config_version = '000000.0000'; } $config_custom_version = array_key_exists('p2custom-ver', $conf_user) ? $conf_user['p2custom-ver'] : ''; if (($config_version !== $_conf['p2expack'] || $config_custom_version !== $_conf['p2custom']) && !defined('P2_CLI_RUN')) { if ($config_version !== $_conf['p2expack']) {
// アップロードされたファイルを処理 foreach ($_FILES['upimg']['name'] as $key => $value) { $path = $_POST['path'][$key]; $name = $_FILES['upimg']['name'][$key]; $type = $_FILES['upimg']['type'][$key]; $filesize = $_FILES['upimg']['size'][$key]; $tmpname = $_FILES['upimg']['tmp_name'][$key]; $errcode = $_FILES['upimg']['error'][$key]; if ($errcode == UPLOAD_ERR_NO_FILE) { continue; } $file = ic2_check_uploaded_file($path, $name, $type, $filesize, $tmpname, $errcode); if (is_array($file)) { $upfiles[] = $file; } else { P2Util::pushInfoHtml($file); } } } } // }}} // {{{ output $_flexy_options = array('locale' => 'ja', 'charset' => 'Shift_JIS', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ic2/templates', 'numberFormat' => ''); $flexy = new HTML_Template_Flexy($_flexy_options); $flexy->compile('ic2s.tpl.html'); if (!$isPopUp && (!empty($upfiles) || P2Util::hasInfoHtml())) { $showForm = false; } else { $showForm = true; } // フォームを修正
} // シリアライズして保存 FileCtl::make_datafile($_conf['conf_user_file']); if (FileCtl::file_write_contents($_conf['conf_user_file'], serialize($conf_save)) === false) { P2Util::pushInfoHtml('<p>×設定を更新保存できませんでした</p>'); } else { P2Util::pushInfoHtml('<p>○設定を更新保存しました</p>'); // 変更があれば、内部データも更新しておく $_conf = array_merge($_conf, $conf_user_def, $conf_save); } unset($conf_save); // }}} // {{{ デフォルトに戻すボタンが押されていたら } elseif (!empty($_POST['submit_default'])) { if (file_exists($_conf['conf_user_file']) and unlink($_conf['conf_user_file'])) { P2Util::pushInfoHtml('<p>○設定をデフォルトに戻しました</p>'); // 変更があれば、内部データも更新しておく $_conf = array_merge($_conf, $conf_user_def); if (is_array($conf_save)) { $_conf = array_merge($_conf, $conf_save); } } } // }}} // {{{ 携帯で表示するグループ if ($_conf['ktai']) { if (isset($_REQUEST['edit_conf_user_group_en'])) { $selected_group = UrlSafeBase64::decode($_REQUEST['edit_conf_user_group_en']); } elseif (isset($_REQUEST['edit_conf_user_group'])) { $selected_group = $_REQUEST['edit_conf_user_group']; } else {
$aShowBrdMenuPc->printBrdMenu($match_cates); $msg_ht .= ob_get_clean(); // 検索結果が一つなら、自動で板一覧を開く if ($GLOBALS['ita_mikke']['num'] == 1) { $msg_ht .= '(自動オープンするよ)'; echo <<<EOP <script type="text/javascript"> //<![CDATA[ parent.subject.location.href="{$_conf['subject_php']}?host={$GLOBALS['ita_mikke']['host']}&bbs={$GLOBALS['ita_mikke']['bbs']}&itaj_en={$GLOBALS['ita_mikke']['itaj_en']}"; //]]> </script> EOP; } } $msg_ht .= '</p>'; P2Util::pushInfoHtml($msg_ht); } else { $match_cates = null; } // }}} P2Util::printInfoHtml(); if ($_conf['menu_hide_brds'] && !$GLOBALS['ita_mikke']['num']) { $brd_menus_style = ' style="display:none"'; } else { $brd_menus_style = ''; } // boardディレクトリから読み込んだユーザ定義板カテゴリメニューを表示 if ($brd_menus_dir) { $brd_menus_title = $brd_menus_online ? '板一覧 (private)' : '板一覧'; echo <<<EOP <hr>
/** * メモを追加 */ public static function addMemo($target, $memo) { if (empty($target)) { return; } if (!is_array($target)) { if (is_integer($updated) || ctype_digit($updated)) { $id = (int) $updated; if ($id > 0) { $updated = array($id); } else { return; } } else { P2Util::pushInfoHtml('<p>WARNING! ImageCache2_DatabaseManager::addMemo(): 不正な引数</p>'); return $removed_files; } } // トランザクションの開始 $ta = new ImageCache2_DataObject_Images(); $db = $ta->getDatabaseConnection(); if ($db->phptype == 'pgsql') { $ta->query('BEGIN'); } elseif ($db->phptype == 'sqlite') { $db->query('BEGIN;'); } // メモに指定文字列が含まれていなければ更新 foreach ($target as $id) { $find = new ImageCache2_DataObject_Images(); $find->whereAdd("id = {$id}"); if ($find->find(true) && strpos($find->memo, $memo) === false) { $update = new ImageCache2_DataObject_Images(); $update->whereAdd("id = {$id}"); if (strlen($find->memo) > 0) { $update->memo = $find->memo . ' ' . $memo; } else { $update->memo = $memo; } $update->update(); unset($update); } unset($find); } // トランザクションのコミット if ($db->phptype == 'pgsql') { $ta->query('COMMIT'); } elseif ($db->phptype == 'sqlite') { $db->query('COMMIT;'); } }
/** * p2 - 最初のログイン画面をHTML表示する関数 * * @access public * @return void */ function printLoginFirst(&$_login) { global $STYLE, $_conf; global $_login_failed_flag, $_p2session; // データ保存ディレクトリに書き込み権限がなければ注意を表示セットする P2Util::checkDirsWritable(array($_conf['dat_dir'], $_conf['idx_dir'], $_conf['pref_dir'])); // 前処理 $_login->cleanInvalidAuthUserFile(); clearstatcache(); // 外部からの変数 $post['form_login_id'] = isset($_POST['form_login_id']) ? $_POST['form_login_id'] : null; $post['form_login_pass'] = isset($_POST['form_login_pass']) ? $_POST['form_login_pass'] : null; //========================================================= // 書き出し用変数 //========================================================= if (UA::isIPhoneGroup()) { $ptitle = $_conf['p2name'] . 'iPhone'; } else { $ptitle = $_conf['p2name']; } $ptitle_ht = hs($ptitle); if (!empty($GLOBALS['brazil'])) { $ptitle_ht = 'p2.2ch.net'; if (!(UA::isK() || UA::isIPhoneGroup())) { $ptitle_ht = '<a href="http://p2.2ch.net/">' . $ptitle_ht . '</a>'; } } $myname = basename($_SERVER['SCRIPT_NAME']); $body_ht = ''; $show_login_form_flag = false; $p_str = array('user' => 'ユーザ', 'password' => 'パスワード'); if (!empty($GLOBALS['brazil'])) { $p_str['user'] = '******'; } // 携帯用表示文字列全角→半角変換 if (!UA::isIPhoneGroup() && UA::isK() && function_exists('mb_convert_kana')) { foreach ($p_str as $k => $v) { $p_str[$k] = mb_convert_kana($v, 'rnsk'); } } // 補助認証 require_once P2_LIB_DIR . '/HostCheck.php'; $mobile = Net_UserAgent_Mobile::singleton(); $auth_sub_input_ht = _getAuthSubInputHtml($mobile); // ログインフォームからの指定 $form_login_id_hs = ''; if ($_login->validLoginId($_login->user_u)) { $form_login_id_hs = hs($_login->user_u); } elseif ($_login->validLoginId($post['form_login_id'])) { $form_login_id_hs = hs($post['form_login_id']); } $form_login_pass_hs = ''; if ($_login->validLoginPass($post['form_login_pass'])) { $form_login_pass_hs = hs($post['form_login_pass']); } // docomoの固有端末認証(セッション利用時のみ有効) $docomo_utn_ht = ''; //if ($_conf['use_session'] && $_login->user_u && $mobile->isDoCoMo()) { if ($_conf['use_session'] && $mobile->isDoCoMo()) { $uri = $myname . '?guid=ON&user='******'<p><a href="' . hs($uri) . '" utn>docomo固有端末認証</a></p>'; } // docomoならリトライ時にパスワード入力を password → text とする // (docomoはpassword入力が完全マスクされるUIで、入力エラーがわかりにく過ぎる) if (isset($post['form_login_pass']) and $mobile->isDoCoMo()) { $type = "text"; } else { $type = "password"; } // {{{ ログイン用フォームを生成 $ruri = $_SERVER['REQUEST_URI']; if (UA::isDoCoMo()) { $ruri = UriUtil::addQueryToUri($ruri, array('guid' => 'ON')); } $REQUEST_URI_hs = hs($ruri); if (!empty($GLOBALS['brazil']) or file_exists($_conf['auth_user_file'])) { $submit_ht = '<input type="submit" name="submit_userlogin" value="ユーザログイン">'; } else { $submit_ht = '<input type="submit" name="submit_newuser" value="新規登録">'; } $login_form_ht = <<<EOP {$docomo_utn_ht} <form id="login" method="POST" action="{$REQUEST_URI_hs}" target="_self" utn> {$_conf['k_input_ht']} {$p_str['user']}: <input type="text" name="form_login_id" value="{$form_login_id_hs}" istyle="3" size="32" autocorrect="off" autocapitalize="off"><br> {$p_str['password']}: <input type="{$type}" name="form_login_pass" value="{$form_login_pass_hs}" istyle="3" autocorrect="off" autocapitalize="off"><br> {$auth_sub_input_ht} <br> {$submit_ht} </form> EOP; // }}} //================================================================= // 新規ユーザ登録処理 //================================================================= $isAllowedNewUser = empty($GLOBALS['brazil']) ? true : false; if ($isAllowedNewUser and !file_exists($_conf['auth_user_file']) && !$_login_failed_flag and !empty($_POST['submit_newuser']) && $post['form_login_id'] && $post['form_login_pass']) { // {{{ 入力エラーをチェック、判定 if (!$_login->validLoginId($post['form_login_id']) || !$_login->validLoginPass($post['form_login_pass'])) { P2Util::pushInfoHtml(sprintf('<p class="infomsg">p2 error: 「%s」名と「%s」は半角英数字で入力して下さい。</p>', hs($p_str['user']), hs($p_str['password']))); $show_login_form_flag = true; // }}} // {{{ 登録処理 } else { $_login->makeUser($post['form_login_id'], $post['form_login_pass']); // 新規登録成功 $form_login_id_hs = hs($post['form_login_id']); $body_ht .= "<p class=\"infomsg\">○ 認証{$p_str['user']}「{$form_login_id_hs}」を登録しました</p>"; $body_ht .= "<p><a href=\"{$myname}?form_login_id={$form_login_id_hs}{$_conf['k_at_a']}\">{$_conf['p2name']} start</a></p>"; $_login->setUser($post['form_login_id']); $_login->setPassX(sha1($post['form_login_pass'])); // セッションが利用されているなら、セッションを更新 if (isset($_p2session)) { // ユーザ名とパスXを更新 $_SESSION['login_user'] = $_login->user_u; $_SESSION['login_pass_x'] = $_login->pass_x; } // 要求があれば、補助認証を登録 $_login->registCookie(); $_login->registKtaiId(); } // }}} // {{{ ログインエラーがある } else { if (isset($_POST['submit_newuser']) || isset($_POST['submit_userlogin'])) { $msg_ht = '<p class="infomsg">'; if (!$post['form_login_id']) { $msg_ht .= "p2 error: 「{$p_str['user']}」が入力されていません。" . "<br>"; } elseif (!$_login->validLoginId($post['form_login_id'])) { $msg_ht .= "p2 error: 「{$p_str['user']}」文字列が不正です。" . "<br>"; } if (!$post['form_login_pass']) { $msg_ht .= "p2 error: 「{$p_str['password']}」が入力されていません。"; } $msg_ht .= '</p>'; P2Util::pushInfoHtml($msg_ht); } $show_login_form_flag = true; } // }}} //========================================================= // HTML表示出力 //========================================================= P2Util::headerNoCache(); P2View::printDoctypeTag(); ?> <html lang="ja"> <head> <?php P2View::printExtraHeadersHtml(); ?> <title><?php eh($ptitle); ?> </title> <?php if (UA::isIPhoneGroup()) { ?> <style type="text/css" media="screen">@import "./iui/iui.css";</style><?php } if (UA::isPC() && !UA::isIPhoneGroup()) { // ユーザは未決定 //P2View::printIncludeCssHtml('style'); //P2View::printIncludeCssHtml('login_first'); ?> <link rel="stylesheet" href="style/login_first.css" type="text/css"> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <?php } ?> </head><body><?php if (UA::isIPhoneGroup()) { ?> <div class="toolbar"><h1 id="pageTitle"><?php echo $ptitle_ht; ?> </h1></div><?php ?> <div id="usage" class="panel"><filedset><?php } else { ?> <h3><?php echo $ptitle_ht; ?> </h3><?php } P2Util::printInfoHtml(); echo $body_ht; if ($show_login_form_flag) { echo $login_form_ht; if (empty($GLOBALS['brazil']) and !(HostCheck::isAddrLocal() || HostCheck::isAddrPrivate())) { ?> <p> <font size="-1" color="gray">※このページはプライベート利用のためのシステムです。<br> 部外者によるログイン試行は、<br> 不正アクセスとして記録されます。<br> このページへのアクセスURLを部外者が<br> 不特定多数に公知することを禁止します。</font></p><?php } } if (!empty($GLOBALS['brazil']) and UA::isK() || UA::isIPhoneGroup()) { ?> <br><hr size="1"><div align="center"><a href="http://p2.2ch.net/">p2.2ch.net</a></div><?php } if (UA::isIPhoneGroup()) { ?> <br><br><br><br><br><br></filedset></div><?php } ?> </body></html><?php }
//==================================================== if (!empty($_REQUEST['check_regist_cookie'])) { if ($_login->checkUserPwWithCid($_COOKIE['cid'])) { if ($_REQUEST['regist_cookie'] == '1') { $info_msg_ht = '<p>○cookie認証登録完了</p>'; } else { $info_msg_ht = '<p>×cookie認証解除失敗</p>'; } } else { if ($_REQUEST['regist_cookie'] == '1') { $info_msg_ht = '<p>×cookie認証登録失敗</p>'; } else { $info_msg_ht = '<p>○cookie認証解除完了</p>'; } } P2Util::pushInfoHtml($info_msg_ht); } //==================================================== // 認証ユーザ登録フォーム //==================================================== if ($_conf['ktai']) { $login_form_ht = <<<EOP <hr> <form id="login_change" method="POST" action="{$_SERVER['SCRIPT_NAME']}" target="_self"> {$p_str['password']}の変更<br> {$_conf['k_input_ht']} <input type="hidden" name="csrfid" value="{$csrfid}"> 新しい{$p_str['password']}:<br> <input type="password" name="form_new_login_pass"><br> 新しい{$p_str['password']} (確認):<br> <input type="password" name="form_new_login_pass2"><br>
/** * 携帯TOPメニューの順番を変更する関数 * * @access public * @param string $code * @param string $set top, up, down, bottom * @return boolean */ function _setOrderIndexMenuK($code, $set) { global $_conf; if (!preg_match('/^[\\w]+$/', $code) || !preg_match('/^[\\w]+$/', $set)) { P2Util::pushInfoHtml('<p>p2 error: 引数が変です</p>'); return false; } /* $_conf['index_menu_k'] = array( 'recent_shinchaku', // 0.最近読んだスレの新着 'recent', // 1.最近読んだスレの全て 'fav_shinchaku', // 2.お気にスレの新着 'fav', // 3.お気にスレの全て 'favita', // 4.お気に板 'cate', // 5.板リスト 'res_hist', // 6.書込履歴 #.ログ 'palace', // 7.スレの殿堂 'setting', // 8.ログイン管理 'editpref' // 9.設定管理 ); */ /* // 無効なコード if (!in_array($code, $_conf['index_menu_k'])) { return false; } */ $menu = $_conf['index_menu_k']; if (false === ($menu = _getMenuKMovedIndex($menu, $code, $set))) { return false; } if (false === P2Util::setConfUser('index_menu_k', $menu)) { return false; } return true; }
} else { P2Util::pushInfoHtml('<p>画像データベースを最適化しました。</p>'); } } // SQLite3 の一覧表示用データキャッシュをVACUUM,REINDX if ($viewer_cache_exists) { $kvs = P2KeyValueStore::getStore($_conf['iv2_cache_db_path'], P2KeyValueStore::CODEC_SERIALIZING); $kvs->optimize(); unset($kvs); P2Util::pushInfoHtml('<p>一覧表\示用のデータキャッシュを最適化しました。</p>'); } break; // 未定義のリクエスト // 未定義のリクエスト default: P2Util::pushInfoHtml('<p>未定義のリクエストです。</p>'); } if (isset($removed_files)) { $flexy->setData('removedFiles', $removed_files); } } // }}} // {{{ 出力 $flexy->setData('skin', $skin_en); $flexy->setData('php_self', $_SERVER['SCRIPT_NAME']); $flexy->setData('p2vid', P2_VERSION_ID); $flexy->setData('info_msg', P2Util::getInfoHtml()); $flexy->setData('pc', !$_conf['ktai']); $flexy->setData('iphone', $_conf['iphone']); $flexy->setData('doctype', $_conf['doctype']); $flexy->setData('extra_headers', $_conf['extra_headers_ht']);
/** * Cookie認証登録解除処理の結果 * * @return void, P2Util::pushInfoHtml() */ function _preExecCheckRegistCookie() { global $_login; if (isset($_REQUEST['check_regist_cookie'])) { if ($_login->checkUserPwWithCid($_COOKIE['cid'])) { if (geti($_REQUEST['regist_cookie']) == '1') { P2Util::pushInfoHtml('<p>○cookie認証登録完了</p>'); } else { P2Util::pushInfoHtml('<p>×cookie認証解除失敗</p>'); } } else { if (geti($_REQUEST['regist_cookie']) == '1') { P2Util::pushInfoHtml('<p>×cookie認証登録失敗</p>'); } else { P2Util::pushInfoHtml('<p>○cookie認証解除完了</p>'); } } } }
/** * 既にdat落ちしているスレは自動的にあぼーんを解除する * $ta_keys はあぼーんリストに入っていたけれど、あぼーんされずに残ったスレたち */ function autoTAbornOff($aThreadList, $ta_keys) { //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('abornoff'); if (!$aThreadList->spmode && !empty($GLOBALS['word']) && !empty($GLOBALS['wakati_word']) && $aThreadList->threads && $ta_keys) { require_once P2_LIB_DIR . '/settaborn_off.inc.php'; // echo sizeof($ta_keys)."*<br>"; $ta_vkeys = array_keys($ta_keys); settaborn_off($aThreadList->host, $aThreadList->bbs, $ta_vkeys); $ks = ''; foreach ($ta_vkeys as $k) { $ta_num--; if ($k) { $ks .= "key:{$k} "; } } if ($ks) { P2Util::pushInfoHtml("<p>p2 info: DAT落ちしたスレッドあぼーんを自動解除しました - {$ks}</p>"); } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('abornoff'); return true; }
/** * スキン設定を更新し、ページをリロードする * * @return false 成功すれば、そのままページリダイレクトされる */ function _updateSkinSetting($newskin) { global $_conf; if ($newskin !== '') { if (!preg_match('/^\\w+$/', $newskin)) { P2Util::pushInfoHtml(sprintf("<p>p2 error: 不正なスキン (%s) が指定されました。</p>", hs($newskin))); return false; } $skinFilePath = P2Util::getSkinFilePathBySkinName($newskin); if (!file_exists($skinFilePath)) { P2Util::pushInfoHtml(sprintf("<p>p2 error: 不正なスキン (%s) が指定されました。</p>", hs($newskin))); return false; } } FileCtl::make_datafile($_conf['skin_setting_path'], $_conf['skin_setting_perm']); if (false === file_put_contents($_conf['skin_setting_path'], $newskin, LOCK_EX)) { P2Util::pushInfoHtml("<p>p2 error: スキン設定を書き込めませんでした。</p>"); return false; } $sid_q = defined('SID') && strlen(SID) ? '&' . SID : ''; header("Location: {$_SERVER['SCRIPT_NAME']}?reload_skin=1" . $sid_q); exit; }
/** * Atom 0.3 を RSS 1.0 に変換する(PHP5, DOM & XSL) */ function atom_to_rss_by_xsl($input, $stylesheet, $output) { $xmlDoc = new DomDocument(); if ($xmlDoc->load(realpath($input))) { $xslDoc = new DomDocument(); $xslDoc->load(realpath($stylesheet)); $proc = new XSLTProcessor(); $proc->importStyleSheet($xslDoc); $rssDoc = $proc->transformToDoc($xmlDoc); $rssDoc->save($output); $rss_content = FileCtl::file_read_contents($output); } else { $rss_content = null; } if (!$rss_content) { P2Util::pushInfoHtml('<p>p2 error: XSL - AtomをRSSに変換できませんでした。</p>'); return FALSE; } return $rss_content; }
/** * brdファイルを生成する * * @return string brdファイルのパス */ public function makeBrdFile($cachefile) { global $_conf, $word; $p2brdfile = $cachefile . ".p2.brd"; FileCtl::make_datafile($p2brdfile); $data = FileCtl::file_read_lines($cachefile); $cont = ''; $this->setBrdMatch($cachefile); // パターンマッチ形式を登録 $this->setBrdList($data); // カテゴリーと板をセット if ($this->categories) { foreach ($this->categories as $cate) { if ($cate->num > 0) { $cont .= $cate->name . "\t0\n"; foreach ($cate->menuitas as $mita) { $cont .= "\t{$mita->host}\t{$mita->bbs}\t{$mita->itaj}\n"; } } } } if ($cont) { if (FileCtl::file_write_contents($p2brdfile, $cont) === false) { p2die("{$p2brdfile} を更新できませんでした"); } return $p2brdfile; } else { if (!$word) { P2Util::pushInfoHtml("<p>p2 error: {$cachefile} から板メニューを生成することはできませんでした。</p>"); } return false; } }