コード例 #1
0
ファイル: P2DOM.php プロジェクト: xingskycn/p2-php
 /**
  * @param string $html
  * @param array $fallbackEncodings
  * @throws P2Exception
  */
 public function __construct($html, array $fallbackEncodings = null)
 {
     set_error_handler(array($this, 'checkConversionFailure'), E_WARNING);
     try {
         $this->_conversionFailed = false;
         $document = new DOMDocument();
         $document->loadHTML($html);
         // 代替エンコーディングを指定して再読み込み
         if ($this->_conversionFailed && $fallbackEncodings) {
             $orig_html = $html;
             foreach ($fallbackEncodings as $charset) {
                 // <head>直後に<meta>を埋め込む
                 $charset = p2h($charset);
                 $html = str_replace('<rep2:charset>', "<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$charset}\">", preg_replace('/<head[^<>]*>/i', '$0<rep2:charset>', $orig_html));
                 $this->_conversionFailed = false;
                 $document = new DOMDocument();
                 $document->loadHTML($html);
                 if (!$this->_conversionFailed) {
                     break;
                 }
             }
         }
     } catch (Exception $e) {
         restore_error_handler();
         throw new P2Exception('Failed to create DOM: ' . get_class($e) . ': ' . $e->getMessage());
     }
     restore_error_handler();
     if ($this->_conversionFailed) {
         throw new P2Exception('Failed to load HTML');
     }
     $this->_document = $document;
     $this->_xpath = new DOMXPath($document);
 }
コード例 #2
0
ファイル: StrCtl.php プロジェクト: xingskycn/p2-php
 /**
  * フォームから送られてきたワードをマッチ関数に適合させる
  *
  * @return string $word_fm 適合パターン。SJISで返す。
  */
 public static function wordForMatch($word, $method = 'regex')
 {
     $word_fm = $word;
     // 「そのまま」でなければ、全角空白を半角空白に矯正
     if ($method != 'just') {
         $word_fm = mb_convert_kana($word_fm, 's');
     }
     $word_fm = p2h(trim($word_fm));
     if (in_array($method, array('and', 'or', 'just'))) {
         // preg_quote()で2バイト目が0x5B("[")の"ー"なども変換されてしまうので
         // UTF-8にしてから正規表現の特殊文字をエスケープ
         $word_fm = mb_convert_encoding($word_fm, 'UTF-8', 'CP932');
         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, 'CP932', 'UTF-8');
         // 他、regex(正規表現)なら
     } else {
         if (P2_MBREGEX_AVAILABLE == 0) {
             $word_fm = str_replace('/', '\\/', $word_fm);
         }
     }
     return $word_fm;
 }
コード例 #3
0
ファイル: editfile.php プロジェクト: xingskycn/p2-php
/**
 * ファイル内容を読み込んで編集する関数
 */
function editFile($path, $encode, $title)
{
    global $_conf, $modori_url, $rows, $cols, $csrfid;
    if ($path == '') {
        p2die('path が指定されていません');
    }
    $filename = basename($path);
    $ptitle = 'Edit: ' . p2h($title) . ' (' . $filename . ')';
    //ファイル内容読み込み
    FileCtl::make_datafile($path) or p2die("cannot make file. ({$path})");
    $cont = file_get_contents($path);
    if ($encode == "EUC-JP") {
        $cont = mb_convert_encoding($cont, 'CP932', 'CP51932');
    }
    $cont_area = p2h($cont);
    if ($modori_url) {
        $modori_url_ht = "<p><a href=\"{$modori_url}\">Back</a></p>\n";
    } else {
        $modori_url_ht = '';
    }
    $rows_at = $rows > 0 ? sprintf(' rows="%d"', $rows) : '';
    $cols_at = $cols > 0 ? sprintf(' cols="%d"', $cols) : '';
    // プリント
    echo $_conf['doctype'];
    echo <<<EOHEADER
<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>
</head>
<body onload="top.document.title=self.document.title;">
EOHEADER;
    $info_msg_ht = P2Util::getInfoHtml();
    echo $modori_url_ht;
    echo $ptitle;
    echo <<<EOFORM
<form action="{$_SERVER['SCRIPT_NAME']}" method="post" accept-charset="{$_conf['accept_charset']}">
    <input type="hidden" name="file" value="{$filename}">
    <input type="hidden" name="modori_url" value="{$modori_url}">
    <input type="hidden" name="encode" value="{$encode}">
    <input type="hidden" name="rows" value="{$rows}">
    <input type="hidden" name="cols" value="{$cols}">
    <input type="hidden" name="csrfid" value="{$csrfid}">
    <input type="submit" name="submit" value="Save">
    {$info_msg_ht}<br>
    <textarea style="font-size:9pt;" id="filecont" name="filecont" wrap="off"{$rows_at}{$cols_at}>{$cont_area}</textarea>
    {$_conf['detect_hint_input_ht']}{$_conf['k_input_ht']}
</form>
EOFORM;
    echo '</body></html>';
    return true;
}
コード例 #4
0
ファイル: P2CommandRunner.php プロジェクト: xingskycn/p2-php
 /**
  * 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_SCRIPT_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>' . p2h($command) . '</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(p2h($output)) . '</p>');
         }
     }
     return $status == 0;
 }
コード例 #5
0
ファイル: setfavita.inc.php プロジェクト: xingskycn/p2-php
/**
 * リクエストパラメータからお気に板をセットする
 *
 * @param   void
 * @return  bool
 */
function setFavItaByRequest()
{
    global $_conf;
    $setfavita = null;
    $host = null;
    $bbs = null;
    $itaj = null;
    $list = null;
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
        if (isset($_GET['setfavita'])) {
            $setfavita = $_GET['setfavita'];
        }
        if (isset($_GET['host'])) {
            $host = $_GET['host'];
        }
        if (isset($_GET['bbs'])) {
            $bbs = $_GET['bbs'];
        }
        if (isset($_GET['itaj_en'])) {
            $itaj = UrlSafeBase64::decode($_GET['itaj_en']);
        }
    } elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
        if (isset($_POST['setfavita'])) {
            $setfavita = $_POST['setfavita'];
        }
        if (isset($_POST['itaj'])) {
            $itaj = $_POST['itaj'];
        }
        if (isset($_POST['url'])) {
            if (preg_match("/http:\\/\\/(.+)\\/([^\\/]+)\\/([^\\/]+\\.html?)?/", $_POST['url'], $matches)) {
                $host = $matches[1];
                $host = preg_replace('{/test/read\\.cgi$}', '', $host);
                $bbs = $matches[2];
            } else {
                $url_ht = p2h($_POST['url']);
                P2Util::pushInfoHtml("<p>p2 info: 「{$url_ht}」は板のURLとして無効です。</p>");
            }
        } elseif (!empty($_POST['submit_setfavita']) && $_POST['list']) {
            $list = $_POST['list'];
        }
    }
    if ($host && $bbs) {
        return setFavItaByHostBbs($host, $bbs, $setfavita, $itaj);
    } elseif ($list) {
        return setFavItaByList($list);
    } else {
        P2Util::pushInfoHtml("<p>p2 info: 板の指定が変です</p>");
        return false;
    }
}
コード例 #6
0
/**
 * 定型文を選択するselect要素を取得する
 *
 * @param   string  $name       select要素のid属性値・兼・name属性値 (デフォルトは'fixed_message')
 * @param   string  $onchange   option要素が選択されたときのイベントハンドラ (デフォルトはなし)
 * @return  string  select要素のHTML
 */
function fixed_name_get_select_element($name = 'fixed_message', $onchange = null)
{
    $name_ht = p2h($name);
    if ($onchange !== null) {
        $onchange_ht = p2h($onchange);
        $select = "<select id=\"{$name_ht}\" name=\"{$name_ht}\" onchange=\"{$onchange_ht}\">\n";
    } else {
        $select = "<select id=\"{$name_ht}\" name=\"{$name_ht}\">\n";
    }
    $select .= "<option value=\"\">定型文</option>\n";
    foreach (fixed_message_get_persister()->getKeys() as $key) {
        $key_ht = p2h($onchange);
        $select .= "<option value=\"{$key_ht}\">{$key_ht}</option>\n";
    }
    $select .= "</option>";
    return $select;
}
コード例 #7
0
ファイル: viewtxt.php プロジェクト: xingskycn/p2-php
/**
 * ファイル内容を読み込んで表示する関数
 */
