示例#1
0
文件: index.funcs.php 项目: poppen/p2
/**
 * @access  public
 * @return  array
 */
function getIndexMenuKIni()
{
    global $_conf;
    // 2008/11/15 旧 $_conf['menuKIni']
    $indexMenuKIni = array('recent_shinchaku' => array($_conf['subject_php'] . '?spmode=recent&sb_view=shinchaku', '最近読んだスレの新着'), 'recent' => array($_conf['subject_php'] . '?spmode=recent&norefresh=1', '最近読んだスレの全て'), 'fav_shinchaku' => array($_conf['subject_php'] . '?spmode=fav&sb_view=shinchaku', 'お気にスレの新着'), 'fav' => array($_conf['subject_php'] . '?spmode=fav&norefresh=1', 'お気にスレの全て'), 'favita' => array($_conf['menu_k_php'] . '?view=favita', 'お気に板'), 'cate' => array($_conf['menu_k_php'] . '?view=cate', '板リスト'), 'res_hist' => array($_conf['subject_php'] . '?spmode=res_hist', '書込履歴'), 'palace' => array($_conf['subject_php'] . '?spmode=palace&norefresh=1', 'スレの殿堂'), 'setting' => array('setting.php?dummy=1', 'ログイン管理'), 'editpref' => array($_conf['editpref_php'] . '?dummy=1', '設定管理'));
    // 携帯なら半角に変換
    if (UA::isK()) {
        foreach ($indexMenuKIni as $k => $v) {
            $indexMenuKIni[$k][1] = mb_convert_kana($indexMenuKIni[$k][1], 'rnsk');
        }
    }
    return $indexMenuKIni;
}
示例#2
0
/**
 *  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 
}
示例#3
0
<?php

/**
 *  p2 書き込みフォーム
 */
// 携帯
if (UA::isK()) {
    $htm['k_br'] = '<br>';
    $htm['kakiko_on_js'] = '';
    // PC
} else {
    $htm['k_br'] = '';
    $htm['kakiko_on_js'] = ' onFocus="adjustTextareaRows(this, 2);" onKeyup="adjustTextareaRows(this, 2);' . " autoSavePostForm('{$host}', '{$bbs}', '{$key}');\"";
}
$htm['subject'] = isset($htm['subject']) ? $htm['subject'] : '';
$popup_hs = isset($popup) ? hs($popup) : '';
$newthread_hidden_ht = isset($newthread_hidden_ht) ? $newthread_hidden_ht : '';
$readnew_hidden_ht = isset($readnew_hidden_ht) ? $readnew_hidden_ht : '';
$ttitle_en_hs = hs($ttitle_en);
// 文字コード判定用文字列を先頭に仕込むことでmb_convert_variables()の自動判定を助ける
$htm['post_form'] = <<<EOP
<form id="resform" method="POST" action="{$_conf['post_php']}" accept-charset="{$_conf['accept_charset']}" onsubmit="disableSubmit(this)">
{$htm['resform_ttitle']}
{$htm['orig_msg']}

    <input type="hidden" name="detect_hint" value="◎◇">
    {$htm['subject']}
    {$htm['maru_kakiko']} 名前: <input id="FROM" name="FROM" type="text" value="{$hs['FROM']}"{$name_size_at}>{$htm['k_br']} 
     E-mail : <input id="mail" name="mail" type="text" value="{$hs['mail']}"{$mail_size_at}{$on_check_sage}>
    {$sage_cb_ht}{$htm['k_br']}
    <textarea id="MESSAGE" name="MESSAGE" rows="{$STYLE['post_msg_rows']}"{$msg_cols_at} wrap="{$wrap}"{$htm['kakiko_on_js']}>{$MESSAGE_hs}</textarea>{$htm['k_br']}
