Ejemplo n.º 1
0
/**
 * @return  void  exit
 */
function _dlDataFile($file)
{
    if (!file_exists($file)) {
        P2Util::printSimpleHtml('データファイルが存在しないよ。');
        exit;
    }
    header('Content-Type: text/plain; name=' . basename($file));
    header("Content-Disposition: attachment; filename=" . basename($file));
    readfile($file);
    exit;
}
Ejemplo n.º 2
0
/**
 * スレッドを指定する
 *
 * @return  array|false
 */
function detectThread()
{
    global $_conf;
    $ls = null;
    // スレURLの直接指定
    if ((isset($_GET['nama_url']) and $url = $_GET['nama_url']) || (isset($_GET['url']) and $url = $_GET['url'])) {
        $url = trim($url);
        // 2ch or pink - http://choco.2ch.net/test/read.cgi/event/1027770702/
        if (preg_match('{http://([^/]+\\.(2ch\\.net|bbspink\\.com))/test/read\\.cgi/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = $matches[5];
            // c-docomo c-au c-other http://c-au.2ch.net/test/--3!mail=sage/operate/1159594301/519-n
        } elseif (preg_match('{http://((c-docomo|c-au|c-other)\\.2ch\\.net)/test/([^/]+)/([^/]+)/([0-9]+)/?([^/]+)?}', $url, $m)) {
            require_once P2_LIB_DIR . '/BbsMap.class.php';
            if ($mapped_host = BbsMap::get2chHostByBbs($m[4])) {
                $host = $mapped_host;
                $bbs = $m[4];
                $key = $m[5];
                $ls = $m[6];
            }
            // 2ch or pink 過去ログhtml - http://pc.2ch.net/mac/kako/1015/10153/1015358199.html
        } elseif (preg_match("/(http:\\/\\/([^\\/]+\\.(2ch\\.net|bbspink\\.com))(\\/[^\\/]+)?\\/([^\\/]+)\\/kako\\/\\d+(\\/\\d+)?\\/(\\d+)).html/", $url, $matches)) {
            //2ch pink 過去ログhtml
            $host = $matches[2];
            $bbs = $matches[5];
            $key = $matches[7];
            $kakolog_uri = $matches[1];
            $_GET['kakolog'] = urlencode($kakolog_uri);
            // まち&したらばJBBS - http://kanto.machibbs.com/bbs/read.pl?BBS=kana&KEY=1034515019
        } elseif (preg_match("/http:\\/\\/([^\\/]+\\.machibbs\\.com|[^\\/]+\\.machi\\.to)\\/bbs\\/read\\.(pl|cgi)\\?BBS=([^&]+)&KEY=([0-9]+)(&START=([0-9]+))?(&END=([0-9]+))?[^\"]*/", $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = $matches[6] . "-" . $matches[8];
        } elseif (preg_match("{http://((jbbs\\.livedoor\\.jp|jbbs\\.livedoor.com|jbbs\\.shitaraba\\.com)(/[^/]+)?)/bbs/read\\.(pl|cgi)\\?BBS=([^&]+)&KEY=([0-9]+)(&START=([0-9]+))?(&END=([0-9]+))?[^\"]*}", $url, $matches)) {
            $host = $matches[1];
            $bbs = $matches[5];
            $key = $matches[6];
            $ls = $matches[8] . "-" . $matches[10];
            // したらばJBBS http://jbbs.livedoor.com/bbs/read.cgi/computer/2999/1081177036/-100
        } elseif (preg_match("{http://(jbbs\\.livedoor\\.jp|jbbs\\.livedoor.com|jbbs\\.shitaraba\\.com)/bbs/read\\.cgi/(\\w+)/(\\d+)/(\\d+)/((\\d+)?-(\\d+)?)?[^\"]*}", $url, $matches)) {
            $host = $matches[1] . "/" . $matches[2];
            $bbs = $matches[3];
            $key = $matches[4];
            $ls = $matches[5];
        }
    } else {
        !empty($_GET['host']) and $host = $_GET['host'];
        // "pc.2ch.net"
        !empty($_POST['host']) and $host = $_POST['host'];
        isset($_GET['bbs']) and $bbs = $_GET['bbs'];
        // "php"
        isset($_POST['bbs']) and $bbs = $_POST['bbs'];
        isset($_GET['key']) and $key = $_GET['key'];
        // "1022999539"
        isset($_POST['key']) and $key = $_POST['key'];
        !empty($_GET['ls']) and $ls = $_GET['ls'];
        // "all"
        !empty($_POST['ls']) and $ls = $_POST['ls'];
    }
    if (empty($host) || !isset($bbs) || !isset($key)) {
        $htm['url'] = htmlspecialchars($url, ENT_QUOTES);
        $msg = "p2 - {$_conf['read_php']}: スレッドの指定が変です。<br>" . "<a href=\"{$htm['url']}\">" . $htm['url'] . "</a>";
        P2Util::printSimpleHtml($msg);
        die;
        return false;
    }
    return array($host, $bbs, $key, $ls);
}
Ejemplo n.º 3
0
    exit;
}
$res_hist_dat_size = filesize($_conf['p2_res_hist_dat']);
$logSizeSt = P2Util::getTranslatedUnitFileSize($res_hist_dat_size);
$maxLogSize = 0;
//1024*1024*10;
$maxLogSizeSt = P2Util::getTranslatedUnitFileSize($maxLogSize);
if ($maxLogSize and $res_hist_dat_size > $maxLogSize) {
    P2Util::printSimpleHtml(sprintf('書き込みログ容量(%s/%s)が大き過ぎるため、表\示できません。<br>
            %sのページより、書き込みログの一括削除を行って下さい。', hs($logSizeSt), hs($maxLogSizeSt), P2View::tagA($_conf['editpref_php'], hs('設定管理'), array('target' => 'subject'))));
    exit;
}
if (false === ($datlines = file($_conf['p2_res_hist_dat']))) {
    p2die('書き込み履歴ログファイルを読み込めませんでした');
} elseif (!$datlines) {
    P2Util::printSimpleHtml($karappoMsgHtml);
    exit;
}
// ファイルの下に記録されているものが新しいので反転させる
$datlines = array_reverse($datlines);
$datlines_num = count($datlines);
$ResHist = new ResHist();
// HTMLプリント用変数
$toolbar_ht = <<<EOP
\tチェックした項目を<input type="submit" name="submit" value="{$deletemsg_st}">
\t全てのチェックボックスを 
\t<input type="button" onclick="hist_checkAll(true)" value="選択"> 
\t<input type="button" onclick="hist_checkAll(false)" value="解除">
EOP;
$hr = P2View::getHrHtmlK();
//==================================================================
Ejemplo n.º 4
0
<?php

/*
    p2 - レス書き込みフォーム
*/
require_once './conf/conf.inc.php';
require_once './iphone/conf.inc.php';
require_once P2_LIB_DIR . '/dataphp.class.php';
$_login->authorize();
// ユーザ認証
//==================================================
// 変数
//==================================================
if (empty($_GET['host'])) {
    // 引数エラー
    P2Util::printSimpleHtml('p2 error: host が指定されていません');
    die;
} else {
    $host = $_GET['host'];
}
$bbs = isset($_GET['bbs']) ? $_GET['bbs'] : '';
$key = isset($_GET['key']) ? $_GET['key'] : '';
$rescount = isset($_GET['rescount']) ? intval($_GET['rescount']) : 1;
$popup = isset($_GET['popup']) ? intval($_GET['popup']) : 0;
$itaj = P2Util::getItaName($host, $bbs);
if (!$itaj) {
    $itaj = $bbs;
}
$ttitle_en = isset($_GET['ttitle_en']) ? $_GET['ttitle_en'] : '';
$ttitle = strlen($ttitle_en) > 0 ? base64_decode($ttitle_en) : '';
$ttitle_hs = htmlspecialchars($ttitle, ENT_QUOTES);
Ejemplo n.º 5
0
<?php

/*
    p2 - ユーザ設定編集UI
*/
/* 2008/7/25 iPhone用にカスタマイズ*/
require_once './conf/conf.inc.php';
require_once './iphone/conf.inc.php';
require_once P2_LIB_DIR . '/dataphp.class.php';
$_login->authorize();
// ユーザ認証
if (!empty($_POST['submit_save']) || !empty($_POST['submit_default'])) {
    if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId()) {
        P2Util::printSimpleHtml("p2 error: 不正なポストです");
        die;
    }
}
//=====================================================================
// 前処理
//=====================================================================
// {{{ 保存ボタンが押されていたら、設定を保存
if (!empty($_POST['submit_save'])) {
    // 値の適正チェック、矯正
    // トリム
    $_POST['conf_edit'] = array_map('trim', $_POST['conf_edit']);
    // 選択肢にないもの → デフォルト矯正
    notSelToDef();
    // ルールを適用する
    applyRules();
    /**
     * デフォルト値 $conf_user_def と変更値 $_POST['conf_edit'] の両方が存在していて、
Ejemplo n.º 6
0
    /**
     * レス記事HTMLを表示する PC用
     *
     * @access  public
     * @param   array
     * @return  void
     */
    function printArticlesHtml($datlines)
    {
        global $_conf, $STYLE;
        // Pager 準備
        if (!(include_once 'Pager/Pager.php')) {
            P2Util::printSimpleHtml('p2 error: PEARの Pager/Pager.php がインストールされていません');
            die;
        }
        $pageID = 1;
        if (isset($_REQUEST['pageID'])) {
            $pageID = max(1, intval($_REQUEST['pageID']));
        }
        $perPage = 100;
        $pager = Pager::factory($this->getPagerParams(count($datlines), $perPage));
        //$links = $pager->getLinks();
        //$data  = $pager->getPageData();
        $data = array_slice($datlines, $perPage * ($pageID - 1), $perPage);
        if ($pager->links) {
            echo "<div>{$pager->links}</div>";
        }
        ?>
<dl><?php 
        $n = ($pageID - 1) * $perPage;
        foreach ($data as $aline) {
            $n++;
            $aline = rtrim($aline);
            $ResArticle = $this->lineToRes($aline, $n);
            $daytime_hs = hs($ResArticle->daytime);
            $ttitle_hs = hs(html_entity_decode($ResArticle->ttitle, ENT_COMPAT, 'Shift_JIS'));
            $info_qs = array('host' => $ResArticle->host, 'bbs' => $ResArticle->bbs, 'key' => $ResArticle->key, UA::getQueryKey() => UA::getQueryValue());
            $info_uri = UriUtil::buildQueryUri('info.php', $info_qs);
            $info_uri_hs = hs($info_uri);
            $sid_qs = array();
            if (defined('SID') && strlen(SID)) {
                $sid_qs[session_name()] = session_id();
            }
            $info_openwin_qs = array_merge($info_qs, array('popup' => '1'), $sid_qs);
            $info_openwin_uri = UriUtil::buildQueryUri('info.php', $info_openwin_qs);
            $info_openwin_uri_as = str_replace("'", "\\'", $info_openwin_uri);
            $info_view_ht = P2View::tagA($info_openwin_uri, hs('情報'), array('target' => '_self', 'onClick' => "return !openSubWin('{$info_openwin_uri_as}',{$STYLE['info_pop_size']},0,0)"));
            $res_ht = "<dt><input name=\"checked_hists[]\" type=\"checkbox\" value=\"{$ResArticle->order},,,,{$daytime_hs}\"> ";
            // 番号
            $res_ht .= "{$ResArticle->order} :";
            // 名前
            $array = explode('#', $ResArticle->name, 2);
            if (count($array) == 2) {
                $name_ht = sprintf('%s◆</b>%s<b>', $array[0], P2Util::mkTrip($array[1]));
                $title_at = ' title="' . hs($ResArticle->name) . '"';
            } else {
                $name_ht = hs($ResArticle->name);
                $title_at = '';
            }
            $res_ht .= '<span class="name"' . $title_at . '><b>' . $name_ht . '</b></span> :';
            // メール
            if ($ResArticle->mail) {
                $res_ht .= hs($ResArticle->mail) . ' :';
            }
            // 日付とID
            $res_ht .= "{$daytime_hs}</dt>\n";
            // 板名
            $atag = P2View::tagA(UriUtil::buildQueryUri($_conf['subject_php'], array('host' => $ResArticle->host, 'bbs' => $ResArticle->bbs, UA::getQueryKey() => UA::getQueryValue())), hs($ResArticle->itaj), array('target' => 'subject'));
            $res_ht .= "<dd>{$atag} / ";
            if ($ResArticle->key) {
                if (empty($ResArticle->resnum) || $ResArticle->resnum == 1) {
                    $ls_qs = array();
                    $footer_anchor = '#footer';
                } else {
                    $lf = max(1, $ResArticle->resnum - 0);
                    $ls_qs = array('ls' => "{$lf}-");
                    $footer_anchor = "#r{$lf}";
                }
                $ttitle_qs = array_merge(array('host' => $ResArticle->host, 'bbs' => $ResArticle->bbs, 'key' => $ResArticle->key, UA::getQueryKey() => UA::getQueryValue(), 'nt' => time()), $ls_qs);
                $ttitle_uri = UriUtil::buildQueryUri($_conf['read_php'], $ttitle_qs) . $footer_anchor;
                $atag = P2View::tagA($ttitle_uri, sprintf('<b>%s </b>', $ttitle_hs));
                $res_ht .= "{$atag} - {$info_view_ht}\n";
            } else {
                $res_ht .= "<b>{$ttitle_hs} </b>\n";
            }
            $res_ht .= "<br><br>";
            // 内容
            $res_ht .= "{$ResArticle->msg}<br><br></dd>\n";
            echo $res_ht;
            ob_flush();
            flush();
        }
        echo '</dl>';
        if ($pager->links) {
            echo "<div>{$pager->links}</div>";
        }
    }
Ejemplo n.º 7
0
} else {
    if ($stalker->isEnabled()) {
        $id = null;
        if (!empty($_GET['id'])) {
            $id = $_GET['id'];
        } elseif (!empty($_GET['key']) && !empty($_GET['resnum'])) {
            $aThread = new ThreadRead();
            $aThread->setThreadPathInfo($_GET['host'], $_GET['bbs'], $_GET['key']);
            $aThread->readDat();
            $resnum = $_GET['resnum'];
            if (isset($aThread->datlines[$resnum - 1])) {
                $ares = $aThread->datlines[$resnum - 1];
                $resar = $aThread->explodeDatLine($ares);
                $m = array();
                if (preg_match('<(ID: ?| )([0-9A-Za-z/.+]{8,11})(?=[^0-9A-Za-z/.+]|$)>', $resar[2], $m)) {
                    $id = $m[2];
                }
            }
        }
        if ($id) {
            $stalker->id = $id;
        } else {
            P2Util::printSimpleHtml('何かが足りないようです。');
            exit;
        }
        $_ime = new P2Ime();
        header('Location: ' . $_ime->through($stalker->getIDURL(), null, false));
    } else {
        P2Util::printSimpleHtml('この板は対応していません。');
    }
}
Ejemplo n.º 8
0
$_conf['subject_php'] = 'subject.php';
// subject_i.php
$_conf['read_php'] = 'read.php';
$_conf['read_new_php'] = 'read_new.php';
$_conf['read_new_k_php'] = 'read_new_k.php';
$_conf['post_php'] = 'post.php';
$_conf['cookie_file_name'] = 'p2_cookie.txt';
$_conf['menu_k_php'] = 'menu_k.php';
// menu_i.php
$_conf['editpref_php'] = 'editpref.php';
// editpref_i.php
// info.php はJavaScriptファイル中に書かれているのが難
// }}}
// 管理者用設定を読み込み
if (!(require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'conf_admin.inc.php')) {
    P2Util::printSimpleHtml("p2 error: 管理者用設定ファイルを読み込めませんでした。");
    trigger_error('!include_once conf_admin.inc.php', E_USER_ERROR);
    die;
}
ini_set('default_socket_timeout', $_conf['default_socket_timeout']);
// cache 保存ディレクトリ (パーミッションは707)
$_conf['cache_dir'] = $_conf['data_dir'] . '/cache';
// 2005/6/29 $_conf['pref_dir'] . '/p2_cache' より変更
// テンポラリディレクトリ (パーミッションは707)
$_conf['tmp_dir'] = $_conf['data_dir'] . '/tmp';
// 管理用保存ディレクトリ (パーミッションは707)
// 2010/02/01 拡張の設定。使用していない。
$_conf['admin_dir'] = $_conf['data_dir'] . '/admin';
$_conf['accesskey_for_k'] = 'accesskey';
// 端末判定
_checkBrowser();
Ejemplo n.º 9
0
require_once './iphone/conf.inc.php';
require_once P2_LIB_DIR . '/dataphp.class.php';
require_once P2_LIB_DIR . '/filectl.class.php';
$_login->authorize();
// ユーザ認証
if (!empty($_conf['disable_res'])) {
    P2Util::printSimpleHtml('p2 error: 書き込み機能\は無効です。');
    die;
}
// 引数エラー
if (empty($_POST['host'])) {
    P2Util::printSimpleHtml('p2 error: 無効な引数です。');
    die;
}
if (!isset($_POST['csrfid']) or $_POST['csrfid'] != P2Util::getCsrfId()) {
    P2Util::printSimpleHtml('p2 error: 不正なポストです');
    die;
}
//================================================================
// 変数
//================================================================
$newtime = date('gis');
$post_keys = array('FROM', 'mail', 'MESSAGE', 'bbs', 'key', 'time', 'host', 'popup', 'rescount', 'subject', 'submit', 'sub', 'ttitle_en');
foreach ($post_keys as $pk) {
    ${$pk} = isset($_POST[$pk]) ? $_POST[$pk] : null;
}
if (!isset($ttitle)) {
    if ($ttitle_en) {
        $ttitle = base64_decode($ttitle_en);
    } elseif ($subject) {
        $ttitle = $subject;
Ejemplo n.º 10
0
$_conf['auth_user_file'] = $_conf['pref_dir'] . '/p2_auth_user.php';
$_conf['auth_ez_file'] = $_conf['pref_dir'] . '/p2_auth_ez.php';
$_conf['auth_jp_file'] = $_conf['pref_dir'] . '/p2_auth_jp.php';
$_conf['auth_docomo_file'] = $_conf['pref_dir'] . '/p2_auth_docomo.php';
$_conf['login_log_file'] = $_conf['pref_dir'] . '/p2_login.log.php';
$_conf['login_failed_log_file'] = $_conf['pref_dir'] . '/p2_login_failed.dat.php';
// saveMatomeCache() のために $_conf['pref_dir'] を絶対パスに変換する
define('P2_PREF_DIR_REAL_PATH', File_Util::realPath($_conf['pref_dir']));
$_conf['matome_cache_path'] = P2_PREF_DIR_REAL_PATH . DIRECTORY_SEPARATOR . 'matome_cache';
$_conf['matome_cache_ext'] = '.htm';
$_conf['matome_cache_max'] = 3;
// 予備キャッシュの数
// {{{ ありえない引数のエラー
// 新規ログインとメンバーログインの同時指定はありえないので、エラー出す
if (isset($_POST['submit_newuser']) && isset($_POST['submit_userlogin'])) {
    P2Util::printSimpleHtml("p2 Error: 無効なURLです。");
    die;
}
// }}}
// {{{ ホストチェック
if ($_conf['secure']['auth_host'] || $_conf['secure']['auth_bbq']) {
    require_once P2_LIB_DIR . '/HostCheck.php';
    if ($_conf['secure']['auth_host'] && HostCheck::getHostAuth() == FALSE || $_conf['secure']['auth_bbq'] && HostCheck::getHostBurned() == TRUE) {
        HostCheck::forbidden();
    }
}
// }}}
// セッションの開始
$_p2session = _startSession();
// ログインクラスのインスタンス生成(ログインユーザが指定されていなければ、この時点でログインフォーム表示に)
// ([todo]この処理を上に持って行きたいが、ユーザーログインか新規登録どうかの区別ができなくなる。