function viewTxtFile($file, $encode)
{
    if (!$file) {
        p2die('file が指定されていません');
    }
    $filename = basename($file);
    $ptitle = $filename;
    //ファイル内容読み込み
    $cont = FileCtl::file_read_contents(P2_BASE_DIR . DIRECTORY_SEPARATOR . $file);
    if ($cont === false) {
        $cont_area = '';
    } else {
        if (strcasecmp($encode, 'EUC-JP') === 0) {
            $cont = mb_convert_encoding($cont, 'CP932', 'CP51932');
        } elseif (strcasecmp($encode, 'UTF-8') === 0) {
            $cont = mb_convert_encoding($cont, 'CP932', 'UTF-8');
        }
        $cont_area = p2h($cont);
    }
    // プリント
    echo <<<EOHEADER
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
    {$_conf['extra_headers_ht']}
    <title>{$ptitle}</title>
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
</head>
<body onload="top.document.title=self.document.title;">

EOHEADER;
    P2Util::printInfoHtml();
    echo "<pre>";
    echo $cont_area;
    echo "</pre>";
    echo '</body></html>';
    return true;
}
コード例 #8
0
ファイル: common.inc.php プロジェクト: xingskycn/p2-php
/**
 * RSSのURLからローカルに保存するファイルのパスを設定する
 */
function rss_get_save_path($remotefile)
{
    global $_conf;
    static $finished = array();
    $remotefile = preg_replace('|^feed://|', 'http://', $remotefile);
    if (array_key_exists($remotefile, $finished)) {
        return $finished[$remotefile];
    }
    $pURL = @parse_url($remotefile);
    if (!$pURL || !isset($pURL['scheme']) || $pURL['scheme'] != 'http' || !isset($pURL['host'])) {
        $errmsg = 'p2 error: 不正なRSSのURL (' . p2h($remotefile) . ')';
        $error = PEAR::raiseError($errmsg);
        return $finished[$remotefile] = $error;
    }
    $localname = '';
    if (isset($pURL['path']) && $pURL['path'] !== '') {
        $localname .= preg_replace('/[^\\w.]/', '_', substr($pURL['path'], 1));
    }
    if (isset($pURL['query']) && $pURL['query'] !== '') {
        $localname .= '_' . preg_replace('/[^\\w.%]/', '_', $pURL['query']) . '.rdf';
    }
    // 拡張子.cgiや.php等で保存するのを防ぐ
    if (!preg_match('/\\.(rdf|rss|xml)$/i', $localname)) {
        // 古いバージョンで取得したRSSを削除
        if (file_exists($localname)) {
            @unlink($localname);
        }
        // 拡張子.rdfを付加
        $localname .= '.rdf';
    }
    // dotFileが作られるのを防ぐ
    if (substr($localname, 0, 1) == '.') {
        $localname = '_' . $localname;
    }
    $localpath = $_conf['dat_dir'] . '/p2_rss/' . $pURL['host'] . '/' . $localname;
    return $finished[$remotefile] = $localpath;
}
コード例 #9
0
ファイル: sb_header_k.inc.php プロジェクト: xingskycn/p2-php
EOP;
} else {
    $ptitle_ht = <<<EOP
<b>{$ptitle_hd}</b>
EOP;
}
// }}}
// フォーム ==================================================
$sb_form_hidden_ht = <<<EOP
<input type="hidden" name="bbs" value="{$aThreadList->bbs}">
<input type="hidden" name="host" value="{$aThreadList->host}">
<input type="hidden" name="spmode" value="{$aThreadList->spmode}">
{$_conf['detect_hint_input_ht']}{$_conf['k_input_ht']}{$_conf['m_favita_set_input_ht']}
EOP;
// フィルタ検索 ==================================================
$hd['word'] = p2h($word);
$filter_form_ht = '';
$hit_ht = '';
if (!$spmode_without_palace_or_favita) {
    if (array_key_exists('method', $sb_filter) && $sb_filter['method'] == 'or') {
        $hd['method_checked_at'] = ' checked';
    } else {
        $hd['method_checked_at'] = '';
    }
    $filter_form_ht = <<<EOP
<form method="GET" action="{$_conf['subject_php']}" accept-charset="{$_conf['accept_charset']}">
{$sb_form_hidden_ht}<input type="text" id="sb_filter_word" name="word" value="{$hd['word']}" size="15">
<input type="checkbox" id="sb_filter_method" name="method" value="or"{$hd['method_checked_at']}><label for="sb_filter_method">OR</label>
<input type="submit" name="submit_kensaku" value="検索">
</form>
コード例 #10
0
ファイル: editpref.php プロジェクト: xingskycn/p2-php
/**
 * お気に入りセットリストを更新する
 *
 * @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 = p2h($newname);
                $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;
}
コード例 #11
0
ファイル: edit_ng_thread.php プロジェクト: xingskycn/p2-php
    $row_format = <<<EOP
<input type="text" name="nga[%1\$d][word]" value="%2\$s"><br>
板:<input type="text" size="5" name="nga[%1\$d][bbs]" value="%5\$s">
<input type="checkbox" name="nga[%1\$d][ignorecase]" value="1"%3\$s>i
<input type="checkbox" name="nga[%1\$d][regex]" value="1"%4\$s>re
<input type="text" name="nga[%1\$d][del]" value="1">×<br>
<input type="hidden" name="nga[%1\$d][lasttime]" value="%6\$s">
<input type="hidden" name="nga[%1\$d][hits]" value="%7\$d">(%6\$d)<br>

EOP;
}
printf($row_format, -1, '', '', '', '', '--', 0);
echo $htm['form_submit'];
if (!empty($formdata)) {
    foreach ($formdata as $k => $v) {
        printf($row_format, $k, p2h($v['word']), $v['ignorecase'], $v['regex'], p2h($v['bbs']), p2h($v['lasttime']), p2h($v['hits']));
    }
    echo $htm['form_submit'];
}
// PCなら
if (!$_conf['ktai']) {
    echo '</table>' . "\n";
}
echo '</form>' . "\n";
// 携帯なら
if ($_conf['ktai']) {
    echo <<<EOP
<hr>
<a {$_conf['accesskey']}="{$_conf['k_accesskey']['up']}" href="editpref.php{$_conf['k_at_q']}">{$_conf['k_accesskey']['up']}.設定編集</a>
{$_conf['k_to_index_ht']}
EOP;
コード例 #12
0
    $row_format = <<<EOP
Mat:<input type="text" name="dat[%1\$d][match]" value="%2\$s"><br>
Rep:<input type="text" name="dat[%1\$d][replace]" value="%3\$s"><br>
Ref:<input type="text" name="dat[%1\$d][referer]" value="%4\$s"><br>
<input type="text" name="dat[%1\$d][extract]" value="{$EXTRACT}"%5\$s>Exp<br>
Src:<input type="text" name="dat[%1\$d][source]" value="%6\$s"><br>
<input type="text" name="dat[%1\$d][del]" value="1">×<br>


EOP;
}
printf($row_format, -1, '', '', '', '', '', '', '');
echo $htm['form_submit'];
if (!empty($formdata)) {
    foreach ($formdata as $k => $v) {
        printf($row_format, $k, p2h($v['match']), p2h($v['replace']), p2h($v['referer']), p2h($v['extract']), p2h($v['source']), $v['recheck'] ? ' checked' : '', p2h($v['ident']));
    }
    echo $htm['form_submit'];
}
// PCなら
if (!$_conf['ktai']) {
    echo '</table>' . "\n";
}
echo '</form>' . "\n";
// 携帯なら
if ($_conf['ktai']) {
    echo <<<EOP
<hr>
<a {$_conf['accesskey']}="{$_conf['k_accesskey']['up']}" href="editpref.php{$_conf['k_at_q']}">{$_conf['k_accesskey']['up']}.設定編集</a>
{$_conf['k_to_index_ht']}
EOP;
コード例 #13
0
ファイル: ShowBrdMenuK.php プロジェクト: xingskycn/p2-php
    /**
     * お気に板をプリントする for 携帯
     */
    public function printFavIta()
    {
        global $_conf;
        $show_flag = false;
        // favita読み込み
        if ($lines = FileCtl::file_read_lines($_conf['favita_brd'], FILE_IGNORE_NEW_LINES)) {
            if ($_conf['expack.misc.multi_favs']) {
                $favset_title = FavSetManager::getFavSetPageTitleHt('m_favita_set', 'お気に板');
            } else {
                $favset_title = 'お気に板';
            }
            echo "<div>{$favset_title}";
            if ($_conf['merge_favita']) {
                echo " (<a href=\"{$_conf['subject_php']}?spmode=merge_favita{$_conf['k_at_a']}{$_conf['m_favita_set_at_a']}\">まとめ</a>)";
            }
            echo " [<a href=\"editfavita.php{$_conf['k_at_q']}{$_conf['m_favita_set_at_a']}\">編集</a>]<hr>";
            $i = 0;
            foreach ($lines as $l) {
                $i++;
                if (preg_match("/^\t?(.+)\t(.+)\t(.+)\$/", $l, $matches)) {
                    $itaj = rtrim($matches[3]);
                    $itaj_view = p2h($itaj);
                    $itaj_en = UrlSafeBase64::encode($itaj);
                    if ($i <= 9) {
                        $accesskey_at = $_conf['k_accesskey_at'][$i];
                        $accesskey_st = $_conf['k_accesskey_st'][$i];
                    } else {
                        $accesskey_at = '';
                        $accesskey_st = '';
                    }
                    echo <<<EOP
<a href="{$_conf['subject_php']}?host={$matches[1]}&amp;bbs={$matches[2]}&amp;itaj_en={$itaj_en}{$_conf['k_at_a']}"{$accesskey_at}>{$accesskey_st}{$itaj_view}</a><br>
EOP;
                    //  [<a href="{$_SERVER['SCRIPT_NAME']}?host={$matches[1]}&amp;bbs={$matches[2]}&amp;setfavita=0&amp;view=favita{$_conf['k_at_a']}{$_conf['m_favita_set_at_a']}">削</a>]
                    $show_flag = true;
                }
            }
            echo "</div>";
        }
        if (empty($show_flag)) {
            echo "<p>お気に板はまだないようだ</p>";
        }
    }
コード例 #14
0
ファイル: sb_footer.inc.php プロジェクト: xingskycn/p2-php
    } elseif (P2Util::isHostMachiBbsNet($aThreadList->host)) {
        // まちビねっと
        $ini_url_text = "http://{$aThreadList->host}/test/read.cgi?bbs={$aThreadList->bbs}&key=";
    } else {
        $ini_url_text = "http://{$aThreadList->host}/test/read.cgi/{$aThreadList->bbs}/";
    }
}
//if(!$aThreadList->spmode || $aThreadList->spmode=="fav" || $aThreadList->spmode=="recent" || $aThreadList->spmode=="res_hist"){
$onclick_ht = <<<EOP
var url_v=document.forms["urlform"].elements["url_text"].value;
if (url_v=="" || url_v=="{$ini_url_text}") {
    alert("見たいスレッドのURLを入力して下さい。 例:http://pc.2ch.net/test/read.cgi/mac/1034199997/");
    return false;
}
EOP;
$onclick_ht = p2h($onclick_ht);
echo <<<EOP
    <form id="urlform" method="GET" action="{$_conf['read_php']}" target="read">
            スレURLを直接指定
            <input id="url_text" type="text" value="{$ini_url_text}" name="url" size="62">
            <input type="submit" name="btnG" value="表\示" onclick="{$onclick_ht}">
    </form>

