pixmicat

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/PMC2Prototype/ @ 377  →  /PMC2Prototype/ @ 378
/PMC2Prototype/lib/pio/pio.log.php
@@ -10,11 +10,12 @@
*/
 
class PIOlog{
var $logfile, $treefile, $porderfile; // Local Constant
var $ENV, $logfile, $treefile, $porderfile; // Local Constant
var $logs, $trees, $LUT, $porder, $torder, $prepared; // Local Global
//var $memcached, $mid;
 
function PIOlog($connstr=''){
function PIOlog($connstr='', $ENV){
$this->ENV = $ENV;
$this->logs = $this->trees = $this->LUT = $this->porder = $this->torder = array();
$this->prepared = 0;
//$this->mid = md5($_SERVER['SCRIPT_FILENAME']); // Unique ID
@@ -101,16 +102,15 @@
 
/* PIO模組版本 */
function pioVersion(){
return '0.4beta (b20070214)';
return '0.4gamma (b20070331)';
}
 
/* 處理連線字串/連接 */
function dbConnect($connStr){
if(preg_match('/^log:\/\/(.*)\:(.*)\/$/i', $connStr, $linkinfos)){
$BOARDBASE = PMCCore_getConfig('ENV.FOLDER.BOARD'); // 基底資料夾
$this->logfile = $BOARDBASE.'/'.$linkinfos[1]; // 投稿文字記錄檔檔名
$this->treefile = $BOARDBASE.'/'.$linkinfos[2]; // 樹狀結構記錄檔檔名
$this->porderfile = PMCCore_getConfig('ENV.FOLDER.TEMP').'lutcache.dat'; // LUT索引查找表暫存檔案
$this->logfile = $this->ENV['BOARD'].'/'.$linkinfos[1]; // 投稿文字記錄檔檔名
$this->treefile = $this->ENV['BOARD'].'/'.$linkinfos[2]; // 樹狀結構記錄檔檔名
$this->porderfile = $this->ENV['LUTCACHE']; // LUT索引查找表暫存檔案
}
}
 
@@ -122,7 +122,7 @@
if(!is_file($value)){ // 檔案不存在
$fp = fopen($value, 'w');
stream_set_write_buffer($fp, 0);
if($value==$this->logfile) fwrite($fp, '1,0,,,0,,0,0,,0,0,,05/01/01(六)00:00,'.PMCCore_getConfig('DEFAULT.NONAME').',,'.PMCCore_getConfig('DEFAULT.NOTITLE').','.PMCCore_getConfig('DEFAULT.NOCOMMENT').',,,'); // PIO Structure V2
if($value==$this->logfile) fwrite($fp, '1,0,,,0,,0,0,,0,0,,05/01/01(六)00:00,'.$this->ENV['NONAME'].',,'.$this->ENV['NOTITLE'].','.$this->ENV['NOCOMMENT'].',,,'); // PIO Structure V2
if($value==$this->treefile) fwrite($fp, '1');
if($value==$this->porderfile) fwrite($fp, '1');
fclose($fp);
@@ -337,7 +337,7 @@
function delOldPostes(){
if(!$this->prepared) $this->dbPrepare();
 
$delPosts = @array_slice($this->porder, PMCCore_getConfig('LOG_MAX') - 1); // 截出舊文編號陣列
$delPosts = @array_slice($this->porder, $this->ENV['LOG_MAX'] - 1); // 截出舊文編號陣列
if(count($delPosts)) return $this->removePosts($delPosts);
else return false;
}
@@ -438,9 +438,9 @@
list($lcom, $lhost, $lpwd, $ltime) = array($logsarray[0]['com'], $logsarray[0]['host'], $logsarray[0]['pwd'], substr($logsarray[0]['tim'],0,-3));
if($host==$lhost || $pass==$lpwd || $passcookie==$lpwd) $pchk = 1;
else $pchk = 0;
if(PMCCore_getConfig('PERIOD.POST') && $pchk){ // 密碼比對符合且開啟連續投稿時間限制
if($timestamp - $ltime < PMCCore_getConfig('PERIOD.POST')) return true; // 投稿時間相距太短
if($timestamp - $ltime < PMCCore_getConfig('PERIOD.IMAGEPOST') && $isupload) return true; // 附加圖檔的投稿時間相距太短
if($this->ENV['PERIOD.POST'] && $pchk){ // 密碼比對符合且開啟連續投稿時間限制
if($timestamp - $ltime < $this->ENV['PERIOD.POST']) return true; // 投稿時間相距太短
if($timestamp - $ltime < $this->ENV['PERIOD.IMAGEPOST'] && $isupload) return true; // 附加圖檔的投稿時間相距太短
if($com == $lcom && !$isupload) return true; // 內文一樣
}
}
/PMC2Prototype/lib/pio/pio.sqlite.php
@@ -10,10 +10,11 @@
*/
 
class PIOsqlite{
var $dbname, $tablename; // Local Constant
var $ENV, $dbname, $tablename; // Local Constant
var $con, $prepared; // Local Global
 
function PIOsqlite($connstr=''){
function PIOsqlite($connstr='', $ENV){
$this->ENV = $ENV;
$this->prepared = 0;
if($connstr) $this->dbConnect($connstr);
}
@@ -44,7 +45,7 @@
 
/* PIO模組版本 */
function pioVersion(){
return '0.4beta (b20070214)';
return '0.4gamma (b20070331)';
}
 
/* 處理連線字串/連接 */
@@ -89,7 +90,7 @@
$result .= 'CREATE INDEX IDX_'.$this->tablename.'_'.$x.' ON '.$this->tablename.'('.$x.');';
}
$result .= 'CREATE INDEX IDX_'.$this->tablename.'_resto_no ON '.$this->tablename.'(resto,no);';
if($isAddInitData) $result .= 'INSERT INTO '.$this->tablename.' (resto,root,time,md5chksum,category,tim,ext,imgw,imgh,imgsize,tw,th,pwd,now,name,email,sub,com,host,status) VALUES (0, datetime("now"), 1111111111, "", "", 1111111111111, "", 0, 0, "", 0, 0, "", "05/01/01(六)00:00", "'.PMCCore_getConfig('DEFAULT.NONAME').'", "", "'.PMCCore_getConfig('DEFAULT.NOTITLE').'", "'.PMCCore_getConfig('DEFAULT.NOCOMMENT').'", "", "");';
if($isAddInitData) $result .= 'INSERT INTO '.$this->tablename.' (resto,root,time,md5chksum,category,tim,ext,imgw,imgh,imgsize,tw,th,pwd,now,name,email,sub,com,host,status) VALUES (0, datetime("now"), 1111111111, "", "", 1111111111111, "", 0, 0, "", 0, 0, "", "05/01/01(六)00:00", "'.$this->ENV['NONAME'].'", "", "'.$this->ENV['NOTITLE'].'", "'.$this->ENV['NOCOMMENT'].'", "", "");';
sqlite_exec($this->con, $result); // 正式新增資料表
$this->dbCommit();
}
@@ -251,7 +252,7 @@
 
$oldAttachments = array(); // 舊文的附加檔案清單
$countline = $this->postCount(); // 文章數目
$cutIndex = $countline - LOG_MAX + 1; // LIMIT用,取出最舊的幾篇
$cutIndex = $countline - $this->ENV['LOG_MAX'] + 1; // LIMIT用,取出最舊的幾篇
if(!$result=$this->_sqlite_call('SELECT no,ext,tim FROM '.$this->tablename." ORDER BY no LIMIT 0, ".$cutIndex)) $this->_error_handler('Get the old post failed', __LINE__);
else{
while(list($dno, $dext, $dtim)=sqlite_fetch_array($result)){ // 個別跑舊文迴圈
@@ -363,9 +364,9 @@
global $FileIO;
if(!$this->prepared) $this->dbPrepare();
 
if(!RENZOKU) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - RENZOKU); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - RENZOKU2); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
if(!$this->ENV['PERIOD.POST']) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - $this->ENV['PERIOD.POST']); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - $this->ENV['PERIOD.IMAGEPOST']); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
else $tmpSQL .= " OR php('md5', com) = '".md5($com)."'"; // 內文一樣的檢查 (與上者兩者擇一) * 此取巧採用了PHP登錄的函式php來叫用md5
if(!$result=$this->_sqlite_call($tmpSQL)) $this->_error_handler('Get the post to check the succession failed', __LINE__);
else{
/PMC2Prototype/lib/pio/pio.sqlite3.php
@@ -10,10 +10,11 @@
*/
 
class PIOsqlite3{
private $DSN, $tablename; // Local Constant
private $ENV, $DSN, $tablename; // Local Constant
private $con, $prepared; // Local Global
 
public function __construct($connstr=''){
public function __construct($connstr='', $ENV){
$this->ENV = $ENV;
$this->prepared = false;
if($connstr) $this->dbConnect($connstr);
}
@@ -26,7 +27,7 @@
 
/* PIO模組版本 */
public function pioVersion() {
return '0.4beta (b20070221)';
return '0.4gamma (b20070331)';
}
 
/* 處理連線字串/連接 */
@@ -71,7 +72,7 @@
$idx = array('resto', 'root', 'time');
foreach($idx as $x) $result .= 'CREATE INDEX IDX_'.$this->tablename.'_'.$x.' ON '.$this->tablename.'('.$x.');';
$result .= 'CREATE INDEX IDX_'.$this->tablename.'_resto_no ON '.$this->tablename.'(resto,no);';
if($isAddInitData) $result .= 'INSERT INTO '.$this->tablename.' (resto,root,time,md5chksum,category,tim,ext,imgw,imgh,imgsize,tw,th,pwd,now,name,email,sub,com,host,status) VALUES (0, datetime("now"), 1111111111, "", "", 1111111111111, "", 0, 0, "", 0, 0, "", "05/01/01(六)00:00", "'.PMCCore_getConfig('DEFAULT.NONAME').'", "", "'.PMCCore_getConfig('DEFAULT.NOTITLE').'", "'.PMCCore_getConfig('DEFAULT.NOCOMMENT').'", "", "");';
if($isAddInitData) $result .= 'INSERT INTO '.$this->tablename.' (resto,root,time,md5chksum,category,tim,ext,imgw,imgh,imgsize,tw,th,pwd,now,name,email,sub,com,host,status) VALUES (0, datetime("now"), 1111111111, "", "", 1111111111111, "", 0, 0, "", 0, 0, "", "05/01/01(六)00:00", "'.$this->ENV['NONAME'].'", "", "'.$this->ENV['NOTITLE'].'", "'.$this->ENV['NOCOMMENT'].'", "", "");';
$this->con->exec($result);
$this->dbCommit();
}
@@ -223,7 +224,7 @@
$oldAttachments = array();
$delStack = array(); // Records needed to be deleted
$countline = $this->postCount();
$cutIndex = $countline - LOG_MAX + 1;
$cutIndex = $countline - $this->ENV['LOG_MAX'] + 1;
$result = $this->con->prepare('SELECT no,ext,tim FROM '.$this->tablename.' ORDER BY no LIMIT 0, :cutindex');
$result->execute(array(':cutindex' => $cutIndex)) or $this->_error_handler('Get the old post failed', __LINE__);
while(list($dno, $dext, $dtim) = $result->fetch(PDO::FETCH_NUM)){
@@ -331,9 +332,9 @@
global $FileIO;
if(!$this->prepared) $this->dbPrepare();
 
if(!RENZOKU) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - RENZOKU); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - RENZOKU2); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
if(!$this->ENV['PERIOD.POST']) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - $this->ENV['PERIOD.POST']); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - $this->ENV['PERIOD.IMAGEPOST']); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
else $tmpSQL .= " OR md5(com) = '".md5($com)."'"; // 內文一樣的檢查 (與上者兩者擇一)
$this->con->sqliteCreateFunction('md5', 'md5', 1); // Register MD5 function
($result = $this->con->query($tmpSQL)) or $this->_error_handler('Get the post to check the succession failed', __LINE__);
/PMC2Prototype/lib/pio/pio.mysql.php
@@ -10,10 +10,11 @@
*/
 
class PIOmysql{
var $username, $password, $server, $dbname, $tablename; // Local Constant
var $ENV, $username, $password, $server, $dbname, $tablename; // Local Constant
var $con, $prepared; // Local Global
 
function PIOmysql($connstr=''){
function PIOmysql($connstr='', $ENV){
$this->ENV = $ENV;
$this->prepared = 0;
if($connstr) $this->dbConnect($connstr);
}
@@ -39,7 +40,7 @@
 
/* PIO模組版本 */
function pioVersion(){
return '0.4beta (b20070214)';
return '0.4gamma (b20070331)';
}
 
/* 處理連線字串/連接 */
@@ -90,7 +91,7 @@
mysql_free_result($result2);
}
mysql_query($result); // 正式新增資料表
if($isAddInitData) $this->addPost(1, 0, '', '', 0, '', 0, 0, '', 0, 0, '', '05/01/01(六)00:00', PMCCore_getConfig('DEFAULT.NONAME'), '', PMCCore_getConfig('DEFAULT.NOTITLE'), PMCCore_getConfig('DEFAULT.NOCOMMENT'), ''); // 追加一筆新資料
if($isAddInitData) $this->addPost(1, 0, '', '', 0, '', 0, 0, '', 0, 0, '', '05/01/01(六)00:00', $this->ENV['NONAME'], '', $this->ENV['NOTITLE'], $this->ENV['NOCOMMENT'], ''); // 追加一筆新資料
$this->dbCommit();
}
}
@@ -258,7 +259,7 @@
 