示例#4
0
文件: Thread.php 项目: poppen/p2
 /**
  * 元スレURLを返す
  *
  * @access  public
  * @param   boolean  $original  携帯でも2chのスレURLを返す
  * @return  string  URL
  */
 function getMotoThread($original = false)
 {
     global $_conf;
     // 携帯カスタマイズ指定
     if ($_conf['ktai'] && !$original && $_conf['k_motothre_external']) {
         $motothre_url = $this->compileMobile2chUri();
         // まちBBS
     } elseif (P2Util::isHostMachiBbs($this->host)) {
         // PC
         if (!$_conf['ktai'] || $original) {
             /*
             $motothre_url = sprintf(
                 'http://%s/bbs/read.cgi?BBS=%s&KEY=%s',
                 $this->host, rawurlencode($this->bbs), rawurlencode($this->key)
             );
             */
             $motothre_url = "http://{$this->host}/bbs/read.cgi/{$this->bbs}/{$this->key}/{$this->ls}";
             // 携帯
         } else {
             $motothre_url = sprintf('http://%s/bbs/read.cgi?IMODE=TRUE&BBS=%s&KEY=%s', $this->host, rawurlencode($this->bbs), rawurlencode($this->key));
         }
         // まちびねっと
     } elseif (P2Util::isHostMachiBbsNet($this->host)) {
         $motothre_url = sprintf('http://%s/test/read.cgi?bbs=%s&key=%s', $this->host, rawurlencode($this->bbs), rawurlencode($this->key));
         // JBBSしたらば
     } elseif (P2Util::isHostJbbsShitaraba($this->host)) {
         $preg = '{(jbbs\\.shitaraba\\.com|jbbs\\.livedoor\\.com|jbbs\\.livedoor\\.jp)}';
         $host_bbs_cgi = preg_replace($preg, '$1/bbs/read.cgi', $this->host);
         $motothre_url = "http://{$host_bbs_cgi}/{$this->bbs}/{$this->key}/{$this->ls}";
         // $motothre_url = "http://{$this->host}/bbs/read.cgi?BBS={$this->bbs}&KEY={$this->key}";
         // 2ch系
     } elseif (P2Util::isHost2chs($this->host)) {
         // PC
         if (!UA::isK() || UA::isIPhoneGroup() || $original) {
             $motothre_url = "http://{$this->host}/test/read.cgi/{$this->bbs}/{$this->key}/{$this->ls}";
             // 携帯
         } else {
             // BBS PINK
             if (P2Util::isHostBbsPink($this->host)) {
                 // r.iはもう使われていない
                 //$motothre_url = "http://{$this->host}/test/r.i/{$this->bbs}/{$this->key}/{$this->ls}";
                 $motothre_url = "http://speedo.ula.cc/test/r.so/{$this->host}/{$this->bbs}/{$this->key}/{$this->ls}?guid=ON";
                 // 2ch(c.2ch)
             } else {
                 $motothre_url = $this->compileMobile2chUri();
             }
         }
         // その他
     } else {
         $motothre_url = "http://{$this->host}/test/read.cgi/{$this->bbs}/{$this->key}/{$this->ls}";
     }
     return $motothre_url;
 }
示例#5
0
文件: read.php 项目: poppen/p2
/**
 * preview >>1
 *
 * @return  void  HTML出力
 */