EOP;
if ($aThreadList->spmode == 'fav' && $_conf['expack.misc.multi_favs']) {
    echo "\t<div style=\"margin:8px 8px;\">\n";
    echo FavSetManager::makeFavSetSwitchForm('m_favlist_set', 'お気にスレ', null, null, false, array('spmode' => 'fav', 'norefresh' => 1));
    echo "\t</div>\n";
}
//}
//================
コード例 #15
0
ファイル: sb_footer_k.inc.php プロジェクト: xingskycn/p2-php
if (!$aThreadList->spmode || $aThreadList->spmode == "taborn" || $aThreadList->spmode == "soko") {
    $htm['change_sort'] .= "<input type=\"hidden\" name=\"host\" value=\"{$aThreadList->host}\">";
    $htm['change_sort'] .= "<input type=\"hidden\" name=\"bbs\" value=\"{$aThreadList->bbs}\">";
}
$htm['change_sort'] .= '<select name="sort">';
foreach ($sorts as $k => $v) {
    if ($GLOBALS['now_sort'] == $k) {
        $sb_sort_selected_at = ' selected';
    } else {
        $sb_sort_selected_at = '';
    }
    $htm['change_sort'] .= "<option value=\"{$k}\"{$sb_sort_selected_at}>{$v}</option>";
}
$htm['change_sort'] .= '</select>';
if (!empty($_REQUEST['sb_view'])) {
    $htm['change_sort'] .= '<input type="hidden" name="sb_view" value="' . p2h($_REQUEST['sb_view']) . '">';
}
if (!empty($_REQUEST['rsort'])) {
    $sb_rsort_checked_at = ' checked';
} else {
    $sb_rsort_checked_at = '';
}
$htm['change_sort'] .= ' <input type="checkbox" id="sb_rsort" name="rsort" value="1"' . $sb_rsort_checked_at . '><label for="sb_rsort">逆順</label>';
$htm['change_sort'] .= ' <input type="submit" value="並び替え"></form>';
// }}}
// HTMLプリント ==============================================
echo '<hr>';
echo $k_sb_navi_ht;
include P2_LIB_DIR . '/sb_toolbar_k.inc.php';
echo $allfav_ht;
echo $switchfavlist_ht;
コード例 #16
0
ファイル: ShowThreadPc.php プロジェクト: xingskycn/p2-php
 /**
  * 置換画像URL+ImageCache2
  */
 public function plugin_replaceImageUrl($url, $purl, $str)
 {
     static $serial = 0;
     global $_conf;
     global $pre_thumb_unlimited, $pre_thumb_ignore_limit, $pre_thumb_limit;
     // +Wiki
     global $replaceImageUrlCtl;
     $url = $purl[0];
     $replaced = $replaceImageUrlCtl->replaceImageUrl($url);
     if (!$replaced[0]) {
         return false;
     }
     foreach ($replaced as $v) {
         $url_en = rawurlencode($v['url']);
         $url_ht = p2h($v['url']);
         $ref_en = $v['referer'] ? '&amp;ref=' . rawurlencode($v['referer']) : '';
         // 準備
         $serial++;
         $thumb_id = 'thumbs' . $serial . $this->thumb_id_suffix;
         $tmp_thumb = './img/ic_load.png';
         $icdb = new ImageCache2_DataObject_Images();
         // r=0:リンク;r=1:リダイレクト;r=2:PHPで表示
         // t=0:オリジナル;t=1:PC用サムネイル;t=2:携帯用サムネイル;t=3:中間イメージ
         // +Wiki
         $img_url = 'ic2.php?r=1&amp;uri=' . $url_en . $ref_en;
         $thumb_url = 'ic2.php?r=1&amp;t=1&amp;uri=' . $url_en . $ref_en;
         // お気にスレ自動画像ランク
         $rank = null;
         if ($_conf['expack.ic2.fav_auto_rank']) {
             $rank = $this->getAutoFavRank();
             if ($rank !== null) {
                 $thumb_url .= '&rank=' . $rank;
             }
         }
         // DBに画像情報が登録されていたとき
         if ($icdb->get($v['url'])) {
             // ウィルスに感染していたファイルのとき
             if ($icdb->mime == 'clamscan/infected') {
                 $result .= "<img class=\"thumbnail\" src=\"./img/x04.png\" width=\"32\" height=\"32\" hspace=\"4\" vspace=\"4\" align=\"middle\">";
                 continue;
             }
             // あぼーん画像のとき
             if ($icdb->rank < 0) {
                 $result .= "<img class=\"thumbnail\" src=\"./img/x01.png\" width=\"32\" height=\"32\" hspace=\"4\" vspace=\"4\" align=\"middle\">";
                 continue;
             }
             // オリジナルがキャッシュされているときは画像を直接読み込む
             $_img_url = $this->thumbnailer->srcUrl($icdb->size, $icdb->md5, $icdb->mime);
             if (file_exists($_img_url)) {
                 $img_url = $_img_url;
                 $cached = true;
             } else {
                 $cached = false;
             }
             // サムネイルが作成されていているときは画像を直接読み込む
             $_thumb_url = $this->thumbnailer->thumbUrl($icdb->size, $icdb->md5, $icdb->mime);
             if (file_exists($_thumb_url)) {
                 $thumb_url = $_thumb_url;
                 // 自動スレタイメモ機能がONでスレタイが記録されていないときはDBを更新
                 if (!is_null($this->img_memo) && strpos($icdb->memo, $this->img_memo) === false) {
                     $update = new ImageCache2_DataObject_Images();
                     if (!is_null($icdb->memo) && strlen($icdb->memo) > 0) {
                         $update->memo = $this->img_memo . ' ' . $icdb->memo;
                     } else {
                         $update->memo = $this->img_memo;
                     }
                     $update->whereAddQuoted('uri', '=', $v['url']);
                 }
                 // expack.ic2.fav_auto_rank_override の設定とランク条件がOKなら
                 // お気にスレ自動画像ランクを上書き更新
                 if ($rank !== null && self::isAutoFavRankOverride($icdb->rank, $rank)) {
                     if ($update === null) {
                         $update = new ImageCache2_DataObject_Images();
                         $update->whereAddQuoted('uri', '=', $v['url']);
                     }
                     $update->rank = $rank;
                 }
                 if ($update !== null) {
                     $update->update();
                 }
             }
             // サムネイルの画像サイズ
             $thumb_size = $this->thumbnailer->calc($icdb->width, $icdb->height);
             $thumb_size = preg_replace('/(\\d+)x(\\d+)/', 'width="$1" height="$2"', $thumb_size);
             $tmp_thumb = './img/ic_load1.png';
             $orig_img_url = $img_url;
             $orig_thumb_url = $thumb_url;
             // 画像がキャッシュされていないとき
             // 自動スレタイメモ機能がONならクエリにUTF-8エンコードしたスレタイを含める
         } else {
             // 画像がブラックリストorエラーログにあるか確認
             if (false !== ($errcode = $icdb->ic2_isError($v['url']))) {
                 $result .= "<img class=\"thumbnail\" src=\"./img/{$errcode}.png\" width=\"32\" height=\"32\" hspace=\"4\" vspace=\"4\" align=\"middle\">";
                 continue;
             }
             $cached = false;
             $orig_img_url = $img_url;
             $orig_thumb_url = $thumb_url;
             $img_url .= $this->img_memo_query;
             $thumb_url .= $this->img_memo_query;
             $thumb_size = '';
             $tmp_thumb = './img/ic_load2.png';
         }
         // キャッシュされておらず、表示数制限が有効のとき
         if (!$cached && !$pre_thumb_unlimited && !$pre_thumb_ignore_limit) {
             // 表示制限を超えていたら、表示しない
             // 表示制限を超えていなければ、表示制限カウンタを下げる
             if ($pre_thumb_limit <= 0) {
                 $show_thumb = false;
             } else {
                 $show_thumb = true;
                 $pre_thumb_limit--;
             }
         } else {
             $show_thumb = true;
         }
         // 表示モード
         if ($show_thumb) {
             $img_tag = "<img class=\"thumbnail\" src=\"{$thumb_url}\" {$thumb_size} hspace=\"4\" vspace=\"4\" align=\"middle\">";
             if ($_conf['iframe_popup']) {
                 $view_img = $this->imageHtmlPopup($img_url, $img_tag, '');
             } else {
                 $view_img = "<a href=\"{$img_url}\"{$_conf['ext_win_target_at']}>{$img_tag}</a>";
             }
         } else {
             $img_tag = "<img id=\"{$thumb_id}\" class=\"thumbnail\" src=\"{$tmp_thumb}\" width=\"32\" height=\"32\" hspace=\"4\" vspace=\"4\" align=\"middle\">";
             $view_img = "<a href=\"{$img_url}\" onclick=\"return loadThumb('{$thumb_url}','{$thumb_id}')\"{$_conf['ext_win_target_at']}>{$img_tag}</a><a href=\"{$img_url}\"{$_conf['ext_win_target_at']}></a>";
         }
         $view_img .= '<img class="ic2-info-opener" src="img/s2a.png" width="16" height="16" onclick="ic2info.show(' . "'{$url_ht}', event)\">";
         $result .= $view_img;
     }
     // ソースへのリンクをime付きで表示
     $ime_url = P2Util::throughIme($url);
     $result .= "<a class=\"img_through_ime\" href=\"{$ime_url}\"{$_conf['ext_win_target_at']}>{$str}</a>";
     return $result;
 }
