Пример #1
0
 public function testGetPTEInstance()
 {
     $PTE1 = PMCLibrary::getPTEInstance();
     $this->assertNotNull($PTE1);
     $PTE2 = PMCLibrary::getPTEInstance();
     $this->assertSame($PTE1, $PTE2);
 }
Пример #2
0
function error($mes, $dest = '')
{
    $PTE = PMCLibrary::getPTEInstance();
    if (is_file($dest)) {
        unlink($dest);
    }
    $pte_vals = array('{$SELF2}' => PHP_SELF2 . '?' . time(), '{$MESG}' => $mes, '{$RETURN_TEXT}' => _T('return'), '{$BACK_TEXT}' => _T('error_back'));
    $dat = '';
    head($dat);
    $dat .= $PTE->ParseBlock('ERROR', $pte_vals);
    foot($dat);
    exit($dat);
}
Пример #3
0
function showstatus()
{
    global $LIMIT_SENSOR, $THUMB_SETTING;
    $PIO = PMCLibrary::getPIOInstance();
    $FileIO = PMCLibrary::getFileIOInstance();
    $PTE = PMCLibrary::getPTEInstance();
    $PMS = PMCLibrary::getPMSInstance();
    $countline = $PIO->postCount();
    // 計算投稿文字記錄檔目前資料筆數
    $counttree = $PIO->threadCount();
    // 計算樹狀結構記錄檔目前資料筆數
    $tmp_total_size = $FileIO->getCurrentStorageSize();
    // 附加圖檔使用量總大小
    $tmp_ts_ratio = STORAGE_MAX > 0 ? $tmp_total_size / STORAGE_MAX : 0;
    // 附加圖檔使用量
    // 決定「附加圖檔使用量」提示文字顏色
    if ($tmp_ts_ratio < 0.3) {
        $clrflag_sl = '235CFF';
    } elseif ($tmp_ts_ratio < 0.5) {
        $clrflag_sl = '0CCE0C';
    } elseif ($tmp_ts_ratio < 0.7) {
        $clrflag_sl = 'F28612';
    } elseif ($tmp_ts_ratio < 0.9) {
        $clrflag_sl = 'F200D3';
    } else {
        $clrflag_sl = 'F2004A';
    }
    // 生成預覽圖物件資訊及功能是否正常
    $func_thumbWork = '<span style="color: red;">' . _T('info_nonfunctional') . '</span>';
    $func_thumbInfo = '(No thumbnail)';
    if (USE_THUMB !== 0) {
        $thumbType = USE_THUMB;
        if (USE_THUMB == 1) {
            $thumbType = 'gd';
        }
        require ROOTPATH . 'lib/thumb/thumb.' . $thumbType . '.php';
        $thObj = new ThumbWrapper();
        if ($thObj->isWorking()) {
            $func_thumbWork = '<span style="color: blue;">' . _T('info_functional') . '</span>';
        }
        $func_thumbInfo = $thObj->getClass();
        unset($thObj);
    }
    // PIOSensor
    if (count($LIMIT_SENSOR)) {
        $piosensorInfo = nl2br(PIOSensor::info($LIMIT_SENSOR));
    }
    $dat = '';
    head($dat);
    $links = '[<a href="' . PHP_SELF2 . '?' . time() . '">' . _T('return') . '</a>] [<a href="' . PHP_SELF . '?mode=moduleloaded">' . _T('module_info_top') . '</a>]';
    $PMS->useModuleMethods('LinksAboveBar', array(&$links, 'status'));
    $dat .= '<div id="banner">' . $links . '<div class="bar_admin">' . _T('info_top') . '</div>
</div>
';
    $dat .= '
<div id="status-table" style="text-align: center;">
<style type="text/css" scoped="scoped">
.admTable {border-collapse:collapse;  border-spacing: 1; margin: 0px auto; text-align: left;}
.admTable TD {border:2px solid gray }
</style>
<table class="admTable">
<thead>
<tr><td style="text-align:center" colspan="4">' . _T('info_basic') . '</td></tr>
</thead>
<tbody>
<tr><td style="width: 240px;">' . _T('info_basic_ver') . '</td><td colspan="3"> ' . PIXMICAT_VER . ' </td></tr>
<tr><td>' . _T('info_basic_pio') . '</td><td colspan="3"> ' . PIXMICAT_BACKEND . ' : ' . $PIO->pioVersion() . '</td></tr>
<tr><td>' . _T('info_basic_threadsperpage') . '</td><td colspan="3"> ' . PAGE_DEF . ' ' . _T('info_basic_threads') . '</td></tr>
<tr><td>' . _T('info_basic_postsperpage') . '</td><td colspan="3"> ' . RE_DEF . ' ' . _T('info_basic_posts') . '</td></tr>
<tr><td>' . _T('info_basic_postsinthread') . '</td><td colspan="3"> ' . RE_PAGE_DEF . ' ' . _T('info_basic_posts') . ' ' . _T('info_basic_posts_showall') . '</td></tr>
<tr><td>' . _T('info_basic_bumpposts') . '</td><td colspan="3"> ' . MAX_RES . ' ' . _T('info_basic_posts') . ' ' . _T('info_basic_0disable') . '</td></tr>
<tr><td>' . _T('info_basic_bumphours') . '</td><td colspan="3"> ' . MAX_AGE_TIME . ' ' . _T('info_basic_hours') . ' ' . _T('info_basic_0disable') . '</td></tr>
<tr><td>' . _T('info_basic_urllinking') . '</td><td colspan="3"> ' . AUTO_LINK . ' ' . _T('info_0no1yes') . '</td></tr>
<tr><td>' . _T('info_basic_com_limit') . '</td><td colspan="3"> ' . COMM_MAX . _T('info_basic_com_after') . '</td></tr>
<tr><td>' . _T('info_basic_anonpost') . '</td><td colspan="3"> ' . ALLOW_NONAME . ' ' . _T('info_basic_anonpost_opt') . '</td></tr>
<tr><td>' . _T('info_basic_del_incomplete') . '</td><td colspan="3"> ' . KILL_INCOMPLETE_UPLOAD . ' ' . _T('info_0no1yes') . '</td></tr>
<tr><td>' . _T('info_basic_use_sample', $THUMB_SETTING['Quality']) . '</td><td colspan="3"> ' . USE_THUMB . ' ' . _T('info_0notuse1use') . '</td></tr>
<tr><td>' . _T('info_basic_useblock') . '</td><td colspan="3"> ' . BAN_CHECK . ' ' . _T('info_0disable1enable') . '</td></tr>
<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 ' . TIME_ZONE . '</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 style="text-align:center" colspan="4">' . _T('info_dsusage_top') . '</td></tr>
<tr style="text-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>
<tr style="text-align:center"><td>' . _T('info_dsusage_count') . '</td><td colspan="' . (isset($piosensorInfo) ? '2' : '3') . '">' . $countline . '</td></tr>
<tr><td style="text-align:center" colspan="4">' . _T('info_fileusage_top') . STORAGE_LIMIT . ' ' . _T('info_0disable1enable') . '</td></tr>';
    if (STORAGE_LIMIT) {
        $dat .= '
<tr style="text-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 style="text-align:center"><td>' . _T('info_fileusage_count') . '</td><td colspan="2"><span style="color: #' . $clrflag_sl . '">' . $tmp_total_size . ' KB</span></td></tr>';
    } else {
        $dat .= '
<tr style="text-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>';
    }
    $dat .= '
<tr><td style="text-align:center" colspan="4">' . _T('info_server_top') . '</td></tr>
<tr style="text-align:center"><td colspan="3">' . $func_thumbInfo . '</td><td>' . $func_thumbWork . '</td></tr>
</tbody>
</table>
<hr />
</div>' . "\n";
    foot($dat);
    echo $dat;
}
Пример #4
0
    public function ModulePage()
    {
        $PIO = PMCLibrary::getPIOInstance();
        $thisPage = $this->getModulePageURL();
        // 基底位置
        $dat = '';
        // HTML Buffer
        $listMax = $PIO->threadCount();
        // 討論串總筆數
        $pageMax = ceil($listMax / $this->THREADLIST_NUMBER) - 1;
        // 分頁最大編號
        $page = isset($_GET['page']) ? intval($_GET['page']) : 0;
        // 目前所在分頁頁數
        $sort = isset($_GET['sort']) ? $_GET['sort'] : 'no';
        if ($page < 0 || $page > $pageMax) {
            exit('Page out of range.');
        }
        // $page 超過範圍
        if (strpos($sort, 'post') !== false) {
            $plist = $PIO->fetchThreadList();
            $pc = $this->_getPostCounts($plist);
            $this->_kasort($pc, $sort == 'postdesc', true);
            // 切出需要的大小
            $plist = array_slice(array_keys($pc), $this->THREADLIST_NUMBER * $page, $this->THREADLIST_NUMBER);
        } else {
            $plist = $PIO->fetchThreadList($this->THREADLIST_NUMBER * $page, $this->THREADLIST_NUMBER, $sort == 'date' ? false : true);
            // 編號由大到小排序
            self::$PMS->useModuleMethods('ThreadOrder', array(0, $page, 0, &$plist));
            // "ThreadOrder" Hook Point
            $pc = $this->_getPostCounts($plist);
        }
        $post = $PIO->fetchPosts($plist);
        // 取出資料
        $post_count = count($post);
        if ($sort == 'date' || strpos($sort, 'post') !== false) {
            // 要重排次序
            $mypost = array();
            foreach ($plist as $p) {
                while (list($k, $v) = each($post)) {
                    if ($v['no'] == $p) {
                        $mypost[] = $v;
                        unset($post[$k]);
                        break;
                    }
                }
                reset($post);
            }
            $post = $mypost;
        }
        head($dat);
        $dat .= '<script>
var selectall = "";
function checkall(){
	selectall = selectall ? "" : "checked";
	var inputs = document.getElementsByTagName("input");
	for(x=0; x < inputs.length; x++){
		if(inputs[x].type == "checkbox" && parseInt(inputs[x].name)) {
			inputs[x].checked = selectall;
		}
	}
}
</script>';
        $dat .= '<div id="contents">
[<a href="' . PHP_SELF2 . '?' . time() . '">' . _T('return') . '</a>]
<div class="bar_reply">' . $this->_T('page_title') . '</div>' . ($this->SHOW_FORM ? '<form action="' . PHP_SELF . '" method="post">' : '') . '<table align="center" width="98%"><tr>
' . ($this->SHOW_FORM ? '<th><a href="javascript:checkall()">↓</a></th>' : '') . '
<th><a href="' . $thisPage . '&amp;sort=no">No.' . ($sort == 'no' ? ' ▼' : '') . '</a></th>
<th width="48%">' . _T('form_topic') . '</th>
<th>' . _T('form_name') . '</th>
<th><a href="' . $thisPage . '&amp;sort=' . ($sort == 'postdesc' ? 'postasc' : 'postdesc') . '">' . _T('reply_btn') . ($sort == 'postdesc' ? ' ▼' : ($sort == 'postasc' ? ' ▲' : '')) . '</a></th>
<th><a href="' . $thisPage . '&amp;sort=date">' . $this->_T('date') . ($sort == 'date' ? ' ▼' : '') . '</a></th></tr>
';
        for ($i = 0; $i < $post_count; $i++) {
            list($no, $sub, $name, $now) = array($post[$i]['no'], $post[$i]['sub'], $post[$i]['name'], $post[$i]['now']);
            $rescount = $pc[$no] - 1;
            if ($this->HIGHLIGHT_COUNT > 0 && $rescount > $this->HIGHLIGHT_COUNT) {
                $rescount = '<span style="color:red">' . $rescount . '</span>';
            }
            $dat .= '<tr class="ListRow' . ($i % 2 + 1) . '_bg">' . ($this->SHOW_FORM ? '<td><input type="checkbox" name="' . $no . '" value="delete" /></td>' : '') . '<td>' . $no . '</td><td><a href="' . PHP_SELF . '?res=' . $no . '">' . $sub . '</a></td><td>' . $name . '</td><td>' . $rescount . '</td><td>' . $now . '</td></tr>' . "\n";
        }
        $dat .= '</table>
<hr />

<div id="page_switch">
<table border="1" style="float: left;"><tr>
';
        if ($page) {
            $dat .= '<td><a href="' . $thisPage . '&amp;page=' . ($page - 1) . '&amp;sort=' . $sort . '">' . _T('prev_page') . '</a></td>';
        } else {
            $dat .= '<td style="white-space: nowrap;">' . _T('first_page') . '</td>';
        }
        $dat .= '<td>';
        for ($i = 0; $i <= $pageMax; $i++) {
            if ($i == $page) {
                $dat .= '[<b>' . $i . '</b>] ';
            } else {
                $dat .= '[<a href="' . $thisPage . '&amp;page=' . $i . '&amp;sort=' . $sort . '">' . $i . '</a>] ';
            }
        }
        $dat .= '</td>';
        if ($page < $pageMax) {
            $dat .= '<td><a href="' . $thisPage . '&amp;page=' . ($page + 1) . '&amp;sort=' . $sort . '">' . _T('next_page') . '</a></td>';
        } else {
            $dat .= '<td style="white-space: nowrap;">' . _T('last_page') . '</td>';
        }
        $dat .= '
</tr></table>
</div>';
        if ($this->SHOW_FORM) {
            $adminMode = adminAuthenticate('check');
            // 前端管理模式
            $adminFunc = '';
            // 前端管理選擇
            if ($adminMode) {
                $adminFunc = '<select name="func"><option value="delete">' . _T('admin_delete') . '</option>';
                $funclist = array();
                $dummy = '';
                self::$PMS->useModuleMethods('AdminFunction', array('add', &$funclist, null, &$dummy));
                // "AdminFunction" Hook Point
                foreach ($funclist as $f) {
                    $adminFunc .= '<option value="' . $f[0] . '">' . $f[1] . '</option>' . "\n";
                }
                $adminFunc .= '</select>';
            }
            $pte_vals = array('{$DEL_HEAD_TEXT}' => '<input type="hidden" name="mode" value="usrdel" />' . _T('del_head'), '{$DEL_IMG_ONLY_FIELD}' => '<input type="checkbox" name="onlyimgdel" id="onlyimgdel" value="on" />', '{$DEL_IMG_ONLY_TEXT}' => _T('del_img_only'), '{$DEL_PASS_TEXT}' => ($adminMode ? $adminFunc : '') . _T('del_pass'), '{$DEL_PASS_FIELD}' => '<input type="password" name="pwd" size="8" value="" />', '{$DEL_SUBMIT_BTN}' => '<input type="submit" value="' . _T('del_btn') . '" />');
            $dat .= PMCLibrary::getPTEInstance()->ParseBlock('DELFORM', $pte_vals) . '</form>';
        }
        $dat .= '</div>';
        foot($dat);
        echo $dat;
    }