function _printPreview1Html(&$aThread, $params)
{
    global $_conf, $STYLE, $_login;
    global $_filter_hits;
    // $res_filter
    extract($params);
    $aThread->ls = '1';
    // 必ずしも正確ではないが便宜的に
    if (!isset($aThread->rescount) and !empty($_GET['rc'])) {
        $aThread->rescount = intval($_GET['rc']);
        $aThread->lsToPoint();
    }
    $body = $aThread->previewOne();
    $ptitle_ht = hs($aThread->itaj) . ' / ' . hs($aThread->ttitle_hc);
    if (UA::isIPhoneGroup()) {
        $read_header_inc_php = P2_IPHONE_LIB_DIR . '/read_header_k.inc.php';
        $read_footer_inc_php = P2_IPHONE_LIB_DIR . '/read_footer_k.inc.php';
    } elseif (UA::isK()) {
        $read_header_inc_php = P2_LIB_DIR . '/read_header_k.inc.php';
        $read_footer_inc_php = P2_LIB_DIR . '/read_footer_k.inc.php';
    } else {
        $read_header_inc_php = P2_LIB_DIR . '/read_header.inc.php';
        $read_footer_inc_php = P2_LIB_DIR . '/read_footer.inc.php';
    }
    require_once $read_header_inc_php;
    echo $body;
    require_once $read_footer_inc_php;
}
示例#6
0
EOP;
}
?>
</table>
<a class='whiteButton' href="<?php 
eh($_SERVER['SCRIPT_NAME']);
?>
?setdef=1<?php 
echo $_conf['k_at_a'];
?>
">デフォルトに戻す</a>
</filedset>
</div>
<?php 
// フッタHTMLを表示する
if (UA::isK() && !UA::isIPhoneGroup()) {
    echo $hr . P2View::getBackToIndexKATag();
}
?>
</body></html><?php 
exit;
//======================================================================
// 関数(このファイル内でのみ利用)
//======================================================================
/**
 * 携帯TOPメニューの順番を変更する関数
 *
 * @access  public
 * @param   string  $code
 * @param   string  $set  top, up, down, bottom
 * @return  boolean
示例#7
0
文件: info_i.php 项目: poppen/p2
/**
 * @return  string  HTML
 */
function _getOffRecentATag($aThread, $offrecent_accesskey, $ttitle_en)
{
    global $_conf;
    $preKey = '';
    if (UA::isK() && $offrecent_accesskey) {
        $preKey = $offrecent_accesskey . '.';
    }
    return P2View::tagA(UriUtil::buildQueryUri('info_i.php', array('host' => $aThread->host, 'bbs' => $aThread->bbs, 'key' => $aThread->key, 'offrecent' => '1', 'popup' => (int) (bool) geti($_GET['popup']), 'ttitle_en' => $ttitle_en, UA::getQueryKey() => UA::getQueryValue())), sprintf('%s履歴から外す', hs($preKey)), array('title' => 'このスレを「最近読んだスレ」と「書き込み履歴」から外します', 'accesskey' => $offrecent_accesskey));
}
示例#8
0
文件: P2View.php 项目: poppen/p2
 /**
  * @static
  * @access  public
  * @return  string
  */
 function getHrHtmlK()
 {
     global $STYLE;
     $hr = '<hr>';
     if (!UA::isK()) {
         return $hr;
     }
     if (!empty($STYLE['k_color'])) {
         $hr = '<hr color="' . hs($STYLE['k_color']) . '">';
     }
     return $hr;
 }
示例#9
0
文件: index.php 项目: poppen/p2
<?php