コード例 #17
0
ファイル: title.php プロジェクト: xingskycn/p2-php
    if (t) {
        t.resizeTo(w, v);
        t.focus();
        return false;
    } else {
        return true;
    }
})
JS;
$bookmarklet = preg_replace('/\\b(var|return|typeof) +/', '$1{%space%}', $bookmarklet);
$bookmarklet = preg_replace('/\\s+/', '', $bookmarklet);
$bookmarklet = str_replace('{%space%}', ' ', $bookmarklet);
$bookmarklet_k = $bookmarklet . "('{$url_b}k',240,320,20,-100)";
$bookmarklet_i = $bookmarklet . "('{$url_b}i',320,480,20,-100)";
$bookmarklet_k_ht = p2h($bookmarklet_k);
$bookmarklet_i_ht = p2h($bookmarklet_i);
$bookmarklet_k_en = rawurlencode($bookmarklet_k);
$bookmarklet_i_en = rawurlencode($bookmarklet_i);
$htm['ktai_url'] = <<<EOT
<table border="0" cellspacing="0" cellpadding="1">
    <tbody>
        <tr>
            <th>携帯用URL:</th>
            <td><a href="{$url_b_ht}k" target="_blank" onclick="return {$bookmarklet_k_ht};">{$url_b_ht}k</a></td>
            <td>[<a href="javascript:{$bookmarklet_k_en};">bookmarklet</a>]</td>
        </tr>
        <tr>
            <th>iPhone用URL:</th>
            <td><a href="{$url_b_ht}i" target="_blank" onclick="return {$bookmarklet_i_ht};">{$url_b_ht}i</a></td>
            <td>[<a href="javascript:{$bookmarklet_i_en};">bookmarklet</a>]</td>
        </tr>
