public function testGetFileIOInstance() { $FileIO1 = PMCLibrary::getFileIOInstance(); $this->assertNotNull($FileIO1); $FileIO2 = PMCLibrary::getFileIOInstance(); $this->assertSame($FileIO1, $FileIO2); }
/** * 程式首次執行之初始化 * @return boolean 是否無錯誤完成 */ function init() { $PIO = PMCLibrary::getPIOInstance(); $FileIO = PMCLibrary::getFileIOInstance(); if (file_exists(PHP_SELF2)) { return true; } if (!is_writable(STORAGE_PATH)) { error(_T('init_permerror')); return false; } createDirectories(); $PIO->dbInit(); $FileIO->init(); return true; }
<?php include './config.php'; include ROOTPATH . 'lib/pmclibrary.php'; @unlink(FILEIO_INDEXLOG); $FileIO = PMCLibrary::getFileIOInstance(); $fio = new IndexFS(FILEIO_INDEXLOG); $fio->openIndex(); clearstatcache(); $dirs = array(IMG_DIR, THUMB_DIR); foreach ($dirs as $dir) { if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file == "." || $file == "..") { continue; } $fio->addRecord($file, filesize($dir . '/' . $file), ''); } } } $fio->saveIndex(); echo "done";
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; }
function isDuplicateAttachment($lcount, $md5hash) { $FileIO = PMCLibrary::getFileIOInstance(); if (!$this->prepared) { $this->dbPrepare(); } $result = $this->_pgsql_call('SELECT tim,ext FROM ' . $this->tablename . " WHERE ext <> '' AND md5chksum = '{$md5hash}' ORDER BY no DESC", array('Get the post to check the duplicate attachment failed', __LINE__)); while (list($ltim, $lext) = pg_fetch_array($result)) { if ($FileIO->imageExists($ltim . $lext)) { return true; } // 有相同檔案 } return false; }
function isDuplicateAttachment($lcount, $md5hash) { $FileIO = PMCLibrary::getFileIOInstance(); $pcount = $this->postCount(); $lcount = $pcount > $lcount ? $lcount : $pcount; for ($i = 0; $i < $lcount; $i++) { $logsarray = $this->_ArrangeArrayStructure($this->porder[$i]); // 分析資料為陣列 if (!$logsarray[0]['md5chksum']) { continue; } // 無附加圖檔 if ($logsarray[0]['md5chksum'] == $md5hash) { if ($FileIO->imageExists($logsarray[0]['tim'] . $logsarray[0]['ext'])) { return true; } // 存在MD5雜湊相同的檔案 } } return false; }
public function isDuplicateAttachment($lcount, $md5hash) { $FileIO = PMCLibrary::getFileIOInstance(); if (!$this->prepared) { $this->dbPrepare(); } $result = $this->con->query('SELECT tim,ext FROM ' . $this->tablename . ' WHERE ext <> "" AND md5chksum = "' . $md5hash . '" ORDER BY no DESC') or $this->_error_handler('Get the post to check the duplicate attachment failed', __LINE__); while (list($ltim, $lext) = $result->fetch(PDO::FETCH_NUM)) { if ($FileIO->imageExists($ltim . $lext)) { return true; } // 有相同檔案 } return false; }
private function GenerateCache() { $PIO = PMCLibrary::getPIOInstance(); $FileIO = PMCLibrary::getFileIOInstance(); // RFC標準所用之時區格式 $RFC_timezone = ' ' . (TIME_ZONE < 0 ? '-' : '+') . substr('0' . abs(TIME_ZONE), -2) . '00'; switch ($this->FEED_DISPLAYTYPE) { case 'T': // 取出前n筆討論串首篇編號 $plist = $PIO->fetchThreadList(0, $this->FEED_COUNT); $plist_count = count($plist); // 為何這樣取?避免 SQL-like 自動排序喪失時間順序 $post = array(); for ($p = 0; $p < $plist_count; $p++) { // 取出編號文章資料 $post[] = current($PIO->fetchPosts($plist[$p])); } break; case 'P': // 取出前n筆文章編號 $plist = $PIO->fetchPostList(0, 0, $this->FEED_COUNT); $post = $PIO->fetchPosts($plist); break; } $post_count = count($post); // RSS Feed內容 $tmp_c = '<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>' . TITLE . '</title> <link>' . $this->BASEDIR . '</link> <description>' . TITLE . '</description> <language>' . PIXMICAT_LANGUAGE . '</language> <generator>' . $this->getModuleName() . ' ' . $this->getModuleVersionInfo() . '</generator> <atom:link href="' . $this->SELF . '" rel="self" type="application/rss+xml" /> '; for ($i = 0; $i < $post_count; $i++) { $imglink = ''; // 圖檔 $resto = 0; // 回應 list($no, $resto, $time, $tw, $th, $tim, $ext, $sub, $com) = array($post[$i]['no'], $post[$i]['resto'], substr($post[$i]['tim'], 0, -3), $post[$i]['tw'], $post[$i]['th'], $post[$i]['tim'], $post[$i]['ext'], $post[$i]['sub'], $post[$i]['com']); // 處理資料 if ($ext && $FileIO->imageExists($tim . 's.jpg')) { $imglink = sprintf('<img src="%s" alt="%s" width="%d" height="%d" /><br />', $FileIO->getImageURL($tim . 's.jpg'), $tim . $ext, $tw, $th); } // 本地時間RFC標準格式 $time = gmdate("D, d M Y H:i:s", $time + TIME_ZONE * 60 * 60) . $RFC_timezone; $reslink = $this->BASEDIR . PHP_SELF . '?res=' . ($resto ? $resto : $no); switch ($this->FEED_DISPLAYTYPE) { case 'T': // 標題 No.編號 (Res:回應數) $titleBar = $sub . ' No.' . $no . ' (Res: ' . ($PIO->postCount($no) - 1) . ')'; break; case 'P': // 標題 (編號) $titleBar = $sub . ' (' . $no . ')'; break; } $tmp_c .= '<item> <title>' . $titleBar . '</title> <link>' . $reslink . '</link> <description> <![CDATA[ ' . $imglink . $com . ' ]]> </description> <comments>' . $reslink . '</comments> <guid isPermaLink="true">' . $reslink . '#r' . $no . '</guid> <pubDate>' . $time . '</pubDate> </item> '; } $tmp_c .= '</channel> </rss>'; $fp = fopen($this->FEED_CACHEFILE, 'w'); flock($fp, LOCK_EX); fwrite($fp, $tmp_c); flock($fp, LOCK_UN); fclose($fp); @chmod($this->FEED_CACHEFILE, 0666); }