]> 4ch.mooo.com Git - test.git/blobdiff - yotsubanome.php
modified: config.php
[test.git] / yotsubanome.php
index 702652959e46be0fe70d2d06113ab94aaee18e36..ef3a8da1be072ce8ce7a6a165fabaa8427b2d725 100755 (executable)
@@ -2,7 +2,7 @@
 /********************************
     四葉の芽画像掲示板
 
-yotsubanome.php*/$ver = "v0.7.8.1.0002 β lot.100404";/*
+yotsubanome.php*/$ver = "v0.7.8.1.0004 β lot.100404";/*
 
 これがコアシステムです。 四葉の芽スクリプト
 このスクリプトはレッツPHP!<http://php.s3.to/>のgazou.phpを改造したものです。
@@ -57,7 +57,7 @@ PHP 4.4.9 或更高版本並開啟 GD 和 Zlib 支援,如支援 ImageMagick 
 define("PHP_DIRECTORY", '../test/'); // yotsubanome "C:\windows\system\"
 
 /* Include */
-include_once(PHP_DIRECTORY.'env.php'); // Enviorment Settings
+include_once(PHP_DIRECTORY.'lib/lib_env.php'); // Enviorment Settings
 include_once(PHP_DIRECTORY.'config.php'); // 引入設定檔
 include_once(PHP_DIRECTORY.'lib/lib_language.php'); // 引入語系
 include_once(PHP_DIRECTORY.'lib/lib_common.php'); // 引入共通函式檔案