コード例 #18
0
ファイル: ShowThread.php プロジェクト: xingskycn/p2-php
 /**
  * リンク対象文字列の種類を判定して対応した関数/メソッドに渡す
  *
  * @param   array   $s
  * @return  string
  */
 public function transLinkDo(array $s)
 {
     global $_conf;
     $orig = $s[0];
     $following = '';
     // PHP 5.2.7 未満の preg_replace_callback() では名前付き捕獲式集合が使えないので
     /*
     if (!array_key_exists('link', $s)) {
         $s['link']  = $s[1];
         $s['quote'] = $s[5];
         $s['url']   = $s[8];
         $s['id']    = $s[11];
     }
     */
     // マッチしたサブパターンに応じて分岐
     // リンク
     if ($s['link']) {
         if (preg_match('{ href=(["\'])?(.+?)(?(1)\\1)(?=[ >])}i', $s[2], $m)) {
             $url = $m[2];
             $str = $s[3];
         } else {
             return $s[3];
         }
         // 引用
     } elseif ($s['quote']) {
         return preg_replace_callback(self::getAnchorRegex('/(%prefix%)?(%a_range%)/'), array($this, '_quoteResCallback'), $s['quote']);
         // http or ftp のURL
     } elseif ($s['url']) {
         if ($_conf['ktai'] && $s[9] == 'ftp') {
             return $orig;
         }
         $url = preg_replace('/^t?(tps?)$/', 'ht$1', $s[9]) . '://' . $s[10];
         $str = $s['url'];
         $following = $s[11];
         if (strlen($following) > 0) {
             // ウィキペディア日本語版のURLで、SJISの2バイト文字の上位バイト
             // (0x81-0x9F,0xE0-0xEF)が続くとき
             if (P2Util::isUrlWikipediaJa($url)) {
                 $leading = ord($following);
                 if (($leading ^ 0x90) < 32 && $leading != 0x80 || ($leading ^ 0xe0) < 16) {
                     $url .= rawurlencode(mb_convert_encoding($following, 'UTF-8', 'CP932'));
                     $str .= $following;
                     $following = '';
                 }
             } elseif (strpos($following, 'tp://') !== false) {
                 // 全角スペース+URL等の場合があるので再チェック
                 $following = $this->transLink($following);
             }
         }
         // ID
     } elseif ($s['id'] && $_conf['flex_idpopup']) {
         // && $_conf['flex_idlink_k']
         return $this->idFilter($s['id'], $s[12]);
         // その他(予備)
     } else {
         return strip_tags($orig);
     }
     // リダイレクタを外す
     switch ($this->_redirector) {
         case self::REDIRECTOR_IMENU:
             $url = preg_replace('{^([a-z]+://)ime\\.nu/}', '$1', $url);
             break;
         case self::REDIRECTOR_PINKTOWER:
             $url = preg_replace('{^([a-z]+://)pinktower\\.com/}', '$1', $url);
             break;
         case self::REDIRECTOR_MACHIBBS:
             $url = preg_replace('{^[a-z]+://machi(?:bbs\\.com|\\.to)/bbs/link\\.cgi\\?URL=}', '', $url);
             break;
     }
     // エスケープされていない特殊文字をエスケープ
     $url = p2h($url, false);
     $str = p2h($str, false);
     // 実態参照・数値参照を完全にデコードしようとすると負荷が大きいし、
     // "&"以外の特殊文字はほとんどの場合URLエンコードされているはずなので
     // 中途半端に凝った処理はせず、"&amp;"→"&"のみ再変換する。
     $raw_url = str_replace('&amp;', '&', $url);
     // URLをパース・ホストを検証
     $purl = @parse_url($raw_url);
     if (!$purl || !array_key_exists('host', $purl) || strpos($purl['host'], '.') === false || $purl['host'] == '127.0.0.1' || P2Util::isHostExample($purl['host'])) {
         return $orig;
     }
     // URLのマッチングで"&amp;"を考慮しなくて済むように、生のURLを登録しておく
     $purl[0] = $raw_url;
     // URLを処理
     foreach ($this->_user_url_handlers as $handler) {
         if (false !== ($link = call_user_func($handler, $url, $purl, $str, $this))) {
             return $link . $following;
         }
     }
     foreach ($this->_url_handlers as $handler) {
         if (false !== ($link = $this->{$handler}($url, $purl, $str))) {
             return $link . $following;
         }
     }
     return $orig;
 }