// p2 -  インデックスページ
require_once './conf/conf.inc.php';
$_login->authorize();
// ユーザ認証
// アクセス拒否用の.htaccessをデータディレクトリに自動作成する
_makeDenyHtaccess($_conf['pref_dir']);
_makeDenyHtaccess($_conf['dat_dir']);
_makeDenyHtaccess($_conf['idx_dir']);
if (UA::isK() || UA::isIPhoneGroup()) {
    // GETクエリーでurlの指定があれば、そのままスレッド読みへ飛ばす
    _locationReadPhpIfGetUrl();
    // void|exit
    if (UA::isIPhoneGroup()) {
        require_once P2_IPHONE_LIB_DIR . '/index_print_k.inc.php';
    } else {
        require_once P2_LIB_DIR . '/index_print_k.inc.php';
    }
    index_print_k();
} else {
    // {{{ PC用 変数
    $title_page = 'title.php';
    $read_page = _getReadPage();
    $sidebar = isset($_GET['sidebar']) ? $_GET['sidebar'] : null;
    $ptitle = "rep2";
    // }}}
    // {{{ PC用 HTMLプリント
    P2Util::headerNoCache();
    ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
示例#10
0
文件: Login.php 项目: poppen/p2
 /**
  * md5_encrypt, md5_decrypt のための password(salt) を得る
  * (クッキーのcidの生成に利用している)
  *
  * @static
  * @access  private
  * @return  string
  */
 function getMd5CryptPassForCid()
 {
     //return md5($_SERVER['SERVER_NAME'] . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['SERVER_SOFTWARE']);
     //$seed = $_SERVER['SERVER_NAME'] . $_SERVER['SERVER_SOFTWARE'];
     $seed = $_SERVER['SERVER_SOFTWARE'];
     require_once P2_LIB_DIR . '/HostCheck.php';
     // ローカルチェックをして、HostCheck::isAddrDocomo() などでホスト名を引く機会を減らす
     $notK = (bool) (HostCheck::isAddrLocal() || HostCheck::isAddrPrivate());
     // 携帯判定された場合は、 IPチェックなし
     if (!$notK and UA::isK(geti($_SERVER['HTTP_USER_AGENT'])) || HostCheck::isAddrDocomo() || HostCheck::isAddrAu() || HostCheck::isAddrSoftBank() || HostCheck::isAddrWillcom() || HostCheck::isAddrJigWeb() || HostCheck::isAddrJig() || HostCheck::isAddrIbis()) {
     } elseif (!empty($_COOKIE['ignore_cip'])) {
     } else {
         $now_ips = explode('.', $_SERVER['REMOTE_ADDR']);
         $seed .= $now_ips[0];
     }
     return md5($seed);
 }
示例#11
0
/**
 * $_conf['expack.use_pecl_http'] の調整
 *
 * @return  void
 */
function _adjustConfUsePeclHttp()
{
    global $_conf;
    if (version_compare(phpversion(), '5.0.0', '<') or $_conf['expack.use_pecl_http'] && !extension_loaded('http')) {
        //if (!($_conf['expack.use_pecl_http'] == 2 && $_conf['expack.dl_pecl_http'])) {
        $_conf['expack.use_pecl_http'] = 0;
        //}
    } elseif ($_conf['expack.use_pecl_http'] == 3 && UA::isK()) {
        $_conf['expack.use_pecl_http'] = 1;
    }
}
示例#12
0
文件: P2Util.php 项目: poppen/p2
 /**
  * @static
  * @access  public
  * @return  void
  */
 function printInfoHtml()
 {
     global $_info_msg_ht, $_conf;
     if (!isset($_info_msg_ht) || !strlen($_info_msg_ht)) {
         return;
     }
     if (UA::isK() && $_conf['k_save_packet']) {
         echo mb_convert_kana($_info_msg_ht, 'rnsk');
     } else {
         echo $_info_msg_ht;
     }
     $_info_msg_ht = '';
 }
示例#13
0
文件: SubjectTxt.php 项目: poppen/p2
 /**
  * subject.txtをダウンロードする
  *
  * @access  public
  * @return  array|null|false  subject.txtの配列データ(eaccelerator, apc用)、またはnullを返す。
  *                            失敗した場合はfalseを返す。
  */
 function downloadSubject()
 {
     global $_conf;
     static $spentDlTime_ = 0;
     // DL所要合計時間
     $perm = isset($_conf['dl_perm']) ? $_conf['dl_perm'] : 0606;
     $modified = false;
     if ($this->storage == 'file') {
         FileCtl::mkdirFor($this->subject_file);
         // 板ディレクトリが無ければ作る
         if (file_exists($this->subject_file)) {
             // ファイルキャッシュがあれば、DL制限時間をかける
             if (UA::isK()) {
                 $dlSubjectTotalLimitTime = $_conf['dlSubjectTotalLimitTimeM'];
             } else {
                 $dlSubjectTotalLimitTime = $_conf['dlSubjectTotalLimitTime'];
             }
             if ($dlSubjectTotalLimitTime and $spentDlTime_ > $dlSubjectTotalLimitTime) {
                 return null;
             }
             // 条件によって、キャッシュを適用する
             // subject.php でrefresh指定がある時は、キャッシュを適用しない
             if (!(basename($_SERVER['SCRIPT_NAME']) == $_conf['subject_php'] && !empty($_REQUEST['refresh']))) {
                 // キャッシュ適用指定時は、その場で抜ける
                 if (!empty($_GET['norefresh']) || isset($_REQUEST['word'])) {
                     return null;
                     // 並列ダウンロード済の場合も抜ける
                 } elseif (!empty($GLOBALS['expack.subject.multi-threaded-download.done'])) {
                     return null;
                     // 新規スレ立て時以外で、キャッシュが新鮮な場合も抜ける
                 } elseif (empty($_POST['newthread']) and $this->isSubjectTxtFresh()) {
                     return null;
                 }
             }
             $modified = gmdate("D, d M Y H:i:s", filemtime($this->subject_file)) . " GMT";
         }
     }
     $dlStartTime = $this->microtimeFloat();
     // DL
     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->subject_url, $params);
     $modified && $req->addHeader('If-Modified-Since', $modified);
     $req->addHeader('User-Agent', sprintf('Monazilla/1.00 (%s/%s)', $_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) {
                 $aNewSubjectTxt = new SubjectTxt($new_host, $this->bbs);
                 return $aNewSubjectTxt->downloadSubject();
             }
         }
         if (!($code == 200 || $code == 206 || $code == 304)) {
             //var_dump($req->getResponseHeader());
             $error_msg = $code;
         }
     }
     if (!is_null($error_msg) && strlen($error_msg) > 0) {
         $attrs = array();
         if ($_conf['ext_win_target']) {
             $attrs['target'] = $_conf['ext_win_target'];
         }
         $atag = P2View::tagA(P2Util::throughIme($this->subject_url), hs($this->subject_url), $attrs);
         $msg_ht = sprintf('<div>Error: %s<br>p2 info - %s に接続できませんでした。</div>', hs($error_msg), $atag);
         P2Util::pushInfoHtml($msg_ht);
         $body = '';
     } else {
         $body = $req->getResponseBody();
     }
     $dlEndTime = $this->microtimeFloat();
     $dlTime = $dlEndTime - $dlStartTime;
     $spentDlTime_ += $dlTime;
     // 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');
         }
         // eaccelerator or apcに保存する場合
         if ($this->storage == 'eaccelerator' || $this->storage == 'apc') {
             $cache_key = "{$this->host}/{$this->bbs}";
             $cont = rtrim($body);
             $lines = explode("\n", $cont);
             if ($this->storage == 'eaccelerator') {
                 eaccelerator_lock($cache_key);
                 eaccelerator_put($cache_key, $lines, $_conf['sb_dl_interval']);
                 eaccelerator_unlock($cache_key);
             } else {
                 apc_store($cache_key, $lines, $_conf['sb_dl_interval']);
             }
             return $lines;
             // ファイルに保存する場合
         } else {
             if (false === FileCtl::filePutRename($this->subject_file, $body)) {
                 // 保存に失敗はしても、既存のキャッシュが読み込めるならよしとしておく
                 if (is_readable($this->subject_file)) {
                     return null;
                 } else {
                     die("Error: cannot write file");
                     return false;
                 }
             }
             chmod($this->subject_file, $perm);
         }
     } else {
         // touchすることで更新インターバルが効くので、しばらく再チェックされなくなる
         // (変更がないのに修正時間を更新するのは、少し気が進まないが、ここでは特に問題ないだろう)
         if ($this->storage == 'file') {
             touch($this->subject_file);
         }
     }
     return null;
 }
示例#14
0
文件: Login.php 项目: unpush/p2-php
 /**
  * MD5Crypt::encrypt, MD5Crypt::decrypt のための password(salt) を得る
  * (クッキーのcidの生成に利用している)
  *
  * @param   void
  * @access  private
  * @return  string
  */
 private static function getMd5CryptPassForCid()
 {
     static $pass = null;
     if ($pass !== null) {
         return $pass;
     }
     $seed = $_SERVER['SERVER_SOFTWARE'];
     // IPチェックなしの場合と
     if (!empty($_COOKIE['ignore_cip'])) {
         // 携帯判定された場合は、 IPチェックなし
     } elseif (UA::isK(geti($_SERVER['HTTP_USER_AGENT'])) || HostCheck::isAddressMobile()) {
     } else {
         $now_ips = explode('.', $_SERVER['REMOTE_ADDR']);
         $seed .= $now_ips[0];
     }
     $pass = md5($seed, true);
     return $pass;
 }