/** * @static * @access public * @return void HTMLタグ出力 */ function printDoctypeTag() { $ie_strict = false; if (UA::isPC() || UA::isIPhoneGroup()) { if ($ie_strict) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?php } else { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <?php } } }
/** * 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 }
// PC用表示 } else { ?> <hr> <table id="footer" width="100%" style="padding:0px 10px 0px 0px;"> <tr> <td align="right"><?php echo $toolbar_ht; ?> </td> <td align="right" style="padding-left:12px;"><a href="#header">▲</a></td> </tr> </table> <?php } if (UA::isPC()) { ?> </form><?php } ?> </body></html> <?php exit; //=================================================================== // 関数(このファイル内でのみ利用) //=================================================================== /* * Local Variables: * mode: php * coding: cp932 * tab-width: 4
/** * @return string HTML */ function _getTtitleNameATag($aThread, $ttitle_name) { global $_conf; $attrs = array('class' => 'thre_title'); if (UA::isPC()) { $attrs['target'] = 'read'; } return P2View::tagA(UriUtil::buildQueryUri($_conf['read_php'], array('host' => $aThread->host, 'bbs' => $aThread->bbs, 'key' => $aThread->key, UA::getQueryKey() => UA::getQueryValue())), hs($ttitle_name) . ' ', $attrs); }
/** * ソースコード補正用チェックボックス * * @return string HTML */ function _getSrcFixHtml($host) { global $_conf; $src_fix_ht = ''; if (UA::isPC() || UA::isIPhoneGroup()) { if ($_conf['editor_srcfix'] == 1 or $_conf['editor_srcfix'] == 2 && preg_match('/pc\\d+\\.2ch\\.net/', $host)) { $src_fix_ht = '<input type="checkbox" id="fix_source" name="fix_source" value="1">ソ\ースコード補正'; } } return $src_fix_ht; }
/** * >>1のみをプレビュー表示するためのHTMLを取得する(オンザフライに対応) * * @access public * @return string|false */ function previewOne() { global $_conf, $ptitle_ht; if (!($this->host && $this->bbs && $this->key)) { return false; } $first_line = ''; // ローカルdatから取得 if (is_readable($this->keydat)) { $fd = fopen($this->keydat, "rb"); $first_line = fgets($fd, 32800); fclose($fd); } if ($first_line) { // be.2ch.net ならEUC→SJIS変換 if (P2Util::isHostBe2chNet($this->host)) { $first_line = mb_convert_encoding($first_line, 'SJIS-win', 'eucJP-win'); } $first_datline = rtrim($first_line); if (strstr($first_datline, "<>")) { $datline_sepa = "<>"; } else { $datline_sepa = ","; $this->dat_type = "2ch_old"; } $d = explode($datline_sepa, $first_datline); $this->setTtitle($d[4]); // 便宜上 if (!$this->readnum) { $this->readnum = 1; } } // ローカルdatなければオンラインから if (!$first_line) { $url = $this->getDatUrl($this->host, $this->bbs, $this->key); $purl = parse_url($url); $purl['query'] = isset($purl['query']) ? '?' . $purl['query'] : ''; // プロキシ if ($_conf['proxy_use']) { $send_host = $_conf['proxy_host']; $send_port = $_conf['proxy_port']; $send_path = $url; } else { $send_host = $purl['host']; $send_port = isset($purl['port']) ? $purl['port'] : null; $send_path = $purl['path'] . $purl['query']; } // デフォルトを80 !$send_port and $send_port = 80; $request = 'GET ' . $send_path . " HTTP/1.0\r\n"; $request .= "Host: " . $purl['host'] . "\r\n"; $request .= 'User-Agent: ' . P2Util::getP2UA($withMonazilla = true) . "\r\n"; // $request .= "Range: bytes={$from_bytes}-\r\n"; // Basic認証用のヘッダ if (isset($purl['user']) && isset($purl['pass'])) { $request .= "Authorization: Basic " . base64_encode($purl['user'] . ":" . $purl['pass']) . "\r\n"; } $request .= "Connection: Close\r\n"; $request .= "\r\n"; // WEBサーバへ接続 $fp = fsockopen($send_host, $send_port, $errno, $errstr, $_conf['fsockopen_time_limit']); if (!$fp) { P2Util::pushInfoHtml(sprintf('<p>サーバ接続エラー: %s (%s)<br>p2 info - %s に接続できませんでした。</p>', $errstr, $errno, P2View::tagA(P2Util::throughIme($url), hs($url), array('target' => $_conf['ext_win_target'])))); $this->diedat = true; return false; } // HTTPリクエスト送信 fputs($fp, $request); // HTTPヘッダレスポンスを取得する $h = $this->freadHttpHeader($fp); if ($h === false) { fclose($fp); $this->_pushInfoHtmlFreadHttpHeaderError($url); $this->diedat = true; return false; } // {{{ HTTPコードをチェック $code = $h['code']; // Partial Content if ($code == "200") { // OK。何もしない // 予期しないHTTPコード。なかったと判断する } else { fclose($fp); $this->previewOneNotFound(); return false; } // }}} if (isset($h['headers']['Content-Length'])) { if (preg_match("/^([0-9]+)/", $h['headers']['Content-Length'], $matches)) { $onbytes = $h['headers']['Content-Length']; } } // bodyを一行目だけ読む $first_line = fgets($fp, 32800); fclose($fp); // be.2ch.net ならEUC→SJIS変換 if (P2Util::isHostBe2chNet($this->host)) { $first_line = mb_convert_encoding($first_line, 'SJIS-win', 'eucJP-win'); } $first_datline = rtrim($first_line); if (strstr($first_datline, '<>')) { $datline_sepa = '<>'; } else { $datline_sepa = ','; $this->dat_type = '2ch_old'; } $d = explode($datline_sepa, $first_datline); $this->setTtitle($d[4]); $this->onthefly = true; } // 厳密にはオンザフライではないが、個人にとっては(既読記録がされないという意味で)オンザフライ if (!$this->isKitoku()) { $this->onthefly = true; } $body = ''; if (!empty($this->onthefly)) { // PC if (UA::isPC()) { $body .= '<div><span class="onthefly">プレビュー</span></div>'; // 携帯 } else { $body .= '<div><font size="-1" color="#00aa00">プレビュー</font></div>'; } } UA::isPC() and $body .= '<dl>'; require_once P2_LIB_DIR . '/ShowThread.php'; // PC if (UA::isPC()) { require_once P2_LIB_DIR . '/ShowThreadPc.php'; $aShowThread = new ShowThreadPc($this); // 携帯 } else { require_once P2_LIB_DIR . '/ShowThreadK.php'; $aShowThread = new ShowThreadK($this); } $body .= $aShowThread->transRes($first_line, 1); // 1を表示 UA::isPC() and $body .= "</dl>\n"; return $body; }
/** * 編集フォームinput用HTMLを得る(関数内でPC、携帯用表示を振り分け) * * @return string */ function getEditConfHtml($name, $description_ht) { global $_conf, $conf_user_def, $conf_user_sel; // デフォルト値の規定がなければ、空白を返す if (!isset($conf_user_def[$name])) { return ''; } // 携帯では編集表示しない項目 if ($_conf['ktai']) { $noKtais = array('enable_headbar', 'enable_spm', 'spm_kokores', 'frame_menu_width', 'frame_subject_width', 'frame_read_width'); if (in_array($name, $noKtais)) { return sprintf('<input type="hidden" name="conf_edit[%s]" value="%s">' . "\n", hs($name), hs($_conf[$name])); } } $name_view_hs = hs($_conf[$name]); if (empty($_conf['ktai'])) { $input_size_at = ' size="38"'; } else { $input_size_at = ''; } // select 選択形式なら if (isset($conf_user_sel[$name])) { $form_ht = getEditConfSelHtml($name); $key = $conf_user_def[$name]; $def_views[$name] = htmlspecialchars($conf_user_sel[$name][$key], ENT_QUOTES); // input 入力式なら } else { $form_ht = <<<EOP <input type="text" name="conf_edit[{$name}]" value="{$name_view_hs}"{$input_size_at}> EOP; $def_views[$name] = htmlspecialchars($conf_user_def[$name], ENT_QUOTES); } // PC用 if (UA::isPC()) { $r = <<<EOP <tr title="デフォルト値: {$def_views[$name]}"> <td>{$name}</td> <td>{$form_ht}</td> <td>{$description_ht}</td> </tr> EOP; // 携帯用 } else { // [{$name}]<br> $r = <<<EOP {$description_ht}<br> {$form_ht}<br> <br> EOP; } return $r; }