コード例 #19
0
ファイル: ic2_getter.php プロジェクト: xingskycn/p2-php
if ($execDL) {
    if (is_null($serial)) {
        $URLs = array($params['uri']);
    } else {
        $URLs = array();
        for ($i = $serial['from']; $i <= $serial['to']; $i++) {
            // URLエンコードされた文字列も%を含むので sprintf() は使わない。
            // URLエンコードのフォーマットは%+16進数なので"%s"を置換しても影響しない。
            $URLs[] = str_replace('%s', str_pad($i, $serial['pad'], '0', STR_PAD_LEFT), $params['uri']);
        }
    }
    $thumbnailer = new ImageCache2_Thumbnailer($thumb_type);
    $images = array();
    foreach ($URLs as $url) {
        $icdb = new ImageCache2_DataObject_Images();
        $img_title = p2h($url);
        $url_en = rawurlencode($url);
        $src_url = 'ic2.php?r=1&uri=' . $url_en;
        $thumb_url = 'ic2.php?r=1&t=' . $thumb_type . '&uri=' . $url_en;
        $thumb_x = '';
        $thumb_y = '';
        $img_memo = $new_memo;
        // 画像がブラックリストorエラーログにあるとき
        if (false !== ($errcode = $icdb->ic2_isError($url))) {
            $img_title = "<s>{$img_title}</s>";
            $thumb_url = "./img/{$errcode}.png";
            // 既にキャッシュされているとき
        } elseif ($icdb->get($url)) {
            $_src_path = $thumbnailer->srcPath($icdb->size, $icdb->md5, $icdb->mime);
            if (file_exists($_src_path)) {
                $src_url = $thumbnailer->srcUrl($icdb->size, $icdb->md5, $icdb->mime);
コード例 #20
0
ファイル: read.inc.php プロジェクト: xingskycn/p2-php
function rss_print_content($item, $num, $count)
{
    $item = array_map('trim', $item);
    // 変数の初期化
    $date_ht = '';
    $subject_ht = '';
    $creator_ht = '';
    $description_ht = '';
    $prev_item_ht = '';
    $next_item_ht = '';
    // リンク
    $item_title = p2h($item['title'], false);
    // タイトル
    $link_orig = P2Util::throughIme($item['link']);
    // トピック
    if (isset($item['dc:subject'])) {
        $subject_ht = $item['dc:subject'];
    }
    // 文責
    if (isset($item['dc:creator']) && $item['dc:creator'] !== '') {
        $creator_ht = "<b class=\"name\">" . trim($item['dc:creator']) . "</b>:";
    }
    // 日時
    if (!empty($item['dc:date'])) {
        $date_ht = rss_format_date($item['dc:date']);
    } elseif (!empty($item['dc:pubdate'])) {
        $date_ht = rss_format_date($item['dc:pubdate']);
    }
    // 概要
    if (isset($item['content:encoded']) && $item['content:encoded'] !== '') {
        $description_ht = rss_desc_converter($item['content:encoded']);
    } elseif (isset($item['description']) && $item['description'] !== '') {
        $description_ht = rss_desc_converter($item['description']);
    }
    // 前後の概要へジャンプ
    if ($count != 0) {
        $prev_item_num = $num - 1;
        $next_item_num = $num + 1;
        if ($prev_item_num != 0) {
            $prev_item_ht = "<a href=\"#it{$prev_item_num}\">▲</a>";
        }
        if ($next_item_num <= $count) {
            $next_item_ht = "<a href=\"#it{$next_item_num}\">▼</a>";
        }
    }
    // 表示
    echo <<<EOP
<table id="it{$num}" width="100%">
    <tr>
        <td align="left"><h3 class="thread_title">{$item_title}</h3></td>
        <td align="right" nowrap>{$prev_item_ht} {$next_item_ht}</td>
    </tr>
</table>
<div style="margin:0.5em">{$creator_ht}{$date_ht} <a href="{$link_orig}">[LINK]</a></div>
<div style="margin:1em 1em 1em 2em">
{$description_ht}
</div>
<div style="text-align:right"><a href="#it{$num}">▲</a></div>

EOP;
    if ($count != 0 && $num != $count) {
        echo "\n<hr style=\"margin:20px 0px\">\n\n";
    }
}
コード例 #21
0
ファイル: setfav.inc.php プロジェクト: xingskycn/p2-php
/**
 * お気にスレをセットする
 *
 * @param   string      $host
 * @param   string      $bbs
 * @param   string      $key
 * @param   int|string  $setfavita  0(解除), 1(追加), 2(トグル), top, up, down, bottom
 * @param   string      $ttitle
 * @param   int|null    $setnum
 * @return  bool
 */
function setFav($host, $bbs, $key, $setfav, $ttitle = null, $setnum = null)
{
    global $_conf;
    //==================================================================
    // key.idx
    //==================================================================
    // idxfileのパスを求めて
    $idxfile = P2Util::idxDirOfHostBbs($host, $bbs) . $key . '.idx';
    // 板ディレクトリが無ければ作る
    // FileCtl::mkdirFor($idxfile);
    // 既にidxデータがあるなら読み込む
    if ($lines = FileCtl::file_read_lines($idxfile, FILE_IGNORE_NEW_LINES)) {
        $data = explode('<>', $lines[0]);
    } else {
        $data = array_fill(0, 12, '');
        if (is_string($ttitle) && strlen($ttitle)) {
            $data[0] = p2h($ttitle, false);
        }
    }
    // {{{ スレッド.idx 記録
    if (($setfav == '0' || $setfav == '1') && $_conf['favlist_idx'] == $_conf['orig_favlist_idx']) {
        // お気にスレから外した結果、idxの意味がなくなれば削除する
        if ($setfav == '0' and !$data[3] && !$data[4] && $data[9] <= 1) {
            @unlink($idxfile);
        } else {
            $sar = array($data[0], $key, $data[2], $data[3], $data[4], $data[5], $setfav, $data[7], $data[8], $data[9], $data[10], $data[11], $data[12]);
            P2Util::recKeyIdx($idxfile, $sar);
        }
    }
    // }}}
    //==================================================================
    // favlist.idx
    //==================================================================
    if (!is_null($setnum) && $_conf['expack.misc.multi_favs']) {
        if (0 < $setnum && $setnum <= $_conf['expack.misc.favset_num']) {
            $favlist_idx = $_conf['pref_dir'] . sprintf('/p2_favlist%d.idx', $setnum);
        } else {
            $favlist_idx = $_conf['orig_favlist_idx'];
        }
    } else {
        $favlist_idx = $_conf['favlist_idx'];
    }
    // favlistファイルがなければ生成
    FileCtl::make_datafile($favlist_idx);
    // favlist読み込み
    $favlines = FileCtl::file_read_lines($favlist_idx, FILE_IGNORE_NEW_LINES);
    //================================================
    // 処理
    //================================================
    $neolines = array();
    $before_line_num = 0;
    $was_set = false;
    // 最初に重複要素を削除しておく
    if (!empty($favlines)) {
        $i = -1;
        foreach ($favlines as $l) {
            $i++;
            $lar = explode('<>', $l);
            // 重複回避
            if ($lar[1] == $key && $lar[11] == $bbs) {
                $before_line_num = $i;
                // 移動前の行番号をセット
                $was_set = true;
                continue;
                // keyのないものは不正データなのでスキップ
            } elseif (!$lar[1]) {
                continue;
            } else {
                $neolines[] = $l;
            }
        }
    }
    if ($setfav == 2) {
        $setfav = $was_set ? 0 : 1;
    }
    // 記録データ設定
    if ($setfav) {
        if (!function_exists('getSetPosLines')) {
            include P2_LIB_DIR . '/getsetposlines.inc.php';
        }
        $newdata = "{$data[0]}<>{$key}<>{$data[2]}<>{$data[3]}<>{$data[4]}<>{$data[5]}<>1<>{$data[7]}<>{$data[8]}<>{$data[9]}<>{$host}<>{$bbs}";
        $rec_lines = getSetPosLines($neolines, $newdata, $before_line_num, $setfav);
    } else {
        $rec_lines = $neolines;
    }
    $cont = '';
    if (!empty($rec_lines)) {
        foreach ($rec_lines as $l) {
            $cont .= $l . "\n";
        }
    }
    // 書き込む
    if (FileCtl::file_write_contents($favlist_idx, $cont) === false) {
        p2die('cannot write file.');
    }
    //================================================
    // お気にスレ共有
    //================================================
    if ($_conf['join_favrank'] && $_conf['favlist_idx'] == $_conf['orig_favlist_idx']) {
        if ($setfav == "0") {
            $act = "out";
        } elseif ($setfav == "1") {
            $act = "add";
        } else {
            return;
        }
        $itaj = P2Util::getItaName($host, $bbs);
        $post = array("host" => $host, "bbs" => $bbs, "key" => $key, "ttitle" => $data[0], "ita" => $itaj, "act" => $act);
        postFavRank($post);
    }
    return true;
}
コード例 #22
0
ファイル: editfavita.php プロジェクト: xingskycn/p2-php
// NOSCRIPT時のHTML表示
//================================================================
if ($lines) {
    // PC(NetFrontを除外)
    if (!$_conf['ktai'] && $_conf['favita_order_dnd'] && !P2Util::isNetFront()) {
        echo '<noscript>';
    }
    echo 'お気に板の並び替え';
    echo '<table>';
    foreach ($lines as $l) {
        if (preg_match('/^\\t?(.+?)\\t(.+?)\\t(.+?)$/', rtrim($l), $matches)) {
            $itaj = rtrim($matches[3]);
            $itaj_en = UrlSafeBase64::encode($itaj);
            $host = $matches[1];
            $bbs = $matches[2];
            $itaj_view = p2h($itaj);
            $itaj_q = '&amp;itaj_en=' . $itaj_en;
            echo <<<EOP
            <tr>
            <td><a href="{$_conf['subject_php']}?host={$host}&amp;bbs={$bbs}{$_conf['k_at_a']}">{$itaj_view}</a></td>
            <td>[ <a class="te" href="{$_SERVER['SCRIPT_NAME']}?host={$host}&amp;bbs={$bbs}{$itaj_q}&amp;setfavita=top{$_conf['k_at_a']}" title="一番上に移動">▲</a></td>
            <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?host={$host}&amp;bbs={$bbs}{$itaj_q}&amp;setfavita=up{$_conf['k_at_a']}" title="一つ上に移動">↑</a></td>
            <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?host={$host}&amp;bbs={$bbs}{$itaj_q}&amp;setfavita=down{$_conf['k_at_a']}" title="一つ下に移動">↓</a></td>
            <td><a class="te" href="{$_SERVER['SCRIPT_NAME']}?host={$host}&amp;bbs={$bbs}{$itaj_q}&amp;setfavita=bottom{$_conf['k_at_a']}" title="一番下に移動">▼</a> ]</td>
            <td>[<a href="{$_SERVER['SCRIPT_NAME']}?host={$host}&amp;bbs={$bbs}&amp;setfavita=0{$_conf['k_at_a']}">削除</a>]</td>
            </tr>
EOP;
        }
    }
    echo "</table>";
    // PC(NetFrontを除外)
コード例 #23
0
ファイル: read_filter_k.php プロジェクト: xingskycn/p2-php
<?php

/**
 * rep2 - 携帯版レスフィルタリング
 */
require_once __DIR__ . '/../init.php';
$_login->authorize();
// ユーザ認証
/**
 * スレッド情報
 */
$host = $_GET['host'];
$bbs = $_GET['bbs'];
$key = $_GET['key'];
$ttitle = UrlSafeBase64::decode($_GET['ttitle_en']);
$ttitle_back = isset($_SERVER['HTTP_REFERER']) ? '<a href="' . p2h($_SERVER['HTTP_REFERER']) . '" title="戻る">' . $ttitle . '</a>' : $ttitle;
$hidden_fields_ht = ResFilterElement::getHiddenFields($host, $bbs, $key);
if ($_conf['iphone']) {
    $word_field_ht = ResFilterElement::getWordField(array('autocorrect' => 'off', 'autocapitalize' => 'off'));
} else {
    $word_field_ht = ResFilterElement::getWordField();
}
$field_field_ht = ResFilterElement::getFieldField();
$method_field_ht = ResFilterElement::getMethodField();
$match_field_ht = ResFilterElement::getMatchField();
$include_field_ht = ResFilterElement::getIncludeField();
/**
 * 検索フォームを表示
 */
P2Util::header_nocache();
echo $_conf['doctype'];
コード例 #24
0
ファイル: FavSetManager.php プロジェクト: xingskycn/p2-php
 /**
  * お気にスレ、お気に板、RSSのセットリストを切り替えるフォームを生成する
  *
  * @param string $set_name
  * @param string $set_title
  * @param string $script
  * @param bool $inline
  * @param array $hidden_values
  * @return string
  */
 public static function makeFavSetSwitchForm($set_name, $set_title, $script = null, $target = null, $inline = false, array $hidden_values = null)
 {
     global $_conf;
     // 変数初期化
     if (!$script) {
         $script = $_SERVER['SCRIPT_NAME'];
     }
     if (!$target) {
         $target = '_self';
     }
     $style = $inline ? ' style="display:inline;"' : '';
     // フォーム作成
     $form_ht = "<form method=\"get\" action=\"{$script}\" target=\"{$target}\"{$style}>";
     $form_ht .= $_conf['k_input_ht'];
     if (is_array($hidden_values)) {
         foreach ($hidden_values as $key => $value) {
             $value = p2h($value);
             $form_ht .= "<input type=\"hidden\" name=\"{$key}\" value=\"{$value}\">";
         }
     }
     $form_ht .= FavSetManager::makeFavSetSwitchElem($set_name, $set_title, true);
     $submit_value = $_conf['ktai'] ? 'セット切替' : 'セット切替';
     $form_ht .= "<input type=\"submit\" value=\"{$submit_value}\"></form>\n";
     return $form_ht;
 }
コード例 #25
0
ファイル: P2Ime.php プロジェクト: xingskycn/p2-php
 /**
  * URLを変換する
  *
  * @param string $url
  * @param int $delay
  * @param bool $escape
  * @return string
  */
 public function through($url, $delay = null, $escape = true)
 {
     if ($delay === null) {
         if ($this->_isExceptionUrl($url)) {
             $delay = -1;
         } else {
             $delay = $this->_delay;
         }
     }
     if (!($this->_ignoreHttp && preg_match('!^http://!', $url))) {
         $url = $this->{$this->_method}($url, $delay);
     }
     if ($escape) {
         return p2h($url, false);
     } else {
         return $url;
     }
 }
コード例 #26
0
ファイル: read_header.inc.php プロジェクト: xingskycn/p2-php
<form method="get" action="{$_conf['read_php']}" class="inline-form">
    <input type="hidden" name="host" value="{$aThread->host}">
    <input type="hidden" name="bbs" value="{$aThread->bbs}">
    <input type="hidden" name="key" value="{$aThread->key}">
    <input type="text" size="7" name="ls" value="{$aThread->ls}">
    {$_conf['k_input_ht']}
    <input type="submit" value="go">
</form>
GOTO;
//====================================================================
// HTMLプリント
//====================================================================
// ツールバー部分HTML =======
// お気にマーク設定
$similar_q = '&amp;itaj_en=' . UrlSafeBase64::encode($aThread->itaj) . '&amp;method=similar&amp;word=' . rawurlencode($aThread->ttitle_hc) . '&amp;refresh=1';
$itaj_hd = p2h($aThread->itaj);
if ($_conf['expack.misc.multi_favs']) {
    $favlist_titles = FavSetManager::getFavSetTitles('m_favlist_set');
    $toolbar_setfav_ht = 'お気に[';
    $favdo = !empty($aThread->favs[0]) ? 0 : 1;
    $favdo_q = '&amp;setfav=' . $favdo;
    $favmark = $favdo ? '+' : '★';
    $favtitle = (!isset($favlist_titles[0]) || $favlist_titles[0] == '' ? 'お気にスレ' : $favlist_titles[0]) . ($favdo ? 'に追加' : 'から外す');
    $setnum_q = '&amp;setnum=0';
    $toolbar_setfav_ht .= <<<EOP
<span class="favdo set0"><a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$favdo_q}{$setnum_q}" target="info" onclick="return setFavJs('{$host_bbs_key_q}{$ttitle_en_q}', '{$favdo}', {$STYLE['info_pop_size']}, 'read', this, '0');" title="{$favtitle}">{$favmark}</a></span>
EOP;
    for ($i = 1; $i <= $_conf['expack.misc.favset_num']; $i++) {
        $favdo = !empty($aThread->favs[$i]) ? 0 : 1;
        $favdo_q = '&amp;setfav=' . $favdo;
        $favmark = $favdo ? $i : '★';
コード例 #27
0
ファイル: edit_conf_user.php プロジェクト: xingskycn/p2-php
/**
 * 編集フォームradio用HTMLを得る
 *
 * @param   stirng  $name   設定項目名
 * @return  string
 */
function getEditConfRadHtml($name)
{
    global $_conf, $conf_user_def, $conf_user_rad;
    $form_ht = '';
    foreach ($conf_user_rad[$name] as $key => $value) {
        /*
        if ($value == "") {
            continue;
        }
        */
        $checked = "";
        if ($_conf[$name] == $key) {
            $checked = " checked";
        }
        $key_ht = p2h($key);
        $value_ht = p2h($value);
        if ($_conf['iphone']) {
            $form_ht .= "<input type=\"radio\" name=\"conf_edit[{$name}]\" value=\"{$key_ht}\"{$checked}><span onclick=\"if(!this.previousSibling.checked)this.previousSibling.checked=true;\">{$value_ht}</span>\n";
        } else {
            $form_ht .= "<label><input type=\"radio\" name=\"conf_edit[{$name}]\" value=\"{$key_ht}\"{$checked}>{$value_ht}</label>\n";
        }
    }
    // foreach
    return $form_ht;
}
コード例 #28
0
ファイル: toolbar_i.inc.php プロジェクト: xingskycn/p2-php
/**
 * 外部アプリ等でスレッドを開くボタン
 *
 * @param string $icon
 * @param string $label (fallback)
 * @param Thread $aThread
 * @return string
 */
function toolbar_i_action_thread_button($icon, $label, Thread $aThread)
{
    global $_conf;
    $type = _toolbar_i_client_type();
    $pattern = $_conf["expack.tba.{$type}.thread_uri"];
    if (!$pattern) {
        return toolbar_i_disabled_button($icon, $label);
    }
    $url = $aThread->getMotoThread(true, '');
    $uri = p2h(strtr($pattern, array('$time' => time(), '$host' => rawurlencode($aThread->host), '$bbs' => rawurlencode($aThread->bbs), '$key' => rawurlencode($aThread->key), '$ls' => rawurlencode($aThread->ls), '$url' => $url, '$eurl' => rawurlencode($url), '$path' => preg_replace('!^https?://!', '', $url))), false);
    $title = $_conf["expack.tba.{$type}.thread_title"];
    if ($title !== '') {
        $label = p2h($title, false);
    }
    return _toolbar_i_button($icon, $label, $uri);
}
コード例 #29
0
ファイル: sb_print_k.inc.php プロジェクト: xingskycn/p2-php
/**
 * sb_print - スレッド一覧を表示する (<tr>〜</tr>)
 */
function sb_print_k($aThreadList)
{
    global $_conf, $sb_view, $p2_setting, $STYLE;
    global $sb_view;
    //=================================================
    if (!$aThreadList->threads) {
        if ($_conf['iphone']) {
            if ($aThreadList->spmode == 'fav' && $sb_view == 'shinchaku') {
                echo '<p class="empty">お気にスレに新着なかったぽ</p>';
            } else {
                echo '<p class="empty">該当サブジェクトはなかったぽ</p>';
            }
        } else {
            if ($aThreadList->spmode == 'fav' && $sb_view == 'shinchaku') {
                echo '<p>お気にスレに新着なかったぽ</p>';
            } else {
                echo '<p>該当サブジェクトはなかったぽ</p>';
            }
        }
        return;
    }
    // 変数 ================================================
    $only_one_bool = false;
    $ita_name_bool = false;
    $sortq_spmode = '';
    $sortq_host = '';
    $sortq_ita = '';
    // >>1
    if (strpos($aThreadList->bbs, 'news') !== false || $aThreadList->bbs == 'bizplus') {
        // 倉庫は除く
        if ($aThreadList->spmode != 'soko') {
            $only_one_bool = true;
        }
    }
    // 板名
    if ($aThreadList->spmode and $aThreadList->spmode != 'taborn' and $aThreadList->spmode != 'soko') {
        $ita_name_bool = true;
    }
    $norefresh_q = '&amp;norefresh=1';
    // ソート ==================================================
    // スペシャルモード時
    if ($aThreadList->spmode) {
        $sortq_spmode = "&amp;spmode={$aThreadList->spmode}";
        // あぼーんなら
        if ($aThreadList->spmode == "taborn" or $aThreadList->spmode == "soko") {
            $sortq_host = "&amp;host={$aThreadList->host}";
            $sortq_ita = "&amp;bbs={$aThreadList->bbs}";
        }
    } else {
        $sortq_host = "&amp;host={$aThreadList->host}";
        $sortq_ita = "&amp;bbs={$aThreadList->bbs}";
    }
    $midoku_sort_ht = "<a href=\"{$_conf['subject_php']}?sort=midoku{$sortq_spmode}{$sortq_host}{$sortq_ita}{$norefresh_q}{$_conf['k_at_a']}\">新着</a>";
    //=====================================================
    // ボディ
    //=====================================================
    // spmodeがあればクエリー追加
    if ($aThreadList->spmode) {
        $spmode_q = "&amp;spmode={$aThreadList->spmode}";
    }
    if ($aThreadList->spmode == 'palace' || $aThreadList->spmode == 'soko' || $aThreadList->spmode == 'taborn') {
        $show_unum = false;
    } else {
        $show_unum = true;
    }
    if ($_conf['iphone']) {
        echo '<ul class="subject">';
    }
    $i = 0;
    foreach ($aThreadList->threads as $aThread) {
        $i++;
        $midoku_ari = '';
        $anum_ht = '';
        //#r1
        $htm = array('ita' => '', 'rnum' => '', 'unum' => '', 'sim' => '');
        $bbs_q = '&amp;bbs=' . $aThread->bbs;
        $key_q = '&amp;key=' . $aThread->key;
        $host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q;
        $offline_q = '';
        if ($aThreadList->spmode != 'taborn') {
            if (!$aThread->torder) {
                $aThread->torder = $i;
            }
        }
        // 新着レス数 =============================================
        // 既得済み
        if ($show_unum && $aThread->isKitoku()) {
            $htm['unum'] = "{$aThread->unum}";
            // iPhone用
            if ($_conf['iphone']) {
                $classunum = 'num unread';
                // 新着あり
                if ($aThread->unum >= 1) {
                    $midoku_ari = true;
                    $classunum .= ' new';
                }
                // subject.txtにない時
                if (!$aThread->isonline) {
                    $htm['unum'] = '-';
                    $classunum .= ' offline';
                }
                $htm['unum'] = "<span class=\"{$classunum}\">{$htm['unum']}</span>";
            } else {
                $anum_ht = sprintf('#r%d', min($aThread->rescount, $aThread->rescount - $aThread->nunum + 1 - $_conf['respointer']));
                // 新着あり
                if ($aThread->unum >= 1) {
                    $midoku_ari = true;
                    $htm['unum'] = "<font color=\"{$STYLE['mobile_subject_newres_color']}\">{$aThread->unum}</font>";
                }
                // subject.txtにない時
                if (!$aThread->isonline) {
                    $htm['unum'] = '-';
                }
                $htm['unum'] = "[{$htm['unum']}]";
            }
        }
        // 新規スレ
        if ($_conf['iphone']) {
            $classtitle = 'title';
            if ($aThread->new) {
                $classtitle .= ' new';
            }
        } else {
            if ($show_unum && $aThread->new) {
                $htm['unum'] = "<font color=\"{$STYLE['mobile_subject_newthre_color']}\">新</font>";
            }
        }
        // 総レス数 =============================================
        $rescount_ht = "{$aThread->rescount}";
        // 板名 ============================================
        if ($ita_name_bool) {
            $ita_name = $aThread->itaj ? $aThread->itaj : $aThread->bbs;
            $ita_name_hd = p2h($ita_name);
            // 全角英数カナスペースを半角に
            if (!empty($_conf['mobile.save_packet'])) {
                $ita_name_hd = mb_convert_kana($ita_name_hd, 'rnsk');
            }
            //$htm['ita'] = "<a href=\"{$_conf['subject_php']}?host={$aThread->host}{$bbs_q}{$_conf['k_at_a']}\">{$ita_name_hd}</a>)";
            //$htm['ita'] = " ({$ita_name_hd})";
            $htm['ita'] = $ita_name_hd;
        }
        // torder(info) =================================================
        /*
        if ($aThread->fav) { //お気にスレ
            $torder_st = "<b>{$aThread->torder}</b>";
        } else {
            $torder_st = $aThread->torder;
        }
        $torder_ht = "<a id=\"to{$i}\" class=\"info\" href=\"info.php?{$host_bbs_key_q}{$_conf['k_at_a']}\">{$torder_st}</a>";
        */
        $torder_ht = $aThread->torder;
        // title =================================================
        $rescount_q = '&amp;rescount=' . $aThread->rescount;
        // dat倉庫 or 殿堂なら
        if ($aThreadList->spmode == 'soko' || $aThreadList->spmode == 'palace') {
            $rescount_q = '';
            $offline_q = '&amp;offline=true';
            $anum_ht = '';
            // subject.txt にない場合
        } elseif (!$aThread->isonline) {
            $offline_q = '&amp;offline=true';
        }
        // タイトル未取得なら
        $ttitle_ht = $aThread->ttitle_ht;
        if (strlen($ttitle_ht) == 0) {
            // 見かけ上のタイトルなので携帯対応URLである必要はない
            $ttitle_ht = p2h($aThread->getMotoThread(true, ''));
        }
        // 全角英数カナスペースを半角に
        if (!empty($_conf['mobile.save_packet'])) {
            $ttitle_ht = mb_convert_kana($ttitle_ht, 'rnsk');
        }
        if ($_conf['iphone']) {
            $htm['rnum'] = "<span class=\"num count\">{$rescount_ht}</span>";
            if ($aThread->similarity) {
                $htm['sim'] .= sprintf(' <span class="num score">%0.1f%%</span>', $aThread->similarity * 100);
            }
        } else {
            $htm['rnum'] = "({$rescount_ht})";
            if ($aThread->similarity) {
                $htm['sim'] .= sprintf(' %0.1f%%', $aThread->similarity * 100);
            }
        }
        $thre_url = "{$_conf['read_php']}?{$host_bbs_key_q}";
        if ($_conf['iphone']) {
            $thre_url .= '&amp;ttitle_en=' . UrlSafeBase64::encode($aThread->ttitle);
        }
        $thre_url .= "{$rescount_q}{$offline_q}{$_conf['k_at_a']}{$anum_ht}";
        // オンリー>>1
        $onlyone_url = "{$_conf['read_php']}?{$host_bbs_key_q}&amp;one=true&amp;k_continue=1{$_conf['k_at_a']}";
        if ($only_one_bool) {
            $one_ht = "<a href=\"{$onlyone_url}\">&gt;&gt;1</a>";
        }
        // >>1のみ, >>1から
        if (P2Util::isHost2chs($aThreadList->host) && !$aThread->isKitoku()) {
            switch ($_conf['mobile.sb_show_first']) {
                case 1:
                    $thre_url = $onlyone_url;
                    break;
                case 2:
                    $thre_url .= '&amp;ls=1-';
                    break;
                default:
                    $thre_url .= '&amp;ls=l' . $_conf['mobile.rnum_range'];
            }
        }
        // アクセスキー
        /*
        $access_ht = '';
        if ($aThread->torder >= 1 and $aThread->torder <= 9) {
            $access_ht = " {$_conf['accesskey']}=\"{$aThread->torder}\"";
        }
        */
        //====================================================================================
        // スレッド一覧 table ボディ HTMLプリント <tr></tr>
        //====================================================================================
        //ボディ
        if ($_conf['iphone']) {
            // information bubble用の隠しスレッド情報。
            // torderの指示子が"%d"でないのはmerge_favitaのため
            $thre_info = sprintf('[%s] %s (%01.1fレス/日)', $aThread->torder, date('y/m/d H:i', $aThread->key), $aThread->dayres);
            if ($htm['ita'] !== '') {
                $htm['ita'] = "<span class=\"ita\">{$htm['ita']}</span>";
            }
            echo <<<EOP
<li><a href="{$thre_url}"><span class="info">{$thre_info}</span> {$htm['unum']} <span class="{$classtitle}">{$ttitle_ht}</span> {$htm['rnum']} {$htm['sim']} {$htm['ita']}</a></li>

EOP;
        } else {
            echo <<<EOP
<div>{$htm['unum']}{$aThread->torder}.<a href="{$thre_url}">{$ttitle_ht}</a> {$htm['rnum']} {$htm['sim']} {$htm['ita']}</div>

EOP;
        }
    }
    if ($_conf['iphone']) {
        echo '</ul>';
    }
}
コード例 #30
0
ファイル: setrss.inc.php プロジェクト: xingskycn/p2-php
            }
        }
        $site = basename($xml);
        $rss = p2GetRSS($xml);
        if ($rss instanceof XML_RSS) {
            $channelInfo = $rss->getChannelInfo();
            if (is_array($channelInfo) && array_key_exists('title', $channelInfo)) {
                $site = mb_convert_encoding($channelInfo['title'], 'CP932', 'UTF-8,CP51932,CP932,ASCII');
            }
        }
    }
}
// ログに記録する変数を最低限のサニタイズ
$xml = preg_replace_callback('/\\s/', 'rawurlencode', $xml);
$site = preg_replace('/\\s+/', ' ', $site);
$site = p2h($site);
// }}}
// {{{ 読み込み
// rss_pathファイルがなければ生成
FileCtl::make_datafile($_conf['expack.rss.setting_path']);
// rss_path読み込み;
$lines = FileCtl::file_read_lines($_conf['expack.rss.setting_path'], FILE_IGNORE_NEW_LINES);
// }}}
// {{{ 処理
// 最初に重複要素を消去
if ($lines) {
    $i = -1;
    unset($neolines);
    foreach ($lines as $l) {
        $i++;
        $lar = explode("\t", $l);