Пример #5
0
 * @version $Id$
 */
/**
 * 取出翻譯資源檔對應字串。
 *
 * @param args 翻譯資源檔索引、其餘變數
 * @see LanguageLoader->getTranslation
 */
function _T()
{
    // 因為 5.3 以前 func_get_args 無法直接指派,故需要由變數 $args 承接再帶入
    $args = func_get_args();
    return call_user_func_array(array(PMCLibrary::getLanguageInstance(), 'getTranslation'), $args);
}
/**
 * 動態附加翻譯資源。此函式已經由 {@link #LanguageLoader->attachLanguage} 取代。
 *
 * @deprecated 7th.Release. Use LanguageLoader->attachLanguage instead.
 * @param callable $fcall 附加翻譯資源字串的函式
 */
function AttachLanguage($fcall)
{
    $GLOBALS['language'] = array();
    call_user_func($fcall);
    PMCLibrary::getLanguageInstance()->attachLanguage($GLOBALS['language']);
}
// 為了相容舊寫法而保留
$PIO = PMCLibrary::getPIOInstance();
$FileIO = PMCLibrary::getFileIOInstance();
$PTE = PMCLibrary::getPTEInstance();
$PMS = PMCLibrary::getPMSInstance();
Пример #6
0
    /**
     * 產出靜態推文表單
     *
     * @param  int $targetPost 推文對象文章編號
     * @return string             表單頁面 HTML
     */
    private function printStaticForm($targetPost)
    {
        $PIO = PMCLibrary::getPIOInstance();
        $PTE = PMCLibrary::getPTEInstance();
        $post = $PIO->fetchPosts($targetPost);
        if (!count($post)) {
            die('[Error] Post does not exist.');
        }
        $dat = $PTE->ParseBlock('HEADER', array('{$TITLE}' => TITLE, '{$RESTO}' => ''));
        $dat .= '</head><body id="main">';
        $dat .= '<form action="' . $this->getModulePageURL(array('no' => $targetPost)) . '" method="post">
' . $this->_T('pushpost') . ' <ul><li>' . _T('form_name') . ' <input type="text" name="name" maxlength="20" /></li><li>' . _T('form_comment') . ' <input type="text" name="comm" size="50" maxlength="50" /><input type="submit" value="' . _T('form_submit_btn') . '" /></li></ul>
</form>';
        $dat .= '</body></html>';
        return $dat;
    }