$oldAttachments = array(); // 舊文的附加檔案清單
$countline = $this->postCount(); // 文章數目
$cutIndex = $countline - LOG_MAX + 1; // LIMIT用,取出最舊的幾篇
$cutIndex = $countline - $this->ENV['LOG_MAX'] + 1; // LIMIT用,取出最舊的幾篇
if(!$result=$this->_mysql_call('SELECT no,ext,tim FROM '.$this->tablename.' ORDER BY no LIMIT 0, '.$cutIndex)) $this->_error_handler('Get the old post failed', __LINE__);
else{
while(list($dno, $dext, $dtim)=mysql_fetch_row($result)){ // 個別跑舊文迴圈
@@ -374,9 +375,9 @@
global $FileIO;
if(!$this->prepared) $this->dbPrepare();
 
if(!RENZOKU) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - RENZOKU); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - RENZOKU2); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
if(!$this->ENV['PERIOD.POST']) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - $this->ENV['PERIOD.POST']); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - $this->ENV['PERIOD.IMAGEPOST']); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
else $tmpSQL .= ' OR md5(com) = "'.md5($com).'"'; // 內文一樣的檢查 (與上者兩者擇一)
if(!$result=$this->_mysql_call($tmpSQL)) $this->_error_handler('Get the post to check the succession failed', __LINE__);
else{
/PMC2Prototype/lib/pio/pio.pgsql.php
@@ -10,10 +10,11 @@
*/
 
class PIOpgsql{
var $username, $password, $server, $port, $dbname, $tablename; // Local Constant
var $ENV, $username, $password, $server, $port, $dbname, $tablename; // Local Constant
var $con, $prepared; // Local Global
 
function PIOpgsql($connstr=''){
function PIOpgsql($connstr='', $ENV){
$this->ENV = $ENV;
$this->prepared = 0;
if($connstr) $this->dbConnect($connstr);
}
@@ -39,7 +40,7 @@
 
/* PIO模組版本 */
function pioVersion(){
return '0.4beta (b20070214)';
return '0.4gamma (b20070331)';
}
 
/* 處理連線字串/連接 */
@@ -87,7 +88,7 @@
$idxs = array('resto', 'root', 'time');
foreach($idxs as $idx) $result .= 'CREATE INDEX '.$this->tablename.'_'.$idx.'_index ON '.$this->tablename.' ('.$idx.');';
pg_query($this->con, $result); // 正式新增資料表
if($isAddInitData) $this->addPost(1, 0, '', '', 0, '', 0, 0, '', 0, 0, '', '05/01/01(六)00:00', PMCCore_getConfig('DEFAULT.NONAME'), '', PMCCore_getConfig('DEFAULT.NOTITLE'), PMCCore_getConfig('DEFAULT.NOCOMMENT'), ''); // 追加一筆新資料
if($isAddInitData) $this->addPost(1, 0, '', '', 0, '', 0, 0, '', 0, 0, '', '05/01/01(六)00:00', $this->ENV['NONAME'], '', $this->ENV['NOTITLE'], $this->ENV['NOCOMMENT'], ''); // 追加一筆新資料
$this->dbCommit();
}
}
@@ -256,7 +257,7 @@
 
$oldAttachments = array(); // 舊文的附加檔案清單
$countline = $this->postCount(); // 文章數目
$cutIndex = $countline - LOG_MAX + 1; // LIMIT用,取出最舊的幾篇
$cutIndex = $countline - $this->ENV['LOG_MAX'] + 1; // LIMIT用,取出最舊的幾篇
if(!$result=$this->_pgsql_call('SELECT no,ext,tim FROM '.$this->tablename.' ORDER BY no LIMIT '.$cutIndex)) $this->_error_handler('Get the old post failed', __LINE__);
else{
while(list($dno, $dext, $dtim)=pg_fetch_array($result)){ // 個別跑舊文迴圈
@@ -372,9 +373,9 @@
global $FileIO;
if(!$this->prepared) $this->dbPrepare();
 
if(!RENZOKU) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - RENZOKU); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - RENZOKU2); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
if(!$this->ENV['PERIOD.POST']) return false; // 關閉連續投稿檢查
$tmpSQL = 'SELECT pwd,host FROM '.$this->tablename.' WHERE time > '.($timestamp - $this->ENV['PERIOD.POST']); // 一般投稿時間檢查
if($isupload) $tmpSQL .= ' OR time > '.($timestamp - $this->ENV['PERIOD.IMAGEPOST']); // 附加圖檔的投稿時間檢查 (與下者兩者擇一)
else $tmpSQL .= " OR md5(com) = '".md5($com)."'"; // 內文一樣的檢查 (與上者兩者擇一)
if(!$result=$this->_pgsql_call($tmpSQL)) $this->_error_handler('Get the post to check the succession failed', __LINE__);
else{
/PMC2Prototype/lib/lib_pio.php
@@ -12,12 +12,23 @@
// 分析連線字串
$PIOconnStr = PMCCore_getConfig('LIB.PIO.CONNECTION_STRING');
$PIObackend = preg_match('/^(.*):\/\//i', $PIOconnStr, $backend) ? $backend[1] : false;
$PIOEnv = array( // PIO 環境常數
'BOARD' => PMCCore_getConfig('ENV.FOLDER.BOARD'),
'LUTCACHE' => PMCCore_getConfig('ENV.FOLDER.TEMP').'lutcache.dat',
'NONAME' => PMCCore_getConfig('DEFAULT.NONAME'),
'NOTITLE' => PMCCore_getConfig('DEFAULT.NOTITLE'),
'NOCOMMENT' => PMCCore_getConfig('DEFAULT.NOCOMMENT'),
'LOG_MAX' => PMCCore_getConfig('LOG_MAX'),
'PERIOD.POST' => PMCCore_getConfig('PERIOD.POST'),
'PERIOD.IMAGEPOST' => PMCCore_getConfig('PERIOD.IMAGEPOST')
);
 
 
// 引入函式庫
$PIOfile = './lib/pio/pio.'.$PIObackend.'.php';
if(is_file($PIOfile)){
require($PIOfile);
$PIOswitch = 'PIO'.$PIObackend;
$returnOBJECT = new $PIOswitch($PIOconnStr);
$returnOBJECT = new $PIOswitch($PIOconnStr, $PIOEnv);
}else{ trigger_error(_T('cannot_load_pio', $PIObackend), E_USER_ERROR); }
?>
/PMC2Prototype/action/action_ajax.php
@@ -9,6 +9,11 @@
 
if(!defined('ENV_RUNTIME')) exit('ACCESS DENIED');
 
// 修整文字以符合 JSON 格式
function jsonified($txt){
return str_replace(array('\\', '"'), array('\\\\', '\\"'), $txt);
}
 
// 更新頁面快取
function updateCache(){
global $PIO, $FileIO;
@@ -62,6 +67,7 @@
$arrReplies = array();
for($i = 0; $i < $postCount; $i++){
$IMG_SRC = $IMG_BAR = '';
$post[$i] = array_map('jsonified', $post[$i]);
extract($post[$i]);
// 修整資料以便輸出為 JSON