@@ -87,7 +87,7 @@ if(file_exists(PHP_DIRECTORY.'lockdown')){
 /* 更新記錄檔檔案/輸出討論串 */
 /* ログの全体更新 */
 function updatelog($resno=0,$page_num=-1,$single_page=false){
-       global $PIO, $FileIO, $PTE, $PMS, $language, $LIMIT_SENSOR, $style_bar;
+       global $config, $PIO, $FileIO, $PTE, $PMS, $language, $LIMIT_SENSOR, $style_bar;
 
        $adminMode = adminAuthenticate('check') && $page_num != -1 && !$single_page; // 前端管理模式
        $adminFunc = ''; // 前端管理選擇
@@ -125,8 +125,10 @@ function updatelog($resno=0,$page_num=-1,$single_page=false){
                        $page_end = ceil($threads_count / PAGE_DEF) - 1; // 頁面編號最後值
                }else{ // 討論串分頁模式 (PHP動態輸出一頁份)
                        $threads_count = $PIO->threadCount(); // 討論串個數
-                       /*//---- if($page_num < 0 || ($page_num * PAGE_DEF) >= $threads_count) error(_T('page_not_found')); // $page_num超過範圍*/
-                       if($threads_count != 0 && $page_num != 0 || ($page_num < 0 || ($page_num * PAGE_DEF) >= $threads_count)) error(_T('page_not_found')); // $page_num超過範圍
+                       //---- if($page_num < 0 || ($page_num * PAGE_DEF) >= $threads_count) error(_T('page_not_found')); // $page_num超過範圍
+                       //++++---- Page 0 bug fix
+                       if($page_num!=0) if($page_num < 0 || ($page_num * PAGE_DEF) >= $threads_count) error(_T('page_not_found')); // $page_num超過範圍
+                       //++++----
                        $page_start = $page_end = $page_num; // 設定靜態頁面編號
                        $threads = $PIO->fetchThreadList($page_num * PAGE_DEF, PAGE_DEF); // 取出分頁後的討論串首篇列表
                        $PMS->useModuleMethods('ThreadOrder', array($resno,$page_num,$single_page,&$threads)); // "ThreadOrder" Hook Point
@@ -173,6 +175,9 @@ function updatelog($resno=0,$page_num=-1,$single_page=false){
                }
        }
 
+       //++++---- Page 0 bug fix
+       if($tree_count==0 && $page_end==-1) $page_end = 0;
+       //++++----
        // 預測過舊文章和將被刪除檔案
        if(PIOSensor::check('predict', $LIMIT_SENSOR)){ // 是否需要預測
                $old_sensor = true; // 標記打開
@@ -187,7 +192,6 @@ function updatelog($resno=0,$page_num=-1,$single_page=false){
 
        $PMS->useModuleMethods('ThreadFront', array(&$pte_vals['{$THREADFRONT}'], $resno)); // "ThreadFront" Hook Point
        $PMS->useModuleMethods('ThreadRear', array(&$pte_vals['{$THREADREAR}'], $resno)); // "ThreadRear" Hook Point
-       if($tree_count==0 && $page_end==-1) $page_end = 0;
 
        // 生成靜態頁面一頁份內容
        for($page = $page_start; $page <= $page_end; $page++){
@@ -267,11 +271,10 @@ function updatelog($resno=0,$page_num=-1,$single_page=false){
                $pte_vals['{$PAGENAV}'] .= '<br style="clear: left;" />
 </div>';
                $dat .= $PTE->ParseBlock('MAIN', $pte_vals);
-               foot($dat); ////++++---- the foot is a special core function wwww --sparky4
+               foot($dat); // the foot is a special core function wwww --sparky4
 
                // 存檔 / 輸出
-               //---- if($single_page || ($page_num == -1 && !$resno)){ // 靜態快取頁面生成
-               if($threads_count == 0 && $page_num == 0 || ($single_page || ($page_num == -1 && !$resno))){ // 靜態快取頁面生成
+               if($single_page || ($page_num == -1 && !$resno)){ // 靜態快取頁面生成
                        if($page==0) $logfilename = PHP_SELF2;
                        else $logfilename = $page.PHP_EXT;
                        $fp = fopen($logfilename, 'w');
@@ -300,7 +303,7 @@ function updatelog($resno=0,$page_num=-1,$single_page=false){
 
 /* 輸出討論串架構 */
 function arrangeThread($PTE, $tree, $tree_cut, $posts, $hiddenReply, $resno=0, $arr_kill, $arr_old, $kill_sensor, $old_sensor, $showquotelink=true, $adminMode=false, $hiddenImage, $hiddenImagP, $hiddenImagRP, $posts_img){
-       global $PIO, $FileIO, $PMS, $language;
+       global $config, $PIO, $FileIO, $PMS, $language;
 
        $thdat = ''; // 討論串輸出碼
        $posts_count = count($posts); // 迴圈次數
@@ -354,8 +357,8 @@ function arrangeThread($PTE, $tree, $tree_cut, $posts, $hiddenReply, $resno=0, $
                if(AUTO_LINK) $com = auto_link($com);
                $com = quoteLight($com);
                $com = quoteLight2($com);
-               if(!$resno && MAX_LINES) list($com, $abbreviated) = abbreviate($com, MAX_LINES);
-               if(isset($abbreviated) && $abbreviated && MAX_LINES) $com .= '<br /><span class="abbrev">'._T('long_comment').'<a href="'.PHP_SELF.'?res='.$tree[0].'#r'.$no.'">'._T('long_here').'</a>'._T('long_see').'</span>';
+               if(!$resno && $config['LINE_NUMBER']) list($com, $abbreviated) = abbreviate($com, $config['LINE_NUMBER']);
+               if(isset($abbreviated) && $abbreviated && $config['LINE_NUMBER']) $com .= '<br /><span class="abbrev">'._T('long_comment').'<a href="'.PHP_SELF.'?res='.$tree[0].'#r'.$no.'">'._T('long_here').'</a>'._T('long_see').'</span>';
 
                if(USE_QUOTESYSTEM && $i){ // 啟用引用瀏覽系統
                        if(preg_match_all('/((?:&gt;|>)+)(?:No\.)?(\d+)/i', $com, $matches, PREG_SET_ORDER)){ // 找尋>>No.xxx
@@ -455,7 +458,7 @@ function arrangeThread($PTE, $tree, $tree_cut, $posts, $hiddenReply, $resno=0, $
 /* 寫入記錄檔 */
 /* 記事書き込み */
 function regist(){
-       global $PIO, $FileIO, $PMS, $language, $BAD_STRING, $BAD_FILEMD5, $BAD_IPADDR, $LIMIT_SENSOR;
+       global $config, $PIO, $FileIO, $PMS, $language, $BAD_STRING, $BAD_FILEMD5, $BAD_IPADDR, $LIMIT_SENSOR;
        $dest = ''; $mes = ''; $up_incomplete = 0; $is_admin = false;
        $path = realpath('.').DIRECTORY_SEPARATOR; // 此目錄的絕對位置
 
@@ -567,7 +570,7 @@ function regist(){
                $size = @getimagesize($dest);
                if(!is_array($size)) error(_T('regist_upload_notimage'), $dest); // $size不為陣列就不是圖檔
                $imgsize = @filesize($dest); // 檔案大小
-               if(!KB) $imgsize .= ' B'; // Bytes only
+               if(!$config['KB']) $imgsize .= ' B'; // Bytes only
                else $imgsize = ($imgsize>=1024) ? (int)($imgsize/1024).' KB' : $imgsize.' B'; // KB和B的判別
                switch($size[2]){ // 判斷上傳附加圖檔之格式
                        case 1 : $ext = ".gif"; break;
@@ -622,7 +625,7 @@ function regist(){
        if($name){
                // 名稱修整
                $name = str_replace(TRIP_KEY, TRIP_KEY_FAKE, $name); // 防止トリップ偽造
-               $name = str_replace(CAP_SUFFIX, CAP_SUFFIX_FAKE, $name); // 防止管理員キャップ偽造
+               $name = str_replace($config['CAP.SUFFIX'], $config['CAP.SUFFIX.FAKE'], $name); // 防止管理員キャップ偽造
                $name = str_replace("\r\n", '', $name);
                $nameOri = $name; // 名稱
                // トリップ
@@ -669,10 +672,10 @@ function regist(){
                        //----"</b></font><font class=\"postertrip\">".
                        $name .= $metrip;
                }
-               if(CAP_ENABLE && preg_match('/(.*?)[##](.*)/u', $email, $aregs)){ // 管理員キャップ(Cap)機能
+               if($config['CAP.ENABLE'] && preg_match('/(.*?)[##](.*)/u', $email, $aregs)){ // 管理員キャップ(Cap)機能
                        $acap_name = $nameOri; $acap_pwd = strtr($aregs[2], array('&amp;'=>'&'));
-                       if($acap_name==CAP_NAME && $acap_pwd==CAP_PASS){
-                               $name = '<span class="admin_cap">'.$name.CAP_SUFFIX.'</span>';
+                       if($acap_name==$config['CAP.NAME'] && $acap_pwd==$config['CAP.PASSWORD']){
+                               $name = '<span class="admin_cap">'.$name.$config['CAP.SUFFIX'].'</span>';
                                $is_admin = true;
                                $email = $aregs[1]; // 去除 #xx 密碼
                        }
@@ -684,6 +687,7 @@ function regist(){
                $name = str_replace('&'.TRIP_KEY, '&amp;'.TRIP_KEY, $name); // 避免 &#xxxx; 後面被視為 Trip 留下 & 造成解析錯誤
        }
        // End of Tripcode area--------------------------------------------------------------------------
+
        // 內文修整
        if((strlen($com) > COMM_MAX) && !$is_admin) error(_T('regist_commenttoolong'), $dest);
        $com = CleanStr($com, $is_admin); // 引入$is_admin參數是因為當管理員キャップ啟動時,允許管理員依config設定是否使用HTML
@@ -718,9 +722,7 @@ function regist(){
 //---- $yd = $youbi[gmdate('w', $time+TIME_ZONE*60*60)];
        $yd = $youbi[date('w', $tome)];
 //---- $now = gmdate('y/m/d', $time+TIME_ZONE*60*60).'('.(string)$yd.')'.gmdate('H:i', $time+TIME_ZONE*60*60);
-       if(!EN_SEC)
-               $now = date(DATE_FORMAT, $tome).'('.(string)$yd.')'.date('H:i', $tome);
-               else $now = date(DATE_FORMAT, $tome).'('.(string)$yd.')'.date('H:i:s', $tome);
+       $now = date($config['DATE_FORMAT'], $tome).'('.(string)$yd.')'.date($config['TIME_FORMAT'], $tome);
 
 //---- if(DISP_ID){ // 顯示ID
 //----         if($email && DISP_ID==1) $now .= ' ID:????';
@@ -728,7 +730,7 @@ function regist(){
 //---- }
        if(DISP_ID){ // 顯示ID
                if($email&&DISP_ID==1) $now .= " ID:????";
-               else $now .= " ID:".substr(crypt(md5(getREMOTE_ADDR().IDSEED.date(DATE_FORMAT, $tome)),'id'), -8);
+               else $now .= " ID:".substr(crypt(md5(getREMOTE_ADDR().IDSEED.date($config['DATE_FORMAT'], $tome)),'id'), -8);
        }
 
        // 連續投稿 / 相同附加圖檔檢查
@@ -800,7 +802,7 @@ function regist(){
 
        // 正式寫入儲存
        $PIO->addPost($no,$resto,$md5chksum,$category,$tim,$ext,$imgW,$imgH,$imgsize,$filename,$W,$H,$pass,$now,$name,$email,$sub,$com,$host,$age,$status);
-       //----$PIO->addPost($no,$now,$name,$email,$sub,$com,$age,$status,$host,$pwd,$ext,$W,$H,$tim,$md5chksum,$imgsize,$filename,$imgW,$imgH,$category,$resto);
+//---- $PIO->addPost($no,$now,$name,$email,$sub,$com,$age,$status,$host,$pwd,$ext,$W,$H,$tim,$md5chksum,$imgsize,$filename,$imgW,$imgH,$category,$resto);
        $PIO->dbCommit();
        $lastno = $PIO->getLastPostNo('afterCommit'); // 取得此新文章編號
        $PMS->useModuleMethods('RegistAfterCommit', array($lastno, $resto, $name, $email, $sub, $com)); // "RegistAfterCommit" Hook Point
@@ -946,7 +948,7 @@ function valid(){
 </div>
 <form action="'.PHP_SELF.'" method="post" id="adminform">
 <div id="admin-check" style="text-align: center;">
-'; //----class="bar_admin"
+';//----class="bar_admin"
        echo $dat;
        if(!$isCheck){
                echo '<br />
@@ -1108,9 +1110,8 @@ _ADMINEOF_;
 </html>');
 }
 
-////////////////
-// manage_css //
-////////////////
+/* manage_css */
+// http://www.magmagateau.com/fuukaba/ is the source of the code below
 function manage_css(){
        global $PMS, $language;
        $order = array(); $line = '';
@@ -1182,23 +1183,23 @@ function manage_css(){
 
                // Success messages
                $action = (file_exists($style_dat)) ? _t('admin_updated') : _t('admin_created');
-               $delete = (@unlink(CSS_DIR.CSVSS)) ? ' - <span class="warning">'.str_replace('[file]', CSS_DIR.CSVSS, _t('admin_deleted')).'</span>' : false;
+               //---- $delete = (@unlink(CSS_DIR.CSVSS)) ? ' - <span class="warning">'.str_replace('[file]', CSS_DIR.CSVSS, _t('admin_deleted')).'</span>' : false;
                $fp = fopen($style_dat, 'w+');
                set_file_buffer($fp, 0);
                rewind($fp);
                fputs($fp, $line);
                fclose($fp);
                @chmod($style_dat, 0666);
-               echo '<div class="bar_managecss">'.str_replace('[file]', $style_dat, _t('admin_updated')).$delete.'</div>';
+               echo '<div class="bar_managecss">'.str_replace('[file]', $style_dat, _t('admin_updated'))./*----$delete.*/'</div>';
        }
 
        // Editing messages
        if(file_exists(DATA_DIR.CSV_SS)){
                $style_data = DATA_DIR.CSV_SS;
                $style_mode = _t('admin_editing');
-       }else{
-               $style_data = CSS_DIR.CSVSS;
-               $style_mode = _t('admin_imported');
+//---- }else{
+//----         $style_data = CSS_DIR.CSVSS;
+//----         $style_mode = _t('admin_imported');
        }
        echo '<div class="banner"><table width="100%"><tr><th class="bar_managecss">
 '.str_replace('[file]', $style_data, $style_mode).'
@@ -1236,26 +1237,26 @@ function manage_css(){
        }
 
        // Read data from R3 DAT
-       else if(file_exists(CSS_DIR.CSVSS)){
-               $style_data = CSS_DIR.CSVSS;
-               $lines = explode("\n", file_get_contents($style_data));
-               $j = 0;
-               foreach($lines as $null => $line){ // Line has data, or line is not commented out
-                       if(substr($line, 0, 2) != '//' && $line != ''){
-                               $bits = explode('[*]', $line);
-                               $j++;
-                               $style_name = $bits[0];
-                               $style_path = CSS_DIR.$bits[2];
-                               if(file_exists($style_path)){
-                                       $style_short = $bits[1];
-                                       if($bits[3]) $style_rel = ' checked="checked"';
-                                       else $style_rel = false;
-                                       $class = ($j % 2) ? 'row1' : 'row2'; // BG colour
-                                       echo '<tr class="'.$class.'"><td align="left" colspan="2"><label><input name="default" type="radio"'.$style_rel.' value="'.$style_name.'" /> '.$style_path.'</label><input type="hidden" name="path['.$style_name.']" value="'.$bits[2].'" /></td><td align="left"><input name="names['.$style_name.']" value="'.$style_name.'" size="25" /></td><td align="left"><input name="short['.$style_name.']" value="'.$style_short.'" size="5" /></td><td align="left"><input name="order['.$style_name.']" size="2" value="'.$j.'" /></td></tr>';
-                               }
-                       }
-               }
-       }
+//---- else if(file_exists(CSS_DIR.CSVSS)){
+//----         $style_data = CSS_DIR.CSVSS;
+//----         $lines = explode("\n", file_get_contents($style_data));
+//----         $j = 0;
+//----         foreach($lines as $null => $line){ // Line has data, or line is not commented out
+//----                 if(substr($line, 0, 2) != '//' && $line != ''){
+//----                         $bits = explode('[*]', $line);
+//----                         $j++;
+//----                         $style_name = $bits[0];
+//----                         $style_path = CSS_DIR.$bits[2];
+//----                         if(file_exists($style_path)){
+//----                                 $style_short = $bits[1];
+//----                                 if($bits[3]) $style_rel = ' checked="checked"';
+//----                                 else $style_rel = false;
+//----                                 $class = ($j % 2) ? 'row1' : 'row2'; // BG colour
+//----                                 echo '<tr class="'.$class.'"><td align="left" colspan="2"><label><input name="default" type="radio"'.$style_rel.' value="'.$style_name.'" /> '.$style_path.'</label><input type="hidden" name="path['.$style_name.']" value="'.$bits[2].'" /></td><td align="left"><input name="names['.$style_name.']" value="'.$style_name.'" size="25" /></td><td align="left"><input name="short['.$style_name.']" value="'.$style_short.'" size="5" /></td><td align="left"><input name="order['.$style_name.']" size="2" value="'.$j.'" /></td></tr>';
+//----                         }
+//----                 }
+//----         }
+//---- }
 
        $j++; $class = ($j % 2) ? 'row1' : 'row2';
 
@@ -1273,7 +1274,7 @@ function manage_css(){
 
 /* 計算目前附加圖檔使用容量 (單位:KB) */
 function total_size($isupdate=false){
-       global $PIO, $FileIO;
+       global $config, $PIO, $FileIO;
 
        $size = 0; $all = 0;
        $cache_file = "./".SIZE_CACHE; // 附加圖檔使用容量值快取檔案
@@ -1302,7 +1303,9 @@ function total_size($isupdate=false){
                $all = $sp[0];
                unset($sp);
        }
-       return (int)($all / 1024);
+//----        return (int)($all / 1024);
+       if(!$config['KB']) return (int)($all);
+       else return (int)($all / 1024);
 }
 
 /* 搜尋(全文檢索)功能 */
@@ -1392,7 +1395,7 @@ function searchCategory(){
        $dat .= "<div>$links</div>\n";
        for($i = 0; $i < $loglist_cut_count; $i++){
                $posts = $PIO->fetchPosts($loglist_cut[$i]); // 取得文章內容
-               $dat .= arrangeThread($PTE, ($posts[0]['resto'] ? $posts[0]['resto'] : $posts[0]['no']), null, $posts, 0, $loglist_cut[$i], array(), array(), false, false, false); // 逐個輸出 (引用連結不顯示)
+               $dat .= arrangeThread($PTE, ($posts[0]['resto'] ? $posts[0]['resto'] : $posts[0]['no']), null, $posts, 0, $loglist_cut[$i], array(), array(), false, false, false, 0, 0, 0, 0, 0); // 逐個輸出 (引用連結不顯示)
        }
 
        $dat .= '<table border="1"><tr>';
@@ -1451,11 +1454,13 @@ function deleteCache($no){
 
 /* 顯示系統各項資訊 */
 function showstatus(){
-       global $PTE, $PIO, $FileIO, $PMS, $language, $LIMIT_SENSOR;
+       global $config, $PTE, $PIO, $FileIO, $PMS, $language, $LIMIT_SENSOR;
        $countline = $PIO->postCount(); // 計算投稿文字記錄檔目前資料筆數
        $counttree = $PIO->threadCount(); // 計算樹狀結構記錄檔目前資料筆數
        $tmp_total_size = total_size(); // 附加圖檔使用量總大小
        $tmp_ts_ratio = STORAGE_MAX > 0 ? $tmp_total_size / STORAGE_MAX : 0; // 附加圖檔使用量
+       if(!$config['KB']) $kbb = ' B';
+       else $kbb = ' KB';
 
        // 決定「附加圖檔使用量」提示文字顏色
        if($tmp_ts_ratio < 0.3 ) $clrflag_sl = '235CFF';
@@ -1508,7 +1513,7 @@ function showstatus(){
 <tr><td>'._T('info_basic_showid').'</td><td colspan="3"> '.DISP_ID.' '._T('info_basic_showid_after').'</td></tr>
 <tr><td>'._T('info_basic_cr_limit').'</td><td colspan="3"> '.BR_CHECK._T('info_basic_cr_after').'</td></tr>
 <!--<tr><td>'._T('info_basic_timezone').'</td><td colspan="3"> GMT </td></tr>-->
-<tr><td>'._T('info_basic_max_lines_limit').'</td><td colspan="3"> '.MAX_LINES._T('info_basic_max_lines_after').'</td></tr>
+<tr><td>'._T('info_basic_line_number_limit').'</td><td colspan="3"> '.$config['LINE_NUMBER']._T('info_basic_line_number_after').'</td></tr>
 <tr><td>'._T('info_basic_theme').'</td><td colspan="3"> '.$PTE->BlockValue('THEMENAME').' '.$PTE->BlockValue('THEMEVER').'<br/>by '.$PTE->BlockValue('THEMEAUTHOR').'</td></tr>
 <tr><td align="center" colspan="4">'._T('info_dsusage_top').'</td></tr>
 <tr align="center"><td>'._T('info_basic_threadcount').'</td><td colspan="'.(isset($piosensorInfo)?'2':'3').'"> '.$counttree.' '._T('info_basic_threads').'</td>'.(isset($piosensorInfo)?'<td rowspan="2">'.$piosensorInfo.'</td>':'').'</tr>
@@ -1517,11 +1522,11 @@ function showstatus(){
 
        if(STORAGE_LIMIT){
                $dat .= '
-<tr align="center"><td>'._T('info_fileusage_limit').'</td><td colspan="2">'.STORAGE_MAX.' KB</td><td rowspan="2">'._T('info_dsusage_usage').'<br /><span style="color: #'.$clrflag_sl.'">'.substr(($tmp_ts_ratio * 100), 0, 6).'</span> %</td></tr>
-<tr align="center"><td>'._T('info_fileusage_count').'</td><td colspan="2"><span style="color: #'.$clrflag_sl.'">'.$tmp_total_size.' KB</span></td></tr>';
+<tr align="center"><td>'._T('info_fileusage_limit').'</td><td colspan="2">'.STORAGE_MAX.$kbb.'</td><td rowspan="2">'._T('info_dsusage_usage').'<br /><span style="color: #'.$clrflag_sl.'">'.substr(($tmp_ts_ratio * 100), 0, 6).'</span> %</td></tr>
+<tr align="center"><td>'._T('info_fileusage_count').'</td><td colspan="2"><span style="color: #'.$clrflag_sl.'">'.$tmp_total_size.$kbb.'</span></td></tr>';
        }else{
                $dat .= '
-<tr align="center"><td>'._T('info_fileusage_count').'</td><td>'.$tmp_total_size.' KB</td><td colspan="2">'._T('info_dsusage_usage').'<br /><span style="color: green;">'._T('info_fileusage_unlimited').'</span></td></tr>';
+<tr align="center"><td>'._T('info_fileusage_count').'</td><td>'.$tmp_total_size.$kbb.'</td><td colspan="2">'._T('info_dsusage_usage').'<br /><span style="color: green;">'._T('info_fileusage_unlimited').'</span></td></tr>';
        }
 
        $dat .= '