Compare commits
1 Commits
34
UPDATE.md
34
UPDATE.md
@@ -1,21 +1,33 @@
|
|||||||
## PicHome beta3.3 更新说明
|
## PicHome Home1.0 更新说明
|
||||||
|
|
||||||
### 1.billfish数据支持,兼容billfish2.5版本数据导入
|
### 1.支持升级到团队版,可在站点设置->授权信息界面查看
|
||||||
|
|
||||||
### 2.eagle数据支持,兼容新旧版本eagle数据导入
|
### 2.billfish数据支持,修复billfish导入有回收站数据导致导入进度不能完成的问题
|
||||||
|
|
||||||
### 3.优化普通目录文件缩略图生成逻辑,优化效率,以及缩略图转换数字显示等问题修复
|
### 3.eagle数据支持,修复eagle导入更新数据时目录数据异常问题
|
||||||
|
|
||||||
### 4.修复普通目录由于文件名长度问题导致的文件缺失和部分服务器中存在因路径分割符不同导致文件导入累加式重复问题
|
### 4.eagle数据支持,修复eagle导入非图片文件缩略图变更后显示异常问题
|
||||||
|
|
||||||
### 5.库设置增加库名称修改选项
|
### 5.普通目录数据支持,整体修改导入逻辑,修复导入错误,提升导入效率
|
||||||
|
|
||||||
### 6.修复页面标签未分类数据显示错误问题,修复单一库时存在的筛选项不能正常显示问题
|
### 6.优化导入体验,导入增加部分错误提示,修复导入时删除库不断弹出弹窗的错误,以及导入类型提示不匹配问题
|
||||||
|
|
||||||
### 7.页面增加按eagle和billfish内目录排序显示支持
|
### 7.导入增加校验更新,用于修复以往导入产生的错误修正
|
||||||
|
|
||||||
### 8.优化库删除逻辑,删除时清理库冗余数据
|
### 7.修复删除库错误,由数据兼容错误导致没有真正删除问题
|
||||||
|
|
||||||
### 9.文件访问地址修改为动态地址,增强文件私密性,为之后版本文件私密保护做准备
|
### 8.增加文件访问永久地址获取(仅管理员可用)
|
||||||
|
|
||||||
### 10.其他已知bug修复
|
### 9.文件访问地址使用动态地址增强安全性(非永久地址)
|
||||||
|
|
||||||
|
### 10.开放库筛选项设置,可在站点设置->筛选器设置中修改,支持标签分类作为单独筛选项展示;若库未设置筛选项,默认使用“全部库”筛选项,并依其变化而变化
|
||||||
|
|
||||||
|
### 11.修复分享的移动端问题
|
||||||
|
|
||||||
|
### 12.新增模板3(适用标签类筛选的内容)
|
||||||
|
|
||||||
|
### 13.优化访问效率
|
||||||
|
|
||||||
|
### 14.优化界面展示效果
|
||||||
|
|
||||||
|
### 15.其他已知bug修复
|
||||||
28
admin.php
28
admin.php
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author zyx(zyx@oaooa.com)
|
* @author zyx(zyx@oaooa.com)
|
||||||
*/
|
*/
|
||||||
define('IN_ADMIN', TRUE);
|
define('IN_ADMIN', TRUE);
|
||||||
define('NOROBOT', TRUE);
|
define('NOROBOT', TRUE);
|
||||||
define('ADMINSCRIPT', basename(__FILE__));
|
define('ADMINSCRIPT', basename(__FILE__));
|
||||||
define('BASESCRIPT', basename(__FILE__));
|
define('BASESCRIPT', basename(__FILE__));
|
||||||
define('CURSCRIPT', 'admin');
|
define('CURSCRIPT', 'admin');
|
||||||
define('APPTYPEID', 0);
|
define('APPTYPEID', 0);
|
||||||
require __DIR__.'/core/adminstart.php';
|
require __DIR__.'/core/adminstart.php';
|
||||||
@@ -1,395 +1,395 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author zyx(zyx@oaooa.com)
|
* @author zyx(zyx@oaooa.com)
|
||||||
*/
|
*/
|
||||||
if(!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
|
if(!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
function runquery($sql) {
|
function runquery($sql) {
|
||||||
global $_G;
|
global $_G;
|
||||||
$tablepre = $_G['config']['db'][1]['tablepre'];
|
$tablepre = $_G['config']['db'][1]['tablepre'];
|
||||||
$dbcharset = $_G['config']['db'][1]['dbcharset'];
|
$dbcharset = $_G['config']['db'][1]['dbcharset'];
|
||||||
|
|
||||||
$sql = str_replace(array(' dzz_', ' `dzz_',' oaooa_', ' `oaooa_' ), array(' {tablepre}', ' `{tablepre}',' {tablepre}', ' `{tablepre}' ), $sql);
|
$sql = str_replace(array(' dzz_', ' `dzz_',' oaooa_', ' `oaooa_' ), array(' {tablepre}', ' `{tablepre}',' {tablepre}', ' `{tablepre}' ), $sql);
|
||||||
|
|
||||||
$sql = str_replace("\r", "\n", str_replace(array(' {tablepre}', ' `{tablepre}'), array(' '.$tablepre, ' `'.$tablepre), $sql));
|
$sql = str_replace("\r", "\n", str_replace(array(' {tablepre}', ' `{tablepre}'), array(' '.$tablepre, ' `'.$tablepre), $sql));
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$num = 0;
|
$num = 0;
|
||||||
foreach(explode(";\n", trim($sql)) as $query) {
|
foreach(explode(";\n", trim($sql)) as $query) {
|
||||||
$queries = explode("\n", trim($query));
|
$queries = explode("\n", trim($query));
|
||||||
foreach($queries as $query) {
|
foreach($queries as $query) {
|
||||||
$ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
|
$ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
|
||||||
}
|
}
|
||||||
$num++;
|
$num++;
|
||||||
}
|
}
|
||||||
unset($sql);
|
unset($sql);
|
||||||
|
|
||||||
foreach($ret as $query) {
|
foreach($ret as $query) {
|
||||||
$query = trim($query);
|
$query = trim($query);
|
||||||
if($query) {
|
if($query) {
|
||||||
|
|
||||||
if(substr($query, 0, 12) == 'CREATE TABLE') {
|
if(substr($query, 0, 12) == 'CREATE TABLE') {
|
||||||
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
|
$name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
|
||||||
DB::query(createtable($query, $dbcharset));
|
DB::query(createtable($query, $dbcharset));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
DB::query($query);
|
DB::query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createtable($sql, $dbcharset) {
|
function createtable($sql, $dbcharset) {
|
||||||
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
|
$type = strtoupper(preg_replace("/^\s*CREATE TABLE\s+.+\s+\(.+?\).*(ENGINE|TYPE)\s*=\s*([a-z]+?).*$/isU", "\\2", $sql));
|
||||||
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
|
$type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
|
||||||
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
|
return preg_replace("/^\s*(CREATE TABLE\s+.+\s+\(.+?\)).*$/isU", "\\1", $sql).
|
||||||
( " ENGINE=$type DEFAULT CHARSET=$dbcharset");
|
( " ENGINE=$type DEFAULT CHARSET=$dbcharset");
|
||||||
}
|
}
|
||||||
|
|
||||||
function cron_create($app, $filename='', $name='', $weekday=-1, $day=-1, $hour=-1, $minute=-1) {
|
function cron_create($app, $filename='', $name='', $weekday=-1, $day=-1, $hour=-1, $minute=-1) {
|
||||||
$pluginid = $app['identifier'];
|
$pluginid = $app['identifier'];
|
||||||
$app_path = $app['app_path'];
|
$app_path = $app['app_path'];
|
||||||
if(!ispluginkey($pluginid)) {
|
if(!ispluginkey($pluginid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dir = DZZ_ROOT.'./'.$app_path.'/'.$pluginid.'/cron';
|
$dir = DZZ_ROOT.'./'.$app_path.'/'.$pluginid.'/cron';
|
||||||
if(!file_exists($dir)) {
|
if(!file_exists($dir)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$crondir = dir($dir);
|
$crondir = dir($dir);
|
||||||
while($filename = $crondir->read()) {
|
while($filename = $crondir->read()) {
|
||||||
if(!in_array($filename, array('.', '..')) && preg_match("/^cron\_[\w\.]+$/", $filename)) {
|
if(!in_array($filename, array('.', '..')) && preg_match("/^cron\_[\w\.]+$/", $filename)) {
|
||||||
$content = file_get_contents($dir.'/'.$filename);
|
$content = file_get_contents($dir.'/'.$filename);
|
||||||
preg_match("/cronname\:(.+?)\n/", $content, $r);$name = trim($r[1]);
|
preg_match("/cronname\:(.+?)\n/", $content, $r);$name = trim($r[1]);
|
||||||
preg_match("/week\:(.+?)\n/", $content, $r);$weekday = trim($r[1]) ? intval($r[1]) : -1;
|
preg_match("/week\:(.+?)\n/", $content, $r);$weekday = trim($r[1]) ? intval($r[1]) : -1;
|
||||||
preg_match("/day\:(.+?)\n/", $content, $r);$day = trim($r[1]) ? intval($r[1]) : -1;
|
preg_match("/day\:(.+?)\n/", $content, $r);$day = trim($r[1]) ? intval($r[1]) : -1;
|
||||||
preg_match("/hour\:(.+?)\n/", $content, $r);$hour = trim($r[1]) ? intval($r[1]) : -1;
|
preg_match("/hour\:(.+?)\n/", $content, $r);$hour = trim($r[1]) ? intval($r[1]) : -1;
|
||||||
preg_match("/minute\:(.+?)\n/", $content, $r);$minute = trim($r[1]) ? trim($r[1]) : 0;
|
preg_match("/minute\:(.+?)\n/", $content, $r);$minute = trim($r[1]) ? trim($r[1]) : 0;
|
||||||
$minutenew = explode(',', $minute);
|
$minutenew = explode(',', $minute);
|
||||||
foreach($minutenew as $key => $val) {
|
foreach($minutenew as $key => $val) {
|
||||||
$minutenew[$key] = $val = intval($val);
|
$minutenew[$key] = $val = intval($val);
|
||||||
if($val < 0 || $var > 59) {
|
if($val < 0 || $var > 59) {
|
||||||
unset($minutenew[$key]);
|
unset($minutenew[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$minutenew = array_slice(array_unique($minutenew), 0, 12);
|
$minutenew = array_slice(array_unique($minutenew), 0, 12);
|
||||||
$minutenew = implode("\t", $minutenew);
|
$minutenew = implode("\t", $minutenew);
|
||||||
$filename = $app_path.':'.$pluginid.':'.$filename;
|
$filename = $app_path.':'.$pluginid.':'.$filename;
|
||||||
$cronid = C::t('cron')->get_cronid_by_filename($filename);
|
$cronid = C::t('cron')->get_cronid_by_filename($filename);
|
||||||
if(!$cronid) {
|
if(!$cronid) {
|
||||||
C::t('cron')->insert(array(
|
C::t('cron')->insert(array(
|
||||||
'available' => 1,
|
'available' => 1,
|
||||||
'type' => 'app',
|
'type' => 'app',
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'filename' => $filename,
|
'filename' => $filename,
|
||||||
'weekday' => $weekday,
|
'weekday' => $weekday,
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
'hour' => $hour,
|
'hour' => $hour,
|
||||||
'minute' => $minutenew,
|
'minute' => $minutenew,
|
||||||
), true);
|
), true);
|
||||||
} else {
|
} else {
|
||||||
C::t('cron')->update($cronid, array(
|
C::t('cron')->update($cronid, array(
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'weekday' => $weekday,
|
'weekday' => $weekday,
|
||||||
'day' => $day,
|
'day' => $day,
|
||||||
'hour' => $hour,
|
'hour' => $hour,
|
||||||
'minute' => $minutenew,
|
'minute' => $minutenew,
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cron_delete($app) {
|
function cron_delete($app) {
|
||||||
$pluginid = $app['identifier'];
|
$pluginid = $app['identifier'];
|
||||||
$app_path = $app['app_path'];
|
$app_path = $app['app_path'];
|
||||||
|
|
||||||
if(!ispluginkey($pluginid)) {
|
if(!ispluginkey($pluginid)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dir = DZZ_ROOT.'./'.$app_path.'/'.$pluginid.'/cron';
|
$dir = DZZ_ROOT.'./'.$app_path.'/'.$pluginid.'/cron';
|
||||||
if(!file_exists($dir)) {
|
if(!file_exists($dir)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$crondir = dir($dir);
|
$crondir = dir($dir);
|
||||||
$count = 0;
|
$count = 0;
|
||||||
while($filename = $crondir->read()) {
|
while($filename = $crondir->read()) {
|
||||||
if(!in_array($filename, array('.', '..')) && preg_match("/^cron\_[\w\.]+$/", $filename)) {
|
if(!in_array($filename, array('.', '..')) && preg_match("/^cron\_[\w\.]+$/", $filename)) {
|
||||||
$filename = $app_path.':'.$pluginid.':'.$filename;
|
$filename = $app_path.':'.$pluginid.':'.$filename;
|
||||||
$cronid = C::t('cron')->get_cronid_by_filename($filename);
|
$cronid = C::t('cron')->get_cronid_by_filename($filename);
|
||||||
C::t('cron')->delete($cronid);
|
C::t('cron')->delete($cronid);
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
function isplugindir($dir) {
|
function isplugindir($dir) {
|
||||||
return preg_match("/^[a-z]+[a-z0-9_]*\/$/", $dir);
|
return preg_match("/^[a-z]+[a-z0-9_]*\/$/", $dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ispluginkey($key) {
|
function ispluginkey($key) {
|
||||||
return preg_match("/^[a-z]+[a-z0-9_]*$/i", $key);
|
return preg_match("/^[a-z]+[a-z0-9_]*$/i", $key);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dir_writeable($dir) {
|
function dir_writeable($dir) {
|
||||||
if(!is_dir($dir)) {
|
if(!is_dir($dir)) {
|
||||||
@mkdir($dir, 0777);
|
@mkdir($dir, 0777);
|
||||||
}
|
}
|
||||||
if(is_dir($dir)) {
|
if(is_dir($dir)) {
|
||||||
if($fp = @fopen("$dir/test.txt", 'w')) {
|
if($fp = @fopen("$dir/test.txt", 'w')) {
|
||||||
@fclose($fp);
|
@fclose($fp);
|
||||||
@unlink("$dir/test.txt");
|
@unlink("$dir/test.txt");
|
||||||
$writeable = 1;
|
$writeable = 1;
|
||||||
} else {
|
} else {
|
||||||
$writeable = 0;
|
$writeable = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $writeable;
|
return $writeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function exportdata($name, $filename, $data) {
|
function exportdata($name, $filename, $data) {
|
||||||
global $_G;
|
global $_G;
|
||||||
require_once libfile('class/xml');
|
require_once libfile('class/xml');
|
||||||
$root = array(
|
$root = array(
|
||||||
'Title' => $name,
|
'Title' => $name,
|
||||||
'Version' => $_G['setting']['version'],
|
'Version' => $_G['setting']['version'],
|
||||||
'Time' => dgmdate(TIMESTAMP, 'Y-m-d H:i'),
|
'Time' => dgmdate(TIMESTAMP, 'Y-m-d H:i'),
|
||||||
'From' => $_G['setting']['bbname'].' ('.$_G['siteurl'].')',
|
'From' => $_G['setting']['bbname'].' ('.$_G['siteurl'].')',
|
||||||
'Data' => exportarray($data, 1)
|
'Data' => exportarray($data, 1)
|
||||||
);
|
);
|
||||||
$filename = strtolower(str_replace(array('!', ' '), array('', '_'), $name)).'_'.$filename.'.xml';
|
$filename = strtolower(str_replace(array('!', ' '), array('', '_'), $name)).'_'.$filename.'.xml';
|
||||||
$plugin_export = array2xml($root, 1);
|
$plugin_export = array2xml($root, 1);
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
dheader('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||||
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
dheader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||||
dheader('Cache-Control: no-cache, must-revalidate');
|
dheader('Cache-Control: no-cache, must-revalidate');
|
||||||
dheader('Pragma: no-cache');
|
dheader('Pragma: no-cache');
|
||||||
dheader('Content-Encoding: none');
|
dheader('Content-Encoding: none');
|
||||||
dheader('Content-Length: '.strlen($plugin_export));
|
dheader('Content-Length: '.strlen($plugin_export));
|
||||||
dheader('Content-Disposition: attachment; filename='.$filename);
|
dheader('Content-Disposition: attachment; filename='.$filename);
|
||||||
dheader('Content-Type: text/xml');
|
dheader('Content-Type: text/xml');
|
||||||
echo $plugin_export;
|
echo $plugin_export;
|
||||||
define('FOOTERDISABLED' , 1);
|
define('FOOTERDISABLED' , 1);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function imagetobase64($file){
|
function imagetobase64($file){
|
||||||
$type=getimagesize($file);//取得图片的大小,类型等
|
$type=getimagesize($file);//取得图片的大小,类型等
|
||||||
$fp=fopen($file,"r")or die("Can't open file");
|
$fp=fopen($file,"r")or die("Can't open file");
|
||||||
$file_content=chunk_split(base64_encode(fread($fp,filesize($file))));//base64编码
|
$file_content=chunk_split(base64_encode(fread($fp,filesize($file))));//base64编码
|
||||||
switch($type[2]){//判读图片类型
|
switch($type[2]){//判读图片类型
|
||||||
case 1:$img_type="gif";break;
|
case 1:$img_type="gif";break;
|
||||||
case 2:$img_type="jpg";break;
|
case 2:$img_type="jpg";break;
|
||||||
case 3:$img_type="png";break;
|
case 3:$img_type="png";break;
|
||||||
}
|
}
|
||||||
$img='data:image/'.$img_type.';base64,'.$file_content;//合成图片的base64编码
|
$img='data:image/'.$img_type.';base64,'.$file_content;//合成图片的base64编码
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
return $img;
|
return $img;
|
||||||
}
|
}
|
||||||
function base64toimage($data,$dir='appimg',$target=''){
|
function base64toimage($data,$dir='appimg',$target=''){
|
||||||
global $_G;
|
global $_G;
|
||||||
$dataarr=explode(',',$data);
|
$dataarr=explode(',',$data);
|
||||||
$imgcontent=base64_decode($dataarr[1]);
|
$imgcontent=base64_decode($dataarr[1]);
|
||||||
$imgext=str_replace(array('data:image/',';base64'),'',$dataarr[0]);
|
$imgext=str_replace(array('data:image/',';base64'),'',$dataarr[0]);
|
||||||
if(!$target) {
|
if(!$target) {
|
||||||
$imageext=array('jpg','jpeg','png','gif');
|
$imageext=array('jpg','jpeg','png','gif');
|
||||||
if(!in_array($imgext,$imageext)) $ext='jpg';
|
if(!in_array($imgext,$imageext)) $ext='jpg';
|
||||||
$subdir = $subdir1 = $subdir2 = '';
|
$subdir = $subdir1 = $subdir2 = '';
|
||||||
$subdir1 = date('Ym');
|
$subdir1 = date('Ym');
|
||||||
$subdir2 = date('d');
|
$subdir2 = date('d');
|
||||||
$subdir = $subdir1.'/'.$subdir2.'/';
|
$subdir = $subdir1.'/'.$subdir2.'/';
|
||||||
$target1=$_G['setting']['attachdir'].$dir.'/'.$subdir.''.date('His').''.strtolower(random(16)).'.'.$imgext;
|
$target1=$_G['setting']['attachdir'].$dir.'/'.$subdir.''.date('His').''.strtolower(random(16)).'.'.$imgext;
|
||||||
$target=str_replace($_G['setting']['attachdir'],'',$target1);
|
$target=str_replace($_G['setting']['attachdir'],'',$target1);
|
||||||
}else{
|
}else{
|
||||||
$target1=$_G['setting']['attachdir'].$target;
|
$target1=$_G['setting']['attachdir'].$target;
|
||||||
}
|
}
|
||||||
$targetpath = dirname($target1);
|
$targetpath = dirname($target1);
|
||||||
dmkdir($targetpath);
|
dmkdir($targetpath);
|
||||||
if(file_put_contents($target1, $imgcontent)){
|
if(file_put_contents($target1, $imgcontent)){
|
||||||
if(@filesize($target1)<200) {
|
if(@filesize($target1)<200) {
|
||||||
@unlink($target1);
|
@unlink($target1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $target;
|
return $target;
|
||||||
}else return false;
|
}else return false;
|
||||||
}
|
}
|
||||||
function importByarray($arr,$force=0){
|
function importByarray($arr,$force=0){
|
||||||
$app=$arr['app'];
|
$app=$arr['app'];
|
||||||
//判断应用是否已经存在
|
//判断应用是否已经存在
|
||||||
$oapp=DB::fetch_first("select * from %t where identifier=%s and app_path=%s ",array('app_market', $app['identifier'],$app['app_path']));
|
$oapp=DB::fetch_first("select * from %t where identifier=%s and app_path=%s ",array('app_market', $app['identifier'],$app['app_path']));
|
||||||
if(!$force && $oapp){
|
if(!$force && $oapp){
|
||||||
showmessage('application_been');
|
showmessage('application_been');
|
||||||
}
|
}
|
||||||
|
|
||||||
//转化应用图标
|
//转化应用图标
|
||||||
if($app['appico']){
|
if($app['appico']){
|
||||||
$app['appico']=base64toimage($app['appico'],'appico');
|
$app['appico']=base64toimage($app['appico'],'appico');
|
||||||
}
|
}
|
||||||
|
|
||||||
$app['extra']=serialize($app['extra']);
|
$app['extra']=serialize($app['extra']);
|
||||||
|
|
||||||
if($oapp){
|
if($oapp){
|
||||||
$appid=$oapp['appid'];
|
$appid=$oapp['appid'];
|
||||||
C::t('app_market')->update($appid,$app);
|
C::t('app_market')->update($appid,$app);
|
||||||
}else{
|
}else{
|
||||||
$app['available']=0;
|
$app['available']=0;
|
||||||
$appid=$app['appid']=C::t('app_market')->insert($app,1);
|
$appid=$app['appid']=C::t('app_market')->insert($app,1);
|
||||||
}
|
}
|
||||||
if($arr['hooks']){//初始化钩子
|
if($arr['hooks']){//初始化钩子
|
||||||
C::t('hooks')->insert_by_appid($appid,$arr['hooks'],$arr['_attributes']['hooks']);
|
C::t('hooks')->insert_by_appid($appid,$arr['hooks'],$arr['_attributes']['hooks']);
|
||||||
}
|
}
|
||||||
if($appid){
|
if($appid){
|
||||||
C::t('app_open')->insert_by_exts($appid,($app['fileext']?explode(',',$app['fileext']):array()));
|
C::t('app_open')->insert_by_exts($appid,($app['fileext']?explode(',',$app['fileext']):array()));
|
||||||
C::t('app_tag')->addtags(($app['tag']?explode(',',$app['tag']):array()),$appid);
|
C::t('app_tag')->addtags(($app['tag']?explode(',',$app['tag']):array()),$appid);
|
||||||
}
|
}
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
function upgradeinformation($status = 0) {
|
function upgradeinformation($status = 0) {
|
||||||
global $_G, $upgrade_step;
|
global $_G, $upgrade_step;
|
||||||
|
|
||||||
if(empty($upgrade_step)) {
|
if(empty($upgrade_step)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if($status==1 && $upgrade_step['step']==2) return '';
|
if($status==1 && $upgrade_step['step']==2) return '';
|
||||||
$update = array();
|
$update = array();
|
||||||
$siteuniqueid = C::t('setting')->fetch('siteuniqueid');
|
$mcode = C::t('setting')->fetch('machinecode');
|
||||||
$update['siteurl']=$_G['siteurl'];
|
$update['siteurl']=$_G['siteurl'];
|
||||||
$update['sitename']=$_G['setting']['sitename'];
|
$update['sitename']=$_G['setting']['sitename'];
|
||||||
$update['uniqueid'] = $siteuniqueid;
|
$update['mcode'] = $mcode;
|
||||||
$update['curversion'] = $upgrade_step['curversion'];
|
$update['curversion'] = $upgrade_step['curversion'];
|
||||||
$update['currelease'] = $upgrade_step['currelease'];
|
$update['currelease'] = $upgrade_step['currelease'];
|
||||||
$update['upgradeversion'] = $upgrade_step['version'];
|
$update['upgradeversion'] = $upgrade_step['version'];
|
||||||
$update['upgraderelease'] = $upgrade_step['release'];
|
$update['upgraderelease'] = $upgrade_step['release'];
|
||||||
$update['step'] = $upgrade_step['step'] == 'dbupdate' ? 4 : $upgrade_step['step'];
|
$update['step'] = $upgrade_step['step'] == 'dbupdate' ? 4 : $upgrade_step['step'];
|
||||||
$update['status'] = $status;
|
$update['status'] = $status;
|
||||||
$update['version_level'] = CORE_VERSION_LEVEL;
|
$update['version_level'] = CORE_VERSION_LEVEL;
|
||||||
|
|
||||||
$data = '';
|
$data = '';
|
||||||
foreach($update as $key => $value) {
|
foreach($update as $key => $value) {
|
||||||
$data .= $key.'='.rawurlencode($value).'&';
|
$data .= $key.'='.rawurlencode($value).'&';
|
||||||
}
|
}
|
||||||
$upgradeurl = APP_CHECK_URL."market/system/upgrade/".rawurlencode(base64_encode($data))."/".TIMESTAMP;
|
$upgradeurl = APP_CHECK_URL."authlicense/count//upgrade/".rawurlencode(base64_encode($data))."/".TIMESTAMP;
|
||||||
dfsockopen($upgradeurl,0, '', '', FALSE, '',0.2);
|
dfsockopen($upgradeurl,0, '', '', FALSE, '',0.2);
|
||||||
return '';
|
return '';
|
||||||
//return '<img src="'.$upgradeurl.'" width="0" height="0" />';
|
//return '<img src="'.$upgradeurl.'" width="0" height="0" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgradeinformation_app($status = 0) {
|
function upgradeinformation_app($status = 0) {
|
||||||
global $_G, $appinfo;
|
global $_G, $appinfo;
|
||||||
if(empty($appinfo)) {
|
if(empty($appinfo)) {
|
||||||
return '';
|
return '';
|
||||||
}else{
|
}else{
|
||||||
if( isset($appinfo['upgradeinfo']) ){
|
if( isset($appinfo['upgradeinfo']) ){
|
||||||
$lastversion=$appinfo['upgradeinfo']['version'];
|
$lastversion=$appinfo['upgradeinfo']['version'];
|
||||||
$mid=$appinfo['upgradeinfo']['mid'];
|
$mid=$appinfo['upgradeinfo']['mid'];
|
||||||
}else{
|
}else{
|
||||||
$lastversion=$appinfo['version'];
|
$lastversion=$appinfo['version'];
|
||||||
$mid=$appinfo['mid'];
|
$mid=$appinfo['mid'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($status==0) return '';
|
if($status==0) return '';
|
||||||
$update = array();
|
$update = array();
|
||||||
$siteuniqueid = C::t('setting')->fetch('siteuniqueid');
|
$siteuniqueid = C::t('setting')->fetch('siteuniqueid');
|
||||||
$update['siteurl']=$_G['siteurl'];
|
$update['siteurl']=$_G['siteurl'];
|
||||||
$update['sitename']=$_G['setting']['sitename'];
|
$update['sitename']=$_G['setting']['sitename'];
|
||||||
$update['uniqueid'] = $siteuniqueid;
|
$update['uniqueid'] = $siteuniqueid;
|
||||||
$update['mid'] = $mid;
|
$update['mid'] = $mid;
|
||||||
$update['curversion'] = $appinfo['version'];
|
$update['curversion'] = $appinfo['version'];
|
||||||
$update['lastversion'] = $lastversion;
|
$update['lastversion'] = $lastversion;
|
||||||
$update['identifier'] = $appinfo['identifier'];
|
$update['identifier'] = $appinfo['identifier'];
|
||||||
$update['lastversion'] = $lastversion;
|
$update['lastversion'] = $lastversion;
|
||||||
$update['status'] = $status;
|
$update['status'] = $status;
|
||||||
$update['version_level'] = CORE_VERSION_LEVEL;
|
$update['version_level'] = CORE_VERSION_LEVEL;
|
||||||
|
|
||||||
$data = '';
|
$data = '';
|
||||||
foreach($update as $key => $value) {
|
foreach($update as $key => $value) {
|
||||||
$data .= $key.'='.rawurlencode($value).'&';
|
$data .= $key.'='.rawurlencode($value).'&';
|
||||||
}
|
}
|
||||||
$upgradeurl=APP_CHECK_URL."market/appinstall/".rawurlencode(base64_encode($data)); //APP_CHECK_URL."index.php?mod=dzzmarket&op=installinfo&data=".rawurlencode(base64_encode($data)).'×tamp='.TIMESTAMP;
|
$upgradeurl=APP_CHECK_URL."market/appinstall/".rawurlencode(base64_encode($data)); //APP_CHECK_URL."index.php?mod=dzzmarket&op=installinfo&data=".rawurlencode(base64_encode($data)).'×tamp='.TIMESTAMP;
|
||||||
dfsockopen($upgradeurl,0, '', '', FALSE, '',0.2);
|
dfsockopen($upgradeurl,0, '', '', FALSE, '',0.2);
|
||||||
return '';
|
return '';
|
||||||
//return '<img src="'.$upgradeurl.'" width="0" height="0" />';
|
//return '<img src="'.$upgradeurl.'" width="0" height="0" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getwheres($intkeys, $strkeys, $randkeys, $likekeys, $pre='') {
|
function getwheres($intkeys, $strkeys, $randkeys, $likekeys, $pre='') {
|
||||||
|
|
||||||
$wherearr = array();
|
$wherearr = array();
|
||||||
$urls = array();
|
$urls = array();
|
||||||
|
|
||||||
foreach ($intkeys as $var) {
|
foreach ($intkeys as $var) {
|
||||||
$value = isset($_GET[$var])?$_GET[$var]:'';
|
$value = isset($_GET[$var])?$_GET[$var]:'';
|
||||||
if(strlen($value)) {
|
if(strlen($value)) {
|
||||||
$urls[] = "$var=$value";
|
$urls[] = "$var=$value";
|
||||||
$var = addslashes($var);
|
$var = addslashes($var);
|
||||||
$wherearr[] = "{$pre}{$var}='".intval($value)."'";
|
$wherearr[] = "{$pre}{$var}='".intval($value)."'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($strkeys as $var) {
|
foreach ($strkeys as $var) {
|
||||||
$value = isset($_GET[$var])?trim($_GET[$var]):'';
|
$value = isset($_GET[$var])?trim($_GET[$var]):'';
|
||||||
if(strlen($value)) {
|
if(strlen($value)) {
|
||||||
$urls[] = "$var=".rawurlencode($value);
|
$urls[] = "$var=".rawurlencode($value);
|
||||||
$var = addslashes($var);
|
$var = addslashes($var);
|
||||||
$value = addslashes($value);
|
$value = addslashes($value);
|
||||||
$wherearr[] = "{$pre}{$var}='$value'";
|
$wherearr[] = "{$pre}{$var}='$value'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($randkeys as $vars) {
|
foreach ($randkeys as $vars) {
|
||||||
$value1 = isset($_GET[$vars[1].'1'])?$vars[0]($_GET[$vars[1].'1']):'';
|
$value1 = isset($_GET[$vars[1].'1'])?$vars[0]($_GET[$vars[1].'1']):'';
|
||||||
$value2 = isset($_GET[$vars[1].'2'])?$vars[0]($_GET[$vars[1].'2']):'';
|
$value2 = isset($_GET[$vars[1].'2'])?$vars[0]($_GET[$vars[1].'2']):'';
|
||||||
if($value1) {
|
if($value1) {
|
||||||
$urls[] = "{$vars[1]}1=".rawurlencode($_GET[$vars[1].'1']);
|
$urls[] = "{$vars[1]}1=".rawurlencode($_GET[$vars[1].'1']);
|
||||||
$vars[1] = addslashes($vars[1]);
|
$vars[1] = addslashes($vars[1]);
|
||||||
$value1 = addslashes($value1);
|
$value1 = addslashes($value1);
|
||||||
$wherearr[] = "{$pre}{$vars[1]}>='$value1'";
|
$wherearr[] = "{$pre}{$vars[1]}>='$value1'";
|
||||||
}
|
}
|
||||||
if($value2) {
|
if($value2) {
|
||||||
$wherearr[] = "{$pre}{$vars[1]}<='$value2'";
|
$wherearr[] = "{$pre}{$vars[1]}<='$value2'";
|
||||||
$vars[2] = addslashes($vars[2]);
|
$vars[2] = addslashes($vars[2]);
|
||||||
$value2 = addslashes($value2);
|
$value2 = addslashes($value2);
|
||||||
$urls[] = "{$vars[1]}2=".rawurlencode($_GET[$vars[1].'2']);
|
$urls[] = "{$vars[1]}2=".rawurlencode($_GET[$vars[1].'2']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($likekeys as $var) {
|
foreach ($likekeys as $var) {
|
||||||
$value = isset($_GET[$var])?stripsearchkey($_GET[$var]):'';
|
$value = isset($_GET[$var])?stripsearchkey($_GET[$var]):'';
|
||||||
if(strlen($value)>1) {
|
if(strlen($value)>1) {
|
||||||
$urls[] = "$var=".rawurlencode($_GET[$var]);
|
$urls[] = "$var=".rawurlencode($_GET[$var]);
|
||||||
$var = addslashes($var);
|
$var = addslashes($var);
|
||||||
$value = addslashes($value);
|
$value = addslashes($value);
|
||||||
$wherearr[] = "{$pre}{$var} LIKE BINARY '%$value%'";
|
$wherearr[] = "{$pre}{$var} LIKE BINARY '%$value%'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return array('wherearr'=>$wherearr, 'urls'=>$urls);
|
return array('wherearr'=>$wherearr, 'urls'=>$urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getorders($alloworders, $default, $pre='') {
|
function getorders($alloworders, $default, $pre='') {
|
||||||
$orders = array('sql'=>'', 'urls'=>array());
|
$orders = array('sql'=>'', 'urls'=>array());
|
||||||
if(empty($_GET['orderby']) || !in_array($_GET['orderby'], $alloworders)) {
|
if(empty($_GET['orderby']) || !in_array($_GET['orderby'], $alloworders)) {
|
||||||
$_GET['orderby'] = $default;
|
$_GET['orderby'] = $default;
|
||||||
if(empty($_GET['ordersc'])) $_GET['ordersc'] = 'desc';
|
if(empty($_GET['ordersc'])) $_GET['ordersc'] = 'desc';
|
||||||
}
|
}
|
||||||
|
|
||||||
$orders['sql'] = " ORDER BY {$pre}$_GET[orderby] ";
|
$orders['sql'] = " ORDER BY {$pre}$_GET[orderby] ";
|
||||||
$orders['urls'][] = "orderby=$_GET[orderby]";
|
$orders['urls'][] = "orderby=$_GET[orderby]";
|
||||||
|
|
||||||
if(!empty($_GET['ordersc']) && $_GET['ordersc'] == 'desc') {
|
if(!empty($_GET['ordersc']) && $_GET['ordersc'] == 'desc') {
|
||||||
$orders['urls'][] = 'ordersc=desc';
|
$orders['urls'][] = 'ordersc=desc';
|
||||||
$orders['sql'] .= ' DESC ';
|
$orders['sql'] .= ' DESC ';
|
||||||
} else {
|
} else {
|
||||||
$orders['urls'][] = 'ordersc=asc';
|
$orders['urls'][] = 'ordersc=asc';
|
||||||
}
|
}
|
||||||
return $orders;
|
return $orders;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace admin\login\classes;
|
namespace admin\login\classes;
|
||||||
use \core as C;
|
use \core as C;
|
||||||
class Adminlogin{
|
class Adminlogin{
|
||||||
public function run(){
|
public function run(){
|
||||||
$dzz = C::app();
|
$dzz = C::app();
|
||||||
$dzz->init();
|
$dzz->init();
|
||||||
$admincp = new \dzz_admincp();
|
$admincp = new \dzz_admincp();
|
||||||
$admincp->core = $dzz;
|
$admincp->core = $dzz;
|
||||||
$return = $admincp->init();
|
$return = $admincp->init();
|
||||||
if(defined('IS_API') && IS_API && $return === 0){
|
if(defined('IS_API') && IS_API && $return === 0){
|
||||||
exit(json_encode(array('loginstatus'=>0,'hash'=>FORMHASH)));
|
exit(json_encode(array('loginstatus'=>0,'hash'=>FORMHASH)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,130 +1,130 @@
|
|||||||
input:-webkit-autofill {
|
input:-webkit-autofill {
|
||||||
box-shadow: 0 0 0px 1000px white inset !important;
|
box-shadow: 0 0 0px 1000px white inset !important;
|
||||||
}
|
}
|
||||||
.mainContainer {
|
.mainContainer {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
.loginContainer {
|
.loginContainer {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%
|
width: 100%
|
||||||
}
|
}
|
||||||
.logintips {
|
.logintips {
|
||||||
color: red;
|
color: red;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: 350px;
|
width: 350px;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid #e3e3e3;
|
border: 1px solid #e3e3e3;
|
||||||
-webkit-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
-webkit-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
||||||
-moz-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
-moz-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
||||||
box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
||||||
}
|
}
|
||||||
#loginform {
|
#loginform {
|
||||||
width: 350px;
|
width: 350px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.login h4 {
|
.login h4 {
|
||||||
height: 35px;
|
height: 35px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.avatarContainer {
|
.avatarContainer {
|
||||||
margin-bottom: 50px;
|
margin-bottom: 50px;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.avatarContainer img {
|
.avatarContainer img {
|
||||||
max-width: 128px;
|
max-width: 128px;
|
||||||
max-height: 128px;
|
max-height: 128px;
|
||||||
}
|
}
|
||||||
.avatarContainer .maintitle{
|
.avatarContainer .maintitle{
|
||||||
font-size:20px;
|
font-size:20px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding-top:10px;
|
padding-top:10px;
|
||||||
}
|
}
|
||||||
#admin_password_Container {
|
#admin_password_Container {
|
||||||
padding: 30px 0 30px 0;
|
padding: 30px 0 30px 0;
|
||||||
}
|
}
|
||||||
#admin_password_Container .input-black {
|
#admin_password_Container .input-black {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.loginformContainer {
|
.loginformContainer {
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: #FFF;
|
background-color: #FFF;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
border: 1px solid #e3e3e3;
|
border: 1px solid #e3e3e3;
|
||||||
-webkit-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
-webkit-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
||||||
-moz-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
-moz-box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
||||||
box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
box-shadow: 0 5px 15px RGBA(0,0,0,.3);
|
||||||
}
|
}
|
||||||
.loginformContainer .username {
|
.loginformContainer .username {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 10px 0 0;
|
margin: 10px 0 0;
|
||||||
min-height: 1em;
|
min-height: 1em;
|
||||||
}
|
}
|
||||||
.loginformContainer .email {
|
.loginformContainer .email {
|
||||||
color: #404040;
|
color: #404040;
|
||||||
line-height: 2;
|
line-height: 2;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
input[type="password"], input[type="text"] {
|
input[type="password"], input[type="text"] {
|
||||||
height: 40px;
|
height: 40px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
outline: none;
|
outline: none;
|
||||||
width: 286px\0;
|
width: 286px\0;
|
||||||
*width:286px;
|
*width:286px;
|
||||||
}
|
}
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
width: 286px\0;
|
width: 286px\0;
|
||||||
*width:286px;
|
*width:286px;
|
||||||
}
|
}
|
||||||
input[type="password"]:focus, input[type="text"]:focus {
|
input[type="password"]:focus, input[type="text"]:focus {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
.footer .copyright {
|
.footer .copyright {
|
||||||
border: medium none;
|
border: medium none;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
position: static;
|
position: static;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.copyright {
|
.copyright {
|
||||||
color: #899;
|
color: #899;
|
||||||
font-family: "微软雅黑";
|
font-family: "微软雅黑";
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
left: 5px;
|
left: 5px;
|
||||||
line-height: 150%;
|
line-height: 150%;
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
.copyright a {
|
.copyright a {
|
||||||
color: #899;
|
color: #899;
|
||||||
}
|
}
|
||||||
.wrapper-placeholder {
|
.wrapper-placeholder {
|
||||||
text-align: left
|
text-align: left
|
||||||
}
|
}
|
||||||
.Topcarousel {
|
.Topcarousel {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
line-height: 100px;
|
line-height: 100px;
|
||||||
font-size: 45px;
|
font-size: 45px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: Administrator
|
* User: Administrator
|
||||||
* Date: 2020/9/7
|
* Date: 2020/9/7
|
||||||
* Time: 16:24
|
* Time: 16:24
|
||||||
*/
|
*/
|
||||||
$return = updatesession();
|
$return = updatesession();
|
||||||
exit(json_encode(array('status'=>$return)));
|
exit(json_encode(array('status'=>$return)));
|
||||||
@@ -1,49 +1,49 @@
|
|||||||
/*
|
/*
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author zyx(zyx@oaooa.com)
|
* @author zyx(zyx@oaooa.com)
|
||||||
*/
|
*/
|
||||||
function checkAll(type, form, value, checkall, changestyle) {
|
function checkAll(type, form, value, checkall, changestyle) {
|
||||||
var checkall = checkall ? checkall : 'chkall';
|
var checkall = checkall ? checkall : 'chkall';
|
||||||
for(var i = 0; i < form.elements.length; i++) {
|
for(var i = 0; i < form.elements.length; i++) {
|
||||||
var e = form.elements[i];
|
var e = form.elements[i];
|
||||||
if(type == 'option' && e.type == 'radio' && e.value == value && e.disabled != true) {
|
if(type == 'option' && e.type == 'radio' && e.value == value && e.disabled != true) {
|
||||||
e.checked = true;
|
e.checked = true;
|
||||||
} else if(type == 'value' && e.type == 'checkbox' && e.getAttribute('chkvalue') == value) {
|
} else if(type == 'value' && e.type == 'checkbox' && e.getAttribute('chkvalue') == value) {
|
||||||
e.checked = form.elements[checkall].checked;
|
e.checked = form.elements[checkall].checked;
|
||||||
if(changestyle) {
|
if(changestyle) {
|
||||||
multiupdate(e);
|
multiupdate(e);
|
||||||
}
|
}
|
||||||
} else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) {
|
} else if(type == 'prefix' && e.name && e.name != checkall && (!value || (value && e.name.match(value)))) {
|
||||||
e.checked = form.elements[checkall].checked;
|
e.checked = form.elements[checkall].checked;
|
||||||
if(changestyle) {
|
if(changestyle) {
|
||||||
if(e.parentNode && e.parentNode.tagName.toLowerCase() == 'li') {
|
if(e.parentNode && e.parentNode.tagName.toLowerCase() == 'li') {
|
||||||
e.parentNode.className = e.checked ? 'checked' : '';
|
e.parentNode.className = e.checked ? 'checked' : '';
|
||||||
}
|
}
|
||||||
if(e.parentNode.parentNode && e.parentNode.parentNode.tagName.toLowerCase() == 'div') {
|
if(e.parentNode.parentNode && e.parentNode.parentNode.tagName.toLowerCase() == 'div') {
|
||||||
e.parentNode.parentNode.className = e.checked ? 'item checked' : 'item';
|
e.parentNode.parentNode.className = e.checked ? 'item checked' : 'item';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function fixTree_organization(el){
|
function fixTree_organization(el){
|
||||||
el.find('.tree-heng1').each(function(){
|
el.find('.tree-heng1').each(function(){
|
||||||
var tr=jQuery(this).parent().parent().parent();
|
var tr=jQuery(this).parent().parent().parent();
|
||||||
var dep=jQuery(this).parent().find('.tree-su').length;
|
var dep=jQuery(this).parent().find('.tree-su').length;
|
||||||
|
|
||||||
tr.nextAll().each(function(){
|
tr.nextAll().each(function(){
|
||||||
var child_org=jQuery(this).find('.child-org');
|
var child_org=jQuery(this).find('.child-org');
|
||||||
var dep1=child_org.find('.tree-su').length;
|
var dep1=child_org.find('.tree-su').length;
|
||||||
if(dep1<=dep) return false;
|
if(dep1<=dep) return false;
|
||||||
else{
|
else{
|
||||||
child_org.find('.tree-su').eq(dep).removeClass('tree-su');
|
child_org.find('.tree-su').eq(dep).removeClass('tree-su');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
.max-width[data-v-6168216d]{width:360px}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
.wait-files[data-v-00939ee2]{line-height:25px;border:1px solid #dcdfe6;margin-bottom:10px;padding:5px;font-size:14px}
|
|
||||||
@@ -1 +1 @@
|
|||||||
.el-avatar[data-v-6f47bc15]{float:left;cursor:pointer}.el-divider--horizontal.el-divider[data-v-6f47bc15]{margin:8px 0}.aboutPichome{padding:0;width:478px}.aboutPichome .el-message-box__btns,.aboutPichome .el-message-box__header{display:none}.aboutPichome .aboutlogo{text-align:center;line-height:0;padding-top:40px}.aboutPichome .aboutmessage{padding:65px 40px;font-size:19px;padding-bottom:15px}.aboutPichome .aboutmessage .aboutlist{margin-bottom:20px;overflow:hidden}.aboutPichome a{text-decoration:none}.aboutPichome .aboutmessage .aboutlist .title{float:left;width:95px}.aboutPichome .aboutmessage .aboutlist .mes{float:left;width:calc(100% - 95px)}.aboutPichome .aboutmessage .aboutlist .update{font-size:12px}
|
.el-avatar[data-v-1aac96c1]{float:left;cursor:pointer}.el-divider--horizontal.el-divider[data-v-1aac96c1]{margin:8px 0}.aboutPichome{padding:0;width:478px}.aboutPichome .el-message-box__btns,.aboutPichome .el-message-box__header{display:none}.aboutPichome .aboutlogo{text-align:center;line-height:0;padding-top:40px}.aboutPichome .aboutmessage{padding:65px 40px;font-size:19px;padding-bottom:15px}.aboutPichome .aboutmessage .aboutlist{margin-bottom:20px;overflow:hidden}.aboutPichome a{text-decoration:none}.aboutPichome .aboutmessage .aboutlist .title{float:left;width:95px}.aboutPichome .aboutmessage .aboutlist .mes{float:left;width:calc(100% - 95px)}.aboutPichome .aboutmessage .aboutlist .update{font-size:12px}
|
||||||
@@ -1 +0,0 @@
|
|||||||
.el-avatar[data-v-663b95fa]{float:left;cursor:pointer}.el-divider--horizontal.el-divider[data-v-663b95fa]{margin:8px 0}.aboutPichome{padding:0;width:478px}.aboutPichome .el-message-box__btns,.aboutPichome .el-message-box__header{display:none}.aboutPichome .aboutlogo{text-align:center;line-height:0;padding-top:40px}.aboutPichome .aboutmessage{padding:65px 40px;font-size:19px;padding-bottom:15px}.aboutPichome .aboutmessage .aboutlist{margin-bottom:20px;overflow:hidden}.aboutPichome a{text-decoration:none}.aboutPichome .aboutmessage .aboutlist .title{float:left;width:95px}.aboutPichome .aboutmessage .aboutlist .mes{float:left;width:calc(100% - 95px)}.aboutPichome .aboutmessage .aboutlist .update{font-size:12px}
|
|
||||||
@@ -1 +1 @@
|
|||||||
.el-container[data-v-6b6f1ca9],.el-main[data-v-6b6f1ca9]{height:100%}.el-main[data-v-6b6f1ca9]{padding:0}.top-title .el-steps[data-v-31baf320]{background:transparent;padding:0 25px}.top-title .el-steps[data-v-31baf320] .el-step__icon{vertical-align:middle}.el-progress[data-v-31baf320]{width:400px;display:inline-block}.content[data-v-31baf320]{padding:20px 25px}.help-inline li[data-v-31baf320]{margin-bottom:5px}.top-title .main-title[data-v-da54ce54]{font-size:14px;color:#909399;cursor:pointer;margin-right:20px;vertical-align:bottom}.top-title .main-title.is-active[data-v-da54ce54]{color:#369}.content[data-v-da54ce54]{padding:20px 25px}.systemExportNotify{width:auto}.help-inline li[data-v-174d5b16]{margin-bottom:5px;padding:0}.max-width[data-v-174d5b16]{width:260px}.custom-single[data-v-174d5b16]{height:40px;margin-bottom:5px}.custom-single .el-checkbox[data-v-174d5b16]{overflow:hidden}.custom-single .el-checkbox[data-v-174d5b16] .el-checkbox__input{vertical-align:text-top}.custom-single .el-checkbox[data-v-174d5b16] .el-checkbox__label{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.el-checkbox[data-v-174d5b16],.el-radio[data-v-174d5b16]{margin-bottom:5px;margin-left:0!important}.el-radio[data-v-174d5b16]{min-width:260px}.max-width[data-v-71031654]{width:50%}.content[data-v-24008314]{padding:20px 25px}.help-inline li[data-v-24008314]{margin-bottom:5px;padding:0}.help-inline[data-v-5e61246c]{display:block}.help-inline li[data-v-5e61246c]{margin-bottom:5px;padding:0}.max-width[data-v-5e61246c]{width:360px}
|
.el-container[data-v-51d41a2c],.el-main[data-v-51d41a2c]{height:100%}.el-main[data-v-51d41a2c]{padding:0}.top-title .el-steps[data-v-31baf320]{background:transparent;padding:0 25px}.top-title .el-steps[data-v-31baf320] .el-step__icon{vertical-align:middle}.el-progress[data-v-31baf320]{width:400px;display:inline-block}.content[data-v-31baf320]{padding:20px 25px}.help-inline li[data-v-31baf320]{margin-bottom:5px}.top-title .main-title[data-v-da54ce54]{font-size:14px;color:#909399;cursor:pointer;margin-right:20px;vertical-align:bottom}.top-title .main-title.is-active[data-v-da54ce54]{color:#369}.content[data-v-da54ce54]{padding:20px 25px}.systemExportNotify{width:auto}.help-inline li[data-v-174d5b16]{margin-bottom:5px;padding:0}.max-width[data-v-174d5b16]{width:260px}.custom-single[data-v-174d5b16]{height:40px;margin-bottom:5px}.custom-single .el-checkbox[data-v-174d5b16]{overflow:hidden}.custom-single .el-checkbox[data-v-174d5b16] .el-checkbox__input{vertical-align:text-top}.custom-single .el-checkbox[data-v-174d5b16] .el-checkbox__label{width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.el-checkbox[data-v-174d5b16],.el-radio[data-v-174d5b16]{margin-bottom:5px;margin-left:0!important}.el-radio[data-v-174d5b16]{min-width:260px}.max-width[data-v-71031654]{width:50%}.content[data-v-24008314]{padding:20px 25px}.help-inline li[data-v-24008314]{margin-bottom:5px;padding:0}.help-inline[data-v-5e61246c]{display:block}.help-inline li[data-v-5e61246c]{margin-bottom:5px;padding:0}.max-width[data-v-5e61246c]{width:360px}
|
||||||
2
admin/system/dist/index.html
vendored
2
admin/system/dist/index.html
vendored
@@ -1 +1 @@
|
|||||||
<!DOCTYPE html><html lang=zh><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title></title><link href=admin/system/dist/css/chunk-2b4f90f7.519dec70.css rel=prefetch><link href=admin/system/dist/css/chunk-494f643e.7502109f.css rel=prefetch><link href=admin/system/dist/css/chunk-5ae5cc35.d763cbce.css rel=prefetch><link href=admin/system/dist/css/chunk-74c32c70.4b7d665e.css rel=prefetch><link href=admin/system/dist/css/chunk-76f23146.6fc79cd8.css rel=prefetch><link href=admin/system/dist/css/chunk-7828662a.c81657ef.css rel=prefetch><link href=admin/system/dist/css/chunk-801d4da6.a47ba236.css rel=prefetch><link href=admin/system/dist/css/chunk-9f9c2568.5356ad7d.css rel=prefetch><link href=admin/system/dist/css/chunk-af3b1b98.b822363f.css rel=prefetch><link href=admin/system/dist/css/chunk-e730cc06.987283b7.css rel=prefetch><link href=admin/system/dist/css/system_temp.a56510eb.css rel=prefetch><link href=admin/system/dist/js/chunk-2b4f90f7.8dd0185d.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0a3327.ad2684c9.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0bdbc6.4ec7bc5e.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0dd46d.e13ddeba.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0efd3c.44a093d1.js rel=prefetch><link href=admin/system/dist/js/chunk-2d20fcd9.50f81306.js rel=prefetch><link href=admin/system/dist/js/chunk-2d21ddf7.9f7b329e.js rel=prefetch><link href=admin/system/dist/js/chunk-494f643e.77a11d42.js rel=prefetch><link href=admin/system/dist/js/chunk-5ae5cc35.25761a21.js rel=prefetch><link href=admin/system/dist/js/chunk-74c32c70.1f5e9382.js rel=prefetch><link href=admin/system/dist/js/chunk-76f23146.0d2957ed.js rel=prefetch><link href=admin/system/dist/js/chunk-7828662a.e587f025.js rel=prefetch><link href=admin/system/dist/js/chunk-801d4da6.0f74a3ea.js rel=prefetch><link href=admin/system/dist/js/chunk-9f9c2568.538835dd.js rel=prefetch><link href=admin/system/dist/js/chunk-af3b1b98.850ec152.js rel=prefetch><link href=admin/system/dist/js/chunk-e730cc06.3ce9a994.js rel=prefetch><link href=admin/system/dist/js/system_temp.c7e32270.js rel=prefetch><link href=admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=preload as=style><link href=admin/system/dist/css/index.7d0ec6bf.css rel=preload as=style><link href=admin/system/dist/js/chunk-vendors.3b95dfe3.js rel=preload as=script><link href=admin/system/dist/js/index.5892fe49.js rel=preload as=script><link href=admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=stylesheet><link href=admin/system/dist/css/index.7d0ec6bf.css rel=stylesheet></head><body><div id=app></div><script src=admin/system/dist/js/chunk-vendors.3b95dfe3.js></script><script src=admin/system/dist/js/index.5892fe49.js></script></body></html>
|
<!DOCTYPE html><html lang=zh><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=favicon.ico><title></title><link href=admin/system/dist/css/chunk-2b4f90f7.519dec70.css rel=prefetch><link href=admin/system/dist/css/chunk-494f643e.7502109f.css rel=prefetch><link href=admin/system/dist/css/chunk-5ae5cc35.d763cbce.css rel=prefetch><link href=admin/system/dist/css/chunk-74c32c70.4b7d665e.css rel=prefetch><link href=admin/system/dist/css/chunk-76f23146.6fc79cd8.css rel=prefetch><link href=admin/system/dist/css/chunk-7828662a.c81657ef.css rel=prefetch><link href=admin/system/dist/css/chunk-7aef2525.9e97ae28.css rel=prefetch><link href=admin/system/dist/css/chunk-9f9c2568.5356ad7d.css rel=prefetch><link href=admin/system/dist/css/chunk-af3b1b98.b822363f.css rel=prefetch><link href=admin/system/dist/css/chunk-e730cc06.987283b7.css rel=prefetch><link href=admin/system/dist/css/system_temp.abc9b69c.css rel=prefetch><link href=admin/system/dist/js/chunk-2b4f90f7.45b9151d.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0a3327.ad2684c9.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0bdbc6.4ec7bc5e.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0dd46d.e13ddeba.js rel=prefetch><link href=admin/system/dist/js/chunk-2d0efd3c.44a093d1.js rel=prefetch><link href=admin/system/dist/js/chunk-2d20fcd9.50f81306.js rel=prefetch><link href=admin/system/dist/js/chunk-2d21ddf7.9f7b329e.js rel=prefetch><link href=admin/system/dist/js/chunk-494f643e.77a11d42.js rel=prefetch><link href=admin/system/dist/js/chunk-5ae5cc35.25761a21.js rel=prefetch><link href=admin/system/dist/js/chunk-74c32c70.1f5e9382.js rel=prefetch><link href=admin/system/dist/js/chunk-76f23146.0d2957ed.js rel=prefetch><link href=admin/system/dist/js/chunk-7828662a.e587f025.js rel=prefetch><link href=admin/system/dist/js/chunk-7aef2525.35b8efb8.js rel=prefetch><link href=admin/system/dist/js/chunk-9f9c2568.538835dd.js rel=prefetch><link href=admin/system/dist/js/chunk-af3b1b98.850ec152.js rel=prefetch><link href=admin/system/dist/js/chunk-e730cc06.3ce9a994.js rel=prefetch><link href=admin/system/dist/js/system_temp.b94f1119.js rel=prefetch><link href=admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=preload as=style><link href=admin/system/dist/css/index.7d0ec6bf.css rel=preload as=style><link href=admin/system/dist/js/chunk-vendors.3b95dfe3.js rel=preload as=script><link href=admin/system/dist/js/index.b9edc49b.js rel=preload as=script><link href=admin/system/dist/css/chunk-vendors.4d5d56a8.css rel=stylesheet><link href=admin/system/dist/css/index.7d0ec6bf.css rel=stylesheet></head><body><div id=app></div><script src=admin/system/dist/js/chunk-vendors.3b95dfe3.js></script><script src=admin/system/dist/js/index.b9edc49b.js></script></body></html>
|
||||||
@@ -1 +1 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2b4f90f7"],{3685:function(t,e,a){},ec9e:function(t,e,a){"use strict";var n=a("3685"),i=a.n(n);i.a},fcc8f:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"resNav"},[a("div",{staticClass:"resNav-item resNav-left"},[a("a",{staticClass:"h-left",attrs:{href:"javascript:;"},on:{click:function(e){return t.goBack()}}},[a("el-image",{attrs:{src:"data/attachment/sitelogo/sitelogo.png",fit:"contain"}}),a("span",{staticClass:"text"},[t._v(t._s(t.navTitle))])],1)]),a("div",{staticClass:"resNav-item resNav-center"}),a("div",{staticClass:"resNav-item resNav-right"},[a("Mavatar")],1)])},i=[],c=(a("d3b7"),a("5530")),s=a("2f62"),r={props:["hideContent","apptype","hideBack"],data:function(){return{}},computed:Object(c["a"])(Object(c["a"])({},Object(s["c"])(["headerName","navTitle","IfuserAgent"])),Object(s["b"])(["GetNavMenu"])),methods:{handleClick:function(t){var e=this.GetNavMenu;for(var a in e)if(e[a].index==t){"admin"==e[a].type?window.location.href="admin.php?mod="+t:window.location.href="index.php?mod="+t;break}},goBack:function(){window.location.href="/"}},components:{Mavatar:function(){return a.e("chunk-801d4da6").then(a.bind(null,"6254"))}}},o=r,d=(a("ec9e"),a("2877")),l=Object(d["a"])(o,n,i,!1,null,"b9d2b62e",null);e["default"]=l.exports}}]);
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2b4f90f7"],{3685:function(t,e,a){},ec9e:function(t,e,a){"use strict";var n=a("3685"),i=a.n(n);i.a},fcc8f:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"resNav"},[a("div",{staticClass:"resNav-item resNav-left"},[a("a",{staticClass:"h-left",attrs:{href:"javascript:;"},on:{click:function(e){return t.goBack()}}},[a("el-image",{attrs:{src:"data/attachment/sitelogo/sitelogo.png",fit:"contain"}}),a("span",{staticClass:"text"},[t._v(t._s(t.navTitle))])],1)]),a("div",{staticClass:"resNav-item resNav-center"}),a("div",{staticClass:"resNav-item resNav-right"},[a("Mavatar")],1)])},i=[],c=(a("d3b7"),a("5530")),s=a("2f62"),r={props:["hideContent","apptype","hideBack"],data:function(){return{}},computed:Object(c["a"])(Object(c["a"])({},Object(s["c"])(["headerName","navTitle","IfuserAgent"])),Object(s["b"])(["GetNavMenu"])),methods:{handleClick:function(t){var e=this.GetNavMenu;for(var a in e)if(e[a].index==t){"admin"==e[a].type?window.location.href="admin.php?mod="+t:window.location.href="index.php?mod="+t;break}},goBack:function(){window.location.href="/"}},components:{Mavatar:function(){return a.e("chunk-7aef2525").then(a.bind(null,"6254"))}}},o=r,l=(a("ec9e"),a("2877")),d=Object(l["a"])(o,n,i,!1,null,"b9d2b62e",null);e["default"]=d.exports}}]);
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2b4f90f7"],{3685:function(t,e,a){},ec9e:function(t,e,a){"use strict";var n=a("3685"),i=a.n(n);i.a},fcc8f:function(t,e,a){"use strict";a.r(e);var n=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"resNav"},[a("div",{staticClass:"resNav-item resNav-left"},[a("a",{staticClass:"h-left",attrs:{href:"javascript:;"},on:{click:function(e){return t.goBack()}}},[a("el-image",{attrs:{src:"data/attachment/sitelogo/sitelogo.png",fit:"contain"}}),a("span",{staticClass:"text"},[t._v(t._s(t.navTitle))])],1)]),a("div",{staticClass:"resNav-item resNav-center"}),a("div",{staticClass:"resNav-item resNav-right"},[a("Mavatar")],1)])},i=[],c=(a("d3b7"),a("5530")),s=a("2f62"),r={props:["hideContent","apptype","hideBack"],data:function(){return{}},computed:Object(c["a"])(Object(c["a"])({},Object(s["c"])(["headerName","navTitle","IfuserAgent"])),Object(s["b"])(["GetNavMenu"])),methods:{handleClick:function(t){var e=this.GetNavMenu;for(var a in e)if(e[a].index==t){"admin"==e[a].type?window.location.href="admin.php?mod="+t:window.location.href="index.php?mod="+t;break}},goBack:function(){window.location.href="/"}},components:{Mavatar:function(){return a.e("chunk-5cdcd199").then(a.bind(null,"6254"))}}},o=r,d=(a("ec9e"),a("2877")),l=Object(d["a"])(o,n,i,!1,null,"b9d2b62e",null);e["default"]=l.exports}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0bdbc6"],{"2ced":function(t,n,e){"use strict";e.r(n);var c=function(){var t=this,n=t.$createElement,e=t._self._c||n;return e("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","text-align":"center"},attrs:{shadow:"hover"}},[e("p",[t._v(t._s(t.$t("upgrade_none")))])])},a=[],o={data:function(){return{}},created:function(){},methods:{},components:{},mounted:function(){}},r=o,s=e("2877"),u=Object(s["a"])(r,c,a,!1,null,null,null);n["default"]=u.exports}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0dd46d"],{8164:function(e,t,a){"use strict";a.r(t);var s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}]},[a("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","text-align":"center"},attrs:{shadow:"hover"}},[a("p",{staticStyle:{"margin-bottom":"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful1")))])],1),a("p",{staticStyle:{margin:"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful2",{msg:e.$route.params.version})))])],1),a("p",{staticStyle:{"margin-bottom":"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful3",{dir:e.dir})))])],1),a("p",{staticStyle:{margin:"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful4",{backdir:e.backdir})))])],1)])],1)},n=[],r=(a("96cf"),a("1da1")),i={data:function(){return{loading:!1,dir:"",backdir:""}},created:function(){this.getData()},methods:{getData:function(){var e=this;return Object(r["a"])(regeneratorRuntime.mark((function t(){var a,s;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,t.next=3,e.axios.post("admin.php?mod=system&op=intsystemupgrade&operation=patch&step=5",{version:e.$route.params.version});case 3:a=t.sent,s=a.data,e.dir=s.dir,e.backdir=s.backdir,e.loading=!1;case 8:case"end":return t.stop()}}),t)})))()}},components:{},mounted:function(){}},c=i,d=a("2877"),u=Object(d["a"])(c,s,n,!1,null,"f4790950",null);t["default"]=u.exports}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0dd46d"],{8164:function(e,t,a){"use strict";a.r(t);var s=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}]},[a("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","text-align":"center"},attrs:{shadow:"hover"}},[a("p",{staticStyle:{"margin-bottom":"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful1")))])],1),a("p",{staticStyle:{margin:"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful2",{msg:e.$route.params.version})))])],1),a("p",{staticStyle:{"margin-bottom":"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful3",{dir:e.dir})))])],1),a("p",{staticStyle:{margin:"0"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("upgrade_successful4",{backdir:e.backdir})))])],1)])],1)},n=[],r=(a("96cf"),a("1da1")),i={data:function(){return{loading:!1,dir:"",backdir:""}},created:function(){this.getData()},methods:{getData:function(){var e=this;return Object(r["a"])(regeneratorRuntime.mark((function t(){var a,s;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,t.next=3,e.axios.post("admin.php?mod=system&op=intsystemupgrade&operation=patch&step=5",{version:e.$route.params.version});case 3:a=t.sent,s=a.data,e.dir=s.dir,e.backdir=s.backdir,e.loading=!1;case 8:case"end":return t.stop()}}),t)})))()}},components:{},mounted:function(){}},c=i,d=a("2877"),u=Object(d["a"])(c,s,n,!1,null,"306dae10",null);t["default"]=u.exports}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0efd3c"],{"9a86":function(e,t,a){"use strict";a.r(t);var r=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}]},[e.floading?a("div",[e.tableData.length?[a("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","margin-bottom":"25px"},attrs:{shadow:"hover"}},[a("ul",{staticClass:"help-inline",domProps:{innerHTML:e._s(e.$t("founder_upgrade_diff_show",{version:e.returnData.version,oldversion:e.oldversion}))}})]),a("el-table",{staticStyle:{width:"100%"},attrs:{data:e.tableData,border:""}},[a("el-table-column",{attrs:{prop:"name",label:"文件名"}}),a("el-table-column",{attrs:{align:"center",prop:"status",label:"状态",width:"120"},scopedSlots:e._u([{key:"default",fn:function(t){return[1==t.row.status?[a("el-link",{attrs:{underline:!1,type:"danger"}},[e._v(e._s(e.$t("founder_upgrade_diff")))])]:2==t.row.status?[a("el-link",{attrs:{underline:!1,type:"info"}},[e._v(e._s(e.$t("founder_upgrade_normal")))])]:3==t.row.status?[a("el-link",{attrs:{underline:!1,type:"primary"}},[e._v(e._s(e.$t("founder_upgrade_new")))])]:e._e()]}}],null,!1,3979069617)})],1),a("div",{staticStyle:{"margin-top":"10px"}},[a("el-button",{attrs:{size:"small",type:"primary"},on:{click:e.handleupdate}},[e._v(e._s(e.button))])],1)]:[a("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)"},attrs:{shadow:"hover"}},[a("el-link",{attrs:{type:"success",underline:!1}},[e._v(e._s(e.$t("filecheck_nofound_md5file")))])],1)]],2):e._e()])},n=[],o=(a("96cf"),a("1da1")),s={props:["returnData"],data:function(){return{loading:!1,floading:!1,tableData:[],button:"",oldversion:""}},created:function(){this.getData()},methods:{getData:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){var a,r,n,o,s;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,a={version:e.returnData.version?e.returnData.version:"",locale:e.returnData.locale?e.returnData.locale:"",charset:e.returnData.charset?e.returnData.charset:""},t.next=4,e.axios.post("admin.php?mod=system&op=intsystemupgrade&operation=patch&step=3",a);case 4:if(r=t.sent,n=r.data,!n.upgradeNone){t.next=12;break}return o={upgradeNone:!0},e.$emit("handleStep",o),t.abrupt("return",!1);case 12:if(!n.upgradeError){t.next=18;break}return o={upgradeError:!0},e.$emit("handleStep",o),t.abrupt("return",!1);case 18:if(!n.bbclosed){t.next=22;break}return s={template:"bbclosed"},e.$emit("handleStep",s),t.abrupt("return",!1);case 22:e.tableData=n.tableData,e.button=n.button,e.oldversion=n.oldversion,e.loading=!1,e.floading=!0;case 27:case"end":return t.stop()}}),t)})))()},handleupdate:function(){var e={template:4};return this.$emit("handleStep",e),!1}},components:{},mounted:function(){}},l=s,i=a("2877"),u=Object(i["a"])(l,r,n,!1,null,null,null);t["default"]=u.exports}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d21ddf7"],{d2c6:function(t,e,a){"use strict";a.r(e);var r=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[3==t.downloadstatus?[a("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","text-align":"center"},attrs:{shadow:"hover"}},[a("p",[t._v(t._s(t.$t("upgrade_redownload",{file:t.data.file})))]),a("el-button",{attrs:{type:"primary",size:"medium"},on:{click:t.handleretry}},[t._v(t._s(t.$t("retry")))])],1)]:[a("el-card",{staticClass:"box-card",staticStyle:{width:"600px",margin:"0 auto","margin-top":"50px"}},[a("div",{staticClass:"clearfix",staticStyle:{"text-align":"center"},attrs:{slot:"header"},slot:"header"},[a("span",[t._v(t._s(t.$t("upgrade_downloading_file")))])]),a("p",{staticStyle:{width:"100%",overflow:"hidden","white-space":"nowrap","text-overflow":"ellipsis","font-size":"14px"}},[4==t.downloadstatus?[t._v(t._s(t.$t("upgrade_download_complete_to_compare")))]:[t._v(t._s(t.data.file))]],2),a("el-progress",{staticStyle:{"margin-bottom":"20px"},attrs:{"text-inside":!0,"stroke-width":26,percentage:t.data.percent}})],1)]],2)},n=[],s=(a("96cf"),a("1da1")),o={props:["returnData"],data:function(){return{stepstatus:!0,downloadstatus:0,data:{file:"",fileseq:1,percent:0}}},created:function(){this.getData()},methods:{getData:function(){var t=this;return Object(s["a"])(regeneratorRuntime.mark((function e(){var a,r,n,s,o,d;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(t.stepstatus){e.next=2;break}return e.abrupt("return",!1);case 2:return a={version:t.returnData.version?t.returnData.version:"",locale:t.returnData.locale?t.returnData.locale:"",charset:t.returnData.charset?t.returnData.charset:"",fileseq:t.data.fileseq},e.next=5,t.axios.post("admin.php?mod=system&op=intsystemupgrade&operation=patch&step=2",a);case 5:if(r=e.sent,n=r.data,!n.upgradeNone){e.next=13;break}return s={upgradeNone:!0},t.$emit("handleStep",s),e.abrupt("return",!1);case 13:if(!n.upgradeError){e.next=19;break}return s={upgradeError:!0},t.$emit("handleStep",s),e.abrupt("return",!1);case 19:if(!n.bbclosed){e.next=23;break}return o={template:"bbclosed"},t.$emit("handleStep",o),e.abrupt("return",!1);case 23:return t.downloadstatus=n.downloadstatus,3==n.downloadstatus?t.data.file=n.data.file:4==n.downloadstatus?(t.data.percent=100,d={template:3},setTimeout((function(){t.$emit("handleStep",d)}),1e3)):(n.data.percent=parseInt(n.data.percent),t.data=n.data,t.getData()),e.abrupt("return",!1);case 26:case"end":return e.stop()}}),e)})))()},handleretry:function(){window.location.reload()}},components:{},mounted:function(){},destroyed:function(){this.stepstatus=!1}},d=o,i=a("2877"),u=Object(i["a"])(d,r,n,!1,null,null,null);e["default"]=u.exports}}]);
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-5cdcd199"],{6254:function(t,a,e){"use strict";e.r(a);var o=function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticStyle:{"margin-left":"10px",display:"inherit"}},[e("el-dropdown",{staticStyle:{width:"35px",height:"35px"},attrs:{trigger:"click","hide-on-click":!1},on:{command:t.handleAvatar}},[t.GetUserData.icon?[e("el-tooltip",{staticClass:"item",attrs:{effect:"dark",content:t.GetUserData.username,placement:"left"}},[e("el-avatar",{attrs:{size:35,src:t.GetUserData.icon}})],1)]:[e("el-tooltip",{staticClass:"item",attrs:{effect:"dark",content:t.GetUserData.username,placement:"left"}},[e("el-avatar",{style:{background:t.GetUserData.headerColor},attrs:{size:35}},[t._v(t._s(t.GetUserData.firstword))])],1)],e("el-dropdown-menu",{staticClass:"avatar-dropdown",attrs:{slot:"dropdown"},slot:"dropdown"},[e("el-dropdown-item",{attrs:{command:"personal"}},[t._v("个人设置")]),e("el-dropdown-item",{attrs:{command:"help"}},[t._v("帮助文档")]),e("el-dropdown-item",{attrs:{command:"problem"}},[t._v("问题反馈")]),e("el-divider"),e("el-dropdown-item",{attrs:{command:"setting"}},[t._v("站点设置")]),e("el-dropdown-item",{attrs:{command:"library"}},[t._v("库设置")]),e("el-dropdown-item",{attrs:{command:"system"}},[e("span",{staticStyle:{position:"relative"}},[t._v(" 系统工具 "),t.GetUserData.upgrade?e("div",{staticClass:"tip",staticStyle:{width:"7px",height:"7px","border-radius":"50%",background:"red",position:"absolute",left:"-13px",top:"0",bottom:"0",margin:"auto"}}):t._e()])]),e("el-divider"),e("el-dropdown-item",{attrs:{command:"about"}},[t._v("关于PicHome")]),e("el-dropdown-item",{attrs:{command:"OutLogin"}},[t._v("退出站点")])],1)],2)],1)},s=[],n=(e("96cf"),e("1da1")),i=e("5530"),r=e("2f62"),c={data:function(){return{}},computed:Object(i["a"])({},Object(r["b"])(["GetUserData","GetFormHash","GetLanguage"])),methods:{handleAvatar:function(t){switch(t){case"personal":window.location.href="index.php?mod=pichome&op=user&do=personal";break;case"help":window.open("https://www.yuque.com/pichome");break;case"problem":window.open("https://support.qq.com/products/340252");break;case"setting":window.location.href="index.php?mod=pichome&op=admin&do=basic";break;case"library":window.location.href="index.php?mod=pichome&op=library";break;case"about":this.$alert('<div class="aboutlogo">\n \t\t\t<img src="dzz/pichome/image/phlogo.png" alt="">\n \t\t</div>\n \t\t<div class="aboutmessage">\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">软件名称:</span><span class="mes">欧奥PicHome</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">版本信息:</span><span class="mes">'+this.GetUserData.version+'</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">版权信息:</span><span class="mes">Powered By oaooa PicHome © 2020-2021 欧奥图文</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">网站地址:</span><span class="mes"><a class="address" href="https://oaooa.com/" target="_blank">oaooa.com</a></span>\n \t\t\t</div>\n \t\t</div>',"",{customClass:"aboutPichome",showClose:!1,showConfirmButton:!1,dangerouslyUseHTMLString:!0,closeOnClickModal:!0});break;case"OutLogin":this.outLogin();break;case"system":window.open("admin.php?mod=system");break}return!1},outLogin:function(){var t=this;return Object(n["a"])(regeneratorRuntime.mark((function a(){var e;return regeneratorRuntime.wrap((function(a){while(1)switch(a.prev=a.next){case 0:return a.next=2,t.axios.post(t.AxiosApi+"user.php?mod=login&op=logging&action=logout&formhash="+t.GetFormHash+"&t="+(new Date).getTime());case 2:e=a.sent,e.data,window.location.reload();case 5:case"end":return a.stop()}}),a)})))()}}},d=c,l=(e("d2ba"),e("9c24"),e("2877")),p=Object(l["a"])(d,o,s,!1,null,"6f47bc15",null);a["default"]=p.exports},"864f":function(t,a,e){},"9c24":function(t,a,e){"use strict";var o=e("864f"),s=e.n(o);s.a},ae63:function(t,a,e){},d2ba:function(t,a,e){"use strict";var o=e("ae63"),s=e.n(o);s.a}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-77c8d08e"],{"1f5d":function(e,t,a){"use strict";a.r(t);var n=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}]},[a("el-card",{staticClass:"box-card",staticStyle:{background:"rgb(240, 249, 235)","margin-bottom":"25px"},attrs:{shadow:"hover"}},[a("ul",{staticClass:"help-inline",domProps:{innerHTML:e._s(e.$t("founder_upgrade_store_directory",{msg:e.returnData.version}))}})]),e._l(e.files,(function(t){return a("div",{staticClass:"wait-files"},[a("i",{staticClass:"el-icon-document"}),e._v(" "+e._s(t)+" ")])})),a("el-button",{attrs:{type:"primary",size:"medium"},on:{click:e.handleupdate}},[e._v(e._s(e.$t("founder_upgrade_download")))])],2)},r=[],o=(a("96cf"),a("1da1")),i={props:["returnData"],data:function(){return{files:[],loading:!1}},created:function(){this.getData()},methods:{getData:function(){var e=this;return Object(o["a"])(regeneratorRuntime.mark((function t(){var a,n,r,o,i;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return e.loading=!0,a={version:e.returnData.version?e.returnData.version:"",locale:e.returnData.locale?e.returnData.locale:"",charset:e.returnData.charset?e.returnData.charset:""},t.next=4,e.axios.post("admin.php?mod=system&op=intsystemupgrade&operation=patch&step=1",a);case 4:return n=t.sent,r=n.data,r.upgradeNone?(o={upgradeNone:!0},e.$emit("handleStep",o)):r.upgradeError?(o={upgradeError:!0},e.$emit("handleStep",o)):r.bbclosed?(i={bbclosed:!0},e.$emit("handleStep",i)):(e.files=r.data,e.loading=!1),t.abrupt("return",!1);case 8:case"end":return t.stop()}}),t)})))()},handleupdate:function(){var e={template:2};this.$emit("handleStep",e)}},components:{},mounted:function(){}},s=i,u=(a("7949"),a("2877")),d=Object(u["a"])(s,n,r,!1,null,"00939ee2",null);t["default"]=d.exports},7949:function(e,t,a){"use strict";var n=a("93b8"),r=a.n(n);r.a},"93b8":function(e,t,a){}}]);
|
|
||||||
1
admin/system/dist/js/chunk-7aef2525.35b8efb8.js
vendored
Normal file
1
admin/system/dist/js/chunk-7aef2525.35b8efb8.js
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-7aef2525"],{"3e42":function(t,e,a){},6254:function(t,e,a){"use strict";a.r(e);var o=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticStyle:{"margin-left":"10px",display:"inherit"}},[a("el-dropdown",{staticStyle:{width:"35px",height:"35px"},attrs:{trigger:"click","hide-on-click":!1},on:{command:t.handleAvatar}},[t.GetUserData.icon?[a("el-tooltip",{staticClass:"item",attrs:{effect:"dark",content:t.GetUserData.username,placement:"left"}},[a("el-avatar",{attrs:{size:35,src:t.GetUserData.icon}})],1)]:[a("el-tooltip",{staticClass:"item",attrs:{effect:"dark",content:t.GetUserData.username,placement:"left"}},[a("el-avatar",{style:{background:t.GetUserData.headerColor},attrs:{size:35}},[t._v(t._s(t.GetUserData.firstword))])],1)],a("el-dropdown-menu",{staticClass:"avatar-dropdown",attrs:{slot:"dropdown"},slot:"dropdown"},[a("el-dropdown-item",{attrs:{command:"personal"}},[t._v("个人设置")]),a("el-dropdown-item",{attrs:{command:"help"}},[t._v("帮助文档")]),a("el-dropdown-item",{attrs:{command:"problem"}},[t._v("问题反馈")]),a("el-divider"),a("el-dropdown-item",{attrs:{command:"setting"}},[t._v("站点设置")]),a("el-dropdown-item",{attrs:{command:"library"}},[t._v("库设置")]),a("el-dropdown-item",{attrs:{command:"system"}},[a("span",{staticStyle:{position:"relative"}},[t._v(" 系统工具 "),t.GetUserData.upgrade?a("div",{staticClass:"tip",staticStyle:{width:"7px",height:"7px","border-radius":"50%",background:"red",position:"absolute",left:"-13px",top:"0",bottom:"0",margin:"auto"}}):t._e()])]),a("el-divider"),a("el-dropdown-item",{attrs:{command:"about"}},[t._v("关于PicHome")]),a("el-dropdown-item",{attrs:{command:"OutLogin"}},[t._v("退出站点")])],1)],2)],1)},s=[],n=(a("96cf"),a("1da1")),i=a("5530"),r=a("2f62"),c={data:function(){return{}},computed:Object(i["a"])({},Object(r["b"])(["GetUserData","GetFormHash","GetLanguage"])),methods:{handleAvatar:function(t){switch(t){case"collection":window.location.href="index.php?mod=collection";break;case"personal":window.location.href="index.php?mod=pichome&op=user&do=personal";break;case"help":window.open("https://www.yuque.com/pichome");break;case"problem":window.open("https://support.qq.com/products/340252");break;case"setting":window.location.href="index.php?mod=pichome&op=admin&do=authorize";break;case"library":window.location.href="index.php?mod=pichome&op=library";break;case"about":this.$alert('<div class="aboutlogo">\n \t\t\t<img src="dzz/pichome/image/phlogo.png" alt="">\n \t\t</div>\n \t\t<div class="aboutmessage">\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">软件名称:</span><span class="mes">欧奥PicHome</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">版本信息:</span><span class="mes">'+this.GetUserData.version+'</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">版权信息:</span><span class="mes">Powered By oaooa PicHome © 2020-2022 欧奥图文</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">网站地址:</span><span class="mes"><a class="address" href="https://oaooa.com/" target="_blank">oaooa.com</a></span>\n \t\t\t</div>\n \t\t</div>',"",{customClass:"aboutPichome",showClose:!1,showConfirmButton:!1,dangerouslyUseHTMLString:!0,closeOnClickModal:!0});break;case"OutLogin":this.outLogin();break;case"system":window.open("admin.php?mod=system");break;case"orguser":window.open("admin.php?mod=orguser");break}return!1},outLogin:function(){var t=this;return Object(n["a"])(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,t.axios.post(t.AxiosApi+"user.php?mod=login&op=logging&action=logout&formhash="+t.GetFormHash+"&t="+(new Date).getTime());case 2:a=e.sent,a.data,window.location.reload();case 5:case"end":return e.stop()}}),e)})))()}}},d=c,l=(a("74bc"),a("9c24"),a("2877")),p=Object(l["a"])(d,o,s,!1,null,"1aac96c1",null);e["default"]=p.exports},"74bc":function(t,e,a){"use strict";var o=a("3e42"),s=a.n(o);s.a},"864f":function(t,e,a){},"9c24":function(t,e,a){"use strict";var o=a("864f"),s=a.n(o);s.a}}]);
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-801d4da6"],{"04d2":function(t,e,a){},6254:function(t,e,a){"use strict";a.r(e);var o=function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticStyle:{"margin-left":"10px",display:"inherit"}},[a("el-dropdown",{staticStyle:{width:"35px",height:"35px"},attrs:{trigger:"click","hide-on-click":!1},on:{command:t.handleAvatar}},[t.GetUserData.icon?[a("el-tooltip",{staticClass:"item",attrs:{effect:"dark",content:t.GetUserData.username,placement:"left"}},[a("el-avatar",{attrs:{size:35,src:t.GetUserData.icon}})],1)]:[a("el-tooltip",{staticClass:"item",attrs:{effect:"dark",content:t.GetUserData.username,placement:"left"}},[a("el-avatar",{style:{background:t.GetUserData.headerColor},attrs:{size:35}},[t._v(t._s(t.GetUserData.firstword))])],1)],a("el-dropdown-menu",{staticClass:"avatar-dropdown",attrs:{slot:"dropdown"},slot:"dropdown"},[a("el-dropdown-item",{attrs:{command:"personal"}},[t._v("个人设置")]),a("el-dropdown-item",{attrs:{command:"help"}},[t._v("帮助文档")]),a("el-dropdown-item",{attrs:{command:"problem"}},[t._v("问题反馈")]),a("el-divider"),a("el-dropdown-item",{attrs:{command:"setting"}},[t._v("站点设置")]),a("el-dropdown-item",{attrs:{command:"library"}},[t._v("库设置")]),a("el-dropdown-item",{attrs:{command:"orguser"}},[t._v("用户管理")]),a("el-dropdown-item",{attrs:{command:"system"}},[a("span",{staticStyle:{position:"relative"}},[t._v(" 系统工具 "),t.GetUserData.upgrade?a("div",{staticClass:"tip",staticStyle:{width:"7px",height:"7px","border-radius":"50%",background:"red",position:"absolute",left:"-13px",top:"0",bottom:"0",margin:"auto"}}):t._e()])]),a("el-divider"),a("el-dropdown-item",{attrs:{command:"about"}},[t._v("关于PicHome")]),a("el-dropdown-item",{attrs:{command:"OutLogin"}},[t._v("退出站点")])],1)],2)],1)},s=[],n=(a("96cf"),a("1da1")),i=a("5530"),r=a("2f62"),c={data:function(){return{}},computed:Object(i["a"])({},Object(r["b"])(["GetUserData","GetFormHash","GetLanguage"])),methods:{handleAvatar:function(t){switch(t){case"collection":window.location.href="index.php?mod=collection";break;case"personal":window.location.href="index.php?mod=pichome&op=user&do=personal";break;case"help":window.open("https://www.yuque.com/pichome");break;case"problem":window.open("https://support.qq.com/products/340252");break;case"setting":window.location.href="index.php?mod=pichome&op=admin&do=basic";break;case"library":window.location.href="index.php?mod=pichome&op=library";break;case"about":this.$alert('<div class="aboutlogo">\n \t\t\t<img src="dzz/pichome/image/phlogo.png" alt="">\n \t\t</div>\n \t\t<div class="aboutmessage">\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">软件名称:</span><span class="mes">欧奥PicHome</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">版本信息:</span><span class="mes">'+this.GetUserData.version+'</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">版权信息:</span><span class="mes">Powered By oaooa PicHome © 2020-2022 欧奥图文</span>\n \t\t\t</div>\n \t\t\t<div class="aboutlist">\n \t\t\t\t<span class="title">网站地址:</span><span class="mes"><a class="address" href="https://oaooa.com/" target="_blank">oaooa.com</a></span>\n \t\t\t</div>\n \t\t</div>',"",{customClass:"aboutPichome",showClose:!1,showConfirmButton:!1,dangerouslyUseHTMLString:!0,closeOnClickModal:!0});break;case"OutLogin":this.outLogin();break;case"system":window.open("admin.php?mod=system");break;case"orguser":window.open("admin.php?mod=orguser");break}return!1},outLogin:function(){var t=this;return Object(n["a"])(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,t.axios.post(t.AxiosApi+"user.php?mod=login&op=logging&action=logout&formhash="+t.GetFormHash+"&t="+(new Date).getTime());case 2:a=e.sent,a.data,window.location.reload();case 5:case"end":return e.stop()}}),e)})))()}}},d=c,l=(a("a16b"),a("9c24"),a("2877")),p=Object(l["a"])(d,o,s,!1,null,"663b95fa",null);e["default"]=p.exports},"864f":function(t,e,a){},"9c24":function(t,e,a){"use strict";var o=a("864f"),s=a.n(o);s.a},a16b:function(t,e,a){"use strict";var o=a("04d2"),s=a.n(o);s.a}}]);
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-9f9c2568"],{"01e3":function(e,t,n){"use strict";n.r(t);var s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"page-content"},[n("div",{staticClass:"top-title color-border",staticStyle:{display:"flex"}},[n("span",[e._v(e._s(e.$t("upgrade"))),e.elstep>0?n("span",{staticClass:"line"}):e._e()]),e.elstep>0?n("el-steps",{staticStyle:{flex:"1"},attrs:{active:e.elstep,"finish-status":"success",simple:""}},[n("el-step",{attrs:{title:e.$t("founder_upgrade_updatelist")}}),n("el-step",{attrs:{title:e.$t("founder_upgrade_download")}}),n("el-step",{attrs:{title:e.$t("founder_upgrade_compare")}}),n("el-step",{attrs:{title:e.$t("founder_upgrade_upgrading")}}),n("el-step",{attrs:{title:e.$t("founder_upgrade_complete")}})],1):e._e()],1),n("el-scrollbar",{staticClass:"page-component__scroll"},[n("div",{staticClass:"content",staticStyle:{padding:"25px"}},[n(e.template,{tag:"component",attrs:{returnData:e.returnData},on:{handleStep:e.handleStep}})],1)])],1)},a=[],r=(n("d3b7"),{props:["returnData"],data:function(){return{elstep:"",template:""}},watch:{elstep:{handler:function(e){this.handleTemplate()}},$route:{handler:function(e){e.params&&e.params.version&&(this.elstep=5)},deep:!0}},created:function(){this.returnData.iframes?this.elstep=4:(this.elstep=this.returnData.step?this.returnData.step:1,this.handleTemplate())},methods:{handleStep:function(e){e.upgradeNone?(this.template="upgradeNone",this.elstep=0):e.upgradeError?(this.template="upgradeError",this.elstep=0):e.bbclosed?(this.template="bbclosed",this.elstep=0):this.elstep=e.template},handleTemplate:function(){switch(this.elstep){case 1:this.template="step1";break;case 2:this.template="step2";break;case 3:this.template="step3";break;case 4:this.template="step4";break;case 5:this.template="step5";break}}},components:{upgradeError:function(){return n.e("chunk-2d20fcd9").then(n.bind(null,"b4d5"))},upgradeNone:function(){return n.e("chunk-2d0bdbc6").then(n.bind(null,"2ced"))},bbclosed:function(){return n.e("chunk-2d0a3327").then(n.bind(null,"00c4"))},step1:function(){return n.e("chunk-77c8d08e").then(n.bind(null,"1f5d"))},step2:function(){return n.e("chunk-2d21ddf7").then(n.bind(null,"d2c6"))},step3:function(){return n.e("chunk-2d0efd3c").then(n.bind(null,"9a86"))},step4:function(){return n.e("chunk-36bedb7f").then(n.bind(null,"4e68"))},step5:function(){return n.e("chunk-2d0dd46d").then(n.bind(null,"8164"))}},destroyed:function(){}}),l=r,p=(n("8dc4"),n("2877")),i=Object(p["a"])(l,s,a,!1,null,"0dbad62e",null);t["default"]=i.exports},"1a21":function(e,t,n){},"8dc4":function(e,t,n){"use strict";var s=n("1a21"),a=n.n(s);a.a}}]);
|
|
||||||
1
admin/system/dist/js/index.b5ff203c.js
vendored
1
admin/system/dist/js/index.b5ff203c.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
admin/system/dist/js/index.d36cff59.js
vendored
1
admin/system/dist/js/index.d36cff59.js
vendored
File diff suppressed because one or more lines are too long
1
admin/system/dist/js/index.d77cc092.js
vendored
1
admin/system/dist/js/index.d77cc092.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -24,7 +24,8 @@ $steplang = array('', lang('founder_upgrade_updatelist'), lang('founder_upgrade_
|
|||||||
|
|
||||||
if ($operation == 'patch' || $operation == 'cross') {
|
if ($operation == 'patch' || $operation == 'cross') {
|
||||||
if (!$_G['setting']['bbclosed']) {
|
if (!$_G['setting']['bbclosed']) {
|
||||||
exit(json_encode(array('bbclosed'=>true)));
|
C::t('setting')->update('bbclosed', 1);
|
||||||
|
updatecache('setting');
|
||||||
}
|
}
|
||||||
|
|
||||||
$msg = '';
|
$msg = '';
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
//error_reporting(E_ALL);
|
//error_reporting(E_ALL);
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
define('NOROBOT', TRUE);
|
define('NOROBOT', TRUE);
|
||||||
$returntype = isset($_GET['returnType']) ? $_GET['returnType']: 'json';//返回值方式
|
$returntype = isset($_GET['returnType']) ? $_GET['returnType']: 'json';//返回值方式
|
||||||
|
|
||||||
$checkLanguage = $_G['language'];
|
$checkLanguage = $_G['language'];
|
||||||
if(file_exists (DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php')){
|
if(file_exists (DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php')){
|
||||||
include DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php';
|
include DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php';
|
||||||
$_G['lang']['template']=array_merge($_G['lang']['template'],$lang);
|
$_G['lang']['template']=array_merge($_G['lang']['template'],$lang);
|
||||||
}
|
}
|
||||||
//判断管理员登录
|
//判断管理员登录
|
||||||
//Hook::listen('adminlogin');
|
//Hook::listen('adminlogin');
|
||||||
//后台管理页面
|
//后台管理页面
|
||||||
if(submitcheck('settingsubmit')){
|
if(submitcheck('settingsubmit')){
|
||||||
if ($_G['adminid'] != 1){
|
if ($_G['adminid'] != 1){
|
||||||
showmessage( lang('no_privilege') ,$returntype);
|
showmessage( lang('no_privilege') ,$returntype);
|
||||||
}
|
}
|
||||||
$settingnew=$_GET["settingnew"];
|
$settingnew=$_GET["settingnew"];
|
||||||
$data=array();
|
$data=array();
|
||||||
foreach($settingnew["mark"] as $k=>$v){
|
foreach($settingnew["mark"] as $k=>$v){
|
||||||
if( isset($data[$v]) ){
|
if( isset($data[$v]) ){
|
||||||
showmessage( lang('Logtag').$v.lang('repeat') ,$returntype);
|
showmessage( lang('Logtag').$v.lang('repeat') ,$returntype);
|
||||||
}
|
}
|
||||||
$data[$v]=array(
|
$data[$v]=array(
|
||||||
"title" => $settingnew["title"][$k],
|
"title" => $settingnew["title"][$k],
|
||||||
"is_open" => intval($settingnew["is_open"][$k]),
|
"is_open" => intval($settingnew["is_open"][$k]),
|
||||||
"issystem" => $settingnew["issystem"][$k]
|
"issystem" => $settingnew["issystem"][$k]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$settingnew = serialize($data);
|
$settingnew = serialize($data);
|
||||||
$update=array(
|
$update=array(
|
||||||
"systemlog_open" =>$_GET["systemlog_open"],
|
"systemlog_open" =>$_GET["systemlog_open"],
|
||||||
"systemlog_setting" =>$settingnew,
|
"systemlog_setting" =>$settingnew,
|
||||||
);
|
);
|
||||||
$result = C::t('setting') ->update_batch($update);
|
$result = C::t('setting') ->update_batch($update);
|
||||||
if( $result ){
|
if( $result ){
|
||||||
include_once libfile('function/cache');
|
include_once libfile('function/cache');
|
||||||
updatecache('setting');
|
updatecache('setting');
|
||||||
}
|
}
|
||||||
writelog('otherlog', lang('Update_setting'));
|
writelog('otherlog', lang('Update_setting'));
|
||||||
showmessage('do_success', dreferer());
|
showmessage('do_success', dreferer());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$systemlog_setting = ($_G["setting"]["systemlog_setting"]);
|
$systemlog_setting = ($_G["setting"]["systemlog_setting"]);
|
||||||
$navtitle=lang('systemlog_setting').' - '.lang('appname');
|
$navtitle=lang('systemlog_setting').' - '.lang('appname');
|
||||||
include template("admin");
|
include template("admin");
|
||||||
}
|
}
|
||||||
@@ -1,63 +1,63 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace admin\systemlog\classes;
|
namespace admin\systemlog\classes;
|
||||||
class Systemlog{
|
class Systemlog{
|
||||||
//$arr 必须传入 level,content
|
//$arr 必须传入 level,content
|
||||||
public function run( $arr=array() ){
|
public function run( $arr=array() ){
|
||||||
global $_G;
|
global $_G;
|
||||||
if( $_G['setting']['systemlog_open'] > 0 ){
|
if( $_G['setting']['systemlog_open'] > 0 ){
|
||||||
$systemlog_setting = ($_G['setting']['systemlog_setting']);
|
$systemlog_setting = ($_G['setting']['systemlog_setting']);
|
||||||
//判断是否开启该类型日志
|
//判断是否开启该类型日志
|
||||||
if(!isset($arr["mark"]) || (isset($systemlog_setting[$arr["mark"]]) && $systemlog_setting[$arr["mark"]]["is_open"]!=1) ){
|
if(!isset($arr["mark"]) || (isset($systemlog_setting[$arr["mark"]]) && $systemlog_setting[$arr["mark"]]["is_open"]!=1) ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$file=$arr["mark"];//$arr["level"];//级别
|
$file=$arr["mark"];//$arr["level"];//级别
|
||||||
$log=$arr["content"];
|
$log=$arr["content"];
|
||||||
$yearmonth = "dzz";//dgmdate(TIMESTAMP, 'Ym', $_G['setting']['timeoffset']);
|
$yearmonth = "dzz";//dgmdate(TIMESTAMP, 'Ym', $_G['setting']['timeoffset']);
|
||||||
$logdir = DZZ_ROOT.'./data/log/';
|
$logdir = DZZ_ROOT.'./data/log/';
|
||||||
$logfile = $logdir.$yearmonth.'_'.$file.'.php';
|
$logfile = $logdir.$yearmonth.'_'.$file.'.php';
|
||||||
|
|
||||||
//检查并返回当前log文件行数
|
//检查并返回当前log文件行数
|
||||||
$i=0;
|
$i=0;
|
||||||
if( file_exists($logfile)){
|
if( file_exists($logfile)){
|
||||||
$fp=fopen($logfile, "r");
|
$fp=fopen($logfile, "r");
|
||||||
while(!feof($fp)) {
|
while(!feof($fp)) {
|
||||||
//每次最多读取1M
|
//每次最多读取1M
|
||||||
if($data=fread($fp,1024*1024*1)){
|
if($data=fread($fp,1024*1024*1)){
|
||||||
//计算读取到的行数
|
//计算读取到的行数
|
||||||
$num=substr_count($data,"\n");
|
$num=substr_count($data,"\n");
|
||||||
$i+=$num;
|
$i+=$num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
//每4000行重新生成日志文件
|
//每4000行重新生成日志文件
|
||||||
if($i>=4000) {
|
if($i>=4000) {
|
||||||
$dir = opendir($logdir);
|
$dir = opendir($logdir);
|
||||||
$length = strlen($file);
|
$length = strlen($file);
|
||||||
$maxid = $id = 0;
|
$maxid = $id = 0;
|
||||||
while($entry = readdir($dir)) {
|
while($entry = readdir($dir)) {
|
||||||
if(strpos($entry, $yearmonth.'_'.$file) !== false) {
|
if(strpos($entry, $yearmonth.'_'.$file) !== false) {
|
||||||
$id = intval(substr($entry, $length + 8, -4));
|
$id = intval(substr($entry, $length + 8, -4));
|
||||||
$id > $maxid && $maxid = $id;
|
$id > $maxid && $maxid = $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
$logfilebak = $logdir.$yearmonth.'_'.$file.'_'.($maxid + 1).'.php';
|
$logfilebak = $logdir.$yearmonth.'_'.$file.'_'.($maxid + 1).'.php';
|
||||||
@rename($logfile, $logfilebak);
|
@rename($logfile, $logfilebak);
|
||||||
}
|
}
|
||||||
if($fp = @fopen($logfile, 'a')) {
|
if($fp = @fopen($logfile, 'a')) {
|
||||||
@flock($fp, 2);
|
@flock($fp, 2);
|
||||||
if(!is_array($log)) {
|
if(!is_array($log)) {
|
||||||
$log = array($log);
|
$log = array($log);
|
||||||
}
|
}
|
||||||
$cur_url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
|
$cur_url = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
|
||||||
$from_url = $_SERVER['HTTP_REFERER'];
|
$from_url = $_SERVER['HTTP_REFERER'];
|
||||||
foreach($log as $tmp) {
|
foreach($log as $tmp) {
|
||||||
$tmp=implode("\t", clearlogstring(array($_G['timestamp'], $_G['username'], $_G['groupid'], $_G['clientip'],$tmp,$cur_url,$from_url))) ;
|
$tmp=implode("\t", clearlogstring(array($_G['timestamp'], $_G['username'], $_G['groupid'], $_G['clientip'],$tmp,$cur_url,$from_url))) ;
|
||||||
fwrite($fp, "<?PHP exit;?>\t".str_replace(array('<?', '?>'), '', $tmp)."\n");
|
fwrite($fp, "<?PHP exit;?>\t".str_replace(array('<?', '?>'), '', $tmp)."\n");
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,177 +1,177 @@
|
|||||||
<?php
|
<?php
|
||||||
//error_reporting(E_ALL);
|
//error_reporting(E_ALL);
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
define('NOROBOT', TRUE);
|
define('NOROBOT', TRUE);
|
||||||
$returntype = isset($_GET['returnType']) ? $_GET['returnType']: 'json';//返回值方式
|
$returntype = isset($_GET['returnType']) ? $_GET['returnType']: 'json';//返回值方式
|
||||||
$type=$_GET['type'];
|
$type=$_GET['type'];
|
||||||
if(!in_array($type, array('list'))) {
|
if(!in_array($type, array('list'))) {
|
||||||
$type='list';
|
$type='list';
|
||||||
}
|
}
|
||||||
|
|
||||||
$checkLanguage = $_G['language'];
|
$checkLanguage = $_G['language'];
|
||||||
if(file_exists (DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php')){
|
if(file_exists (DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php')){
|
||||||
include DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php';
|
include DZZ_ROOT.'./admin/language/'.$checkLanguage.'/'.'lang.php';
|
||||||
$_G['lang']['template']=array_merge($_G['lang']['template'],$lang);
|
$_G['lang']['template']=array_merge($_G['lang']['template'],$lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($type=="list"){
|
if($type=="list"){
|
||||||
//Hook::listen('adminlogin');
|
//Hook::listen('adminlogin');
|
||||||
!isset($_GET['page']) && $_GET['page']=1;
|
!isset($_GET['page']) && $_GET['page']=1;
|
||||||
$page=max(1,intval($_GET['page']));
|
$page=max(1,intval($_GET['page']));
|
||||||
$lpp = empty($_GET['lpp']) ? 15 : $_GET['lpp'];
|
$lpp = empty($_GET['lpp']) ? 15 : $_GET['lpp'];
|
||||||
$checklpp = array();
|
$checklpp = array();
|
||||||
$checklpp[$lpp] = 'selected="selected"';
|
$checklpp[$lpp] = 'selected="selected"';
|
||||||
$extrainput = '';
|
$extrainput = '';
|
||||||
$systemlog_setting = is_serialized($_G["setting"]["systemlog_setting"])?unserialize($_G["setting"]["systemlog_setting"]):$_G["setting"]["systemlog_setting"];
|
$systemlog_setting = is_serialized($_G["setting"]["systemlog_setting"])?unserialize($_G["setting"]["systemlog_setting"]):$_G["setting"]["systemlog_setting"];
|
||||||
$operationarr = array_keys($systemlog_setting);
|
$operationarr = array_keys($systemlog_setting);
|
||||||
$operation = in_array($_GET['operation'], $operationarr) ? $_GET['operation'] : "cplog";
|
$operation = in_array($_GET['operation'], $operationarr) ? $_GET['operation'] : "cplog";
|
||||||
$navtitle=$systemlog_setting[$operation]["title"].' - '.lang('appname');//lang('nav_logs_'.$operation).' - '.lang('admin_navtitle');
|
$navtitle=$systemlog_setting[$operation]["title"].' - '.lang('appname');//lang('nav_logs_'.$operation).' - '.lang('admin_navtitle');
|
||||||
|
|
||||||
$logdir = DZZ_ROOT.'./data/log/';
|
$logdir = DZZ_ROOT.'./data/log/';
|
||||||
$logfiles = get_log_files($logdir, $operation);
|
$logfiles = get_log_files($logdir, $operation);
|
||||||
|
|
||||||
if($logfiles) $logfiles=array_reverse($logfiles);
|
if($logfiles) $logfiles=array_reverse($logfiles);
|
||||||
//error_reporting(E_ALL);
|
//error_reporting(E_ALL);
|
||||||
$firstlogs = file( $logdir.$logfiles[0] ) ;
|
$firstlogs = file( $logdir.$logfiles[0] ) ;
|
||||||
$firstlogsnum = count($firstlogs);
|
$firstlogsnum = count($firstlogs);
|
||||||
$countlogfile=count($logfiles);
|
$countlogfile=count($logfiles);
|
||||||
$count = ($countlogfile-1)*4000+$firstlogsnum;
|
$count = ($countlogfile-1)*4000+$firstlogsnum;
|
||||||
$multipage = multi($count, $lpp, $page, MOD_URL."&type=list&operation=$operation&lpp=$lpp",'pull-right' );
|
$multipage = multi($count, $lpp, $page, MOD_URL."&type=list&operation=$operation&lpp=$lpp",'pull-right' );
|
||||||
|
|
||||||
$logs = array();
|
$logs = array();
|
||||||
$jishu=4000;//每个日志文件最多行数
|
$jishu=4000;//每个日志文件最多行数
|
||||||
$start = ($page - 1) * $lpp;
|
$start = ($page - 1) * $lpp;
|
||||||
$lastlog=$last_secondlog="";
|
$lastlog=$last_secondlog="";
|
||||||
|
|
||||||
$newdata=array();
|
$newdata=array();
|
||||||
foreach($logfiles as $k=>$v){
|
foreach($logfiles as $k=>$v){
|
||||||
$nowfilemaxnum=($jishu*($k+1))-($jishu-$firstlogsnum);
|
$nowfilemaxnum=($jishu*($k+1))-($jishu-$firstlogsnum);
|
||||||
$startnum=($nowfilemaxnum-$jishu)<=0?0:($nowfilemaxnum-$jishu+1);
|
$startnum=($nowfilemaxnum-$jishu)<=0?0:($nowfilemaxnum-$jishu+1);
|
||||||
$newdata[]=array("file"=>$v,"start"=>$startnum,"end"=>$nowfilemaxnum);
|
$newdata[]=array("file"=>$v,"start"=>$startnum,"end"=>$nowfilemaxnum);
|
||||||
}
|
}
|
||||||
//print_R($newdata);
|
//print_R($newdata);
|
||||||
//查询当前分页数据位于哪个日志文件
|
//查询当前分页数据位于哪个日志文件
|
||||||
$lastlog=$last_secondlog="";
|
$lastlog=$last_secondlog="";
|
||||||
foreach($newdata as $k=>$v){
|
foreach($newdata as $k=>$v){
|
||||||
if( $start<=$v["end"]){
|
if( $start<=$v["end"]){
|
||||||
$lastlog=$v;
|
$lastlog=$v;
|
||||||
if( ($start+$lpp)<$v["end"]){
|
if( ($start+$lpp)<$v["end"]){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if( isset($newdata[$k+1])){
|
if( isset($newdata[$k+1])){
|
||||||
$last_secondlog=$newdata[$k+1];
|
$last_secondlog=$newdata[$k+1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$j=0;
|
$j=0;
|
||||||
for($i=$lastlog["start"];$i<$lastlog["end"];$i++){
|
for($i=$lastlog["start"];$i<$lastlog["end"];$i++){
|
||||||
if( $start<=($lastlog["start"]+$j) ){
|
if( $start<=($lastlog["start"]+$j) ){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
//获取数据开始
|
//获取数据开始
|
||||||
$logs = file( $logdir.$lastlog["file"] );
|
$logs = file( $logdir.$lastlog["file"] );
|
||||||
$logs = array_reverse($logs);
|
$logs = array_reverse($logs);
|
||||||
if( $lastlog["file"]!=$logfiles[0] ){
|
if( $lastlog["file"]!=$logfiles[0] ){
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
$logs = array_slice($logs, $j, $lpp);
|
$logs = array_slice($logs, $j, $lpp);
|
||||||
$onecountget = count($logs);
|
$onecountget = count($logs);
|
||||||
|
|
||||||
$jj=0;
|
$jj=0;
|
||||||
if( $last_secondlog ){
|
if( $last_secondlog ){
|
||||||
for($i=$last_secondlog["start"];$i<$last_secondlog["end"];$i++){
|
for($i=$last_secondlog["start"];$i<$last_secondlog["end"];$i++){
|
||||||
if( ($jj)>= ($lpp-$onecountget) ){//$last_secondlog["start"] ){
|
if( ($jj)>= ($lpp-$onecountget) ){//$last_secondlog["start"] ){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$jj++;
|
$jj++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($last_secondlog){
|
if($last_secondlog){
|
||||||
$logs2 = file( $logdir.$last_secondlog["file"] );
|
$logs2 = file( $logdir.$last_secondlog["file"] );
|
||||||
$logs2 = array_reverse($logs2);
|
$logs2 = array_reverse($logs2);
|
||||||
$end=$lpp-count($logs);
|
$end=$lpp-count($logs);
|
||||||
$logs2 = array_slice( $logs2, 0, $jj);
|
$logs2 = array_slice( $logs2, 0, $jj);
|
||||||
$logs=array_merge($logs,$logs2);
|
$logs=array_merge($logs,$logs2);
|
||||||
}
|
}
|
||||||
//获取数据结束
|
//获取数据结束
|
||||||
|
|
||||||
$usergroup = array();
|
$usergroup = array();
|
||||||
foreach(C::t('usergroup')->range() as $group) {
|
foreach(C::t('usergroup')->range() as $group) {
|
||||||
$usergroup[$group['groupid']] = $group['grouptitle'];
|
$usergroup[$group['groupid']] = $group['grouptitle'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$list=array();
|
$list=array();
|
||||||
foreach($logs as $k => $logrow) {
|
foreach($logs as $k => $logrow) {
|
||||||
$log = explode("\t", $logrow);
|
$log = explode("\t", $logrow);
|
||||||
if(empty($log[1])) {
|
if(empty($log[1])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log[1] = dgmdate($log[1], 'y-n-j H:i');
|
$log[1] = dgmdate($log[1], 'y-n-j H:i');
|
||||||
$log[2] = $log[2];
|
$log[2] = $log[2];
|
||||||
$log[2] = ($log[2] != $_G['member']['username'] ? "<b>$log[2]</b>" : $log[2]);
|
$log[2] = ($log[2] != $_G['member']['username'] ? "<b>$log[2]</b>" : $log[2]);
|
||||||
$log[3] = $usergroup[$log[3]];
|
$log[3] = $usergroup[$log[3]];
|
||||||
|
|
||||||
$list[$k]=$log;
|
$list[$k]=$log;
|
||||||
}
|
}
|
||||||
|
|
||||||
include template('list');
|
include template('list');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getactionarray() {
|
function getactionarray() {
|
||||||
$isfounder = true;
|
$isfounder = true;
|
||||||
unset($topmenu['index'], $menu['index']);
|
unset($topmenu['index'], $menu['index']);
|
||||||
$actioncat = $actionarray = array();
|
$actioncat = $actionarray = array();
|
||||||
$actioncat[] = 'setting';
|
$actioncat[] = 'setting';
|
||||||
$actioncat = array_merge($actioncat, array_keys($topmenu));
|
$actioncat = array_merge($actioncat, array_keys($topmenu));
|
||||||
foreach($menu as $tkey => $items) {
|
foreach($menu as $tkey => $items) {
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
$actionarray[$tkey][] = $item;
|
$actionarray[$tkey][] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array('actions' => $actionarray, 'cats' => $actioncat);
|
return array('actions' => $actionarray, 'cats' => $actioncat);
|
||||||
}
|
}
|
||||||
function get_log_files($logdir = '', $action = 'action') {
|
function get_log_files($logdir = '', $action = 'action') {
|
||||||
$dir = opendir($logdir);
|
$dir = opendir($logdir);
|
||||||
$files = array();
|
$files = array();
|
||||||
while($entry = readdir($dir)) {
|
while($entry = readdir($dir)) {
|
||||||
$files[] = $entry;
|
$files[] = $entry;
|
||||||
}
|
}
|
||||||
closedir($dir);
|
closedir($dir);
|
||||||
|
|
||||||
if($files) {
|
if($files) {
|
||||||
sort($files);
|
sort($files);
|
||||||
$logfile = $action;
|
$logfile = $action;
|
||||||
$logfiles = array();
|
$logfiles = array();
|
||||||
$ym = '';
|
$ym = '';
|
||||||
foreach($files as $file) {
|
foreach($files as $file) {
|
||||||
if(strpos($file, $logfile) !== FALSE) {
|
if(strpos($file, $logfile) !== FALSE) {
|
||||||
if(substr($file, 0, 6) != $ym) {
|
if(substr($file, 0, 6) != $ym) {
|
||||||
$ym = substr($file, 0, 6);
|
$ym = substr($file, 0, 6);
|
||||||
}
|
}
|
||||||
$logfiles[$ym][] = $file;
|
$logfiles[$ym][] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($logfiles) {
|
if($logfiles) {
|
||||||
$lfs = array();
|
$lfs = array();
|
||||||
foreach($logfiles as $ym => $lf) {
|
foreach($logfiles as $ym => $lf) {
|
||||||
$lastlogfile = $lf[0];
|
$lastlogfile = $lf[0];
|
||||||
unset($lf[0]);
|
unset($lf[0]);
|
||||||
$lf[] = $lastlogfile;
|
$lf[] = $lastlogfile;
|
||||||
$lfs = array_merge($lfs, $lf);
|
$lfs = array_merge($lfs, $lf);
|
||||||
}
|
}
|
||||||
return $lfs;
|
return $lfs;
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* 应用安装文件;
|
* 应用安装文件;
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author qchlian
|
* @author qchlian
|
||||||
*/
|
*/
|
||||||
if(!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
|
if(!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
/*以下配置初始化时已存入数据库配置表
|
/*以下配置初始化时已存入数据库配置表
|
||||||
*$systemlog_setting = array(
|
*$systemlog_setting = array(
|
||||||
* 级别 名称 标记 是否开启
|
* 级别 名称 标记 是否开启
|
||||||
"errorlog"=>array("title"=>"系统错误","is_open"=>1,"issystem"=>1),
|
"errorlog"=>array("title"=>"系统错误","is_open"=>1,"issystem"=>1),
|
||||||
"cplog"=>array("title"=>"后台访问","is_open"=>1,"issystem"=>1),
|
"cplog"=>array("title"=>"后台访问","is_open"=>1,"issystem"=>1),
|
||||||
"deletelog"=>array("title"=>"数据删除","is_open"=>1,"issystem"=>1),
|
"deletelog"=>array("title"=>"数据删除","is_open"=>1,"issystem"=>1),
|
||||||
"updatelog"=>array("title"=>"数据更新","is_open"=>1,"issystem"=>1),
|
"updatelog"=>array("title"=>"数据更新","is_open"=>1,"issystem"=>1),
|
||||||
"loginlog"=>array("title"=>"用户登录","is_open"=>1,"issystem"=>1),
|
"loginlog"=>array("title"=>"用户登录","is_open"=>1,"issystem"=>1),
|
||||||
"sendmail"=>array("title"=>"邮件发送","is_open"=>1,"issystem"=>1),
|
"sendmail"=>array("title"=>"邮件发送","is_open"=>1,"issystem"=>1),
|
||||||
"otherlog"=>array("title"=>"其他信息","is_open"=>1,"issystem"=>1),
|
"otherlog"=>array("title"=>"其他信息","is_open"=>1,"issystem"=>1),
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$sql = <<<EOF
|
$sql = <<<EOF
|
||||||
DELETE FROM `dzz_setting` WHERE `skey` = 'systemlog_open';
|
DELETE FROM `dzz_setting` WHERE `skey` = 'systemlog_open';
|
||||||
INSERT INTO `dzz_setting` (`skey`,`svalue`) VALUES ('systemlog_open', '1');
|
INSERT INTO `dzz_setting` (`skey`,`svalue`) VALUES ('systemlog_open', '1');
|
||||||
DELETE FROM `dzz_setting` WHERE `skey` = 'systemlog_setting';
|
DELETE FROM `dzz_setting` WHERE `skey` = 'systemlog_setting';
|
||||||
INSERT INTO `dzz_setting` (`skey`,`svalue`) VALUES ('systemlog_setting','a:7:{s:8:"errorlog";a:3:{s:5:"title";s:12:"系统错误";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:5:"cplog";a:3:{s:5:"title";s:12:"后台访问";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:9:"deletelog";a:3:{s:5:"title";s:12:"数据删除";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:9:"updatelog";a:3:{s:5:"title";s:12:"数据更新";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:8:"loginlog";a:3:{s:5:"title";s:12:"用户登录";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:8:"sendmail";a:3:{s:5:"title";s:12:"邮件发送";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:8:"otherlog";a:3:{s:5:"title";s:12:"其他信息";s:7:"is_open";i:1;s:8:"issystem";i:1;}}');
|
INSERT INTO `dzz_setting` (`skey`,`svalue`) VALUES ('systemlog_setting','a:7:{s:8:"errorlog";a:3:{s:5:"title";s:12:"系统错误";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:5:"cplog";a:3:{s:5:"title";s:12:"后台访问";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:9:"deletelog";a:3:{s:5:"title";s:12:"数据删除";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:9:"updatelog";a:3:{s:5:"title";s:12:"数据更新";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:8:"loginlog";a:3:{s:5:"title";s:12:"用户登录";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:8:"sendmail";a:3:{s:5:"title";s:12:"邮件发送";s:7:"is_open";i:1;s:8:"issystem";i:1;}s:8:"otherlog";a:3:{s:5:"title";s:12:"其他信息";s:7:"is_open";i:1;s:8:"issystem";i:1;}}');
|
||||||
EOF;
|
EOF;
|
||||||
runquery($sql);
|
runquery($sql);
|
||||||
$finish = true; //结束时必须加入此句,告诉应用安装程序已经完成自定义的安装流程
|
$finish = true; //结束时必须加入此句,告诉应用安装程序已经完成自定义的安装流程
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
$lang = array (
|
$lang = array (
|
||||||
'appname'=>'系统日志',
|
'appname'=>'系统日志',
|
||||||
'logs' => '运行记录',
|
'logs' => '运行记录',
|
||||||
'systemlog_setting'=>'设置',
|
'systemlog_setting'=>'设置',
|
||||||
'systemlog_list'=>'日志列表',
|
'systemlog_list'=>'日志列表',
|
||||||
'info'=>'信息',
|
'info'=>'信息',
|
||||||
'loginfo'=>'日志信息',
|
'loginfo'=>'日志信息',
|
||||||
'visit'=>'访问页面',
|
'visit'=>'访问页面',
|
||||||
'from'=>'来源页面',
|
'from'=>'来源页面',
|
||||||
'logswitch'=>'日志开关',
|
'logswitch'=>'日志开关',
|
||||||
'logtype'=>'日志类型',
|
'logtype'=>'日志类型',
|
||||||
'logtypename'=>'日志类型名称',
|
'logtypename'=>'日志类型名称',
|
||||||
'logtype'=>'日志类型',
|
'logtype'=>'日志类型',
|
||||||
'logflag'=>'日志标识',
|
'logflag'=>'日志标识',
|
||||||
'Logtag'=>'日志标记',
|
'Logtag'=>'日志标记',
|
||||||
'repeat'=>'重复',
|
'repeat'=>'重复',
|
||||||
'Update_setting'=>'更新日志设置'
|
'Update_setting'=>'更新日志设置'
|
||||||
);
|
);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,160 +1,160 @@
|
|||||||
<!--{template common/header_simple_start}-->
|
<!--{template common/header_simple_start}-->
|
||||||
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
|
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
|
||||||
<link href="static/icheck/skins/minimal/blue.css?{VERHASH}" rel="stylesheet" media="all">
|
<link href="static/icheck/skins/minimal/blue.css?{VERHASH}" rel="stylesheet" media="all">
|
||||||
<link rel="stylesheet" href="static/css/checkbox.css">
|
<link rel="stylesheet" href="static/css/checkbox.css">
|
||||||
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
|
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
|
||||||
<style>
|
<style>
|
||||||
html, body {
|
html, body {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
color: #4B4B4B;
|
color: #4B4B4B;
|
||||||
}
|
}
|
||||||
.form-horizontal-left .radio-inline {
|
.form-horizontal-left .radio-inline {
|
||||||
padding: 5px 20px;
|
padding: 5px 20px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.loginset-template{
|
.loginset-template{
|
||||||
width: 100px;
|
width: 100px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.loginset-template .loginset-template-icon{
|
.loginset-template .loginset-template-icon{
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border: 1px solid #AAB479;
|
border: 1px solid #AAB479;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 1px;
|
right: 1px;
|
||||||
top: 1px;
|
top: 1px;
|
||||||
color: #DD4B39;
|
color: #DD4B39;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.loginset-template:hover .loginset-template-icon{
|
.loginset-template:hover .loginset-template-icon{
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
.loginset-template:hover .loginset-template-icon>span{
|
.loginset-template:hover .loginset-template-icon>span{
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.loginset-template .loginset-template-icon1{
|
.loginset-template .loginset-template-icon1{
|
||||||
display: block!important;
|
display: block!important;
|
||||||
}
|
}
|
||||||
.loginset-template .loginset-template-icon1>span{
|
.loginset-template .loginset-template-icon1>span{
|
||||||
display: block!important;
|
display: block!important;
|
||||||
}
|
}
|
||||||
#cpform{
|
#cpform{
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<!--{template common/header_simple_end}-->
|
<!--{template common/header_simple_end}-->
|
||||||
<!--{template common/commer_header}-->
|
<!--{template common/commer_header}-->
|
||||||
<div class="bs-container clearfix">
|
<div class="bs-container clearfix">
|
||||||
<div class="bs-left-container clearfix">
|
<div class="bs-left-container clearfix">
|
||||||
<!--{template left}-->
|
<!--{template left}-->
|
||||||
</div>
|
</div>
|
||||||
<div class="left-drager">
|
<div class="left-drager">
|
||||||
<div class="left-drager-op">
|
<div class="left-drager-op">
|
||||||
<div class="left-drager-sub"></div>
|
<div class="left-drager-sub"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="bs-main-container clearfix">
|
<div class="bs-main-container clearfix">
|
||||||
<div class="main-title clearfix">
|
<div class="main-title clearfix">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<form id="cpform" action="{MOD_URL}&op=admin" class="form-horizontal-left" method="post" name="cpform">
|
<form id="cpform" action="{MOD_URL}&op=admin" class="form-horizontal-left" method="post" name="cpform">
|
||||||
<input type="hidden" value="{FORMHASH}" name="formhash">
|
<input type="hidden" value="{FORMHASH}" name="formhash">
|
||||||
<input type="hidden" value="basic" name="operation">
|
<input type="hidden" value="basic" name="operation">
|
||||||
|
|
||||||
<dl>
|
<dl>
|
||||||
<dt>{lang logswitch}:</dt>
|
<dt>{lang logswitch}:</dt>
|
||||||
<dd class="clearfix">
|
<dd class="clearfix">
|
||||||
<label class="radio-inline "><input type="radio" name="systemlog_open" value="1"<!--{if $_G[setting][systemlog_open]==1}-->checked<!--{/if}--> onclick="document.getElementById('hidden1').style.display='block';">{lang enable}</label>
|
<label class="radio-inline "><input type="radio" name="systemlog_open" value="1"<!--{if $_G[setting][systemlog_open]==1}-->checked<!--{/if}--> onclick="document.getElementById('hidden1').style.display='block';">{lang enable}</label>
|
||||||
<label class="radio radio-inline"><input type="radio" name="systemlog_open" value="0"<!--{if $_G[setting][systemlog_open]==0}-->checked<!--{/if}--> onclick="document.getElementById('hidden1').style.display='none';">{lang forbidden}</label>
|
<label class="radio radio-inline"><input type="radio" name="systemlog_open" value="0"<!--{if $_G[setting][systemlog_open]==0}-->checked<!--{/if}--> onclick="document.getElementById('hidden1').style.display='none';">{lang forbidden}</label>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl id="hidden1">
|
<dl id="hidden1">
|
||||||
<dt>{lang logtype}:</dt>
|
<dt>{lang logtype}:</dt>
|
||||||
<dd class="clearfix">
|
<dd class="clearfix">
|
||||||
|
|
||||||
<table id="systemlogtable" class="table text-center" style="width: auto;margin-bottom:0; <!--{if $_G[setting][systemlog_open]==0}-->display:none<!--{/if}-->">
|
<table id="systemlogtable" class="table text-center" style="width: auto;margin-bottom:0; <!--{if $_G[setting][systemlog_open]==0}-->display:none<!--{/if}-->">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{lang logtypename}</th>
|
<th>{lang logtypename}</th>
|
||||||
<th>{lang logflag}</th>
|
<th>{lang logflag}</th>
|
||||||
<th>{lang logswitch}</th>
|
<th>{lang logswitch}</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{eval $i=0;}
|
{eval $i=0;}
|
||||||
<!--{loop $systemlog_setting $mark $info}-->
|
<!--{loop $systemlog_setting $mark $info}-->
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" name="settingnew[issystem][$i]" value="$info[issystem]" />
|
<input type="hidden" name="settingnew[issystem][$i]" value="$info[issystem]" />
|
||||||
<input class="form-control" style="width:120px;" <!--{if $info[issystem]==1}-->readonly="readonly"<!--{/if}--> type="text" name="settingnew[title][$i]" value="$info[title]" />
|
<input class="form-control" style="width:120px;" <!--{if $info[issystem]==1}-->readonly="readonly"<!--{/if}--> type="text" name="settingnew[title][$i]" value="$info[title]" />
|
||||||
</td>
|
</td>
|
||||||
<td><input class="form-control" style="width:100px;" <!--{if $info[issystem]==1}-->readonly="readonly"<!--{/if}--> type="text" name="settingnew[mark][$i]" value="$mark" /></td>
|
<td><input class="form-control" style="width:100px;" <!--{if $info[issystem]==1}-->readonly="readonly"<!--{/if}--> type="text" name="settingnew[mark][$i]" value="$mark" /></td>
|
||||||
<td><input type="checkbox" name="settingnew[is_open][$i]" value="1" <!--{if $info[is_open]==1}-->checked<!--{/if}--> /></td>
|
<td><input type="checkbox" name="settingnew[is_open][$i]" value="1" <!--{if $info[is_open]==1}-->checked<!--{/if}--> /></td>
|
||||||
<td>
|
<td>
|
||||||
<!--{if $info[issystem]!=1}-->
|
<!--{if $info[issystem]!=1}-->
|
||||||
<a href="javascript:;" class="col-xs-2 img_delete" onclick="deletesystem(this);"><span class="dzz dzz-delete" style="font-size:22px;"></span></a>
|
<a href="javascript:;" class="col-xs-2 img_delete" onclick="deletesystem(this);"><span class="dzz dzz-delete" style="font-size:22px;"></span></a>
|
||||||
<!--{/if}-->
|
<!--{/if}-->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{eval $i++;}
|
{eval $i++;}
|
||||||
<!--{/loop}-->
|
<!--{/loop}-->
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="4" align="left"><a href="javascript:;" onclick="addsystemtype(this);"><i class="glyphicon glyphicon-plus"></i>{lang add}</a></td>
|
<td colspan="4" align="left"><a href="javascript:;" onclick="addsystemtype(this);"><i class="glyphicon glyphicon-plus"></i>{lang add}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl>
|
<dl>
|
||||||
|
|
||||||
<dd>
|
<dd>
|
||||||
<input class="btn btn-primary" id="submit_editsubmit" name="settingsubmit" value="{lang save_changes}" type="submit">
|
<input class="btn btn-primary" id="submit_editsubmit" name="settingsubmit" value="{lang save_changes}" type="submit">
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery('.left-drager').leftDrager_layout();
|
jQuery('.left-drager').leftDrager_layout();
|
||||||
jQuery(document).ready(function(e) {
|
jQuery(document).ready(function(e) {
|
||||||
jQuery('input').iCheck({
|
jQuery('input').iCheck({
|
||||||
checkboxClass: 'icheckbox_minimal-blue',
|
checkboxClass: 'icheckbox_minimal-blue',
|
||||||
radioClass: 'iradio_minimal-blue',
|
radioClass: 'iradio_minimal-blue',
|
||||||
});
|
});
|
||||||
jQuery('input').on('ifChecked', function(e) {
|
jQuery('input').on('ifChecked', function(e) {
|
||||||
jQuery(this).trigger('click');
|
jQuery(this).trigger('click');
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery('input[required]').on('blur', function() {
|
jQuery('input[required]').on('blur', function() {
|
||||||
if(this.value == '') { jQuery(this).addClass('input-error') } else { jQuery(this).removeClass('input-error'); }
|
if(this.value == '') { jQuery(this).addClass('input-error') } else { jQuery(this).removeClass('input-error'); }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
function addsystemtype( obj ){
|
function addsystemtype( obj ){
|
||||||
var num=jQuery("#systemlogtable").find("tr").length-1;
|
var num=jQuery("#systemlogtable").find("tr").length-1;
|
||||||
var html='<tr><td><input type="hidden" name="settingnew[issystem]['+num+']" value="0" /><input class="form-control" style="width:120px;" type="text" name="settingnew[title]['+num+']" value="" /></td><td><input class="form-control" style="width:100px;" type="text" name="settingnew[mark]['+num+']" value="" /></td><td><input type="checkbox" name="settingnew[is_open]['+num+']" value="1" checked /></td><td><a class="col-xs-2 img_delete" onclick="deletesystem(this);" href="javascript:;"><span class="dzz dzz-delete" style="font-size:22px;"></span></a></td></tr>';
|
var html='<tr><td><input type="hidden" name="settingnew[issystem]['+num+']" value="0" /><input class="form-control" style="width:120px;" type="text" name="settingnew[title]['+num+']" value="" /></td><td><input class="form-control" style="width:100px;" type="text" name="settingnew[mark]['+num+']" value="" /></td><td><input type="checkbox" name="settingnew[is_open]['+num+']" value="1" checked /></td><td><a class="col-xs-2 img_delete" onclick="deletesystem(this);" href="javascript:;"><span class="dzz dzz-delete" style="font-size:22px;"></span></a></td></tr>';
|
||||||
jQuery(obj).parents("tr").before(html);
|
jQuery(obj).parents("tr").before(html);
|
||||||
|
|
||||||
jQuery("#systemlogtable").iCheck({
|
jQuery("#systemlogtable").iCheck({
|
||||||
checkboxClass: 'icheckbox_minimal-blue',
|
checkboxClass: 'icheckbox_minimal-blue',
|
||||||
radioClass: 'iradio_minimal-blue',
|
radioClass: 'iradio_minimal-blue',
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletesystem( obj ){
|
function deletesystem( obj ){
|
||||||
jQuery(obj).parents("tr").remove();
|
jQuery(obj).parents("tr").remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script>
|
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script>
|
||||||
<script type="text/javascript" src="static/icheck/icheck.min.js?{VERHASH}"></script>
|
<script type="text/javascript" src="static/icheck/icheck.min.js?{VERHASH}"></script>
|
||||||
<!--{template common/footer_simple}-->
|
<!--{template common/footer_simple}-->
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<ul class="nav-stacked">
|
<ul class="nav-stacked">
|
||||||
<li <!--{if $_GET[op]!="admin" }--> class="active" <!--{/if}-->><a hidefocus="true" href="{MOD_URL}">{lang systemlog_list}</a></li>
|
<li <!--{if $_GET[op]!="admin" }--> class="active" <!--{/if}-->><a hidefocus="true" href="{MOD_URL}">{lang systemlog_list}</a></li>
|
||||||
<li <!--{if $_GET[op]=="admin" }--> class="active" <!--{/if}-->><a hidefocus="true" href="{MOD_URL}&op=admin">{lang systemlog_setting}</a></li>
|
<li <!--{if $_GET[op]=="admin" }--> class="active" <!--{/if}-->><a hidefocus="true" href="{MOD_URL}&op=admin">{lang systemlog_setting}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -1,110 +1,110 @@
|
|||||||
<!--{template common/header_simple_start}-->
|
<!--{template common/header_simple_start}-->
|
||||||
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
|
<link href="static/css/common.css?{VERHASH}" rel="stylesheet" media="all">
|
||||||
<link href="static/select2/select2.css?{VERHASH}" rel="stylesheet" media="all">
|
<link href="static/select2/select2.css?{VERHASH}" rel="stylesheet" media="all">
|
||||||
<link href="static/select2/select2-bootstrap.css?{VERHASH}" rel="stylesheet" media="all">
|
<link href="static/select2/select2-bootstrap.css?{VERHASH}" rel="stylesheet" media="all">
|
||||||
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
|
<script type="text/javascript" src="static/js/jquery.leftDrager.js?{VERHASH}"></script>
|
||||||
<style>
|
<style>
|
||||||
input[type="text"] {
|
input[type="text"] {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<!--{template common/header_simple_end}-->
|
<!--{template common/header_simple_end}-->
|
||||||
<!--{template common/commer_header}-->
|
<!--{template common/commer_header}-->
|
||||||
<div class="bs-container clearfix">
|
<div class="bs-container clearfix">
|
||||||
<div class="bs-left-container clearfix">
|
<div class="bs-left-container clearfix">
|
||||||
<!--{template left}-->
|
<!--{template left}-->
|
||||||
</div>
|
</div>
|
||||||
<div class="left-drager">
|
<div class="left-drager">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="bs-main-container clearfix">
|
<div class="bs-main-container clearfix">
|
||||||
|
|
||||||
<div class="main-header clearfix" style="border-bottom:1px solid #e1e1e1;padding-top: 15px;">
|
<div class="main-header clearfix" style="border-bottom:1px solid #e1e1e1;padding-top: 15px;">
|
||||||
|
|
||||||
<ul class="nav nav-pills nav-pills-bottomguide">
|
<ul class="nav nav-pills nav-pills-bottomguide">
|
||||||
|
|
||||||
<!--{loop $systemlog_setting $mark $info}-->
|
<!--{loop $systemlog_setting $mark $info}-->
|
||||||
<!--{if $info[is_open]==1 }-->
|
<!--{if $info[is_open]==1 }-->
|
||||||
<li <!--{if $operation==$mark }-->class="active"<!--{/if}-->>
|
<li <!--{if $operation==$mark }-->class="active"<!--{/if}-->>
|
||||||
<a hidefocus="true" href="{BASESCRIPT}?mod=systemlog&type=list&operation=$mark">{$info['title']}</a>
|
<a hidefocus="true" href="{BASESCRIPT}?mod=systemlog&type=list&operation=$mark">{$info['title']}</a>
|
||||||
</li>
|
</li>
|
||||||
<!--{/if}-->
|
<!--{/if}-->
|
||||||
<!--{/loop}-->
|
<!--{/loop}-->
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="main-content" style="border-top:1px solid #FFF">
|
<div class="main-content" style="border-top:1px solid #FFF">
|
||||||
|
|
||||||
<form id="cpform" action="{BASESCRIPT}?mod=systemlog&type=list&operation=$operation" class="form-horizontal form-horizontal-left" method="post" name="cpform">
|
<form id="cpform" action="{BASESCRIPT}?mod=systemlog&type=list&operation=$operation" class="form-horizontal form-horizontal-left" method="post" name="cpform">
|
||||||
<input type="hidden" value="{FORMHASH}" name="formhash">
|
<input type="hidden" value="{FORMHASH}" name="formhash">
|
||||||
<input type="hidden" name="lpp" value="20">
|
<input type="hidden" name="lpp" value="20">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<th width="80">{lang operator}</th>
|
<th width="80">{lang operator}</th>
|
||||||
<th width="80">{lang usergroup}</th>
|
<th width="80">{lang usergroup}</th>
|
||||||
<th width="120">{lang ip}</th>
|
<th width="120">{lang ip}</th>
|
||||||
<th width="120">{lang time}</th>
|
<th width="120">{lang time}</th>
|
||||||
<th>{lang info}</th>
|
<th>{lang info}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<!--{if $list}-->
|
<!--{if $list}-->
|
||||||
<!--{loop $list $key $log}-->
|
<!--{loop $list $key $log}-->
|
||||||
<tr>
|
<tr>
|
||||||
<td>$log[2]</td>
|
<td>$log[2]</td>
|
||||||
<td>$log[3]</td>
|
<td>$log[3]</td>
|
||||||
<td>$log[4]</td>
|
<td>$log[4]</td>
|
||||||
<td>$log[1]</td>
|
<td>$log[1]</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="javascript:;" onclick="togglecplog('{$key}')">{eval echo cutstr($log[5], 200)}</a>
|
<a href="javascript:;" onclick="togglecplog('{$key}')">{eval echo cutstr($log[5], 200)}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<thead id="cplog_{$key}" style="display:none">
|
<thead id="cplog_{$key}" style="display:none">
|
||||||
<td colspan="10">
|
<td colspan="10">
|
||||||
{lang loginfo}: $log[5]
|
{lang loginfo}: $log[5]
|
||||||
<br/>{lang visit}: $log[6]
|
<br/>{lang visit}: $log[6]
|
||||||
<br/>{lang from}: $log[7]</td>
|
<br/>{lang from}: $log[7]</td>
|
||||||
</thead>
|
</thead>
|
||||||
<!--{/loop}-->
|
<!--{/loop}-->
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="15">
|
<td colspan="15">
|
||||||
<div class="pull-left input-group" style="width:100px;">
|
<div class="pull-left input-group" style="width:100px;">
|
||||||
<span class="input-group-addon">{lang logs_lpp}</span>
|
<span class="input-group-addon">{lang logs_lpp}</span>
|
||||||
<select class="input-sm form-control" style="margin:0;width:60px;" onchange="if(this.options[this.selectedIndex].value != '') {this.form.lpp.value = this.options[this.selectedIndex].value;this.form.submit(); }">
|
<select class="input-sm form-control" style="margin:0;width:60px;" onchange="if(this.options[this.selectedIndex].value != '') {this.form.lpp.value = this.options[this.selectedIndex].value;this.form.submit(); }">
|
||||||
<option value="20" $checklpp[20]> 20 </option>
|
<option value="20" $checklpp[20]> 20 </option>
|
||||||
<option value="40" $checklpp[40]> 40 </option>
|
<option value="40" $checklpp[40]> 40 </option>
|
||||||
<option value="80" $checklpp[80]> 80 </option>
|
<option value="80" $checklpp[80]> 80 </option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="pull-left input-group" style="width:128px;">
|
<div class="pull-left input-group" style="width:128px;">
|
||||||
<input type="text" class="input-sm form-control" style="width:90px;border-left:0" name="keyword" value="$_GET[keyword]">
|
<input type="text" class="input-sm form-control" style="width:90px;border-left:0" name="keyword" value="$_GET[keyword]">
|
||||||
<a href="javascript:;" class="input-group-addon" onclick="document.getElementById('cpform').submit();return false"><i class="glyphicon glyphicon-search"></i></a>
|
<a href="javascript:;" class="input-group-addon" onclick="document.getElementById('cpform').submit();return false"><i class="glyphicon glyphicon-search"></i></a>
|
||||||
</div>
|
</div>
|
||||||
$multipage
|
$multipage
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!--{else}-->
|
<!--{else}-->
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5">{lang there_no_such_results}</td>
|
<td colspan="5">{lang there_no_such_results}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!--{/if}-->
|
<!--{/if}-->
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function togglecplog(k) {
|
function togglecplog(k) {
|
||||||
var cplogobj = document.getElementById('cplog_' + k);
|
var cplogobj = document.getElementById('cplog_' + k);
|
||||||
if(cplogobj.style.display == 'none') {
|
if(cplogobj.style.display == 'none') {
|
||||||
cplogobj.style.display = '';
|
cplogobj.style.display = '';
|
||||||
} else {
|
} else {
|
||||||
cplogobj.style.display = 'none';
|
cplogobj.style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery('.left-drager').leftDrager_layout();
|
jQuery('.left-drager').leftDrager_layout();
|
||||||
</script>
|
</script>
|
||||||
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script>
|
<script src="static/bootstrap/js/bootstrap.min.js?{VERHASH}"></script>
|
||||||
<!--{template common/footer_simple}-->
|
<!--{template common/footer_simple}-->
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* 应用卸载文件;
|
* 应用卸载文件;
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author qchlian
|
* @author qchlian
|
||||||
*/
|
*/
|
||||||
if(!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
|
if(!defined('IN_OAOOA') || !defined('IN_ADMIN')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
$sql = <<<EOF
|
$sql = <<<EOF
|
||||||
DELETE FROM `dzz_setting` WHERE `dzz_setting`.`skey` = 'systemlog_setting';
|
DELETE FROM `dzz_setting` WHERE `dzz_setting`.`skey` = 'systemlog_setting';
|
||||||
DELETE FROM `dzz_setting` WHERE `dzz_setting`.`skey` = 'systemlog_open';
|
DELETE FROM `dzz_setting` WHERE `dzz_setting`.`skey` = 'systemlog_open';
|
||||||
EOF;
|
EOF;
|
||||||
runquery($sql);
|
runquery($sql);
|
||||||
$finish = true;
|
$finish = true;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<ul class="nav navbar-nav navbar-nav-left" style="min-width:168px">
|
<ul class="nav navbar-nav navbar-nav-left" style="min-width:168px">
|
||||||
<li>
|
<li>
|
||||||
<a class="leftTopmenu" href="index.php?mod=appmanagement" style="padding:8px"><div class="gb_fc"><span class="dzz dzz-chevron-left" style="display:block"></span></div></a>
|
<a class="leftTopmenu" href="index.php?mod=appmanagement" style="padding:8px"><div class="gb_fc"><span class="dzz dzz-chevron-left" style="display:block"></span></div></a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{MOD_URL}">{lang appname}</a>
|
<a href="{MOD_URL}">{lang appname}</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
110
avatar.php
110
avatar.php
@@ -1,55 +1,55 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author zyx(zyx@oaooa.com)
|
* @author zyx(zyx@oaooa.com)
|
||||||
*/
|
*/
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
define('SITEURL', strtolower(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));
|
define('SITEURL', strtolower(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'))));
|
||||||
|
|
||||||
$uid = isset($_GET['uid']) ? $_GET['uid'] : 0;
|
$uid = isset($_GET['uid']) ? $_GET['uid'] : 0;
|
||||||
$size = isset($_GET['size']) ? $_GET['size'] : '';
|
$size = isset($_GET['size']) ? $_GET['size'] : '';
|
||||||
$random = isset($_GET['random']) ? $_GET['random'] : '';
|
$random = isset($_GET['random']) ? $_GET['random'] : '';
|
||||||
$type = isset($_GET['type']) ? $_GET['type'] : '';
|
$type = isset($_GET['type']) ? $_GET['type'] : '';
|
||||||
$check = isset($_GET['check_file_exists']) ? $_GET['check_file_exists'] : '';
|
$check = isset($_GET['check_file_exists']) ? $_GET['check_file_exists'] : '';
|
||||||
|
|
||||||
$avatar = './data/avatar/'.get_avatar($uid, $size, $type);
|
$avatar = './data/avatar/'.get_avatar($uid, $size, $type);
|
||||||
if(file_exists(dirname(__FILE__).'/'.$avatar)) {
|
if(file_exists(dirname(__FILE__).'/'.$avatar)) {
|
||||||
if($check) {
|
if($check) {
|
||||||
echo 1;
|
echo 1;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$random = !empty($random) ? rand(1000, 9999) : '';
|
$random = !empty($random) ? rand(1000, 9999) : '';
|
||||||
$avatar_url = empty($random) ? $avatar : $avatar.'?random='.$random;
|
$avatar_url = empty($random) ? $avatar : $avatar.'?random='.$random;
|
||||||
} else {
|
} else {
|
||||||
if($check) {
|
if($check) {
|
||||||
echo 0;
|
echo 0;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
|
$size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
|
||||||
$avatar_url = 'data/avatar/noavatar_'.$size.'.gif';
|
$avatar_url = 'data/avatar/noavatar_'.$size.'.gif';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($random)) {
|
if(empty($random)) {
|
||||||
header("HTTP/1.1 301 Moved Permanently");
|
header("HTTP/1.1 301 Moved Permanently");
|
||||||
header("Last-Modified:".date('r'));
|
header("Last-Modified:".date('r'));
|
||||||
header("Expires: ".date('r', time() + 86400));
|
header("Expires: ".date('r', time() + 86400));
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: '.SITEURL.'/'.$avatar_url);
|
header('Location: '.SITEURL.'/'.$avatar_url);
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
function get_avatar($uid, $size = 'middle', $type = '') {
|
function get_avatar($uid, $size = 'middle', $type = '') {
|
||||||
$size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
|
$size = in_array($size, array('big', 'middle', 'small')) ? $size : 'middle';
|
||||||
$uid = abs(intval($uid));
|
$uid = abs(intval($uid));
|
||||||
$uid = sprintf("%09d", $uid);
|
$uid = sprintf("%09d", $uid);
|
||||||
$dir1 = substr($uid, 0, 3);
|
$dir1 = substr($uid, 0, 3);
|
||||||
$dir2 = substr($uid, 3, 2);
|
$dir2 = substr($uid, 3, 2);
|
||||||
$dir3 = substr($uid, 5, 2);
|
$dir3 = substr($uid, 5, 2);
|
||||||
$typeadd = $type == 'real' ? '_real' : '';
|
$typeadd = $type == 'real' ? '_real' : '';
|
||||||
return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).$typeadd."_avatar_$size.jpg";
|
return $dir1.'/'.$dir2.'/'.$dir3.'/'.substr($uid, -2).$typeadd."_avatar_$size.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,37 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
$_config = array();
|
$_config = array();
|
||||||
$_config['namespacelist'] = array(
|
$_config['namespacelist'] = array(
|
||||||
'root' =>DZZ_ROOT,
|
'root' =>DZZ_ROOT,
|
||||||
'coreroot' => DZZ_ROOT.'core',
|
'coreroot' => DZZ_ROOT.'core',
|
||||||
'admin' => DZZ_ROOT.'admin',
|
'admin' => DZZ_ROOT.'admin',
|
||||||
'core' => CORE_PATH,
|
'core' => CORE_PATH,
|
||||||
'dzz' => DZZ_ROOT.APP_DIRNAME,
|
'dzz' => DZZ_ROOT.APP_DIRNAME,
|
||||||
'user' => DZZ_ROOT.'user',
|
'user' => DZZ_ROOT.'user',
|
||||||
'misc' => DZZ_ROOT.'misc'
|
'misc' => DZZ_ROOT.'misc'
|
||||||
);
|
);
|
||||||
|
|
||||||
$_config['default_mod'] = 'index';
|
$_config['default_mod'] = 'index';
|
||||||
|
|
||||||
$_config['default_op'] = 'index';
|
$_config['default_op'] = 'index';
|
||||||
|
|
||||||
$_config['default_action'] = 'index';
|
$_config['default_action'] = 'index';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 其它配置
|
* 其它配置
|
||||||
*/
|
*/
|
||||||
$_config['allow_robot'] = false;
|
$_config['allow_robot'] = false;
|
||||||
$_config['allow_view'] = 0;//(0=>所有人,1=>用户,2=>管理员,3=>创始人)
|
$_config['allow_view'] = 0;//(0=>所有人,1=>用户,2=>管理员,3=>创始人)
|
||||||
$_config['libfile'] = '';
|
$_config['libfile'] = '';
|
||||||
$_config['language'] = '';
|
$_config['language'] = '';
|
||||||
$_config['mod_view_perm'] = '';
|
$_config['mod_view_perm'] = '';
|
||||||
$_config['action_name'] = 'do';
|
$_config['action_name'] = 'do';
|
||||||
$_config['do_name'] = 'action';
|
$_config['do_name'] = 'action';
|
||||||
|
|
||||||
$_config['profile']['privacy'] = array(
|
$_config['profile']['privacy'] = array(
|
||||||
'-1'=>'私密',
|
'-1'=>'私密',
|
||||||
'0'=>'公开',
|
'0'=>'公开',
|
||||||
'1'=>'本部门可见',
|
'1'=>'本部门可见',
|
||||||
'2'=>'本机构可见',
|
'2'=>'本机构可见',
|
||||||
);
|
);
|
||||||
return $_config;
|
return $_config;
|
||||||
@@ -1,22 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author zyx(zyx@oaooa.com)
|
* @author zyx(zyx@oaooa.com)
|
||||||
*/
|
*/
|
||||||
require __DIR__.'/coreBase.php';
|
require __DIR__.'/coreBase.php';
|
||||||
$dzz = C::app();
|
$dzz = C::app();
|
||||||
Hook::listen('dzz_initbefore');//初始化前钩子
|
Hook::listen('dzz_initbefore');//初始化前钩子
|
||||||
$dzz->init();
|
$dzz->init();
|
||||||
|
|
||||||
$admincp = new dzz_admincp();
|
$admincp = new dzz_admincp();
|
||||||
$admincp->core = $dzz;
|
$admincp->core = $dzz;
|
||||||
$admincp->init();
|
$admincp->init();
|
||||||
Hook::listen('dzz_initafter');//初始化后钩子
|
Hook::listen('dzz_initafter');//初始化后钩子
|
||||||
$files = Hook::listen('dzz_route',$_GET);//路由钩子,返回文件路径
|
$files = Hook::listen('dzz_route',$_GET);//路由钩子,返回文件路径
|
||||||
foreach($files as $v){
|
foreach($files as $v){
|
||||||
require $v;//包含文件
|
require $v;//包含文件
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
152
core/class/cache/cache_file.php
vendored
152
core/class/cache/cache_file.php
vendored
@@ -1,77 +1,77 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class ultrax_cache {
|
class ultrax_cache {
|
||||||
|
|
||||||
function ultrax_cache($conf) {
|
function ultrax_cache($conf) {
|
||||||
$this->conf = $conf;
|
$this->conf = $conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_cache($key) {
|
function get_cache($key) {
|
||||||
if($this->cache_exists($key)) {
|
if($this->cache_exists($key)) {
|
||||||
$data = $this->_get_cache($key);
|
$data = $this->_get_cache($key);
|
||||||
return $data['data'];
|
return $data['data'];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_cache($key, $value, $life) {
|
function set_cache($key, $value, $life) {
|
||||||
global $_G;
|
global $_G;
|
||||||
$data = array($key => array('data' => $value, 'life' => $life));
|
$data = array($key => array('data' => $value, 'life' => $life));
|
||||||
require_once libfile('function/cache');
|
require_once libfile('function/cache');
|
||||||
$cache_file = $this->get_cache_file_path($key);
|
$cache_file = $this->get_cache_file_path($key);
|
||||||
dmkdir(dirname($cache_file));
|
dmkdir(dirname($cache_file));
|
||||||
$cachedata = "\$data = ".arrayeval($data).";\n";
|
$cachedata = "\$data = ".arrayeval($data).";\n";
|
||||||
if($fp = @fopen($cache_file, 'wb')) {
|
if($fp = @fopen($cache_file, 'wb')) {
|
||||||
fwrite($fp, "<?php\n//Dzz! cache file, DO NOT modify me!".
|
fwrite($fp, "<?php\n//Dzz! cache file, DO NOT modify me!".
|
||||||
"\n//Created: ".date("M j, Y, G:i").
|
"\n//Created: ".date("M j, Y, G:i").
|
||||||
"\n//Identify: ".md5($cache_file.$cachedata.$_G['config']['security']['authkey'])."\n\nif(!defined('IN_OAOOA')) {\n\texit('Access Denied');\n}\n\n$cachedata?>");
|
"\n//Identify: ".md5($cache_file.$cachedata.$_G['config']['security']['authkey'])."\n\nif(!defined('IN_OAOOA')) {\n\texit('Access Denied');\n}\n\n$cachedata?>");
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
} else {
|
} else {
|
||||||
exit('Can not write to cache files, please check directory ./data/ and ./data/ultraxcache/ .');
|
exit('Can not write to cache files, please check directory ./data/ and ./data/ultraxcache/ .');
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function del_cache($key) {
|
function del_cache($key) {
|
||||||
$cache_file = $this->get_cache_file_path($key);
|
$cache_file = $this->get_cache_file_path($key);
|
||||||
if(file_exists($cache_file)) {
|
if(file_exists($cache_file)) {
|
||||||
return @unlink($cache_file);
|
return @unlink($cache_file);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _get_cache($key) {
|
function _get_cache($key) {
|
||||||
static $data = null;
|
static $data = null;
|
||||||
if(!isset($data[$key])) {
|
if(!isset($data[$key])) {
|
||||||
include $this->get_cache_file_path($key);
|
include $this->get_cache_file_path($key);
|
||||||
}
|
}
|
||||||
return $data[$key];
|
return $data[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
function cache_exists($key) {
|
function cache_exists($key) {
|
||||||
$cache_file = $this->get_cache_file_path($key);
|
$cache_file = $this->get_cache_file_path($key);
|
||||||
if(!file_exists($cache_file)) {
|
if(!file_exists($cache_file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data = $this->_get_cache($key);
|
$data = $this->_get_cache($key);
|
||||||
if($data['life'] && (filemtime($cache_file) < time() - $data['life'])) {
|
if($data['life'] && (filemtime($cache_file) < time() - $data['life'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_cache_file_path($key) {
|
function get_cache_file_path($key) {
|
||||||
static $cache_path = null;
|
static $cache_path = null;
|
||||||
if(!isset($cache_path[$key])) {
|
if(!isset($cache_path[$key])) {
|
||||||
$dir = hexdec($key{0}.$key{1}.$key{2}) % 1000;
|
$dir = hexdec($key{0}.$key{1}.$key{2}) % 1000;
|
||||||
$cache_path[$key] = $this->conf['path'].'/'.$dir.'/'.$key.'.php';
|
$cache_path[$key] = $this->conf['path'].'/'.$dir.'/'.$key.'.php';
|
||||||
}
|
}
|
||||||
return $cache_path[$key];
|
return $cache_path[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
80
core/class/cache/cache_sql.php
vendored
80
core/class/cache/cache_sql.php
vendored
@@ -1,41 +1,41 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class ultrax_cache {
|
class ultrax_cache {
|
||||||
|
|
||||||
function ultrax_cache($conf) {
|
function ultrax_cache($conf) {
|
||||||
$this->conf = $conf;
|
$this->conf = $conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_cache($key) {
|
function get_cache($key) {
|
||||||
static $data = null;
|
static $data = null;
|
||||||
if(!isset($data[$key])) {
|
if(!isset($data[$key])) {
|
||||||
$cache = C::t('cache')->fetch($key);
|
$cache = C::t('cache')->fetch($key);
|
||||||
if(!$cache) {
|
if(!$cache) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data[$key] = unserialize($cache['cachevalue']);
|
$data[$key] = unserialize($cache['cachevalue']);
|
||||||
if($cache['life'] && ($cache['dateline'] < time() - $data[$key]['life'])) {
|
if($cache['life'] && ($cache['dateline'] < time() - $data[$key]['life'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $data[$key]['data'];
|
return $data[$key]['data'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_cache($key, $value, $life) {
|
function set_cache($key, $value, $life) {
|
||||||
$data = array(
|
$data = array(
|
||||||
'cachekey' => $key,
|
'cachekey' => $key,
|
||||||
'cachevalue' => serialize(array('data' => $value, 'life' => $life)),
|
'cachevalue' => serialize(array('data' => $value, 'life' => $life)),
|
||||||
'dateline' => time(),
|
'dateline' => time(),
|
||||||
);
|
);
|
||||||
return C::t('cache')->insert($data);
|
return C::t('cache')->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function del_cache($key) {
|
function del_cache($key) {
|
||||||
return C::t('cache')->delete($key);
|
return C::t('cache')->delete($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class CException extends Exception{
|
class CException extends Exception{
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,239 +1,239 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
define('CODETABLE_DIR', DZZ_ROOT.'./core/class/chinesetable/');
|
define('CODETABLE_DIR', DZZ_ROOT.'./core/class/chinesetable/');
|
||||||
|
|
||||||
class Chinese {
|
class Chinese {
|
||||||
|
|
||||||
var $table = '';
|
var $table = '';
|
||||||
var $iconv_enabled = false;
|
var $iconv_enabled = false;
|
||||||
var $convertbig5 = false;
|
var $convertbig5 = false;
|
||||||
var $unicode_table = array();
|
var $unicode_table = array();
|
||||||
var $config = array (
|
var $config = array (
|
||||||
'SourceLang' => '',
|
'SourceLang' => '',
|
||||||
'TargetLang' => '',
|
'TargetLang' => '',
|
||||||
'GBtoUnicode_table' => 'gb-unicode.table',
|
'GBtoUnicode_table' => 'gb-unicode.table',
|
||||||
'BIG5toUnicode_table' => 'big5-unicode.table',
|
'BIG5toUnicode_table' => 'big5-unicode.table',
|
||||||
'GBtoBIG5_table' => 'gb-big5.table',
|
'GBtoBIG5_table' => 'gb-big5.table',
|
||||||
);
|
);
|
||||||
|
|
||||||
function Chinese($SourceLang, $TargetLang, $ForceTable = FALSE) {
|
function Chinese($SourceLang, $TargetLang, $ForceTable = FALSE) {
|
||||||
$this->config['SourceLang'] = $this->_lang($SourceLang);
|
$this->config['SourceLang'] = $this->_lang($SourceLang);
|
||||||
$this->config['TargetLang'] = $this->_lang($TargetLang);
|
$this->config['TargetLang'] = $this->_lang($TargetLang);
|
||||||
|
|
||||||
if(ICONV_ENABLE && $this->config['TargetLang'] != 'BIG5' && !$ForceTable) {
|
if(ICONV_ENABLE && $this->config['TargetLang'] != 'BIG5' && !$ForceTable) {
|
||||||
$this->iconv_enabled = true;
|
$this->iconv_enabled = true;
|
||||||
} else {
|
} else {
|
||||||
$this->iconv_enabled = false;
|
$this->iconv_enabled = false;
|
||||||
$this->OpenTable();
|
$this->OpenTable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _lang($LangCode) {
|
function _lang($LangCode) {
|
||||||
$LangCode = strtoupper($LangCode);
|
$LangCode = strtoupper($LangCode);
|
||||||
|
|
||||||
if(substr($LangCode, 0, 2) == 'GB') {
|
if(substr($LangCode, 0, 2) == 'GB') {
|
||||||
return 'GBK';
|
return 'GBK';
|
||||||
} elseif(substr($LangCode, 0, 3) == 'BIG') {
|
} elseif(substr($LangCode, 0, 3) == 'BIG') {
|
||||||
return 'BIG5';
|
return 'BIG5';
|
||||||
} elseif(substr($LangCode, 0, 3) == 'UTF') {
|
} elseif(substr($LangCode, 0, 3) == 'UTF') {
|
||||||
return 'UTF-8';
|
return 'UTF-8';
|
||||||
} elseif(substr($LangCode, 0, 3) == 'UNI') {
|
} elseif(substr($LangCode, 0, 3) == 'UNI') {
|
||||||
return 'UNICODE';
|
return 'UNICODE';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _hex2bin($hexdata) {
|
function _hex2bin($hexdata) {
|
||||||
for($i=0; $i < strlen($hexdata); $i += 2) {
|
for($i=0; $i < strlen($hexdata); $i += 2) {
|
||||||
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
|
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
|
||||||
}
|
}
|
||||||
return $bindata;
|
return $bindata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function OpenTable() {
|
function OpenTable() {
|
||||||
$this->unicode_table = array();
|
$this->unicode_table = array();
|
||||||
if(!$this->iconv_enabled && $this->config['TargetLang'] == 'BIG5') {
|
if(!$this->iconv_enabled && $this->config['TargetLang'] == 'BIG5') {
|
||||||
$this->config['TargetLang'] = 'GBK';
|
$this->config['TargetLang'] = 'GBK';
|
||||||
$this->convertbig5 = TRUE;
|
$this->convertbig5 = TRUE;
|
||||||
}
|
}
|
||||||
if($this->config['SourceLang'] == 'GBK' || $this->config['TargetLang'] == 'GBK') {
|
if($this->config['SourceLang'] == 'GBK' || $this->config['TargetLang'] == 'GBK') {
|
||||||
$this->table = CODETABLE_DIR.$this->config['GBtoUnicode_table'];
|
$this->table = CODETABLE_DIR.$this->config['GBtoUnicode_table'];
|
||||||
} elseif($this->config['SourceLang'] == 'BIG5' || $this->config['TargetLang'] == 'BIG5') {
|
} elseif($this->config['SourceLang'] == 'BIG5' || $this->config['TargetLang'] == 'BIG5') {
|
||||||
$this->table = CODETABLE_DIR.$this->config['BIG5toUnicode_table'];
|
$this->table = CODETABLE_DIR.$this->config['BIG5toUnicode_table'];
|
||||||
}
|
}
|
||||||
$fp = fopen($this->table, 'rb');
|
$fp = fopen($this->table, 'rb');
|
||||||
$tabletmp = fread($fp, filesize($this->table));
|
$tabletmp = fread($fp, filesize($this->table));
|
||||||
for($i = 0; $i < strlen($tabletmp); $i += 4) {
|
for($i = 0; $i < strlen($tabletmp); $i += 4) {
|
||||||
$tmp = unpack('nkey/nvalue', substr($tabletmp, $i, 4));
|
$tmp = unpack('nkey/nvalue', substr($tabletmp, $i, 4));
|
||||||
if($this->config['TargetLang'] == 'UTF-8') {
|
if($this->config['TargetLang'] == 'UTF-8') {
|
||||||
$this->unicode_table[$tmp['key']] = '0x'.dechex($tmp['value']);
|
$this->unicode_table[$tmp['key']] = '0x'.dechex($tmp['value']);
|
||||||
} elseif($this->config['SourceLang'] == 'UTF-8') {
|
} elseif($this->config['SourceLang'] == 'UTF-8') {
|
||||||
$this->unicode_table[$tmp['value']] = '0x'.dechex($tmp['key']);
|
$this->unicode_table[$tmp['value']] = '0x'.dechex($tmp['key']);
|
||||||
} elseif($this->config['TargetLang'] == 'UNICODE') {
|
} elseif($this->config['TargetLang'] == 'UNICODE') {
|
||||||
$this->unicode_table[$tmp['key']] = dechex($tmp['value']);
|
$this->unicode_table[$tmp['key']] = dechex($tmp['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function CHSUtoUTF8($c) {
|
function CHSUtoUTF8($c) {
|
||||||
$str = '';
|
$str = '';
|
||||||
if($c < 0x80) {
|
if($c < 0x80) {
|
||||||
$str .= $c;
|
$str .= $c;
|
||||||
} elseif($c < 0x800) {
|
} elseif($c < 0x800) {
|
||||||
$str .= (0xC0 | $c >> 6);
|
$str .= (0xC0 | $c >> 6);
|
||||||
$str .= (0x80 | $c & 0x3F);
|
$str .= (0x80 | $c & 0x3F);
|
||||||
} elseif($c < 0x10000) {
|
} elseif($c < 0x10000) {
|
||||||
$str .= (0xE0 | $c >> 12);
|
$str .= (0xE0 | $c >> 12);
|
||||||
$str .= (0x80 | $c >> 6 & 0x3F);
|
$str .= (0x80 | $c >> 6 & 0x3F);
|
||||||
$str .=( 0x80 | $c & 0x3F);
|
$str .=( 0x80 | $c & 0x3F);
|
||||||
} elseif($c < 0x200000) {
|
} elseif($c < 0x200000) {
|
||||||
$str .= (0xF0 | $c >> 18);
|
$str .= (0xF0 | $c >> 18);
|
||||||
$str .= (0x80 | $c >> 12 & 0x3F);
|
$str .= (0x80 | $c >> 12 & 0x3F);
|
||||||
$str .= (0x80 | $c >> 6 & 0x3F);
|
$str .= (0x80 | $c >> 6 & 0x3F);
|
||||||
$str .= (0x80 | $c & 0x3F);
|
$str .= (0x80 | $c & 0x3F);
|
||||||
}
|
}
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function GB2312toBIG5($c) {
|
function GB2312toBIG5($c) {
|
||||||
$f = fopen(CODETABLE_DIR.$this->config['GBtoBIG5_table'], 'r');
|
$f = fopen(CODETABLE_DIR.$this->config['GBtoBIG5_table'], 'r');
|
||||||
$max=strlen($c)-1;
|
$max=strlen($c)-1;
|
||||||
for($i = 0;$i < $max;$i++){
|
for($i = 0;$i < $max;$i++){
|
||||||
$h=ord($c[$i]);
|
$h=ord($c[$i]);
|
||||||
if($h>=160) {
|
if($h>=160) {
|
||||||
$l=ord($c[$i+1]);
|
$l=ord($c[$i+1]);
|
||||||
if($h==161 && $l==64){
|
if($h==161 && $l==64){
|
||||||
$gb=" ";
|
$gb=" ";
|
||||||
} else{
|
} else{
|
||||||
fseek($f,($h-160)*510+($l-1)*2);
|
fseek($f,($h-160)*510+($l-1)*2);
|
||||||
$gb=fread($f,2);
|
$gb=fread($f,2);
|
||||||
}
|
}
|
||||||
$c[$i]=$gb[0];
|
$c[$i]=$gb[0];
|
||||||
$c[$i+1]=$gb[1];
|
$c[$i+1]=$gb[1];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = $c;
|
$result = $c;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Convert($SourceText) {
|
function Convert($SourceText) {
|
||||||
if($this->config['SourceLang'] == $this->config['TargetLang']) {
|
if($this->config['SourceLang'] == $this->config['TargetLang']) {
|
||||||
return $SourceText;
|
return $SourceText;
|
||||||
} elseif($this->iconv_enabled) {
|
} elseif($this->iconv_enabled) {
|
||||||
if($this->config['TargetLang'] <> 'UNICODE') {
|
if($this->config['TargetLang'] <> 'UNICODE') {
|
||||||
return iconv($this->config['SourceLang'], $this->config['TargetLang'], $SourceText);
|
return iconv($this->config['SourceLang'], $this->config['TargetLang'], $SourceText);
|
||||||
} else {
|
} else {
|
||||||
$return = '';
|
$return = '';
|
||||||
while($SourceText != '') {
|
while($SourceText != '') {
|
||||||
if(ord(substr($SourceText, 0, 1)) > 127) {
|
if(ord(substr($SourceText, 0, 1)) > 127) {
|
||||||
$return .= "&#x".dechex($this->Utf8_Unicode(iconv($this->config['SourceLang'],"UTF-8", substr($SourceText, 0, 2)))).";";
|
$return .= "&#x".dechex($this->Utf8_Unicode(iconv($this->config['SourceLang'],"UTF-8", substr($SourceText, 0, 2)))).";";
|
||||||
$SourceText = substr($SourceText, 2, strlen($SourceText));
|
$SourceText = substr($SourceText, 2, strlen($SourceText));
|
||||||
} else {
|
} else {
|
||||||
$return .= substr($SourceText, 0, 1);
|
$return .= substr($SourceText, 0, 1);
|
||||||
$SourceText = substr($SourceText, 1, strlen($SourceText));
|
$SourceText = substr($SourceText, 1, strlen($SourceText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif($this->config['TargetLang'] == 'UNICODE') {
|
} elseif($this->config['TargetLang'] == 'UNICODE') {
|
||||||
$utf = '';
|
$utf = '';
|
||||||
while($SourceText != '') {
|
while($SourceText != '') {
|
||||||
if(ord(substr($SourceText, 0, 1)) > 127) {
|
if(ord(substr($SourceText, 0, 1)) > 127) {
|
||||||
if($this->config['SourceLang'] == 'GBK') {
|
if($this->config['SourceLang'] == 'GBK') {
|
||||||
$utf .= '&#x'.$this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2))) - 0x8080].';';
|
$utf .= '&#x'.$this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2))) - 0x8080].';';
|
||||||
} elseif($this->config['SourceLang'] == 'BIG5') {
|
} elseif($this->config['SourceLang'] == 'BIG5') {
|
||||||
$utf .= '&#x'.$this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2)))].';';
|
$utf .= '&#x'.$this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2)))].';';
|
||||||
}
|
}
|
||||||
$SourceText = substr($SourceText, 2, strlen($SourceText));
|
$SourceText = substr($SourceText, 2, strlen($SourceText));
|
||||||
} else {
|
} else {
|
||||||
$utf .= substr($SourceText, 0, 1);
|
$utf .= substr($SourceText, 0, 1);
|
||||||
$SourceText = substr($SourceText, 1, strlen($SourceText));
|
$SourceText = substr($SourceText, 1, strlen($SourceText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $utf;
|
return $utf;
|
||||||
} else {
|
} else {
|
||||||
$ret = '';
|
$ret = '';
|
||||||
if($this->config['SourceLang'] == 'UTF-8') {
|
if($this->config['SourceLang'] == 'UTF-8') {
|
||||||
$out = '';
|
$out = '';
|
||||||
$len = strlen($SourceText);
|
$len = strlen($SourceText);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while($i < $len) {
|
while($i < $len) {
|
||||||
$c = ord(substr($SourceText, $i++, 1));
|
$c = ord(substr($SourceText, $i++, 1));
|
||||||
switch($c >> 4) {
|
switch($c >> 4) {
|
||||||
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
|
||||||
$out .= substr($SourceText, $i - 1, 1);
|
$out .= substr($SourceText, $i - 1, 1);
|
||||||
break;
|
break;
|
||||||
case 12: case 13:
|
case 12: case 13:
|
||||||
$char2 = ord(substr($SourceText, $i++, 1));
|
$char2 = ord(substr($SourceText, $i++, 1));
|
||||||
$char3 = $this->unicode_table[(($c & 0x1F) << 6) | ($char2 & 0x3F)];
|
$char3 = $this->unicode_table[(($c & 0x1F) << 6) | ($char2 & 0x3F)];
|
||||||
if($this->config['TargetLang'] == 'GBK') {
|
if($this->config['TargetLang'] == 'GBK') {
|
||||||
$out .= $this->_hex2bin(dechex($char3 + 0x8080));
|
$out .= $this->_hex2bin(dechex($char3 + 0x8080));
|
||||||
} elseif($this->config['TargetLang'] == 'BIG5') {
|
} elseif($this->config['TargetLang'] == 'BIG5') {
|
||||||
$out .= $this->_hex2bin($char3);
|
$out .= $this->_hex2bin($char3);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
$char2 = ord(substr($SourceText, $i++, 1));
|
$char2 = ord(substr($SourceText, $i++, 1));
|
||||||
$char3 = ord(substr($SourceText, $i++, 1));
|
$char3 = ord(substr($SourceText, $i++, 1));
|
||||||
$char4 = $this->unicode_table[(($c & 0x0F) << 12) | (($char2 & 0x3F) << 6) | (($char3 & 0x3F) << 0)];
|
$char4 = $this->unicode_table[(($c & 0x0F) << 12) | (($char2 & 0x3F) << 6) | (($char3 & 0x3F) << 0)];
|
||||||
if($this->config['TargetLang'] == 'GBK') {
|
if($this->config['TargetLang'] == 'GBK') {
|
||||||
$out .= $this->_hex2bin(dechex($char4 + 0x8080));
|
$out .= $this->_hex2bin(dechex($char4 + 0x8080));
|
||||||
} elseif($this->config['TargetLang'] == 'BIG5') {
|
} elseif($this->config['TargetLang'] == 'BIG5') {
|
||||||
$out .= $this->_hex2bin($char4);
|
$out .= $this->_hex2bin($char4);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !$this->convertbig5 ? $out : $this->GB2312toBIG5($out);
|
return !$this->convertbig5 ? $out : $this->GB2312toBIG5($out);
|
||||||
} else {
|
} else {
|
||||||
while($SourceText != '') {
|
while($SourceText != '') {
|
||||||
if(ord(substr($SourceText, 0, 1)) > 127) {
|
if(ord(substr($SourceText, 0, 1)) > 127) {
|
||||||
if($this->config['SourceLang'] == 'BIG5') {
|
if($this->config['SourceLang'] == 'BIG5') {
|
||||||
$utf8 = $this->CHSUtoUTF8(hexdec($this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2)))]));
|
$utf8 = $this->CHSUtoUTF8(hexdec($this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2)))]));
|
||||||
} elseif($this->config['SourceLang'] == 'GBK') {
|
} elseif($this->config['SourceLang'] == 'GBK') {
|
||||||
$utf8=$this->CHSUtoUTF8(hexdec($this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2))) - 0x8080]));
|
$utf8=$this->CHSUtoUTF8(hexdec($this->unicode_table[hexdec(bin2hex(substr($SourceText, 0, 2))) - 0x8080]));
|
||||||
}
|
}
|
||||||
for($i = 0; $i < strlen($utf8); $i += 3) {
|
for($i = 0; $i < strlen($utf8); $i += 3) {
|
||||||
$ret .= chr(substr($utf8, $i, 3));
|
$ret .= chr(substr($utf8, $i, 3));
|
||||||
}
|
}
|
||||||
$SourceText = substr($SourceText, 2, strlen($SourceText));
|
$SourceText = substr($SourceText, 2, strlen($SourceText));
|
||||||
} else {
|
} else {
|
||||||
$ret .= substr($SourceText, 0, 1);
|
$ret .= substr($SourceText, 0, 1);
|
||||||
$SourceText = substr($SourceText, 1, strlen($SourceText));
|
$SourceText = substr($SourceText, 1, strlen($SourceText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$SourceText = '';
|
$SourceText = '';
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Utf8_Unicode($char) {
|
function Utf8_Unicode($char) {
|
||||||
switch(strlen($char)) {
|
switch(strlen($char)) {
|
||||||
case 1:
|
case 1:
|
||||||
return ord($char);
|
return ord($char);
|
||||||
case 2:
|
case 2:
|
||||||
$n = (ord($char[0]) & 0x3f) << 6;
|
$n = (ord($char[0]) & 0x3f) << 6;
|
||||||
$n += ord($char[1]) & 0x3f;
|
$n += ord($char[1]) & 0x3f;
|
||||||
return $n;
|
return $n;
|
||||||
case 3:
|
case 3:
|
||||||
$n = (ord($char[0]) & 0x1f) << 12;
|
$n = (ord($char[0]) & 0x1f) << 12;
|
||||||
$n += (ord($char[1]) & 0x3f) << 6;
|
$n += (ord($char[1]) & 0x3f) << 6;
|
||||||
$n += ord($char[2]) & 0x3f;
|
$n += ord($char[2]) & 0x3f;
|
||||||
return $n;
|
return $n;
|
||||||
case 4:
|
case 4:
|
||||||
$n = (ord($char[0]) & 0x0f) << 18;
|
$n = (ord($char[0]) & 0x0f) << 18;
|
||||||
$n += (ord($char[1]) & 0x3f) << 12;
|
$n += (ord($char[1]) & 0x3f) << 12;
|
||||||
$n += (ord($char[2]) & 0x3f) << 6;
|
$n += (ord($char[2]) & 0x3f) << 6;
|
||||||
$n += ord($char[3]) & 0x3f;
|
$n += ord($char[3]) & 0x3f;
|
||||||
return $n;
|
return $n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,262 +1,262 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* This file is part of the ImagePalette package.
|
* This file is part of the ImagePalette package.
|
||||||
*
|
*
|
||||||
* (c) Brian McDonald <brian@brianmcdonald.io>
|
* (c) Brian McDonald <brian@brianmcdonald.io>
|
||||||
* (c) gandalfx - https://github.com/gandalfx
|
* (c) gandalfx - https://github.com/gandalfx
|
||||||
*
|
*
|
||||||
* For the full copyright and license information, please view the LICENSE
|
* For the full copyright and license information, please view the LICENSE
|
||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Represents an argb color
|
* Represents an argb color
|
||||||
*
|
*
|
||||||
* @author Gandalfx
|
* @author Gandalfx
|
||||||
* @package BrianMcdo\ImagePalette
|
* @package BrianMcdo\ImagePalette
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Color {
|
class Color {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Red value
|
* Red value
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $r;
|
public $r;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Green value
|
* Green value
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $g;
|
public $g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blue value
|
* Blue value
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $b;
|
public $b;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alpha value
|
* Alpha value
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $a;
|
public $a;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct new Color
|
* Construct new Color
|
||||||
*
|
*
|
||||||
* @param int|array $color
|
* @param int|array $color
|
||||||
* @param bool $short
|
* @param bool $short
|
||||||
*/
|
*/
|
||||||
//颜色16进制转RGB
|
//颜色16进制转RGB
|
||||||
static function hex2rgb($color){
|
static function hex2rgb($color){
|
||||||
if ( $color[0] == '#' ) {
|
if ( $color[0] == '#' ) {
|
||||||
$color = substr( $color, 1 );
|
$color = substr( $color, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( strlen( $color ) == 6 ) {
|
if ( strlen( $color ) == 6 ) {
|
||||||
list( $r, $g, $b ) = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
list( $r, $g, $b ) = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
||||||
} elseif ( strlen( $color ) == 3 ) {
|
} elseif ( strlen( $color ) == 3 ) {
|
||||||
list( $r, $g, $b ) = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
list( $r, $g, $b ) = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$r = hexdec( $r );
|
$r = hexdec( $r );
|
||||||
$g = hexdec( $g );
|
$g = hexdec( $g );
|
||||||
$b = hexdec( $b );
|
$b = hexdec( $b );
|
||||||
$a = hexdec( $b );
|
$a = hexdec( $b );
|
||||||
return array( $r, $g, $b );
|
return array( $r, $g, $b );
|
||||||
}
|
}
|
||||||
public function __construct($color = 0x000000, $short = false)
|
public function __construct($color = 0x000000, $short = false)
|
||||||
{
|
{
|
||||||
if (is_numeric($color)) {
|
if (is_numeric($color)) {
|
||||||
|
|
||||||
if ($short) {
|
if ($short) {
|
||||||
$this->r = (($color >> 8) & 0xf) * 0x11;
|
$this->r = (($color >> 8) & 0xf) * 0x11;
|
||||||
$this->g = (($color >> 4) & 0xf) * 0x11;
|
$this->g = (($color >> 4) & 0xf) * 0x11;
|
||||||
$this->b = ($color & 0xf) * 0x11;
|
$this->b = ($color & 0xf) * 0x11;
|
||||||
$this->a = (($color >> 12) & 0xf) * 0x11;
|
$this->a = (($color >> 12) & 0xf) * 0x11;
|
||||||
} else {
|
} else {
|
||||||
$this->r = ($color >> 16) & 0xff;
|
$this->r = ($color >> 16) & 0xff;
|
||||||
$this->g = ($color >> 8) & 0xff;
|
$this->g = ($color >> 8) & 0xff;
|
||||||
$this->b = $color & 0xff;
|
$this->b = $color & 0xff;
|
||||||
$this->a = ($color >> 24) & 0xff;
|
$this->a = ($color >> 24) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (is_array($color)) {
|
} elseif (is_array($color)) {
|
||||||
|
|
||||||
list($this->r, $this->g, $this->b) = $color;
|
list($this->r, $this->g, $this->b) = $color;
|
||||||
|
|
||||||
if (count($color) > 3)
|
if (count($color) > 3)
|
||||||
$this->a = $color[3];
|
$this->a = $color[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some useful magic getters
|
* Some useful magic getters
|
||||||
*
|
*
|
||||||
* @param string $property
|
* @param string $property
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function __get($property)
|
public function __get($property)
|
||||||
{
|
{
|
||||||
$method = 'to' . ucfirst($property);
|
$method = 'to' . ucfirst($property);
|
||||||
if (method_exists($this, $method))
|
if (method_exists($this, $method))
|
||||||
return $this->$method();
|
return $this->$method();
|
||||||
|
|
||||||
switch ($property) {
|
switch ($property) {
|
||||||
case 'red': case 'getRed':
|
case 'red': case 'getRed':
|
||||||
return $this->r;
|
return $this->r;
|
||||||
case 'green': case 'getGreen':
|
case 'green': case 'getGreen':
|
||||||
return $this->g;
|
return $this->g;
|
||||||
case 'blue': case 'getBlue':
|
case 'blue': case 'getBlue':
|
||||||
return $this->b;
|
return $this->b;
|
||||||
case 'alpha': case 'getAlpha':
|
case 'alpha': case 'getAlpha':
|
||||||
return $this->a;
|
return $this->a;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception("Property $property does not exist");
|
throw new \Exception("Property $property does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic method, alias for toHexString
|
* Magic method, alias for toHexString
|
||||||
*
|
*
|
||||||
* @see toHexString()
|
* @see toHexString()
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return $this->toHexString();
|
return $this->toHexString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the difference between this color
|
* Returns the difference between this color
|
||||||
* and the provided color
|
* and the provided color
|
||||||
* using simple pythagoras *without* sqrt
|
* using simple pythagoras *without* sqrt
|
||||||
*
|
*
|
||||||
* @param int|Color
|
* @param int|Color
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getDiff($color)
|
public function getDiff($color)
|
||||||
{
|
{
|
||||||
if (!$color instanceof Color) {
|
if (!$color instanceof Color) {
|
||||||
$color = new Color($color);
|
$color = new Color($color);
|
||||||
}
|
}
|
||||||
return pow($this->r - $color->r, 2)
|
return pow($this->r - $color->r, 2)
|
||||||
+ pow($this->g - $color->g, 2)
|
+ pow($this->g - $color->g, 2)
|
||||||
+ pow($this->b - $color->b, 2);
|
+ pow($this->b - $color->b, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not this color has an alpha value > 0
|
* Whether or not this color has an alpha value > 0
|
||||||
*
|
*
|
||||||
* @see isTransparent for full transparency
|
* @see isTransparent for full transparency
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function hasAlpha()
|
public function hasAlpha()
|
||||||
{
|
{
|
||||||
return (boolean) $this->a;
|
return (boolean) $this->a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect Transparency using GD
|
* Detect Transparency using GD
|
||||||
* Returns true if the provided color has zero opacity
|
* Returns true if the provided color has zero opacity
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isTransparent()
|
public function isTransparent()
|
||||||
{
|
{
|
||||||
return $this->a === 127;
|
return $this->a === 127;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing int values for
|
* Returns an array containing int values for
|
||||||
* red, green, blue and alpha
|
* red, green, blue and alpha
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toArray()
|
public function toArray()
|
||||||
{
|
{
|
||||||
return array($this->r, $this->g, $this->b, $this->a);
|
return array($this->r, $this->g, $this->b, $this->a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing int values for
|
* Returns an array containing int values for
|
||||||
* red, green and blue
|
* red, green and blue
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toRgb()
|
public function toRgb()
|
||||||
{
|
{
|
||||||
return array($this->r, $this->g, $this->b);
|
return array($this->r, $this->g, $this->b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing int values for
|
* Returns an array containing int values for
|
||||||
* red, green and blue and a double for alpha
|
* red, green and blue and a double for alpha
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function toRgba()
|
public function toRgba()
|
||||||
{
|
{
|
||||||
return array($this->r, $this->g, $this->b, 1 - $this->a / 0x100);
|
return array($this->r, $this->g, $this->b, 1 - $this->a / 0x100);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an int representing the color
|
* Returns an int representing the color
|
||||||
* defined by the red, green and blue values
|
* defined by the red, green and blue values
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function toInt()
|
public function toInt()
|
||||||
{
|
{
|
||||||
return ($this->r << 16) | ($this->g << 8) | $this->b;
|
return ($this->r << 16) | ($this->g << 8) | $this->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render 6-digit hexadecimal string representation
|
* Render 6-digit hexadecimal string representation
|
||||||
* like '#abcdef'
|
* like '#abcdef'
|
||||||
*
|
*
|
||||||
* @param string $prefix defaults to '#'
|
* @param string $prefix defaults to '#'
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function toHexString($prefix = '#')
|
public function toHexString($prefix = '#')
|
||||||
{
|
{
|
||||||
return $prefix . str_pad(dechex($this->toInt()), 6, '0', STR_PAD_LEFT);
|
return $prefix . str_pad(dechex($this->toInt()), 6, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render 3-integer decimal string representation
|
* Render 3-integer decimal string representation
|
||||||
* like 'rgb(123,0,20)'
|
* like 'rgb(123,0,20)'
|
||||||
*
|
*
|
||||||
* @param string $prefix defaults to 'rgb'
|
* @param string $prefix defaults to 'rgb'
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function toRgbString($prefix = 'rgb')
|
public function toRgbString($prefix = 'rgb')
|
||||||
{
|
{
|
||||||
return $prefix . '('
|
return $prefix . '('
|
||||||
. $this->r . ','
|
. $this->r . ','
|
||||||
. $this->g . ','
|
. $this->g . ','
|
||||||
. $this->b . ')';
|
. $this->b . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render 3-integer decimal string representation
|
* Render 3-integer decimal string representation
|
||||||
* like 'rgba(123,0,20,0.5)'
|
* like 'rgba(123,0,20,0.5)'
|
||||||
*
|
*
|
||||||
* @param string $prefix defaults to 'argb'
|
* @param string $prefix defaults to 'argb'
|
||||||
* @param int $alphaPrecision max alpha digits, default 2
|
* @param int $alphaPrecision max alpha digits, default 2
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function toRgbaString($prefix = 'rgba', $alphaPrecision = 2)
|
public function toRgbaString($prefix = 'rgba', $alphaPrecision = 2)
|
||||||
{
|
{
|
||||||
return $prefix . '('
|
return $prefix . '('
|
||||||
. $this->r . ','
|
. $this->r . ','
|
||||||
. $this->g . ','
|
. $this->g . ','
|
||||||
. $this->b . ','
|
. $this->b . ','
|
||||||
. round(1 - $this->a / 0x100, $alphaPrecision) . ')';
|
. round(1 - $this->a / 0x100, $alphaPrecision) . ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class DbException extends Exception{
|
class DbException extends Exception{
|
||||||
|
|
||||||
public $sql;
|
public $sql;
|
||||||
|
|
||||||
public function __construct($message, $code = 0, $sql = '') {
|
public function __construct($message, $code = 0, $sql = '') {
|
||||||
$this->sql = $sql;
|
$this->sql = $sql;
|
||||||
parent::__construct($message, $code);
|
parent::__construct($message, $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSql() {
|
public function getSql() {
|
||||||
return $this->sql;
|
return $this->sql;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,198 +1,198 @@
|
|||||||
<?php
|
<?php
|
||||||
class Des
|
class Des
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 加密方法
|
* 加密方法
|
||||||
*
|
*
|
||||||
* @param string $str 需要加密的内容
|
* @param string $str 需要加密的内容
|
||||||
* @param string $key 密钥
|
* @param string $key 密钥
|
||||||
* @param bool $toBase64 是否base64
|
* @param bool $toBase64 是否base64
|
||||||
* return string
|
* return string
|
||||||
*/
|
*/
|
||||||
public function encrypt($str, $key, $toBase64=true)
|
public function encrypt($str, $key, $toBase64=true)
|
||||||
{
|
{
|
||||||
if ($str == "") {
|
if ($str == "") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if ($toBase64) {
|
if ($toBase64) {
|
||||||
return base64_encode(self::_des($key,$str,1));
|
return base64_encode(self::_des($key,$str,1));
|
||||||
}
|
}
|
||||||
return self::_des($key,$str,1);
|
return self::_des($key,$str,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解密方法
|
* 解密方法
|
||||||
*
|
*
|
||||||
* @param string $str 需要加密的内容
|
* @param string $str 需要加密的内容
|
||||||
* @param string $key 密钥
|
* @param string $key 密钥
|
||||||
* @param bool $toBase64 是否base64
|
* @param bool $toBase64 是否base64
|
||||||
* return string
|
* return string
|
||||||
*/
|
*/
|
||||||
public function decrypt($str, $key, $toBase64=true)
|
public function decrypt($str, $key, $toBase64=true)
|
||||||
{
|
{
|
||||||
if ($str == "") {
|
if ($str == "") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if ($toBase64) {
|
if ($toBase64) {
|
||||||
return self::_des($key,base64_decode($str),0);
|
return self::_des($key,base64_decode($str),0);
|
||||||
}
|
}
|
||||||
return self::_des($key,$str,0);
|
return self::_des($key,$str,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _des($key, $message, $encrypt, $mode=0, $iv=null) {
|
private function _des($key, $message, $encrypt, $mode=0, $iv=null) {
|
||||||
$spfunction1 = array (0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004);
|
$spfunction1 = array (0x1010400,0,0x10000,0x1010404,0x1010004,0x10404,0x4,0x10000,0x400,0x1010400,0x1010404,0x400,0x1000404,0x1010004,0x1000000,0x4,0x404,0x1000400,0x1000400,0x10400,0x10400,0x1010000,0x1010000,0x1000404,0x10004,0x1000004,0x1000004,0x10004,0,0x404,0x10404,0x1000000,0x10000,0x1010404,0x4,0x1010000,0x1010400,0x1000000,0x1000000,0x400,0x1010004,0x10000,0x10400,0x1000004,0x400,0x4,0x1000404,0x10404,0x1010404,0x10004,0x1010000,0x1000404,0x1000004,0x404,0x10404,0x1010400,0x404,0x1000400,0x1000400,0,0x10004,0x10400,0,0x1010004);
|
||||||
$spfunction2 = array (-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000);
|
$spfunction2 = array (-0x7fef7fe0,-0x7fff8000,0x8000,0x108020,0x100000,0x20,-0x7fefffe0,-0x7fff7fe0,-0x7fffffe0,-0x7fef7fe0,-0x7fef8000,-0x80000000,-0x7fff8000,0x100000,0x20,-0x7fefffe0,0x108000,0x100020,-0x7fff7fe0,0,-0x80000000,0x8000,0x108020,-0x7ff00000,0x100020,-0x7fffffe0,0,0x108000,0x8020,-0x7fef8000,-0x7ff00000,0x8020,0,0x108020,-0x7fefffe0,0x100000,-0x7fff7fe0,-0x7ff00000,-0x7fef8000,0x8000,-0x7ff00000,-0x7fff8000,0x20,-0x7fef7fe0,0x108020,0x20,0x8000,-0x80000000,0x8020,-0x7fef8000,0x100000,-0x7fffffe0,0x100020,-0x7fff7fe0,-0x7fffffe0,0x100020,0x108000,0,-0x7fff8000,0x8020,-0x80000000,-0x7fefffe0,-0x7fef7fe0,0x108000);
|
||||||
$spfunction3 = array (0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200);
|
$spfunction3 = array (0x208,0x8020200,0,0x8020008,0x8000200,0,0x20208,0x8000200,0x20008,0x8000008,0x8000008,0x20000,0x8020208,0x20008,0x8020000,0x208,0x8000000,0x8,0x8020200,0x200,0x20200,0x8020000,0x8020008,0x20208,0x8000208,0x20200,0x20000,0x8000208,0x8,0x8020208,0x200,0x8000000,0x8020200,0x8000000,0x20008,0x208,0x20000,0x8020200,0x8000200,0,0x200,0x20008,0x8020208,0x8000200,0x8000008,0x200,0,0x8020008,0x8000208,0x20000,0x8000000,0x8020208,0x8,0x20208,0x20200,0x8000008,0x8020000,0x8000208,0x208,0x8020000,0x20208,0x8,0x8020008,0x20200);
|
||||||
$spfunction4 = array (0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080);
|
$spfunction4 = array (0x802001,0x2081,0x2081,0x80,0x802080,0x800081,0x800001,0x2001,0,0x802000,0x802000,0x802081,0x81,0,0x800080,0x800001,0x1,0x2000,0x800000,0x802001,0x80,0x800000,0x2001,0x2080,0x800081,0x1,0x2080,0x800080,0x2000,0x802080,0x802081,0x81,0x800080,0x800001,0x802000,0x802081,0x81,0,0,0x802000,0x2080,0x800080,0x800081,0x1,0x802001,0x2081,0x2081,0x80,0x802081,0x81,0x1,0x2000,0x800001,0x2001,0x802080,0x800081,0x2001,0x2080,0x800000,0x802001,0x80,0x800000,0x2000,0x802080);
|
||||||
$spfunction5 = array (0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100);
|
$spfunction5 = array (0x100,0x2080100,0x2080000,0x42000100,0x80000,0x100,0x40000000,0x2080000,0x40080100,0x80000,0x2000100,0x40080100,0x42000100,0x42080000,0x80100,0x40000000,0x2000000,0x40080000,0x40080000,0,0x40000100,0x42080100,0x42080100,0x2000100,0x42080000,0x40000100,0,0x42000000,0x2080100,0x2000000,0x42000000,0x80100,0x80000,0x42000100,0x100,0x2000000,0x40000000,0x2080000,0x42000100,0x40080100,0x2000100,0x40000000,0x42080000,0x2080100,0x40080100,0x100,0x2000000,0x42080000,0x42080100,0x80100,0x42000000,0x42080100,0x2080000,0,0x40080000,0x42000000,0x80100,0x2000100,0x40000100,0x80000,0,0x40080000,0x2080100,0x40000100);
|
||||||
$spfunction6 = array (0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010);
|
$spfunction6 = array (0x20000010,0x20400000,0x4000,0x20404010,0x20400000,0x10,0x20404010,0x400000,0x20004000,0x404010,0x400000,0x20000010,0x400010,0x20004000,0x20000000,0x4010,0,0x400010,0x20004010,0x4000,0x404000,0x20004010,0x10,0x20400010,0x20400010,0,0x404010,0x20404000,0x4010,0x404000,0x20404000,0x20000000,0x20004000,0x10,0x20400010,0x404000,0x20404010,0x400000,0x4010,0x20000010,0x400000,0x20004000,0x20000000,0x4010,0x20000010,0x20404010,0x404000,0x20400000,0x404010,0x20404000,0,0x20400010,0x10,0x4000,0x20400000,0x404010,0x4000,0x400010,0x20004010,0,0x20404000,0x20000000,0x400010,0x20004010);
|
||||||
$spfunction7 = array (0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002);
|
$spfunction7 = array (0x200000,0x4200002,0x4000802,0,0x800,0x4000802,0x200802,0x4200800,0x4200802,0x200000,0,0x4000002,0x2,0x4000000,0x4200002,0x802,0x4000800,0x200802,0x200002,0x4000800,0x4000002,0x4200000,0x4200800,0x200002,0x4200000,0x800,0x802,0x4200802,0x200800,0x2,0x4000000,0x200800,0x4000000,0x200800,0x200000,0x4000802,0x4000802,0x4200002,0x4200002,0x2,0x200002,0x4000000,0x4000800,0x200000,0x4200800,0x802,0x200802,0x4200800,0x802,0x4000002,0x4200802,0x4200000,0x200800,0,0x2,0x4200802,0,0x200802,0x4200000,0x800,0x4000002,0x4000800,0x800,0x200002);
|
||||||
$spfunction8 = array (0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000);
|
$spfunction8 = array (0x10001040,0x1000,0x40000,0x10041040,0x10000000,0x10001040,0x40,0x10000000,0x40040,0x10040000,0x10041040,0x41000,0x10041000,0x41040,0x1000,0x40,0x10040000,0x10000040,0x10001000,0x1040,0x41000,0x40040,0x10040040,0x10041000,0x1040,0,0,0x10040040,0x10000040,0x10001000,0x41040,0x40000,0x41040,0x40000,0x10041000,0x1000,0x40,0x10040040,0x1000,0x41040,0x10001000,0x40,0x10000040,0x10040000,0x10040040,0x10000000,0x40000,0x10001040,0,0x10041040,0x40040,0x10000040,0x10040000,0x10001000,0x10001040,0,0x10041040,0x41000,0x41000,0x1040,0x1040,0x40040,0x10000000,0x10041000);
|
||||||
$masks = array (4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0);
|
$masks = array (4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0);
|
||||||
|
|
||||||
$keys = self::_createKeys ($key);
|
$keys = self::_createKeys ($key);
|
||||||
$m=0;
|
$m=0;
|
||||||
$len = strlen($message);
|
$len = strlen($message);
|
||||||
$chunk = 0;
|
$chunk = 0;
|
||||||
|
|
||||||
$iterations = ((count($keys) == 32) ? 3 : 9);
|
$iterations = ((count($keys) == 32) ? 3 : 9);
|
||||||
if ($iterations == 3) {$looping = (($encrypt) ? array (0, 32, 2) : array (30, -2, -2));}
|
if ($iterations == 3) {$looping = (($encrypt) ? array (0, 32, 2) : array (30, -2, -2));}
|
||||||
else {$looping = (($encrypt) ? array (0, 32, 2, 62, 30, -2, 64, 96, 2) : array (94, 62, -2, 32, 64, 2, 30, -2, -2));}
|
else {$looping = (($encrypt) ? array (0, 32, 2, 62, 30, -2, 64, 96, 2) : array (94, 62, -2, 32, 64, 2, 30, -2, -2));}
|
||||||
|
|
||||||
$message .= (chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0));
|
$message .= (chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0) . chr(0));
|
||||||
|
|
||||||
$result = "";
|
$result = "";
|
||||||
$tempresult = "";
|
$tempresult = "";
|
||||||
|
|
||||||
if ($mode == 1) {
|
if ($mode == 1) {
|
||||||
$cbcleft = (ord($iv{$m++}) << 24) | (ord($iv{$m++}) << 16) | (ord($iv{$m++}) << 8) | ord($iv{$m++});
|
$cbcleft = (ord($iv{$m++}) << 24) | (ord($iv{$m++}) << 16) | (ord($iv{$m++}) << 8) | ord($iv{$m++});
|
||||||
$cbcright = (ord($iv{$m++}) << 24) | (ord($iv{$m++}) << 16) | (ord($iv{$m++}) << 8) | ord($iv{$m++});
|
$cbcright = (ord($iv{$m++}) << 24) | (ord($iv{$m++}) << 16) | (ord($iv{$m++}) << 8) | ord($iv{$m++});
|
||||||
$m=0;
|
$m=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ($m < $len) {
|
while ($m < $len) {
|
||||||
$left = (ord($message{$m++}) << 24) | (ord($message{$m++}) << 16) | (ord($message{$m++}) << 8) | ord($message{$m++});
|
$left = (ord($message{$m++}) << 24) | (ord($message{$m++}) << 16) | (ord($message{$m++}) << 8) | ord($message{$m++});
|
||||||
$right = (ord($message{$m++}) << 24) | (ord($message{$m++}) << 16) | (ord($message{$m++}) << 8) | ord($message{$m++});
|
$right = (ord($message{$m++}) << 24) | (ord($message{$m++}) << 16) | (ord($message{$m++}) << 8) | ord($message{$m++});
|
||||||
|
|
||||||
if ($mode == 1) {if ($encrypt) {$left ^= $cbcleft; $right ^= $cbcright;} else {$cbcleft2 = $cbcleft; $cbcright2 = $cbcright; $cbcleft = $left; $cbcright = $right;}}
|
if ($mode == 1) {if ($encrypt) {$left ^= $cbcleft; $right ^= $cbcright;} else {$cbcleft2 = $cbcleft; $cbcright2 = $cbcright; $cbcleft = $left; $cbcright = $right;}}
|
||||||
|
|
||||||
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
||||||
$temp = (($left >> 16 & $masks[16]) ^ $right) & 0x0000ffff; $right ^= $temp; $left ^= ($temp << 16);
|
$temp = (($left >> 16 & $masks[16]) ^ $right) & 0x0000ffff; $right ^= $temp; $left ^= ($temp << 16);
|
||||||
$temp = (($right >> 2 & $masks[2]) ^ $left) & 0x33333333; $left ^= $temp; $right ^= ($temp << 2);
|
$temp = (($right >> 2 & $masks[2]) ^ $left) & 0x33333333; $left ^= $temp; $right ^= ($temp << 2);
|
||||||
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
||||||
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
|
|
||||||
$left = (($left << 1) | ($left >> 31 & $masks[31]));
|
$left = (($left << 1) | ($left >> 31 & $masks[31]));
|
||||||
$right = (($right << 1) | ($right >> 31 & $masks[31]));
|
$right = (($right << 1) | ($right >> 31 & $masks[31]));
|
||||||
|
|
||||||
for ($j=0; $j<$iterations; $j+=3) {
|
for ($j=0; $j<$iterations; $j+=3) {
|
||||||
$endloop = $looping[$j+1];
|
$endloop = $looping[$j+1];
|
||||||
$loopinc = $looping[$j+2];
|
$loopinc = $looping[$j+2];
|
||||||
for ($i=$looping[$j]; $i!=$endloop; $i+=$loopinc) {
|
for ($i=$looping[$j]; $i!=$endloop; $i+=$loopinc) {
|
||||||
$right1 = $right ^ $keys[$i];
|
$right1 = $right ^ $keys[$i];
|
||||||
$right2 = (($right >> 4 & $masks[4]) | ($right << 28)) ^ $keys[$i+1];
|
$right2 = (($right >> 4 & $masks[4]) | ($right << 28)) ^ $keys[$i+1];
|
||||||
$temp = $left;
|
$temp = $left;
|
||||||
$left = $right;
|
$left = $right;
|
||||||
$right = $temp ^ ($spfunction2[($right1 >> 24 & $masks[24]) & 0x3f] | $spfunction4[($right1 >> 16 & $masks[16]) & 0x3f]
|
$right = $temp ^ ($spfunction2[($right1 >> 24 & $masks[24]) & 0x3f] | $spfunction4[($right1 >> 16 & $masks[16]) & 0x3f]
|
||||||
| $spfunction6[($right1 >> 8 & $masks[8]) & 0x3f] | $spfunction8[$right1 & 0x3f]
|
| $spfunction6[($right1 >> 8 & $masks[8]) & 0x3f] | $spfunction8[$right1 & 0x3f]
|
||||||
| $spfunction1[($right2 >> 24 & $masks[24]) & 0x3f] | $spfunction3[($right2 >> 16 & $masks[16]) & 0x3f]
|
| $spfunction1[($right2 >> 24 & $masks[24]) & 0x3f] | $spfunction3[($right2 >> 16 & $masks[16]) & 0x3f]
|
||||||
| $spfunction5[($right2 >> 8 & $masks[8]) & 0x3f] | $spfunction7[$right2 & 0x3f]);
|
| $spfunction5[($right2 >> 8 & $masks[8]) & 0x3f] | $spfunction7[$right2 & 0x3f]);
|
||||||
}
|
}
|
||||||
$temp = $left; $left = $right; $right = $temp;
|
$temp = $left; $left = $right; $right = $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
$left = (($left >> 1 & $masks[1]) | ($left << 31));
|
$left = (($left >> 1 & $masks[1]) | ($left << 31));
|
||||||
$right = (($right >> 1 & $masks[1]) | ($right << 31));
|
$right = (($right >> 1 & $masks[1]) | ($right << 31));
|
||||||
|
|
||||||
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
||||||
$temp = (($right >> 2 & $masks[2]) ^ $left) & 0x33333333; $left ^= $temp; $right ^= ($temp << 2);
|
$temp = (($right >> 2 & $masks[2]) ^ $left) & 0x33333333; $left ^= $temp; $right ^= ($temp << 2);
|
||||||
$temp = (($left >> 16 & $masks[16]) ^ $right) & 0x0000ffff; $right ^= $temp; $left ^= ($temp << 16);
|
$temp = (($left >> 16 & $masks[16]) ^ $right) & 0x0000ffff; $right ^= $temp; $left ^= ($temp << 16);
|
||||||
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
||||||
|
|
||||||
if ($mode == 1) {if ($encrypt) {$cbcleft = $left; $cbcright = $right;} else {$left ^= $cbcleft2; $right ^= $cbcright2;}}
|
if ($mode == 1) {if ($encrypt) {$cbcleft = $left; $cbcright = $right;} else {$left ^= $cbcleft2; $right ^= $cbcright2;}}
|
||||||
$tempresult .= (chr($left>>24 & $masks[24]) . chr(($left>>16 & $masks[16]) & 0xff) . chr(($left>>8 & $masks[8]) & 0xff) . chr($left & 0xff) . chr($right>>24 & $masks[24]) . chr(($right>>16 & $masks[16]) & 0xff) . chr(($right>>8 & $masks[8]) & 0xff) . chr($right & 0xff));
|
$tempresult .= (chr($left>>24 & $masks[24]) . chr(($left>>16 & $masks[16]) & 0xff) . chr(($left>>8 & $masks[8]) & 0xff) . chr($left & 0xff) . chr($right>>24 & $masks[24]) . chr(($right>>16 & $masks[16]) & 0xff) . chr(($right>>8 & $masks[8]) & 0xff) . chr($right & 0xff));
|
||||||
|
|
||||||
$chunk += 8;
|
$chunk += 8;
|
||||||
if ($chunk == 512) {$result .= $tempresult; $tempresult = ""; $chunk = 0;}
|
if ($chunk == 512) {$result .= $tempresult; $tempresult = ""; $chunk = 0;}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($result . $tempresult);
|
return ($result . $tempresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _createKeys ($key) {
|
private function _createKeys ($key) {
|
||||||
$pc2bytes0 = array (0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204);
|
$pc2bytes0 = array (0,0x4,0x20000000,0x20000004,0x10000,0x10004,0x20010000,0x20010004,0x200,0x204,0x20000200,0x20000204,0x10200,0x10204,0x20010200,0x20010204);
|
||||||
$pc2bytes1 = array (0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101);
|
$pc2bytes1 = array (0,0x1,0x100000,0x100001,0x4000000,0x4000001,0x4100000,0x4100001,0x100,0x101,0x100100,0x100101,0x4000100,0x4000101,0x4100100,0x4100101);
|
||||||
$pc2bytes2 = array (0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808);
|
$pc2bytes2 = array (0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808,0,0x8,0x800,0x808,0x1000000,0x1000008,0x1000800,0x1000808);
|
||||||
$pc2bytes3 = array (0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000);
|
$pc2bytes3 = array (0,0x200000,0x8000000,0x8200000,0x2000,0x202000,0x8002000,0x8202000,0x20000,0x220000,0x8020000,0x8220000,0x22000,0x222000,0x8022000,0x8222000);
|
||||||
$pc2bytes4 = array (0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010);
|
$pc2bytes4 = array (0,0x40000,0x10,0x40010,0,0x40000,0x10,0x40010,0x1000,0x41000,0x1010,0x41010,0x1000,0x41000,0x1010,0x41010);
|
||||||
$pc2bytes5 = array (0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420);
|
$pc2bytes5 = array (0,0x400,0x20,0x420,0,0x400,0x20,0x420,0x2000000,0x2000400,0x2000020,0x2000420,0x2000000,0x2000400,0x2000020,0x2000420);
|
||||||
$pc2bytes6 = array (0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002);
|
$pc2bytes6 = array (0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002,0,0x10000000,0x80000,0x10080000,0x2,0x10000002,0x80002,0x10080002);
|
||||||
$pc2bytes7 = array (0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800);
|
$pc2bytes7 = array (0,0x10000,0x800,0x10800,0x20000000,0x20010000,0x20000800,0x20010800,0x20000,0x30000,0x20800,0x30800,0x20020000,0x20030000,0x20020800,0x20030800);
|
||||||
$pc2bytes8 = array (0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002);
|
$pc2bytes8 = array (0,0x40000,0,0x40000,0x2,0x40002,0x2,0x40002,0x2000000,0x2040000,0x2000000,0x2040000,0x2000002,0x2040002,0x2000002,0x2040002);
|
||||||
$pc2bytes9 = array (0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408);
|
$pc2bytes9 = array (0,0x10000000,0x8,0x10000008,0,0x10000000,0x8,0x10000008,0x400,0x10000400,0x408,0x10000408,0x400,0x10000400,0x408,0x10000408);
|
||||||
$pc2bytes10 = array (0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020);
|
$pc2bytes10 = array (0,0x20,0,0x20,0x100000,0x100020,0x100000,0x100020,0x2000,0x2020,0x2000,0x2020,0x102000,0x102020,0x102000,0x102020);
|
||||||
$pc2bytes11 = array (0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200);
|
$pc2bytes11 = array (0,0x1000000,0x200,0x1000200,0x200000,0x1200000,0x200200,0x1200200,0x4000000,0x5000000,0x4000200,0x5000200,0x4200000,0x5200000,0x4200200,0x5200200);
|
||||||
$pc2bytes12 = array (0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010);
|
$pc2bytes12 = array (0,0x1000,0x8000000,0x8001000,0x80000,0x81000,0x8080000,0x8081000,0x10,0x1010,0x8000010,0x8001010,0x80010,0x81010,0x8080010,0x8081010);
|
||||||
$pc2bytes13 = array (0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105);
|
$pc2bytes13 = array (0,0x4,0x100,0x104,0,0x4,0x100,0x104,0x1,0x5,0x101,0x105,0x1,0x5,0x101,0x105);
|
||||||
$masks = array (4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0);
|
$masks = array (4294967295,2147483647,1073741823,536870911,268435455,134217727,67108863,33554431,16777215,8388607,4194303,2097151,1048575,524287,262143,131071,65535,32767,16383,8191,4095,2047,1023,511,255,127,63,31,15,7,3,1,0);
|
||||||
|
|
||||||
$iterations = ((strlen($key) >= 24) ? 3 : 1);
|
$iterations = ((strlen($key) >= 24) ? 3 : 1);
|
||||||
$keys = array ();
|
$keys = array ();
|
||||||
$shifts = array (0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0);
|
$shifts = array (0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0);
|
||||||
$m=0;
|
$m=0;
|
||||||
$n=0;
|
$n=0;
|
||||||
|
|
||||||
for ($j=0; $j<$iterations; $j++) {
|
for ($j=0; $j<$iterations; $j++) {
|
||||||
$left = (ord($key{$m++}) << 24) | (ord($key{$m++}) << 16) | (ord($key{$m++}) << 8) | ord($key{$m++});
|
$left = (ord($key{$m++}) << 24) | (ord($key{$m++}) << 16) | (ord($key{$m++}) << 8) | ord($key{$m++});
|
||||||
$right = (ord($key{$m++}) << 24) | (ord($key{$m++}) << 16) | (ord($key{$m++}) << 8) | ord($key{$m++});
|
$right = (ord($key{$m++}) << 24) | (ord($key{$m++}) << 16) | (ord($key{$m++}) << 8) | ord($key{$m++});
|
||||||
|
|
||||||
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
$temp = (($left >> 4 & $masks[4]) ^ $right) & 0x0f0f0f0f; $right ^= $temp; $left ^= ($temp << 4);
|
||||||
$temp = (($right >> 16 & $masks[16]) ^ $left) & 0x0000ffff; $left ^= $temp; $right ^= ($temp << -16);
|
$temp = (($right >> 16 & $masks[16]) ^ $left) & 0x0000ffff; $left ^= $temp; $right ^= ($temp << -16);
|
||||||
$temp = (($left >> 2 & $masks[2]) ^ $right) & 0x33333333; $right ^= $temp; $left ^= ($temp << 2);
|
$temp = (($left >> 2 & $masks[2]) ^ $right) & 0x33333333; $right ^= $temp; $left ^= ($temp << 2);
|
||||||
$temp = (($right >> 16 & $masks[16]) ^ $left) & 0x0000ffff; $left ^= $temp; $right ^= ($temp << -16);
|
$temp = (($right >> 16 & $masks[16]) ^ $left) & 0x0000ffff; $left ^= $temp; $right ^= ($temp << -16);
|
||||||
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
$temp = (($right >> 8 & $masks[8]) ^ $left) & 0x00ff00ff; $left ^= $temp; $right ^= ($temp << 8);
|
||||||
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
$temp = (($left >> 1 & $masks[1]) ^ $right) & 0x55555555; $right ^= $temp; $left ^= ($temp << 1);
|
||||||
|
|
||||||
$temp = ($left << 8) | (($right >> 20 & $masks[20]) & 0x000000f0);
|
$temp = ($left << 8) | (($right >> 20 & $masks[20]) & 0x000000f0);
|
||||||
$left = ($right << 24) | (($right << 8) & 0xff0000) | (($right >> 8 & $masks[8]) & 0xff00) | (($right >> 24 & $masks[24]) & 0xf0);
|
$left = ($right << 24) | (($right << 8) & 0xff0000) | (($right >> 8 & $masks[8]) & 0xff00) | (($right >> 24 & $masks[24]) & 0xf0);
|
||||||
$right = $temp;
|
$right = $temp;
|
||||||
|
|
||||||
for ($i=0; $i < count($shifts); $i++) {
|
for ($i=0; $i < count($shifts); $i++) {
|
||||||
if ($shifts[$i] > 0) {
|
if ($shifts[$i] > 0) {
|
||||||
$left = (($left << 2) | ($left >> 26 & $masks[26]));
|
$left = (($left << 2) | ($left >> 26 & $masks[26]));
|
||||||
$right = (($right << 2) | ($right >> 26 & $masks[26]));
|
$right = (($right << 2) | ($right >> 26 & $masks[26]));
|
||||||
} else {
|
} else {
|
||||||
$left = (($left << 1) | ($left >> 27 & $masks[27]));
|
$left = (($left << 1) | ($left >> 27 & $masks[27]));
|
||||||
$right = (($right << 1) | ($right >> 27 & $masks[27]));
|
$right = (($right << 1) | ($right >> 27 & $masks[27]));
|
||||||
}
|
}
|
||||||
$left = $left & -0xf;
|
$left = $left & -0xf;
|
||||||
$right = $right & -0xf;
|
$right = $right & -0xf;
|
||||||
|
|
||||||
$lefttemp = $pc2bytes0[$left >> 28 & $masks[28]] | $pc2bytes1[($left >> 24 & $masks[24]) & 0xf]
|
$lefttemp = $pc2bytes0[$left >> 28 & $masks[28]] | $pc2bytes1[($left >> 24 & $masks[24]) & 0xf]
|
||||||
| $pc2bytes2[($left >> 20 & $masks[20]) & 0xf] | $pc2bytes3[($left >> 16 & $masks[16]) & 0xf]
|
| $pc2bytes2[($left >> 20 & $masks[20]) & 0xf] | $pc2bytes3[($left >> 16 & $masks[16]) & 0xf]
|
||||||
| $pc2bytes4[($left >> 12 & $masks[12]) & 0xf] | $pc2bytes5[($left >> 8 & $masks[8]) & 0xf]
|
| $pc2bytes4[($left >> 12 & $masks[12]) & 0xf] | $pc2bytes5[($left >> 8 & $masks[8]) & 0xf]
|
||||||
| $pc2bytes6[($left >> 4 & $masks[4]) & 0xf];
|
| $pc2bytes6[($left >> 4 & $masks[4]) & 0xf];
|
||||||
$righttemp = $pc2bytes7[$right >> 28 & $masks[28]] | $pc2bytes8[($right >> 24 & $masks[24]) & 0xf]
|
$righttemp = $pc2bytes7[$right >> 28 & $masks[28]] | $pc2bytes8[($right >> 24 & $masks[24]) & 0xf]
|
||||||
| $pc2bytes9[($right >> 20 & $masks[20]) & 0xf] | $pc2bytes10[($right >> 16 & $masks[16]) & 0xf]
|
| $pc2bytes9[($right >> 20 & $masks[20]) & 0xf] | $pc2bytes10[($right >> 16 & $masks[16]) & 0xf]
|
||||||
| $pc2bytes11[($right >> 12 & $masks[12]) & 0xf] | $pc2bytes12[($right >> 8 & $masks[8]) & 0xf]
|
| $pc2bytes11[($right >> 12 & $masks[12]) & 0xf] | $pc2bytes12[($right >> 8 & $masks[8]) & 0xf]
|
||||||
| $pc2bytes13[($right >> 4 & $masks[4]) & 0xf];
|
| $pc2bytes13[($right >> 4 & $masks[4]) & 0xf];
|
||||||
$temp = (($righttemp >> 16 & $masks[16]) ^ $lefttemp) & 0x0000ffff;
|
$temp = (($righttemp >> 16 & $masks[16]) ^ $lefttemp) & 0x0000ffff;
|
||||||
$keys[$n++] = $lefttemp ^ $temp; $keys[$n++] = $righttemp ^ ($temp << 16);
|
$keys[$n++] = $lefttemp ^ $temp; $keys[$n++] = $righttemp ^ ($temp << 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $keys;
|
return $keys;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用方式
|
// 使用方式
|
||||||
//$Des = new Des();
|
//$Des = new Des();
|
||||||
/*$string = 'hello leven';
|
/*$string = 'hello leven';
|
||||||
$key = '123456';
|
$key = '123456';
|
||||||
$encode = $Des->encrypt($string,$key,true);
|
$encode = $Des->encrypt($string,$key,true);
|
||||||
$decode = $Des->decrypt($encode,$key,true);
|
$decode = $Des->decrypt($encode,$key,true);
|
||||||
echo $encode;
|
echo $encode;
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
echo $decode;*/
|
echo $decode;*/
|
||||||
?>
|
?>
|
||||||
@@ -1,321 +1,321 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class GifMerge {
|
class GifMerge {
|
||||||
var $ver = '1.1';
|
var $ver = '1.1';
|
||||||
var $dly = 50;
|
var $dly = 50;
|
||||||
var $mod = 'C_FILE';
|
var $mod = 'C_FILE';
|
||||||
var $first = true;
|
var $first = true;
|
||||||
var $use_loop = false;
|
var $use_loop = false;
|
||||||
var $transparent = false;
|
var $transparent = false;
|
||||||
var $use_global_in = false;
|
var $use_global_in = false;
|
||||||
var $x = 0;
|
var $x = 0;
|
||||||
var $y = 0;
|
var $y = 0;
|
||||||
var $ch = 0;
|
var $ch = 0;
|
||||||
var $fin = 0;
|
var $fin = 0;
|
||||||
var $fout = '';
|
var $fout = '';
|
||||||
var $loop = 0;
|
var $loop = 0;
|
||||||
var $delay = 0;
|
var $delay = 0;
|
||||||
var $width = 0;
|
var $width = 0;
|
||||||
var $height = 0;
|
var $height = 0;
|
||||||
var $trans1 = 255;
|
var $trans1 = 255;
|
||||||
var $trans2 = 255;
|
var $trans2 = 255;
|
||||||
var $trans3 = 255;
|
var $trans3 = 255;
|
||||||
var $disposal = 2;
|
var $disposal = 2;
|
||||||
var $out_color_table_size = 0;
|
var $out_color_table_size = 0;
|
||||||
var $local_color_table_flag = 0;
|
var $local_color_table_flag = 0;
|
||||||
var $global_color_table_size = 0;
|
var $global_color_table_size = 0;
|
||||||
var $out_color_table_sizecode = 0;
|
var $out_color_table_sizecode = 0;
|
||||||
var $global_color_table_sizecode= 0;
|
var $global_color_table_sizecode= 0;
|
||||||
var $gif = array(0x47, 0x49, 0x46);
|
var $gif = array(0x47, 0x49, 0x46);
|
||||||
var $buffer = array();
|
var $buffer = array();
|
||||||
var $local_in = array();
|
var $local_in = array();
|
||||||
var $global_in = array();
|
var $global_in = array();
|
||||||
var $global_out = array();
|
var $global_out = array();
|
||||||
var $logical_screen_descriptor = array();
|
var $logical_screen_descriptor = array();
|
||||||
|
|
||||||
function GifMerge($images, $t1, $t2, $t3, $loop, $dl, $xpos, $ypos, $model) {
|
function GifMerge($images, $t1, $t2, $t3, $loop, $dl, $xpos, $ypos, $model) {
|
||||||
if($model) {
|
if($model) {
|
||||||
$this->mod = $model;
|
$this->mod = $model;
|
||||||
}
|
}
|
||||||
if($loop > -1) {
|
if($loop > -1) {
|
||||||
$this->loop = floor($loop - 1);
|
$this->loop = floor($loop - 1);
|
||||||
$this->use_loop = true;
|
$this->use_loop = true;
|
||||||
}
|
}
|
||||||
if($t1 > -1 && $t2 > -1 && $t3 > -1) {
|
if($t1 > -1 && $t2 > -1 && $t3 > -1) {
|
||||||
$this->trans1 = $t1;
|
$this->trans1 = $t1;
|
||||||
$this->trans2 = $t2;
|
$this->trans2 = $t2;
|
||||||
$this->trans3 = $t3;
|
$this->trans3 = $t3;
|
||||||
$this->transparent = true;
|
$this->transparent = true;
|
||||||
}
|
}
|
||||||
for($i = 0; $i < count($images); $i++) {
|
for($i = 0; $i < count($images); $i++) {
|
||||||
$dl[$i] ? $this->delay = $dl[$i] : $this->delay = $this->dly;
|
$dl[$i] ? $this->delay = $dl[$i] : $this->delay = $this->dly;
|
||||||
$xpos[$i] ? $this->x = $xpos[$i] : $this->x = 0;
|
$xpos[$i] ? $this->x = $xpos[$i] : $this->x = 0;
|
||||||
$ypos[$i] ? $this->y = $ypos[$i] : $this->y = 0;
|
$ypos[$i] ? $this->y = $ypos[$i] : $this->y = 0;
|
||||||
$this->start_gifmerge_process($images[$i]);
|
$this->start_gifmerge_process($images[$i]);
|
||||||
}
|
}
|
||||||
$this->fout .= "\x3b";
|
$this->fout .= "\x3b";
|
||||||
}
|
}
|
||||||
|
|
||||||
function start_gifmerge_process($fp) {
|
function start_gifmerge_process($fp) {
|
||||||
if($this->mod == 'C_FILE') {
|
if($this->mod == 'C_FILE') {
|
||||||
if(!$this->fin = fopen($fp, 'rb')) {
|
if(!$this->fin = fopen($fp, 'rb')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} elseif($this->mod == 'C_MEMORY') {
|
} elseif($this->mod == 'C_MEMORY') {
|
||||||
$this->ch = 0;
|
$this->ch = 0;
|
||||||
$this->fin = $fp;
|
$this->fin = $fp;
|
||||||
}
|
}
|
||||||
$this->getbytes(6);
|
$this->getbytes(6);
|
||||||
if(!$this->arrcmp($this->buffer, $this->gif, 3)) {
|
if(!$this->arrcmp($this->buffer, $this->gif, 3)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->getbytes(7);
|
$this->getbytes(7);
|
||||||
if($this->first) $this->logical_screen_descriptor = $this->buffer;
|
if($this->first) $this->logical_screen_descriptor = $this->buffer;
|
||||||
$this->global_color_table_sizecode = $this->buffer[4] & 0x07;
|
$this->global_color_table_sizecode = $this->buffer[4] & 0x07;
|
||||||
$this->global_color_table_size = 2 << $this->global_color_table_sizecode;
|
$this->global_color_table_size = 2 << $this->global_color_table_sizecode;
|
||||||
if($this->buffer[4] & 0x80) {
|
if($this->buffer[4] & 0x80) {
|
||||||
$this->getbytes((3 * $this->global_color_table_size));
|
$this->getbytes((3 * $this->global_color_table_size));
|
||||||
for($i = 0; $i < ((3 * $this->global_color_table_size)); $i++) {
|
for($i = 0; $i < ((3 * $this->global_color_table_size)); $i++) {
|
||||||
$this->global_in[$i] = $this->buffer[$i];
|
$this->global_in[$i] = $this->buffer[$i];
|
||||||
}
|
}
|
||||||
if($this->out_color_table_size == 0) {
|
if($this->out_color_table_size == 0) {
|
||||||
$this->out_color_table_size = $this->global_color_table_size;
|
$this->out_color_table_size = $this->global_color_table_size;
|
||||||
$this->out_color_table_sizecode = $this->global_color_table_sizecode;
|
$this->out_color_table_sizecode = $this->global_color_table_sizecode;
|
||||||
$this->global_out = $this->global_in;
|
$this->global_out = $this->global_in;
|
||||||
}
|
}
|
||||||
if($this->global_color_table_size != $this->out_color_table_size || $this->arrcmp($this->global_out, $this->global_in, (3 * $this->global_color_table_size))) {
|
if($this->global_color_table_size != $this->out_color_table_size || $this->arrcmp($this->global_out, $this->global_in, (3 * $this->global_color_table_size))) {
|
||||||
$this->use_global_in = true;
|
$this->use_global_in = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for($loop = true; $loop;) {
|
for($loop = true; $loop;) {
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
switch($this->buffer[0]) {
|
switch($this->buffer[0]) {
|
||||||
case 0x21:
|
case 0x21:
|
||||||
$this->read_extension();
|
$this->read_extension();
|
||||||
break;
|
break;
|
||||||
case 0x2c:
|
case 0x2c:
|
||||||
$this->read_image_descriptor();
|
$this->read_image_descriptor();
|
||||||
break;
|
break;
|
||||||
case 0x3b:
|
case 0x3b:
|
||||||
$loop = false;
|
$loop = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$loop = false;
|
$loop = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->mod == 'C_FILE') {
|
if($this->mod == 'C_FILE') {
|
||||||
fclose($this->fin);
|
fclose($this->fin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_image_descriptor() {
|
function read_image_descriptor() {
|
||||||
$this->getbytes(9);
|
$this->getbytes(9);
|
||||||
$head = $this->buffer;
|
$head = $this->buffer;
|
||||||
$this->local_color_table_flag = ($this->buffer[8] & 0x80) ? true : false;
|
$this->local_color_table_flag = ($this->buffer[8] & 0x80) ? true : false;
|
||||||
if($this->local_color_table_flag) {
|
if($this->local_color_table_flag) {
|
||||||
$sizecode = $this->buffer[8] & 0x07;
|
$sizecode = $this->buffer[8] & 0x07;
|
||||||
$size = 2 << $sizecode;
|
$size = 2 << $sizecode;
|
||||||
$this->getbytes(3 * $size);
|
$this->getbytes(3 * $size);
|
||||||
for($i = 0; $i < (3 * $size); $i++) {
|
for($i = 0; $i < (3 * $size); $i++) {
|
||||||
$this->local_in[$i] = $this->buffer[$i];
|
$this->local_in[$i] = $this->buffer[$i];
|
||||||
}
|
}
|
||||||
if($this->out_color_table_size == 0) {
|
if($this->out_color_table_size == 0) {
|
||||||
$this->out_color_table_size = $size;
|
$this->out_color_table_size = $size;
|
||||||
$this->out_color_table_sizecode = $sizecode;
|
$this->out_color_table_sizecode = $sizecode;
|
||||||
for($i = 0; $i < (3 * $size); $i++) {
|
for($i = 0; $i < (3 * $size); $i++) {
|
||||||
$this->global_out[$i] = $this->local_in[$i];
|
$this->global_out[$i] = $this->local_in[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->first) {
|
if($this->first) {
|
||||||
$this->first = false;
|
$this->first = false;
|
||||||
$this->fout .= "\x47\x49\x46\x38\x39\x61";
|
$this->fout .= "\x47\x49\x46\x38\x39\x61";
|
||||||
if($this->width && $this->height) {
|
if($this->width && $this->height) {
|
||||||
$this->logical_screen_descriptor[0] = $this->width & 0xFF;
|
$this->logical_screen_descriptor[0] = $this->width & 0xFF;
|
||||||
$this->logical_screen_descriptor[1] = ($this->width & 0xFF00) >> 8;
|
$this->logical_screen_descriptor[1] = ($this->width & 0xFF00) >> 8;
|
||||||
$this->logical_screen_descriptor[2] = $this->height & 0xFF;
|
$this->logical_screen_descriptor[2] = $this->height & 0xFF;
|
||||||
$this->logical_screen_descriptor[3] = ($this->height & 0xFF00) >> 8;
|
$this->logical_screen_descriptor[3] = ($this->height & 0xFF00) >> 8;
|
||||||
}
|
}
|
||||||
$this->logical_screen_descriptor[4] |= 0x80;
|
$this->logical_screen_descriptor[4] |= 0x80;
|
||||||
$this->logical_screen_descriptor[5] &= 0xF0;
|
$this->logical_screen_descriptor[5] &= 0xF0;
|
||||||
$this->logical_screen_descriptor[6] |= $this->out_color_table_sizecode;
|
$this->logical_screen_descriptor[6] |= $this->out_color_table_sizecode;
|
||||||
$this->putbytes($this->logical_screen_descriptor, 7);
|
$this->putbytes($this->logical_screen_descriptor, 7);
|
||||||
$this->putbytes($this->global_out, ($this->out_color_table_size * 3));
|
$this->putbytes($this->global_out, ($this->out_color_table_size * 3));
|
||||||
if($this->use_loop) {
|
if($this->use_loop) {
|
||||||
$ns[0] = 0x21;
|
$ns[0] = 0x21;
|
||||||
$ns[1] = 0xFF;
|
$ns[1] = 0xFF;
|
||||||
$ns[2] = 0x0B;
|
$ns[2] = 0x0B;
|
||||||
$ns[3] = 0x4e;
|
$ns[3] = 0x4e;
|
||||||
$ns[4] = 0x45;
|
$ns[4] = 0x45;
|
||||||
$ns[5] = 0x54;
|
$ns[5] = 0x54;
|
||||||
$ns[6] = 0x53;
|
$ns[6] = 0x53;
|
||||||
$ns[7] = 0x43;
|
$ns[7] = 0x43;
|
||||||
$ns[8] = 0x41;
|
$ns[8] = 0x41;
|
||||||
$ns[9] = 0x50;
|
$ns[9] = 0x50;
|
||||||
$ns[10] = 0x45;
|
$ns[10] = 0x45;
|
||||||
$ns[11] = 0x32;
|
$ns[11] = 0x32;
|
||||||
$ns[12] = 0x2e;
|
$ns[12] = 0x2e;
|
||||||
$ns[13] = 0x30;
|
$ns[13] = 0x30;
|
||||||
$ns[14] = 0x03;
|
$ns[14] = 0x03;
|
||||||
$ns[15] = 0x01;
|
$ns[15] = 0x01;
|
||||||
$ns[16] = $this->loop & 255;
|
$ns[16] = $this->loop & 255;
|
||||||
$ns[17] = $this->loop >> 8;
|
$ns[17] = $this->loop >> 8;
|
||||||
$ns[18] = 0x00;
|
$ns[18] = 0x00;
|
||||||
$this->putbytes($ns, 19);
|
$this->putbytes($ns, 19);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->use_global_in) {
|
if($this->use_global_in) {
|
||||||
$outtable = $this->global_in;
|
$outtable = $this->global_in;
|
||||||
$outsize = $this->global_color_table_size;
|
$outsize = $this->global_color_table_size;
|
||||||
$outsizecode = $this->global_color_table_sizecode;
|
$outsizecode = $this->global_color_table_sizecode;
|
||||||
} else {
|
} else {
|
||||||
$outtable = $this->global_out;
|
$outtable = $this->global_out;
|
||||||
$outsize = $this->out_color_table_size;
|
$outsize = $this->out_color_table_size;
|
||||||
}
|
}
|
||||||
if($this->local_color_table_flag) {
|
if($this->local_color_table_flag) {
|
||||||
if($size == $this->out_color_table_size && !$this->arrcmp($this->local_in, $this->global_out, $size)) {
|
if($size == $this->out_color_table_size && !$this->arrcmp($this->local_in, $this->global_out, $size)) {
|
||||||
$outtable = $this->global_out;
|
$outtable = $this->global_out;
|
||||||
$outsize = $this->out_color_table_size;
|
$outsize = $this->out_color_table_size;
|
||||||
} else {
|
} else {
|
||||||
$outtable = $this->local_in;
|
$outtable = $this->local_in;
|
||||||
$outsize = $size;
|
$outsize = $size;
|
||||||
$outsizecode = $sizecode;
|
$outsizecode = $sizecode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$use_trans = false;
|
$use_trans = false;
|
||||||
if($this->transparent) {
|
if($this->transparent) {
|
||||||
for($i = 0; $i < $outsize; $i++) {
|
for($i = 0; $i < $outsize; $i++) {
|
||||||
if($outtable[3 * $i] == $this->trans1 && $outtable [3 * $i + 1] == $this->trans2 && $outtable [3 * $i + 2] == $this->trans3) {
|
if($outtable[3 * $i] == $this->trans1 && $outtable [3 * $i + 1] == $this->trans2 && $outtable [3 * $i + 2] == $this->trans3) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($i < $outsize) {
|
if($i < $outsize) {
|
||||||
$transindex = $i;
|
$transindex = $i;
|
||||||
$use_trans = true;
|
$use_trans = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->delay || $use_trans) {
|
if($this->delay || $use_trans) {
|
||||||
$this->buffer[0] = 0x21;
|
$this->buffer[0] = 0x21;
|
||||||
$this->buffer[1] = 0xf9;
|
$this->buffer[1] = 0xf9;
|
||||||
$this->buffer[2] = 0x04;
|
$this->buffer[2] = 0x04;
|
||||||
$this->buffer[3] = ($this->disposal << 2) + ($use_trans ? 1 : 0);
|
$this->buffer[3] = ($this->disposal << 2) + ($use_trans ? 1 : 0);
|
||||||
$this->buffer[4] = $this->delay & 0xff;
|
$this->buffer[4] = $this->delay & 0xff;
|
||||||
$this->buffer[5] = ($this->delay & 0xff00) >> 8;
|
$this->buffer[5] = ($this->delay & 0xff00) >> 8;
|
||||||
$this->buffer[6] = $use_trans ? $transindex : 0;
|
$this->buffer[6] = $use_trans ? $transindex : 0;
|
||||||
$this->buffer[7] = 0x00;
|
$this->buffer[7] = 0x00;
|
||||||
$this->putbytes($this->buffer,8);
|
$this->putbytes($this->buffer,8);
|
||||||
}
|
}
|
||||||
$this->buffer[0] = 0x2c;
|
$this->buffer[0] = 0x2c;
|
||||||
$this->putbytes($this->buffer,1);
|
$this->putbytes($this->buffer,1);
|
||||||
$head[0] = $this->x & 0xff;
|
$head[0] = $this->x & 0xff;
|
||||||
$head[1] = ($this->x & 0xff00) >> 8;
|
$head[1] = ($this->x & 0xff00) >> 8;
|
||||||
$head[2] = $this->y & 0xff;
|
$head[2] = $this->y & 0xff;
|
||||||
$head[3] = ($this->y & 0xff00) >> 8;
|
$head[3] = ($this->y & 0xff00) >> 8;
|
||||||
$head[8] &= 0x40;
|
$head[8] &= 0x40;
|
||||||
if($outtable != $this->global_out) {
|
if($outtable != $this->global_out) {
|
||||||
$head[8] |= 0x80;
|
$head[8] |= 0x80;
|
||||||
$head[8] |= $outsizecode;
|
$head[8] |= $outsizecode;
|
||||||
}
|
}
|
||||||
$this->putbytes($head,9);
|
$this->putbytes($head,9);
|
||||||
if($outtable != $this->global_out) {
|
if($outtable != $this->global_out) {
|
||||||
$this->putbytes($outtable, (3 * $outsize));
|
$this->putbytes($outtable, (3 * $outsize));
|
||||||
}
|
}
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
$this->putbytes($this->buffer,1);
|
$this->putbytes($this->buffer,1);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
$this->putbytes($this->buffer,1);
|
$this->putbytes($this->buffer,1);
|
||||||
if(($u = $this->buffer[0]) == 0) {
|
if(($u = $this->buffer[0]) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->getbytes($u);
|
$this->getbytes($u);
|
||||||
$this->putbytes($this->buffer, $u);
|
$this->putbytes($this->buffer, $u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_extension() {
|
function read_extension() {
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
switch($this->buffer[0]) {
|
switch($this->buffer[0]) {
|
||||||
case 0xf9:
|
case 0xf9:
|
||||||
$this->getbytes(6);
|
$this->getbytes(6);
|
||||||
break;
|
break;
|
||||||
case 0xfe:
|
case 0xfe:
|
||||||
for(;;) {
|
for(;;) {
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
if(($u = $this->buffer[0]) == 0) {
|
if(($u = $this->buffer[0]) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->getbytes($u);
|
$this->getbytes($u);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
$this->getbytes(13);
|
$this->getbytes(13);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
$this->getbytes(0);
|
$this->getbytes(0);
|
||||||
if(($u = $this->buffer[0]) == 0) {
|
if(($u = $this->buffer[0]) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->getbytes($u);
|
$this->getbytes($u);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0xff:
|
case 0xff:
|
||||||
$this->getbytes(9);
|
$this->getbytes(9);
|
||||||
$this->getbytes(3);
|
$this->getbytes(3);
|
||||||
for(;;) {
|
for(;;) {
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
if(!$this->buffer[0]) {
|
if(!$this->buffer[0]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->getbytes($this->buffer[0]);
|
$this->getbytes($this->buffer[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
for(;;) {
|
for(;;) {
|
||||||
$this->getbytes(1);
|
$this->getbytes(1);
|
||||||
if(!$this->buffer[0]) {
|
if(!$this->buffer[0]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->getbytes($this->buffer[0]);
|
$this->getbytes($this->buffer[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function arrcmp($b, $s, $l) {
|
function arrcmp($b, $s, $l) {
|
||||||
for($i = 0; $i < $l; $i++) {
|
for($i = 0; $i < $l; $i++) {
|
||||||
if($s{$i} != $b{$i}) {
|
if($s{$i} != $b{$i}) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getbytes($l) {
|
function getbytes($l) {
|
||||||
for($i = 0; $i < $l; $i++) {
|
for($i = 0; $i < $l; $i++) {
|
||||||
if($this->mod == 'C_FILE') {
|
if($this->mod == 'C_FILE') {
|
||||||
$bin = unpack('C*', fread($this->fin, 1));
|
$bin = unpack('C*', fread($this->fin, 1));
|
||||||
$this->buffer[$i] = $bin[1];
|
$this->buffer[$i] = $bin[1];
|
||||||
} elseif($this->mod == 'C_MEMORY') {
|
} elseif($this->mod == 'C_MEMORY') {
|
||||||
$bin = unpack('C*', substr($this->fin, $this->ch, 1));
|
$bin = unpack('C*', substr($this->fin, $this->ch, 1));
|
||||||
$this->buffer[$i] = $bin[1];
|
$this->buffer[$i] = $bin[1];
|
||||||
$this->ch++;
|
$this->ch++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->buffer;
|
return $this->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function putbytes($s, $l) {
|
function putbytes($s, $l) {
|
||||||
for($i = 0; $i < $l; $i++) {
|
for($i = 0; $i < $l; $i++) {
|
||||||
$this->fout .= pack('C*', $s[$i]);
|
$this->fout .= pack('C*', $s[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAnimation() {
|
function getAnimation() {
|
||||||
return $this->fout;
|
return $this->fout;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,99 +1,99 @@
|
|||||||
<?php
|
<?php
|
||||||
class JSSDK {
|
class JSSDK {
|
||||||
private $appId;
|
private $appId;
|
||||||
private $appSecret;
|
private $appSecret;
|
||||||
private $qy;
|
private $qy;
|
||||||
public function __construct($appId, $appSecret,$qy=1) {
|
public function __construct($appId, $appSecret,$qy=1) {
|
||||||
$this->appId = $appId;
|
$this->appId = $appId;
|
||||||
$this->appSecret = $appSecret;
|
$this->appSecret = $appSecret;
|
||||||
$this->qy=$qy;
|
$this->qy=$qy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSignPackage() {
|
public function getSignPackage() {
|
||||||
|
|
||||||
$jsapiTicket = $this->getJsApiTicket();
|
$jsapiTicket = $this->getJsApiTicket();
|
||||||
// 注意 URL 一定要动态获取,不能 hardcode.
|
// 注意 URL 一定要动态获取,不能 hardcode.
|
||||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
||||||
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
|
||||||
|
|
||||||
$timestamp = time();
|
$timestamp = time();
|
||||||
$nonceStr = $this->createNonceStr();
|
$nonceStr = $this->createNonceStr();
|
||||||
|
|
||||||
// 这里参数的顺序要按照 key 值 ASCII 码升序排序
|
// 这里参数的顺序要按照 key 值 ASCII 码升序排序
|
||||||
$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr×tamp=$timestamp&url=$url";
|
$string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr×tamp=$timestamp&url=$url";
|
||||||
|
|
||||||
$signature = sha1($string);
|
$signature = sha1($string);
|
||||||
|
|
||||||
$signPackage = array(
|
$signPackage = array(
|
||||||
"appId" => $this->appId,
|
"appId" => $this->appId,
|
||||||
"nonceStr" => $nonceStr,
|
"nonceStr" => $nonceStr,
|
||||||
"timestamp" => $timestamp,
|
"timestamp" => $timestamp,
|
||||||
"url" => $url,
|
"url" => $url,
|
||||||
"signature" => $signature,
|
"signature" => $signature,
|
||||||
"rawString" => $string
|
"rawString" => $string
|
||||||
);
|
);
|
||||||
return $signPackage;
|
return $signPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createNonceStr($length = 16) {
|
private function createNonceStr($length = 16) {
|
||||||
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
$str = "";
|
$str = "";
|
||||||
for ($i = 0; $i < $length; $i++) {
|
for ($i = 0; $i < $length; $i++) {
|
||||||
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
|
$str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
|
||||||
}
|
}
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getJsApiTicket() {
|
private function getJsApiTicket() {
|
||||||
// jsapi_ticket 应该全局存储与更新
|
// jsapi_ticket 应该全局存储与更新
|
||||||
if(loadcache('qy_jsapi_ticket') && ($ticket=authcode(getglobal('cache/qy_jsapi_ticket'),'DECODE',getglobal('setting/authkey')))){
|
if(loadcache('qy_jsapi_ticket') && ($ticket=authcode(getglobal('cache/qy_jsapi_ticket'),'DECODE',getglobal('setting/authkey')))){
|
||||||
return $ticket;
|
return $ticket;
|
||||||
}
|
}
|
||||||
|
|
||||||
$accessToken = $this->getAccessToken();
|
$accessToken = $this->getAccessToken();
|
||||||
// 如果是企业号用以下 URL 获取 ticket
|
// 如果是企业号用以下 URL 获取 ticket
|
||||||
if($this->qy) $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";
|
if($this->qy) $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";
|
||||||
else $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=$accessToken";
|
else $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=$accessToken";
|
||||||
$res = json_decode($this->httpGet($url));
|
$res = json_decode($this->httpGet($url));
|
||||||
$ticket = $res->ticket;
|
$ticket = $res->ticket;
|
||||||
if ($ticket) {
|
if ($ticket) {
|
||||||
$expire = $res->expires_in ? intval($res->expires_in)-200 : 7000;
|
$expire = $res->expires_in ? intval($res->expires_in)-200 : 7000;
|
||||||
savecache('qy_jsapi_ticket',authcode($ticket,'ENCODE',getglobal('setting/authkey'),$expire));
|
savecache('qy_jsapi_ticket',authcode($ticket,'ENCODE',getglobal('setting/authkey'),$expire));
|
||||||
return $ticket;
|
return $ticket;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAccessToken() {
|
private function getAccessToken() {
|
||||||
// access_token 应该全局存储与更新
|
// access_token 应该全局存储与更新
|
||||||
if(loadcache('qy_access_token') && ($token=authcode(getglobal('cache/qy_access_token'),'DECODE',getglobal('setting/authkey')))){
|
if(loadcache('qy_access_token') && ($token=authcode(getglobal('cache/qy_access_token'),'DECODE',getglobal('setting/authkey')))){
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
// 如果是企业号用以下URL获取access_token
|
// 如果是企业号用以下URL获取access_token
|
||||||
if($this->qy) $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
|
if($this->qy) $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
|
||||||
else $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
|
else $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$this->appId&secret=$this->appSecret";
|
||||||
$res = json_decode($this->httpGet($url));
|
$res = json_decode($this->httpGet($url));
|
||||||
$access_token = $res->access_token;
|
$access_token = $res->access_token;
|
||||||
if ($access_token) {
|
if ($access_token) {
|
||||||
$expire = $res->expires_in ? intval($res->expires_in)-200 : 7000;
|
$expire = $res->expires_in ? intval($res->expires_in)-200 : 7000;
|
||||||
//TODO: cache access_token
|
//TODO: cache access_token
|
||||||
savecache('qy_access_token',authcode($access_token,'ENCODE',getglobal('setting/authkey'),$expire));
|
savecache('qy_access_token',authcode($access_token,'ENCODE',getglobal('setting/authkey'),$expire));
|
||||||
}
|
}
|
||||||
return $access_token;
|
return $access_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function httpGet($url) {
|
private function httpGet($url) {
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
|
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
curl_setopt($curl, CURLOPT_URL, $url);
|
curl_setopt($curl, CURLOPT_URL, $url);
|
||||||
|
|
||||||
$res = curl_exec($curl);
|
$res = curl_exec($curl);
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,109 +1,109 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class bbcode {
|
class bbcode {
|
||||||
|
|
||||||
var $search_exp = array();
|
var $search_exp = array();
|
||||||
var $replace_exp = array();
|
var $replace_exp = array();
|
||||||
var $search_str = array();
|
var $search_str = array();
|
||||||
var $replace_str = array();
|
var $replace_str = array();
|
||||||
var $html_s_exp = array();
|
var $html_s_exp = array();
|
||||||
var $html_r_exp = array();
|
var $html_r_exp = array();
|
||||||
var $html_s_str = array();
|
var $html_s_str = array();
|
||||||
var $html_r_str = array();
|
var $html_r_str = array();
|
||||||
|
|
||||||
function &instance() {
|
function &instance() {
|
||||||
static $object;
|
static $object;
|
||||||
if(empty($object)) {
|
if(empty($object)) {
|
||||||
$object = new bbcode();
|
$object = new bbcode();
|
||||||
}
|
}
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbcode() {
|
function bbcode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbcode2html($message, $parseurl=0) {
|
function bbcode2html($message, $parseurl=0) {
|
||||||
if(empty($this->search_exp)) {
|
if(empty($this->search_exp)) {
|
||||||
$this->search_exp = array(
|
$this->search_exp = array(
|
||||||
"/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
|
"/\s*\[quote\][\n\r]*(.+?)[\n\r]*\[\/quote\]\s*/is",
|
||||||
"/\[url\]\s*(https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|ed2k:\/\/){1}([^\[\"']+?)\s*\[\/url\]/i",
|
"/\[url\]\s*(https?:\/\/|ftp:\/\/|gopher:\/\/|news:\/\/|telnet:\/\/|rtsp:\/\/|mms:\/\/|callto:\/\/|ed2k:\/\/){1}([^\[\"']+?)\s*\[\/url\]/i",
|
||||||
"/\[em:([0-9]+):\]/i",
|
"/\[em:([0-9]+):\]/i",
|
||||||
);
|
);
|
||||||
$this->replace_exp = array(
|
$this->replace_exp = array(
|
||||||
"<div class=\"quote\"><blockquote>\\1</blockquote></div>",
|
"<div class=\"quote\"><blockquote>\\1</blockquote></div>",
|
||||||
"<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>",
|
"<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>",
|
||||||
" <img src=\"".STATICURL."image/smiley/comcom/\\1.gif\" class=\"vm\"> "
|
" <img src=\"".STATICURL."image/smiley/comcom/\\1.gif\" class=\"vm\"> "
|
||||||
);
|
);
|
||||||
$this->replace_exp[] = '$this->bb_img(\'\\1\')';
|
$this->replace_exp[] = '$this->bb_img(\'\\1\')';
|
||||||
$this->search_str = array('[b]', '[/b]','[i]', '[/i]', '[u]', '[/u]');
|
$this->search_str = array('[b]', '[/b]','[i]', '[/i]', '[u]', '[/u]');
|
||||||
$this->replace_str = array('<b>', '</b>', '<i>','</i>', '<u>', '</u>');
|
$this->replace_str = array('<b>', '</b>', '<i>','</i>', '<u>', '</u>');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($parseurl==2) {
|
if($parseurl==2) {
|
||||||
$message = bbcode::parseurl($message);
|
$message = bbcode::parseurl($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@$message = preg_replace($this->search_exp, $this->replace_exp, $message, 20);
|
@$message = preg_replace($this->search_exp, $this->replace_exp, $message, 20);
|
||||||
|
|
||||||
if($parseurl==2) {
|
if($parseurl==2) {
|
||||||
@$message = preg_replace_callback("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", array($this, 'bbcode2html_callback_bb_img_1'), $message, 20);
|
@$message = preg_replace_callback("/\[img\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/is", array($this, 'bbcode2html_callback_bb_img_1'), $message, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@$message = str_replace($this->search_str, $this->replace_str, $message);
|
@$message = str_replace($this->search_str, $this->replace_str, $message);
|
||||||
return nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message));
|
return nl2br(str_replace(array("\t", ' ', ' '), array(' ', ' ', ' '), $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbcode2html_callback_bb_img_1($matches) {
|
function bbcode2html_callback_bb_img_1($matches) {
|
||||||
return $this->bb_img($matches[1]);
|
return $this->bb_img($matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseurl($message) {
|
function parseurl($message) {
|
||||||
return preg_replace("/(?<=[^\]a-z0-9-=\"'\\/])((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+)/i", "[url]\\1\\3[/url]", ' '.$message);
|
return preg_replace("/(?<=[^\]a-z0-9-=\"'\\/])((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/)([a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+)/i", "[url]\\1\\3[/url]", ' '.$message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function html2bbcode($message) {
|
function html2bbcode($message) {
|
||||||
|
|
||||||
if(empty($this->html_s_exp)) {
|
if(empty($this->html_s_exp)) {
|
||||||
$this->html_s_exp = array(
|
$this->html_s_exp = array(
|
||||||
"/\<div class=\"quote\"\>\<blockquote\>(.*?)\<\/blockquote\>\<\/div\>/is",
|
"/\<div class=\"quote\"\>\<blockquote\>(.*?)\<\/blockquote\>\<\/div\>/is",
|
||||||
"/\<a href=\"(.+?)\".*?\<\/a\>/is",
|
"/\<a href=\"(.+?)\".*?\<\/a\>/is",
|
||||||
"/(\r\n|\n|\r)/",
|
"/(\r\n|\n|\r)/",
|
||||||
"/<br.*>/siU",
|
"/<br.*>/siU",
|
||||||
"/[ \t]*\<img src=\"static\/image\/smiley\/comcom\/(.+?).gif\".*?\>[ \t]*/is",
|
"/[ \t]*\<img src=\"static\/image\/smiley\/comcom\/(.+?).gif\".*?\>[ \t]*/is",
|
||||||
"/\s*\<img src=\"(.+?)\".*?\>\s*/is"
|
"/\s*\<img src=\"(.+?)\".*?\>\s*/is"
|
||||||
);
|
);
|
||||||
$this->html_r_exp = array(
|
$this->html_r_exp = array(
|
||||||
"[quote]\\1[/quote]",
|
"[quote]\\1[/quote]",
|
||||||
"\\1",
|
"\\1",
|
||||||
'',
|
'',
|
||||||
"\n",
|
"\n",
|
||||||
"[em:\\1:]",
|
"[em:\\1:]",
|
||||||
"\n[img]\\1[/img]\n"
|
"\n[img]\\1[/img]\n"
|
||||||
);
|
);
|
||||||
$this->html_s_str = array('<b>', '</b>', '<i>','</i>', '<u>', '</u>', ' ', ' ', ' ', '<', '>', '&');
|
$this->html_s_str = array('<b>', '</b>', '<i>','</i>', '<u>', '</u>', ' ', ' ', ' ', '<', '>', '&');
|
||||||
$this->html_r_str = array('[b]', '[/b]','[i]', '[/i]', '[u]', '[/u]', "\t", ' ', ' ', '<', '>', '&');
|
$this->html_r_str = array('[b]', '[/b]','[i]', '[/i]', '[u]', '[/u]', "\t", ' ', ' ', '<', '>', '&');
|
||||||
}
|
}
|
||||||
|
|
||||||
@$message = str_replace($this->html_s_str, $this->html_r_str,
|
@$message = str_replace($this->html_s_str, $this->html_r_str,
|
||||||
preg_replace($this->html_s_exp, $this->html_r_exp, $message));
|
preg_replace($this->html_s_exp, $this->html_r_exp, $message));
|
||||||
|
|
||||||
$message = dhtmlspecialchars($message);
|
$message = dhtmlspecialchars($message);
|
||||||
|
|
||||||
return trim($message);
|
return trim($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bb_img($url) {
|
function bb_img($url) {
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) {
|
if(!in_array(strtolower(substr($url, 0, 6)), array('http:/', 'https:', 'ftp://', 'rtsp:/', 'mms://'))) {
|
||||||
$url = isset($_G['siteurl']) && !empty($_G['siteurl']) ? $_G['siteurl'].$url : 'http://'.$url;
|
$url = isset($_G['siteurl']) && !empty($_G['siteurl']) ? $_G['siteurl'].$url : 'http://'.$url;
|
||||||
}
|
}
|
||||||
$url = addslashes($url);
|
$url = addslashes($url);
|
||||||
return "<img src=\"$url\" class=\"vm\">";
|
return "<img src=\"$url\" class=\"vm\">";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,323 +1,323 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command
|
* Command
|
||||||
*
|
*
|
||||||
* This class represents a shell command.
|
* This class represents a shell command.
|
||||||
*
|
*
|
||||||
* @author Michael Härtl <haertl.mike@gmail.com>
|
* @author Michael Härtl <haertl.mike@gmail.com>
|
||||||
* @version 1.0.5
|
* @version 1.0.5
|
||||||
* @license http://www.opensource.org/licenses/MIT
|
* @license http://www.opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
class command
|
class command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool whether to escape any argument passed through addArg(). Default is true.
|
* @var bool whether to escape any argument passed through addArg(). Default is true.
|
||||||
*/
|
*/
|
||||||
public $escapeArgs = true;
|
public $escapeArgs = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool whether to escape the command passed to setCommand() or the constructor.
|
* @var bool whether to escape the command passed to setCommand() or the constructor.
|
||||||
* This is only useful if $escapeArgs is false. Default is false.
|
* This is only useful if $escapeArgs is false. Default is false.
|
||||||
*/
|
*/
|
||||||
public $escapeCommand = false;
|
public $escapeCommand = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool whether to use `exec()` instead of `proc_open()`. This can be used on Windows system
|
* @var bool whether to use `exec()` instead of `proc_open()`. This can be used on Windows system
|
||||||
* to workaround some quirks there. Note, that any errors from your command will be output directly
|
* to workaround some quirks there. Note, that any errors from your command will be output directly
|
||||||
* to the PHP output stream. `getStdErr()` will also not work anymore and thus you also won't get
|
* to the PHP output stream. `getStdErr()` will also not work anymore and thus you also won't get
|
||||||
* the error output from `getError()` in this case. You also can't pass any environment
|
* the error output from `getError()` in this case. You also can't pass any environment
|
||||||
* variables to the command if this is enabled. Default is false.
|
* variables to the command if this is enabled. Default is false.
|
||||||
*/
|
*/
|
||||||
public $useExec = false;
|
public $useExec = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool whether to capture stderr (2>&1) when `useExec` is true. This will try to redirect the
|
* @var bool whether to capture stderr (2>&1) when `useExec` is true. This will try to redirect the
|
||||||
* stderr to stdout and provide the complete output of both in `getStdErr()` and `getError()`.
|
* stderr to stdout and provide the complete output of both in `getStdErr()` and `getError()`.
|
||||||
* Default is `true`.
|
* Default is `true`.
|
||||||
*/
|
*/
|
||||||
public $captureStdErr = true;
|
public $captureStdErr = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string|null the initial working dir for proc_open(). Default is null for current PHP working dir.
|
* @var string|null the initial working dir for proc_open(). Default is null for current PHP working dir.
|
||||||
*/
|
*/
|
||||||
public $procCwd;
|
public $procCwd;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array|null an array with environment variables to pass to proc_open(). Default is null for none.
|
* @var array|null an array with environment variables to pass to proc_open(). Default is null for none.
|
||||||
*/
|
*/
|
||||||
public $procEnv;
|
public $procEnv;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array|null an array of other_options for proc_open(). Default is null for none.
|
* @var array|null an array of other_options for proc_open(). Default is null for none.
|
||||||
*/
|
*/
|
||||||
public $procOptions;
|
public $procOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string the command to execute
|
* @var string the command to execute
|
||||||
*/
|
*/
|
||||||
protected $_command;
|
protected $_command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array the list of command arguments
|
* @var array the list of command arguments
|
||||||
*/
|
*/
|
||||||
protected $_args = array();
|
protected $_args = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string the full command string to execute
|
* @var string the full command string to execute
|
||||||
*/
|
*/
|
||||||
protected $_execCommand;
|
protected $_execCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string the stdout output
|
* @var string the stdout output
|
||||||
*/
|
*/
|
||||||
protected $_stdOut = '';
|
protected $_stdOut = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string the stderr output
|
* @var string the stderr output
|
||||||
*/
|
*/
|
||||||
protected $_stdErr = '';
|
protected $_stdErr = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int the exit code
|
* @var int the exit code
|
||||||
*/
|
*/
|
||||||
protected $_exitCode;
|
protected $_exitCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string the error message
|
* @var string the error message
|
||||||
*/
|
*/
|
||||||
protected $_error = '';
|
protected $_error = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool whether the command was successfully executed
|
* @var bool whether the command was successfully executed
|
||||||
*/
|
*/
|
||||||
protected $_executed = false;
|
protected $_executed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|array $options either a command string or an options array (see setOptions())
|
* @param string|array $options either a command string or an options array (see setOptions())
|
||||||
*/
|
*/
|
||||||
public function __construct($options = null)
|
public function __construct($options = null)
|
||||||
{
|
{
|
||||||
if (is_array($options)) {
|
if (is_array($options)) {
|
||||||
$this->setOptions($options);
|
$this->setOptions($options);
|
||||||
} elseif (is_string($options)) {
|
} elseif (is_string($options)) {
|
||||||
$this->setCommand($options);
|
$this->setCommand($options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $options array of name => value options that should be applied to the object
|
* @param array $options array of name => value options that should be applied to the object
|
||||||
* You can also pass options that use a setter, e.g. you can pass a 'fileName' option which
|
* You can also pass options that use a setter, e.g. you can pass a 'fileName' option which
|
||||||
* will be passed to setFileName().
|
* will be passed to setFileName().
|
||||||
* @return Command for method chaining
|
* @return Command for method chaining
|
||||||
*/
|
*/
|
||||||
public function setOptions($options)
|
public function setOptions($options)
|
||||||
{
|
{
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
if (property_exists($this, $key)) {
|
if (property_exists($this, $key)) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
} else {
|
} else {
|
||||||
$method = 'set'.ucfirst($key);
|
$method = 'set'.ucfirst($key);
|
||||||
if (method_exists($this, $method)) {
|
if (method_exists($this, $method)) {
|
||||||
call_user_func(array($this,$method), $value);
|
call_user_func(array($this,$method), $value);
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception("Unknown configuration option '$key'");
|
throw new \Exception("Unknown configuration option '$key'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $command the command or full command string to execute, like 'gzip' or 'gzip -d'.
|
* @param string $command the command or full command string to execute, like 'gzip' or 'gzip -d'.
|
||||||
* You can still call addArg() to add more arguments to the command. If $escapeCommand was set to true,
|
* You can still call addArg() to add more arguments to the command. If $escapeCommand was set to true,
|
||||||
* the command gets escaped through escapeshellcmd().
|
* the command gets escaped through escapeshellcmd().
|
||||||
* @return Command for method chaining
|
* @return Command for method chaining
|
||||||
*/
|
*/
|
||||||
public function setCommand($command)
|
public function setCommand($command)
|
||||||
{
|
{
|
||||||
$this->_command = $this->escapeCommand ? escapeshellcmd($command) : $command;
|
$this->_command = $this->escapeCommand ? escapeshellcmd($command) : $command;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string|null the command that was set through setCommand() or passed to the constructor. Null if none.
|
* @return string|null the command that was set through setCommand() or passed to the constructor. Null if none.
|
||||||
*/
|
*/
|
||||||
public function getCommand()
|
public function getCommand()
|
||||||
{
|
{
|
||||||
return $this->_command;
|
return $this->_command;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string|bool the full command string to execute. If no command was set with setCommand()
|
* @return string|bool the full command string to execute. If no command was set with setCommand()
|
||||||
* or passed to the constructor it will return false.
|
* or passed to the constructor it will return false.
|
||||||
*/
|
*/
|
||||||
public function getExecCommand()
|
public function getExecCommand()
|
||||||
{
|
{
|
||||||
if ($this->_execCommand===null) {
|
if ($this->_execCommand===null) {
|
||||||
$command = $this->getCommand();
|
$command = $this->getCommand();
|
||||||
if (!$command) {
|
if (!$command) {
|
||||||
$this->_error = 'Could not locate any executable command';
|
$this->_error = 'Could not locate any executable command';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$args = $this->getArgs();
|
$args = $this->getArgs();
|
||||||
$this->_execCommand = $args ? $command.' '.$args : $command;
|
$this->_execCommand = $args ? $command.' '.$args : $command;
|
||||||
}
|
}
|
||||||
return $this->_execCommand;
|
return $this->_execCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $args the command arguments as string. Note that these will not get escaped!
|
* @param string $args the command arguments as string. Note that these will not get escaped!
|
||||||
* @return Command for method chaining
|
* @return Command for method chaining
|
||||||
*/
|
*/
|
||||||
public function setArgs($args)
|
public function setArgs($args)
|
||||||
{
|
{
|
||||||
$this->_args = array($args);
|
$this->_args = array($args);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the command args that where set through setArgs() or added with addArg() separated by spaces
|
* @return string the command args that where set through setArgs() or added with addArg() separated by spaces
|
||||||
*/
|
*/
|
||||||
public function getArgs()
|
public function getArgs()
|
||||||
{
|
{
|
||||||
return implode(' ', $this->_args);
|
return implode(' ', $this->_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key the argument key to add e.g. `--feature` or `--name=`. If the key does not end with
|
* @param string $key the argument key to add e.g. `--feature` or `--name=`. If the key does not end with
|
||||||
* and `=`, the $value will be separated by a space, if any. Keys are not escaped unless $value is null
|
* and `=`, the $value will be separated by a space, if any. Keys are not escaped unless $value is null
|
||||||
* and $escape is `true`.
|
* and $escape is `true`.
|
||||||
* @param string|array|null $value the optional argument value which will get escaped if $escapeArgs is true.
|
* @param string|array|null $value the optional argument value which will get escaped if $escapeArgs is true.
|
||||||
* An array can be passed to add more than one value for a key, e.g. `addArg('--exclude', array('val1','val2'))`
|
* An array can be passed to add more than one value for a key, e.g. `addArg('--exclude', array('val1','val2'))`
|
||||||
* which will create the option `--exclude 'val1' 'val2'`.
|
* which will create the option `--exclude 'val1' 'val2'`.
|
||||||
* @param bool|null $escape if set, this overrides the $escapeArgs setting and enforces escaping/no escaping
|
* @param bool|null $escape if set, this overrides the $escapeArgs setting and enforces escaping/no escaping
|
||||||
* @return Command for method chaining
|
* @return Command for method chaining
|
||||||
*/
|
*/
|
||||||
public function addArg($key, $value = null, $escape = null)
|
public function addArg($key, $value = null, $escape = null)
|
||||||
{
|
{
|
||||||
$old=setlocale(LC_ALL,0);
|
$old=setlocale(LC_ALL,0);
|
||||||
setlocale(LC_ALL,'us');
|
setlocale(LC_ALL,'us');
|
||||||
$doEscape = $escape!==null ? $escape : $this->escapeArgs;
|
$doEscape = $escape!==null ? $escape : $this->escapeArgs;
|
||||||
if ($value===null) {
|
if ($value===null) {
|
||||||
// Only escape single arguments if explicitely requested
|
// Only escape single arguments if explicitely requested
|
||||||
$this->_args[] = $escape ? escapeshellarg($key) : $key;
|
$this->_args[] = $escape ? escapeshellarg($key) : $key;
|
||||||
} else {
|
} else {
|
||||||
$separator = substr($key, -1)==='=' ? '' : ' ';
|
$separator = substr($key, -1)==='=' ? '' : ' ';
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$params = array();
|
$params = array();
|
||||||
foreach ($value as $v) {
|
foreach ($value as $v) {
|
||||||
$params[] = $doEscape ? escapeshellarg($v) : $v;
|
$params[] = $doEscape ? escapeshellarg($v) : $v;
|
||||||
}
|
}
|
||||||
$this->_args[] = $key.$separator.implode(' ',$params);
|
$this->_args[] = $key.$separator.implode(' ',$params);
|
||||||
} else {
|
} else {
|
||||||
$this->_args[] = $key.$separator.($doEscape ? escapeshellarg($value) : $value);
|
$this->_args[] = $key.$separator.($doEscape ? escapeshellarg($value) : $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//print_r($old);
|
//print_r($old);
|
||||||
setlocale(LC_ALL,$old);
|
setlocale(LC_ALL,$old);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the command output (stdout). Empty if none.
|
* @return string the command output (stdout). Empty if none.
|
||||||
*/
|
*/
|
||||||
public function getOutput()
|
public function getOutput()
|
||||||
{
|
{
|
||||||
return $this->_stdOut;
|
return $this->_stdOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the error message, either stderr or internal message. Empty if none.
|
* @return string the error message, either stderr or internal message. Empty if none.
|
||||||
*/
|
*/
|
||||||
public function getError()
|
public function getError()
|
||||||
{
|
{
|
||||||
return $this->_error;
|
return $this->_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the stderr output. Empty if none.
|
* @return string the stderr output. Empty if none.
|
||||||
*/
|
*/
|
||||||
public function getStdErr()
|
public function getStdErr()
|
||||||
{
|
{
|
||||||
return $this->_stdErr;
|
return $this->_stdErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int|null the exit code or null if command was not executed yet
|
* @return int|null the exit code or null if command was not executed yet
|
||||||
*/
|
*/
|
||||||
public function getExitCode()
|
public function getExitCode()
|
||||||
{
|
{
|
||||||
return $this->_exitCode;
|
return $this->_exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string whether the command was successfully executed
|
* @return string whether the command was successfully executed
|
||||||
*/
|
*/
|
||||||
public function getExecuted()
|
public function getExecuted()
|
||||||
{
|
{
|
||||||
return $this->_executed;
|
return $this->_executed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the command
|
* Execute the command
|
||||||
*
|
*
|
||||||
* @return bool whether execution was successful. If false, error details can be obtained through
|
* @return bool whether execution was successful. If false, error details can be obtained through
|
||||||
* getError(), getStdErr() and getExitCode().
|
* getError(), getStdErr() and getExitCode().
|
||||||
*/
|
*/
|
||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
$command = $this->getExecCommand();
|
$command = $this->getExecCommand();
|
||||||
|
|
||||||
if (!$command) {
|
if (!$command) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->useExec) {
|
if ($this->useExec) {
|
||||||
$execCommand = $this->captureStdErr ? "$command 2>&1" : $command;
|
$execCommand = $this->captureStdErr ? "$command 2>&1" : $command;
|
||||||
exec($execCommand, $output, $this->_exitCode);
|
exec($execCommand, $output, $this->_exitCode);
|
||||||
$this->_stdOut = trim(implode("\n", $output));
|
$this->_stdOut = trim(implode("\n", $output));
|
||||||
if ($this->_exitCode!==0) {
|
if ($this->_exitCode!==0) {
|
||||||
$this->_stdErr = $this->_stdOut;
|
$this->_stdErr = $this->_stdOut;
|
||||||
$this->_error = empty($this->_stdErr) ? 'Command failed' : $this->_stdErr;
|
$this->_error = empty($this->_stdErr) ? 'Command failed' : $this->_stdErr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$descriptors = array(
|
$descriptors = array(
|
||||||
1 => array('pipe','w'),
|
1 => array('pipe','w'),
|
||||||
2 => array('pipe','a'),
|
2 => array('pipe','a'),
|
||||||
);
|
);
|
||||||
$process = proc_open($command, $descriptors, $pipes, $this->procCwd, $this->procEnv, $this->procOptions);
|
$process = proc_open($command, $descriptors, $pipes, $this->procCwd, $this->procEnv, $this->procOptions);
|
||||||
|
|
||||||
if (is_resource($process)) {
|
if (is_resource($process)) {
|
||||||
|
|
||||||
$this->_stdOut = trim(stream_get_contents($pipes[1]));
|
$this->_stdOut = trim(stream_get_contents($pipes[1]));
|
||||||
$this->_stdErr = trim(stream_get_contents($pipes[2]));
|
$this->_stdErr = trim(stream_get_contents($pipes[2]));
|
||||||
fclose($pipes[1]);
|
fclose($pipes[1]);
|
||||||
fclose($pipes[2]);
|
fclose($pipes[2]);
|
||||||
|
|
||||||
$this->_exitCode = proc_close($process);
|
$this->_exitCode = proc_close($process);
|
||||||
|
|
||||||
if ($this->_exitCode!==0) {
|
if ($this->_exitCode!==0) {
|
||||||
$this->_error = $this->_stdErr ? $this->_stdErr : "Failed without error message: $command";
|
$this->_error = $this->_stdErr ? $this->_stdErr : "Failed without error message: $command";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->_error = "Could not run command $command";
|
$this->_error = "Could not run command $command";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_executed = true;
|
$this->_executed = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string the current command string to execute
|
* @return string the current command string to execute
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return (string)$this->getExecCommand();
|
return (string)$this->getExecCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,393 +1,393 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
class core
|
class core
|
||||||
{
|
{
|
||||||
private static $_tables;
|
private static $_tables;
|
||||||
private static $_tptables;
|
private static $_tptables;
|
||||||
private static $_imports;
|
private static $_imports;
|
||||||
private static $_app;
|
private static $_app;
|
||||||
private static $_memory;
|
private static $_memory;
|
||||||
|
|
||||||
// 类名映射
|
// 类名映射
|
||||||
protected static $map = array();
|
protected static $map = array();
|
||||||
|
|
||||||
//psr4
|
//psr4
|
||||||
private static $prefixLengthsPsr4 = array();
|
private static $prefixLengthsPsr4 = array();
|
||||||
private static $prefixDirsPsr4 = array();
|
private static $prefixDirsPsr4 = array();
|
||||||
private static $fallbackDirsPsr4 = array();
|
private static $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
public static function app($params=array()) {
|
public static function app($params=array()) {
|
||||||
if(!is_object(self::$_app)) {
|
if(!is_object(self::$_app)) {
|
||||||
self::$_app = dzz_app::instance($params);
|
self::$_app = dzz_app::instance($params);
|
||||||
}
|
}
|
||||||
return self::$_app;
|
return self::$_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function creatapp() {
|
public static function creatapp() {
|
||||||
|
|
||||||
if(!is_object(self::$_app)) {
|
if(!is_object(self::$_app)) {
|
||||||
|
|
||||||
self::$_app = dzz_app::instance();
|
self::$_app = dzz_app::instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::$_app;
|
return self::$_app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function t($name) {
|
public static function t($name) {
|
||||||
return self::_make_obj($name, 'table', DZZ_TABLE_EXTENDABLE);
|
return self::_make_obj($name, 'table', DZZ_TABLE_EXTENDABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tp_t($name) {
|
public static function tp_t($name) {
|
||||||
return self::_tp_make_obj($name, 'table', DZZ_TABLE_EXTENDABLE);
|
return self::_tp_make_obj($name, 'table', DZZ_TABLE_EXTENDABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function m($name) {
|
public static function m($name) {
|
||||||
$args = array();
|
$args = array();
|
||||||
if(func_num_args() > 1) {
|
if(func_num_args() > 1) {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
unset($args[0]);
|
unset($args[0]);
|
||||||
}
|
}
|
||||||
return self::_make_obj($name, 'model', true, $args);
|
return self::_make_obj($name, 'model', true, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function _make_obj($name, $type, $extendable = true, $p = array()) {
|
protected static function _make_obj($name, $type, $extendable = true, $p = array()) {
|
||||||
$folder = null;
|
$folder = null;
|
||||||
if($name[0] === '#') {
|
if($name[0] === '#') {
|
||||||
list(, $folder, $name) = explode('#', $name);
|
list(, $folder, $name) = explode('#', $name);
|
||||||
}
|
}
|
||||||
$cname = $type.'_'.$name;
|
$cname = $type.'_'.$name;
|
||||||
if(!isset(self::$_tables[$cname])) {
|
if(!isset(self::$_tables[$cname])) {
|
||||||
if(!class_exists($cname, false)) {
|
if(!class_exists($cname, false)) {
|
||||||
self::import('class'.'/'.$type.'/'.$name,$folder);
|
self::import('class'.'/'.$type.'/'.$name,$folder);
|
||||||
}
|
}
|
||||||
if($extendable) {
|
if($extendable) {
|
||||||
self::$_tables[$cname] = new dzz_container();
|
self::$_tables[$cname] = new dzz_container();
|
||||||
switch (count($p)) {
|
switch (count($p)) {
|
||||||
case 0: self::$_tables[$cname]->obj = new $cname();break;
|
case 0: self::$_tables[$cname]->obj = new $cname();break;
|
||||||
case 1: self::$_tables[$cname]->obj = new $cname($p[1]);break;
|
case 1: self::$_tables[$cname]->obj = new $cname($p[1]);break;
|
||||||
case 2: self::$_tables[$cname]->obj = new $cname($p[1], $p[2]);break;
|
case 2: self::$_tables[$cname]->obj = new $cname($p[1], $p[2]);break;
|
||||||
case 3: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3]);break;
|
case 3: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3]);break;
|
||||||
case 4: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3], $p[4]);break;
|
case 4: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3], $p[4]);break;
|
||||||
case 5: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3], $p[4], $p[5]);break;
|
case 5: self::$_tables[$cname]->obj = new $cname($p[1], $p[2], $p[3], $p[4], $p[5]);break;
|
||||||
default: $ref = new ReflectionClass($cname);self::$_tables[$cname]->obj = $ref->newInstanceArgs($p);unset($ref);break;
|
default: $ref = new ReflectionClass($cname);self::$_tables[$cname]->obj = $ref->newInstanceArgs($p);unset($ref);break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self::$_tables[$cname] = new $cname();
|
self::$_tables[$cname] = new $cname();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self::$_tables[$cname];
|
return self::$_tables[$cname];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function _tp_make_obj($name, $type, $extendable = true, $p = array()) {
|
protected static function _tp_make_obj($name, $type, $extendable = true, $p = array()) {
|
||||||
$folder = null;
|
$folder = null;
|
||||||
if($name[0] === '#') {
|
if($name[0] === '#') {
|
||||||
list(, $folder, $name) = explode('#', $name);
|
list(, $folder, $name) = explode('#', $name);
|
||||||
}
|
}
|
||||||
$cname = $type.'_'.$name;
|
$cname = $type.'_'.$name;
|
||||||
if(!isset(self::$_tptables[$cname])) {
|
if(!isset(self::$_tptables[$cname])) {
|
||||||
/*if(!class_exists($cname, false)) {
|
/*if(!class_exists($cname, false)) {
|
||||||
self::import('class'.'/'.$type.'/'.$name,$folder);
|
self::import('class'.'/'.$type.'/'.$name,$folder);
|
||||||
}*/
|
}*/
|
||||||
self::$_tptables[$cname] = new dzz_mode($name);
|
self::$_tptables[$cname] = new dzz_mode($name);
|
||||||
}
|
}
|
||||||
return self::$_tptables[$cname];
|
return self::$_tptables[$cname];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function memory() {
|
public static function memory() {
|
||||||
if(!self::$_memory) {
|
if(!self::$_memory) {
|
||||||
self::$_memory = new dzz_memory();
|
self::$_memory = new dzz_memory();
|
||||||
self::$_memory->init(self::app()->config['memory']);
|
self::$_memory->init(self::app()->config['memory']);
|
||||||
}
|
}
|
||||||
return self::$_memory;
|
return self::$_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function import($name, $folder = '', $force = true) {
|
public static function import($name, $folder = '', $force = true) {
|
||||||
//如果文件名为空或者false,阻止向下进行
|
//如果文件名为空或者false,阻止向下进行
|
||||||
if(preg_match('/^\s*$/',$name) || $name == false){
|
if(preg_match('/^\s*$/',$name) || $name == false){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$key = $folder.$name;
|
$key = $folder.$name;
|
||||||
if(!isset(self::$_imports[$key])) {
|
if(!isset(self::$_imports[$key])) {
|
||||||
if($folder){
|
if($folder){
|
||||||
$path = DZZ_ROOT.'./dzz/'.$folder.'/';
|
$path = DZZ_ROOT.'./dzz/'.$folder.'/';
|
||||||
}else{
|
}else{
|
||||||
$path = DZZ_ROOT.'./core/';
|
$path = DZZ_ROOT.'./core/';
|
||||||
if(defined('CURSCRIPT')) {
|
if(defined('CURSCRIPT')) {
|
||||||
$path1= DZZ_ROOT.'./'.CURSCRIPT.'/';
|
$path1= DZZ_ROOT.'./'.CURSCRIPT.'/';
|
||||||
if(defined('CURMODULE')) $path2=DZZ_ROOT.'/'.CURSCRIPT.'/'.CURMODULE.'/';
|
if(defined('CURMODULE')) $path2=DZZ_ROOT.'/'.CURSCRIPT.'/'.CURMODULE.'/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strpos($name, '/') !== false) {
|
if(strpos($name, '/') !== false) {
|
||||||
$pre = basename(dirname($name));
|
$pre = basename(dirname($name));
|
||||||
$filename = dirname($name).'/'.$pre.'_'.basename($name).'.php';
|
$filename = dirname($name).'/'.$pre.'_'.basename($name).'.php';
|
||||||
} else {
|
} else {
|
||||||
$filename = $name.'.php';
|
$filename = $name.'.php';
|
||||||
}
|
}
|
||||||
if(isset($path2) && is_file($path2.$filename)) {
|
if(isset($path2) && is_file($path2.$filename)) {
|
||||||
self::$_imports[$key] = true;
|
self::$_imports[$key] = true;
|
||||||
$rt = include $path2.$filename;
|
$rt = include $path2.$filename;
|
||||||
return $rt;
|
return $rt;
|
||||||
}elseif(isset($path1) && is_file($path1.$filename)) {
|
}elseif(isset($path1) && is_file($path1.$filename)) {
|
||||||
self::$_imports[$key] = true;
|
self::$_imports[$key] = true;
|
||||||
$rt = include $path1.$filename;
|
$rt = include $path1.$filename;
|
||||||
return $rt;
|
return $rt;
|
||||||
}elseif(is_file($path.$filename)) {
|
}elseif(is_file($path.$filename)) {
|
||||||
self::$_imports[$key] = true;
|
self::$_imports[$key] = true;
|
||||||
$rt = include $path.$filename;
|
$rt = include $path.$filename;
|
||||||
return $rt;
|
return $rt;
|
||||||
} elseif(!$force) {
|
} elseif(!$force) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
//throw new Exception('Oops! System file lost: '.$filename);
|
//throw new Exception('Oops! System file lost: '.$filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function handleException($exception) {
|
public static function handleException($exception) {
|
||||||
global $_config;
|
global $_config;
|
||||||
if($_config['debug']>0){
|
if($_config['debug']>0){
|
||||||
dzz_error::exception_error($exception);
|
dzz_error::exception_error($exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function handleError($errno, $errstr, $errfile, $errline) {
|
public static function handleError($errno, $errstr, $errfile, $errline) {
|
||||||
if($errno & DZZ_CORE_DEBUG) {
|
if($errno & DZZ_CORE_DEBUG) {
|
||||||
dzz_error::system_error($errstr, false, true, false);
|
dzz_error::system_error($errstr, false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function handleShutdown() {
|
public static function handleShutdown() {
|
||||||
if(($error = error_get_last()) && $error['type'] & DZZ_CORE_DEBUG) {
|
if(($error = error_get_last()) && $error['type'] & DZZ_CORE_DEBUG) {
|
||||||
dzz_error::system_error($error['message'], false, true, false);
|
dzz_error::system_error($error['message'], false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function autoload($class) {
|
public static function autoload($class) {
|
||||||
$module='';
|
$module='';
|
||||||
if($class[0] === '#') {
|
if($class[0] === '#') {
|
||||||
list(, $module, $class) = explode('#', $class);
|
list(, $module, $class) = explode('#', $class);
|
||||||
}
|
}
|
||||||
$class = ($class);
|
$class = ($class);
|
||||||
$namespaceArr = explode('\\',$class);
|
$namespaceArr = explode('\\',$class);
|
||||||
$namesapce = $namespaceArr[0].'\\';
|
$namesapce = $namespaceArr[0].'\\';
|
||||||
if(array_key_exists($namesapce,self::$prefixDirsPsr4)){
|
if(array_key_exists($namesapce,self::$prefixDirsPsr4)){
|
||||||
$file = self::findFile($class);
|
$file = self::findFile($class);
|
||||||
if(file_exists($file)){
|
if(file_exists($file)){
|
||||||
include_once $file;
|
include_once $file;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} elseif(strpos($class, '_') !== false) {
|
} elseif(strpos($class, '_') !== false) {
|
||||||
list($folder) = explode('_', $class);
|
list($folder) = explode('_', $class);
|
||||||
$file = 'class/'.$folder.BS.substr($class, strlen($folder) + 1);
|
$file = 'class/'.$folder.BS.substr($class, strlen($folder) + 1);
|
||||||
} else {
|
} else {
|
||||||
$file = 'class/'.$class;
|
$file = 'class/'.$class;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
self::import($file,$module);
|
self::import($file,$module);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
|
|
||||||
$trace = $exc->getTrace();
|
$trace = $exc->getTrace();
|
||||||
foreach ($trace as $log) {
|
foreach ($trace as $log) {
|
||||||
if(empty($log['class']) && $log['function'] == 'class_exists') {
|
if(empty($log['class']) && $log['function'] == 'class_exists') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dzz_error::exception_error($exc);
|
dzz_error::exception_error($exc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//查找文件
|
//查找文件
|
||||||
private static function findFile($class)
|
private static function findFile($class)
|
||||||
{
|
{
|
||||||
if (!empty(self::$map[$class])) {
|
if (!empty(self::$map[$class])) {
|
||||||
// 类库映射
|
// 类库映射
|
||||||
return self::$map[$class];
|
return self::$map[$class];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找 PSR-4
|
// 查找 PSR-4
|
||||||
$logicalPathPsr4 = strtr($class, '\\', '/') . EXT;
|
$logicalPathPsr4 = strtr($class, '\\', '/') . EXT;
|
||||||
$first = $class[0];
|
$first = $class[0];
|
||||||
if (isset(self::$prefixLengthsPsr4[$first])) {
|
if (isset(self::$prefixLengthsPsr4[$first])) {
|
||||||
|
|
||||||
foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) {
|
foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) {
|
||||||
|
|
||||||
if (0 === strpos($class, $prefix)) {
|
if (0 === strpos($class, $prefix)) {
|
||||||
|
|
||||||
foreach (self::$prefixDirsPsr4[$prefix] as $dir) {
|
foreach (self::$prefixDirsPsr4[$prefix] as $dir) {
|
||||||
if (is_file($file = $dir .BS .substr($logicalPathPsr4, $length))) {
|
if (is_file($file = $dir .BS .substr($logicalPathPsr4, $length))) {
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查找 PSR-4 fallback dirs
|
// 查找 PSR-4 fallback dirs
|
||||||
foreach (self::$fallbackDirsPsr4 as $dir) {
|
foreach (self::$fallbackDirsPsr4 as $dir) {
|
||||||
if (is_file($file = $dir . $logicalPathPsr4)) {
|
if (is_file($file = $dir . $logicalPathPsr4)) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self::$map[$class] = false;
|
return self::$map[$class] = false;
|
||||||
}
|
}
|
||||||
// 注册命名空间
|
// 注册命名空间
|
||||||
public static function addNamespace($namespace, $path = '')
|
public static function addNamespace($namespace, $path = '')
|
||||||
{
|
{
|
||||||
if (is_array($namespace)) {
|
if (is_array($namespace)) {
|
||||||
foreach ($namespace as $prefix => $paths) {
|
foreach ($namespace as $prefix => $paths) {
|
||||||
self::addPsr4($prefix . '\\', rtrim($paths, '/'), true);
|
self::addPsr4($prefix . '\\', rtrim($paths, '/'), true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self::addPsr4($namespace . '\\', rtrim($path, '/'), true);
|
self::addPsr4($namespace . '\\', rtrim($path, '/'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加Psr4空间
|
// 添加Psr4空间
|
||||||
private static function addPsr4($prefix, $paths, $prepend = false)
|
private static function addPsr4($prefix, $paths, $prepend = false)
|
||||||
{
|
{
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
// Register directories for the root namespace.
|
// Register directories for the root namespace.
|
||||||
if ($prepend) {
|
if ($prepend) {
|
||||||
self::$fallbackDirsPsr4 = array_merge(
|
self::$fallbackDirsPsr4 = array_merge(
|
||||||
(array) $paths,
|
(array) $paths,
|
||||||
self::$fallbackDirsPsr4
|
self::$fallbackDirsPsr4
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
self::$fallbackDirsPsr4 = array_merge(
|
self::$fallbackDirsPsr4 = array_merge(
|
||||||
self::$fallbackDirsPsr4,
|
self::$fallbackDirsPsr4,
|
||||||
(array) $paths
|
(array) $paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} elseif (!isset(self::$prefixDirsPsr4[$prefix])) {
|
} elseif (!isset(self::$prefixDirsPsr4[$prefix])) {
|
||||||
// Register directories for a new namespace.
|
// Register directories for a new namespace.
|
||||||
$length = strlen($prefix);
|
$length = strlen($prefix);
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
if ('\\' !== $prefix[$length - 1]) {
|
||||||
throw dzz_error::system_error("A non-empty PSR-4 prefix must end with a namespace separator.");
|
throw dzz_error::system_error("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
}
|
}
|
||||||
self::$prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
self::$prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
self::$prefixDirsPsr4[$prefix] = (array) $paths;
|
self::$prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
} elseif ($prepend) {
|
} elseif ($prepend) {
|
||||||
// Prepend directories for an already registered namespace.
|
// Prepend directories for an already registered namespace.
|
||||||
self::$prefixDirsPsr4[$prefix] = array_merge(
|
self::$prefixDirsPsr4[$prefix] = array_merge(
|
||||||
(array) $paths,
|
(array) $paths,
|
||||||
self::$prefixDirsPsr4[$prefix]
|
self::$prefixDirsPsr4[$prefix]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Append directories for an already registered namespace.
|
// Append directories for an already registered namespace.
|
||||||
self::$prefixDirsPsr4[$prefix] = array_merge(
|
self::$prefixDirsPsr4[$prefix] = array_merge(
|
||||||
self::$prefixDirsPsr4[$prefix],
|
self::$prefixDirsPsr4[$prefix],
|
||||||
(array) $paths
|
(array) $paths
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function analysisStart($name){
|
public static function analysisStart($name){
|
||||||
$key = 'other';
|
$key = 'other';
|
||||||
if($name[0] === '#') {
|
if($name[0] === '#') {
|
||||||
list(, $key, $name) = explode('#', $name);
|
list(, $key, $name) = explode('#', $name);
|
||||||
}
|
}
|
||||||
if(!isset($_ENV['analysis'])) {
|
if(!isset($_ENV['analysis'])) {
|
||||||
$_ENV['analysis'] = array();
|
$_ENV['analysis'] = array();
|
||||||
}
|
}
|
||||||
if(!isset($_ENV['analysis'][$key])) {
|
if(!isset($_ENV['analysis'][$key])) {
|
||||||
$_ENV['analysis'][$key] = array();
|
$_ENV['analysis'][$key] = array();
|
||||||
$_ENV['analysis'][$key]['sum'] = 0;
|
$_ENV['analysis'][$key]['sum'] = 0;
|
||||||
}
|
}
|
||||||
$_ENV['analysis'][$key][$name]['start'] = microtime(TRUE);
|
$_ENV['analysis'][$key][$name]['start'] = microtime(TRUE);
|
||||||
$_ENV['analysis'][$key][$name]['start_memory_get_usage'] = memory_get_usage();
|
$_ENV['analysis'][$key][$name]['start_memory_get_usage'] = memory_get_usage();
|
||||||
$_ENV['analysis'][$key][$name]['start_memory_get_real_usage'] = memory_get_usage(true);
|
$_ENV['analysis'][$key][$name]['start_memory_get_real_usage'] = memory_get_usage(true);
|
||||||
$_ENV['analysis'][$key][$name]['start_memory_get_peak_usage'] = memory_get_peak_usage();
|
$_ENV['analysis'][$key][$name]['start_memory_get_peak_usage'] = memory_get_peak_usage();
|
||||||
$_ENV['analysis'][$key][$name]['start_memory_get_peak_real_usage'] = memory_get_peak_usage(true);
|
$_ENV['analysis'][$key][$name]['start_memory_get_peak_real_usage'] = memory_get_peak_usage(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function analysisStop($name) {
|
public static function analysisStop($name) {
|
||||||
$key = 'other';
|
$key = 'other';
|
||||||
if($name[0] === '#') {
|
if($name[0] === '#') {
|
||||||
list(, $key, $name) = explode('#', $name);
|
list(, $key, $name) = explode('#', $name);
|
||||||
}
|
}
|
||||||
if(isset($_ENV['analysis'][$key][$name]['start'])) {
|
if(isset($_ENV['analysis'][$key][$name]['start'])) {
|
||||||
$diff = round((microtime(TRUE) - $_ENV['analysis'][$key][$name]['start']) * 1000, 5);
|
$diff = round((microtime(TRUE) - $_ENV['analysis'][$key][$name]['start']) * 1000, 5);
|
||||||
$_ENV['analysis'][$key][$name]['time'] = $diff;
|
$_ENV['analysis'][$key][$name]['time'] = $diff;
|
||||||
$_ENV['analysis'][$key]['sum'] = $_ENV['analysis'][$key]['sum'] + $diff;
|
$_ENV['analysis'][$key]['sum'] = $_ENV['analysis'][$key]['sum'] + $diff;
|
||||||
unset($_ENV['analysis'][$key][$name]['start']);
|
unset($_ENV['analysis'][$key][$name]['start']);
|
||||||
$_ENV['analysis'][$key][$name]['stop_memory_get_usage'] = memory_get_usage();
|
$_ENV['analysis'][$key][$name]['stop_memory_get_usage'] = memory_get_usage();
|
||||||
$_ENV['analysis'][$key][$name]['stop_memory_get_real_usage'] = memory_get_usage(true);
|
$_ENV['analysis'][$key][$name]['stop_memory_get_real_usage'] = memory_get_usage(true);
|
||||||
$_ENV['analysis'][$key][$name]['stop_memory_get_peak_usage'] = memory_get_peak_usage();
|
$_ENV['analysis'][$key][$name]['stop_memory_get_peak_usage'] = memory_get_peak_usage();
|
||||||
$_ENV['analysis'][$key][$name]['stop_memory_get_peak_real_usage'] = memory_get_peak_usage(true);
|
$_ENV['analysis'][$key][$name]['stop_memory_get_peak_real_usage'] = memory_get_peak_usage(true);
|
||||||
}
|
}
|
||||||
return $_ENV['analysis'][$key][$name];
|
return $_ENV['analysis'][$key][$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loadConfig($file = null){
|
public static function loadConfig($file = null){
|
||||||
if($file && file_exists($file)){
|
if($file && file_exists($file)){
|
||||||
|
|
||||||
return include $file;
|
return include $file;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getConfig($name){
|
public static function getConfig($name){
|
||||||
|
|
||||||
global $_config;
|
global $_config;
|
||||||
|
|
||||||
return $_config[$name];
|
return $_config[$name];
|
||||||
}
|
}
|
||||||
public static function setConfig($name,$value = null){
|
public static function setConfig($name,$value = null){
|
||||||
|
|
||||||
global $_config;
|
global $_config;
|
||||||
|
|
||||||
if(is_string($name)){//单个设置
|
if(is_string($name)){//单个设置
|
||||||
|
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
|
|
||||||
$_config[$name] = $value;
|
$_config[$name] = $value;
|
||||||
|
|
||||||
}elseif(is_array($name)){//批量设置
|
}elseif(is_array($name)){//批量设置
|
||||||
|
|
||||||
$name = array_change_key_case($name,CASE_LOWER);
|
$name = array_change_key_case($name,CASE_LOWER);
|
||||||
|
|
||||||
foreach($name as $k=>$v){
|
foreach($name as $k=>$v){
|
||||||
|
|
||||||
$_config[$k] = $v;
|
$_config[$k] = $v;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static function getNamespaceDir($namespace = null){
|
public static function getNamespaceDir($namespace = null){
|
||||||
// 查找 PSR-4
|
// 查找 PSR-4
|
||||||
$logicalPathPsr4 = strtr($namespace, '\\', '/');
|
$logicalPathPsr4 = strtr($namespace, '\\', '/');
|
||||||
|
|
||||||
$first = $namespace[0];
|
$first = $namespace[0];
|
||||||
|
|
||||||
if (isset(self::$prefixLengthsPsr4[$first])) {
|
if (isset(self::$prefixLengthsPsr4[$first])) {
|
||||||
|
|
||||||
foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) {
|
foreach (self::$prefixLengthsPsr4[$first] as $prefix => $length) {
|
||||||
|
|
||||||
if (0 === strpos($namespace, $prefix)) {
|
if (0 === strpos($namespace, $prefix)) {
|
||||||
|
|
||||||
foreach (self::$prefixDirsPsr4[$prefix] as $dir) {
|
foreach (self::$prefixDirsPsr4[$prefix] as $dir) {
|
||||||
|
|
||||||
if (is_dir($realdir = $dir .BS .substr($logicalPathPsr4, $length))) {
|
if (is_dir($realdir = $dir .BS .substr($logicalPathPsr4, $length))) {
|
||||||
|
|
||||||
return $realdir;
|
return $realdir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,82 +1,82 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* PHP 汉字转拼音
|
* PHP 汉字转拼音
|
||||||
* @example
|
* @example
|
||||||
* echo pinyin::encode('乐云网络'); //编码为拼音首字母
|
* echo pinyin::encode('乐云网络'); //编码为拼音首字母
|
||||||
* echo pinyin::encode('乐云网络', 'all'); //编码为全拼音
|
* echo pinyin::encode('乐云网络', 'all'); //编码为全拼音
|
||||||
*/
|
*/
|
||||||
class pinyin {
|
class pinyin {
|
||||||
/**
|
/**
|
||||||
* 拼音字符转换图
|
* 拼音字符转换图
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private static $_aMaps = array(
|
private static $_aMaps = array(
|
||||||
'a'=>-20319,'ai'=>-20317,'an'=>-20304,'ang'=>-20295,'ao'=>-20292,
|
'a'=>-20319,'ai'=>-20317,'an'=>-20304,'ang'=>-20295,'ao'=>-20292,
|
||||||
'ba'=>-20283,'bai'=>-20265,'ban'=>-20257,'bang'=>-20242,'bao'=>-20230,'bei'=>-20051,'ben'=>-20036,'beng'=>-20032,'bi'=>-20026,'bian'=>-20002,'biao'=>-19990,'bie'=>-19986,'bin'=>-19982,'bing'=>-19976,'bo'=>-19805,'bu'=>-19784,
|
'ba'=>-20283,'bai'=>-20265,'ban'=>-20257,'bang'=>-20242,'bao'=>-20230,'bei'=>-20051,'ben'=>-20036,'beng'=>-20032,'bi'=>-20026,'bian'=>-20002,'biao'=>-19990,'bie'=>-19986,'bin'=>-19982,'bing'=>-19976,'bo'=>-19805,'bu'=>-19784,
|
||||||
'ca'=>-19775,'cai'=>-19774,'can'=>-19763,'cang'=>-19756,'cao'=>-19751,'ce'=>-19746,'ceng'=>-19741,'cha'=>-19739,'chai'=>-19728,'chan'=>-19725,'chang'=>-19715,'chao'=>-19540,'che'=>-19531,'chen'=>-19525,'cheng'=>-19515,'chi'=>-19500,'chong'=>-19484,'chou'=>-19479,'chu'=>-19467,'chuai'=>-19289,'chuan'=>-19288,'chuang'=>-19281,'chui'=>-19275,'chun'=>-19270,'chuo'=>-19263,'ci'=>-19261,'cong'=>-19249,'cou'=>-19243,'cu'=>-19242,'cuan'=>-19238,'cui'=>-19235,'cun'=>-19227,'cuo'=>-19224,
|
'ca'=>-19775,'cai'=>-19774,'can'=>-19763,'cang'=>-19756,'cao'=>-19751,'ce'=>-19746,'ceng'=>-19741,'cha'=>-19739,'chai'=>-19728,'chan'=>-19725,'chang'=>-19715,'chao'=>-19540,'che'=>-19531,'chen'=>-19525,'cheng'=>-19515,'chi'=>-19500,'chong'=>-19484,'chou'=>-19479,'chu'=>-19467,'chuai'=>-19289,'chuan'=>-19288,'chuang'=>-19281,'chui'=>-19275,'chun'=>-19270,'chuo'=>-19263,'ci'=>-19261,'cong'=>-19249,'cou'=>-19243,'cu'=>-19242,'cuan'=>-19238,'cui'=>-19235,'cun'=>-19227,'cuo'=>-19224,
|
||||||
'da'=>-19218,'dai'=>-19212,'dan'=>-19038,'dang'=>-19023,'dao'=>-19018,'de'=>-19006,'deng'=>-19003,'di'=>-18996,'dian'=>-18977,'diao'=>-18961,'die'=>-18952,'ding'=>-18783,'diu'=>-18774,'dong'=>-18773,'dou'=>-18763,'du'=>-18756,'duan'=>-18741,'dui'=>-18735,'dun'=>-18731,'duo'=>-18722,
|
'da'=>-19218,'dai'=>-19212,'dan'=>-19038,'dang'=>-19023,'dao'=>-19018,'de'=>-19006,'deng'=>-19003,'di'=>-18996,'dian'=>-18977,'diao'=>-18961,'die'=>-18952,'ding'=>-18783,'diu'=>-18774,'dong'=>-18773,'dou'=>-18763,'du'=>-18756,'duan'=>-18741,'dui'=>-18735,'dun'=>-18731,'duo'=>-18722,
|
||||||
'e'=>-18710,'en'=>-18697,'er'=>-18696,
|
'e'=>-18710,'en'=>-18697,'er'=>-18696,
|
||||||
'fa'=>-18526,'fan'=>-18518,'fang'=>-18501,'fei'=>-18490,'fen'=>-18478,'feng'=>-18463,'fo'=>-18448,'fou'=>-18447,'fu'=>-18446,
|
'fa'=>-18526,'fan'=>-18518,'fang'=>-18501,'fei'=>-18490,'fen'=>-18478,'feng'=>-18463,'fo'=>-18448,'fou'=>-18447,'fu'=>-18446,
|
||||||
'ga'=>-18239,'gai'=>-18237,'gan'=>-18231,'gang'=>-18220,'gao'=>-18211,'ge'=>-18201,'gei'=>-18184,'gen'=>-18183,'geng'=>-18181,'gong'=>-18012,'gou'=>-17997,'gu'=>-17988,'gua'=>-17970,'guai'=>-17964,'guan'=>-17961,'guang'=>-17950,'gui'=>-17947,'gun'=>-17931,'guo'=>-17928,
|
'ga'=>-18239,'gai'=>-18237,'gan'=>-18231,'gang'=>-18220,'gao'=>-18211,'ge'=>-18201,'gei'=>-18184,'gen'=>-18183,'geng'=>-18181,'gong'=>-18012,'gou'=>-17997,'gu'=>-17988,'gua'=>-17970,'guai'=>-17964,'guan'=>-17961,'guang'=>-17950,'gui'=>-17947,'gun'=>-17931,'guo'=>-17928,
|
||||||
'ha'=>-17922,'hai'=>-17759,'han'=>-17752,'hang'=>-17733,'hao'=>-17730,'he'=>-17721,'hei'=>-17703,'hen'=>-17701,'heng'=>-17697,'hong'=>-17692,'hou'=>-17683,'hu'=>-17676,'hua'=>-17496,'huai'=>-17487,'huan'=>-17482,'huang'=>-17468,'hui'=>-17454,'hun'=>-17433,'huo'=>-17427,
|
'ha'=>-17922,'hai'=>-17759,'han'=>-17752,'hang'=>-17733,'hao'=>-17730,'he'=>-17721,'hei'=>-17703,'hen'=>-17701,'heng'=>-17697,'hong'=>-17692,'hou'=>-17683,'hu'=>-17676,'hua'=>-17496,'huai'=>-17487,'huan'=>-17482,'huang'=>-17468,'hui'=>-17454,'hun'=>-17433,'huo'=>-17427,
|
||||||
'ji'=>-17417,'jia'=>-17202,'jian'=>-17185,'jiang'=>-16983,'jiao'=>-16970,'jie'=>-16942,'jin'=>-16915,'jing'=>-16733,'jiong'=>-16708,'jiu'=>-16706,'ju'=>-16689,'juan'=>-16664,'jue'=>-16657,'jun'=>-16647,
|
'ji'=>-17417,'jia'=>-17202,'jian'=>-17185,'jiang'=>-16983,'jiao'=>-16970,'jie'=>-16942,'jin'=>-16915,'jing'=>-16733,'jiong'=>-16708,'jiu'=>-16706,'ju'=>-16689,'juan'=>-16664,'jue'=>-16657,'jun'=>-16647,
|
||||||
'ka'=>-16474,'kai'=>-16470,'kan'=>-16465,'kang'=>-16459,'kao'=>-16452,'ke'=>-16448,'ken'=>-16433,'keng'=>-16429,'kong'=>-16427,'kou'=>-16423,'ku'=>-16419,'kua'=>-16412,'kuai'=>-16407,'kuan'=>-16403,'kuang'=>-16401,'kui'=>-16393,'kun'=>-16220,'kuo'=>-16216,
|
'ka'=>-16474,'kai'=>-16470,'kan'=>-16465,'kang'=>-16459,'kao'=>-16452,'ke'=>-16448,'ken'=>-16433,'keng'=>-16429,'kong'=>-16427,'kou'=>-16423,'ku'=>-16419,'kua'=>-16412,'kuai'=>-16407,'kuan'=>-16403,'kuang'=>-16401,'kui'=>-16393,'kun'=>-16220,'kuo'=>-16216,
|
||||||
'la'=>-16212,'lai'=>-16205,'lan'=>-16202,'lang'=>-16187,'lao'=>-16180,'le'=>-16171,'lei'=>-16169,'leng'=>-16158,'li'=>-16155,'lia'=>-15959,'lian'=>-15958,'liang'=>-15944,'liao'=>-15933,'lie'=>-15920,'lin'=>-15915,'ling'=>-15903,'liu'=>-15889,'long'=>-15878,'lou'=>-15707,'lu'=>-15701,'lv'=>-15681,'luan'=>-15667,'lue'=>-15661,'lun'=>-15659,'luo'=>-15652,
|
'la'=>-16212,'lai'=>-16205,'lan'=>-16202,'lang'=>-16187,'lao'=>-16180,'le'=>-16171,'lei'=>-16169,'leng'=>-16158,'li'=>-16155,'lia'=>-15959,'lian'=>-15958,'liang'=>-15944,'liao'=>-15933,'lie'=>-15920,'lin'=>-15915,'ling'=>-15903,'liu'=>-15889,'long'=>-15878,'lou'=>-15707,'lu'=>-15701,'lv'=>-15681,'luan'=>-15667,'lue'=>-15661,'lun'=>-15659,'luo'=>-15652,
|
||||||
'ma'=>-15640,'mai'=>-15631,'man'=>-15625,'mang'=>-15454,'mao'=>-15448,'me'=>-15436,'mei'=>-15435,'men'=>-15419,'meng'=>-15416,'mi'=>-15408,'mian'=>-15394,'miao'=>-15385,'mie'=>-15377,'min'=>-15375,'ming'=>-15369,'miu'=>-15363,'mo'=>-15362,'mou'=>-15183,'mu'=>-15180,
|
'ma'=>-15640,'mai'=>-15631,'man'=>-15625,'mang'=>-15454,'mao'=>-15448,'me'=>-15436,'mei'=>-15435,'men'=>-15419,'meng'=>-15416,'mi'=>-15408,'mian'=>-15394,'miao'=>-15385,'mie'=>-15377,'min'=>-15375,'ming'=>-15369,'miu'=>-15363,'mo'=>-15362,'mou'=>-15183,'mu'=>-15180,
|
||||||
'na'=>-15165,'nai'=>-15158,'nan'=>-15153,'nang'=>-15150,'nao'=>-15149,'ne'=>-15144,'nei'=>-15143,'nen'=>-15141,'neng'=>-15140,'ni'=>-15139,'nian'=>-15128,'niang'=>-15121,'niao'=>-15119,'nie'=>-15117,'nin'=>-15110,'ning'=>-15109,'niu'=>-14941,'nong'=>-14937,'nu'=>-14933,'nv'=>-14930,'nuan'=>-14929,'nue'=>-14928,'nuo'=>-14926,
|
'na'=>-15165,'nai'=>-15158,'nan'=>-15153,'nang'=>-15150,'nao'=>-15149,'ne'=>-15144,'nei'=>-15143,'nen'=>-15141,'neng'=>-15140,'ni'=>-15139,'nian'=>-15128,'niang'=>-15121,'niao'=>-15119,'nie'=>-15117,'nin'=>-15110,'ning'=>-15109,'niu'=>-14941,'nong'=>-14937,'nu'=>-14933,'nv'=>-14930,'nuan'=>-14929,'nue'=>-14928,'nuo'=>-14926,
|
||||||
'o'=>-14922,'ou'=>-14921,
|
'o'=>-14922,'ou'=>-14921,
|
||||||
'pa'=>-14914,'pai'=>-14908,'pan'=>-14902,'pang'=>-14894,'pao'=>-14889,'pei'=>-14882,'pen'=>-14873,'peng'=>-14871,'pi'=>-14857,'pian'=>-14678,'piao'=>-14674,'pie'=>-14670,'pin'=>-14668,'ping'=>-14663,'po'=>-14654,'pu'=>-14645,
|
'pa'=>-14914,'pai'=>-14908,'pan'=>-14902,'pang'=>-14894,'pao'=>-14889,'pei'=>-14882,'pen'=>-14873,'peng'=>-14871,'pi'=>-14857,'pian'=>-14678,'piao'=>-14674,'pie'=>-14670,'pin'=>-14668,'ping'=>-14663,'po'=>-14654,'pu'=>-14645,
|
||||||
'qi'=>-14630,'qia'=>-14594,'qian'=>-14429,'qiang'=>-14407,'qiao'=>-14399,'qie'=>-14384,'qin'=>-14379,'qing'=>-14368,'qiong'=>-14355,'qiu'=>-14353,'qu'=>-14345,'quan'=>-14170,'que'=>-14159,'qun'=>-14151,
|
'qi'=>-14630,'qia'=>-14594,'qian'=>-14429,'qiang'=>-14407,'qiao'=>-14399,'qie'=>-14384,'qin'=>-14379,'qing'=>-14368,'qiong'=>-14355,'qiu'=>-14353,'qu'=>-14345,'quan'=>-14170,'que'=>-14159,'qun'=>-14151,
|
||||||
'ran'=>-14149,'rang'=>-14145,'rao'=>-14140,'re'=>-14137,'ren'=>-14135,'reng'=>-14125,'ri'=>-14123,'rong'=>-14122,'rou'=>-14112,'ru'=>-14109,'ruan'=>-14099,'rui'=>-14097,'run'=>-14094,'ruo'=>-14092,
|
'ran'=>-14149,'rang'=>-14145,'rao'=>-14140,'re'=>-14137,'ren'=>-14135,'reng'=>-14125,'ri'=>-14123,'rong'=>-14122,'rou'=>-14112,'ru'=>-14109,'ruan'=>-14099,'rui'=>-14097,'run'=>-14094,'ruo'=>-14092,
|
||||||
'sa'=>-14090,'sai'=>-14087,'san'=>-14083,'sang'=>-13917,'sao'=>-13914,'se'=>-13910,'sen'=>-13907,'seng'=>-13906,'sha'=>-13905,'shai'=>-13896,'shan'=>-13894,'shang'=>-13878,'shao'=>-13870,'she'=>-13859,'shen'=>-13847,'sheng'=>-13831,'shi'=>-13658,'shou'=>-13611,'shu'=>-13601,'shua'=>-13406,'shuai'=>-13404,'shuan'=>-13400,'shuang'=>-13398,'shui'=>-13395,'shun'=>-13391,'shuo'=>-13387,'si'=>-13383,'song'=>-13367,'sou'=>-13359,'su'=>-13356,'suan'=>-13343,'sui'=>-13340,'sun'=>-13329,'suo'=>-13326,
|
'sa'=>-14090,'sai'=>-14087,'san'=>-14083,'sang'=>-13917,'sao'=>-13914,'se'=>-13910,'sen'=>-13907,'seng'=>-13906,'sha'=>-13905,'shai'=>-13896,'shan'=>-13894,'shang'=>-13878,'shao'=>-13870,'she'=>-13859,'shen'=>-13847,'sheng'=>-13831,'shi'=>-13658,'shou'=>-13611,'shu'=>-13601,'shua'=>-13406,'shuai'=>-13404,'shuan'=>-13400,'shuang'=>-13398,'shui'=>-13395,'shun'=>-13391,'shuo'=>-13387,'si'=>-13383,'song'=>-13367,'sou'=>-13359,'su'=>-13356,'suan'=>-13343,'sui'=>-13340,'sun'=>-13329,'suo'=>-13326,
|
||||||
'ta'=>-13318,'tai'=>-13147,'tan'=>-13138,'tang'=>-13120,'tao'=>-13107,'te'=>-13096,'teng'=>-13095,'ti'=>-13091,'tian'=>-13076,'tiao'=>-13068,'tie'=>-13063,'ting'=>-13060,'tong'=>-12888,'tou'=>-12875,'tu'=>-12871,'tuan'=>-12860,'tui'=>-12858,'tun'=>-12852,'tuo'=>-12849,
|
'ta'=>-13318,'tai'=>-13147,'tan'=>-13138,'tang'=>-13120,'tao'=>-13107,'te'=>-13096,'teng'=>-13095,'ti'=>-13091,'tian'=>-13076,'tiao'=>-13068,'tie'=>-13063,'ting'=>-13060,'tong'=>-12888,'tou'=>-12875,'tu'=>-12871,'tuan'=>-12860,'tui'=>-12858,'tun'=>-12852,'tuo'=>-12849,
|
||||||
'wa'=>-12838,'wai'=>-12831,'wan'=>-12829,'wang'=>-12812,'wei'=>-12802,'wen'=>-12607,'weng'=>-12597,'wo'=>-12594,'wu'=>-12585,
|
'wa'=>-12838,'wai'=>-12831,'wan'=>-12829,'wang'=>-12812,'wei'=>-12802,'wen'=>-12607,'weng'=>-12597,'wo'=>-12594,'wu'=>-12585,
|
||||||
'xi'=>-12556,'xia'=>-12359,'xian'=>-12346,'xiang'=>-12320,'xiao'=>-12300,'xie'=>-12120,'xin'=>-12099,'xing'=>-12089,'xiong'=>-12074,'xiu'=>-12067,'xu'=>-12058,'xuan'=>-12039,'xue'=>-11867,'xun'=>-11861,
|
'xi'=>-12556,'xia'=>-12359,'xian'=>-12346,'xiang'=>-12320,'xiao'=>-12300,'xie'=>-12120,'xin'=>-12099,'xing'=>-12089,'xiong'=>-12074,'xiu'=>-12067,'xu'=>-12058,'xuan'=>-12039,'xue'=>-11867,'xun'=>-11861,
|
||||||
'ya'=>-11847,'yan'=>-11831,'yang'=>-11798,'yao'=>-11781,'ye'=>-11604,'yi'=>-11589,'yin'=>-11536,'ying'=>-11358,'yo'=>-11340,'yong'=>-11339,'you'=>-11324,'yu'=>-11303,'yuan'=>-11097,'yue'=>-11077,'yun'=>-11067,
|
'ya'=>-11847,'yan'=>-11831,'yang'=>-11798,'yao'=>-11781,'ye'=>-11604,'yi'=>-11589,'yin'=>-11536,'ying'=>-11358,'yo'=>-11340,'yong'=>-11339,'you'=>-11324,'yu'=>-11303,'yuan'=>-11097,'yue'=>-11077,'yun'=>-11067,
|
||||||
'za'=>-11055,'zai'=>-11052,'zan'=>-11045,'zang'=>-11041,'zao'=>-11038,'ze'=>-11024,'zei'=>-11020,'zen'=>-11019,'zeng'=>-11018,'zha'=>-11014,'zhai'=>-10838,'zhan'=>-10832,'zhang'=>-10815,'zhao'=>-10800,'zhe'=>-10790,'zhen'=>-10780,'zheng'=>-10764,'zhi'=>-10587,'zhong'=>-10544,'zhou'=>-10533,'zhu'=>-10519,'zhua'=>-10331,'zhuai'=>-10329,'zhuan'=>-10328,'zhuang'=>-10322,'zhui'=>-10315,'zhun'=>-10309,'zhuo'=>-10307,'zi'=>-10296,'zong'=>-10281,'zou'=>-10274,'zu'=>-10270,'zuan'=>-10262,'zui'=>-10260,'zun'=>-10256,'zuo'=>-10254
|
'za'=>-11055,'zai'=>-11052,'zan'=>-11045,'zang'=>-11041,'zao'=>-11038,'ze'=>-11024,'zei'=>-11020,'zen'=>-11019,'zeng'=>-11018,'zha'=>-11014,'zhai'=>-10838,'zhan'=>-10832,'zhang'=>-10815,'zhao'=>-10800,'zhe'=>-10790,'zhen'=>-10780,'zheng'=>-10764,'zhi'=>-10587,'zhong'=>-10544,'zhou'=>-10533,'zhu'=>-10519,'zhua'=>-10331,'zhuai'=>-10329,'zhuan'=>-10328,'zhuang'=>-10322,'zhui'=>-10315,'zhun'=>-10309,'zhuo'=>-10307,'zi'=>-10296,'zong'=>-10281,'zou'=>-10274,'zu'=>-10270,'zuan'=>-10262,'zui'=>-10260,'zun'=>-10256,'zuo'=>-10254
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将中文编码成拼音
|
* 将中文编码成拼音
|
||||||
* @param string $utf8Data utf8字符集数据
|
* @param string $utf8Data utf8字符集数据
|
||||||
* @param string $sRetFormat 返回格式 [head:首字母|all:全拼音]
|
* @param string $sRetFormat 返回格式 [head:首字母|all:全拼音]
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function encode($utf8Data, $sRetFormat='head'){
|
public static function encode($utf8Data, $sRetFormat='head'){
|
||||||
$sGBK = iconv('UTF-8', 'GBK', $utf8Data);
|
$sGBK = iconv('UTF-8', 'GBK', $utf8Data);
|
||||||
$aBuf = array();
|
$aBuf = array();
|
||||||
for ($i=0, $iLoop=strlen($sGBK); $i<$iLoop; $i++) {
|
for ($i=0, $iLoop=strlen($sGBK); $i<$iLoop; $i++) {
|
||||||
$iChr = ord($sGBK{$i});
|
$iChr = ord($sGBK{$i});
|
||||||
if ($iChr>160)
|
if ($iChr>160)
|
||||||
$iChr = ($iChr<<8) + ord($sGBK{++$i}) - 65536;
|
$iChr = ($iChr<<8) + ord($sGBK{++$i}) - 65536;
|
||||||
if ('head' === $sRetFormat)
|
if ('head' === $sRetFormat)
|
||||||
$aBuf[] = substr(self::zh2py($iChr),0,1);
|
$aBuf[] = substr(self::zh2py($iChr),0,1);
|
||||||
else
|
else
|
||||||
$aBuf[] = self::zh2py($iChr);
|
$aBuf[] = self::zh2py($iChr);
|
||||||
}
|
}
|
||||||
if ('head' === $sRetFormat)
|
if ('head' === $sRetFormat)
|
||||||
return implode('', $aBuf);
|
return implode('', $aBuf);
|
||||||
else
|
else
|
||||||
return implode(' ', $aBuf);
|
return implode(' ', $aBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 中文转换到拼音(每次处理一个字符)
|
* 中文转换到拼音(每次处理一个字符)
|
||||||
* @param number $iWORD 待处理字符双字节
|
* @param number $iWORD 待处理字符双字节
|
||||||
* @return string 拼音
|
* @return string 拼音
|
||||||
*/
|
*/
|
||||||
private static function zh2py($iWORD) {
|
private static function zh2py($iWORD) {
|
||||||
if($iWORD>0 && $iWORD<160 ) {
|
if($iWORD>0 && $iWORD<160 ) {
|
||||||
return chr($iWORD);
|
return chr($iWORD);
|
||||||
} elseif ($iWORD<-20319||$iWORD>-10247) {
|
} elseif ($iWORD<-20319||$iWORD>-10247) {
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
foreach (self::$_aMaps as $py => $code) {
|
foreach (self::$_aMaps as $py => $code) {
|
||||||
if($code > $iWORD) break;
|
if($code > $iWORD) break;
|
||||||
$result = $py;
|
$result = $py;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,459 +1,459 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class seccode {
|
class seccode {
|
||||||
|
|
||||||
var $code;
|
var $code;
|
||||||
var $type = 0;
|
var $type = 0;
|
||||||
var $width = 150;
|
var $width = 150;
|
||||||
var $height = 60;
|
var $height = 60;
|
||||||
var $background = 1;
|
var $background = 1;
|
||||||
var $adulterate = 1;
|
var $adulterate = 1;
|
||||||
var $ttf = 0;
|
var $ttf = 0;
|
||||||
var $angle = 0;
|
var $angle = 0;
|
||||||
var $warping = 0;
|
var $warping = 0;
|
||||||
var $scatter = 0;
|
var $scatter = 0;
|
||||||
var $color = 1;
|
var $color = 1;
|
||||||
var $size = 0;
|
var $size = 0;
|
||||||
var $shadow = 1;
|
var $shadow = 1;
|
||||||
var $animator = 0;
|
var $animator = 0;
|
||||||
var $fontpath = '';
|
var $fontpath = '';
|
||||||
var $datapath = '';
|
var $datapath = '';
|
||||||
var $includepath= '';
|
var $includepath= '';
|
||||||
|
|
||||||
var $fontcolor;
|
var $fontcolor;
|
||||||
var $im;
|
var $im;
|
||||||
|
|
||||||
function display() {
|
function display() {
|
||||||
$this->type == 2 && !extension_loaded('ming') && $this->type = 0;
|
$this->type == 2 && !extension_loaded('ming') && $this->type = 0;
|
||||||
if($this->type < 2 && function_exists('imagecreate') && function_exists('imagecolorset') && function_exists('imagecopyresized') &&
|
if($this->type < 2 && function_exists('imagecreate') && function_exists('imagecolorset') && function_exists('imagecopyresized') &&
|
||||||
function_exists('imagecolorallocate') && function_exists('imagechar') && function_exists('imagecolorsforindex') &&
|
function_exists('imagecolorallocate') && function_exists('imagechar') && function_exists('imagecolorsforindex') &&
|
||||||
function_exists('imageline') && function_exists('imagecreatefromstring') && (function_exists('imagegif') || function_exists('imagepng') || function_exists('imagejpeg'))) {
|
function_exists('imageline') && function_exists('imagecreatefromstring') && (function_exists('imagegif') || function_exists('imagepng') || function_exists('imagejpeg'))) {
|
||||||
$this->image();
|
$this->image();
|
||||||
} elseif($this->type == 2 && extension_loaded('ming')) {
|
} elseif($this->type == 2 && extension_loaded('ming')) {
|
||||||
$this->flash();
|
$this->flash();
|
||||||
} elseif($this->type == 3) {
|
} elseif($this->type == 3) {
|
||||||
$this->audio();
|
$this->audio();
|
||||||
} else {
|
} else {
|
||||||
$this->bitmap();
|
$this->bitmap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function image() {
|
function image() {
|
||||||
$bgcontent = $this->background();
|
$bgcontent = $this->background();
|
||||||
|
|
||||||
if($this->animator == 1 && function_exists('imagegif')) {
|
if($this->animator == 1 && function_exists('imagegif')) {
|
||||||
include_once $this->includepath.'class_gifmerge.php';
|
include_once $this->includepath.'class_gifmerge.php';
|
||||||
$trueframe = mt_rand(1, 9);
|
$trueframe = mt_rand(1, 9);
|
||||||
|
|
||||||
for($i = 0; $i <= 9; $i++) {
|
for($i = 0; $i <= 9; $i++) {
|
||||||
$this->im = imagecreatefromstring($bgcontent);
|
$this->im = imagecreatefromstring($bgcontent);
|
||||||
$x[$i] = $y[$i] = 0;
|
$x[$i] = $y[$i] = 0;
|
||||||
$this->adulterate && $this->adulterate();
|
$this->adulterate && $this->adulterate();
|
||||||
if($i == $trueframe) {
|
if($i == $trueframe) {
|
||||||
$this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();
|
$this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();
|
||||||
$d[$i] = mt_rand(250, 400);
|
$d[$i] = mt_rand(250, 400);
|
||||||
$this->scatter && $this->scatter($this->im);
|
$this->scatter && $this->scatter($this->im);
|
||||||
} else {
|
} else {
|
||||||
$this->adulteratefont();
|
$this->adulteratefont();
|
||||||
$d[$i] = mt_rand(5, 15);
|
$d[$i] = mt_rand(5, 15);
|
||||||
$this->scatter && $this->scatter($this->im, 1);
|
$this->scatter && $this->scatter($this->im, 1);
|
||||||
}
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
imagegif($this->im);
|
imagegif($this->im);
|
||||||
imagedestroy($this->im);
|
imagedestroy($this->im);
|
||||||
$frame[$i] = ob_get_contents();
|
$frame[$i] = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
$anim = new GifMerge($frame, 255, 255, 255, 0, $d, $x, $y, 'C_MEMORY');
|
$anim = new GifMerge($frame, 255, 255, 255, 0, $d, $x, $y, 'C_MEMORY');
|
||||||
header('Content-type: image/gif');
|
header('Content-type: image/gif');
|
||||||
echo $anim->getAnimation();
|
echo $anim->getAnimation();
|
||||||
} else {
|
} else {
|
||||||
$this->im = imagecreatefromstring($bgcontent);
|
$this->im = imagecreatefromstring($bgcontent);
|
||||||
$this->adulterate && $this->adulterate();
|
$this->adulterate && $this->adulterate();
|
||||||
$this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();
|
$this->ttf && function_exists('imagettftext') || $this->type == 1 ? $this->ttffont() : $this->giffont();
|
||||||
$this->scatter && $this->scatter($this->im);
|
$this->scatter && $this->scatter($this->im);
|
||||||
|
|
||||||
if(function_exists('imagepng')) {
|
if(function_exists('imagepng')) {
|
||||||
header('Content-type: image/png');
|
header('Content-type: image/png');
|
||||||
imagepng($this->im);
|
imagepng($this->im);
|
||||||
} else {
|
} else {
|
||||||
header('Content-type: image/jpeg');
|
header('Content-type: image/jpeg');
|
||||||
imagejpeg($this->im, '', 100);
|
imagejpeg($this->im, '', 100);
|
||||||
}
|
}
|
||||||
imagedestroy($this->im);
|
imagedestroy($this->im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function background() {
|
function background() {
|
||||||
$this->im = imagecreatetruecolor($this->width, $this->height);
|
$this->im = imagecreatetruecolor($this->width, $this->height);
|
||||||
$backgrounds = $c = array();
|
$backgrounds = $c = array();
|
||||||
if($this->background && function_exists('imagecreatefromjpeg') && function_exists('imagecolorat') && function_exists('imagecopymerge') &&
|
if($this->background && function_exists('imagecreatefromjpeg') && function_exists('imagecolorat') && function_exists('imagecopymerge') &&
|
||||||
function_exists('imagesetpixel') && function_exists('imageSX') && function_exists('imageSY')) {
|
function_exists('imagesetpixel') && function_exists('imageSX') && function_exists('imageSY')) {
|
||||||
if($handle = @opendir($this->datapath.'background/')) {
|
if($handle = @opendir($this->datapath.'background/')) {
|
||||||
while($bgfile = @readdir($handle)) {
|
while($bgfile = @readdir($handle)) {
|
||||||
if(preg_match('/\.jpg$/i', $bgfile)) {
|
if(preg_match('/\.jpg$/i', $bgfile)) {
|
||||||
$backgrounds[] = $this->datapath.'background/'.$bgfile;
|
$backgrounds[] = $this->datapath.'background/'.$bgfile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@closedir($handle);
|
@closedir($handle);
|
||||||
}
|
}
|
||||||
if($backgrounds) {
|
if($backgrounds) {
|
||||||
$imwm = imagecreatefromjpeg($backgrounds[array_rand($backgrounds)]);
|
$imwm = imagecreatefromjpeg($backgrounds[array_rand($backgrounds)]);
|
||||||
$colorindex = imagecolorat($imwm, 0, 0);
|
$colorindex = imagecolorat($imwm, 0, 0);
|
||||||
$c = imagecolorsforindex($imwm, $colorindex);
|
$c = imagecolorsforindex($imwm, $colorindex);
|
||||||
$colorindex = imagecolorat($imwm, 1, 0);
|
$colorindex = imagecolorat($imwm, 1, 0);
|
||||||
imagesetpixel($imwm, 0, 0, $colorindex);
|
imagesetpixel($imwm, 0, 0, $colorindex);
|
||||||
$c[0] = $c['red'];$c[1] = $c['green'];$c[2] = $c['blue'];
|
$c[0] = $c['red'];$c[1] = $c['green'];$c[2] = $c['blue'];
|
||||||
imagecopymerge($this->im, $imwm, 0, 0, mt_rand(0, 200 - $this->width), mt_rand(0, 80 - $this->height), imageSX($imwm), imageSY($imwm), 100);
|
imagecopymerge($this->im, $imwm, 0, 0, mt_rand(0, 200 - $this->width), mt_rand(0, 80 - $this->height), imageSX($imwm), imageSY($imwm), 100);
|
||||||
imagedestroy($imwm);
|
imagedestroy($imwm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$this->background || !$backgrounds) {
|
if(!$this->background || !$backgrounds) {
|
||||||
for($i = 0;$i < 3;$i++) {
|
for($i = 0;$i < 3;$i++) {
|
||||||
$start[$i] = mt_rand(200, 255);$end[$i] = mt_rand(100, 150);$step[$i] = ($end[$i] - $start[$i]) / $this->width;$c[$i] = $start[$i];
|
$start[$i] = mt_rand(200, 255);$end[$i] = mt_rand(100, 150);$step[$i] = ($end[$i] - $start[$i]) / $this->width;$c[$i] = $start[$i];
|
||||||
}
|
}
|
||||||
for($i = 0;$i < $this->width;$i++) {
|
for($i = 0;$i < $this->width;$i++) {
|
||||||
$color = imagecolorallocate($this->im, $c[0], $c[1], $c[2]);
|
$color = imagecolorallocate($this->im, $c[0], $c[1], $c[2]);
|
||||||
imageline($this->im, $i, 0, $i, $this->height, $color);
|
imageline($this->im, $i, 0, $i, $this->height, $color);
|
||||||
$c[0] += $step[0];$c[1] += $step[1];$c[2] += $step[2];
|
$c[0] += $step[0];$c[1] += $step[1];$c[2] += $step[2];
|
||||||
}
|
}
|
||||||
$c[0] -= 20;$c[1] -= 20;$c[2] -= 20;
|
$c[0] -= 20;$c[1] -= 20;$c[2] -= 20;
|
||||||
}
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
if(function_exists('imagepng')) {
|
if(function_exists('imagepng')) {
|
||||||
imagepng($this->im);
|
imagepng($this->im);
|
||||||
} else {
|
} else {
|
||||||
imagejpeg($this->im, '', 100);
|
imagejpeg($this->im, '', 100);
|
||||||
}
|
}
|
||||||
imagedestroy($this->im);
|
imagedestroy($this->im);
|
||||||
$bgcontent = ob_get_contents();
|
$bgcontent = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$this->fontcolor = $c;
|
$this->fontcolor = $c;
|
||||||
return $bgcontent;
|
return $bgcontent;
|
||||||
}
|
}
|
||||||
|
|
||||||
function adulterate() {
|
function adulterate() {
|
||||||
$linenums = $this->height / 10;
|
$linenums = $this->height / 10;
|
||||||
for($i = 0; $i <= $linenums;$i++) {
|
for($i = 0; $i <= $linenums;$i++) {
|
||||||
$color = $this->color ? imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)) : imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
$color = $this->color ? imagecolorallocate($this->im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)) : imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
||||||
$x = mt_rand(0, $this->width);
|
$x = mt_rand(0, $this->width);
|
||||||
$y = mt_rand(0, $this->height);
|
$y = mt_rand(0, $this->height);
|
||||||
if(mt_rand(0, 1)) {
|
if(mt_rand(0, 1)) {
|
||||||
$w = mt_rand(0, $this->width);
|
$w = mt_rand(0, $this->width);
|
||||||
$h = mt_rand(0, $this->height);
|
$h = mt_rand(0, $this->height);
|
||||||
$s = mt_rand(0, 360);
|
$s = mt_rand(0, 360);
|
||||||
$e = mt_rand(0, 360);
|
$e = mt_rand(0, 360);
|
||||||
for($j = 0;$j < 3;$j++) {
|
for($j = 0;$j < 3;$j++) {
|
||||||
imagearc($this->im, $x + $j, $y, $w, $h, $s, $e, $color);
|
imagearc($this->im, $x + $j, $y, $w, $h, $s, $e, $color);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$xe = mt_rand(0, $this->width);
|
$xe = mt_rand(0, $this->width);
|
||||||
$ye = mt_rand(0, $this->height);
|
$ye = mt_rand(0, $this->height);
|
||||||
imageline($this->im, $x, $y, $xe, $ye, $color);
|
imageline($this->im, $x, $y, $xe, $ye, $color);
|
||||||
for($j = 0;$j < 3;$j++) {
|
for($j = 0;$j < 3;$j++) {
|
||||||
imageline($this->im, $x + $j, $y, $xe, $ye, $color);
|
imageline($this->im, $x + $j, $y, $xe, $ye, $color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function adulteratefont() {
|
function adulteratefont() {
|
||||||
$seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
|
$seccodeunits = 'BCEFGHJKMPQRTVWXY2346789';
|
||||||
$x = $this->width / 4;
|
$x = $this->width / 4;
|
||||||
$y = $this->height / 10;
|
$y = $this->height / 10;
|
||||||
$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
||||||
for($i = 0; $i <= 3; $i++) {
|
for($i = 0; $i <= 3; $i++) {
|
||||||
$adulteratecode = $seccodeunits[mt_rand(0, 23)];
|
$adulteratecode = $seccodeunits[mt_rand(0, 23)];
|
||||||
imagechar($this->im, 5, $x * $i + mt_rand(0, $x - 10), mt_rand($y, $this->height - 10 - $y), $adulteratecode, $text_color);
|
imagechar($this->im, 5, $x * $i + mt_rand(0, $x - 10), mt_rand($y, $this->height - 10 - $y), $adulteratecode, $text_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ttffont() {
|
function ttffont() {
|
||||||
$seccode = $this->code;
|
$seccode = $this->code;
|
||||||
$seccoderoot = $this->type ? $this->fontpath.'ch/' : $this->fontpath.'en/';
|
$seccoderoot = $this->type ? $this->fontpath.'ch/' : $this->fontpath.'en/';
|
||||||
$dirs = opendir($seccoderoot);
|
$dirs = opendir($seccoderoot);
|
||||||
$seccodettf = array();
|
$seccodettf = array();
|
||||||
while($entry = readdir($dirs)) {
|
while($entry = readdir($dirs)) {
|
||||||
if($entry != '.' && $entry != '..' && in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
|
if($entry != '.' && $entry != '..' && in_array(strtolower(fileext($entry)), array('ttf', 'ttc'))) {
|
||||||
$seccodettf[] = $entry;
|
$seccodettf[] = $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(empty($seccodettf)) {
|
if(empty($seccodettf)) {
|
||||||
$this->giffont();
|
$this->giffont();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$seccodelength = 4;
|
$seccodelength = 4;
|
||||||
if($this->type && !empty($seccodettf)) {
|
if($this->type && !empty($seccodettf)) {
|
||||||
if(strtoupper(CHARSET) != 'UTF-8') {
|
if(strtoupper(CHARSET) != 'UTF-8') {
|
||||||
include $this->includepath.'class_chinese.php';
|
include $this->includepath.'class_chinese.php';
|
||||||
$cvt = new Chinese(CHARSET, 'utf8');
|
$cvt = new Chinese(CHARSET, 'utf8');
|
||||||
$seccode = $cvt->Convert($seccode);
|
$seccode = $cvt->Convert($seccode);
|
||||||
}
|
}
|
||||||
$seccode = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
|
$seccode = array(substr($seccode, 0, 3), substr($seccode, 3, 3));
|
||||||
$seccodelength = 2;
|
$seccodelength = 2;
|
||||||
}
|
}
|
||||||
$widthtotal = 0;
|
$widthtotal = 0;
|
||||||
for($i = 0; $i < $seccodelength; $i++) {
|
for($i = 0; $i < $seccodelength; $i++) {
|
||||||
$font[$i]['font'] = $seccoderoot.$seccodettf[array_rand($seccodettf)];
|
$font[$i]['font'] = $seccoderoot.$seccodettf[array_rand($seccodettf)];
|
||||||
$font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0;
|
$font[$i]['angle'] = $this->angle ? mt_rand(-30, 30) : 0;
|
||||||
$font[$i]['size'] = $this->type ? $this->width / 7 : $this->width / 6;
|
$font[$i]['size'] = $this->type ? $this->width / 7 : $this->width / 6;
|
||||||
$this->size && $font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20);
|
$this->size && $font[$i]['size'] = mt_rand($font[$i]['size'] - $this->width / 40, $font[$i]['size'] + $this->width / 20);
|
||||||
$box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]);
|
$box = imagettfbbox($font[$i]['size'], 0, $font[$i]['font'], $seccode[$i]);
|
||||||
$font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]);
|
$font[$i]['zheight'] = max($box[1], $box[3]) - min($box[5], $box[7]);
|
||||||
$box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]);
|
$box = imagettfbbox($font[$i]['size'], $font[$i]['angle'], $font[$i]['font'], $seccode[$i]);
|
||||||
$font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]);
|
$font[$i]['height'] = max($box[1], $box[3]) - min($box[5], $box[7]);
|
||||||
$font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight'];
|
$font[$i]['hd'] = $font[$i]['height'] - $font[$i]['zheight'];
|
||||||
$font[$i]['width'] = (max($box[2], $box[4]) - min($box[0], $box[6])) + mt_rand(0, $this->width / 8);
|
$font[$i]['width'] = (max($box[2], $box[4]) - min($box[0], $box[6])) + mt_rand(0, $this->width / 8);
|
||||||
$font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width'];
|
$font[$i]['width'] = $font[$i]['width'] > $this->width / $seccodelength ? $this->width / $seccodelength : $font[$i]['width'];
|
||||||
$widthtotal += $font[$i]['width'];
|
$widthtotal += $font[$i]['width'];
|
||||||
}
|
}
|
||||||
$x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal);
|
$x = mt_rand($font[0]['angle'] > 0 ? cos(deg2rad(90 - $font[0]['angle'])) * $font[0]['zheight'] : 1, $this->width - $widthtotal);
|
||||||
!$this->color && $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
!$this->color && $text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
||||||
for($i = 0; $i < $seccodelength; $i++) {
|
for($i = 0; $i < $seccodelength; $i++) {
|
||||||
if($this->color) {
|
if($this->color) {
|
||||||
$this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
|
$this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
|
||||||
$this->shadow && $text_shadowcolor = imagecolorallocate($this->im, 0, 0, 0);
|
$this->shadow && $text_shadowcolor = imagecolorallocate($this->im, 0, 0, 0);
|
||||||
$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
||||||
} elseif($this->shadow) {
|
} elseif($this->shadow) {
|
||||||
$text_shadowcolor = imagecolorallocate($this->im, 0, 0, 0);
|
$text_shadowcolor = imagecolorallocate($this->im, 0, 0, 0);
|
||||||
}
|
}
|
||||||
$y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']);
|
$y = $font[0]['angle'] > 0 ? mt_rand($font[$i]['height'], $this->height) : mt_rand($font[$i]['height'] - $font[$i]['hd'], $this->height - $font[$i]['hd']);
|
||||||
$this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]);
|
$this->shadow && imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x + 1, $y + 1, $text_shadowcolor, $font[$i]['font'], $seccode[$i]);
|
||||||
imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]);
|
imagettftext($this->im, $font[$i]['size'], $font[$i]['angle'], $x, $y, $text_color, $font[$i]['font'], $seccode[$i]);
|
||||||
$x += $font[$i]['width'];
|
$x += $font[$i]['width'];
|
||||||
}
|
}
|
||||||
$this->warping && $this->warping($this->im);
|
$this->warping && $this->warping($this->im);
|
||||||
}
|
}
|
||||||
|
|
||||||
function warping(&$obj) {
|
function warping(&$obj) {
|
||||||
$rgb = array();
|
$rgb = array();
|
||||||
$direct = rand(0, 1);
|
$direct = rand(0, 1);
|
||||||
$width = imagesx($obj);
|
$width = imagesx($obj);
|
||||||
$height = imagesy($obj);
|
$height = imagesy($obj);
|
||||||
$level = $width / 20;
|
$level = $width / 20;
|
||||||
for($j = 0;$j < $height;$j++) {
|
for($j = 0;$j < $height;$j++) {
|
||||||
for($i = 0;$i < $width;$i++) {
|
for($i = 0;$i < $width;$i++) {
|
||||||
$rgb[$i] = imagecolorat($obj, $i , $j);
|
$rgb[$i] = imagecolorat($obj, $i , $j);
|
||||||
}
|
}
|
||||||
for($i = 0;$i < $width;$i++) {
|
for($i = 0;$i < $width;$i++) {
|
||||||
$r = sin($j / $height * 2 * M_PI - M_PI * 0.5) * ($direct ? $level : -$level);
|
$r = sin($j / $height * 2 * M_PI - M_PI * 0.5) * ($direct ? $level : -$level);
|
||||||
imagesetpixel($obj, $i + $r , $j , $rgb[$i]);
|
imagesetpixel($obj, $i + $r , $j , $rgb[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scatter(&$obj, $level = 0) {
|
function scatter(&$obj, $level = 0) {
|
||||||
$rgb = array();
|
$rgb = array();
|
||||||
$this->scatter = $level ? $level : $this->scatter;
|
$this->scatter = $level ? $level : $this->scatter;
|
||||||
$width = imagesx($obj);
|
$width = imagesx($obj);
|
||||||
$height = imagesy($obj);
|
$height = imagesy($obj);
|
||||||
for($j = 0;$j < $height;$j++) {
|
for($j = 0;$j < $height;$j++) {
|
||||||
for($i = 0;$i < $width;$i++) {
|
for($i = 0;$i < $width;$i++) {
|
||||||
$rgb[$i] = imagecolorat($obj, $i , $j);
|
$rgb[$i] = imagecolorat($obj, $i , $j);
|
||||||
}
|
}
|
||||||
for($i = 0;$i < $width;$i++) {
|
for($i = 0;$i < $width;$i++) {
|
||||||
$r = rand(-$this->scatter, $this->scatter);
|
$r = rand(-$this->scatter, $this->scatter);
|
||||||
imagesetpixel($obj, $i + $r , $j , $rgb[$i]);
|
imagesetpixel($obj, $i + $r , $j , $rgb[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function giffont() {
|
function giffont() {
|
||||||
$seccode = $this->code;
|
$seccode = $this->code;
|
||||||
$seccodedir = array();
|
$seccodedir = array();
|
||||||
if(function_exists('imagecreatefromgif')) {
|
if(function_exists('imagecreatefromgif')) {
|
||||||
$seccoderoot = $this->datapath.'gif/';
|
$seccoderoot = $this->datapath.'gif/';
|
||||||
$dirs = opendir($seccoderoot);
|
$dirs = opendir($seccoderoot);
|
||||||
while($dir = readdir($dirs)) {
|
while($dir = readdir($dirs)) {
|
||||||
if($dir != '.' && $dir != '..' && file_exists($seccoderoot.$dir.'/9.gif')) {
|
if($dir != '.' && $dir != '..' && file_exists($seccoderoot.$dir.'/9.gif')) {
|
||||||
$seccodedir[] = $dir;
|
$seccodedir[] = $dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$widthtotal = 0;
|
$widthtotal = 0;
|
||||||
for($i = 0; $i <= 3; $i++) {
|
for($i = 0; $i <= 3; $i++) {
|
||||||
$this->imcodefile = $seccodedir ? $seccoderoot.$seccodedir[array_rand($seccodedir)].'/'.strtolower($seccode[$i]).'.gif' : '';
|
$this->imcodefile = $seccodedir ? $seccoderoot.$seccodedir[array_rand($seccodedir)].'/'.strtolower($seccode[$i]).'.gif' : '';
|
||||||
if(!empty($this->imcodefile) && file_exists($this->imcodefile)) {
|
if(!empty($this->imcodefile) && file_exists($this->imcodefile)) {
|
||||||
$font[$i]['file'] = $this->imcodefile;
|
$font[$i]['file'] = $this->imcodefile;
|
||||||
$font[$i]['data'] = getimagesize($this->imcodefile);
|
$font[$i]['data'] = getimagesize($this->imcodefile);
|
||||||
$font[$i]['width'] = $font[$i]['data'][0] + mt_rand(0, 6) - 4;
|
$font[$i]['width'] = $font[$i]['data'][0] + mt_rand(0, 6) - 4;
|
||||||
$font[$i]['height'] = $font[$i]['data'][1] + mt_rand(0, 6) - 4;
|
$font[$i]['height'] = $font[$i]['data'][1] + mt_rand(0, 6) - 4;
|
||||||
$font[$i]['width'] += mt_rand(0, $this->width / 5 - $font[$i]['width']);
|
$font[$i]['width'] += mt_rand(0, $this->width / 5 - $font[$i]['width']);
|
||||||
$widthtotal += $font[$i]['width'];
|
$widthtotal += $font[$i]['width'];
|
||||||
} else {
|
} else {
|
||||||
$font[$i]['file'] = '';
|
$font[$i]['file'] = '';
|
||||||
$font[$i]['width'] = 8 + mt_rand(0, $this->width / 5 - 5);
|
$font[$i]['width'] = 8 + mt_rand(0, $this->width / 5 - 5);
|
||||||
$widthtotal += $font[$i]['width'];
|
$widthtotal += $font[$i]['width'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$x = mt_rand(1, $this->width - $widthtotal);
|
$x = mt_rand(1, $this->width - $widthtotal);
|
||||||
for($i = 0; $i <= 3; $i++) {
|
for($i = 0; $i <= 3; $i++) {
|
||||||
$this->color && $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
|
$this->color && $this->fontcolor = array(mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
|
||||||
if($font[$i]['file']) {
|
if($font[$i]['file']) {
|
||||||
$this->imcode = imagecreatefromgif($font[$i]['file']);
|
$this->imcode = imagecreatefromgif($font[$i]['file']);
|
||||||
if($this->size) {
|
if($this->size) {
|
||||||
$font[$i]['width'] = mt_rand($font[$i]['width'] - $this->width / 20, $font[$i]['width'] + $this->width / 20);
|
$font[$i]['width'] = mt_rand($font[$i]['width'] - $this->width / 20, $font[$i]['width'] + $this->width / 20);
|
||||||
$font[$i]['height'] = mt_rand($font[$i]['height'] - $this->width / 20, $font[$i]['height'] + $this->width / 20);
|
$font[$i]['height'] = mt_rand($font[$i]['height'] - $this->width / 20, $font[$i]['height'] + $this->width / 20);
|
||||||
}
|
}
|
||||||
$y = mt_rand(0, $this->height - $font[$i]['height']);
|
$y = mt_rand(0, $this->height - $font[$i]['height']);
|
||||||
if($this->shadow) {
|
if($this->shadow) {
|
||||||
$this->imcodeshadow = $this->imcode;
|
$this->imcodeshadow = $this->imcode;
|
||||||
imagecolorset($this->imcodeshadow, 0, 0, 0, 0);
|
imagecolorset($this->imcodeshadow, 0, 0, 0, 0);
|
||||||
imagecopyresized($this->im, $this->imcodeshadow, $x + 1, $y + 1, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]);
|
imagecopyresized($this->im, $this->imcodeshadow, $x + 1, $y + 1, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]);
|
||||||
}
|
}
|
||||||
imagecolorset($this->imcode, 0 , $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
imagecolorset($this->imcode, 0 , $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
||||||
imagecopyresized($this->im, $this->imcode, $x, $y, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]);
|
imagecopyresized($this->im, $this->imcode, $x, $y, 0, 0, $font[$i]['width'], $font[$i]['height'], $font[$i]['data'][0], $font[$i]['data'][1]);
|
||||||
} else {
|
} else {
|
||||||
$y = mt_rand(0, $this->height - 20);
|
$y = mt_rand(0, $this->height - 20);
|
||||||
if($this->shadow) {
|
if($this->shadow) {
|
||||||
$text_shadowcolor = imagecolorallocate($this->im, 0, 0, 0);
|
$text_shadowcolor = imagecolorallocate($this->im, 0, 0, 0);
|
||||||
imagechar($this->im, 5, $x + 1, $y + 1, $seccode[$i], $text_shadowcolor);
|
imagechar($this->im, 5, $x + 1, $y + 1, $seccode[$i], $text_shadowcolor);
|
||||||
}
|
}
|
||||||
$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
$text_color = imagecolorallocate($this->im, $this->fontcolor[0], $this->fontcolor[1], $this->fontcolor[2]);
|
||||||
imagechar($this->im, 5, $x, $y, $seccode[$i], $text_color);
|
imagechar($this->im, 5, $x, $y, $seccode[$i], $text_color);
|
||||||
}
|
}
|
||||||
$x += $font[$i]['width'];
|
$x += $font[$i]['width'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function flash() {
|
function flash() {
|
||||||
$spacing = 5;
|
$spacing = 5;
|
||||||
$codewidth = ($this->width - $spacing * 5) / 4;
|
$codewidth = ($this->width - $spacing * 5) / 4;
|
||||||
$strforswdaction = '';
|
$strforswdaction = '';
|
||||||
for($i = 0; $i <= 3; $i++) {
|
for($i = 0; $i <= 3; $i++) {
|
||||||
$strforswdaction .= $this->swfcode($codewidth, $spacing, $this->code[$i], $i+1);
|
$strforswdaction .= $this->swfcode($codewidth, $spacing, $this->code[$i], $i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ming_setScale(20.00000000);
|
ming_setScale(20.00000000);
|
||||||
ming_useswfversion(6);
|
ming_useswfversion(6);
|
||||||
$movie = new SWFMovie();
|
$movie = new SWFMovie();
|
||||||
$movie->setDimension($this->width, $this->height);
|
$movie->setDimension($this->width, $this->height);
|
||||||
$movie->setBackground(255, 255, 255);
|
$movie->setBackground(255, 255, 255);
|
||||||
$movie->setRate(31);
|
$movie->setRate(31);
|
||||||
|
|
||||||
$fontcolor = '0x'.(sprintf('%02s', dechex (mt_rand(0, 255)))).(sprintf('%02s', dechex (mt_rand(0, 128)))).(sprintf('%02s', dechex (mt_rand(0, 255))));
|
$fontcolor = '0x'.(sprintf('%02s', dechex (mt_rand(0, 255)))).(sprintf('%02s', dechex (mt_rand(0, 128)))).(sprintf('%02s', dechex (mt_rand(0, 255))));
|
||||||
$strAction = "
|
$strAction = "
|
||||||
_root.createEmptyMovieClip ( 'triangle', 1 );
|
_root.createEmptyMovieClip ( 'triangle', 1 );
|
||||||
with ( _root.triangle ) {
|
with ( _root.triangle ) {
|
||||||
lineStyle( 3, $fontcolor, 100 );
|
lineStyle( 3, $fontcolor, 100 );
|
||||||
$strforswdaction
|
$strforswdaction
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
$movie->add(new SWFAction( str_replace("\r", "", $strAction) ));
|
$movie->add(new SWFAction( str_replace("\r", "", $strAction) ));
|
||||||
header('Content-type: application/x-shockwave-flash');
|
header('Content-type: application/x-shockwave-flash');
|
||||||
$movie->output();
|
$movie->output();
|
||||||
}
|
}
|
||||||
|
|
||||||
function swfcode($width, $d, $code, $order) {
|
function swfcode($width, $d, $code, $order) {
|
||||||
$str = '';
|
$str = '';
|
||||||
$height = $this->height - $d * 2;
|
$height = $this->height - $d * 2;
|
||||||
$x_0 = ($order * ($width + $d) - $width);
|
$x_0 = ($order * ($width + $d) - $width);
|
||||||
$x_1 = $x_0 + $width / 2;
|
$x_1 = $x_0 + $width / 2;
|
||||||
$x_2 = $x_0 + $width;
|
$x_2 = $x_0 + $width;
|
||||||
$y_0 = $d;
|
$y_0 = $d;
|
||||||
$y_2 = $y_0 + $height;
|
$y_2 = $y_0 + $height;
|
||||||
$y_1 = $y_2 / 2;
|
$y_1 = $y_2 / 2;
|
||||||
$y_0_5 = $y_2 / 4;
|
$y_0_5 = $y_2 / 4;
|
||||||
$y_1_5 = $y_1 + $y_0_5;
|
$y_1_5 = $y_1 + $y_0_5;
|
||||||
switch($code) {
|
switch($code) {
|
||||||
case 'B':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_1_5.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
case 'B':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_1_5.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
||||||
case 'C':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break;
|
case 'C':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break;
|
||||||
case 'E':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
case 'E':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
||||||
case 'F':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
case 'F':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
||||||
case 'G':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
case 'G':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');';break;
|
||||||
case 'H':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
case 'H':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
||||||
case 'J':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_1_5.');';break;
|
case 'J':$str .= 'moveTo('.$x_1.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_1_5.');';break;
|
||||||
case 'K':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break;
|
case 'K':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break;
|
||||||
case 'M':$str .= 'moveTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break;
|
case 'M':$str .= 'moveTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break;
|
||||||
case 'P':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break;
|
case 'P':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break;
|
||||||
case 'Q':$str .= 'moveTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');';break;
|
case 'Q':$str .= 'moveTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');';break;
|
||||||
case 'R':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break;
|
case 'R':$str .= 'moveTo('.$x_0.', '.$y_1.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0_5.');lineTo('.$x_1.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');';break;
|
||||||
case 'T':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');';break;
|
case 'T':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');';break;
|
||||||
case 'V':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break;
|
case 'V':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break;
|
||||||
case 'W':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break;
|
case 'W':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');';break;
|
||||||
case 'X':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break;
|
case 'X':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');';break;
|
||||||
case 'Y':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_1.', '.$y_2.');';break;
|
case 'Y':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_1.', '.$y_1.');lineTo('.$x_2.', '.$y_0.');moveTo('.$x_1.', '.$y_1.');lineTo('.$x_1.', '.$y_2.');';break;
|
||||||
case '2':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break;
|
case '2':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');';break;
|
||||||
case '3':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
case '3':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
||||||
case '4':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
case '4':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
||||||
case '6':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');';break;
|
case '6':$str .= 'moveTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');';break;
|
||||||
case '7':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break;
|
case '7':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');';break;
|
||||||
case '8':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
case '8':$str .= 'moveTo('.$x_0.', '.$y_0.');lineTo('.$x_0.', '.$y_2.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_0.', '.$y_0.');moveTo('.$x_0.', '.$y_1.');lineTo('.$x_2.', '.$y_1.');';break;
|
||||||
case '9':$str .= 'moveTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');';break;
|
case '9':$str .= 'moveTo('.$x_2.', '.$y_1.');lineTo('.$x_0.', '.$y_1.');lineTo('.$x_0.', '.$y_0.');lineTo('.$x_2.', '.$y_0.');lineTo('.$x_2.', '.$y_2.');lineTo('.$x_0.', '.$y_2.');';break;
|
||||||
}
|
}
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function audio() {
|
function audio() {
|
||||||
header('Content-type: audio/mpeg');
|
header('Content-type: audio/mpeg');
|
||||||
for($i = 0;$i <= 3; $i++) {
|
for($i = 0;$i <= 3; $i++) {
|
||||||
readfile($this->datapath.'sound/'.strtolower($this->code[$i]).'.mp3');
|
readfile($this->datapath.'sound/'.strtolower($this->code[$i]).'.mp3');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bitmap() {
|
function bitmap() {
|
||||||
$numbers = array
|
$numbers = array
|
||||||
(
|
(
|
||||||
'B' => array('00','fc','66','66','66','7c','66','66','fc','00'),
|
'B' => array('00','fc','66','66','66','7c','66','66','fc','00'),
|
||||||
'C' => array('00','38','64','c0','c0','c0','c4','64','3c','00'),
|
'C' => array('00','38','64','c0','c0','c0','c4','64','3c','00'),
|
||||||
'E' => array('00','fe','62','62','68','78','6a','62','fe','00'),
|
'E' => array('00','fe','62','62','68','78','6a','62','fe','00'),
|
||||||
'F' => array('00','f8','60','60','68','78','6a','62','fe','00'),
|
'F' => array('00','f8','60','60','68','78','6a','62','fe','00'),
|
||||||
'G' => array('00','78','cc','cc','de','c0','c4','c4','7c','00'),
|
'G' => array('00','78','cc','cc','de','c0','c4','c4','7c','00'),
|
||||||
'H' => array('00','e7','66','66','66','7e','66','66','e7','00'),
|
'H' => array('00','e7','66','66','66','7e','66','66','e7','00'),
|
||||||
'J' => array('00','f8','cc','cc','cc','0c','0c','0c','7f','00'),
|
'J' => array('00','f8','cc','cc','cc','0c','0c','0c','7f','00'),
|
||||||
'K' => array('00','f3','66','66','7c','78','6c','66','f7','00'),
|
'K' => array('00','f3','66','66','7c','78','6c','66','f7','00'),
|
||||||
'M' => array('00','f7','63','6b','6b','77','77','77','e3','00'),
|
'M' => array('00','f7','63','6b','6b','77','77','77','e3','00'),
|
||||||
'P' => array('00','f8','60','60','7c','66','66','66','fc','00'),
|
'P' => array('00','f8','60','60','7c','66','66','66','fc','00'),
|
||||||
'Q' => array('00','78','cc','cc','cc','cc','cc','cc','78','00'),
|
'Q' => array('00','78','cc','cc','cc','cc','cc','cc','78','00'),
|
||||||
'R' => array('00','f3','66','6c','7c','66','66','66','fc','00'),
|
'R' => array('00','f3','66','6c','7c','66','66','66','fc','00'),
|
||||||
'T' => array('00','78','30','30','30','30','b4','b4','fc','00'),
|
'T' => array('00','78','30','30','30','30','b4','b4','fc','00'),
|
||||||
'V' => array('00','1c','1c','36','36','36','63','63','f7','00'),
|
'V' => array('00','1c','1c','36','36','36','63','63','f7','00'),
|
||||||
'W' => array('00','36','36','36','77','7f','6b','63','f7','00'),
|
'W' => array('00','36','36','36','77','7f','6b','63','f7','00'),
|
||||||
'X' => array('00','f7','66','3c','18','18','3c','66','ef','00'),
|
'X' => array('00','f7','66','3c','18','18','3c','66','ef','00'),
|
||||||
'Y' => array('00','7e','18','18','18','3c','24','66','ef','00'),
|
'Y' => array('00','7e','18','18','18','3c','24','66','ef','00'),
|
||||||
'2' => array('fc','c0','60','30','18','0c','cc','cc','78','00'),
|
'2' => array('fc','c0','60','30','18','0c','cc','cc','78','00'),
|
||||||
'3' => array('78','8c','0c','0c','38','0c','0c','8c','78','00'),
|
'3' => array('78','8c','0c','0c','38','0c','0c','8c','78','00'),
|
||||||
'4' => array('00','3e','0c','fe','4c','6c','2c','3c','1c','1c'),
|
'4' => array('00','3e','0c','fe','4c','6c','2c','3c','1c','1c'),
|
||||||
'6' => array('78','cc','cc','cc','ec','d8','c0','60','3c','00'),
|
'6' => array('78','cc','cc','cc','ec','d8','c0','60','3c','00'),
|
||||||
'7' => array('30','30','38','18','18','18','1c','8c','fc','00'),
|
'7' => array('30','30','38','18','18','18','1c','8c','fc','00'),
|
||||||
'8' => array('78','cc','cc','cc','78','cc','cc','cc','78','00'),
|
'8' => array('78','cc','cc','cc','78','cc','cc','cc','78','00'),
|
||||||
'9' => array('f0','18','0c','6c','dc','cc','cc','cc','78','00')
|
'9' => array('f0','18','0c','6c','dc','cc','cc','cc','78','00')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($numbers as $i => $number) {
|
foreach($numbers as $i => $number) {
|
||||||
for($j = 0; $j < 6; $j++) {
|
for($j = 0; $j < 6; $j++) {
|
||||||
$a1 = substr('012', mt_rand(0, 2), 1).substr('012345', mt_rand(0, 5), 1);
|
$a1 = substr('012', mt_rand(0, 2), 1).substr('012345', mt_rand(0, 5), 1);
|
||||||
$a2 = substr('012345', mt_rand(0, 5), 1).substr('0123', mt_rand(0, 3), 1);
|
$a2 = substr('012345', mt_rand(0, 5), 1).substr('0123', mt_rand(0, 3), 1);
|
||||||
mt_rand(0, 1) == 1 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a1);
|
mt_rand(0, 1) == 1 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a1);
|
||||||
mt_rand(0, 1) == 0 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a2);
|
mt_rand(0, 1) == 0 ? array_push($numbers[$i], $a1) : array_unshift($numbers[$i], $a2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$bitmap = array();
|
$bitmap = array();
|
||||||
for($i = 0; $i < 20; $i++) {
|
for($i = 0; $i < 20; $i++) {
|
||||||
for($j = 0; $j <= 3; $j++) {
|
for($j = 0; $j <= 3; $j++) {
|
||||||
$bytes = $numbers[$this->code[$j]][$i];
|
$bytes = $numbers[$this->code[$j]][$i];
|
||||||
$a = mt_rand(0, 14);
|
$a = mt_rand(0, 14);
|
||||||
array_push($bitmap, $bytes);
|
array_push($bitmap, $bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for($i = 0; $i < 8; $i++) {
|
for($i = 0; $i < 8; $i++) {
|
||||||
$a = substr('012345', mt_rand(0, 2), 1) . substr('012345', mt_rand(0, 5), 1);
|
$a = substr('012345', mt_rand(0, 2), 1) . substr('012345', mt_rand(0, 5), 1);
|
||||||
array_unshift($bitmap, $a);
|
array_unshift($bitmap, $a);
|
||||||
array_push($bitmap, $a);
|
array_push($bitmap, $a);
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = pack('H*', '424d9e000000000000003e000000280000002000000018000000010001000000'.
|
$image = pack('H*', '424d9e000000000000003e000000280000002000000018000000010001000000'.
|
||||||
'0000600000000000000000000000000000000000000000000000FFFFFF00'.implode('', $bitmap));
|
'0000600000000000000000000000000000000000000000000000FFFFFF00'.implode('', $bitmap));
|
||||||
|
|
||||||
header('Content-Type: image/bmp');
|
header('Content-Type: image/bmp');
|
||||||
echo $image;
|
echo $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,140 +1,140 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
function xml2array(&$xml, $isnormal = FALSE,$encodeing='ISO-8859-1') {
|
function xml2array(&$xml, $isnormal = FALSE,$encodeing='ISO-8859-1') {
|
||||||
$xml_parser = new XMLparse($isnormal,$encodeing);
|
$xml_parser = new XMLparse($isnormal,$encodeing);
|
||||||
$data = $xml_parser->parse($xml);
|
$data = $xml_parser->parse($xml);
|
||||||
$xml_parser->destruct();
|
$xml_parser->destruct();
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function xmlattribute( $xml, $encodeing='ISO-8859-1') {
|
function xmlattribute( $xml, $encodeing='ISO-8859-1') {
|
||||||
$xml = str_replace($encodeing, 'UTF-8', $xml);
|
$xml = str_replace($encodeing, 'UTF-8', $xml);
|
||||||
libxml_disable_entity_loader(true);
|
libxml_disable_entity_loader(true);
|
||||||
$values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement')), true);
|
$values = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement')), true);
|
||||||
if( $values["item"] ){
|
if( $values["item"] ){
|
||||||
$data=attribute2arr($values["item"]);
|
$data=attribute2arr($values["item"]);
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function attribute2arr( $values,$data=array() ){
|
function attribute2arr( $values,$data=array() ){
|
||||||
foreach( $values as $k=>$v ){
|
foreach( $values as $k=>$v ){
|
||||||
if( isset($v["item"]) ){
|
if( isset($v["item"]) ){
|
||||||
$return = attribute2arr($v["item"]);
|
$return = attribute2arr($v["item"]);
|
||||||
if($return) $data[$v['@attributes']["id"]]=$return ;
|
if($return) $data[$v['@attributes']["id"]]=$return ;
|
||||||
}
|
}
|
||||||
if( count($v['@attributes'])>1 ){
|
if( count($v['@attributes'])>1 ){
|
||||||
$data[$v['@attributes']["id"]]["_attributes"]=$v['@attributes'];
|
$data[$v['@attributes']["id"]]["_attributes"]=$v['@attributes'];
|
||||||
unset($data[$v['@attributes']["id"]]["_attributes"]["id"]);
|
unset($data[$v['@attributes']["id"]]["_attributes"]["id"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function array2xml($arr, $htmlon = TRUE, $isnormal = FALSE, $level = 1,$encodeing='ISO-8859-1') {
|
function array2xml($arr, $htmlon = TRUE, $isnormal = FALSE, $level = 1,$encodeing='ISO-8859-1') {
|
||||||
$s = $level == 1 ? "<?xml version=\"1.0\" encoding=\"".$encodeing."\"?>\r\n<root>\r\n" : '';
|
$s = $level == 1 ? "<?xml version=\"1.0\" encoding=\"".$encodeing."\"?>\r\n<root>\r\n" : '';
|
||||||
$space = str_repeat("\t", $level);
|
$space = str_repeat("\t", $level);
|
||||||
|
|
||||||
foreach($arr as $k => $v) {
|
foreach($arr as $k => $v) {
|
||||||
if($k=="_attributes"){
|
if($k=="_attributes"){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$string="";
|
$string="";
|
||||||
if( isset($arr['_attributes'])){
|
if( isset($arr['_attributes'])){
|
||||||
foreach($arr["_attributes"] as $k2=>$v2){
|
foreach($arr["_attributes"] as $k2=>$v2){
|
||||||
if($k2==$k){
|
if($k2==$k){
|
||||||
foreach($v2 as $k3=>$v3){
|
foreach($v2 as $k3=>$v3){
|
||||||
$string.=' '.$k3.'="'.$v3.'"';
|
$string.=' '.$k3.'="'.$v3.'"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!is_array($v)) {
|
if(!is_array($v)) {
|
||||||
$s .= $space."<item id=\"$k\"$string>".($htmlon ? '<![CDATA[' : '').$v.($htmlon ? ']]>' : '')."</item>\r\n";
|
$s .= $space."<item id=\"$k\"$string>".($htmlon ? '<![CDATA[' : '').$v.($htmlon ? ']]>' : '')."</item>\r\n";
|
||||||
} else {
|
} else {
|
||||||
$s .= $space."<item id=\"$k\"$string>\r\n".array2xml($v, $htmlon, $isnormal, $level + 1,$encodeing).$space."</item>\r\n";
|
$s .= $space."<item id=\"$k\"$string>\r\n".array2xml($v, $htmlon, $isnormal, $level + 1,$encodeing).$space."</item>\r\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s);
|
$s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s);
|
||||||
return $level == 1 ? $s."</root>" : $s;
|
return $level == 1 ? $s."</root>" : $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
class XMLparse {
|
class XMLparse {
|
||||||
|
|
||||||
var $parser;
|
var $parser;
|
||||||
var $document;
|
var $document;
|
||||||
var $stack;
|
var $stack;
|
||||||
var $data;
|
var $data;
|
||||||
var $last_opened_tag;
|
var $last_opened_tag;
|
||||||
var $isnormal;
|
var $isnormal;
|
||||||
var $attrs = array();
|
var $attrs = array();
|
||||||
var $failed = FALSE;
|
var $failed = FALSE;
|
||||||
|
|
||||||
function __construct($isnormal,$encodeing) {
|
function __construct($isnormal,$encodeing) {
|
||||||
$this->XMLparse($isnormal,$encodeing);
|
$this->XMLparse($isnormal,$encodeing);
|
||||||
}
|
}
|
||||||
|
|
||||||
function XMLparse($isnormal,$encodeing) {
|
function XMLparse($isnormal,$encodeing) {
|
||||||
$this->isnormal = $isnormal;
|
$this->isnormal = $isnormal;
|
||||||
$this->parser = xml_parser_create($encodeing);
|
$this->parser = xml_parser_create($encodeing);
|
||||||
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
|
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
|
||||||
xml_set_object($this->parser, $this);
|
xml_set_object($this->parser, $this);
|
||||||
xml_set_element_handler($this->parser, 'open','close');
|
xml_set_element_handler($this->parser, 'open','close');
|
||||||
xml_set_character_data_handler($this->parser, 'data');
|
xml_set_character_data_handler($this->parser, 'data');
|
||||||
}
|
}
|
||||||
|
|
||||||
function destruct() {
|
function destruct() {
|
||||||
xml_parser_free($this->parser);
|
xml_parser_free($this->parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(&$data) {
|
function parse(&$data) {
|
||||||
$this->document = array();
|
$this->document = array();
|
||||||
$this->stack = array();
|
$this->stack = array();
|
||||||
return xml_parse($this->parser, $data, true) && !$this->failed ? $this->document : '';
|
return xml_parse($this->parser, $data, true) && !$this->failed ? $this->document : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(&$parser, $tag, $attributes) {
|
function open(&$parser, $tag, $attributes) {
|
||||||
$this->data = '';
|
$this->data = '';
|
||||||
$this->failed = FALSE;
|
$this->failed = FALSE;
|
||||||
if(!$this->isnormal) {
|
if(!$this->isnormal) {
|
||||||
if(isset($attributes['id']) && !is_string($this->document[$attributes['id']])) {
|
if(isset($attributes['id']) && !is_string($this->document[$attributes['id']])) {
|
||||||
$this->document = &$this->document[$attributes['id']];
|
$this->document = &$this->document[$attributes['id']];
|
||||||
} else {
|
} else {
|
||||||
$this->failed = TRUE;
|
$this->failed = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!isset($this->document[$tag]) || !is_string($this->document[$tag])) {
|
if(!isset($this->document[$tag]) || !is_string($this->document[$tag])) {
|
||||||
$this->document = &$this->document[$tag];
|
$this->document = &$this->document[$tag];
|
||||||
} else {
|
} else {
|
||||||
$this->failed = TRUE;
|
$this->failed = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->stack[] = &$this->document;
|
$this->stack[] = &$this->document;
|
||||||
$this->last_opened_tag = $tag;
|
$this->last_opened_tag = $tag;
|
||||||
$this->attrs = $attributes;
|
$this->attrs = $attributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
function data(&$parser, $data) {
|
function data(&$parser, $data) {
|
||||||
if($this->last_opened_tag != NULL) {
|
if($this->last_opened_tag != NULL) {
|
||||||
$this->data .= $data;
|
$this->data .= $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(&$parser, $tag) {
|
function close(&$parser, $tag) {
|
||||||
if($this->last_opened_tag == $tag) {
|
if($this->last_opened_tag == $tag) {
|
||||||
$this->document = $this->data;
|
$this->document = $this->data;
|
||||||
$this->last_opened_tag = NULL;
|
$this->last_opened_tag = NULL;
|
||||||
}
|
}
|
||||||
array_pop($this->stack);
|
array_pop($this->stack);
|
||||||
if($this->stack) {
|
if($this->stack) {
|
||||||
$this->document = &$this->stack[count($this->stack)-1];
|
$this->document = &$this->stack[count($this->stack)-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,309 +1,309 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class zipfile {
|
class zipfile {
|
||||||
var $datasec = array();
|
var $datasec = array();
|
||||||
|
|
||||||
var $ctrl_dir = array();
|
var $ctrl_dir = array();
|
||||||
|
|
||||||
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
|
var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
|
||||||
|
|
||||||
var $old_offset = 0;
|
var $old_offset = 0;
|
||||||
function unix2DosTime($unixtime = 0) {
|
function unix2DosTime($unixtime = 0) {
|
||||||
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
|
$timearray = ($unixtime == 0) ? getdate() : getdate($unixtime);
|
||||||
|
|
||||||
if($timearray['year'] < 1980) {
|
if($timearray['year'] < 1980) {
|
||||||
$timearray['year'] = 1980;
|
$timearray['year'] = 1980;
|
||||||
$timearray['mon'] = 1;
|
$timearray['mon'] = 1;
|
||||||
$timearray['mday'] = 1;
|
$timearray['mday'] = 1;
|
||||||
$timearray['hours'] = 0;
|
$timearray['hours'] = 0;
|
||||||
$timearray['minutes'] = 0;
|
$timearray['minutes'] = 0;
|
||||||
$timearray['seconds'] = 0;
|
$timearray['seconds'] = 0;
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
|
return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) |
|
||||||
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
|
($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1);
|
||||||
} // end of the 'unix2DosTime()' method
|
} // end of the 'unix2DosTime()' method
|
||||||
|
|
||||||
|
|
||||||
function addFile($data, $name, $time = 0) {
|
function addFile($data, $name, $time = 0) {
|
||||||
$name = str_replace('\\', '/', $name);
|
$name = str_replace('\\', '/', $name);
|
||||||
|
|
||||||
$dtime = dechex($this->unix2DosTime($time));
|
$dtime = dechex($this->unix2DosTime($time));
|
||||||
$hexdtime = '\x' . $dtime[6] . $dtime[7]
|
$hexdtime = '\x' . $dtime[6] . $dtime[7]
|
||||||
. '\x' . $dtime[4] . $dtime[5]
|
. '\x' . $dtime[4] . $dtime[5]
|
||||||
. '\x' . $dtime[2] . $dtime[3]
|
. '\x' . $dtime[2] . $dtime[3]
|
||||||
. '\x' . $dtime[0] . $dtime[1];
|
. '\x' . $dtime[0] . $dtime[1];
|
||||||
eval('$hexdtime = "' . $hexdtime . '";');
|
eval('$hexdtime = "' . $hexdtime . '";');
|
||||||
|
|
||||||
$fr = "\x50\x4b\x03\x04";
|
$fr = "\x50\x4b\x03\x04";
|
||||||
$fr .= "\x14\x00"; // ver needed to extract
|
$fr .= "\x14\x00"; // ver needed to extract
|
||||||
$fr .= "\x00\x00"; // gen purpose bit flag
|
$fr .= "\x00\x00"; // gen purpose bit flag
|
||||||
$fr .= "\x08\x00"; // compression method
|
$fr .= "\x08\x00"; // compression method
|
||||||
$fr .= $hexdtime; // last mod time and date
|
$fr .= $hexdtime; // last mod time and date
|
||||||
|
|
||||||
$unc_len = strlen($data);
|
$unc_len = strlen($data);
|
||||||
$crc = crc32($data);
|
$crc = crc32($data);
|
||||||
$zdata = gzcompress($data);
|
$zdata = gzcompress($data);
|
||||||
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
|
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
|
||||||
$c_len = strlen($zdata);
|
$c_len = strlen($zdata);
|
||||||
$fr .= pack('V', $crc); // crc32
|
$fr .= pack('V', $crc); // crc32
|
||||||
$fr .= pack('V', $c_len); // compressed filesize
|
$fr .= pack('V', $c_len); // compressed filesize
|
||||||
$fr .= pack('V', $unc_len); // uncompressed filesize
|
$fr .= pack('V', $unc_len); // uncompressed filesize
|
||||||
$fr .= pack('v', strlen($name)); // length of filename
|
$fr .= pack('v', strlen($name)); // length of filename
|
||||||
$fr .= pack('v', 0); // extra field length
|
$fr .= pack('v', 0); // extra field length
|
||||||
$fr .= $name;
|
$fr .= $name;
|
||||||
|
|
||||||
$fr .= $zdata;
|
$fr .= $zdata;
|
||||||
|
|
||||||
|
|
||||||
$this -> datasec[] = $fr;
|
$this -> datasec[] = $fr;
|
||||||
|
|
||||||
$cdrec = "\x50\x4b\x01\x02";
|
$cdrec = "\x50\x4b\x01\x02";
|
||||||
$cdrec .= "\x00\x00"; // version made by
|
$cdrec .= "\x00\x00"; // version made by
|
||||||
$cdrec .= "\x14\x00"; // version needed to extract
|
$cdrec .= "\x14\x00"; // version needed to extract
|
||||||
$cdrec .= "\x00\x00"; // gen purpose bit flag
|
$cdrec .= "\x00\x00"; // gen purpose bit flag
|
||||||
$cdrec .= "\x08\x00"; // compression method
|
$cdrec .= "\x08\x00"; // compression method
|
||||||
$cdrec .= $hexdtime; // last mod time & date
|
$cdrec .= $hexdtime; // last mod time & date
|
||||||
$cdrec .= pack('V', $crc); // crc32
|
$cdrec .= pack('V', $crc); // crc32
|
||||||
$cdrec .= pack('V', $c_len); // compressed filesize
|
$cdrec .= pack('V', $c_len); // compressed filesize
|
||||||
$cdrec .= pack('V', $unc_len); // uncompressed filesize
|
$cdrec .= pack('V', $unc_len); // uncompressed filesize
|
||||||
$cdrec .= pack('v', strlen($name) ); // length of filename
|
$cdrec .= pack('v', strlen($name) ); // length of filename
|
||||||
$cdrec .= pack('v', 0 ); // extra field length
|
$cdrec .= pack('v', 0 ); // extra field length
|
||||||
$cdrec .= pack('v', 0 ); // file comment length
|
$cdrec .= pack('v', 0 ); // file comment length
|
||||||
$cdrec .= pack('v', 0 ); // disk number start
|
$cdrec .= pack('v', 0 ); // disk number start
|
||||||
$cdrec .= pack('v', 0 ); // internal file attributes
|
$cdrec .= pack('v', 0 ); // internal file attributes
|
||||||
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
|
$cdrec .= pack('V', 32 ); // external file attributes - 'archive' bit set
|
||||||
|
|
||||||
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
|
$cdrec .= pack('V', $this -> old_offset ); // relative offset of local header
|
||||||
$this -> old_offset += strlen($fr);
|
$this -> old_offset += strlen($fr);
|
||||||
|
|
||||||
$cdrec .= $name;
|
$cdrec .= $name;
|
||||||
|
|
||||||
$this -> ctrl_dir[] = $cdrec;
|
$this -> ctrl_dir[] = $cdrec;
|
||||||
} // end of the 'addFile()' method
|
} // end of the 'addFile()' method
|
||||||
|
|
||||||
|
|
||||||
function file() {
|
function file() {
|
||||||
$data = implode('', $this -> datasec);
|
$data = implode('', $this -> datasec);
|
||||||
$ctrldir = implode('', $this -> ctrl_dir);
|
$ctrldir = implode('', $this -> ctrl_dir);
|
||||||
|
|
||||||
return
|
return
|
||||||
$data .
|
$data .
|
||||||
$ctrldir .
|
$ctrldir .
|
||||||
$this -> eof_ctrl_dir .
|
$this -> eof_ctrl_dir .
|
||||||
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
|
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk"
|
||||||
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
|
pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall
|
||||||
pack('V', strlen($ctrldir)) . // size of central dir
|
pack('V', strlen($ctrldir)) . // size of central dir
|
||||||
pack('V', strlen($data)) . // offset to start of central dir
|
pack('V', strlen($data)) . // offset to start of central dir
|
||||||
"\x00\x00"; // .zip file comment length
|
"\x00\x00"; // .zip file comment length
|
||||||
} // end of the 'file()' method
|
} // end of the 'file()' method
|
||||||
|
|
||||||
} // end of the 'zipfile' class
|
} // end of the 'zipfile' class
|
||||||
|
|
||||||
|
|
||||||
class SimpleUnzip {
|
class SimpleUnzip {
|
||||||
var $Comment = '';
|
var $Comment = '';
|
||||||
|
|
||||||
var $Entries = array();
|
var $Entries = array();
|
||||||
|
|
||||||
var $Name = '';
|
var $Name = '';
|
||||||
|
|
||||||
var $Size = 0;
|
var $Size = 0;
|
||||||
|
|
||||||
var $Time = 0;
|
var $Time = 0;
|
||||||
|
|
||||||
function SimpleUnzip($in_FileName = '') {
|
function SimpleUnzip($in_FileName = '') {
|
||||||
if($in_FileName !== '') {
|
if($in_FileName !== '') {
|
||||||
SimpleUnzip::ReadFile($in_FileName);
|
SimpleUnzip::ReadFile($in_FileName);
|
||||||
}
|
}
|
||||||
} // end of the 'SimpleUnzip' constructor
|
} // end of the 'SimpleUnzip' constructor
|
||||||
|
|
||||||
function Count() {
|
function Count() {
|
||||||
return count($this->Entries);
|
return count($this->Entries);
|
||||||
} // end of the 'Count()' method
|
} // end of the 'Count()' method
|
||||||
|
|
||||||
function GetData($in_Index) {
|
function GetData($in_Index) {
|
||||||
return $this->Entries[$in_Index]->Data;
|
return $this->Entries[$in_Index]->Data;
|
||||||
} // end of the 'GetData()' method
|
} // end of the 'GetData()' method
|
||||||
|
|
||||||
function GetEntry($in_Index) {
|
function GetEntry($in_Index) {
|
||||||
return $this->Entries[$in_Index];
|
return $this->Entries[$in_Index];
|
||||||
} // end of the 'GetEntry()' method
|
} // end of the 'GetEntry()' method
|
||||||
|
|
||||||
function GetError($in_Index) {
|
function GetError($in_Index) {
|
||||||
return $this->Entries[$in_Index]->Error;
|
return $this->Entries[$in_Index]->Error;
|
||||||
} // end of the 'GetError()' method
|
} // end of the 'GetError()' method
|
||||||
|
|
||||||
function GetErrorMsg($in_Index) {
|
function GetErrorMsg($in_Index) {
|
||||||
return $this->Entries[$in_Index]->ErrorMsg;
|
return $this->Entries[$in_Index]->ErrorMsg;
|
||||||
} // end of the 'GetErrorMsg()' method
|
} // end of the 'GetErrorMsg()' method
|
||||||
|
|
||||||
function GetName($in_Index) {
|
function GetName($in_Index) {
|
||||||
return $this->Entries[$in_Index]->Name;
|
return $this->Entries[$in_Index]->Name;
|
||||||
} // end of the 'GetName()' method
|
} // end of the 'GetName()' method
|
||||||
|
|
||||||
function GetPath($in_Index) {
|
function GetPath($in_Index) {
|
||||||
return $this->Entries[$in_Index]->Path;
|
return $this->Entries[$in_Index]->Path;
|
||||||
} // end of the 'GetPath()' method
|
} // end of the 'GetPath()' method
|
||||||
|
|
||||||
function GetTime($in_Index) {
|
function GetTime($in_Index) {
|
||||||
return $this->Entries[$in_Index]->Time;
|
return $this->Entries[$in_Index]->Time;
|
||||||
} // end of the 'GetTime()' method
|
} // end of the 'GetTime()' method
|
||||||
|
|
||||||
function ReadFile($in_FileName) {
|
function ReadFile($in_FileName) {
|
||||||
$this->Entries = array();
|
$this->Entries = array();
|
||||||
|
|
||||||
$this->Name = $in_FileName;
|
$this->Name = $in_FileName;
|
||||||
$this->Time = filemtime($in_FileName);
|
$this->Time = filemtime($in_FileName);
|
||||||
$this->Size = filesize($in_FileName);
|
$this->Size = filesize($in_FileName);
|
||||||
|
|
||||||
$oF = fopen($in_FileName, 'rb');
|
$oF = fopen($in_FileName, 'rb');
|
||||||
$vZ = fread($oF, $this->Size);
|
$vZ = fread($oF, $this->Size);
|
||||||
fclose($oF);
|
fclose($oF);
|
||||||
|
|
||||||
$aE = explode("\x50\x4b\x05\x06", $vZ);
|
$aE = explode("\x50\x4b\x05\x06", $vZ);
|
||||||
|
|
||||||
|
|
||||||
$aP = unpack('x16/v1CL', $aE[1]);
|
$aP = unpack('x16/v1CL', $aE[1]);
|
||||||
$this->Comment = substr($aE[1], 18, $aP['CL']);
|
$this->Comment = substr($aE[1], 18, $aP['CL']);
|
||||||
|
|
||||||
$this->Comment = strtr($this->Comment, array("\r\n" => "\n",
|
$this->Comment = strtr($this->Comment, array("\r\n" => "\n",
|
||||||
"\r" => "\n"));
|
"\r" => "\n"));
|
||||||
|
|
||||||
$aE = explode("\x50\x4b\x01\x02", $vZ);
|
$aE = explode("\x50\x4b\x01\x02", $vZ);
|
||||||
$aE = explode("\x50\x4b\x03\x04", $aE[0]);
|
$aE = explode("\x50\x4b\x03\x04", $aE[0]);
|
||||||
array_shift($aE);
|
array_shift($aE);
|
||||||
|
|
||||||
foreach($aE as $vZ) {
|
foreach($aE as $vZ) {
|
||||||
$aI = array();
|
$aI = array();
|
||||||
$aI['E'] = 0;
|
$aI['E'] = 0;
|
||||||
$aI['EM'] = '';
|
$aI['EM'] = '';
|
||||||
$aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
|
$aP = unpack('v1VN/v1GPF/v1CM/v1FT/v1FD/V1CRC/V1CS/V1UCS/v1FNL', $vZ);
|
||||||
$bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
|
$bE = ($aP['GPF'] && 0x0001) ? TRUE : FALSE;
|
||||||
$nF = $aP['FNL'];
|
$nF = $aP['FNL'];
|
||||||
|
|
||||||
if($aP['GPF'] & 0x0008) {
|
if($aP['GPF'] & 0x0008) {
|
||||||
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
|
$aP1 = unpack('V1CRC/V1CS/V1UCS', substr($vZ, -12));
|
||||||
|
|
||||||
$aP['CRC'] = $aP1['CRC'];
|
$aP['CRC'] = $aP1['CRC'];
|
||||||
$aP['CS'] = $aP1['CS'];
|
$aP['CS'] = $aP1['CS'];
|
||||||
$aP['UCS'] = $aP1['UCS'];
|
$aP['UCS'] = $aP1['UCS'];
|
||||||
|
|
||||||
$vZ = substr($vZ, 0, -12);
|
$vZ = substr($vZ, 0, -12);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aI['N'] = substr($vZ, 26, $nF);
|
$aI['N'] = substr($vZ, 26, $nF);
|
||||||
|
|
||||||
if(substr($aI['N'], -1) == '/') {
|
if(substr($aI['N'], -1) == '/') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$aI['P'] = dirname($aI['N']);
|
$aI['P'] = dirname($aI['N']);
|
||||||
$aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
|
$aI['P'] = $aI['P'] == '.' ? '' : $aI['P'];
|
||||||
$aI['N'] = basename($aI['N']);
|
$aI['N'] = basename($aI['N']);
|
||||||
|
|
||||||
$vZ = substr($vZ, 26 + $nF);
|
$vZ = substr($vZ, 26 + $nF);
|
||||||
|
|
||||||
if(strlen($vZ) != $aP['CS']) {
|
if(strlen($vZ) != $aP['CS']) {
|
||||||
$aI['E'] = 1;
|
$aI['E'] = 1;
|
||||||
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
|
$aI['EM'] = 'Compressed size is not equal with the value in header information.';
|
||||||
} else {
|
} else {
|
||||||
if($bE) {
|
if($bE) {
|
||||||
$aI['E'] = 5;
|
$aI['E'] = 5;
|
||||||
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
|
$aI['EM'] = 'File is encrypted, which is not supported from this class.';
|
||||||
} else {
|
} else {
|
||||||
switch($aP['CM']) {
|
switch($aP['CM']) {
|
||||||
case 0: // Stored
|
case 0: // Stored
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8: // Deflated
|
case 8: // Deflated
|
||||||
$vZ = gzinflate($vZ);
|
$vZ = gzinflate($vZ);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 12: // BZIP2
|
case 12: // BZIP2
|
||||||
if(! extension_loaded('bz2')) {
|
if(! extension_loaded('bz2')) {
|
||||||
if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
|
||||||
@dl('php_bz2.dll');
|
@dl('php_bz2.dll');
|
||||||
} else {
|
} else {
|
||||||
@dl('bz2.so');
|
@dl('bz2.so');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(extension_loaded('bz2')) {
|
if(extension_loaded('bz2')) {
|
||||||
$vZ = bzdecompress($vZ);
|
$vZ = bzdecompress($vZ);
|
||||||
} else {
|
} else {
|
||||||
$aI['E'] = 7;
|
$aI['E'] = 7;
|
||||||
$aI['EM'] = "PHP BZIP2 extension not available.";
|
$aI['EM'] = "PHP BZIP2 extension not available.";
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$aI['E'] = 6;
|
$aI['E'] = 6;
|
||||||
$aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
|
$aI['EM'] = "De-/Compression method {$aP['CM']} is not supported.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $aI['E']) {
|
if(! $aI['E']) {
|
||||||
if($vZ === FALSE) {
|
if($vZ === FALSE) {
|
||||||
$aI['E'] = 2;
|
$aI['E'] = 2;
|
||||||
$aI['EM'] = 'Decompression of data failed.';
|
$aI['EM'] = 'Decompression of data failed.';
|
||||||
} else {
|
} else {
|
||||||
if(strlen($vZ) != $aP['UCS']) {
|
if(strlen($vZ) != $aP['UCS']) {
|
||||||
$aI['E'] = 3;
|
$aI['E'] = 3;
|
||||||
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
|
$aI['EM'] = 'Uncompressed size is not equal with the value in header information.';
|
||||||
} else {
|
} else {
|
||||||
if(crc32($vZ) != $aP['CRC']) {
|
if(crc32($vZ) != $aP['CRC']) {
|
||||||
$aI['E'] = 4;
|
$aI['E'] = 4;
|
||||||
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
|
$aI['EM'] = 'CRC32 checksum is not equal with the value in header information.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aI['D'] = $vZ;
|
$aI['D'] = $vZ;
|
||||||
|
|
||||||
$aI['T'] = @mktime(($aP['FT'] & 0xf800) >> 11,
|
$aI['T'] = @mktime(($aP['FT'] & 0xf800) >> 11,
|
||||||
($aP['FT'] & 0x07e0) >> 5,
|
($aP['FT'] & 0x07e0) >> 5,
|
||||||
($aP['FT'] & 0x001f) << 1,
|
($aP['FT'] & 0x001f) << 1,
|
||||||
($aP['FD'] & 0x01e0) >> 5,
|
($aP['FD'] & 0x01e0) >> 5,
|
||||||
($aP['FD'] & 0x001f),
|
($aP['FD'] & 0x001f),
|
||||||
(($aP['FD'] & 0xfe00) >> 9) + 1980);
|
(($aP['FD'] & 0xfe00) >> 9) + 1980);
|
||||||
|
|
||||||
$this->Entries[] = new SimpleUnzipEntry($aI);
|
$this->Entries[] = new SimpleUnzipEntry($aI);
|
||||||
} // end for each entries
|
} // end for each entries
|
||||||
|
|
||||||
return $this->Entries;
|
return $this->Entries;
|
||||||
} // end of the 'ReadFile()' method
|
} // end of the 'ReadFile()' method
|
||||||
} // end of the 'SimpleUnzip' class
|
} // end of the 'SimpleUnzip' class
|
||||||
|
|
||||||
class SimpleUnzipEntry {
|
class SimpleUnzipEntry {
|
||||||
var $Data = '';
|
var $Data = '';
|
||||||
|
|
||||||
var $Error = 0;
|
var $Error = 0;
|
||||||
|
|
||||||
var $ErrorMsg = '';
|
var $ErrorMsg = '';
|
||||||
|
|
||||||
var $Name = '';
|
var $Name = '';
|
||||||
|
|
||||||
var $Path = '';
|
var $Path = '';
|
||||||
|
|
||||||
var $Time = 0;
|
var $Time = 0;
|
||||||
|
|
||||||
function SimpleUnzipEntry($in_Entry) {
|
function SimpleUnzipEntry($in_Entry) {
|
||||||
$this->Data = $in_Entry['D'];
|
$this->Data = $in_Entry['D'];
|
||||||
$this->Error = $in_Entry['E'];
|
$this->Error = $in_Entry['E'];
|
||||||
$this->ErrorMsg = $in_Entry['EM'];
|
$this->ErrorMsg = $in_Entry['EM'];
|
||||||
$this->Name = $in_Entry['N'];
|
$this->Name = $in_Entry['N'];
|
||||||
$this->Path = $in_Entry['P'];
|
$this->Path = $in_Entry['P'];
|
||||||
$this->Time = $in_Entry['T'];
|
$this->Time = $in_Entry['T'];
|
||||||
} // end of the 'SimpleUnzipEntry' constructor
|
} // end of the 'SimpleUnzipEntry' constructor
|
||||||
} // end of the 'SimpleUnzipEntry' class
|
} // end of the 'SimpleUnzipEntry' class
|
||||||
|
|
||||||
?>
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,221 +1,221 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class db_driver_mysql
|
class db_driver_mysql
|
||||||
{
|
{
|
||||||
var $tablepre;
|
var $tablepre;
|
||||||
var $version = '';
|
var $version = '';
|
||||||
var $drivertype = 'mysql';
|
var $drivertype = 'mysql';
|
||||||
var $querynum = 0;
|
var $querynum = 0;
|
||||||
var $slaveid = 0;
|
var $slaveid = 0;
|
||||||
var $curlink;
|
var $curlink;
|
||||||
var $link = array();
|
var $link = array();
|
||||||
var $config = array();
|
var $config = array();
|
||||||
var $sqldebug = array();
|
var $sqldebug = array();
|
||||||
var $map = array();
|
var $map = array();
|
||||||
|
|
||||||
function db_mysql($config = array()) {
|
function db_mysql($config = array()) {
|
||||||
if(!empty($config)) {
|
if(!empty($config)) {
|
||||||
$this->set_config($config);
|
$this->set_config($config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_config($config) {
|
function set_config($config) {
|
||||||
$this->config = &$config;
|
$this->config = &$config;
|
||||||
$this->tablepre = $config['1']['tablepre'];
|
$this->tablepre = $config['1']['tablepre'];
|
||||||
if(!empty($this->config['map'])) {
|
if(!empty($this->config['map'])) {
|
||||||
$this->map = $this->config['map'];
|
$this->map = $this->config['map'];
|
||||||
for($i = 1; $i <= 100; $i++) {
|
for($i = 1; $i <= 100; $i++) {
|
||||||
if(isset($this->map['attachment']) && $i <= 10) {
|
if(isset($this->map['attachment']) && $i <= 10) {
|
||||||
$this->map['attachment_'.($i-1)] = $this->map['attachment'];
|
$this->map['attachment_'.($i-1)] = $this->map['attachment'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isset($this->map['user'])) {
|
if(isset($this->map['user'])) {
|
||||||
$this->map['user_status'] =
|
$this->map['user_status'] =
|
||||||
$this->map['user_profile'] =
|
$this->map['user_profile'] =
|
||||||
$this->map['user_field'] =
|
$this->map['user_field'] =
|
||||||
$this->map['user'];
|
$this->map['user'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function linknum(){
|
function linknum(){
|
||||||
return $this->curlink;
|
return $this->curlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($serverid = 1) {
|
function connect($serverid = 1) {
|
||||||
|
|
||||||
if(empty($this->config) || empty($this->config[$serverid])) {
|
if(empty($this->config) || empty($this->config[$serverid])) {
|
||||||
$this->halt('config_db_not_found');
|
$this->halt('config_db_not_found');
|
||||||
}
|
}
|
||||||
if(!empty($this->config[$serverid]['unix_socket'])){//使用socket连接;
|
if(!empty($this->config[$serverid]['unix_socket'])){//使用socket连接;
|
||||||
$this->config[$serverid]['dbhost']=$this->config[$serverid]['unix_socket'];
|
$this->config[$serverid]['dbhost']=$this->config[$serverid]['unix_socket'];
|
||||||
}elseif($this->config[$serverid]['port']){
|
}elseif($this->config[$serverid]['port']){
|
||||||
list($dbhost,$port)=explode(':',$this->config[$serverid]['dbhost']);
|
list($dbhost,$port)=explode(':',$this->config[$serverid]['dbhost']);
|
||||||
$this->config[$serverid]['dbhost']=$dbhost.':'.$this->config[$serverid]['port'];
|
$this->config[$serverid]['dbhost']=$dbhost.':'.$this->config[$serverid]['port'];
|
||||||
}
|
}
|
||||||
$this->link[$serverid] = $this->_dbconnect(
|
$this->link[$serverid] = $this->_dbconnect(
|
||||||
$this->config[$serverid]['dbhost'],
|
$this->config[$serverid]['dbhost'],
|
||||||
$this->config[$serverid]['dbuser'],
|
$this->config[$serverid]['dbuser'],
|
||||||
$this->config[$serverid]['dbpw'],
|
$this->config[$serverid]['dbpw'],
|
||||||
$this->config[$serverid]['dbcharset'],
|
$this->config[$serverid]['dbcharset'],
|
||||||
$this->config[$serverid]['dbname'],
|
$this->config[$serverid]['dbname'],
|
||||||
$this->config[$serverid]['pconnect']
|
$this->config[$serverid]['pconnect']
|
||||||
);
|
);
|
||||||
$this->curlink = $this->link[$serverid];
|
$this->curlink = $this->link[$serverid];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _dbconnect($dbhost, $dbuser, $dbpw, $dbcharset, $dbname, $pconnect, $halt = true) {
|
function _dbconnect($dbhost, $dbuser, $dbpw, $dbcharset, $dbname, $pconnect, $halt = true) {
|
||||||
|
|
||||||
if($pconnect) {
|
if($pconnect) {
|
||||||
$link = @mysql_pconnect($dbhost, $dbuser, $dbpw);
|
$link = @mysql_pconnect($dbhost, $dbuser, $dbpw);
|
||||||
} else {
|
} else {
|
||||||
$link = @mysql_connect($dbhost, $dbuser, $dbpw, 1);
|
$link = @mysql_connect($dbhost, $dbuser, $dbpw, 1);
|
||||||
}
|
}
|
||||||
if(!$link) {
|
if(!$link) {
|
||||||
$halt && $this->halt('notconnect', $this->errno());
|
$halt && $this->halt('notconnect', $this->errno());
|
||||||
} else {
|
} else {
|
||||||
$this->curlink = $link;
|
$this->curlink = $link;
|
||||||
if($this->version() > '4.1') {
|
if($this->version() > '4.1') {
|
||||||
$dbcharset = $dbcharset ? $dbcharset : $this->config[1]['dbcharset'];
|
$dbcharset = $dbcharset ? $dbcharset : $this->config[1]['dbcharset'];
|
||||||
$serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary' : '';
|
$serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary' : '';
|
||||||
$serverset .= $this->version() > '5.0.1' ? ((empty($serverset) ? '' : ',').'sql_mode=\'\'') : '';
|
$serverset .= $this->version() > '5.0.1' ? ((empty($serverset) ? '' : ',').'sql_mode=\'\'') : '';
|
||||||
$serverset && mysql_query("SET $serverset", $link);
|
$serverset && mysql_query("SET $serverset", $link);
|
||||||
}
|
}
|
||||||
$dbname && @mysql_select_db($dbname, $link);
|
$dbname && @mysql_select_db($dbname, $link);
|
||||||
}
|
}
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_name($tablename) {
|
function table_name($tablename) {
|
||||||
if(!empty($this->map) && !empty($this->map[$tablename])) {
|
if(!empty($this->map) && !empty($this->map[$tablename])) {
|
||||||
$id = $this->map[$tablename];
|
$id = $this->map[$tablename];
|
||||||
if(!$this->link[$id]) {
|
if(!$this->link[$id]) {
|
||||||
$this->connect($id);
|
$this->connect($id);
|
||||||
}
|
}
|
||||||
$this->curlink = $this->link[$id];
|
$this->curlink = $this->link[$id];
|
||||||
} else {
|
} else {
|
||||||
$this->curlink = $this->link[1];
|
$this->curlink = $this->link[1];
|
||||||
}
|
}
|
||||||
return $this->tablepre.$tablename;
|
return $this->tablepre.$tablename;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($dbname) {
|
function select_db($dbname) {
|
||||||
return mysql_select_db($dbname, $this->curlink);
|
return mysql_select_db($dbname, $this->curlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_array($query, $result_type = MYSQL_ASSOC) {
|
function fetch_array($query, $result_type = MYSQL_ASSOC) {
|
||||||
if($result_type == 'MYSQL_ASSOC') $result_type = MYSQL_ASSOC;
|
if($result_type == 'MYSQL_ASSOC') $result_type = MYSQL_ASSOC;
|
||||||
return mysql_fetch_array($query, $result_type);
|
return mysql_fetch_array($query, $result_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_first($sql) {
|
function fetch_first($sql) {
|
||||||
return $this->fetch_array($this->query($sql));
|
return $this->fetch_array($this->query($sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
function result_first($sql) {
|
function result_first($sql) {
|
||||||
return $this->result($this->query($sql), 0);
|
return $this->result($this->query($sql), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function query($sql, $silent = false, $unbuffered = false) {
|
public function query($sql, $silent = false, $unbuffered = false) {
|
||||||
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
||||||
$starttime = microtime(true);
|
$starttime = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if('UNBUFFERED' === $silent) {
|
if('UNBUFFERED' === $silent) {
|
||||||
$silent = false;
|
$silent = false;
|
||||||
$unbuffered = true;
|
$unbuffered = true;
|
||||||
} elseif('SILENT' === $silent) {
|
} elseif('SILENT' === $silent) {
|
||||||
$silent = true;
|
$silent = true;
|
||||||
$unbuffered = false;
|
$unbuffered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$func = $unbuffered ? 'mysql_unbuffered_query' : 'mysql_query';
|
$func = $unbuffered ? 'mysql_unbuffered_query' : 'mysql_query';
|
||||||
|
|
||||||
if(!($query = $func($sql, $this->curlink))) {
|
if(!($query = $func($sql, $this->curlink))) {
|
||||||
if(in_array($this->errno(), array(2006, 2013)) && substr($silent, 0, 5) != 'RETRY') {
|
if(in_array($this->errno(), array(2006, 2013)) && substr($silent, 0, 5) != 'RETRY') {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
return $this->query($sql, 'RETRY'.$silent);
|
return $this->query($sql, 'RETRY'.$silent);
|
||||||
}
|
}
|
||||||
if(!$silent) {
|
if(!$silent) {
|
||||||
$this->halt($this->error(), $this->errno(), $sql);
|
$this->halt($this->error(), $this->errno(), $sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
||||||
$this->sqldebug[] = array($sql, number_format((microtime(true) - $starttime), 6), debug_backtrace(), $this->curlink);
|
$this->sqldebug[] = array($sql, number_format((microtime(true) - $starttime), 6), debug_backtrace(), $this->curlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->querynum++;
|
$this->querynum++;
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function affected_rows() {
|
function affected_rows() {
|
||||||
return mysql_affected_rows($this->curlink);
|
return mysql_affected_rows($this->curlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
return (($this->curlink) ? mysql_error($this->curlink) : mysql_error());
|
return (($this->curlink) ? mysql_error($this->curlink) : mysql_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
function errno() {
|
function errno() {
|
||||||
return intval(($this->curlink) ? mysql_errno($this->curlink) : mysql_errno());
|
return intval(($this->curlink) ? mysql_errno($this->curlink) : mysql_errno());
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $row = 0) {
|
function result($query, $row = 0) {
|
||||||
$query = @mysql_result($query, $row);
|
$query = @mysql_result($query, $row);
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_rows($query) {
|
function num_rows($query) {
|
||||||
$query = mysql_num_rows($query);
|
$query = mysql_num_rows($query);
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_fields($query) {
|
function num_fields($query) {
|
||||||
return mysql_num_fields($query);
|
return mysql_num_fields($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function free_result($query) {
|
function free_result($query) {
|
||||||
return mysql_free_result($query);
|
return mysql_free_result($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function insert_id() {
|
function insert_id() {
|
||||||
return ($id = mysql_insert_id($this->curlink)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
|
return ($id = mysql_insert_id($this->curlink)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row($query) {
|
function fetch_row($query) {
|
||||||
$query = mysql_fetch_row($query);
|
$query = mysql_fetch_row($query);
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_fields($query) {
|
function fetch_fields($query) {
|
||||||
return mysql_fetch_field($query);
|
return mysql_fetch_field($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function version() {
|
function version() {
|
||||||
if(empty($this->version)) {
|
if(empty($this->version)) {
|
||||||
$this->version = mysql_get_server_info($this->curlink);
|
$this->version = mysql_get_server_info($this->curlink);
|
||||||
}
|
}
|
||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function escape_string($str) {
|
function escape_string($str) {
|
||||||
return mysql_escape_string($str);
|
return mysql_escape_string($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
return mysql_close($this->curlink);
|
return mysql_close($this->curlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
function halt($message = '', $code = 0, $sql = '') {
|
function halt($message = '', $code = 0, $sql = '') {
|
||||||
throw new DbException($message, $code, $sql);
|
throw new DbException($message, $code, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,85 +1,85 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
class db_driver_mysql_slave extends db_driver_mysql
|
class db_driver_mysql_slave extends db_driver_mysql
|
||||||
{
|
{
|
||||||
|
|
||||||
public $slaveid = null;
|
public $slaveid = null;
|
||||||
|
|
||||||
public $slavequery = 0;
|
public $slavequery = 0;
|
||||||
|
|
||||||
public $slaveexcept = false;
|
public $slaveexcept = false;
|
||||||
|
|
||||||
public $excepttables = array();
|
public $excepttables = array();
|
||||||
|
|
||||||
public $tablename = '';
|
public $tablename = '';
|
||||||
|
|
||||||
protected $_weighttable = array();
|
protected $_weighttable = array();
|
||||||
|
|
||||||
public $serverid = null;
|
public $serverid = null;
|
||||||
|
|
||||||
function set_config($config) {
|
function set_config($config) {
|
||||||
parent::set_config($config);
|
parent::set_config($config);
|
||||||
|
|
||||||
if($this->config['common']['slave_except_table']) {
|
if($this->config['common']['slave_except_table']) {
|
||||||
$this->excepttables = explode(',', str_replace(' ', '', $this->config['common']['slave_except_table']));
|
$this->excepttables = explode(',', str_replace(' ', '', $this->config['common']['slave_except_table']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function table_name($tablename) {
|
public function table_name($tablename) {
|
||||||
$this->tablename = $tablename;
|
$this->tablename = $tablename;
|
||||||
if(!$this->slaveexcept && $this->excepttables) {
|
if(!$this->slaveexcept && $this->excepttables) {
|
||||||
$this->slaveexcept = in_array($tablename, $this->excepttables, true);
|
$this->slaveexcept = in_array($tablename, $this->excepttables, true);
|
||||||
}
|
}
|
||||||
$this->serverid = isset($this->map[$this->tablename]) ? $this->map[$this->tablename] : 1;
|
$this->serverid = isset($this->map[$this->tablename]) ? $this->map[$this->tablename] : 1;
|
||||||
return $this->tablepre.$tablename;
|
return $this->tablepre.$tablename;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _slave_connect() {
|
protected function _slave_connect() {
|
||||||
if(!empty($this->config[$this->serverid]['slave'])) {
|
if(!empty($this->config[$this->serverid]['slave'])) {
|
||||||
$this->_choose_slave();
|
$this->_choose_slave();
|
||||||
if($this->slaveid) {
|
if($this->slaveid) {
|
||||||
if(!isset($this->link[$this->slaveid])) {
|
if(!isset($this->link[$this->slaveid])) {
|
||||||
$this->connect($this->slaveid);
|
$this->connect($this->slaveid);
|
||||||
}
|
}
|
||||||
$this->slavequery ++;
|
$this->slavequery ++;
|
||||||
$this->curlink = $this->link[$this->slaveid];
|
$this->curlink = $this->link[$this->slaveid];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _choose_slave(){
|
protected function _choose_slave(){
|
||||||
if(!isset($this->_weighttable[$this->serverid])) {
|
if(!isset($this->_weighttable[$this->serverid])) {
|
||||||
foreach ($this->config[$this->serverid]['slave'] as $key => $value) {
|
foreach ($this->config[$this->serverid]['slave'] as $key => $value) {
|
||||||
$this->_weighttable[$this->serverid] .= str_repeat($key, 1 + intval($value['weight']));
|
$this->_weighttable[$this->serverid] .= str_repeat($key, 1 + intval($value['weight']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sid = $this->_weighttable[$this->serverid][mt_rand(0, strlen($this->_weighttable[$this->serverid]) -1)];
|
$sid = $this->_weighttable[$this->serverid][mt_rand(0, strlen($this->_weighttable[$this->serverid]) -1)];
|
||||||
$this->slaveid = $this->serverid.'_'.$sid;
|
$this->slaveid = $this->serverid.'_'.$sid;
|
||||||
if(!isset($this->config[$this->slaveid])) {
|
if(!isset($this->config[$this->slaveid])) {
|
||||||
$this->config[$this->slaveid] = $this->config[$this->serverid]['slave'][$sid];
|
$this->config[$this->slaveid] = $this->config[$this->serverid]['slave'][$sid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _master_connect() {
|
protected function _master_connect() {
|
||||||
if(!$this->link[$this->serverid]) {
|
if(!$this->link[$this->serverid]) {
|
||||||
$this->connect($this->serverid);
|
$this->connect($this->serverid);
|
||||||
}
|
}
|
||||||
$this->curlink = $this->link[$this->serverid];
|
$this->curlink = $this->link[$this->serverid];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function query($sql, $silent = false, $unbuffered = false) {
|
public function query($sql, $silent = false, $unbuffered = false) {
|
||||||
if(!(!$this->slaveexcept && strtoupper(substr($sql, 0 , 6)) === 'SELECT' && $this->_slave_connect())) {
|
if(!(!$this->slaveexcept && strtoupper(substr($sql, 0 , 6)) === 'SELECT' && $this->_slave_connect())) {
|
||||||
$this->_master_connect();
|
$this->_master_connect();
|
||||||
}
|
}
|
||||||
$this->tablename = '';
|
$this->tablename = '';
|
||||||
$this->slaveexcept = false;
|
$this->slaveexcept = false;
|
||||||
return parent::query($sql, $silent, $unbuffered);
|
return parent::query($sql, $silent, $unbuffered);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,225 +1,225 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class db_driver_mysqli
|
class db_driver_mysqli
|
||||||
{
|
{
|
||||||
var $tablepre;
|
var $tablepre;
|
||||||
var $version = '';
|
var $version = '';
|
||||||
var $drivertype = 'mysqli';
|
var $drivertype = 'mysqli';
|
||||||
var $querynum = 0;
|
var $querynum = 0;
|
||||||
var $slaveid = 0;
|
var $slaveid = 0;
|
||||||
var $curlink;
|
var $curlink;
|
||||||
var $link = array();
|
var $link = array();
|
||||||
var $config = array();
|
var $config = array();
|
||||||
var $sqldebug = array();
|
var $sqldebug = array();
|
||||||
var $map = array();
|
var $map = array();
|
||||||
|
|
||||||
function db_mysql($config = array()) {
|
function db_mysql($config = array()) {
|
||||||
if(!empty($config)) {
|
if(!empty($config)) {
|
||||||
$this->set_config($config);
|
$this->set_config($config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_config($config) {
|
function set_config($config) {
|
||||||
$this->config = &$config;
|
$this->config = &$config;
|
||||||
$this->tablepre = $config['1']['tablepre'];
|
$this->tablepre = $config['1']['tablepre'];
|
||||||
if(!empty($this->config['map'])) {
|
if(!empty($this->config['map'])) {
|
||||||
$this->map = $this->config['map'];
|
$this->map = $this->config['map'];
|
||||||
for($i = 1; $i <= 100; $i++) {
|
for($i = 1; $i <= 100; $i++) {
|
||||||
if(isset($this->map['attachment']) && $i <= 10) {
|
if(isset($this->map['attachment']) && $i <= 10) {
|
||||||
$this->map['attachment_'.($i-1)] = $this->map['attachment'];
|
$this->map['attachment_'.($i-1)] = $this->map['attachment'];
|
||||||
}
|
}
|
||||||
if(isset($this->map['user'])) {
|
if(isset($this->map['user'])) {
|
||||||
$this->map['user_status'] =
|
$this->map['user_status'] =
|
||||||
$this->map['user_profile'] =
|
$this->map['user_profile'] =
|
||||||
$this->map['user_field'] =
|
$this->map['user_field'] =
|
||||||
$this->map['user'];
|
$this->map['user'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function linknum(){
|
function linknum(){
|
||||||
return $this->curlink;
|
return $this->curlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($serverid = 1) {
|
function connect($serverid = 1) {
|
||||||
|
|
||||||
if(empty($this->config) || empty($this->config[$serverid])) {
|
if(empty($this->config) || empty($this->config[$serverid])) {
|
||||||
$this->halt('config_db_not_found');
|
$this->halt('config_db_not_found');
|
||||||
}
|
}
|
||||||
//兼容支持域名直接带有端口的情况
|
//兼容支持域名直接带有端口的情况
|
||||||
if(strpos($this->config[$serverid]['dbhost'],':')!==false){
|
if(strpos($this->config[$serverid]['dbhost'],':')!==false){
|
||||||
list($dbhost,$port)=explode(':',$this->config[$serverid]['dbhost']);
|
list($dbhost,$port)=explode(':',$this->config[$serverid]['dbhost']);
|
||||||
if($port && empty($this->config[$serverid]['port'])) $this->config[$serverid]['port']=$port;
|
if($port && empty($this->config[$serverid]['port'])) $this->config[$serverid]['port']=$port;
|
||||||
if($dbhost) $this->config[$serverid]['dbhost']=$dbhost;
|
if($dbhost) $this->config[$serverid]['dbhost']=$dbhost;
|
||||||
}elseif(strpos($this->config[$serverid]['dbhost'],'.sock')!==false){//地址直接是socket地址
|
}elseif(strpos($this->config[$serverid]['dbhost'],'.sock')!==false){//地址直接是socket地址
|
||||||
$this->config[$serverid]['unix_socket']=$this->config[$serverid]['dbhost'];
|
$this->config[$serverid]['unix_socket']=$this->config[$serverid]['dbhost'];
|
||||||
$this->config[$serverid]['dbhost']='localhost';
|
$this->config[$serverid]['dbhost']='localhost';
|
||||||
}
|
}
|
||||||
if(empty($this->config[$serverid]['port'])) $this->config[$serverid]['port']='3306';
|
if(empty($this->config[$serverid]['port'])) $this->config[$serverid]['port']='3306';
|
||||||
|
|
||||||
$this->link[$serverid] = $this->_dbconnect(
|
$this->link[$serverid] = $this->_dbconnect(
|
||||||
$this->config[$serverid]['dbhost'],
|
$this->config[$serverid]['dbhost'],
|
||||||
$this->config[$serverid]['dbuser'],
|
$this->config[$serverid]['dbuser'],
|
||||||
$this->config[$serverid]['dbpw'],
|
$this->config[$serverid]['dbpw'],
|
||||||
$this->config[$serverid]['dbcharset'],
|
$this->config[$serverid]['dbcharset'],
|
||||||
$this->config[$serverid]['dbname'],
|
$this->config[$serverid]['dbname'],
|
||||||
$this->config[$serverid]['pconnect'],
|
$this->config[$serverid]['pconnect'],
|
||||||
$this->config[$serverid]['port'],
|
$this->config[$serverid]['port'],
|
||||||
$this->config[$serverid]['unix_socket']
|
$this->config[$serverid]['unix_socket']
|
||||||
);
|
);
|
||||||
$this->curlink = $this->link[$serverid];
|
$this->curlink = $this->link[$serverid];
|
||||||
}
|
}
|
||||||
|
|
||||||
function _dbconnect($dbhost, $dbuser, $dbpw, $dbcharset, $dbname, $pconnect,$port='3306',$unix_socket='', $halt = true) {
|
function _dbconnect($dbhost, $dbuser, $dbpw, $dbcharset, $dbname, $pconnect,$port='3306',$unix_socket='', $halt = true) {
|
||||||
$link = new mysqli();
|
$link = new mysqli();
|
||||||
if(!$link->real_connect($dbhost, $dbuser, $dbpw, $dbname, $port, $unix_socket)) {
|
if(!$link->real_connect($dbhost, $dbuser, $dbpw, $dbname, $port, $unix_socket)) {
|
||||||
$halt && $this->halt('notconnect', $this->errno());
|
$halt && $this->halt('notconnect', $this->errno());
|
||||||
} else {
|
} else {
|
||||||
$this->curlink = $link;
|
$this->curlink = $link;
|
||||||
if($this->version() > '4.1') {
|
if($this->version() > '4.1') {
|
||||||
$link->set_charset($dbcharset ? $dbcharset : $this->config[1]['dbcharset']);
|
$link->set_charset($dbcharset ? $dbcharset : $this->config[1]['dbcharset']);
|
||||||
$serverset = $this->version() > '5.0.1' ? 'sql_mode=\'\'' : '';
|
$serverset = $this->version() > '5.0.1' ? 'sql_mode=\'\'' : '';
|
||||||
$serverset && $link->query("SET $serverset");
|
$serverset && $link->query("SET $serverset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_name($tablename) {
|
function table_name($tablename) {
|
||||||
if(!empty($this->map) && !empty($this->map[$tablename])) {
|
if(!empty($this->map) && !empty($this->map[$tablename])) {
|
||||||
$id = $this->map[$tablename];
|
$id = $this->map[$tablename];
|
||||||
if(!$this->link[$id]) {
|
if(!$this->link[$id]) {
|
||||||
$this->connect($id);
|
$this->connect($id);
|
||||||
}
|
}
|
||||||
$this->curlink = $this->link[$id];
|
$this->curlink = $this->link[$id];
|
||||||
} else {
|
} else {
|
||||||
$this->curlink = $this->link[1];
|
$this->curlink = $this->link[1];
|
||||||
}
|
}
|
||||||
return $this->tablepre.$tablename;
|
return $this->tablepre.$tablename;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($dbname) {
|
function select_db($dbname) {
|
||||||
return $this->curlink->select_db($dbname);
|
return $this->curlink->select_db($dbname);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_array($query, $result_type = MYSQLI_ASSOC) {
|
function fetch_array($query, $result_type = MYSQLI_ASSOC) {
|
||||||
if($result_type == 'MYSQL_ASSOC') $result_type = MYSQLI_ASSOC;
|
if($result_type == 'MYSQL_ASSOC') $result_type = MYSQLI_ASSOC;
|
||||||
return $query ? $query->fetch_array($result_type) : null;
|
return $query ? $query->fetch_array($result_type) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_first($sql) {
|
function fetch_first($sql) {
|
||||||
return $this->fetch_array($this->query($sql));
|
return $this->fetch_array($this->query($sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
function result_first($sql) {
|
function result_first($sql) {
|
||||||
return $this->result($this->query($sql), 0);
|
return $this->result($this->query($sql), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function query($sql, $silent = false, $unbuffered = false) {
|
public function query($sql, $silent = false, $unbuffered = false) {
|
||||||
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
||||||
$starttime = microtime(true);
|
$starttime = microtime(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if('UNBUFFERED' === $silent) {
|
if('UNBUFFERED' === $silent) {
|
||||||
$silent = false;
|
$silent = false;
|
||||||
$unbuffered = true;
|
$unbuffered = true;
|
||||||
} elseif('SILENT' === $silent) {
|
} elseif('SILENT' === $silent) {
|
||||||
$silent = true;
|
$silent = true;
|
||||||
$unbuffered = false;
|
$unbuffered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resultmode = $unbuffered ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT;
|
$resultmode = $unbuffered ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT;
|
||||||
|
|
||||||
if(!($query = $this->curlink->query($sql, $resultmode))) {
|
if(!($query = $this->curlink->query($sql, $resultmode))) {
|
||||||
if(in_array($this->errno(), array(2006, 2013)) && substr($silent, 0, 5) != 'RETRY') {
|
if(in_array($this->errno(), array(2006, 2013)) && substr($silent, 0, 5) != 'RETRY') {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
return $this->curlink->query($sql, 'RETRY'.$silent);
|
return $this->curlink->query($sql, 'RETRY'.$silent);
|
||||||
}
|
}
|
||||||
if(!$silent) {
|
if(!$silent) {
|
||||||
$this->halt($this->error(), $this->errno(), $sql);
|
$this->halt($this->error(), $this->errno(), $sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
if(defined('DZZ_DEBUG') && DZZ_DEBUG) {
|
||||||
$this->sqldebug[] = array($sql, number_format((microtime(true) - $starttime), 6), debug_backtrace(), $this->curlink);
|
$this->sqldebug[] = array($sql, number_format((microtime(true) - $starttime), 6), debug_backtrace(), $this->curlink);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->querynum++;
|
$this->querynum++;
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function affected_rows() {
|
function affected_rows() {
|
||||||
return $this->curlink->affected_rows;
|
return $this->curlink->affected_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
return (($this->curlink) ? $this->curlink->error : mysqli_error());
|
return (($this->curlink) ? $this->curlink->error : mysqli_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
function errno() {
|
function errno() {
|
||||||
return intval(($this->curlink) ? $this->curlink->errno : mysqli_errno());
|
return intval(($this->curlink) ? $this->curlink->errno : mysqli_errno());
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $row = 0) {
|
function result($query, $row = 0) {
|
||||||
if(!$query || $query->num_rows == 0) {
|
if(!$query || $query->num_rows == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$query->data_seek($row);
|
$query->data_seek($row);
|
||||||
$assocs = $query->fetch_row();
|
$assocs = $query->fetch_row();
|
||||||
return $assocs[0];
|
return $assocs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_rows($query) {
|
function num_rows($query) {
|
||||||
$query = $query ? $query->num_rows : 0;
|
$query = $query ? $query->num_rows : 0;
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function num_fields($query) {
|
function num_fields($query) {
|
||||||
return $query ? $query->field_count : null;
|
return $query ? $query->field_count : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function free_result($query) {
|
function free_result($query) {
|
||||||
return $query ? $query->free() : false;
|
return $query ? $query->free() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function insert_id() {
|
function insert_id() {
|
||||||
return ($id = $this->curlink->insert_id) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
|
return ($id = $this->curlink->insert_id) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row($query) {
|
function fetch_row($query) {
|
||||||
$query = $query ? $query->fetch_row() : null;
|
$query = $query ? $query->fetch_row() : null;
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_fields($query) {
|
function fetch_fields($query) {
|
||||||
return $query ? $query->fetch_field() : null;
|
return $query ? $query->fetch_field() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function version() {
|
function version() {
|
||||||
if(empty($this->version)) {
|
if(empty($this->version)) {
|
||||||
$this->version = $this->curlink->server_info;
|
$this->version = $this->curlink->server_info;
|
||||||
}
|
}
|
||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
function escape_string($str) {
|
function escape_string($str) {
|
||||||
return $this->curlink->escape_string($str);
|
return $this->curlink->escape_string($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
return $this->curlink->close();
|
return $this->curlink->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function halt($message = '', $code = 0, $sql = '') {
|
function halt($message = '', $code = 0, $sql = '') {
|
||||||
throw new DbException($message, $code, $sql);
|
throw new DbException($message, $code, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -1,86 +1,86 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class db_driver_mysqli_slave extends db_driver_mysqli
|
class db_driver_mysqli_slave extends db_driver_mysqli
|
||||||
{
|
{
|
||||||
|
|
||||||
public $slaveid = null;
|
public $slaveid = null;
|
||||||
|
|
||||||
public $slavequery = 0;
|
public $slavequery = 0;
|
||||||
|
|
||||||
public $slaveexcept = false;
|
public $slaveexcept = false;
|
||||||
|
|
||||||
public $excepttables = array();
|
public $excepttables = array();
|
||||||
|
|
||||||
public $tablename = '';
|
public $tablename = '';
|
||||||
|
|
||||||
protected $_weighttable = array();
|
protected $_weighttable = array();
|
||||||
|
|
||||||
public $serverid = null;
|
public $serverid = null;
|
||||||
|
|
||||||
function set_config($config) {
|
function set_config($config) {
|
||||||
parent::set_config($config);
|
parent::set_config($config);
|
||||||
|
|
||||||
if($this->config['common']['slave_except_table']) {
|
if($this->config['common']['slave_except_table']) {
|
||||||
$this->excepttables = explode(',', str_replace(' ', '', $this->config['common']['slave_except_table']));
|
$this->excepttables = explode(',', str_replace(' ', '', $this->config['common']['slave_except_table']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function table_name($tablename) {
|
public function table_name($tablename) {
|
||||||
$this->tablename = $tablename;
|
$this->tablename = $tablename;
|
||||||
if(!$this->slaveexcept && $this->excepttables) {
|
if(!$this->slaveexcept && $this->excepttables) {
|
||||||
$this->slaveexcept = in_array($tablename, $this->excepttables, true);
|
$this->slaveexcept = in_array($tablename, $this->excepttables, true);
|
||||||
}
|
}
|
||||||
$this->serverid = isset($this->map[$this->tablename]) ? $this->map[$this->tablename] : 1;
|
$this->serverid = isset($this->map[$this->tablename]) ? $this->map[$this->tablename] : 1;
|
||||||
return $this->tablepre.$tablename;
|
return $this->tablepre.$tablename;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _slave_connect() {
|
protected function _slave_connect() {
|
||||||
if(!empty($this->config[$this->serverid]['slave'])) {
|
if(!empty($this->config[$this->serverid]['slave'])) {
|
||||||
$this->_choose_slave();
|
$this->_choose_slave();
|
||||||
if($this->slaveid) {
|
if($this->slaveid) {
|
||||||
if(!isset($this->link[$this->slaveid])) {
|
if(!isset($this->link[$this->slaveid])) {
|
||||||
$this->connect($this->slaveid);
|
$this->connect($this->slaveid);
|
||||||
}
|
}
|
||||||
$this->slavequery ++;
|
$this->slavequery ++;
|
||||||
$this->curlink = $this->link[$this->slaveid];
|
$this->curlink = $this->link[$this->slaveid];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _choose_slave(){
|
protected function _choose_slave(){
|
||||||
if(!isset($this->_weighttable[$this->serverid])) {
|
if(!isset($this->_weighttable[$this->serverid])) {
|
||||||
foreach ($this->config[$this->serverid]['slave'] as $key => $value) {
|
foreach ($this->config[$this->serverid]['slave'] as $key => $value) {
|
||||||
$this->_weighttable[$this->serverid] .= str_repeat($key, 1 + intval($value['weight']));
|
$this->_weighttable[$this->serverid] .= str_repeat($key, 1 + intval($value['weight']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sid = $this->_weighttable[$this->serverid][mt_rand(0, strlen($this->_weighttable[$this->serverid]) -1)];
|
$sid = $this->_weighttable[$this->serverid][mt_rand(0, strlen($this->_weighttable[$this->serverid]) -1)];
|
||||||
$this->slaveid = $this->serverid.'_'.$sid;
|
$this->slaveid = $this->serverid.'_'.$sid;
|
||||||
if(!isset($this->config[$this->slaveid])) {
|
if(!isset($this->config[$this->slaveid])) {
|
||||||
$this->config[$this->slaveid] = $this->config[$this->serverid]['slave'][$sid];
|
$this->config[$this->slaveid] = $this->config[$this->serverid]['slave'][$sid];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _master_connect() {
|
protected function _master_connect() {
|
||||||
if(!$this->link[$this->serverid]) {
|
if(!$this->link[$this->serverid]) {
|
||||||
$this->connect($this->serverid);
|
$this->connect($this->serverid);
|
||||||
}
|
}
|
||||||
$this->curlink = $this->link[$this->serverid];
|
$this->curlink = $this->link[$this->serverid];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function query($sql, $silent = false, $unbuffered = false) {
|
public function query($sql, $silent = false, $unbuffered = false) {
|
||||||
if(!(!$this->slaveexcept && strtoupper(substr($sql, 0 , 6)) === 'SELECT' && $this->_slave_connect())) {
|
if(!(!$this->slaveexcept && strtoupper(substr($sql, 0 , 6)) === 'SELECT' && $this->_slave_connect())) {
|
||||||
$this->_master_connect();
|
$this->_master_connect();
|
||||||
}
|
}
|
||||||
$this->tablename = '';
|
$this->tablename = '';
|
||||||
$this->slaveexcept = false;
|
$this->slaveexcept = false;
|
||||||
return parent::query($sql, $silent, $unbuffered);
|
return parent::query($sql, $silent, $unbuffered);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,75 +1,75 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
|
|
||||||
class Datareturn
|
class Datareturn
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $returnData = '';
|
private static $returnData = '';
|
||||||
|
|
||||||
private static $template = '';
|
private static $template = '';
|
||||||
|
|
||||||
public static function data_return($type = 'json', $data = '', $template = '')
|
public static function data_return($type = 'json', $data = '', $template = '')
|
||||||
{
|
{
|
||||||
self::$returnData = $data;
|
self::$returnData = $data;
|
||||||
|
|
||||||
self::$template = $template;
|
self::$template = $template;
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
|
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
||||||
self::json_return();
|
self::json_return();
|
||||||
break;
|
break;
|
||||||
case 'string':
|
case 'string':
|
||||||
|
|
||||||
self::string_return();
|
self::string_return();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'html':
|
case 'html':
|
||||||
|
|
||||||
self::html_return();
|
self::html_return();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Array':
|
case 'Array':
|
||||||
self::Array_return();
|
self::Array_return();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
self::json_return();
|
self::json_return();
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function Array_return()
|
private static function Array_return()
|
||||||
{
|
{
|
||||||
return self::$returnData;
|
return self::$returnData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function json_return()
|
private static function json_return()
|
||||||
{
|
{
|
||||||
|
|
||||||
echo json_encode(self::$returnData);
|
echo json_encode(self::$returnData);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function html_return()
|
private static function html_return()
|
||||||
{
|
{
|
||||||
|
|
||||||
extract(self::$returnData);
|
extract(self::$returnData);
|
||||||
|
|
||||||
include template(self::$template);
|
include template(self::$template);
|
||||||
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function string_return()
|
private static function string_return()
|
||||||
{
|
{
|
||||||
if(isset(self::$returnData['error'])){
|
if(isset(self::$returnData['error'])){
|
||||||
echo self::$returnData['error'];
|
echo self::$returnData['error'];
|
||||||
}else{
|
}else{
|
||||||
echo self::$returnData;
|
echo self::$returnData;
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,186 +1,186 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
class Hook
|
class Hook
|
||||||
{
|
{
|
||||||
|
|
||||||
private static $tags = array();
|
private static $tags = array();
|
||||||
public static $usetag = array();
|
public static $usetag = array();
|
||||||
/**
|
/**
|
||||||
* 动态添加行为扩展到某个标签
|
* 动态添加行为扩展到某个标签
|
||||||
* @param string $tag 标签名称
|
* @param string $tag 标签名称
|
||||||
* @param mixed $behavior 行为名称
|
* @param mixed $behavior 行为名称
|
||||||
* @param mixed $behavior 行为名称
|
* @param mixed $behavior 行为名称
|
||||||
* @param bool $first 是否放到开头执行
|
* @param bool $first 是否放到开头执行
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function add($tag, $behavior, $first = false)
|
public static function add($tag, $behavior, $first = false)
|
||||||
{
|
{
|
||||||
isset(self::$tags[$tag]) || self::$tags[$tag] = array();
|
isset(self::$tags[$tag]) || self::$tags[$tag] = array();
|
||||||
if (is_array($behavior) && !is_callable($behavior)) {//此处废弃,暂不调整
|
if (is_array($behavior) && !is_callable($behavior)) {//此处废弃,暂不调整
|
||||||
if (!array_key_exists('_overlay', $behavior) || !$behavior['_overlay']) {
|
if (!array_key_exists('_overlay', $behavior) || !$behavior['_overlay']) {
|
||||||
unset($behavior['_overlay']);
|
unset($behavior['_overlay']);
|
||||||
self::$tags[$tag] = array_merge(self::$tags[$tag], $behavior);
|
self::$tags[$tag] = array_merge(self::$tags[$tag], $behavior);
|
||||||
} else {
|
} else {
|
||||||
unset($behavior['_overlay']);
|
unset($behavior['_overlay']);
|
||||||
self::$tags[$tag] = $behavior;
|
self::$tags[$tag] = $behavior;
|
||||||
}
|
}
|
||||||
} elseif ($first) {
|
} elseif ($first) {
|
||||||
array_unshift(self::$tags[$tag], $behavior);
|
array_unshift(self::$tags[$tag], $behavior);
|
||||||
} else {
|
} else {
|
||||||
self::$tags[$tag][] = $behavior;
|
self::$tags[$tag][] = $behavior;
|
||||||
}
|
}
|
||||||
self::$tags[$tag]=array_unique( self::$tags[$tag]);
|
self::$tags[$tag]=array_unique( self::$tags[$tag]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量导入插件
|
* 批量导入插件
|
||||||
* @param array $tags 插件信息
|
* @param array $tags 插件信息
|
||||||
* @param boolean $recursive 是否递归合并
|
* @param boolean $recursive 是否递归合并
|
||||||
*/
|
*/
|
||||||
public static function import(array $tags, $recursive = true)
|
public static function import(array $tags, $recursive = true)
|
||||||
{
|
{
|
||||||
if ($recursive) {
|
if ($recursive) {
|
||||||
foreach ($tags as $tag => $behavior) {
|
foreach ($tags as $tag => $behavior) {
|
||||||
self::add($tag, $behavior);
|
self::add($tag, $behavior);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self::$tags = $tags + self::$tags;
|
self::$tags = $tags + self::$tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取插件信息
|
* 获取插件信息
|
||||||
* @param string $tag 插件位置 留空获取全部
|
* @param string $tag 插件位置 留空获取全部
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function get($tag = '')
|
public static function get($tag = '')
|
||||||
{
|
{
|
||||||
if (empty($tag)) {
|
if (empty($tag)) {
|
||||||
//获取全部的插件信息
|
//获取全部的插件信息
|
||||||
return self::$tags;
|
return self::$tags;
|
||||||
} else {
|
} else {
|
||||||
return array_key_exists($tag, self::$tags) ? self::$tags[$tag] : array();
|
return array_key_exists($tag, self::$tags) ? self::$tags[$tag] : array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监听标签的行为
|
* 监听标签的行为
|
||||||
* @param string $tag 标签名称
|
* @param string $tag 标签名称
|
||||||
* @param mixed $params 传入参数
|
* @param mixed $params 传入参数
|
||||||
* @param mixed $extra 额外参数
|
* @param mixed $extra 额外参数
|
||||||
* @param bool $once 只获取一个有效返回值
|
* @param bool $once 只获取一个有效返回值
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function listen($tag, &$params = null, $extra = null,$once = false)
|
public static function listen($tag, &$params = null, $extra = null,$once = false)
|
||||||
{
|
{
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$tags = static::get($tag);
|
$tags = static::get($tag);
|
||||||
|
|
||||||
$break = false;
|
$break = false;
|
||||||
|
|
||||||
foreach ($tags as $key => $name) {
|
foreach ($tags as $key => $name) {
|
||||||
|
|
||||||
if(is_array($name)){
|
if(is_array($name)){
|
||||||
foreach($name as $val){
|
foreach($name as $val){
|
||||||
$results[$key] = self::exec($val, $tag, $params, $extra,$break);
|
$results[$key] = self::exec($val, $tag, $params, $extra,$break);
|
||||||
|
|
||||||
if (false === $results[$key] || $break == true) {
|
if (false === $results[$key] || $break == true) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} elseif($once) {
|
} elseif($once) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$results[$key] = self::exec($name, $tag, $params, $extra,$break);
|
$results[$key] = self::exec($name, $tag, $params, $extra,$break);
|
||||||
|
|
||||||
if (false === $results[$key] || $break == true) {
|
if (false === $results[$key] || $break == true) {
|
||||||
|
|
||||||
// 如果返回false 则中断行为执行
|
// 如果返回false 则中断行为执行
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} elseif ($once) {
|
} elseif ($once) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $once ? ($results?end($results):$results) : $results;
|
return $once ? ($results?end($results):$results) : $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行某个行为
|
* 执行某个行为
|
||||||
* @param mixed $class 要执行的行为
|
* @param mixed $class 要执行的行为
|
||||||
* @param string $tag 方法名(标签名)
|
* @param string $tag 方法名(标签名)
|
||||||
* @param Mixed $params 传人的参数
|
* @param Mixed $params 传人的参数
|
||||||
* @param mixed $extra 额外参数
|
* @param mixed $extra 额外参数
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function exec($class, $tag = '', &$params = null,$extra = null,&$break)
|
public static function exec($class, $tag = '', &$params = null,$extra = null,&$break)
|
||||||
{
|
{
|
||||||
if(strpos($class,'|') !== false){//判断是否规定了作用域,并判断作用域确定是否执行钩子
|
if(strpos($class,'|') !== false){//判断是否规定了作用域,并判断作用域确定是否执行钩子
|
||||||
$rangArr = explode('|',$class);
|
$rangArr = explode('|',$class);
|
||||||
$class = $rangArr[0];
|
$class = $rangArr[0];
|
||||||
$range = $rangArr[1];
|
$range = $rangArr[1];
|
||||||
if(defined('CURMODULE')){
|
if(defined('CURMODULE')){
|
||||||
$execrange = CURSCRIPT.'/'.CURMODULE;
|
$execrange = CURSCRIPT.'/'.CURMODULE;
|
||||||
}else{
|
}else{
|
||||||
$execrange = CURSCRIPT;
|
$execrange = CURSCRIPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strpos($execrange,$range) !== 0){
|
if(strpos($execrange,$range) !== 0){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//self::$usetag[] = $tag;
|
//self::$usetag[] = $tag;
|
||||||
$method = static::parseName($tag, 1, false);
|
$method = static::parseName($tag, 1, false);
|
||||||
if ($class instanceof \Closure) {
|
if ($class instanceof \Closure) {
|
||||||
|
|
||||||
$result = call_user_func_array($class, array( & $params, $extra));
|
$result = call_user_func_array($class, array( & $params, $extra));
|
||||||
$class = 'Closure';
|
$class = 'Closure';
|
||||||
|
|
||||||
} elseif (is_array($class)) {
|
} elseif (is_array($class)) {
|
||||||
list($class, $method) = $class;
|
list($class, $method) = $class;
|
||||||
$classobj = new $class();
|
$classobj = new $class();
|
||||||
$result = $classobj->$method($params, $extra);
|
$result = $classobj->$method($params, $extra);
|
||||||
//$result = (new $class())->$method($params, $extra);
|
//$result = (new $class())->$method($params, $extra);
|
||||||
//$result = call_user_func_array(array($class,$method), array( & $params, $extra));
|
//$result = call_user_func_array(array($class,$method), array( & $params, $extra));
|
||||||
$class = $class . '->' . $method;
|
$class = $class . '->' . $method;
|
||||||
|
|
||||||
} elseif (is_object($class)) {
|
} elseif (is_object($class)) {
|
||||||
|
|
||||||
$result = $class->$method($params, $extra);
|
$result = $class->$method($params, $extra);
|
||||||
$class = get_class($class);
|
$class = get_class($class);
|
||||||
|
|
||||||
} elseif (strpos($class, '::')) {
|
} elseif (strpos($class, '::')) {
|
||||||
|
|
||||||
$result = call_user_func_array($class, array( & $params, $extra));
|
$result = call_user_func_array($class, array( & $params, $extra));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$obj = new $class();
|
$obj = new $class();
|
||||||
$method = ($tag && is_callable(array($obj, $method))) ? $method : 'run';
|
$method = ($tag && is_callable(array($obj, $method))) ? $method : 'run';
|
||||||
$result = $obj->$method($params, $extra,$break);
|
$result = $obj->$method($params, $extra,$break);
|
||||||
|
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseName($name, $type = 0, $ucfirst = true)
|
public static function parseName($name, $type = 0, $ucfirst = true)
|
||||||
{
|
{
|
||||||
if ($type) {
|
if ($type) {
|
||||||
$name = preg_replace_callback('/_([a-zA-Z])/', function ($match) {
|
$name = preg_replace_callback('/_([a-zA-Z])/', function ($match) {
|
||||||
return strtoupper($match[1]);
|
return strtoupper($match[1]);
|
||||||
}, $name);
|
}, $name);
|
||||||
return $ucfirst ? ucfirst($name) : lcfirst($name);
|
return $ucfirst ? ucfirst($name) : lcfirst($name);
|
||||||
} else {
|
} else {
|
||||||
return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_"));
|
return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,169 +1,169 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Created by PhpStorm.
|
* Created by PhpStorm.
|
||||||
* User: a
|
* User: a
|
||||||
* Date: 2017/2/9
|
* Date: 2017/2/9
|
||||||
* Time: 11:33
|
* Time: 11:33
|
||||||
*/
|
*/
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
|
|
||||||
class HookRead
|
class HookRead
|
||||||
{
|
{
|
||||||
|
|
||||||
public static $tags = array();//钩子数组
|
public static $tags = array();//钩子数组
|
||||||
|
|
||||||
public static $tagcachefile = '';//钩子列表缓存文件
|
public static $tagcachefile = '';//钩子列表缓存文件
|
||||||
|
|
||||||
private static $cacheTagFileCtime = 0;//钩子列表缓存文件生成时间
|
private static $cacheTagFileCtime = 0;//钩子列表缓存文件生成时间
|
||||||
|
|
||||||
/*初始化
|
/*初始化
|
||||||
* @description 增加系统预埋钩子
|
* @description 增加系统预埋钩子
|
||||||
* CACHE_DIR 缓存目录
|
* CACHE_DIR 缓存目录
|
||||||
* */
|
* */
|
||||||
public static function _init()
|
public static function _init()
|
||||||
{
|
{
|
||||||
self::$tagcachefile = CACHE_DIR . BS . 'tags' . EXT;//钩子列表缓存文件路径
|
self::$tagcachefile = CACHE_DIR . BS . 'tags' . EXT;//钩子列表缓存文件路径
|
||||||
|
|
||||||
if (file_exists(self::$tagcachefile)) {
|
if (file_exists(self::$tagcachefile)) {
|
||||||
|
|
||||||
self::$tags = is_array(include self::$tagcachefile) ? include self::$tagcachefile:array();
|
self::$tags = is_array(include self::$tagcachefile) ? include self::$tagcachefile:array();
|
||||||
|
|
||||||
self::$cacheTagFileCtime = filectime(self::$tagcachefile);
|
self::$cacheTagFileCtime = filectime(self::$tagcachefile);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::readTags();//读取系统预埋钩子
|
self::readTags();//读取系统预埋钩子
|
||||||
|
|
||||||
if(file_exists(self::$tagcachefile)){//判断钩子列表缓存文件是否生成
|
if(file_exists(self::$tagcachefile)){//判断钩子列表缓存文件是否生成
|
||||||
|
|
||||||
self::$tags = is_array(include self::$tagcachefile) ? include self::$tagcachefile:array();//读取钩子列表缓存文件
|
self::$tags = is_array(include self::$tagcachefile) ? include self::$tagcachefile:array();//读取钩子列表缓存文件
|
||||||
|
|
||||||
self::$tags = self::tagsArrayParse(self::$tags);//缓存钩子列表文件内容处理
|
self::$tags = self::tagsArrayParse(self::$tags);//缓存钩子列表文件内容处理
|
||||||
|
|
||||||
Hook::import(self::$tags);//导入钩子
|
Hook::import(self::$tags);//导入钩子
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @description 递归读取所有的钩子列表文件(根目录,应用目录,模块目录)
|
* @description 递归读取所有的钩子列表文件(根目录,应用目录,模块目录)
|
||||||
* @$dirname 默认为根目录
|
* @$dirname 默认为根目录
|
||||||
* @$deep 读取文件层级
|
* @$deep 读取文件层级
|
||||||
* @return null
|
* @return null
|
||||||
* */
|
* */
|
||||||
private static function readTags($dirname = DZZ_ROOT,$deep = 0)
|
private static function readTags($dirname = DZZ_ROOT,$deep = 0)
|
||||||
{
|
{
|
||||||
if(!is_dir($dirname)){
|
if(!is_dir($dirname)){
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dirname = rtrim($dirname,BS);
|
$dirname = rtrim($dirname,BS);
|
||||||
|
|
||||||
$deep++;
|
$deep++;
|
||||||
|
|
||||||
$openfile = opendir($dirname);
|
$openfile = opendir($dirname);
|
||||||
|
|
||||||
while (($file = readdir($openfile)) !== false) {
|
while (($file = readdir($openfile)) !== false) {
|
||||||
|
|
||||||
if ($file != '.' && $file != '..' && is_dir($dirname.BS.$file) && strpos($file,'.') !== 0) {
|
if ($file != '.' && $file != '..' && is_dir($dirname.BS.$file) && strpos($file,'.') !== 0) {
|
||||||
|
|
||||||
$dir = $dirname .BS. $file;
|
$dir = $dirname .BS. $file;
|
||||||
|
|
||||||
|
|
||||||
if($file == CONFIG_NAME){
|
if($file == CONFIG_NAME){
|
||||||
|
|
||||||
$tagfile = $dir.BS. 'tags' . EXT;
|
$tagfile = $dir.BS. 'tags' . EXT;
|
||||||
|
|
||||||
if (file_exists($tagfile)) {
|
if (file_exists($tagfile)) {
|
||||||
|
|
||||||
if ( !file_exists(self::$tagcachefile) || (filemtime($tagfile) > self::$cacheTagFileCtime)) {
|
if ( !file_exists(self::$tagcachefile) || (filemtime($tagfile) > self::$cacheTagFileCtime)) {
|
||||||
|
|
||||||
$key = str_replace(array(DZZ_ROOT,CONFIG_NAME.BS),'',$dir);
|
$key = str_replace(array(DZZ_ROOT,CONFIG_NAME.BS),'',$dir);
|
||||||
|
|
||||||
$tagsArr = include $tagfile;
|
$tagsArr = include $tagfile;
|
||||||
|
|
||||||
if(is_array($tagsArr)){
|
if(is_array($tagsArr)){
|
||||||
|
|
||||||
self::$tags[$key] = $tagsArr;
|
self::$tags[$key] = $tagsArr;
|
||||||
|
|
||||||
$writestr = "<?php \t\n return ";
|
$writestr = "<?php \t\n return ";
|
||||||
|
|
||||||
$writestr .= var_export(self::$tags,true).";";
|
$writestr .= var_export(self::$tags,true).";";
|
||||||
|
|
||||||
$fp = fopen(self::$tagcachefile,'w+');
|
$fp = fopen(self::$tagcachefile,'w+');
|
||||||
|
|
||||||
fwrite($fp,$writestr);
|
fwrite($fp,$writestr);
|
||||||
|
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if($deep <= 3){
|
if($deep <= 3){
|
||||||
|
|
||||||
self::readTags($dir,$deep);
|
self::readTags($dir,$deep);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closedir($openfile);
|
closedir($openfile);
|
||||||
}
|
}
|
||||||
/*@description钩子缓存数组处理函数
|
/*@description钩子缓存数组处理函数
|
||||||
* @$arr array
|
* @$arr array
|
||||||
* @return array
|
* @return array
|
||||||
* */
|
* */
|
||||||
private static function tagsArrayParse($arr = null){
|
private static function tagsArrayParse($arr = null){
|
||||||
|
|
||||||
if(!is_array($arr)) return false;
|
if(!is_array($arr)) return false;
|
||||||
|
|
||||||
$tagArrReturn = array();
|
$tagArrReturn = array();
|
||||||
|
|
||||||
foreach($arr as $v){
|
foreach($arr as $v){
|
||||||
|
|
||||||
foreach($v as $key=>$val){
|
foreach($v as $key=>$val){
|
||||||
|
|
||||||
$keyArr = array_keys($val);
|
$keyArr = array_keys($val);
|
||||||
|
|
||||||
foreach($keyArr as $k=>$value){//取出所有键,加上p
|
foreach($keyArr as $k=>$value){//取出所有键,加上p
|
||||||
|
|
||||||
$keyArr[$k] = 'p'.$value;
|
$keyArr[$k] = 'p'.$value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$val = array_combine($keyArr,$val);//用新键值组成数组
|
$val = array_combine($keyArr,$val);//用新键值组成数组
|
||||||
|
|
||||||
if(isset($tagArrReturn[$key])){
|
if(isset($tagArrReturn[$key])){
|
||||||
|
|
||||||
$tagArrReturn[$key] = array_merge_recursive($tagArrReturn[$key],$val);
|
$tagArrReturn[$key] = array_merge_recursive($tagArrReturn[$key],$val);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$tagArrReturn[$key] = $val;
|
$tagArrReturn[$key] = $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//去掉键所加的p,并对数组进行排序
|
//去掉键所加的p,并对数组进行排序
|
||||||
foreach($tagArrReturn as $item=>$ival){
|
foreach($tagArrReturn as $item=>$ival){
|
||||||
|
|
||||||
$pkey = array_keys($ival);
|
$pkey = array_keys($ival);
|
||||||
|
|
||||||
foreach ($pkey as $n=>$ivalue){
|
foreach ($pkey as $n=>$ivalue){
|
||||||
|
|
||||||
$pkey[$n] = str_replace('p','',$ivalue);
|
$pkey[$n] = str_replace('p','',$ivalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ival = array_combine($pkey,$ival);
|
$ival = array_combine($pkey,$ival);
|
||||||
|
|
||||||
krsort($ival,SORT_NUMERIC);
|
krsort($ival,SORT_NUMERIC);
|
||||||
|
|
||||||
$tagArrReturn[$item] = $ival;
|
$tagArrReturn[$item] = $ival;
|
||||||
|
|
||||||
}
|
}
|
||||||
return $tagArrReturn;
|
return $tagArrReturn;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,338 +1,338 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
use DB;
|
use DB;
|
||||||
class Tpsql extends Tpdb{
|
class Tpsql extends Tpdb{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 架构函数 读取数据库配置信息
|
* 架构函数 读取数据库配置信息
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $config 数据库配置数组
|
* @param array $config 数据库配置数组
|
||||||
*/
|
*/
|
||||||
public function __construct($config=''){
|
public function __construct($config=''){
|
||||||
if ( !extension_loaded('mysql') ) {
|
if ( !extension_loaded('mysql') ) {
|
||||||
echo lang('does_mysqli');
|
echo lang('does_mysqli');
|
||||||
exit;
|
exit;
|
||||||
//E(L('_NOT_SUPPERT_').':mysql');
|
//E(L('_NOT_SUPPERT_').':mysql');
|
||||||
}
|
}
|
||||||
if(!empty($config)) {
|
if(!empty($config)) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
if(empty($this->config['params'])) {
|
if(empty($this->config['params'])) {
|
||||||
$this->config['params'] = '';
|
$this->config['params'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连接数据库方法
|
* 连接数据库方法
|
||||||
* @access public
|
* @access public
|
||||||
* @throws ThinkExecption
|
* @throws ThinkExecption
|
||||||
*/
|
*/
|
||||||
public function connect($config='',$linkNum=1,$force=false) {
|
public function connect($config='',$linkNum=1,$force=false) {
|
||||||
$this->linkID[$linkNum] =DB::linknum();
|
$this->linkID[$linkNum] =DB::linknum();
|
||||||
if ( !isset($this->linkID[$linkNum]) ) {
|
if ( !isset($this->linkID[$linkNum]) ) {
|
||||||
if(empty($config)) $config = $this->config;
|
if(empty($config)) $config = $this->config;
|
||||||
// 处理不带端口号的socket连接情况
|
// 处理不带端口号的socket连接情况
|
||||||
$host = $config['dbhost'].(isset($config['hostport'])?":{$config['hostport']}":'');
|
$host = $config['dbhost'].(isset($config['hostport'])?":{$config['hostport']}":'');
|
||||||
// 是否长连接
|
// 是否长连接
|
||||||
$pconnect =$config['pconnect']; // !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
|
$pconnect =$config['pconnect']; // !empty($config['params']['persist'])? $config['params']['persist']:$this->pconnect;
|
||||||
if($pconnect) {
|
if($pconnect) {
|
||||||
$this->linkID[$linkNum] = mysql_pconnect( $host, $config['dbuser'], $config['dbpw'],131072);
|
$this->linkID[$linkNum] = mysql_pconnect( $host, $config['dbuser'], $config['dbpw'],131072);
|
||||||
}else{
|
}else{
|
||||||
$this->linkID[$linkNum] = mysql_connect( $host, $config['dbuser'], $config['dbpw'],true,131072);
|
$this->linkID[$linkNum] = mysql_connect( $host, $config['dbuser'], $config['dbpw'],true,131072);
|
||||||
}
|
}
|
||||||
if ( !$this->linkID[$linkNum] || (!empty($config['dbname']) && !mysql_select_db($config['dbname'], $this->linkID[$linkNum])) ) {
|
if ( !$this->linkID[$linkNum] || (!empty($config['dbname']) && !mysql_select_db($config['dbname'], $this->linkID[$linkNum])) ) {
|
||||||
echo lang('database_error');exit;
|
echo lang('database_error');exit;
|
||||||
//E(mysql_error());
|
//E(mysql_error());
|
||||||
}
|
}
|
||||||
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
|
$dbVersion = mysql_get_server_info($this->linkID[$linkNum]);
|
||||||
//使用UTF8存取数据库
|
//使用UTF8存取数据库
|
||||||
mysql_query("SET NAMES 'utf-8'", $this->linkID[$linkNum]);
|
mysql_query("SET NAMES 'utf-8'", $this->linkID[$linkNum]);
|
||||||
//设置 sql_model
|
//设置 sql_model
|
||||||
if($dbVersion >'5.0.1'){
|
if($dbVersion >'5.0.1'){
|
||||||
mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
|
mysql_query("SET sql_mode=''",$this->linkID[$linkNum]);
|
||||||
}
|
}
|
||||||
// 标记连接成功
|
// 标记连接成功
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
// 注销数据库连接配置信息
|
// 注销数据库连接配置信息
|
||||||
//if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
|
//if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
|
||||||
}
|
}
|
||||||
//print_r( $this->linkID[$linkNum] );exit;
|
//print_r( $this->linkID[$linkNum] );exit;
|
||||||
return $this->linkID[$linkNum];
|
return $this->linkID[$linkNum];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 释放查询结果
|
* 释放查询结果
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function free() {
|
public function free() {
|
||||||
mysql_free_result($this->queryID);
|
mysql_free_result($this->queryID);
|
||||||
$this->queryID = null;
|
$this->queryID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行查询 返回数据集
|
* 执行查询 返回数据集
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $str sql指令
|
* @param string $str sql指令
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function query($str) {
|
public function query($str) {
|
||||||
if(0===stripos($str, 'call')){ // 存储过程查询支持
|
if(0===stripos($str, 'call')){ // 存储过程查询支持
|
||||||
$this->close();
|
$this->close();
|
||||||
$this->connected = false;
|
$this->connected = false;
|
||||||
}
|
}
|
||||||
$this->initConnect(false);
|
$this->initConnect(false);
|
||||||
if ( !$this->_linkID ) return false;
|
if ( !$this->_linkID ) return false;
|
||||||
$this->queryStr = $str;
|
$this->queryStr = $str;
|
||||||
//释放前次的查询结果
|
//释放前次的查询结果
|
||||||
if ( $this->queryID ) { $this->free(); }
|
if ( $this->queryID ) { $this->free(); }
|
||||||
//N('db_query',1);
|
//N('db_query',1);
|
||||||
// 记录开始执行时间
|
// 记录开始执行时间
|
||||||
//G('queryStartTime');
|
//G('queryStartTime');
|
||||||
$this->queryID = mysql_query($str, $this->_linkID);
|
$this->queryID = mysql_query($str, $this->_linkID);
|
||||||
$this->debug();
|
$this->debug();
|
||||||
if ( false === $this->queryID ) {
|
if ( false === $this->queryID ) {
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$this->numRows = mysql_num_rows($this->queryID);
|
$this->numRows = mysql_num_rows($this->queryID);
|
||||||
return $this->getAll();
|
return $this->getAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行语句
|
* 执行语句
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $str sql指令
|
* @param string $str sql指令
|
||||||
* @return integer|false
|
* @return integer|false
|
||||||
*/
|
*/
|
||||||
public function execute($str) {
|
public function execute($str) {
|
||||||
$this->initConnect(true);
|
$this->initConnect(true);
|
||||||
if ( !$this->_linkID ) return false;
|
if ( !$this->_linkID ) return false;
|
||||||
$this->queryStr = $str;
|
$this->queryStr = $str;
|
||||||
//释放前次的查询结果
|
//释放前次的查询结果
|
||||||
if ( $this->queryID ) { $this->free(); }
|
if ( $this->queryID ) { $this->free(); }
|
||||||
//N('db_write',1);
|
//N('db_write',1);
|
||||||
// 记录开始执行时间
|
// 记录开始执行时间
|
||||||
//G('queryStartTime');
|
//G('queryStartTime');
|
||||||
$result = mysql_query($str, $this->_linkID) ;
|
$result = mysql_query($str, $this->_linkID) ;
|
||||||
$this->debug();
|
$this->debug();
|
||||||
if ( false === $result) {
|
if ( false === $result) {
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$this->numRows = mysql_affected_rows($this->_linkID);
|
$this->numRows = mysql_affected_rows($this->_linkID);
|
||||||
$this->lastInsID = mysql_insert_id($this->_linkID);
|
$this->lastInsID = mysql_insert_id($this->_linkID);
|
||||||
return $this->numRows;
|
return $this->numRows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动事务
|
* 启动事务
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTrans() {
|
public function startTrans() {
|
||||||
$this->initConnect(true);
|
$this->initConnect(true);
|
||||||
if ( !$this->_linkID ) return false;
|
if ( !$this->_linkID ) return false;
|
||||||
//数据rollback 支持
|
//数据rollback 支持
|
||||||
if ($this->transTimes == 0) {
|
if ($this->transTimes == 0) {
|
||||||
mysql_query('START TRANSACTION', $this->_linkID);
|
mysql_query('START TRANSACTION', $this->_linkID);
|
||||||
}
|
}
|
||||||
$this->transTimes++;
|
$this->transTimes++;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于非自动提交状态下面的查询提交
|
* 用于非自动提交状态下面的查询提交
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolen
|
* @return boolen
|
||||||
*/
|
*/
|
||||||
public function commit() {
|
public function commit() {
|
||||||
if ($this->transTimes > 0) {
|
if ($this->transTimes > 0) {
|
||||||
$result = mysql_query('COMMIT', $this->_linkID);
|
$result = mysql_query('COMMIT', $this->_linkID);
|
||||||
$this->transTimes = 0;
|
$this->transTimes = 0;
|
||||||
if(!$result){
|
if(!$result){
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事务回滚
|
* 事务回滚
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolen
|
* @return boolen
|
||||||
*/
|
*/
|
||||||
public function rollback() {
|
public function rollback() {
|
||||||
if ($this->transTimes > 0) {
|
if ($this->transTimes > 0) {
|
||||||
$result = mysql_query('ROLLBACK', $this->_linkID);
|
$result = mysql_query('ROLLBACK', $this->_linkID);
|
||||||
$this->transTimes = 0;
|
$this->transTimes = 0;
|
||||||
if(!$result){
|
if(!$result){
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得所有的查询数据
|
* 获得所有的查询数据
|
||||||
* @access private
|
* @access private
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getAll() {
|
private function getAll() {
|
||||||
//返回数据集
|
//返回数据集
|
||||||
$result = array();
|
$result = array();
|
||||||
if($this->numRows >0) {
|
if($this->numRows >0) {
|
||||||
while($row = mysql_fetch_assoc($this->queryID)){
|
while($row = mysql_fetch_assoc($this->queryID)){
|
||||||
$result[] = $row;
|
$result[] = $row;
|
||||||
}
|
}
|
||||||
mysql_data_seek($this->queryID,0);
|
mysql_data_seek($this->queryID,0);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得数据表的字段信息
|
* 取得数据表的字段信息
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getFields($tableName) {
|
public function getFields($tableName) {
|
||||||
$result = $this->query('SHOW COLUMNS FROM '.$this->parseKey($tableName));
|
$result = $this->query('SHOW COLUMNS FROM '.$this->parseKey($tableName));
|
||||||
$info = array();
|
$info = array();
|
||||||
if($result) {
|
if($result) {
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
$info[$val['Field']] = array(
|
$info[$val['Field']] = array(
|
||||||
'name' => $val['Field'],
|
'name' => $val['Field'],
|
||||||
'type' => $val['Type'],
|
'type' => $val['Type'],
|
||||||
'notnull' => (bool) (strtoupper($val['Null']) === 'NO'), // not null is empty, null is yes
|
'notnull' => (bool) (strtoupper($val['Null']) === 'NO'), // not null is empty, null is yes
|
||||||
'default' => $val['Default'],
|
'default' => $val['Default'],
|
||||||
'primary' => (strtolower($val['Key']) == 'pri'),
|
'primary' => (strtolower($val['Key']) == 'pri'),
|
||||||
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
|
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得数据库的表信息
|
* 取得数据库的表信息
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getTables($dbName='') {
|
public function getTables($dbName='') {
|
||||||
if(!empty($dbName)) {
|
if(!empty($dbName)) {
|
||||||
$sql = 'SHOW TABLES FROM '.$dbName;
|
$sql = 'SHOW TABLES FROM '.$dbName;
|
||||||
}else{
|
}else{
|
||||||
$sql = 'SHOW TABLES ';
|
$sql = 'SHOW TABLES ';
|
||||||
}
|
}
|
||||||
$result = $this->query($sql);
|
$result = $this->query($sql);
|
||||||
$info = array();
|
$info = array();
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
$info[$key] = current($val);
|
$info[$key] = current($val);
|
||||||
}
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换记录
|
* 替换记录
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $data 数据
|
* @param mixed $data 数据
|
||||||
* @param array $options 参数表达式
|
* @param array $options 参数表达式
|
||||||
* @return false | integer
|
* @return false | integer
|
||||||
*/
|
*/
|
||||||
public function replace($data,$options=array()) {
|
public function replace($data,$options=array()) {
|
||||||
foreach ($data as $key=>$val){
|
foreach ($data as $key=>$val){
|
||||||
$value = $this->parseValue($val);
|
$value = $this->parseValue($val);
|
||||||
if(is_scalar($value)) { // 过滤非标量数据
|
if(is_scalar($value)) { // 过滤非标量数据
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
$fields[] = $this->parseKey($key);
|
$fields[] = $this->parseKey($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = 'REPLACE INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
|
$sql = 'REPLACE INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
|
||||||
return $this->execute($sql);
|
return $this->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入记录
|
* 插入记录
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $datas 数据
|
* @param mixed $datas 数据
|
||||||
* @param array $options 参数表达式
|
* @param array $options 参数表达式
|
||||||
* @param boolean $replace 是否replace
|
* @param boolean $replace 是否replace
|
||||||
* @return false | integer
|
* @return false | integer
|
||||||
*/
|
*/
|
||||||
public function insertAll($datas,$options=array(),$replace=false) {
|
public function insertAll($datas,$options=array(),$replace=false) {
|
||||||
if(!is_array($datas[0])) return false;
|
if(!is_array($datas[0])) return false;
|
||||||
$fields = array_keys($datas[0]);
|
$fields = array_keys($datas[0]);
|
||||||
array_walk($fields, array($this, 'parseKey'));
|
array_walk($fields, array($this, 'parseKey'));
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($datas as $data){
|
foreach ($datas as $data){
|
||||||
$value = array();
|
$value = array();
|
||||||
foreach ($data as $key=>$val){
|
foreach ($data as $key=>$val){
|
||||||
$val = $this->parseValue($val);
|
$val = $this->parseValue($val);
|
||||||
if(is_scalar($val)) { // 过滤非标量数据
|
if(is_scalar($val)) { // 过滤非标量数据
|
||||||
$value[] = $val;
|
$value[] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$values[] = '('.implode(',', $value).')';
|
$values[] = '('.implode(',', $value).')';
|
||||||
}
|
}
|
||||||
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values);
|
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values);
|
||||||
return $this->execute($sql);
|
return $this->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭数据库
|
* 关闭数据库
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close() {
|
||||||
if ($this->_linkID){
|
if ($this->_linkID){
|
||||||
mysql_close($this->_linkID);
|
mysql_close($this->_linkID);
|
||||||
}
|
}
|
||||||
$this->_linkID = null;
|
$this->_linkID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库错误信息
|
* 数据库错误信息
|
||||||
* 并显示当前的SQL语句
|
* 并显示当前的SQL语句
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function error() {
|
public function error() {
|
||||||
$this->error = mysql_errno().':'.mysql_error($this->_linkID);
|
$this->error = mysql_errno().':'.mysql_error($this->_linkID);
|
||||||
if('' != $this->queryStr){
|
if('' != $this->queryStr){
|
||||||
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
|
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
|
||||||
}
|
}
|
||||||
//trace($this->error,'','ERR');
|
//trace($this->error,'','ERR');
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL指令安全过滤
|
* SQL指令安全过滤
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $str SQL字符串
|
* @param string $str SQL字符串
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeString($str) {
|
public function escapeString($str) {
|
||||||
if($this->_linkID) {
|
if($this->_linkID) {
|
||||||
return mysql_real_escape_string($str,$this->_linkID);
|
return mysql_real_escape_string($str,$this->_linkID);
|
||||||
}else{
|
}else{
|
||||||
return mysql_escape_string($str);
|
return mysql_escape_string($str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段和表名处理添加`
|
* 字段和表名处理添加`
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseKey(&$key) {
|
protected function parseKey(&$key) {
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if(!preg_match('/[,\'\"\*\(\)`.\s]/',$key)) {
|
if(!preg_match('/[,\'\"\*\(\)`.\s]/',$key)) {
|
||||||
$key = '`'.$key.'`';
|
$key = '`'.$key.'`';
|
||||||
}
|
}
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,333 +1,333 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
use DB;
|
use DB;
|
||||||
class Tpsqli extends Tpdb{
|
class Tpsqli extends Tpdb{
|
||||||
/**
|
/**
|
||||||
* 架构函数 读取数据库配置信息
|
* 架构函数 读取数据库配置信息
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $config 数据库配置数组
|
* @param array $config 数据库配置数组
|
||||||
*/
|
*/
|
||||||
public function __construct($config=''){
|
public function __construct($config=''){
|
||||||
if ( !extension_loaded('mysqli') ) {
|
if ( !extension_loaded('mysqli') ) {
|
||||||
echo lang('does_mysqli');
|
echo lang('does_mysqli');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if(!empty($config)) {
|
if(!empty($config)) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
if(empty($this->config['params'])) {
|
if(empty($this->config['params'])) {
|
||||||
$this->config['params'] = '';
|
$this->config['params'] = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 连接数据库方法
|
* 连接数据库方法
|
||||||
* @access public
|
* @access public
|
||||||
* @throws ThinkExecption
|
* @throws ThinkExecption
|
||||||
*/
|
*/
|
||||||
public function connect($config='',$linkNum=0) {
|
public function connect($config='',$linkNum=0) {
|
||||||
$this->linkID[$linkNum] =DB::linknum();
|
$this->linkID[$linkNum] =DB::linknum();
|
||||||
if ( !isset($this->linkID[$linkNum]) ) {
|
if ( !isset($this->linkID[$linkNum]) ) {
|
||||||
if(empty($config)) $config = $this->config;
|
if(empty($config)) $config = $this->config;
|
||||||
$this->linkID[$linkNum] = new \mysqli($config['hostname'],$config['username'],$config['password'],$config['database'],$config['hostport']?intval($config['hostport']):3306);
|
$this->linkID[$linkNum] = new \mysqli($config['hostname'],$config['username'],$config['password'],$config['database'],$config['hostport']?intval($config['hostport']):3306);
|
||||||
if (mysqli_connect_errno()){
|
if (mysqli_connect_errno()){
|
||||||
echo lang('database_error');exit;//E(mysqli_connect_error());
|
echo lang('database_error');exit;//E(mysqli_connect_error());
|
||||||
}
|
}
|
||||||
$dbVersion = $this->linkID[$linkNum]->server_version;
|
$dbVersion = $this->linkID[$linkNum]->server_version;
|
||||||
|
|
||||||
// 设置数据库编码
|
// 设置数据库编码
|
||||||
$this->linkID[$linkNum]->query("SET NAMES '".C('DB_CHARSET')."'");
|
$this->linkID[$linkNum]->query("SET NAMES '".C('DB_CHARSET')."'");
|
||||||
//设置 sql_model
|
//设置 sql_model
|
||||||
if($dbVersion >'5.0.1'){
|
if($dbVersion >'5.0.1'){
|
||||||
$this->linkID[$linkNum]->query("SET sql_mode=''");
|
$this->linkID[$linkNum]->query("SET sql_mode=''");
|
||||||
}
|
}
|
||||||
// 标记连接成功
|
// 标记连接成功
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
//注销数据库安全信息
|
//注销数据库安全信息
|
||||||
if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
|
if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
|
||||||
}
|
}
|
||||||
return $this->linkID[$linkNum];
|
return $this->linkID[$linkNum];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 释放查询结果
|
* 释放查询结果
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function free() {
|
public function free() {
|
||||||
$this->queryID->free_result();
|
$this->queryID->free_result();
|
||||||
$this->queryID = null;
|
$this->queryID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行查询 返回数据集
|
* 执行查询 返回数据集
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $str sql指令
|
* @param string $str sql指令
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function query($str) {
|
public function query($str) {
|
||||||
$this->initConnect(false);
|
$this->initConnect(false);
|
||||||
if ( !$this->_linkID ) return false;
|
if ( !$this->_linkID ) return false;
|
||||||
$this->queryStr = $str;
|
$this->queryStr = $str;
|
||||||
//释放前次的查询结果
|
//释放前次的查询结果
|
||||||
if ( $this->queryID ) $this->free();
|
if ( $this->queryID ) $this->free();
|
||||||
//N('db_query',1);
|
//N('db_query',1);
|
||||||
// 记录开始执行时间
|
// 记录开始执行时间
|
||||||
//G('queryStartTime');
|
//G('queryStartTime');
|
||||||
$this->queryID = $this->_linkID->query($str);
|
$this->queryID = $this->_linkID->query($str);
|
||||||
// 对存储过程改进
|
// 对存储过程改进
|
||||||
if( $this->_linkID->more_results() ){
|
if( $this->_linkID->more_results() ){
|
||||||
while (($res = $this->_linkID->next_result()) != NULL) {
|
while (($res = $this->_linkID->next_result()) != NULL) {
|
||||||
$res->free_result();
|
$res->free_result();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->debug();
|
$this->debug();
|
||||||
if ( false === $this->queryID ) {
|
if ( false === $this->queryID ) {
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$this->numRows = $this->queryID->num_rows;
|
$this->numRows = $this->queryID->num_rows;
|
||||||
$this->numCols = $this->queryID->field_count;
|
$this->numCols = $this->queryID->field_count;
|
||||||
return $this->getAll();
|
return $this->getAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行语句
|
* 执行语句
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $str sql指令
|
* @param string $str sql指令
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
public function execute($str) {
|
public function execute($str) {
|
||||||
$this->initConnect(true);
|
$this->initConnect(true);
|
||||||
if ( !$this->_linkID ) return false;
|
if ( !$this->_linkID ) return false;
|
||||||
$this->queryStr = $str;
|
$this->queryStr = $str;
|
||||||
//释放前次的查询结果
|
//释放前次的查询结果
|
||||||
if ( $this->queryID ) $this->free();
|
if ( $this->queryID ) $this->free();
|
||||||
//N('db_write',1);
|
//N('db_write',1);
|
||||||
// 记录开始执行时间
|
// 记录开始执行时间
|
||||||
//G('queryStartTime');
|
//G('queryStartTime');
|
||||||
$result = $this->_linkID->query($str);
|
$result = $this->_linkID->query($str);
|
||||||
$this->debug();
|
$this->debug();
|
||||||
if ( false === $result ) {
|
if ( false === $result ) {
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$this->numRows = $this->_linkID->affected_rows;
|
$this->numRows = $this->_linkID->affected_rows;
|
||||||
$this->lastInsID = $this->_linkID->insert_id;
|
$this->lastInsID = $this->_linkID->insert_id;
|
||||||
return $this->numRows;
|
return $this->numRows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启动事务
|
* 启动事务
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function startTrans() {
|
public function startTrans() {
|
||||||
$this->initConnect(true);
|
$this->initConnect(true);
|
||||||
//数据rollback 支持
|
//数据rollback 支持
|
||||||
if ($this->transTimes == 0) {
|
if ($this->transTimes == 0) {
|
||||||
$this->_linkID->autocommit(false);
|
$this->_linkID->autocommit(false);
|
||||||
}
|
}
|
||||||
$this->transTimes++;
|
$this->transTimes++;
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于非自动提交状态下面的查询提交
|
* 用于非自动提交状态下面的查询提交
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolen
|
* @return boolen
|
||||||
*/
|
*/
|
||||||
public function commit() {
|
public function commit() {
|
||||||
if ($this->transTimes > 0) {
|
if ($this->transTimes > 0) {
|
||||||
$result = $this->_linkID->commit();
|
$result = $this->_linkID->commit();
|
||||||
$this->_linkID->autocommit( true);
|
$this->_linkID->autocommit( true);
|
||||||
$this->transTimes = 0;
|
$this->transTimes = 0;
|
||||||
if(!$result){
|
if(!$result){
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事务回滚
|
* 事务回滚
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolen
|
* @return boolen
|
||||||
*/
|
*/
|
||||||
public function rollback() {
|
public function rollback() {
|
||||||
if ($this->transTimes > 0) {
|
if ($this->transTimes > 0) {
|
||||||
$result = $this->_linkID->rollback();
|
$result = $this->_linkID->rollback();
|
||||||
$this->_linkID->autocommit( true);
|
$this->_linkID->autocommit( true);
|
||||||
$this->transTimes = 0;
|
$this->transTimes = 0;
|
||||||
if(!$result){
|
if(!$result){
|
||||||
$this->error();
|
$this->error();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得所有的查询数据
|
* 获得所有的查询数据
|
||||||
* @access private
|
* @access private
|
||||||
* @param string $sql sql语句
|
* @param string $sql sql语句
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getAll() {
|
private function getAll() {
|
||||||
//返回数据集
|
//返回数据集
|
||||||
$result = array();
|
$result = array();
|
||||||
if($this->numRows>0) {
|
if($this->numRows>0) {
|
||||||
//返回数据集
|
//返回数据集
|
||||||
for($i=0;$i<$this->numRows ;$i++ ){
|
for($i=0;$i<$this->numRows ;$i++ ){
|
||||||
$result[$i] = $this->queryID->fetch_assoc();
|
$result[$i] = $this->queryID->fetch_assoc();
|
||||||
}
|
}
|
||||||
$this->queryID->data_seek(0);
|
$this->queryID->data_seek(0);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得数据表的字段信息
|
* 取得数据表的字段信息
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getFields($tableName) {
|
public function getFields($tableName) {
|
||||||
$result = $this->query('SHOW COLUMNS FROM '.$this->parseKey($tableName));
|
$result = $this->query('SHOW COLUMNS FROM '.$this->parseKey($tableName));
|
||||||
$info = array();
|
$info = array();
|
||||||
if($result) {
|
if($result) {
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
$info[$val['Field']] = array(
|
$info[$val['Field']] = array(
|
||||||
'name' => $val['Field'],
|
'name' => $val['Field'],
|
||||||
'type' => $val['Type'],
|
'type' => $val['Type'],
|
||||||
'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
|
'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
|
||||||
'default' => $val['Default'],
|
'default' => $val['Default'],
|
||||||
'primary' => (strtolower($val['Key']) == 'pri'),
|
'primary' => (strtolower($val['Key']) == 'pri'),
|
||||||
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
|
'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得数据表的字段信息
|
* 取得数据表的字段信息
|
||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getTables($dbName='') {
|
public function getTables($dbName='') {
|
||||||
$sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES ';
|
$sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES ';
|
||||||
$result = $this->query($sql);
|
$result = $this->query($sql);
|
||||||
$info = array();
|
$info = array();
|
||||||
if($result) {
|
if($result) {
|
||||||
foreach ($result as $key => $val) {
|
foreach ($result as $key => $val) {
|
||||||
$info[$key] = current($val);
|
$info[$key] = current($val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 替换记录
|
* 替换记录
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $data 数据
|
* @param mixed $data 数据
|
||||||
* @param array $options 参数表达式
|
* @param array $options 参数表达式
|
||||||
* @return false | integer
|
* @return false | integer
|
||||||
*/
|
*/
|
||||||
public function replace($data,$options=array()) {
|
public function replace($data,$options=array()) {
|
||||||
foreach ($data as $key=>$val){
|
foreach ($data as $key=>$val){
|
||||||
$value = $this->parseValue($val);
|
$value = $this->parseValue($val);
|
||||||
if(is_scalar($value)) { // 过滤非标量数据
|
if(is_scalar($value)) { // 过滤非标量数据
|
||||||
$values[] = $value;
|
$values[] = $value;
|
||||||
$fields[] = $this->parseKey($key);
|
$fields[] = $this->parseKey($key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql = 'REPLACE INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
|
$sql = 'REPLACE INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')';
|
||||||
return $this->execute($sql);
|
return $this->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入记录
|
* 插入记录
|
||||||
* @access public
|
* @access public
|
||||||
* @param mixed $datas 数据
|
* @param mixed $datas 数据
|
||||||
* @param array $options 参数表达式
|
* @param array $options 参数表达式
|
||||||
* @param boolean $replace 是否replace
|
* @param boolean $replace 是否replace
|
||||||
* @return false | integer
|
* @return false | integer
|
||||||
*/
|
*/
|
||||||
public function insertAll($datas,$options=array(),$replace=false) {
|
public function insertAll($datas,$options=array(),$replace=false) {
|
||||||
if(!is_array($datas[0])) return false;
|
if(!is_array($datas[0])) return false;
|
||||||
$fields = array_keys($datas[0]);
|
$fields = array_keys($datas[0]);
|
||||||
array_walk($fields, array($this, 'parseKey'));
|
array_walk($fields, array($this, 'parseKey'));
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($datas as $data){
|
foreach ($datas as $data){
|
||||||
$value = array();
|
$value = array();
|
||||||
foreach ($data as $key=>$val){
|
foreach ($data as $key=>$val){
|
||||||
$val = $this->parseValue($val);
|
$val = $this->parseValue($val);
|
||||||
if(is_scalar($val)) { // 过滤非标量数据
|
if(is_scalar($val)) { // 过滤非标量数据
|
||||||
$value[] = $val;
|
$value[] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$values[] = '('.implode(',', $value).')';
|
$values[] = '('.implode(',', $value).')';
|
||||||
}
|
}
|
||||||
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values);
|
$sql = ($replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values);
|
||||||
return $this->execute($sql);
|
return $this->execute($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭数据库
|
* 关闭数据库
|
||||||
* @access public
|
* @access public
|
||||||
* @return volid
|
* @return volid
|
||||||
*/
|
*/
|
||||||
public function close() {
|
public function close() {
|
||||||
if ($this->_linkID){
|
if ($this->_linkID){
|
||||||
$this->_linkID->close();
|
$this->_linkID->close();
|
||||||
}
|
}
|
||||||
$this->_linkID = null;
|
$this->_linkID = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库错误信息
|
* 数据库错误信息
|
||||||
* 并显示当前的SQL语句
|
* 并显示当前的SQL语句
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function error() {
|
public function error() {
|
||||||
$this->error = $this->_linkID->errno.':'.$this->_linkID->error;
|
$this->error = $this->_linkID->errno.':'.$this->_linkID->error;
|
||||||
if('' != $this->queryStr){
|
if('' != $this->queryStr){
|
||||||
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
|
$this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
|
||||||
}
|
}
|
||||||
//trace($this->error,'','ERR');
|
//trace($this->error,'','ERR');
|
||||||
return $this->error;
|
return $this->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL指令安全过滤
|
* SQL指令安全过滤
|
||||||
* @static
|
* @static
|
||||||
* @access public
|
* @access public
|
||||||
* @param string $str SQL指令
|
* @param string $str SQL指令
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function escapeString($str) {
|
public function escapeString($str) {
|
||||||
if($this->_linkID) {
|
if($this->_linkID) {
|
||||||
return $this->_linkID->real_escape_string($str);
|
return $this->_linkID->real_escape_string($str);
|
||||||
}else{
|
}else{
|
||||||
return addslashes($str);
|
return addslashes($str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字段和表名处理添加`
|
* 字段和表名处理添加`
|
||||||
* @access protected
|
* @access protected
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseKey(&$key) {
|
protected function parseKey(&$key) {
|
||||||
$key = trim($key);
|
$key = trim($key);
|
||||||
if(!preg_match('/[,\'\"\*\(\)`.\s]/',$key)) {
|
if(!preg_match('/[,\'\"\*\(\)`.\s]/',$key)) {
|
||||||
$key = '`'.$key.'`';
|
$key = '`'.$key.'`';
|
||||||
}
|
}
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,51 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
|
|
||||||
use \core as C;
|
use \core as C;
|
||||||
|
|
||||||
class Apprun{
|
class Apprun{
|
||||||
|
|
||||||
public function run(){
|
public function run(){
|
||||||
|
|
||||||
global $_config;
|
global $_config;
|
||||||
|
|
||||||
$this->mod_prem_check($_config['MOD_VIEW_PERM']);
|
$this->mod_prem_check($_config['MOD_VIEW_PERM']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mod_prem_check($chkarr = array()){
|
private function mod_prem_check($chkarr = array()){
|
||||||
|
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
if(!empty($chkarr)){
|
if(!empty($chkarr)){
|
||||||
|
|
||||||
if(!defined('CURMODULE')) return false;
|
if(!defined('CURMODULE')) return false;
|
||||||
|
|
||||||
foreach ($chkarr as $v){
|
foreach ($chkarr as $v){
|
||||||
|
|
||||||
$modarr = explode(',',$v['MOD_NAME']);
|
$modarr = explode(',',$v['MOD_NAME']);
|
||||||
|
|
||||||
if(in_array(CURMODULE,$modarr)){
|
if(in_array(CURMODULE,$modarr)){
|
||||||
|
|
||||||
$this->perm_chk($v['PERM']);
|
$this->perm_chk($v['PERM']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function perm_chk($perm = ''){
|
private function perm_chk($perm = ''){
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
switch ($perm){
|
switch ($perm){
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case 1:if(!$_G['uid']) exit('Access Denied');
|
case 1:if(!$_G['uid']) exit('Access Denied');
|
||||||
break;
|
break;
|
||||||
case 2:if($_G['adminid']!=1) exit('Access Denied');
|
case 2:if($_G['adminid']!=1) exit('Access Denied');
|
||||||
break;
|
break;
|
||||||
case 3: if(!C::t('user')->checkfounder($_G['member'])) exit('Access Denied');
|
case 3: if(!C::t('user')->checkfounder($_G['member'])) exit('Access Denied');
|
||||||
break;
|
break;
|
||||||
default: exit('arg error');
|
default: exit('arg error');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,66 +1,66 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace core\dzz;
|
namespace core\dzz;
|
||||||
|
|
||||||
class Config{
|
class Config{
|
||||||
|
|
||||||
public function run(&$param){
|
public function run(&$param){
|
||||||
|
|
||||||
global $_config,$_G,$_GET;
|
global $_config,$_G,$_GET;
|
||||||
|
|
||||||
//应用常量
|
//应用常量
|
||||||
define('APP_PATH',CURSCRIPT);
|
define('APP_PATH',CURSCRIPT);
|
||||||
define('APP_NAME',CURSCRIPT);
|
define('APP_NAME',CURSCRIPT);
|
||||||
define('APP_DIR',DZZ_ROOT.APP_PATH);
|
define('APP_DIR',DZZ_ROOT.APP_PATH);
|
||||||
define('APP_URL','index.php');
|
define('APP_URL','index.php');
|
||||||
//默认应用配置
|
//默认应用配置
|
||||||
$default_mod_file=DZZ_ROOT.'./data/cache/default_mod.php';
|
$default_mod_file=DZZ_ROOT.'./data/cache/default_mod.php';
|
||||||
if(CURSCRIPT == 'dzz' && @file_exists($default_mod_file)){
|
if(CURSCRIPT == 'dzz' && @file_exists($default_mod_file)){
|
||||||
$default_mod_config = require_once $default_mod_file;
|
$default_mod_config = require_once $default_mod_file;
|
||||||
$_config = array_merge($_config,$default_mod_config);
|
$_config = array_merge($_config,$default_mod_config);
|
||||||
}
|
}
|
||||||
//应用配置
|
//应用配置
|
||||||
if(@file_exists(DZZ_ROOT.CURSCRIPT.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT)){
|
if(@file_exists(DZZ_ROOT.CURSCRIPT.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT)){
|
||||||
$app_config = require_once DZZ_ROOT.CURSCRIPT.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT;
|
$app_config = require_once DZZ_ROOT.CURSCRIPT.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT;
|
||||||
if(isset($app_config['db']) ){
|
if(isset($app_config['db']) ){
|
||||||
unset($app_config['db']);
|
unset($app_config['db']);
|
||||||
}
|
}
|
||||||
$_config = array_merge($_config,$app_config);
|
$_config = array_merge($_config,$app_config);
|
||||||
}
|
}
|
||||||
$mod = isset($param[MOULD]) ? $param[MOULD]:$_config['default_mod'];
|
$mod = isset($param[MOULD]) ? $param[MOULD]:$_config['default_mod'];
|
||||||
|
|
||||||
if(!empty($mod)){
|
if(!empty($mod)){
|
||||||
if(strpos($mod,'vapp_')!==false){
|
if(strpos($mod,'vapp_')!==false){
|
||||||
$_GET['vapp']=preg_replace("/^vapp_/i",'',$mod);
|
$_GET['vapp']=preg_replace("/^vapp_/i",'',$mod);
|
||||||
$mod='vapp';
|
$mod='vapp';
|
||||||
}
|
}
|
||||||
if(strpos(strtolower($mod),':')!==false) {
|
if(strpos(strtolower($mod),':')!==false) {
|
||||||
$patharr = explode(':', $mod);
|
$patharr = explode(':', $mod);
|
||||||
$modvar = true;
|
$modvar = true;
|
||||||
foreach ($patharr as $path) {
|
foreach ($patharr as $path) {
|
||||||
if (!preg_match("/\w+/i", $path)) $modvar = false;
|
if (!preg_match("/\w+/i", $path)) $modvar = false;
|
||||||
}
|
}
|
||||||
if($modvar) define('CURMODULE',str_replace(':', '/', $mod));
|
if($modvar) define('CURMODULE',str_replace(':', '/', $mod));
|
||||||
}else{
|
}else{
|
||||||
/* if(CURSCRIPT == 'dzz' && $mod == 'index'){
|
/* if(CURSCRIPT == 'dzz' && $mod == 'index'){
|
||||||
define('CURMODULE',CURSCRIPT);
|
define('CURMODULE',CURSCRIPT);
|
||||||
$modconfig = DZZ_ROOT.CURMODULE.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT;
|
$modconfig = DZZ_ROOT.CURMODULE.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT;
|
||||||
}else{*/
|
}else{*/
|
||||||
define('CURMODULE',$mod);
|
define('CURMODULE',$mod);
|
||||||
$modconfig = DZZ_ROOT.APP_PATH.BS.CURMODULE.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT;
|
$modconfig = DZZ_ROOT.APP_PATH.BS.CURMODULE.BS.CONFIG_NAME.BS.CONFIG_NAME.EXT;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
if(@file_exists($modconfig)){
|
if(@file_exists($modconfig)){
|
||||||
//模块配置
|
//模块配置
|
||||||
$mod_config = require_once $modconfig;
|
$mod_config = require_once $modconfig;
|
||||||
if(isset($mod_config['db']) ){
|
if(isset($mod_config['db']) ){
|
||||||
unset($mod_config['db']);
|
unset($mod_config['db']);
|
||||||
}
|
}
|
||||||
//配置合并
|
//配置合并
|
||||||
if(is_array($mod_config)){
|
if(is_array($mod_config)){
|
||||||
$_config = array_merge($_config,$mod_config);
|
$_config = array_merge($_config,$mod_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,245 +1,245 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_admincp
|
class dzz_admincp
|
||||||
{
|
{
|
||||||
var $core = null;
|
var $core = null;
|
||||||
var $script = null;
|
var $script = null;
|
||||||
|
|
||||||
var $userlogin = false;
|
var $userlogin = false;
|
||||||
var $adminsession = array();
|
var $adminsession = array();
|
||||||
var $adminuser = array();
|
var $adminuser = array();
|
||||||
var $perms = null;
|
var $perms = null;
|
||||||
|
|
||||||
var $panel = 1;
|
var $panel = 1;
|
||||||
|
|
||||||
var $isfounder = false;
|
var $isfounder = false;
|
||||||
|
|
||||||
var $cpsetting = array();
|
var $cpsetting = array();
|
||||||
|
|
||||||
var $cpaccess = 0;
|
var $cpaccess = 0;
|
||||||
|
|
||||||
var $sessionlife = 1800;
|
var $sessionlife = 1800;
|
||||||
var $sessionlimit = 0;
|
var $sessionlimit = 0;
|
||||||
var $isapi = 0;
|
var $isapi = 0;
|
||||||
var $isnotloginop = ['interface','kuinterface','updatesession'];
|
var $isnotloginop = ['interface','kuinterface','updatesession'];
|
||||||
var $isnotlogin = false;
|
var $isnotlogin = false;
|
||||||
|
|
||||||
function &instance() {
|
function &instance() {
|
||||||
static $object;
|
static $object;
|
||||||
if(empty($object)) {
|
if(empty($object)) {
|
||||||
$object = new dzz_admincp();
|
$object = new dzz_admincp();
|
||||||
}
|
}
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if(empty($this->core) || !is_object($this->core)) {
|
if(empty($this->core) || !is_object($this->core)) {
|
||||||
exit('No Dzz core found');
|
exit('No Dzz core found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cpsetting = $this->core->config['admincp'];
|
$this->cpsetting = $this->core->config['admincp'];
|
||||||
$this->adminuser = & $this->core->var['member'];
|
$this->adminuser = & $this->core->var['member'];
|
||||||
|
|
||||||
$this->isfounder = $this->checkfounder($this->adminuser);
|
$this->isfounder = $this->checkfounder($this->adminuser);
|
||||||
|
|
||||||
$this->sessionlimit = TIMESTAMP - $this->sessionlife;
|
$this->sessionlimit = TIMESTAMP - $this->sessionlife;
|
||||||
$opname = $_GET['op'];
|
$opname = $_GET['op'];
|
||||||
if(!$this->api && in_array($opname,$this->isnotloginop)){
|
if(!$this->api && in_array($opname,$this->isnotloginop)){
|
||||||
$this->isnotlogin = true;
|
$this->isnotlogin = true;
|
||||||
}
|
}
|
||||||
$this->isapi = defined('IS_API') ? IS_API:0;
|
$this->isapi = defined('IS_API') ? IS_API:0;
|
||||||
$return = $this->check_cpaccess();
|
$return = $this->check_cpaccess();
|
||||||
if( $return === 0){
|
if( $return === 0){
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
if( $_GET['mod']!="systemlog"){
|
if( $_GET['mod']!="systemlog"){
|
||||||
$this->writecplog();
|
$this->writecplog();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function writecplog() {
|
function writecplog() {
|
||||||
global $_G;
|
global $_G;
|
||||||
$extralog = implodearray(array('GET' => $_GET, 'POST' => $_POST), array('formhash', 'submit', 'addsubmit', 'admin_password', 'sid', 'action'));
|
$extralog = implodearray(array('GET' => $_GET, 'POST' => $_POST), array('formhash', 'submit', 'addsubmit', 'admin_password', 'sid', 'action'));
|
||||||
writelog('cplog', $extralog);
|
writelog('cplog', $extralog);
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_cpaccess() {
|
function check_cpaccess() {
|
||||||
global $_G;
|
global $_G;
|
||||||
$session = array();
|
$session = array();
|
||||||
|
|
||||||
if(!$this->adminuser['uid']) {
|
if(!$this->adminuser['uid']) {
|
||||||
$this->cpaccess = 0;
|
$this->cpaccess = 0;
|
||||||
} else {
|
} else {
|
||||||
if(!$this->isfounder) {
|
if(!$this->isfounder) {
|
||||||
$session = C::t('user')->fetch($this->adminuser['uid']);
|
$session = C::t('user')->fetch($this->adminuser['uid']);
|
||||||
if($session && ($session['groupid']==1) ) {
|
if($session && ($session['groupid']==1) ) {
|
||||||
$session = array_merge($session, (array)C::t('admincp_session')->fetch($this->adminuser['uid'], $session['groupid']));
|
$session = array_merge($session, (array)C::t('admincp_session')->fetch($this->adminuser['uid'], $session['groupid']));
|
||||||
}else $session=array();
|
}else $session=array();
|
||||||
} else {
|
} else {
|
||||||
$session = C::t('admincp_session')->fetch($this->adminuser['uid'], $this->panel);
|
$session = C::t('admincp_session')->fetch($this->adminuser['uid'], $this->panel);
|
||||||
}
|
}
|
||||||
if(empty($session)) {
|
if(empty($session)) {
|
||||||
$this->cpaccess = $this->isfounder ? 1 : -2;
|
$this->cpaccess = $this->isfounder ? 1 : -2;
|
||||||
|
|
||||||
} elseif(isset($_G['setting']['adminipaccess']) && $_G['setting']['adminipaccess'] && !ipaccess($_G['clientip'], $_G['setting']['adminipaccess'])) {
|
} elseif(isset($_G['setting']['adminipaccess']) && $_G['setting']['adminipaccess'] && !ipaccess($_G['clientip'], $_G['setting']['adminipaccess'])) {
|
||||||
if((!$this->isapi && ! $this->isnotlogin)) $this->do_user_login();
|
if((!$this->isapi && ! $this->isnotlogin)) $this->do_user_login();
|
||||||
else return 0;
|
else return 0;
|
||||||
|
|
||||||
} elseif ($session && empty($session['uid'])) {
|
} elseif ($session && empty($session['uid'])) {
|
||||||
$this->cpaccess = 1;
|
$this->cpaccess = 1;
|
||||||
|
|
||||||
} elseif ($session['dateline'] < $this->sessionlimit) {
|
} elseif ($session['dateline'] < $this->sessionlimit) {
|
||||||
$this->cpaccess = 1;
|
$this->cpaccess = 1;
|
||||||
|
|
||||||
} elseif ($this->cpsetting['checkip'] && ($session['ip'] != $this->core->var['clientip'])) {
|
} elseif ($this->cpsetting['checkip'] && ($session['ip'] != $this->core->var['clientip'])) {
|
||||||
$this->cpaccess = 1;
|
$this->cpaccess = 1;
|
||||||
|
|
||||||
} elseif ($session['errorcount'] >= 0 && $session['errorcount'] <= 3) {
|
} elseif ($session['errorcount'] >= 0 && $session['errorcount'] <= 3) {
|
||||||
$this->cpaccess = 2;
|
$this->cpaccess = 2;
|
||||||
|
|
||||||
} elseif ($session['errorcount'] == -1) {
|
} elseif ($session['errorcount'] == -1) {
|
||||||
$this->cpaccess = 3;
|
$this->cpaccess = 3;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->cpaccess = -1;
|
$this->cpaccess = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($this->cpaccess == 2 || $this->cpaccess == 3) {
|
if($this->cpaccess == 2 || $this->cpaccess == 3) {
|
||||||
if(!empty($session['customperm'])) {
|
if(!empty($session['customperm'])) {
|
||||||
$session['customperm'] = dunserialize($session['customperm']);
|
$session['customperm'] = dunserialize($session['customperm']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->adminsession = $session;
|
$this->adminsession = $session;
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['admin_password'])) {
|
if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['admin_password'])) {
|
||||||
if($this->cpaccess == 2) {
|
if($this->cpaccess == 2) {
|
||||||
$this->check_admin_login();
|
$this->check_admin_login();
|
||||||
} elseif($this->cpaccess == 0) {
|
} elseif($this->cpaccess == 0) {
|
||||||
$this->check_user_login();
|
$this->check_user_login();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->cpaccess == 1) {
|
if($this->cpaccess == 1) {
|
||||||
C::t('admincp_session')->delete($this->adminuser['uid'],$this->adminuser['groupid'], $this->sessionlife);
|
C::t('admincp_session')->delete($this->adminuser['uid'],$this->adminuser['groupid'], $this->sessionlife);
|
||||||
C::t('admincp_session')->insert(array(
|
C::t('admincp_session')->insert(array(
|
||||||
'uid' => $this->adminuser['uid'],
|
'uid' => $this->adminuser['uid'],
|
||||||
'adminid' => $this->adminuser['adminid'],
|
'adminid' => $this->adminuser['adminid'],
|
||||||
'panel' => $this->adminuser['groupid'],
|
'panel' => $this->adminuser['groupid'],
|
||||||
'ip' => $this->core->var['clientip'],
|
'ip' => $this->core->var['clientip'],
|
||||||
'dateline' => TIMESTAMP,
|
'dateline' => TIMESTAMP,
|
||||||
'errorcount' => 0,
|
'errorcount' => 0,
|
||||||
));
|
));
|
||||||
} elseif ($this->cpaccess == 3) {
|
} elseif ($this->cpaccess == 3) {
|
||||||
//$this->load_admin_perms();
|
//$this->load_admin_perms();
|
||||||
C::t('admincp_session')->update($this->adminuser['uid'], $this->adminuser['groupid'], array('dateline' => TIMESTAMP, 'ip' => $this->core->var['clientip'], 'errorcount' => -1));
|
C::t('admincp_session')->update($this->adminuser['uid'], $this->adminuser['groupid'], array('dateline' => TIMESTAMP, 'ip' => $this->core->var['clientip'], 'errorcount' => -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->cpaccess != 3) {
|
if($this->cpaccess != 3) {
|
||||||
if((!$this->isapi && ! $this->isnotlogin)) $this->do_user_login();
|
if((!$this->isapi && ! $this->isnotlogin)) $this->do_user_login();
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_admin_login() {
|
function check_admin_login() {
|
||||||
global $_G;
|
global $_G;
|
||||||
if((empty($_POST['admin_questionid']) || empty($_POST['admin_answer'])) && ($_G['config']['admincp']['forcesecques'] || $_G['group']['forcesecques'])) {
|
if((empty($_POST['admin_questionid']) || empty($_POST['admin_answer'])) && ($_G['config']['admincp']['forcesecques'] || $_G['group']['forcesecques'])) {
|
||||||
if((!$this->isapi && ! $this->isnotlogin)) $this->do_user_login();
|
if((!$this->isapi && ! $this->isnotlogin)) $this->do_user_login();
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
require_once DZZ_ROOT.'/user/function/function_user.php';
|
require_once DZZ_ROOT.'/user/function/function_user.php';
|
||||||
$ucresult = uc_user_login($this->adminuser['uid'], $_POST['admin_password'], 1, 1, $_POST['admin_questionid'], $_POST['admin_answer'], $this->core->var['clientip']);
|
$ucresult = uc_user_login($this->adminuser['uid'], $_POST['admin_password'], 1, 1, $_POST['admin_questionid'], $_POST['admin_answer'], $this->core->var['clientip']);
|
||||||
if($ucresult[0] > 0) {
|
if($ucresult[0] > 0) {
|
||||||
C::t('admincp_session')->update($this->adminuser['uid'], $this->adminuser['groupid'], array('dateline' => TIMESTAMP, 'ip' => $this->core->var['clientip'], 'errorcount' => -1));
|
C::t('admincp_session')->update($this->adminuser['uid'], $this->adminuser['groupid'], array('dateline' => TIMESTAMP, 'ip' => $this->core->var['clientip'], 'errorcount' => -1));
|
||||||
if((!$this->isapi && ! $this->isnotlogin)) {
|
if((!$this->isapi && ! $this->isnotlogin)) {
|
||||||
$referer = ($_GET['referer']) ? $_GET['referer']:$_SERVER['HTTP_REFERER'];
|
$referer = ($_GET['referer']) ? $_GET['referer']:$_SERVER['HTTP_REFERER'];
|
||||||
dheader('Location: '.$referer);
|
dheader('Location: '.$referer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errorcount = $this->adminsession['errorcount'] + 1;
|
$errorcount = $this->adminsession['errorcount'] + 1;
|
||||||
C::t('admincp_session')->update($this->adminuser['uid'], $this->adminuser['groupid'], array('dateline' => TIMESTAMP, 'ip' => $this->core->var['clientip'], 'errorcount' => $errorcount));
|
C::t('admincp_session')->update($this->adminuser['uid'], $this->adminuser['groupid'], array('dateline' => TIMESTAMP, 'ip' => $this->core->var['clientip'], 'errorcount' => $errorcount));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_user_login() {
|
function check_user_login() {
|
||||||
global $_G;
|
global $_G;
|
||||||
$admin_email = isset($_POST['admin_email']) ? trim($_POST['admin_email']) : '';
|
$admin_email = isset($_POST['admin_email']) ? trim($_POST['admin_email']) : '';
|
||||||
if($admin_email != '') {
|
if($admin_email != '') {
|
||||||
require_once DZZ_ROOT.'/user/function/function_user.php';
|
require_once DZZ_ROOT.'/user/function/function_user.php';
|
||||||
if(logincheck($_POST['admin_email'])) {
|
if(logincheck($_POST['admin_email'])) {
|
||||||
if((empty($_POST['admin_questionid']) || empty($_POST['admin_answer'])) && ($_G['config']['admincp']['forcesecques'] || $_G['group']['forcesecques'])) {
|
if((empty($_POST['admin_questionid']) || empty($_POST['admin_answer'])) && ($_G['config']['admincp']['forcesecques'] || $_G['group']['forcesecques'])) {
|
||||||
//$this->do_user_login();
|
//$this->do_user_login();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$result = userlogin($_POST['admin_email'], $_POST['admin_password'], $_POST['admin_questionid'], $_POST['admin_answer'], 'auto', $this->core->var['clientip']);
|
$result = userlogin($_POST['admin_email'], $_POST['admin_password'], $_POST['admin_questionid'], $_POST['admin_answer'], 'auto', $this->core->var['clientip']);
|
||||||
if($result['status'] == 1) {
|
if($result['status'] == 1) {
|
||||||
|
|
||||||
if($this->checkfounder($result['member']) || $result['member']['groupid']==1) {
|
if($this->checkfounder($result['member']) || $result['member']['groupid']==1) {
|
||||||
C::t('admincp_session')->insert(array(
|
C::t('admincp_session')->insert(array(
|
||||||
'uid' =>$result['member']['uid'],
|
'uid' =>$result['member']['uid'],
|
||||||
'adminid' =>$result['member']['adminid'],
|
'adminid' =>$result['member']['adminid'],
|
||||||
'panel' =>$result['member']['groupid'],
|
'panel' =>$result['member']['groupid'],
|
||||||
'dateline' => TIMESTAMP,
|
'dateline' => TIMESTAMP,
|
||||||
'ip' => $this->core->var['clientip'],
|
'ip' => $this->core->var['clientip'],
|
||||||
'errorcount' => -1), false, true);
|
'errorcount' => -1), false, true);
|
||||||
|
|
||||||
setloginstatus($result['member'], 0);
|
setloginstatus($result['member'], 0);
|
||||||
$referer = ($_GET['referer']) ? $_GET['referer']:$_SERVER['HTTP_REFERER'];
|
$referer = ($_GET['referer']) ? $_GET['referer']:$_SERVER['HTTP_REFERER'];
|
||||||
if((!$this->isapi && ! $this->isnotlogin)) {
|
if((!$this->isapi && ! $this->isnotlogin)) {
|
||||||
$referer = ($_GET['referer']) ? $_GET['referer']:$_SERVER['HTTP_REFERER'];
|
$referer = ($_GET['referer']) ? $_GET['referer']:$_SERVER['HTTP_REFERER'];
|
||||||
dheader('Location: '.$referer );
|
dheader('Location: '.$referer );
|
||||||
//dheader('Location: '.ADMINSCRIPT.'?'.cpurl('url', array('sid')));
|
//dheader('Location: '.ADMINSCRIPT.'?'.cpurl('url', array('sid')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->cpaccess = -2;
|
$this->cpaccess = -2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loginfailed($_POST['admin_email']);
|
loginfailed($_POST['admin_email']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->cpaccess = -4;
|
$this->cpaccess = -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function checkfounder($user) {
|
function checkfounder($user) {
|
||||||
|
|
||||||
$founders = str_replace(' ', '', $this->cpsetting['founder']);
|
$founders = str_replace(' ', '', $this->cpsetting['founder']);
|
||||||
if(!$user['uid'] || $user['groupid'] != 1 || $user['adminid'] != 1) {
|
if(!$user['uid'] || $user['groupid'] != 1 || $user['adminid'] != 1) {
|
||||||
return false;
|
return false;
|
||||||
} elseif(empty($founders)) {
|
} elseif(empty($founders)) {
|
||||||
return true;
|
return true;
|
||||||
} elseif(strexists(",$founders,", ",$user[uid],")) {
|
} elseif(strexists(",$founders,", ",$user[uid],")) {
|
||||||
return true;
|
return true;
|
||||||
} elseif(!is_numeric($user['nickname']) && strexists(",$founders,", ",$user[nickname],")) {
|
} elseif(!is_numeric($user['nickname']) && strexists(",$founders,", ",$user[nickname],")) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_user_login() {
|
function do_user_login() {
|
||||||
if((!$this->isapi && ! $this->isnotlogin)) require $this->admincpfile('login');
|
if((!$this->isapi && ! $this->isnotlogin)) require $this->admincpfile('login');
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_admin_logout() {
|
function do_admin_logout() {
|
||||||
C::t('admincp_session')->delete($this->adminuser['uid'], $this->adminuser['groupid'], $this->sessionlife);
|
C::t('admincp_session')->delete($this->adminuser['uid'], $this->adminuser['groupid'], $this->sessionlife);
|
||||||
}
|
}
|
||||||
|
|
||||||
function admincpfile($action) {
|
function admincpfile($action) {
|
||||||
return './admin/login/login.php';
|
return './admin/login/login.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -188,7 +188,7 @@ class dzz_app extends dzz_base{
|
|||||||
}
|
}
|
||||||
$url = parse_url($_G['siteurl']);
|
$url = parse_url($_G['siteurl']);
|
||||||
$_G['siteroot'] = isset($url['path']) ? $url['path'] : '';
|
$_G['siteroot'] = isset($url['path']) ? $url['path'] : '';
|
||||||
$_G['siteport'] = empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' ? '' : ':'.$_SERVER['SERVER_PORT'];
|
$_G['siteport'] = (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' || $_SERVER['SERVER_PORT'] == '443' || $_SERVER['HTTP_X_FORWARDED_PORT'] == '443')? '' : ':'.$_SERVER['SERVER_PORT'];
|
||||||
|
|
||||||
if(defined('SUB_DIR')) {
|
if(defined('SUB_DIR')) {
|
||||||
$_G['siteurl'] = str_replace(SUB_DIR, '/', $_G['siteurl']);
|
$_G['siteurl'] = str_replace(SUB_DIR, '/', $_G['siteurl']);
|
||||||
@@ -208,6 +208,8 @@ class dzz_app extends dzz_base{
|
|||||||
}elseif($_SERVER['SERVER_PORT'] == 443){ //其他
|
}elseif($_SERVER['SERVER_PORT'] == 443){ //其他
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}elseif($_SERVER['REQUEST_SCHEME'] == 'https'){ //其他
|
}elseif($_SERVER['REQUEST_SCHEME'] == 'https'){ //其他
|
||||||
|
return TRUE;
|
||||||
|
}elseif(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){ //其他
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -363,18 +365,19 @@ class dzz_app extends dzz_base{
|
|||||||
|
|
||||||
$allowgzip = $this->config['output']['gzip'] && empty($this->var['inajax']) && EXT_OBGZIP;
|
$allowgzip = $this->config['output']['gzip'] && empty($this->var['inajax']) && EXT_OBGZIP;
|
||||||
setglobal('gzipcompress', $allowgzip);
|
setglobal('gzipcompress', $allowgzip);
|
||||||
if($this->config['localurl']){
|
|
||||||
setglobal('localurl', $this->config['localurl']);
|
|
||||||
}
|
|
||||||
if(!ob_start($allowgzip ? 'ob_gzhandler' : null)) {
|
if(!ob_start($allowgzip ? 'ob_gzhandler' : null)) {
|
||||||
ob_start();
|
ob_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
setglobal('charset', $this->config['output']['charset']);
|
setglobal('charset', $this->config['output']['charset']);
|
||||||
define('CHARSET', $this->config['output']['charset']);
|
define('CHARSET', $this->config['output']['charset']);
|
||||||
if($this->config['output']['forceheader']) {
|
if($this->config['output']['forceheader']) {
|
||||||
@header('Content-Type: text/html; charset='.CHARSET);
|
@header('Content-Type: text/html; charset='.CHARSET);
|
||||||
}
|
}
|
||||||
|
if($this->config['localurl']){
|
||||||
|
setglobal('localurl', $this->config['localurl']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,6 +511,15 @@ class dzz_app extends dzz_base{
|
|||||||
}
|
}
|
||||||
|
|
||||||
setglobal('uid', getglobal('uid', 'member'));
|
setglobal('uid', getglobal('uid', 'member'));
|
||||||
|
if($this->var['member']['adminid']){
|
||||||
|
setglobal('pichomelevel',5);
|
||||||
|
}else{
|
||||||
|
$pichomelevel = C::t('user_setting')->fetch_by_skey('pichomelevel',getglobal('uid', 'member'));
|
||||||
|
$pichomelevel = $pichomelevel ? intval($pichomelevel):0;
|
||||||
|
setglobal('pichomelevel',$pichomelevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//设置语言;
|
//设置语言;
|
||||||
$langlist=$this->var['config']['output']['language_list'];
|
$langlist=$this->var['config']['output']['language_list'];
|
||||||
if($language=getcookie('language')){
|
if($language=getcookie('language')){
|
||||||
|
|||||||
@@ -1,59 +1,59 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class dzz_base
|
abstract class dzz_base
|
||||||
{
|
{
|
||||||
private $_e;
|
private $_e;
|
||||||
private $_m;
|
private $_m;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($name, $value) {
|
public function __set($name, $value) {
|
||||||
$setter='set'.$name;
|
$setter='set'.$name;
|
||||||
if(method_exists($this,$setter)) {
|
if(method_exists($this,$setter)) {
|
||||||
return $this->$setter($value);
|
return $this->$setter($value);
|
||||||
} elseif($this->canGetProperty($name)) {
|
} elseif($this->canGetProperty($name)) {
|
||||||
throw new Exception('The property "'.get_class($this).'->'.$name.'" is readonly');
|
throw new Exception('The property "'.get_class($this).'->'.$name.'" is readonly');
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
|
throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
$getter='get'.$name;
|
$getter='get'.$name;
|
||||||
if(method_exists($this,$getter)) {
|
if(method_exists($this,$getter)) {
|
||||||
return $this->$getter();
|
return $this->$getter();
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
|
throw new Exception('The property "'.get_class($this).'->'.$name.'" is not defined');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __call($name,$parameters) {
|
public function __call($name,$parameters) {
|
||||||
throw new Exception('Class "'.get_class($this).'" does not have a method named "'.$name.'".');
|
throw new Exception('Class "'.get_class($this).'" does not have a method named "'.$name.'".');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canGetProperty($name)
|
public function canGetProperty($name)
|
||||||
{
|
{
|
||||||
return method_exists($this,'get'.$name);
|
return method_exists($this,'get'.$name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canSetProperty($name)
|
public function canSetProperty($name)
|
||||||
{
|
{
|
||||||
return method_exists($this,'set'.$name);
|
return method_exists($this,'set'.$name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString() {
|
public function __toString() {
|
||||||
return get_class($this);
|
return get_class($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke() {
|
public function __invoke() {
|
||||||
return get_class($this);
|
return get_class($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
class dzz_censor {
|
class dzz_censor {
|
||||||
var $censor_words = array();
|
var $censor_words = array();
|
||||||
var $censor_replace='*';
|
var $censor_replace='*';
|
||||||
var $highlight;
|
var $highlight;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
global $_G;
|
global $_G;
|
||||||
if(empty($_G['cache']['censor'])) loadcache('censor');
|
if(empty($_G['cache']['censor'])) loadcache('censor');
|
||||||
$this->censor_words = !empty($_G['cache']['censor']['words']) ? explode(',',$_G['cache']['censor']['words']) : array();
|
$this->censor_words = !empty($_G['cache']['censor']['words']) ? explode(',',$_G['cache']['censor']['words']) : array();
|
||||||
$this->censor_replace = !empty($_G['cache']['censor']['replace']) ? $_G['cache']['censor']['replace'] : '*';
|
$this->censor_replace = !empty($_G['cache']['censor']['replace']) ? $_G['cache']['censor']['replace'] : '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function & instance() {
|
public static function & instance() {
|
||||||
static $instance;
|
static $instance;
|
||||||
if(!$instance) {
|
if(!$instance) {
|
||||||
$instance = new self();
|
$instance = new self();
|
||||||
}
|
}
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
public function replace($message){
|
public function replace($message){
|
||||||
if($badwords = array_combine($this->censor_words,array_fill(0,count($this->censor_words),$this->censor_replace))){
|
if($badwords = array_combine($this->censor_words,array_fill(0,count($this->censor_words),$this->censor_replace))){
|
||||||
return strtr($message,$badwords);
|
return strtr($message,$badwords);
|
||||||
}else{
|
}else{
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,134 +1,134 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_container extends dzz_base
|
class dzz_container extends dzz_base
|
||||||
{
|
{
|
||||||
protected $_obj;
|
protected $_obj;
|
||||||
protected $_objs = array();
|
protected $_objs = array();
|
||||||
public function __construct($obj = null) {
|
public function __construct($obj = null) {
|
||||||
if(isset($obj)) {
|
if(isset($obj)) {
|
||||||
if(is_object($obj)) {
|
if(is_object($obj)) {
|
||||||
$this->_obj = $obj;
|
$this->_obj = $obj;
|
||||||
} else if(is_string($obj)) {
|
} else if(is_string($obj)) {
|
||||||
try {
|
try {
|
||||||
if(func_num_args()) {
|
if(func_num_args()) {
|
||||||
$p = func_get_args();
|
$p = func_get_args();
|
||||||
unset($p[0]);
|
unset($p[0]);
|
||||||
$ref = new ReflectionClass($obj);
|
$ref = new ReflectionClass($obj);
|
||||||
$this->_obj = $ref->newInstanceArgs($p);
|
$this->_obj = $ref->newInstanceArgs($p);
|
||||||
unset($ref);
|
unset($ref);
|
||||||
} else {
|
} else {
|
||||||
$this->_obj = new $obj;
|
$this->_obj = new $obj;
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new Exception('Class "'.$obj.'" does not exists.');
|
throw new Exception('Class "'.$obj.'" does not exists.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
public function getobj() {
|
public function getobj() {
|
||||||
return $this->_obj;
|
return $this->_obj;
|
||||||
}
|
}
|
||||||
public function setobj($value) {
|
public function setobj($value) {
|
||||||
$this->_obj = $value;
|
$this->_obj = $value;
|
||||||
}
|
}
|
||||||
public function __call($name, $p) {
|
public function __call($name, $p) {
|
||||||
if(method_exists($this->_obj, $name)) {
|
if(method_exists($this->_obj, $name)) {
|
||||||
if(isset($this->_obj->methods[$name][0])) {
|
if(isset($this->_obj->methods[$name][0])) {
|
||||||
$this->_call($name, $p, 0);
|
$this->_call($name, $p, 0);
|
||||||
}
|
}
|
||||||
switch (count($p)) {
|
switch (count($p)) {
|
||||||
case 0: $this->_obj->data = $this->_obj->{$name}();break;
|
case 0: $this->_obj->data = $this->_obj->{$name}();break;
|
||||||
case 1: $this->_obj->data = $this->_obj->{$name}($p[0]);break;
|
case 1: $this->_obj->data = $this->_obj->{$name}($p[0]);break;
|
||||||
case 2: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1]);break;
|
case 2: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1]);break;
|
||||||
case 3: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1], $p[2]);break;
|
case 3: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1], $p[2]);break;
|
||||||
case 4: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1], $p[2], $p[3]);break;
|
case 4: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1], $p[2], $p[3]);break;
|
||||||
case 5: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1], $p[2], $p[3], $p[4]);break;
|
case 5: $this->_obj->data = $this->_obj->{$name}($p[0], $p[1], $p[2], $p[3], $p[4]);break;
|
||||||
default: $this->_obj->data = call_user_func_array(array($this->_obj, $name), $p);break;
|
default: $this->_obj->data = call_user_func_array(array($this->_obj, $name), $p);break;
|
||||||
}
|
}
|
||||||
if(isset($this->_obj->methods[$name][1])) {
|
if(isset($this->_obj->methods[$name][1])) {
|
||||||
$this->_call($name, $p, 1);
|
$this->_call($name, $p, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_obj->data;
|
return $this->_obj->data;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Class "'.get_class($this->_obj).'" does not have a method named "'.$name.'".');
|
throw new Exception('Class "'.get_class($this->_obj).'" does not have a method named "'.$name.'".');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function _call($name, $p, $type) {
|
protected function _call($name, $p, $type) {
|
||||||
$ret = null;
|
$ret = null;
|
||||||
if(isset($this->_obj->methods[$name][$type])) {
|
if(isset($this->_obj->methods[$name][$type])) {
|
||||||
foreach($this->_obj->methods[$name][$type] as $extend) {
|
foreach($this->_obj->methods[$name][$type] as $extend) {
|
||||||
if(is_array($extend) && isset($extend['class'])) {
|
if(is_array($extend) && isset($extend['class'])) {
|
||||||
$obj = $this->_getobj($extend['class'], $this->_obj);
|
$obj = $this->_getobj($extend['class'], $this->_obj);
|
||||||
switch (count($p)) {
|
switch (count($p)) {
|
||||||
case 0: $ret = $obj->{$extend['method']}();break;
|
case 0: $ret = $obj->{$extend['method']}();break;
|
||||||
case 1: $ret = $obj->{$extend['method']}($p[0]);break;
|
case 1: $ret = $obj->{$extend['method']}($p[0]);break;
|
||||||
case 2: $ret = $obj->{$extend['method']}($p[0], $p[1]);break;
|
case 2: $ret = $obj->{$extend['method']}($p[0], $p[1]);break;
|
||||||
case 3: $ret = $obj->{$extend['method']}($p[0], $p[1], $p[2]);break;
|
case 3: $ret = $obj->{$extend['method']}($p[0], $p[1], $p[2]);break;
|
||||||
case 4: $ret = $obj->{$extend['method']}($p[0], $p[1], $p[2], $p[3]);break;
|
case 4: $ret = $obj->{$extend['method']}($p[0], $p[1], $p[2], $p[3]);break;
|
||||||
case 5: $ret = $obj->{$extend['method']}($p[0], $p[1], $p[2], $p[3], $p[4]);break;
|
case 5: $ret = $obj->{$extend['method']}($p[0], $p[1], $p[2], $p[3], $p[4]);break;
|
||||||
default: $ret = call_user_func_array(array($obj, $extend['method']), $p);break;
|
default: $ret = call_user_func_array(array($obj, $extend['method']), $p);break;
|
||||||
}
|
}
|
||||||
} elseif(is_callable($extend, true)) {
|
} elseif(is_callable($extend, true)) {
|
||||||
if(is_array($extend)) {
|
if(is_array($extend)) {
|
||||||
list($obj, $method) = $extend;
|
list($obj, $method) = $extend;
|
||||||
if(method_exists($obj, $method)) {
|
if(method_exists($obj, $method)) {
|
||||||
if(is_object($obj)) {
|
if(is_object($obj)) {
|
||||||
$obj->obj = $this->_obj;
|
$obj->obj = $this->_obj;
|
||||||
switch (count($p)) {
|
switch (count($p)) {
|
||||||
case 0: $ret = $obj->{$method}();break;
|
case 0: $ret = $obj->{$method}();break;
|
||||||
case 1: $ret = $obj->{$method}($p[0]);break;
|
case 1: $ret = $obj->{$method}($p[0]);break;
|
||||||
case 2: $ret = $obj->{$method}($p[0], $p[1]);break;
|
case 2: $ret = $obj->{$method}($p[0], $p[1]);break;
|
||||||
case 3: $ret = $obj->{$method}($p[0], $p[1], $p[2]);break;
|
case 3: $ret = $obj->{$method}($p[0], $p[1], $p[2]);break;
|
||||||
case 4: $ret = $obj->{$method}($p[0], $p[1], $p[2], $p[3]);break;
|
case 4: $ret = $obj->{$method}($p[0], $p[1], $p[2], $p[3]);break;
|
||||||
case 5: $ret = $obj->{$method}($p[0], $p[1], $p[2], $p[3], $p[4]);break;
|
case 5: $ret = $obj->{$method}($p[0], $p[1], $p[2], $p[3], $p[4]);break;
|
||||||
default: $ret = call_user_func_array(array($obj, $method), $p);break;
|
default: $ret = call_user_func_array(array($obj, $method), $p);break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$p[] = $this;
|
$p[] = $this;
|
||||||
$ret = call_user_func_array($extend, $p);
|
$ret = call_user_func_array($extend, $p);
|
||||||
}
|
}
|
||||||
}/* else {
|
}/* else {
|
||||||
throw new Exception('Class "'.get_class($extend[0]).'" does not have a method named "'.$extend[1].'".');
|
throw new Exception('Class "'.get_class($extend[0]).'" does not have a method named "'.$extend[1].'".');
|
||||||
}*/
|
}*/
|
||||||
} else {
|
} else {
|
||||||
$p[] = $this->_obj;
|
$p[] = $this->_obj;
|
||||||
$ret = call_user_func_array($extend, $p);
|
$ret = call_user_func_array($extend, $p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
protected function _getobj($class, $obj) {
|
protected function _getobj($class, $obj) {
|
||||||
if(!isset($this->_objs[$class])) {
|
if(!isset($this->_objs[$class])) {
|
||||||
$this->_objs[$class] = new $class($obj);
|
$this->_objs[$class] = new $class($obj);
|
||||||
if(method_exists($this->_objs[$class], 'init_base_var')) {
|
if(method_exists($this->_objs[$class], 'init_base_var')) {
|
||||||
$this->_objs[$class]->init_base_var();
|
$this->_objs[$class]->init_base_var();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->_objs[$class];
|
return $this->_objs[$class];
|
||||||
}
|
}
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
if(isset($this->_obj) && property_exists($this->_obj, $name) === true) {
|
if(isset($this->_obj) && property_exists($this->_obj, $name) === true) {
|
||||||
return $this->_obj->$name;
|
return $this->_obj->$name;
|
||||||
} else {
|
} else {
|
||||||
return parent::__get($name);
|
return parent::__get($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function __set($name, $value) {
|
public function __set($name, $value) {
|
||||||
if(isset($this->_obj) && property_exists($this->_obj, $name) === true) {
|
if(isset($this->_obj) && property_exists($this->_obj, $name) === true) {
|
||||||
return $this->_obj->$name = $value;
|
return $this->_obj->$name = $value;
|
||||||
} else {
|
} else {
|
||||||
return parent::__set($name, $value);
|
return parent::__set($name, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function __isset($name) {
|
public function __isset($name) {
|
||||||
return isset($this->_obj->$name);
|
return isset($this->_obj->$name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,153 +1,153 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_cron
|
class dzz_cron
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function runcron(){
|
public static function runcron(){
|
||||||
$crons = C::t('cron')->fetch_all_nextruncronid(TIMESTAMP);
|
$crons = C::t('cron')->fetch_all_nextruncronid(TIMESTAMP);
|
||||||
foreach($crons as $v){
|
foreach($crons as $v){
|
||||||
self::run($v);
|
self::run($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static function run($cronid = 0) {
|
public static function run($cronid = 0) {
|
||||||
global $_G;
|
global $_G;
|
||||||
$cron = $cronid ? C::t('cron')->fetch($cronid) : C::t('cron')->fetch_nextrun(TIMESTAMP);
|
$cron = $cronid ? C::t('cron')->fetch($cronid) : C::t('cron')->fetch_nextrun(TIMESTAMP);
|
||||||
$processname ='DZZ_CRON_'.(empty($cron) ? 'CHECKER' : $cron['cronid']);
|
$processname ='DZZ_CRON_'.(empty($cron) ? 'CHECKER' : $cron['cronid']);
|
||||||
if($cronid && !empty($cron)) {
|
if($cronid && !empty($cron)) {
|
||||||
dzz_process::unlock($processname);
|
dzz_process::unlock($processname);
|
||||||
}
|
}
|
||||||
if(dzz_process::islocked($processname, 600)) {
|
if(dzz_process::islocked($processname, 600)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($cron) {
|
if($cron) {
|
||||||
$cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']);
|
$cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']);
|
||||||
$efile = explode(':', $cron['filename']);
|
$efile = explode(':', $cron['filename']);
|
||||||
if(count($efile) > 1) {
|
if(count($efile) > 1) {
|
||||||
$filename = array_pop($efile);
|
$filename = array_pop($efile);
|
||||||
$cronfile = DZZ_ROOT. './'.implode("/",$efile).'/cron/'.$filename;
|
$cronfile = DZZ_ROOT. './'.implode("/",$efile).'/cron/'.$filename;
|
||||||
} else {
|
} else {
|
||||||
$cronfile = DZZ_ROOT.'./core/cron/'.$cron['filename'];
|
$cronfile = DZZ_ROOT.'./core/cron/'.$cron['filename'];
|
||||||
}
|
}
|
||||||
if($cronfile) {
|
if($cronfile) {
|
||||||
$cron['minute'] = explode("\t", $cron['minute']);
|
$cron['minute'] = explode("\t", $cron['minute']);
|
||||||
self::setnextime($cron);
|
self::setnextime($cron);
|
||||||
|
|
||||||
@set_time_limit(1000);
|
@set_time_limit(1000);
|
||||||
@ignore_user_abort(TRUE);
|
@ignore_user_abort(TRUE);
|
||||||
|
|
||||||
if(!@include $cronfile) {
|
if(!@include $cronfile) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::nextcron();
|
self::nextcron();
|
||||||
dzz_process::unlock($processname);
|
dzz_process::unlock($processname);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private static function nextcron() {
|
private static function nextcron() {
|
||||||
$cron = C::t('cron')->fetch_nextcron();
|
$cron = C::t('cron')->fetch_nextcron();
|
||||||
if($cron && isset($cron['nextrun'])) {
|
if($cron && isset($cron['nextrun'])) {
|
||||||
savecache('cronnextrun', $cron['nextrun']);
|
savecache('cronnextrun', $cron['nextrun']);
|
||||||
} else {
|
} else {
|
||||||
savecache('cronnextrun', TIMESTAMP + 86400 * 365);
|
savecache('cronnextrun', TIMESTAMP + 86400 * 365);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private static function setnextime($cron) {
|
private static function setnextime($cron) {
|
||||||
if(empty($cron)) return FALSE;
|
if(empty($cron)) return FALSE;
|
||||||
list($yearnow, $monthnow, $daynow, $weekdaynow, $hournow, $minutenow) = explode('-', gmdate('Y-m-d-w-H-i', TIMESTAMP + getglobal('setting/timeoffset') * 3600));
|
list($yearnow, $monthnow, $daynow, $weekdaynow, $hournow, $minutenow) = explode('-', gmdate('Y-m-d-w-H-i', TIMESTAMP + getglobal('setting/timeoffset') * 3600));
|
||||||
if($cron['weekday'] == -1) {
|
if($cron['weekday'] == -1) {
|
||||||
if($cron['day'] == -1) {
|
if($cron['day'] == -1) {
|
||||||
$firstday = $daynow;
|
$firstday = $daynow;
|
||||||
$secondday = $daynow + 1;
|
$secondday = $daynow + 1;
|
||||||
} else {
|
} else {
|
||||||
$firstday = $cron['day'];
|
$firstday = $cron['day'];
|
||||||
$secondday = $cron['day'] + gmdate('t', TIMESTAMP + getglobal('setting/timeoffset') * 3600);
|
$secondday = $cron['day'] + gmdate('t', TIMESTAMP + getglobal('setting/timeoffset') * 3600);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$firstday = $daynow + ($cron['weekday'] - $weekdaynow);
|
$firstday = $daynow + ($cron['weekday'] - $weekdaynow);
|
||||||
$secondday = $firstday + 7;
|
$secondday = $firstday + 7;
|
||||||
}
|
}
|
||||||
if($firstday < $daynow) {
|
if($firstday < $daynow) {
|
||||||
$firstday = $secondday;
|
$firstday = $secondday;
|
||||||
}
|
}
|
||||||
if($firstday == $daynow) {
|
if($firstday == $daynow) {
|
||||||
$todaytime = self::todaynextrun($cron);
|
$todaytime = self::todaynextrun($cron);
|
||||||
if($todaytime['hour'] == -1 && $todaytime['minute'] == -1) {
|
if($todaytime['hour'] == -1 && $todaytime['minute'] == -1) {
|
||||||
$cron['day'] = $secondday;
|
$cron['day'] = $secondday;
|
||||||
$nexttime = self::todaynextrun($cron, 0, -1);
|
$nexttime = self::todaynextrun($cron, 0, -1);
|
||||||
$cron['hour'] = $nexttime['hour'];
|
$cron['hour'] = $nexttime['hour'];
|
||||||
$cron['minute'] = $nexttime['minute'];
|
$cron['minute'] = $nexttime['minute'];
|
||||||
} else {
|
} else {
|
||||||
$cron['day'] = $firstday;
|
$cron['day'] = $firstday;
|
||||||
$cron['hour'] = $todaytime['hour'];
|
$cron['hour'] = $todaytime['hour'];
|
||||||
$cron['minute'] = $todaytime['minute'];
|
$cron['minute'] = $todaytime['minute'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$cron['day'] = $firstday;
|
$cron['day'] = $firstday;
|
||||||
$nexttime = self::todaynextrun($cron, 0, -1);
|
$nexttime = self::todaynextrun($cron, 0, -1);
|
||||||
$cron['hour'] = $nexttime['hour'];
|
$cron['hour'] = $nexttime['hour'];
|
||||||
$cron['minute'] = $nexttime['minute'];
|
$cron['minute'] = $nexttime['minute'];
|
||||||
}
|
}
|
||||||
$nextrun = @gmmktime($cron['hour'], $cron['minute'] > 0 ? $cron['minute'] : 0, 0, $monthnow, $cron['day'], $yearnow) - getglobal('setting/timeoffset') * 3600;
|
$nextrun = @gmmktime($cron['hour'], $cron['minute'] > 0 ? $cron['minute'] : 0, 0, $monthnow, $cron['day'], $yearnow) - getglobal('setting/timeoffset') * 3600;
|
||||||
$data = array('lastrun' => TIMESTAMP, 'nextrun' => $nextrun);
|
$data = array('lastrun' => TIMESTAMP, 'nextrun' => $nextrun);
|
||||||
if(!($nextrun > TIMESTAMP)) {
|
if(!($nextrun > TIMESTAMP)) {
|
||||||
$data['available'] = '0';
|
$data['available'] = '0';
|
||||||
}
|
}
|
||||||
C::t('cron')->update($cron['cronid'], $data);
|
C::t('cron')->update($cron['cronid'], $data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function todaynextrun($cron, $hour = -2, $minute = -2) {
|
private static function todaynextrun($cron, $hour = -2, $minute = -2) {
|
||||||
|
|
||||||
$hour = $hour == -2 ? gmdate('H', TIMESTAMP + getglobal('setting/timeoffset') * 3600) : $hour;
|
$hour = $hour == -2 ? gmdate('H', TIMESTAMP + getglobal('setting/timeoffset') * 3600) : $hour;
|
||||||
$minute = $minute == -2 ? gmdate('i', TIMESTAMP + getglobal('setting/timeoffset') * 3600) : $minute;
|
$minute = $minute == -2 ? gmdate('i', TIMESTAMP + getglobal('setting/timeoffset') * 3600) : $minute;
|
||||||
|
|
||||||
$nexttime = array();
|
$nexttime = array();
|
||||||
if($cron['hour'] == -1 && !$cron['minute']) {
|
if($cron['hour'] == -1 && !$cron['minute']) {
|
||||||
$nexttime['hour'] = $hour;
|
$nexttime['hour'] = $hour;
|
||||||
$nexttime['minute'] = $minute + 1;
|
$nexttime['minute'] = $minute + 1;
|
||||||
} elseif($cron['hour'] == -1 && $cron['minute'] != '') {
|
} elseif($cron['hour'] == -1 && $cron['minute'] != '') {
|
||||||
$nexttime['hour'] = $hour;
|
$nexttime['hour'] = $hour;
|
||||||
if(($nextminute = self::nextminute($cron['minute'], $minute)) === false) {
|
if(($nextminute = self::nextminute($cron['minute'], $minute)) === false) {
|
||||||
++$nexttime['hour'];
|
++$nexttime['hour'];
|
||||||
$nextminute = $cron['minute'][0];
|
$nextminute = $cron['minute'][0];
|
||||||
}
|
}
|
||||||
$nexttime['minute'] = $nextminute;
|
$nexttime['minute'] = $nextminute;
|
||||||
} elseif($cron['hour'] != -1 && $cron['minute'] == '') {
|
} elseif($cron['hour'] != -1 && $cron['minute'] == '') {
|
||||||
if($cron['hour'] < $hour) {
|
if($cron['hour'] < $hour) {
|
||||||
$nexttime['hour'] = $nexttime['minute'] = -1;
|
$nexttime['hour'] = $nexttime['minute'] = -1;
|
||||||
} elseif($cron['hour'] == $hour) {
|
} elseif($cron['hour'] == $hour) {
|
||||||
$nexttime['hour'] = $cron['hour'];
|
$nexttime['hour'] = $cron['hour'];
|
||||||
$nexttime['minute'] = $minute + 1;
|
$nexttime['minute'] = $minute + 1;
|
||||||
} else {
|
} else {
|
||||||
$nexttime['hour'] = $cron['hour'];
|
$nexttime['hour'] = $cron['hour'];
|
||||||
$nexttime['minute'] = 0;
|
$nexttime['minute'] = 0;
|
||||||
}
|
}
|
||||||
} elseif($cron['hour'] != -1 && $cron['minute'] != '') {
|
} elseif($cron['hour'] != -1 && $cron['minute'] != '') {
|
||||||
$nextminute = self::nextminute($cron['minute'], $minute);
|
$nextminute = self::nextminute($cron['minute'], $minute);
|
||||||
if($cron['hour'] < $hour || ($cron['hour'] == $hour && $nextminute === false)) {
|
if($cron['hour'] < $hour || ($cron['hour'] == $hour && $nextminute === false)) {
|
||||||
$nexttime['hour'] = -1;
|
$nexttime['hour'] = -1;
|
||||||
$nexttime['minute'] = -1;
|
$nexttime['minute'] = -1;
|
||||||
} else {
|
} else {
|
||||||
$nexttime['hour'] = $cron['hour'];
|
$nexttime['hour'] = $cron['hour'];
|
||||||
$nexttime['minute'] = $nextminute;
|
$nexttime['minute'] = $nextminute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $nexttime;
|
return $nexttime;
|
||||||
}
|
}
|
||||||
private static function nextminute($nextminutes, $minutenow) {
|
private static function nextminute($nextminutes, $minutenow) {
|
||||||
foreach($nextminutes as $nextminute) {
|
foreach($nextminutes as $nextminute) {
|
||||||
if($nextminute > $minutenow) {
|
if($nextminute > $minutenow) {
|
||||||
return $nextminute;
|
return $nextminute;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,469 +1,469 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
class dzz_database {
|
class dzz_database {
|
||||||
|
|
||||||
public static $db;
|
public static $db;
|
||||||
|
|
||||||
public static $driver;
|
public static $driver;
|
||||||
|
|
||||||
public static function init($driver, $config) {
|
public static function init($driver, $config) {
|
||||||
self::$driver = $driver;
|
self::$driver = $driver;
|
||||||
self::$db = new $driver;
|
self::$db = new $driver;
|
||||||
self::$db->set_config($config);
|
self::$db->set_config($config);
|
||||||
self::$db->connect();
|
self::$db->connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function linknum(){
|
public static function linknum(){
|
||||||
return self::$db->linknum();
|
return self::$db->linknum();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function object() {
|
public static function object() {
|
||||||
return self::$db;
|
return self::$db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table($table) {
|
public static function table($table) {
|
||||||
return self::$db->table_name($table);
|
return self::$db->table_name($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function delete($table, $condition, $limit = 0, $unbuffered = true) {
|
public static function delete($table, $condition, $limit = 0, $unbuffered = true) {
|
||||||
if (empty($condition)) {
|
if (empty($condition)) {
|
||||||
return false;
|
return false;
|
||||||
} elseif (is_array($condition)) {
|
} elseif (is_array($condition)) {
|
||||||
if (count($condition) == 2 && isset($condition['where']) && isset($condition['arg'])) {
|
if (count($condition) == 2 && isset($condition['where']) && isset($condition['arg'])) {
|
||||||
$where = self::format($condition['where'], $condition['arg']);
|
$where = self::format($condition['where'], $condition['arg']);
|
||||||
} else {
|
} else {
|
||||||
$where = self::implode_field_value($condition, ' AND ');
|
$where = self::implode_field_value($condition, ' AND ');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$where = $condition;
|
$where = $condition;
|
||||||
}
|
}
|
||||||
$limit = dintval($limit);
|
$limit = dintval($limit);
|
||||||
$sql = "DELETE FROM " . self::table($table) . " WHERE $where " . ($limit > 0 ? "LIMIT $limit" : '');
|
$sql = "DELETE FROM " . self::table($table) . " WHERE $where " . ($limit > 0 ? "LIMIT $limit" : '');
|
||||||
return self::query($sql, ($unbuffered ? 'UNBUFFERED' : ''));
|
return self::query($sql, ($unbuffered ? 'UNBUFFERED' : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function insert($table, $data, $return_insert_id = false, $replace = false, $silent = false) {
|
public static function insert($table, $data, $return_insert_id = false, $replace = false, $silent = false) {
|
||||||
|
|
||||||
$sql = self::implode($data);
|
$sql = self::implode($data);
|
||||||
|
|
||||||
$cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
|
$cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
|
||||||
|
|
||||||
$table = self::table($table);
|
$table = self::table($table);
|
||||||
$silent = $silent ? 'SILENT' : '';
|
$silent = $silent ? 'SILENT' : '';
|
||||||
return self::query("$cmd $table SET $sql", null, $silent, !$return_insert_id);
|
return self::query("$cmd $table SET $sql", null, $silent, !$return_insert_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function update($table, $data, $condition, $unbuffered = false, $low_priority = false) {
|
public static function update($table, $data, $condition, $unbuffered = false, $low_priority = false) {
|
||||||
$sql = self::implode($data);
|
$sql = self::implode($data);
|
||||||
if(empty($sql)) {
|
if(empty($sql)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$cmd = "UPDATE " . ($low_priority ? 'LOW_PRIORITY' : '');
|
$cmd = "UPDATE " . ($low_priority ? 'LOW_PRIORITY' : '');
|
||||||
$table = self::table($table);
|
$table = self::table($table);
|
||||||
$where = '';
|
$where = '';
|
||||||
if (empty($condition)) {
|
if (empty($condition)) {
|
||||||
$where = '1';
|
$where = '1';
|
||||||
} elseif (is_array($condition)) {
|
} elseif (is_array($condition)) {
|
||||||
$where = self::implode($condition, ' AND ');
|
$where = self::implode($condition, ' AND ');
|
||||||
} else {
|
} else {
|
||||||
$where = $condition;
|
$where = $condition;
|
||||||
}
|
}
|
||||||
$res = self::query("$cmd $table SET $sql WHERE $where", $unbuffered ? 'UNBUFFERED' : '');
|
$res = self::query("$cmd $table SET $sql WHERE $where", $unbuffered ? 'UNBUFFERED' : '');
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function insert_id() {
|
public static function insert_id() {
|
||||||
return self::$db->insert_id();
|
return self::$db->insert_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fetch($resourceid, $type = 'MYSQL_ASSOC') {
|
public static function fetch($resourceid, $type = 'MYSQL_ASSOC') {
|
||||||
return self::$db->fetch_array($resourceid, $type);
|
return self::$db->fetch_array($resourceid, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fetch_first($sql, $arg = array(), $silent = false) {
|
public static function fetch_first($sql, $arg = array(), $silent = false) {
|
||||||
$res = self::query($sql, $arg, $silent, false);
|
$res = self::query($sql, $arg, $silent, false);
|
||||||
$ret = self::$db->fetch_array($res);
|
$ret = self::$db->fetch_array($res);
|
||||||
self::$db->free_result($res);
|
self::$db->free_result($res);
|
||||||
return $ret ? $ret : array();
|
return $ret ? $ret : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fetch_all($sql, $arg = array(), $keyfield = '', $silent=false) {
|
public static function fetch_all($sql, $arg = array(), $keyfield = '', $silent=false) {
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$query = self::query($sql, $arg, $silent, false);
|
$query = self::query($sql, $arg, $silent, false);
|
||||||
while ($row = self::$db->fetch_array($query)) {
|
while ($row = self::$db->fetch_array($query)) {
|
||||||
if ($keyfield && isset($row[$keyfield])) {
|
if ($keyfield && isset($row[$keyfield])) {
|
||||||
$data[$row[$keyfield]] = $row;
|
$data[$row[$keyfield]] = $row;
|
||||||
} else {
|
} else {
|
||||||
$data[] = $row;
|
$data[] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::$db->free_result($query);
|
self::$db->free_result($query);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function result($resourceid, $row = 0) {
|
public static function result($resourceid, $row = 0) {
|
||||||
return self::$db->result($resourceid, $row);
|
return self::$db->result($resourceid, $row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function result_first($sql, $arg = array(), $silent = false) {
|
public static function result_first($sql, $arg = array(), $silent = false) {
|
||||||
$res = self::query($sql, $arg, $silent, false);
|
$res = self::query($sql, $arg, $silent, false);
|
||||||
$ret = self::$db->result($res, 0);
|
$ret = self::$db->result($res, 0);
|
||||||
self::$db->free_result($res);
|
self::$db->free_result($res);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function query($sql, $arg = array(), $silent = false, $unbuffered = false) {
|
public static function query($sql, $arg = array(), $silent = false, $unbuffered = false) {
|
||||||
if (!empty($arg)) {
|
if (!empty($arg)) {
|
||||||
if (is_array($arg)) {
|
if (is_array($arg)) {
|
||||||
$sql = self::format($sql, $arg);
|
$sql = self::format($sql, $arg);
|
||||||
} elseif ($arg === 'SILENT') {
|
} elseif ($arg === 'SILENT') {
|
||||||
$silent = true;
|
$silent = true;
|
||||||
|
|
||||||
} elseif ($arg === 'UNBUFFERED') {
|
} elseif ($arg === 'UNBUFFERED') {
|
||||||
$unbuffered = true;
|
$unbuffered = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self::checkquery($sql);
|
self::checkquery($sql);
|
||||||
|
|
||||||
$ret = self::$db->query($sql, $silent, $unbuffered);
|
$ret = self::$db->query($sql, $silent, $unbuffered);
|
||||||
if (!$unbuffered && $ret) {
|
if (!$unbuffered && $ret) {
|
||||||
$cmd = trim(strtoupper(substr($sql, 0, strpos($sql, ' '))));
|
$cmd = trim(strtoupper(substr($sql, 0, strpos($sql, ' '))));
|
||||||
if ($cmd === 'SELECT') {
|
if ($cmd === 'SELECT') {
|
||||||
|
|
||||||
} elseif ($cmd === 'UPDATE' || $cmd === 'DELETE') {
|
} elseif ($cmd === 'UPDATE' || $cmd === 'DELETE') {
|
||||||
$ret = self::$db->affected_rows();
|
$ret = self::$db->affected_rows();
|
||||||
} elseif ($cmd === 'INSERT') {
|
} elseif ($cmd === 'INSERT') {
|
||||||
$ret = self::$db->insert_id();
|
$ret = self::$db->insert_id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function num_rows($resourceid) {
|
public static function num_rows($resourceid) {
|
||||||
return self::$db->num_rows($resourceid);
|
return self::$db->num_rows($resourceid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function affected_rows() {
|
public static function affected_rows() {
|
||||||
return self::$db->affected_rows();
|
return self::$db->affected_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function free_result($query) {
|
public static function free_result($query) {
|
||||||
return self::$db->free_result($query);
|
return self::$db->free_result($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function error() {
|
public static function error() {
|
||||||
return self::$db->error();
|
return self::$db->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function errno() {
|
public static function errno() {
|
||||||
return self::$db->errno();
|
return self::$db->errno();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function checkquery($sql) {
|
public static function checkquery($sql) {
|
||||||
return dzz_database_safecheck::checkquery($sql);
|
return dzz_database_safecheck::checkquery($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function quote($str, $noarray = false) {
|
public static function quote($str, $noarray = false) {
|
||||||
|
|
||||||
if (is_string($str))
|
if (is_string($str))
|
||||||
return '\'' . addcslashes($str, "\n\r\\'\"\032") . '\'';
|
return '\'' . addcslashes($str, "\n\r\\'\"\032") . '\'';
|
||||||
|
|
||||||
if (is_int($str) or is_float($str))
|
if (is_int($str) or is_float($str))
|
||||||
return '\'' . $str . '\'';
|
return '\'' . $str . '\'';
|
||||||
|
|
||||||
if (is_array($str)) {
|
if (is_array($str)) {
|
||||||
if($noarray === false) {
|
if($noarray === false) {
|
||||||
foreach ($str as &$v) {
|
foreach ($str as &$v) {
|
||||||
$v = self::quote($v, true);
|
$v = self::quote($v, true);
|
||||||
}
|
}
|
||||||
return $str;
|
return $str;
|
||||||
} else {
|
} else {
|
||||||
return '\'\'';
|
return '\'\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_bool($str))
|
if (is_bool($str))
|
||||||
return $str ? '1' : '0';
|
return $str ? '1' : '0';
|
||||||
|
|
||||||
return '\'\'';
|
return '\'\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function quote_field($field) {
|
public static function quote_field($field) {
|
||||||
if (is_array($field)) {
|
if (is_array($field)) {
|
||||||
foreach ($field as $k => $v) {
|
foreach ($field as $k => $v) {
|
||||||
$field[$k] = self::quote_field($v);
|
$field[$k] = self::quote_field($v);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (strpos($field, '`') !== false)
|
if (strpos($field, '`') !== false)
|
||||||
$field = str_replace('`', '', $field);
|
$field = str_replace('`', '', $field);
|
||||||
$field = '`' . $field . '`';
|
$field = '`' . $field . '`';
|
||||||
}
|
}
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function limit($start, $limit = 0) {
|
public static function limit($start, $limit = 0) {
|
||||||
$limit = intval($limit > 0 ? $limit : 0);
|
$limit = intval($limit > 0 ? $limit : 0);
|
||||||
$start = intval($start > 0 ? $start : 0);
|
$start = intval($start > 0 ? $start : 0);
|
||||||
if ($start > 0 && $limit > 0) {
|
if ($start > 0 && $limit > 0) {
|
||||||
return " LIMIT $start, $limit";
|
return " LIMIT $start, $limit";
|
||||||
} elseif ($limit) {
|
} elseif ($limit) {
|
||||||
return " LIMIT $limit";
|
return " LIMIT $limit";
|
||||||
} elseif ($start) {
|
} elseif ($start) {
|
||||||
return " LIMIT $start";
|
return " LIMIT $start";
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function order($field, $order = 'ASC') {
|
public static function order($field, $order = 'ASC') {
|
||||||
if(empty($field)) {
|
if(empty($field)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$order = strtoupper($order) == 'ASC' || empty($order) ? 'ASC' : 'DESC';
|
$order = strtoupper($order) == 'ASC' || empty($order) ? 'ASC' : 'DESC';
|
||||||
return self::quote_field($field) . ' ' . $order;
|
return self::quote_field($field) . ' ' . $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function field($field, $val, $glue = '=') {
|
public static function field($field, $val, $glue = '=') {
|
||||||
|
|
||||||
$field = self::quote_field($field);
|
$field = self::quote_field($field);
|
||||||
|
|
||||||
if (is_array($val)) {
|
if (is_array($val)) {
|
||||||
$glue = $glue == 'notin' ? 'notin' : 'in';
|
$glue = $glue == 'notin' ? 'notin' : 'in';
|
||||||
} elseif ($glue == 'in') {
|
} elseif ($glue == 'in') {
|
||||||
$glue = '=';
|
$glue = '=';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($glue) {
|
switch ($glue) {
|
||||||
case '=':
|
case '=':
|
||||||
return $field . $glue . self::quote($val);
|
return $field . $glue . self::quote($val);
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
case '+':
|
case '+':
|
||||||
return $field . '=' . $field . $glue . self::quote((string) $val);
|
return $field . '=' . $field . $glue . self::quote((string) $val);
|
||||||
break;
|
break;
|
||||||
case '|':
|
case '|':
|
||||||
case '&':
|
case '&':
|
||||||
case '^':
|
case '^':
|
||||||
return $field . '=' . $field . $glue . self::quote($val);
|
return $field . '=' . $field . $glue . self::quote($val);
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
case '<':
|
case '<':
|
||||||
case '<>':
|
case '<>':
|
||||||
case '<=':
|
case '<=':
|
||||||
case '>=':
|
case '>=':
|
||||||
return $field . $glue . self::quote($val);
|
return $field . $glue . self::quote($val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'like':
|
case 'like':
|
||||||
return $field . ' LIKE(' . self::quote($val) . ')';
|
return $field . ' LIKE(' . self::quote($val) . ')';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'in':
|
case 'in':
|
||||||
case 'notin':
|
case 'notin':
|
||||||
$val = $val ? implode(',', self::quote($val)) : '\'\'';
|
$val = $val ? implode(',', self::quote($val)) : '\'\'';
|
||||||
return $field . ($glue == 'notin' ? ' NOT' : '') . ' IN(' . $val . ')';
|
return $field . ($glue == 'notin' ? ' NOT' : '') . ' IN(' . $val . ')';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new DbException('Not allow this glue between field and value: "' . $glue . '"');
|
throw new DbException('Not allow this glue between field and value: "' . $glue . '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function implode($array, $glue = ',') {
|
public static function implode($array, $glue = ',') {
|
||||||
$sql = $comma = '';
|
$sql = $comma = '';
|
||||||
$glue = ' ' . trim($glue) . ' ';
|
$glue = ' ' . trim($glue) . ' ';
|
||||||
foreach ($array as $k => $v) {
|
foreach ($array as $k => $v) {
|
||||||
$sql .= $comma . self::quote_field($k) . '=' . self::quote($v);
|
$sql .= $comma . self::quote_field($k) . '=' . self::quote($v);
|
||||||
$comma = $glue;
|
$comma = $glue;
|
||||||
}
|
}
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function implode_field_value($array, $glue = ',') {
|
public static function implode_field_value($array, $glue = ',') {
|
||||||
return self::implode($array, $glue);
|
return self::implode($array, $glue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function format($sql, $arg) {
|
public static function format($sql, $arg) {
|
||||||
$count = substr_count($sql, '%');
|
$count = substr_count($sql, '%');
|
||||||
if (!$count) {
|
if (!$count) {
|
||||||
return $sql;
|
return $sql;
|
||||||
} elseif ($count > count($arg)) {
|
} elseif ($count > count($arg)) {
|
||||||
throw new DbException('SQL string format error! This SQL need "' . $count . '" vars to replace into.', 0, $sql);
|
throw new DbException('SQL string format error! This SQL need "' . $count . '" vars to replace into.', 0, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
$len = strlen($sql);
|
$len = strlen($sql);
|
||||||
$i = $find = 0;
|
$i = $find = 0;
|
||||||
$ret = '';
|
$ret = '';
|
||||||
while ($i <= $len && $find < $count) {
|
while ($i <= $len && $find < $count) {
|
||||||
if ($sql[$i] == '%') {
|
if ($sql[$i] == '%') {
|
||||||
$next = $sql[$i + 1];
|
$next = $sql[$i + 1];
|
||||||
if ($next == 't') {
|
if ($next == 't') {
|
||||||
$ret .= self::table($arg[$find]);
|
$ret .= self::table($arg[$find]);
|
||||||
} elseif ($next == 's') {
|
} elseif ($next == 's') {
|
||||||
$ret .= self::quote(is_array($arg[$find]) ? serialize($arg[$find]) : (string) $arg[$find]);
|
$ret .= self::quote(is_array($arg[$find]) ? serialize($arg[$find]) : (string) $arg[$find]);
|
||||||
} elseif ($next == 'f') {
|
} elseif ($next == 'f') {
|
||||||
$ret .= sprintf('%F', $arg[$find]);
|
$ret .= sprintf('%F', $arg[$find]);
|
||||||
} elseif ($next == 'd') {
|
} elseif ($next == 'd') {
|
||||||
$ret .= dintval($arg[$find]);
|
$ret .= dintval($arg[$find]);
|
||||||
} elseif ($next == 'i') {
|
} elseif ($next == 'i') {
|
||||||
$ret .= $arg[$find];
|
$ret .= $arg[$find];
|
||||||
} elseif ($next == 'n') {
|
} elseif ($next == 'n') {
|
||||||
if (!empty($arg[$find])) {
|
if (!empty($arg[$find])) {
|
||||||
$ret .= is_array($arg[$find]) ? implode(',', self::quote($arg[$find])) : self::quote($arg[$find]);
|
$ret .= is_array($arg[$find]) ? implode(',', self::quote($arg[$find])) : self::quote($arg[$find]);
|
||||||
} else {
|
} else {
|
||||||
$ret .= '0';
|
$ret .= '0';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret .= self::quote($arg[$find]);
|
$ret .= self::quote($arg[$find]);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
$find++;
|
$find++;
|
||||||
} else {
|
} else {
|
||||||
$ret .= $sql[$i];
|
$ret .= $sql[$i];
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
if ($i < $len) {
|
if ($i < $len) {
|
||||||
$ret .= substr($sql, $i);
|
$ret .= substr($sql, $i);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_database_safecheck {
|
class dzz_database_safecheck {
|
||||||
|
|
||||||
protected static $checkcmd = array('SEL'=>1, 'UPD'=>1, 'INS'=>1, 'REP'=>1, 'DEL'=>1);
|
protected static $checkcmd = array('SEL'=>1, 'UPD'=>1, 'INS'=>1, 'REP'=>1, 'DEL'=>1);
|
||||||
protected static $config;
|
protected static $config;
|
||||||
|
|
||||||
public static function checkquery($sql) {
|
public static function checkquery($sql) {
|
||||||
if (self::$config === null) {
|
if (self::$config === null) {
|
||||||
self::$config = getglobal('config/security/querysafe');
|
self::$config = getglobal('config/security/querysafe');
|
||||||
}
|
}
|
||||||
if (self::$config['status']) {
|
if (self::$config['status']) {
|
||||||
$check = 1;
|
$check = 1;
|
||||||
$cmd = strtoupper(substr(trim($sql), 0, 3));
|
$cmd = strtoupper(substr(trim($sql), 0, 3));
|
||||||
if(isset(self::$checkcmd[$cmd])) {
|
if(isset(self::$checkcmd[$cmd])) {
|
||||||
$check = self::_do_query_safe($sql);
|
$check = self::_do_query_safe($sql);
|
||||||
} elseif(substr($cmd, 0, 2) === '/*') {
|
} elseif(substr($cmd, 0, 2) === '/*') {
|
||||||
$check = -1;
|
$check = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($check < 1) {
|
if ($check < 1) {
|
||||||
throw new DbException('It is not safe to do this query', 0, $sql);
|
throw new DbException('It is not safe to do this query', 0, $sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _do_query_safe($sql) {
|
private static function _do_query_safe($sql) {
|
||||||
$sql = str_replace(array('\\\\', '\\\'', '\\"', '\'\''), '', $sql);
|
$sql = str_replace(array('\\\\', '\\\'', '\\"', '\'\''), '', $sql);
|
||||||
$mark = $clean = '';
|
$mark = $clean = '';
|
||||||
if (strpos($sql, '/') === false && strpos($sql, '#') === false && strpos($sql, '-- ') === false && strpos($sql, '@') === false && strpos($sql, '`') === false) {
|
if (strpos($sql, '/') === false && strpos($sql, '#') === false && strpos($sql, '-- ') === false && strpos($sql, '@') === false && strpos($sql, '`') === false) {
|
||||||
$clean = preg_replace("/'(.+?)'/s", '', $sql);
|
$clean = preg_replace("/'(.+?)'/s", '', $sql);
|
||||||
} else {
|
} else {
|
||||||
$len = strlen($sql);
|
$len = strlen($sql);
|
||||||
$mark = $clean = '';
|
$mark = $clean = '';
|
||||||
for ($i = 0; $i < $len; $i++) {
|
for ($i = 0; $i < $len; $i++) {
|
||||||
$str = $sql[$i];
|
$str = $sql[$i];
|
||||||
switch ($str) {
|
switch ($str) {
|
||||||
case '`':
|
case '`':
|
||||||
if(!$mark) {
|
if(!$mark) {
|
||||||
$mark = '`';
|
$mark = '`';
|
||||||
$clean .= $str;
|
$clean .= $str;
|
||||||
} elseif ($mark == '`') {
|
} elseif ($mark == '`') {
|
||||||
$mark = '';
|
$mark = '';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
if (!$mark) {
|
if (!$mark) {
|
||||||
$mark = '\'';
|
$mark = '\'';
|
||||||
$clean .= $str;
|
$clean .= $str;
|
||||||
} elseif ($mark == '\'') {
|
} elseif ($mark == '\'') {
|
||||||
$mark = '';
|
$mark = '';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if (empty($mark) && $sql[$i + 1] == '*') {
|
if (empty($mark) && $sql[$i + 1] == '*') {
|
||||||
$mark = '/*';
|
$mark = '/*';
|
||||||
$clean .= $mark;
|
$clean .= $mark;
|
||||||
$i++;
|
$i++;
|
||||||
} elseif ($mark == '/*' && $sql[$i - 1] == '*') {
|
} elseif ($mark == '/*' && $sql[$i - 1] == '*') {
|
||||||
$mark = '';
|
$mark = '';
|
||||||
$clean .= '*';
|
$clean .= '*';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '#':
|
case '#':
|
||||||
if (empty($mark)) {
|
if (empty($mark)) {
|
||||||
$mark = $str;
|
$mark = $str;
|
||||||
$clean .= $str;
|
$clean .= $str;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "\n":
|
case "\n":
|
||||||
if ($mark == '#' || $mark == '--') {
|
if ($mark == '#' || $mark == '--') {
|
||||||
$mark = '';
|
$mark = '';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
if (empty($mark) && substr($sql, $i, 3) == '-- ') {
|
if (empty($mark) && substr($sql, $i, 3) == '-- ') {
|
||||||
$mark = '-- ';
|
$mark = '-- ';
|
||||||
$clean .= $mark;
|
$clean .= $mark;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$clean .= $mark ? '' : $str;
|
$clean .= $mark ? '' : $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strpos($clean, '@') !== false) {
|
if(strpos($clean, '@') !== false) {
|
||||||
return '-3';
|
return '-3';
|
||||||
}
|
}
|
||||||
|
|
||||||
$clean = preg_replace("/[^a-z0-9_\-\(\)#\*\/\"]+/is", "", strtolower($clean));
|
$clean = preg_replace("/[^a-z0-9_\-\(\)#\*\/\"]+/is", "", strtolower($clean));
|
||||||
|
|
||||||
if (self::$config['afullnote']) {
|
if (self::$config['afullnote']) {
|
||||||
$clean = str_replace('/**/', '', $clean);
|
$clean = str_replace('/**/', '', $clean);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array(self::$config['dfunction'])) {
|
if (is_array(self::$config['dfunction'])) {
|
||||||
foreach (self::$config['dfunction'] as $fun) {
|
foreach (self::$config['dfunction'] as $fun) {
|
||||||
if (strpos($clean, $fun . '(') !== false)
|
if (strpos($clean, $fun . '(') !== false)
|
||||||
return '-1';
|
return '-1';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array(self::$config['daction'])) {
|
if (is_array(self::$config['daction'])) {
|
||||||
foreach (self::$config['daction'] as $action) {
|
foreach (self::$config['daction'] as $action) {
|
||||||
if (strpos($clean, $action) !== false)
|
if (strpos($clean, $action) !== false)
|
||||||
return '-3';
|
return '-3';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$config['dlikehex'] && strpos($clean, 'like0x')) {
|
if (self::$config['dlikehex'] && strpos($clean, 'like0x')) {
|
||||||
return '-2';
|
return '-2';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array(self::$config['dnote'])) {
|
if (is_array(self::$config['dnote'])) {
|
||||||
foreach (self::$config['dnote'] as $note) {
|
foreach (self::$config['dnote'] as $note) {
|
||||||
if (strpos($clean, $note) !== false)
|
if (strpos($clean, $note) !== false)
|
||||||
return '-4';
|
return '-4';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setconfigstatus($data) {
|
public static function setconfigstatus($data) {
|
||||||
self::$config['status'] = $data ? 1 : 0;
|
self::$config['status'] = $data ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,398 +1,398 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
class dzz_error
|
class dzz_error
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function system_error($message, $show = true, $save = true, $halt = true) {
|
public static function system_error($message, $show = true, $save = true, $halt = true) {
|
||||||
if(!empty($message)) {
|
if(!empty($message)) {
|
||||||
$message = lang($message);
|
$message = lang($message);
|
||||||
} else {
|
} else {
|
||||||
$message = lang('error_unknow');
|
$message = lang('error_unknow');
|
||||||
}
|
}
|
||||||
|
|
||||||
list($showtrace, $logtrace) = dzz_error::debug_backtrace();
|
list($showtrace, $logtrace) = dzz_error::debug_backtrace();
|
||||||
|
|
||||||
if($save) {
|
if($save) {
|
||||||
$messagesave = '<b>'.$message.'</b><br><b>PHP:</b>'.$logtrace;
|
$messagesave = '<b>'.$message.'</b><br><b>PHP:</b>'.$logtrace;
|
||||||
dzz_error::write_error_log($messagesave);
|
dzz_error::write_error_log($messagesave);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($show) {
|
if($show) {
|
||||||
if(!defined('IN_MOBILE')) {
|
if(!defined('IN_MOBILE')) {
|
||||||
dzz_error::show_error('system', "<li>$message</li>",DZZ_CORE_DEBUG?$showtrace:array(), 0);
|
dzz_error::show_error('system', "<li>$message</li>",DZZ_CORE_DEBUG?$showtrace:array(), 0);
|
||||||
} else {
|
} else {
|
||||||
dzz_error::mobile_show_error('system', "<li>$message</li>", DZZ_CORE_DEBUG?$showtrace:array(), 0);
|
dzz_error::mobile_show_error('system', "<li>$message</li>", DZZ_CORE_DEBUG?$showtrace:array(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($halt) {
|
if($halt) {
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function template_error($message, $tplname) {
|
public static function template_error($message, $tplname) {
|
||||||
$message = lang($message);
|
$message = lang($message);
|
||||||
$tplname = str_replace(DZZ_ROOT, '', $tplname);
|
$tplname = str_replace(DZZ_ROOT, '', $tplname);
|
||||||
$message = $message.': '.$tplname;
|
$message = $message.': '.$tplname;
|
||||||
dzz_error::system_error($message);
|
dzz_error::system_error($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function debug_backtrace() {
|
public static function debug_backtrace() {
|
||||||
$skipfunc[] = 'error->debug_backtrace';
|
$skipfunc[] = 'error->debug_backtrace';
|
||||||
$skipfunc[] = 'error->db_error';
|
$skipfunc[] = 'error->db_error';
|
||||||
$skipfunc[] = 'error->template_error';
|
$skipfunc[] = 'error->template_error';
|
||||||
$skipfunc[] = 'error->system_error';
|
$skipfunc[] = 'error->system_error';
|
||||||
$skipfunc[] = 'db_mysql->halt';
|
$skipfunc[] = 'db_mysql->halt';
|
||||||
$skipfunc[] = 'db_mysql->query';
|
$skipfunc[] = 'db_mysql->query';
|
||||||
$skipfunc[] = 'DB::_execute';
|
$skipfunc[] = 'DB::_execute';
|
||||||
|
|
||||||
$show = $log = '';
|
$show = $log = '';
|
||||||
$debug_backtrace = debug_backtrace();
|
$debug_backtrace = debug_backtrace();
|
||||||
krsort($debug_backtrace);
|
krsort($debug_backtrace);
|
||||||
foreach ($debug_backtrace as $k => $error) {
|
foreach ($debug_backtrace as $k => $error) {
|
||||||
$file = str_replace(DZZ_ROOT, '', $error['file']);
|
$file = str_replace(DZZ_ROOT, '', $error['file']);
|
||||||
$func = isset($error['class']) ? $error['class'] : '';
|
$func = isset($error['class']) ? $error['class'] : '';
|
||||||
$func .= isset($error['type']) ? $error['type'] : '';
|
$func .= isset($error['type']) ? $error['type'] : '';
|
||||||
$func .= isset($error['function']) ? $error['function'] : '';
|
$func .= isset($error['function']) ? $error['function'] : '';
|
||||||
if(in_array($func, $skipfunc)) {
|
if(in_array($func, $skipfunc)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$error[line] = sprintf('%04d', $error['line']);
|
$error[line] = sprintf('%04d', $error['line']);
|
||||||
|
|
||||||
$show .= "<li>[Line: $error[line]]".$file."($func)</li>";
|
$show .= "<li>[Line: $error[line]]".$file."($func)</li>";
|
||||||
$log .= !empty($log) ? ' -> ' : '';$file.':'.$error['line'];
|
$log .= !empty($log) ? ' -> ' : '';$file.':'.$error['line'];
|
||||||
$log .= $file.':'.$error['line'];
|
$log .= $file.':'.$error['line'];
|
||||||
}
|
}
|
||||||
return array($show, $log);
|
return array($show, $log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function db_error($message, $sql) {
|
public static function db_error($message, $sql) {
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
list($showtrace, $logtrace) = dzz_error::debug_backtrace();
|
list($showtrace, $logtrace) = dzz_error::debug_backtrace();
|
||||||
|
|
||||||
$title = lang('db_'.$message);
|
$title = lang('db_'.$message);
|
||||||
$title_msg = lang('db_error_message');
|
$title_msg = lang('db_error_message');
|
||||||
$title_sql = lang('db_query_sql');
|
$title_sql = lang('db_query_sql');
|
||||||
$title_backtrace = lang('backtrace');
|
$title_backtrace = lang('backtrace');
|
||||||
$title_help = lang('db_help_link');
|
$title_help = lang('db_help_link');
|
||||||
|
|
||||||
$db = &DB::object();
|
$db = &DB::object();
|
||||||
$dberrno = $db->errno();
|
$dberrno = $db->errno();
|
||||||
$dberror = str_replace($db->tablepre, '', $db->error());
|
$dberror = str_replace($db->tablepre, '', $db->error());
|
||||||
$sql = dhtmlspecialchars(str_replace($db->tablepre, '', $sql));
|
$sql = dhtmlspecialchars(str_replace($db->tablepre, '', $sql));
|
||||||
|
|
||||||
$msg = '<li>[Type] '.$title.'</li>';
|
$msg = '<li>[Type] '.$title.'</li>';
|
||||||
$msg .= $dberrno ? '<li>['.$dberrno.'] '.$dberror.'</li>' : '';
|
$msg .= $dberrno ? '<li>['.$dberrno.'] '.$dberror.'</li>' : '';
|
||||||
$msg .= $sql ? '<li>[Query] '.$sql.'</li>' : '';
|
$msg .= $sql ? '<li>[Query] '.$sql.'</li>' : '';
|
||||||
|
|
||||||
dzz_error::show_error('db', $msg, $showtrace, false);
|
dzz_error::show_error('db', $msg, $showtrace, false);
|
||||||
unset($msg, $phperror);
|
unset($msg, $phperror);
|
||||||
|
|
||||||
$errormsg = '<b>'.$title.'</b>';
|
$errormsg = '<b>'.$title.'</b>';
|
||||||
$errormsg .= "[$dberrno]<br /><b>ERR:</b> $dberror<br />";
|
$errormsg .= "[$dberrno]<br /><b>ERR:</b> $dberror<br />";
|
||||||
if($sql) {
|
if($sql) {
|
||||||
$errormsg .= '<b>SQL:</b> '.$sql;
|
$errormsg .= '<b>SQL:</b> '.$sql;
|
||||||
}
|
}
|
||||||
$errormsg .= "<br />";
|
$errormsg .= "<br />";
|
||||||
$errormsg .= '<b>PHP:</b> '.$logtrace;
|
$errormsg .= '<b>PHP:</b> '.$logtrace;
|
||||||
|
|
||||||
dzz_error::write_error_log($errormsg);
|
dzz_error::write_error_log($errormsg);
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function exception_error($exception) {
|
public static function exception_error($exception) {
|
||||||
|
|
||||||
if($exception instanceof DbException) {
|
if($exception instanceof DbException) {
|
||||||
$type = 'db';
|
$type = 'db';
|
||||||
} else {
|
} else {
|
||||||
$type = 'system';
|
$type = 'system';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($type == 'db') {
|
if($type == 'db') {
|
||||||
$errormsg = '('.$exception->getCode().') ';
|
$errormsg = '('.$exception->getCode().') ';
|
||||||
$errormsg .= self::sql_clear($exception->getMessage());
|
$errormsg .= self::sql_clear($exception->getMessage());
|
||||||
if($exception->getSql()) {
|
if($exception->getSql()) {
|
||||||
$errormsg .= '<div class="sql">';
|
$errormsg .= '<div class="sql">';
|
||||||
$errormsg .= self::sql_clear($exception->getSql());
|
$errormsg .= self::sql_clear($exception->getSql());
|
||||||
$errormsg .= '</div>';
|
$errormsg .= '</div>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$errormsg = $exception->getMessage();
|
$errormsg = $exception->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
$trace = $exception->getTrace();
|
$trace = $exception->getTrace();
|
||||||
krsort($trace);
|
krsort($trace);
|
||||||
|
|
||||||
$trace[] = array('file'=>$exception->getFile(), 'line'=>$exception->getLine(), 'function'=> 'break');
|
$trace[] = array('file'=>$exception->getFile(), 'line'=>$exception->getLine(), 'function'=> 'break');
|
||||||
$phpmsg = array();
|
$phpmsg = array();
|
||||||
foreach ($trace as $error) {
|
foreach ($trace as $error) {
|
||||||
if(!empty($error['function'])) {
|
if(!empty($error['function'])) {
|
||||||
$fun = '';
|
$fun = '';
|
||||||
if(!empty($error['class'])) {
|
if(!empty($error['class'])) {
|
||||||
$fun .= $error['class'].$error['type'];
|
$fun .= $error['class'].$error['type'];
|
||||||
}
|
}
|
||||||
$fun .= $error['function'].'(';
|
$fun .= $error['function'].'(';
|
||||||
if(!empty($error['args'])) {
|
if(!empty($error['args'])) {
|
||||||
$mark = '';
|
$mark = '';
|
||||||
foreach($error['args'] as $arg) {
|
foreach($error['args'] as $arg) {
|
||||||
$fun .= $mark;
|
$fun .= $mark;
|
||||||
if(is_array($arg)) {
|
if(is_array($arg)) {
|
||||||
$fun .= 'Array';
|
$fun .= 'Array';
|
||||||
} elseif(is_bool($arg)) {
|
} elseif(is_bool($arg)) {
|
||||||
$fun .= $arg ? 'true' : 'false';
|
$fun .= $arg ? 'true' : 'false';
|
||||||
} elseif(is_int($arg)) {
|
} elseif(is_int($arg)) {
|
||||||
$fun .= (defined('DZZ_DEBUG') && DZZ_DEBUG) ? $arg : '%d';
|
$fun .= (defined('DZZ_DEBUG') && DZZ_DEBUG) ? $arg : '%d';
|
||||||
} elseif(is_float($arg)) {
|
} elseif(is_float($arg)) {
|
||||||
$fun .= (defined('DZZ_DEBUG') && DZZ_DEBUG) ? $arg : '%f';
|
$fun .= (defined('DZZ_DEBUG') && DZZ_DEBUG) ? $arg : '%f';
|
||||||
} else {
|
} else {
|
||||||
$fun .= (defined('DZZ_DEBUG') && DZZ_DEBUG) ? '\''.dhtmlspecialchars(substr(self::clear($arg), 0, 10)).(strlen($arg) > 10 ? ' ...' : '').'\'' : '%s';
|
$fun .= (defined('DZZ_DEBUG') && DZZ_DEBUG) ? '\''.dhtmlspecialchars(substr(self::clear($arg), 0, 10)).(strlen($arg) > 10 ? ' ...' : '').'\'' : '%s';
|
||||||
}
|
}
|
||||||
$mark = ', ';
|
$mark = ', ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$fun .= ')';
|
$fun .= ')';
|
||||||
$error['function'] = $fun;
|
$error['function'] = $fun;
|
||||||
}
|
}
|
||||||
$phpmsg[] = array(
|
$phpmsg[] = array(
|
||||||
'file' => str_replace(array(DZZ_ROOT, '\\'), array('', '/'), $error['file']),
|
'file' => str_replace(array(DZZ_ROOT, '\\'), array('', '/'), $error['file']),
|
||||||
'line' => $error['line'],
|
'line' => $error['line'],
|
||||||
'function' => $error['function'],
|
'function' => $error['function'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::show_error($type, $errormsg, $phpmsg);
|
self::show_error($type, $errormsg, $phpmsg);
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function show_error($type, $errormsg, $phpmsg = '', $typemsg = '') {
|
public static function show_error($type, $errormsg, $phpmsg = '', $typemsg = '') {
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$gzip = getglobal('gzipcompress');
|
$gzip = getglobal('gzipcompress');
|
||||||
ob_start($gzip ? 'ob_gzhandler' : null);
|
ob_start($gzip ? 'ob_gzhandler' : null);
|
||||||
|
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
$title = $type == 'db' ? 'Database' : 'System';
|
$title = $type == 'db' ? 'Database' : 'System';
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>$host - $title Error</title>
|
<title>$host - $title Error</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset={$_G['config']['output']['charset']}" />
|
<meta http-equiv="Content-Type" content="text/html; charset={$_G['config']['output']['charset']}" />
|
||||||
<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
|
<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
<!--
|
<!--
|
||||||
body { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;}
|
body { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;}
|
||||||
#container { width: 1024px; }
|
#container { width: 1024px; }
|
||||||
#message { width: 1024px; color: black; }
|
#message { width: 1024px; color: black; }
|
||||||
|
|
||||||
.red {color: red;}
|
.red {color: red;}
|
||||||
a:link { font: 9pt/11pt verdana, arial, sans-serif; color: red; }
|
a:link { font: 9pt/11pt verdana, arial, sans-serif; color: red; }
|
||||||
a:visited { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
|
a:visited { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
|
||||||
h1 { color: #FF0000; font: 18pt "Verdana"; margin-bottom: 0.5em;}
|
h1 { color: #FF0000; font: 18pt "Verdana"; margin-bottom: 0.5em;}
|
||||||
.bg1{ background-color: #FFFFCC;}
|
.bg1{ background-color: #FFFFCC;}
|
||||||
.bg2{ background-color: #EEEEEE;}
|
.bg2{ background-color: #EEEEEE;}
|
||||||
.table {background: #AAAAAA; font: 11pt Menlo,Consolas,"Lucida Console"}
|
.table {background: #AAAAAA; font: 11pt Menlo,Consolas,"Lucida Console"}
|
||||||
.info {
|
.info {
|
||||||
background: none repeat scroll 0 0 #F3F3F3;
|
background: none repeat scroll 0 0 #F3F3F3;
|
||||||
border: 0px solid #aaaaaa;
|
border: 0px solid #aaaaaa;
|
||||||
border-radius: 10px 10px 10px 10px;
|
border-radius: 10px 10px 10px 10px;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
font-size: 11pt;
|
font-size: 11pt;
|
||||||
line-height: 160%;
|
line-height: 160%;
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.help {
|
.help {
|
||||||
background: #F3F3F3;
|
background: #F3F3F3;
|
||||||
border-radius: 10px 10px 10px 10px;
|
border-radius: 10px 10px 10px 10px;
|
||||||
font: 12px verdana, arial, sans-serif;
|
font: 12px verdana, arial, sans-serif;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 160%;
|
line-height: 160%;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sql {
|
.sql {
|
||||||
background: none repeat scroll 0 0 #FFFFCC;
|
background: none repeat scroll 0 0 #FFFFCC;
|
||||||
border: 1px solid #aaaaaa;
|
border: 1px solid #aaaaaa;
|
||||||
color: #000000;
|
color: #000000;
|
||||||
font: arial, sans-serif;
|
font: arial, sans-serif;
|
||||||
font-size: 9pt;
|
font-size: 9pt;
|
||||||
line-height: 160%;
|
line-height: 160%;
|
||||||
margin-top: 1em;
|
margin-top: 1em;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
-->
|
-->
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
<h1>Dzz! $title Error</h1>
|
<h1>Dzz! $title Error</h1>
|
||||||
<div class='info'>$errormsg</div>
|
<div class='info'>$errormsg</div>
|
||||||
|
|
||||||
|
|
||||||
EOT;
|
EOT;
|
||||||
if(!empty($phpmsg)) {
|
if(!empty($phpmsg)) {
|
||||||
echo '<div class="info">';
|
echo '<div class="info">';
|
||||||
echo '<p><strong>PHP Debug</strong></p>';
|
echo '<p><strong>PHP Debug</strong></p>';
|
||||||
echo '<table cellpadding="5" cellspacing="1" width="100%" class="table">';
|
echo '<table cellpadding="5" cellspacing="1" width="100%" class="table">';
|
||||||
echo '<tr class="bg2"><td>No.</td><td>File</td><td>Line</td><td>Code</td></tr>';
|
echo '<tr class="bg2"><td>No.</td><td>File</td><td>Line</td><td>Code</td></tr>';
|
||||||
if(is_array($phpmsg)) {
|
if(is_array($phpmsg)) {
|
||||||
foreach($phpmsg as $k => $msg) {
|
foreach($phpmsg as $k => $msg) {
|
||||||
$k++;
|
$k++;
|
||||||
echo '<tr class="bg1">';
|
echo '<tr class="bg1">';
|
||||||
echo '<td>'.$k.'</td>';
|
echo '<td>'.$k.'</td>';
|
||||||
echo '<td>'.$msg['file'].'</td>';
|
echo '<td>'.$msg['file'].'</td>';
|
||||||
echo '<td>'.$msg['line'].'</td>';
|
echo '<td>'.$msg['line'].'</td>';
|
||||||
echo '<td>'.$msg['function'].'</td>';
|
echo '<td>'.$msg['function'].'</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo '<tr><td><ul>'.$phpmsg.'</ul></td></tr>';
|
echo '<tr><td><ul>'.$phpmsg.'</ul></td></tr>';
|
||||||
}
|
}
|
||||||
echo '</table></div>';
|
echo '</table></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$helplink = '';
|
$helplink = '';
|
||||||
|
|
||||||
|
|
||||||
$endmsg = lang('error_end_message', array('host'=>$host));
|
$endmsg = lang('error_end_message', array('host'=>$host));
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<div class="help">$endmsg. $helplink</div>
|
<div class="help">$endmsg. $helplink</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
EOT;
|
EOT;
|
||||||
$exit && exit();
|
$exit && exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function mobile_show_error($type, $errormsg, $phpmsg) {
|
public static function mobile_show_error($type, $errormsg, $phpmsg) {
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
$host = $_SERVER['HTTP_HOST'];
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
$phpmsg = trim($phpmsg);
|
$phpmsg = trim($phpmsg);
|
||||||
$title = 'Mobile '.($type == 'db' ? 'Database' : 'System');
|
$title = 'Mobile '.($type == 'db' ? 'Database' : 'System');
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
|
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>$host - $title Error</title>
|
<title>$host - $title Error</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
|
<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
<!--
|
<!--
|
||||||
body { background-color: white; color: black; }
|
body { background-color: white; color: black; }
|
||||||
UL, LI { margin: 0; padding: 2px; list-style: none; }
|
UL, LI { margin: 0; padding: 2px; list-style: none; }
|
||||||
#message { color: black; background-color: #FFFFCC; }
|
#message { color: black; background-color: #FFFFCC; }
|
||||||
#bodytitle { font: 11pt/13pt verdana, arial, sans-serif; height: 20px; vertical-align: top; }
|
#bodytitle { font: 11pt/13pt verdana, arial, sans-serif; height: 20px; vertical-align: top; }
|
||||||
.bodytext { font: 8pt/11pt verdana, arial, sans-serif; }
|
.bodytext { font: 8pt/11pt verdana, arial, sans-serif; }
|
||||||
.help { font: 12px verdana, arial, sans-serif; color: red;}
|
.help { font: 12px verdana, arial, sans-serif; color: red;}
|
||||||
.red {color: red;}
|
.red {color: red;}
|
||||||
a:link { font: 8pt/11pt verdana, arial, sans-serif; color: red; }
|
a:link { font: 8pt/11pt verdana, arial, sans-serif; color: red; }
|
||||||
a:visited { font: 8pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
|
a:visited { font: 8pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
|
||||||
-->
|
-->
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<table cellpadding="1" cellspacing="1" id="container">
|
<table cellpadding="1" cellspacing="1" id="container">
|
||||||
<tr>
|
<tr>
|
||||||
<td id="bodytitle" width="100%">Dzz! $title Error </td>
|
<td id="bodytitle" width="100%">Dzz! $title Error </td>
|
||||||
</tr>
|
</tr>
|
||||||
EOT;
|
EOT;
|
||||||
|
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<tr><td><hr size="1"/></td></tr>
|
<tr><td><hr size="1"/></td></tr>
|
||||||
<tr><td class="bodytext">Error messages: </td></tr>
|
<tr><td class="bodytext">Error messages: </td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="bodytext" id="message">
|
<td class="bodytext" id="message">
|
||||||
<ul> $errormsg</ul>
|
<ul> $errormsg</ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
EOT;
|
EOT;
|
||||||
if(!empty($phpmsg) && $type == 'db') {
|
if(!empty($phpmsg) && $type == 'db') {
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<tr><td class="bodytext"> </td></tr>
|
<tr><td class="bodytext"> </td></tr>
|
||||||
<tr><td class="bodytext">Program messages: </td></tr>
|
<tr><td class="bodytext">Program messages: </td></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="bodytext">
|
<td class="bodytext">
|
||||||
<ul> $phpmsg </ul>
|
<ul> $phpmsg </ul>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
EOT;
|
EOT;
|
||||||
}
|
}
|
||||||
$endmsg = lang('mobile_error_end_message', array('host'=>$host));
|
$endmsg = lang('mobile_error_end_message', array('host'=>$host));
|
||||||
echo <<<EOT
|
echo <<<EOT
|
||||||
<tr>
|
<tr>
|
||||||
<td class="help"><br />$endmsg</td>
|
<td class="help"><br />$endmsg</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
EOT;
|
EOT;
|
||||||
$exit && exit();
|
$exit && exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function clear($message) {
|
public static function clear($message) {
|
||||||
return str_replace(array("\t", "\r", "\n"), " ", $message);
|
return str_replace(array("\t", "\r", "\n"), " ", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sql_clear($message) {
|
public static function sql_clear($message) {
|
||||||
$message = self::clear($message);
|
$message = self::clear($message);
|
||||||
$message = str_replace(DB::object()->tablepre, '', $message);
|
$message = str_replace(DB::object()->tablepre, '', $message);
|
||||||
$message = dhtmlspecialchars($message);
|
$message = dhtmlspecialchars($message);
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function write_error_log($message) {
|
public static function write_error_log($message) {
|
||||||
$loginfo=array("mark"=>"errorlog","content"=>$message);
|
$loginfo=array("mark"=>"errorlog","content"=>$message);
|
||||||
Hook::listen('systemlog',$loginfo);
|
Hook::listen('systemlog',$loginfo);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$message = dzz_error::clear($message);
|
$message = dzz_error::clear($message);
|
||||||
$time = time();
|
$time = time();
|
||||||
$file = DZZ_ROOT.'./data/log/'.date("Ym").'_errorlog.php';
|
$file = DZZ_ROOT.'./data/log/'.date("Ym").'_errorlog.php';
|
||||||
$hash = md5($message);
|
$hash = md5($message);
|
||||||
|
|
||||||
$uid = getglobal('uid');
|
$uid = getglobal('uid');
|
||||||
$ip = getglobal('clientip');
|
$ip = getglobal('clientip');
|
||||||
|
|
||||||
$user = '<b>User:</b> uid='.intval($uid).'; IP='.$ip.'; RIP:'.$_SERVER['REMOTE_ADDR'];
|
$user = '<b>User:</b> uid='.intval($uid).'; IP='.$ip.'; RIP:'.$_SERVER['REMOTE_ADDR'];
|
||||||
$uri = 'Request: '.dhtmlspecialchars(dzz_error::clear($_SERVER['REQUEST_URI']));
|
$uri = 'Request: '.dhtmlspecialchars(dzz_error::clear($_SERVER['REQUEST_URI']));
|
||||||
$message = "<?PHP exit;?>\t{$time}\t$message\t$hash\t$user $uri\n";
|
$message = "<?PHP exit;?>\t{$time}\t$message\t$hash\t$user $uri\n";
|
||||||
if($fp = @fopen($file, 'rb')) {
|
if($fp = @fopen($file, 'rb')) {
|
||||||
$lastlen = 50000;
|
$lastlen = 50000;
|
||||||
$maxtime = 60 * 10;
|
$maxtime = 60 * 10;
|
||||||
$offset = filesize($file) - $lastlen;
|
$offset = filesize($file) - $lastlen;
|
||||||
if($offset > 0) {
|
if($offset > 0) {
|
||||||
fseek($fp, $offset);
|
fseek($fp, $offset);
|
||||||
}
|
}
|
||||||
if($data = fread($fp, $lastlen)) {
|
if($data = fread($fp, $lastlen)) {
|
||||||
$array = explode("\n", $data);
|
$array = explode("\n", $data);
|
||||||
if(is_array($array)) foreach($array as $key => $val) {
|
if(is_array($array)) foreach($array as $key => $val) {
|
||||||
$row = explode("\t", $val);
|
$row = explode("\t", $val);
|
||||||
if($row[0] != '<?PHP exit;?>') continue;
|
if($row[0] != '<?PHP exit;?>') continue;
|
||||||
if($row[3] == $hash && ($row[1] > $time - $maxtime)) {
|
if($row[3] == $hash && ($row[1] > $time - $maxtime)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error_log($message, 3, $file);
|
error_log($message, 3, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,390 +1,390 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!defined('FTP_ERR_SERVER_DISABLED')) {
|
if(!defined('FTP_ERR_SERVER_DISABLED')) {
|
||||||
define('FTP_ERR_SERVER_DISABLED', -100);
|
define('FTP_ERR_SERVER_DISABLED', -100);
|
||||||
define('FTP_ERR_CONFIG_OFF', -101);
|
define('FTP_ERR_CONFIG_OFF', -101);
|
||||||
define('FTP_ERR_CONNECT_TO_SERVER', -102);
|
define('FTP_ERR_CONNECT_TO_SERVER', -102);
|
||||||
define('FTP_ERR_USER_NO_LOGGIN', -103);
|
define('FTP_ERR_USER_NO_LOGGIN', -103);
|
||||||
define('FTP_ERR_CHDIR', -104);
|
define('FTP_ERR_CHDIR', -104);
|
||||||
define('FTP_ERR_MKDIR', -105);
|
define('FTP_ERR_MKDIR', -105);
|
||||||
define('FTP_ERR_SOURCE_READ', -106);
|
define('FTP_ERR_SOURCE_READ', -106);
|
||||||
define('FTP_ERR_TARGET_WRITE', -107);
|
define('FTP_ERR_TARGET_WRITE', -107);
|
||||||
}
|
}
|
||||||
class dzz_ftp
|
class dzz_ftp
|
||||||
{
|
{
|
||||||
var $enabled = false;
|
var $enabled = false;
|
||||||
var $config = array();
|
var $config = array();
|
||||||
var $func;
|
var $func;
|
||||||
var $connectid;
|
var $connectid;
|
||||||
var $_error;
|
var $_error;
|
||||||
var $systype='';
|
var $systype='';
|
||||||
function &instance($config = array()) {
|
function &instance($config = array()) {
|
||||||
static $object;
|
static $object;
|
||||||
if(empty($object)) {
|
if(empty($object)) {
|
||||||
$object = new dzz_ftp($config);
|
$object = new dzz_ftp($config);
|
||||||
}
|
}
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
function __construct($config = array()) {
|
function __construct($config = array()) {
|
||||||
$this->set_error(0);
|
$this->set_error(0);
|
||||||
$this->config = !$config ? getglobal('setting/ftp') : $config;
|
$this->config = !$config ? getglobal('setting/ftp') : $config;
|
||||||
$this->enabled = false;
|
$this->enabled = false;
|
||||||
if(empty($this->config['on']) || empty($this->config['host'])) {
|
if(empty($this->config['on']) || empty($this->config['host'])) {
|
||||||
$this->set_error(FTP_ERR_CONFIG_OFF);
|
$this->set_error(FTP_ERR_CONFIG_OFF);
|
||||||
} else {
|
} else {
|
||||||
$this->func = /*$this->config['ssl'] &&*/ function_exists('ssh2_connect') ? 'ssh2_connect' : 'ftp_connect';
|
$this->func = /*$this->config['ssl'] &&*/ function_exists('ssh2_connect') ? 'ssh2_connect' : 'ftp_connect';
|
||||||
if($this->func == 'ftp_connect' && !function_exists('ftp_connect')) {
|
if($this->func == 'ftp_connect' && !function_exists('ftp_connect')) {
|
||||||
$this->set_error(FTP_ERR_SERVER_DISABLED);
|
$this->set_error(FTP_ERR_SERVER_DISABLED);
|
||||||
} else {
|
} else {
|
||||||
$this->config['host'] = dzz_ftp::clear($this->config['host']);
|
$this->config['host'] = dzz_ftp::clear($this->config['host']);
|
||||||
$this->config['port'] = intval($this->config['port']);
|
$this->config['port'] = intval($this->config['port']);
|
||||||
$this->config['ssl'] = intval($this->config['ssl']);
|
$this->config['ssl'] = intval($this->config['ssl']);
|
||||||
$this->config['username'] = dzz_ftp::clear($this->config['username']);
|
$this->config['username'] = dzz_ftp::clear($this->config['username']);
|
||||||
$this->config['password'] = authcode($this->config['password'], 'DECODE', md5(getglobal('config/security/authkey')));
|
$this->config['password'] = authcode($this->config['password'], 'DECODE', md5(getglobal('config/security/authkey')));
|
||||||
$this->config['timeout'] = intval($this->config['timeout']);
|
$this->config['timeout'] = intval($this->config['timeout']);
|
||||||
$this->config['charset'] = ($this->config['charset']);
|
$this->config['charset'] = ($this->config['charset']);
|
||||||
$this->enabled = true;
|
$this->enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function basename($path){
|
function basename($path){
|
||||||
$arr=explode('/',$path);
|
$arr=explode('/',$path);
|
||||||
return $arr[count($arr)-1];
|
return $arr[count($arr)-1];
|
||||||
}
|
}
|
||||||
function upload($source, $target,$mode=FTP_BINARY,$startpos=0) {
|
function upload($source, $target,$mode=FTP_BINARY,$startpos=0) {
|
||||||
if($this->error()) {
|
if($this->error()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$old_dir = $this->ftp_pwd();
|
$old_dir = $this->ftp_pwd();
|
||||||
$dirname = dirname($target);
|
$dirname = dirname($target);
|
||||||
$filename =$this->basename($target);
|
$filename =$this->basename($target);
|
||||||
if(!$this->ftp_chdir($dirname)) {
|
if(!$this->ftp_chdir($dirname)) {
|
||||||
if($this->ftp_mkdir($dirname)) {
|
if($this->ftp_mkdir($dirname)) {
|
||||||
$this->ftp_chmod($dirname);
|
$this->ftp_chmod($dirname);
|
||||||
if(!$this->ftp_chdir($dirname)) {
|
if(!$this->ftp_chdir($dirname)) {
|
||||||
$this->set_error(FTP_ERR_CHDIR);
|
$this->set_error(FTP_ERR_CHDIR);
|
||||||
}
|
}
|
||||||
//$this->ftp_put('index.htm', getglobal('setting/attachdir').'/index.htm', FTP_BINARY);
|
//$this->ftp_put('index.htm', getglobal('setting/attachdir').'/index.htm', FTP_BINARY);
|
||||||
} else {
|
} else {
|
||||||
$this->set_error(FTP_ERR_MKDIR);
|
$this->set_error(FTP_ERR_MKDIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = 0;
|
$res = 0;
|
||||||
if(!$this->error()) {
|
if(!$this->error()) {
|
||||||
if($fp = @fopen($source, 'rb')) {
|
if($fp = @fopen($source, 'rb')) {
|
||||||
|
|
||||||
$res = $this->ftp_fput($filename, $fp, $mode , $startpos);
|
$res = $this->ftp_fput($filename, $fp, $mode , $startpos);
|
||||||
@fclose($fp);
|
@fclose($fp);
|
||||||
!$res && $this->set_error(FTP_ERR_TARGET_WRITE);
|
!$res && $this->set_error(FTP_ERR_TARGET_WRITE);
|
||||||
} else {
|
} else {
|
||||||
$this->set_error(FTP_ERR_SOURCE_READ);
|
$this->set_error(FTP_ERR_SOURCE_READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ftp_chdir($old_dir);
|
$this->ftp_chdir($old_dir);
|
||||||
|
|
||||||
return $res ? 1 : 0;
|
return $res ? 1 : 0;
|
||||||
}
|
}
|
||||||
function connect() {
|
function connect() {
|
||||||
if(!$this->enabled || empty($this->config)) {
|
if(!$this->enabled || empty($this->config)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return $this->ftp_connect(
|
return $this->ftp_connect(
|
||||||
$this->config['host'],
|
$this->config['host'],
|
||||||
$this->config['username'],
|
$this->config['username'],
|
||||||
$this->config['password'],
|
$this->config['password'],
|
||||||
$this->config['attachdir'],
|
$this->config['attachdir'],
|
||||||
$this->config['port'],
|
$this->config['port'],
|
||||||
$this->config['timeout'],
|
$this->config['timeout'],
|
||||||
$this->config['ssl'],
|
$this->config['ssl'],
|
||||||
$this->config['pasv']
|
$this->config['pasv']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function ftp_connect($ftphost, $username, $password, $ftppath, $ftpport = 21, $timeout = 30, $ftpssl = 0, $ftppasv = 0) {
|
function ftp_connect($ftphost, $username, $password, $ftppath, $ftpport = 21, $timeout = 30, $ftpssl = 0, $ftppasv = 0) {
|
||||||
$res = 0;
|
$res = 0;
|
||||||
$fun = $this->func;
|
$fun = $this->func;
|
||||||
if($this->connectid = $fun($ftphost, $ftpport, 20)) {
|
if($this->connectid = $fun($ftphost, $ftpport, 20)) {
|
||||||
$timeout && $this->set_option(FTP_TIMEOUT_SEC, $timeout);
|
$timeout && $this->set_option(FTP_TIMEOUT_SEC, $timeout);
|
||||||
if($this->ftp_login($username, $password)) {
|
if($this->ftp_login($username, $password)) {
|
||||||
$this->ftp_pasv($ftppasv);
|
$this->ftp_pasv($ftppasv);
|
||||||
if($ftppath){
|
if($ftppath){
|
||||||
if($this->ftp_chdir($ftppath)) {
|
if($this->ftp_chdir($ftppath)) {
|
||||||
$res = $this->connectid;
|
$res = $this->connectid;
|
||||||
} else {
|
} else {
|
||||||
$this->set_error(FTP_ERR_CHDIR);
|
$this->set_error(FTP_ERR_CHDIR);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$res = $this->connectid;
|
$res = $this->connectid;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->set_error(FTP_ERR_USER_NO_LOGGIN);
|
$this->set_error(FTP_ERR_USER_NO_LOGGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$this->set_error(FTP_ERR_CONNECT_TO_SERVER);
|
$this->set_error(FTP_ERR_CONNECT_TO_SERVER);
|
||||||
}
|
}
|
||||||
if($res > 0) {
|
if($res > 0) {
|
||||||
$this->set_error();
|
$this->set_error();
|
||||||
$this->enabled = 1;
|
$this->enabled = 1;
|
||||||
$this->systype=$this->ftp_systype();
|
$this->systype=$this->ftp_systype();
|
||||||
} else {
|
} else {
|
||||||
$this->enabled = 0;
|
$this->enabled = 0;
|
||||||
$this->ftp_close();
|
$this->ftp_close();
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_error($code = 0) {
|
function set_error($code = 0) {
|
||||||
$this->_error = $code;
|
$this->_error = $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
return $this->_error;
|
return $this->_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear($str) {
|
function clear($str) {
|
||||||
return str_replace(array( "\n", "\r", '..'), '', $str);
|
return str_replace(array( "\n", "\r", '..'), '', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_option($cmd, $value) {
|
function set_option($cmd, $value) {
|
||||||
if(function_exists('ftp_set_option')) {
|
if(function_exists('ftp_set_option')) {
|
||||||
return @ftp_set_option($this->connectid, $cmd, $value);
|
return @ftp_set_option($this->connectid, $cmd, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function ftp_mkdir($directory) {
|
function ftp_mkdir($directory) {
|
||||||
$directory = dzz_ftp::clear($directory);
|
$directory = dzz_ftp::clear($directory);
|
||||||
$epath = explode('/', $directory);
|
$epath = explode('/', $directory);
|
||||||
$dir = '';$comma = '';
|
$dir = '';$comma = '';
|
||||||
foreach($epath as $path) {
|
foreach($epath as $path) {
|
||||||
$dir .= $comma.$path;
|
$dir .= $comma.$path;
|
||||||
$comma = '/';
|
$comma = '/';
|
||||||
$return = @ftp_mkdir($this->connectid, $dir);
|
$return = @ftp_mkdir($this->connectid, $dir);
|
||||||
$this->ftp_chmod($dir);
|
$this->ftp_chmod($dir);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_rmdir($directory) {
|
function ftp_rmdir($directory) {
|
||||||
$directory = dzz_ftp::clear($directory);
|
$directory = dzz_ftp::clear($directory);
|
||||||
return @ftp_rmdir($this->connectid, $directory);
|
return @ftp_rmdir($this->connectid, $directory);
|
||||||
}
|
}
|
||||||
function ftp_rmdir_force($path){
|
function ftp_rmdir_force($path){
|
||||||
$path = dzz_ftp::clear($path);
|
$path = dzz_ftp::clear($path);
|
||||||
if(!@ftp_rmdir($this->connectid, $path)){
|
if(!@ftp_rmdir($this->connectid, $path)){
|
||||||
//检查子目录
|
//检查子目录
|
||||||
if($list=self::ftp_list($path,0)){
|
if($list=self::ftp_list($path,0)){
|
||||||
foreach($list as $value){
|
foreach($list as $value){
|
||||||
if($value['type']=='folder'){
|
if($value['type']=='folder'){
|
||||||
self::ftp_rmdir_force($value['path']);
|
self::ftp_rmdir_force($value['path']);
|
||||||
}else{
|
}else{
|
||||||
self::ftp_delete($value['path']);
|
self::ftp_delete($value['path']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return @ftp_rmdir($this->connectid, $path);
|
return @ftp_rmdir($this->connectid, $path);
|
||||||
}else{
|
}else{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_put($remote_file, $local_file, $mode = FTP_BINARY) {
|
function ftp_put($remote_file, $local_file, $mode = FTP_BINARY) {
|
||||||
$remote_file = dzz_ftp::clear($remote_file);
|
$remote_file = dzz_ftp::clear($remote_file);
|
||||||
$local_file = dzz_ftp::clear($local_file);
|
$local_file = dzz_ftp::clear($local_file);
|
||||||
$mode = intval($mode);
|
$mode = intval($mode);
|
||||||
return @ftp_put($this->connectid, $remote_file, $local_file, $mode);
|
return @ftp_put($this->connectid, $remote_file, $local_file, $mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_fput($remote_file, $sourcefp, $mode = FTP_BINARY,$startpos=0) {
|
function ftp_fput($remote_file, $sourcefp, $mode = FTP_BINARY,$startpos=0) {
|
||||||
$remote_file = dzz_ftp::clear($remote_file);
|
$remote_file = dzz_ftp::clear($remote_file);
|
||||||
$mode = intval($mode);
|
$mode = intval($mode);
|
||||||
return @ftp_fput($this->connectid, $remote_file, $sourcefp, $mode,$startpos);
|
return @ftp_fput($this->connectid, $remote_file, $sourcefp, $mode,$startpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_size($remote_file) {
|
function ftp_size($remote_file) {
|
||||||
$remote_file = dzz_ftp::clear($remote_file);
|
$remote_file = dzz_ftp::clear($remote_file);
|
||||||
return @ftp_size($this->connectid, $remote_file);
|
return @ftp_size($this->connectid, $remote_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_close() {
|
function ftp_close() {
|
||||||
return @ftp_close($this->connectid);
|
return @ftp_close($this->connectid);
|
||||||
}
|
}
|
||||||
function ftp_rename($path,$newpath) {
|
function ftp_rename($path,$newpath) {
|
||||||
$path = dzz_ftp::clear($path);
|
$path = dzz_ftp::clear($path);
|
||||||
$newpath = dzz_ftp::clear($newpath);
|
$newpath = dzz_ftp::clear($newpath);
|
||||||
return @ftp_rename($this->connectid, $path,$newpath);
|
return @ftp_rename($this->connectid, $path,$newpath);
|
||||||
}
|
}
|
||||||
function ftp_delete($path) {
|
function ftp_delete($path) {
|
||||||
$path = dzz_ftp::clear($path);
|
$path = dzz_ftp::clear($path);
|
||||||
return @ftp_delete($this->connectid, $path);
|
return @ftp_delete($this->connectid, $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_get($local_file, $remote_file, $mode, $resumepos = 0) {
|
function ftp_get($local_file, $remote_file, $mode, $resumepos = 0) {
|
||||||
$remote_file = dzz_ftp::clear($remote_file);
|
$remote_file = dzz_ftp::clear($remote_file);
|
||||||
$local_file = dzz_ftp::clear($local_file);
|
$local_file = dzz_ftp::clear($local_file);
|
||||||
$mode = intval($mode);
|
$mode = intval($mode);
|
||||||
$resumepos = intval($resumepos);
|
$resumepos = intval($resumepos);
|
||||||
return @ftp_get($this->connectid, $local_file, $remote_file, $mode, $resumepos);
|
return @ftp_get($this->connectid, $local_file, $remote_file, $mode, $resumepos);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_login($username, $password) {
|
function ftp_login($username, $password) {
|
||||||
$username = $this->clear($username);
|
$username = $this->clear($username);
|
||||||
$password = str_replace(array("\n", "\r"), array('', ''), $password);
|
$password = str_replace(array("\n", "\r"), array('', ''), $password);
|
||||||
return @ftp_login($this->connectid, $username, $password);
|
return @ftp_login($this->connectid, $username, $password);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_pasv($pasv) {
|
function ftp_pasv($pasv) {
|
||||||
return @ftp_pasv($this->connectid, $pasv ? true : false);
|
return @ftp_pasv($this->connectid, $pasv ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_chdir($directory) {
|
function ftp_chdir($directory) {
|
||||||
$directory = dzz_ftp::clear($directory);
|
$directory = dzz_ftp::clear($directory);
|
||||||
return @ftp_chdir($this->connectid, $directory);
|
return @ftp_chdir($this->connectid, $directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_site($cmd) {
|
function ftp_site($cmd) {
|
||||||
$cmd = dzz_ftp::clear($cmd);
|
$cmd = dzz_ftp::clear($cmd);
|
||||||
return @ftp_site($this->connectid, $cmd);
|
return @ftp_site($this->connectid, $cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_chmod($filename, $chmod = 0777) {
|
function ftp_chmod($filename, $chmod = 0777) {
|
||||||
//$chmod = octdec ( str_pad ( $chmod, 4, '0', STR_PAD_LEFT ) );
|
//$chmod = octdec ( str_pad ( $chmod, 4, '0', STR_PAD_LEFT ) );
|
||||||
//$chmod = (int) $chmod;
|
//$chmod = (int) $chmod;
|
||||||
|
|
||||||
$filename = dzz_ftp::clear($filename);
|
$filename = dzz_ftp::clear($filename);
|
||||||
if(function_exists('ftp_chmod')) {
|
if(function_exists('ftp_chmod')) {
|
||||||
return @ftp_chmod($this->connectid, $chmod, $filename);
|
return @ftp_chmod($this->connectid, $chmod, $filename);
|
||||||
} else {
|
} else {
|
||||||
return @ftp_site($this->connectid, 'CHMOD '.$chmod.' '.$filename);
|
return @ftp_site($this->connectid, 'CHMOD '.$chmod.' '.$filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function ftp_chmod_son($filename,$chmod = 0777){
|
function ftp_chmod_son($filename,$chmod = 0777){
|
||||||
//$chmod = octdec ( str_pad ( $chmod, 4, '0', STR_PAD_LEFT ) );
|
//$chmod = octdec ( str_pad ( $chmod, 4, '0', STR_PAD_LEFT ) );
|
||||||
//$chmod = (int) $chmod;
|
//$chmod = (int) $chmod;
|
||||||
|
|
||||||
$filename = dzz_ftp::clear($filename);
|
$filename = dzz_ftp::clear($filename);
|
||||||
//检查子目录
|
//检查子目录
|
||||||
if($list=self::ftp_list($filename,0)){
|
if($list=self::ftp_list($filename,0)){
|
||||||
foreach($list as $value){
|
foreach($list as $value){
|
||||||
if($value['type']=='folder'){
|
if($value['type']=='folder'){
|
||||||
self::ftp_chmod_son($value['path'],$chmod);
|
self::ftp_chmod_son($value['path'],$chmod);
|
||||||
}else{
|
}else{
|
||||||
self::ftp_chmod($value['path'],$chmod);
|
self::ftp_chmod($value['path'],$chmod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self::ftp_chmod($filename,$chmod);
|
return self::ftp_chmod($filename,$chmod);
|
||||||
}
|
}
|
||||||
function ftp_meta($path){
|
function ftp_meta($path){
|
||||||
$path = dzz_ftp::clear($path);
|
$path = dzz_ftp::clear($path);
|
||||||
$ppath=substr($path,0,strrpos($path,'/'));
|
$ppath=substr($path,0,strrpos($path,'/'));
|
||||||
$data=self::ftp_list($ppath,0);
|
$data=self::ftp_list($ppath,0);
|
||||||
foreach($data as $value){
|
foreach($data as $value){
|
||||||
if($value['path']==$path){
|
if($value['path']==$path){
|
||||||
$value['path']=diconv($value['path'],$this->config['charset'],CHARSET);
|
$value['path']=diconv($value['path'],$this->config['charset'],CHARSET);
|
||||||
$value['name']=diconv($value['name'],$this->config['charset'],CHARSET);
|
$value['name']=diconv($value['name'],$this->config['charset'],CHARSET);
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function ftp_mdtm($cmd) {
|
function ftp_mdtm($cmd) {
|
||||||
$cmd = dzz_ftp::clear($cmd);
|
$cmd = dzz_ftp::clear($cmd);
|
||||||
return @ftp_mdtm($this->connectid, $cmd);
|
return @ftp_mdtm($this->connectid, $cmd);
|
||||||
}
|
}
|
||||||
function ftp_pwd() {
|
function ftp_pwd() {
|
||||||
return @ftp_pwd($this->connectid);
|
return @ftp_pwd($this->connectid);
|
||||||
}
|
}
|
||||||
function ftp_systype(){
|
function ftp_systype(){
|
||||||
return @ftp_systype($this->connectid);
|
return @ftp_systype($this->connectid);
|
||||||
}
|
}
|
||||||
function ftp_isdir($dir){ //判断是否为目录
|
function ftp_isdir($dir){ //判断是否为目录
|
||||||
if(@ftp_chdir($this->connectid,$dir)){
|
if(@ftp_chdir($this->connectid,$dir)){
|
||||||
@ftp_cdup($this->connectid);
|
@ftp_cdup($this->connectid);
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_list($path,$iconv=1) {
|
function ftp_list($path,$iconv=1) {
|
||||||
$path = dzz_ftp::clear($path);
|
$path = dzz_ftp::clear($path);
|
||||||
if(empty($path)) $path=self::ftp_pwd();
|
if(empty($path)) $path=self::ftp_pwd();
|
||||||
else self::ftp_chdir($path);
|
else self::ftp_chdir($path);
|
||||||
$files = array();
|
$files = array();
|
||||||
$rawList = ftp_rawlist($this->connectid, '');
|
$rawList = ftp_rawlist($this->connectid, '');
|
||||||
$data=self::parseRawList($rawList);
|
$data=self::parseRawList($rawList);
|
||||||
foreach($data as $key => $value){
|
foreach($data as $key => $value){
|
||||||
$value['path']=$iconv?diconv(preg_replace("/\/+/",'/',$path.'/'.$value['name']),$this->config['charset'],CHARSET):preg_replace("/\/+/",'/',$path.'/'.$value['name']);
|
$value['path']=$iconv?diconv(preg_replace("/\/+/",'/',$path.'/'.$value['name']),$this->config['charset'],CHARSET):preg_replace("/\/+/",'/',$path.'/'.$value['name']);
|
||||||
$value['name']=$iconv?diconv($value['name'],$this->config['charset'],CHARSET):$value['name'];
|
$value['name']=$iconv?diconv($value['name'],$this->config['charset'],CHARSET):$value['name'];
|
||||||
$data[$key]=$value;
|
$data[$key]=$value;
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
function byteconvert($bytes) {
|
function byteconvert($bytes) {
|
||||||
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
|
||||||
$exp = floor( log($bytes) / log(1024) );
|
$exp = floor( log($bytes) / log(1024) );
|
||||||
return sprintf( '%.2f ' . $symbol[ $exp ], ($bytes / pow(1024, floor($exp))) );
|
return sprintf( '%.2f ' . $symbol[ $exp ], ($bytes / pow(1024, floor($exp))) );
|
||||||
}
|
}
|
||||||
|
|
||||||
function chmodnum($chmod) {
|
function chmodnum($chmod) {
|
||||||
$trans = array('-' => '0', 'r' => '4', 'w' => '2', 'x' => '1', 't' => '1', 's' => '1');
|
$trans = array('-' => '0', 'r' => '4', 'w' => '2', 'x' => '1', 't' => '1', 's' => '1');
|
||||||
$chmod = substr(strtr($chmod, $trans), 1);
|
$chmod = substr(strtr($chmod, $trans), 1);
|
||||||
$array = str_split($chmod, 3);
|
$array = str_split($chmod, 3);
|
||||||
return array_sum(str_split($array[0])) . array_sum(str_split($array[1])) . array_sum(str_split($array[2]));
|
return array_sum(str_split($array[0])) . array_sum(str_split($array[1])) . array_sum(str_split($array[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseRawList($rawList){
|
function parseRawList($rawList){
|
||||||
$data=array();
|
$data=array();
|
||||||
foreach($rawList as $key=>$value)
|
foreach($rawList as $key=>$value)
|
||||||
{
|
{
|
||||||
$temp=array();
|
$temp=array();
|
||||||
$parser = null;
|
$parser = null;
|
||||||
if(preg_match("/Window/i",$this->systype)){
|
if(preg_match("/Window/i",$this->systype)){
|
||||||
$parser = explode(" ", preg_replace('!\s+!', ' ', $value));
|
$parser = explode(" ", preg_replace('!\s+!', ' ', $value));
|
||||||
if(isset($parser)){
|
if(isset($parser)){
|
||||||
list($month,$day,$year)=explode('-',$parser[0]);
|
list($month,$day,$year)=explode('-',$parser[0]);
|
||||||
$temp['mtime']=strtotime($year.'-'.$month.'-'.$day.' '.$parser[1]);
|
$temp['mtime']=strtotime($year.'-'.$month.'-'.$day.' '.$parser[1]);
|
||||||
$temp['type']=preg_match("/<DIR>/i",$parser[2])?'folder':'file';
|
$temp['type']=preg_match("/<DIR>/i",$parser[2])?'folder':'file';
|
||||||
|
|
||||||
if($temp['type']=='folder'){
|
if($temp['type']=='folder'){
|
||||||
$temp['size']=0;
|
$temp['size']=0;
|
||||||
$temp['name']=substr($value,strrpos($value,$parser[3]));
|
$temp['name']=substr($value,strrpos($value,$parser[3]));
|
||||||
}else{
|
}else{
|
||||||
$temp['size']=$parser[2];
|
$temp['size']=$parser[2];
|
||||||
$temp['name']=substr($value,strrpos($value,$parser[3]));
|
$temp['name']=substr($value,strrpos($value,$parser[3]));
|
||||||
}
|
}
|
||||||
$temp['mod']=0;
|
$temp['mod']=0;
|
||||||
$data[] = $temp;
|
$data[] = $temp;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$parser = explode(" ", preg_replace('!\s+!', ' ', $value));
|
$parser = explode(" ", preg_replace('!\s+!', ' ', $value));
|
||||||
//echo $value;
|
//echo $value;
|
||||||
//print_r($parser);
|
//print_r($parser);
|
||||||
if(isset($parser)){
|
if(isset($parser)){
|
||||||
|
|
||||||
$temp['mod']=self::chmodnum($parser[0]);
|
$temp['mod']=self::chmodnum($parser[0]);
|
||||||
$temp['mtime']=strtotime($parser[5].' '.$parser[6].' '.$parser[7]);
|
$temp['mtime']=strtotime($parser[5].' '.$parser[6].' '.$parser[7]);
|
||||||
$temp['type']=(substr($parser[0], 0, 1)=='d')?'folder':'file';
|
$temp['type']=(substr($parser[0], 0, 1)=='d')?'folder':'file';
|
||||||
$temp['size']=$parser[4];
|
$temp['size']=$parser[4];
|
||||||
$temp['name']=substr($value,strrpos($value,$parser[8]));
|
$temp['name']=substr($value,strrpos($value,$parser[8]));
|
||||||
if($temp['name']!='.' && $temp['name']!='..'){
|
if($temp['name']!='.' && $temp['name']!='..'){
|
||||||
// print_r($temp);
|
// print_r($temp);
|
||||||
$data[] = $temp;
|
$data[] = $temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,191 +1,191 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_memory extends dzz_base
|
class dzz_memory extends dzz_base
|
||||||
{
|
{
|
||||||
private $config;
|
private $config;
|
||||||
private $extension = array();
|
private $extension = array();
|
||||||
private $memory;
|
private $memory;
|
||||||
private $prefix;
|
private $prefix;
|
||||||
private $userprefix;
|
private $userprefix;
|
||||||
public $type;
|
public $type;
|
||||||
public $enable = false;
|
public $enable = false;
|
||||||
public $debug = array();
|
public $debug = array();
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->extension['redis'] = extension_loaded('redis');
|
$this->extension['redis'] = extension_loaded('redis');
|
||||||
$this->extension['memcache'] = extension_loaded('memcache');
|
$this->extension['memcache'] = extension_loaded('memcache');
|
||||||
$this->extension['memcached'] = extension_loaded('memcached');
|
$this->extension['memcached'] = extension_loaded('memcached');
|
||||||
$this->extension['apc'] = function_exists('apc_cache_info') && @apc_cache_info();
|
$this->extension['apc'] = function_exists('apc_cache_info') && @apc_cache_info();
|
||||||
$this->extension['xcache'] = function_exists('xcache_get');
|
$this->extension['xcache'] = function_exists('xcache_get');
|
||||||
$this->extension['eaccelerator'] = function_exists('eaccelerator_get');
|
$this->extension['eaccelerator'] = function_exists('eaccelerator_get');
|
||||||
$this->extension['wincache'] = function_exists('wincache_ucache_meminfo') && wincache_ucache_meminfo();
|
$this->extension['wincache'] = function_exists('wincache_ucache_meminfo') && wincache_ucache_meminfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init($config) {
|
public function init($config) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->prefix = empty($config['prefix']) ? substr(md5($_SERVER['HTTP_HOST']), 0, 6).'_' : $config['prefix'];
|
$this->prefix = empty($config['prefix']) ? substr(md5($_SERVER['HTTP_HOST']), 0, 6).'_' : $config['prefix'];
|
||||||
|
|
||||||
|
|
||||||
if($this->extension['redis'] && !empty($config['redis']['server'])) {
|
if($this->extension['redis'] && !empty($config['redis']['server'])) {
|
||||||
$this->memory = new memory_driver_redis();
|
$this->memory = new memory_driver_redis();
|
||||||
$this->memory->init($this->config['redis']);
|
$this->memory->init($this->config['redis']);
|
||||||
if(!$this->memory->enable) {
|
if(!$this->memory->enable) {
|
||||||
$this->memory = null;
|
$this->memory = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$this->memory->enable && $this->extension['memcached'] && !empty($config['memcached']['server'])) {
|
if(!$this->memory->enable && $this->extension['memcached'] && !empty($config['memcached']['server'])) {
|
||||||
$this->memory = new memory_driver_memcached();
|
$this->memory = new memory_driver_memcached();
|
||||||
$this->memory->init($this->config['memcached']);
|
$this->memory->init($this->config['memcached']);
|
||||||
if(!$this->memory->enable) {
|
if(!$this->memory->enable) {
|
||||||
$this->memory = null;
|
$this->memory = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$this->memory->enable && $this->extension['memcache'] && !empty($config['memcache']['server'])) {
|
if(!$this->memory->enable && $this->extension['memcache'] && !empty($config['memcache']['server'])) {
|
||||||
$this->memory = new memory_driver_memcache();
|
$this->memory = new memory_driver_memcache();
|
||||||
$this->memory->init($this->config['memcache']);
|
$this->memory->init($this->config['memcache']);
|
||||||
if(!$this->memory->enable) {
|
if(!$this->memory->enable) {
|
||||||
$this->memory = null;
|
$this->memory = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(array('apc', 'eaccelerator', 'xcache', 'wincache') as $cache) {
|
foreach(array('apc', 'eaccelerator', 'xcache', 'wincache') as $cache) {
|
||||||
if(!is_object($this->memory) && $this->extension[$cache] && $this->config[$cache]) {
|
if(!is_object($this->memory) && $this->extension[$cache] && $this->config[$cache]) {
|
||||||
$class_name = 'memory_driver_'.$cache;
|
$class_name = 'memory_driver_'.$cache;
|
||||||
$this->memory = new $class_name();
|
$this->memory = new $class_name();
|
||||||
$this->memory->init(null);
|
$this->memory->init(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_object($this->memory)) {
|
if(is_object($this->memory)) {
|
||||||
$this->enable = true;
|
$this->enable = true;
|
||||||
$this->type = str_replace('memory_driver_', '', get_class($this->memory));
|
$this->type = str_replace('memory_driver_', '', get_class($this->memory));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($key, $prefix = '') {
|
public function get($key, $prefix = '') {
|
||||||
static $getmulti = null;
|
static $getmulti = null;
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if($this->enable) {
|
if($this->enable) {
|
||||||
if(!isset($getmulti)) $getmulti = method_exists($this->memory, 'getMulti');
|
if(!isset($getmulti)) $getmulti = method_exists($this->memory, 'getMulti');
|
||||||
$this->userprefix = $prefix;
|
$this->userprefix = $prefix;
|
||||||
if(is_array($key)) {
|
if(is_array($key)) {
|
||||||
if($getmulti) {
|
if($getmulti) {
|
||||||
$ret = $this->memory->getMulti($this->_key($key));
|
$ret = $this->memory->getMulti($this->_key($key));
|
||||||
if($ret !== false && !empty($ret)) {
|
if($ret !== false && !empty($ret)) {
|
||||||
$_ret = array();
|
$_ret = array();
|
||||||
foreach((array)$ret as $_key => $value) {
|
foreach((array)$ret as $_key => $value) {
|
||||||
$_ret[$this->_trim_key($_key)] = $value;
|
$_ret[$this->_trim_key($_key)] = $value;
|
||||||
}
|
}
|
||||||
$ret = $_ret;
|
$ret = $_ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$_ret = false;
|
$_ret = false;
|
||||||
foreach($key as $id) {
|
foreach($key as $id) {
|
||||||
if(($_ret = $this->memory->get($this->_key($id))) !== false && isset($_ret)) {
|
if(($_ret = $this->memory->get($this->_key($id))) !== false && isset($_ret)) {
|
||||||
$ret[$id] = $_ret;
|
$ret[$id] = $_ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(empty($ret)) $ret = false;
|
if(empty($ret)) $ret = false;
|
||||||
} else {
|
} else {
|
||||||
$ret = $this->memory->get($this->_key($key));
|
$ret = $this->memory->get($this->_key($key));
|
||||||
if(!isset($ret)) $ret = false;
|
if(!isset($ret)) $ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($key, $value, $ttl = 0, $prefix = '') {
|
public function set($key, $value, $ttl = 0, $prefix = '') {
|
||||||
|
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if($value === false) $value = '';
|
if($value === false) $value = '';
|
||||||
if($this->enable) {
|
if($this->enable) {
|
||||||
$this->userprefix = $prefix;
|
$this->userprefix = $prefix;
|
||||||
$ret = $this->memory->set($this->_key($key), $value, $ttl);
|
$ret = $this->memory->set($this->_key($key), $value, $ttl);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rm($key, $prefix = '') {
|
public function rm($key, $prefix = '') {
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if($this->enable) {
|
if($this->enable) {
|
||||||
$this->userprefix = $prefix;
|
$this->userprefix = $prefix;
|
||||||
$key = $this->_key($key);
|
$key = $this->_key($key);
|
||||||
foreach((array)$key as $id) {
|
foreach((array)$key as $id) {
|
||||||
$ret = $this->memory->rm($id);
|
$ret = $this->memory->rm($id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear() {
|
public function clear() {
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if($this->enable && method_exists($this->memory, 'clear')) {
|
if($this->enable && method_exists($this->memory, 'clear')) {
|
||||||
$ret = $this->memory->clear();
|
$ret = $this->memory->clear();
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function inc($key, $step = 1) {
|
public function inc($key, $step = 1) {
|
||||||
static $hasinc = null;
|
static $hasinc = null;
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if($this->enable) {
|
if($this->enable) {
|
||||||
if(!isset($hasinc)) $hasinc = method_exists($this->memory, 'inc');
|
if(!isset($hasinc)) $hasinc = method_exists($this->memory, 'inc');
|
||||||
if($hasinc) {
|
if($hasinc) {
|
||||||
$ret = $this->memory->inc($this->_key($key), $step);
|
$ret = $this->memory->inc($this->_key($key), $step);
|
||||||
} else {
|
} else {
|
||||||
if(($data = $this->memory->get($key)) !== false) {
|
if(($data = $this->memory->get($key)) !== false) {
|
||||||
$ret = ($this->memory->set($key, $data + ($step)) !== false ? $this->memory->get($key) : false);
|
$ret = ($this->memory->set($key, $data + ($step)) !== false ? $this->memory->get($key) : false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dec($key, $step = 1) {
|
public function dec($key, $step = 1) {
|
||||||
static $hasdec = null;
|
static $hasdec = null;
|
||||||
$ret = false;
|
$ret = false;
|
||||||
if($this->enable) {
|
if($this->enable) {
|
||||||
if(!isset($hasdec)) $hasdec = method_exists($this->memory, 'dec');
|
if(!isset($hasdec)) $hasdec = method_exists($this->memory, 'dec');
|
||||||
if($hasdec) {
|
if($hasdec) {
|
||||||
$ret = $this->memory->dec($this->_key($key), $step);
|
$ret = $this->memory->dec($this->_key($key), $step);
|
||||||
} else {
|
} else {
|
||||||
if(($data = $this->memory->get($key)) !== false) {
|
if(($data = $this->memory->get($key)) !== false) {
|
||||||
$ret = ($this->memory->set($key, $data - ($step)) !== false ? $this->memory->get($key) : false);
|
$ret = ($this->memory->set($key, $data - ($step)) !== false ? $this->memory->get($key) : false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _key($str) {
|
private function _key($str) {
|
||||||
$perfix = $this->prefix.$this->userprefix;
|
$perfix = $this->prefix.$this->userprefix;
|
||||||
if(is_array($str)) {
|
if(is_array($str)) {
|
||||||
foreach($str as &$val) {
|
foreach($str as &$val) {
|
||||||
$val = $perfix.$val;
|
$val = $perfix.$val;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$str = $perfix.$str;
|
$str = $perfix.$str;
|
||||||
}
|
}
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _trim_key($str) {
|
private function _trim_key($str) {
|
||||||
return substr($str, strlen($this->prefix.$this->userprefix));
|
return substr($str, strlen($this->prefix.$this->userprefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getextension() {
|
public function getextension() {
|
||||||
return $this->extension;
|
return $this->extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getconfig() {
|
public function getconfig() {
|
||||||
return $this->config;
|
return $this->config;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,148 +1,148 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
* @copyright QiaoQiaoShiDai Internet Technology(Shanghai)Co.,Ltd
|
||||||
* @license https://www.oaooa.com/licenses/
|
* @license https://www.oaooa.com/licenses/
|
||||||
*
|
*
|
||||||
* @link https://www.oaooa.com
|
* @link https://www.oaooa.com
|
||||||
* @author zyx(zyx@oaooa.com)
|
* @author zyx(zyx@oaooa.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_notification {
|
class dzz_notification {
|
||||||
|
|
||||||
|
|
||||||
public static function notification_add($touid, $type, $note, $notevars = array(), $category = 0,$langfolder='') {
|
public static function notification_add($touid, $type, $note, $notevars = array(), $category = 0,$langfolder='') {
|
||||||
global $_G;
|
global $_G;
|
||||||
|
|
||||||
if(!($tospace = getuserbyuid($touid))) {
|
if(!($tospace = getuserbyuid($touid))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$notestring = lang($note, $notevars,'',$langfolder);
|
$notestring = lang($note, $notevars,'',$langfolder);
|
||||||
$notestring_wx = lang($note.'_wx', $notevars,'',$langfolder);
|
$notestring_wx = lang($note.'_wx', $notevars,'',$langfolder);
|
||||||
$redirect=lang( $note.'_redirecturl', $notevars,'',$langfolder);
|
$redirect=lang( $note.'_redirecturl', $notevars,'',$langfolder);
|
||||||
|
|
||||||
|
|
||||||
$title=lang($note.'_title',$notevars,'',$langfolder);
|
$title=lang($note.'_title',$notevars,'',$langfolder);
|
||||||
$oldnote = array();
|
$oldnote = array();
|
||||||
//if($notevars['from_id'] && $notevars['from_idtype']) {
|
//if($notevars['from_id'] && $notevars['from_idtype']) {
|
||||||
$oldnote = C::t('notification')->fetch_by_fromid_uid_type($notevars['from_id'], $notevars['from_idtype'], $touid,$type);
|
$oldnote = C::t('notification')->fetch_by_fromid_uid_type($notevars['from_id'], $notevars['from_idtype'], $touid,$type);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if(empty($oldnote['from_num'])) $oldnote['from_num'] = 0;
|
if(empty($oldnote['from_num'])) $oldnote['from_num'] = 0;
|
||||||
$notevars['from_num'] = (isset($notevars['from_num'])&& $notevars['from_num']) ? $notevars['from_num'] : 1;
|
$notevars['from_num'] = (isset($notevars['from_num'])&& $notevars['from_num']) ? $notevars['from_num'] : 1;
|
||||||
$setarr = array(
|
$setarr = array(
|
||||||
'uid' => $touid,
|
'uid' => $touid,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'new' => 1,
|
'new' => 1,
|
||||||
'wx_new' =>1,
|
'wx_new' =>1,
|
||||||
'wx_note'=>$notestring_wx,
|
'wx_note'=>$notestring_wx,
|
||||||
'redirecturl'=>$redirect,
|
'redirecturl'=>$redirect,
|
||||||
'title'=>$title,
|
'title'=>$title,
|
||||||
'authorid' => $_G['uid'],
|
'authorid' => $_G['uid'],
|
||||||
'author' => $_G['username'],
|
'author' => $_G['username'],
|
||||||
'note' => $notestring,
|
'note' => $notestring,
|
||||||
'dateline' => $_G['timestamp'],
|
'dateline' => $_G['timestamp'],
|
||||||
'from_id' => $notevars['from_id'],
|
'from_id' => $notevars['from_id'],
|
||||||
'from_idtype' => $notevars['from_idtype'],
|
'from_idtype' => $notevars['from_idtype'],
|
||||||
'from_num' => ($oldnote['from_num']+$notevars['from_num']),
|
'from_num' => ($oldnote['from_num']+$notevars['from_num']),
|
||||||
'category'=>$category
|
'category'=>$category
|
||||||
);
|
);
|
||||||
/*if($category==1) {
|
/*if($category==1) {
|
||||||
$setarr['authorid'] = 0;
|
$setarr['authorid'] = 0;
|
||||||
$setarr['author'] = '';
|
$setarr['author'] = '';
|
||||||
}*/
|
}*/
|
||||||
if($oldnote['id']) {
|
if($oldnote['id']) {
|
||||||
$setarr['id']=$oldnote['id'];
|
$setarr['id']=$oldnote['id'];
|
||||||
C::t('notification')->update($oldnote['id'], $setarr);
|
C::t('notification')->update($oldnote['id'], $setarr);
|
||||||
} else {
|
} else {
|
||||||
$oldnote['new'] = 0;
|
$oldnote['new'] = 0;
|
||||||
$setarr['id']=C::t('notification')->insert($setarr, true);
|
$setarr['id']=C::t('notification')->insert($setarr, true);
|
||||||
}
|
}
|
||||||
$noteid=$setarr['id'];
|
$noteid=$setarr['id'];
|
||||||
Hook::listen('online_notification', $noteid);
|
Hook::listen('online_notification', $noteid);
|
||||||
//self::wx_notification($setarr);
|
//self::wx_notification($setarr);
|
||||||
//$banType = array('task');
|
//$banType = array('task');
|
||||||
if(empty($oldnote['new'])) {
|
if(empty($oldnote['new'])) {
|
||||||
C::t('user')->increase($touid, array('newprompt' => 1));
|
C::t('user')->increase($touid, array('newprompt' => 1));
|
||||||
|
|
||||||
/*require_once libfile('function/mail');
|
/*require_once libfile('function/mail');
|
||||||
$mail_subject = lang('notification', 'mail_to_user');
|
$mail_subject = lang('notification', 'mail_to_user');
|
||||||
sendmail_touser($touid, $mail_subject, $notestring, $type);*/
|
sendmail_touser($touid, $mail_subject, $notestring, $type);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function wx_sendMsg($data){
|
public function wx_sendMsg($data){
|
||||||
if(!getglobal('setting/CorpID') || !getglobal('setting/CorpSecret')) return false;
|
if(!getglobal('setting/CorpID') || !getglobal('setting/CorpSecret')) return false;
|
||||||
$user=C::t('user')->fetch($data['uid']);
|
$user=C::t('user')->fetch($data['uid']);
|
||||||
if(!$user['wechat_userid'] || $user['wechat_status']!=1){
|
if(!$user['wechat_userid'] || $user['wechat_status']!=1){
|
||||||
C::t('notification')->update($data['id'],array('wx_new'=>$data['wx_new']+1));
|
C::t('notification')->update($data['id'],array('wx_new'=>$data['wx_new']+1));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$agentid=0;
|
$agentid=0;
|
||||||
if($data['from_idtype']=='app' && $data['from_id'] && ($wxapp=C::t('wx_app')->fetch($data['from_id']))){
|
if($data['from_idtype']=='app' && $data['from_id'] && ($wxapp=C::t('wx_app')->fetch($data['from_id']))){
|
||||||
if($wxapp['agentid'] && $wxapp['status']<1) $agentid=$wxapp['agentid'];
|
if($wxapp['agentid'] && $wxapp['status']<1) $agentid=$wxapp['agentid'];
|
||||||
}
|
}
|
||||||
$appsecret=getglobal('setting/CorpSecret');
|
$appsecret=getglobal('setting/CorpSecret');
|
||||||
if(isset($wxapp['secret']) && $wxapp['secret']){
|
if(isset($wxapp['secret']) && $wxapp['secret']){
|
||||||
$appsecret=$wxapp['secret'];
|
$appsecret=$wxapp['secret'];
|
||||||
}
|
}
|
||||||
$wx=new qyWechat(array('appid'=>getglobal('setting/CorpID'),'appsecret'=>$appsecret));
|
$wx=new qyWechat(array('appid'=>getglobal('setting/CorpID'),'appsecret'=>$appsecret));
|
||||||
$msg=array(
|
$msg=array(
|
||||||
"touser" =>$user['wechat_userid'], //"dzz-".$data['uid'],
|
"touser" =>$user['wechat_userid'], //"dzz-".$data['uid'],
|
||||||
//"toparty" => "1",
|
//"toparty" => "1",
|
||||||
"safe"=>0, //是否为保密消息,对于news无效
|
"safe"=>0, //是否为保密消息,对于news无效
|
||||||
"agentid" => $agentid, //应用id
|
"agentid" => $agentid, //应用id
|
||||||
"msgtype" => "news", //根据信息类型,选择下面对应的信息结构体
|
"msgtype" => "news", //根据信息类型,选择下面对应的信息结构体
|
||||||
"news" => array( //不支持保密
|
"news" => array( //不支持保密
|
||||||
"articles" => array( //articles 图文消息,一个图文消息支持1到10个图文
|
"articles" => array( //articles 图文消息,一个图文消息支持1到10个图文
|
||||||
array(
|
array(
|
||||||
"title" => $data['title'], //标题
|
"title" => $data['title'], //标题
|
||||||
"description" => getstr($data['wx_note'],0,0,0,0,-1), //描述
|
"description" => getstr($data['wx_note'],0,0,0,0,-1), //描述
|
||||||
"url" => $wx->getOauthRedirect(getglobal('siteurl').'index.php?mod=system&op=wxredirect&url='.dzzencode($data['redirecturl'])) //点击后跳转的链接。可根据url里面带的code参数校验员工的真实身份。
|
"url" => $wx->getOauthRedirect(getglobal('siteurl').'index.php?mod=system&op=wxredirect&url='.dzzencode($data['redirecturl'])) //点击后跳转的链接。可根据url里面带的code参数校验员工的真实身份。
|
||||||
// "picurl" => "http://cs.286.com.cn/data/attachment/appimg/201409/15/161401bmtrmxlmjtlfllkr.png", //图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图640320,小图8080。如不填,在客户端不显示图片
|
// "picurl" => "http://cs.286.com.cn/data/attachment/appimg/201409/15/161401bmtrmxlmjtlfllkr.png", //图文消息的图片链接,支持JPG、PNG格式,较好的效果为大图640320,小图8080。如不填,在客户端不显示图片
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if($ret=$wx->sendMessage($msg)){
|
if($ret=$wx->sendMessage($msg)){
|
||||||
C::t('notification')->update($data['id'],array('wx_new'=>0));
|
C::t('notification')->update($data['id'],array('wx_new'=>0));
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
C::t('notification')->update($data['id'],array('wx_new'=>$data['wx_new']+1));
|
C::t('notification')->update($data['id'],array('wx_new'=>$data['wx_new']+1));
|
||||||
$message='wx_notification:errCode:'.$wx->errCode.';errMsg:'.$wx->errMsg;
|
$message='wx_notification:errCode:'.$wx->errCode.';errMsg:'.$wx->errMsg;
|
||||||
runlog('wxlog',$message);
|
runlog('wxlog',$message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function update_newprompt($uid, $type) {
|
public function update_newprompt($uid, $type) {
|
||||||
global $_G;
|
global $_G;
|
||||||
if($_G['member']['newprompt_num']) {
|
if($_G['member']['newprompt_num']) {
|
||||||
$tmpprompt = $_G['member']['newprompt_num'];
|
$tmpprompt = $_G['member']['newprompt_num'];
|
||||||
$num = 0;
|
$num = 0;
|
||||||
$updateprompt = 0;
|
$updateprompt = 0;
|
||||||
if(!empty($tmpprompt[$type])) {
|
if(!empty($tmpprompt[$type])) {
|
||||||
unset($tmpprompt[$type]);
|
unset($tmpprompt[$type]);
|
||||||
$updateprompt = true;
|
$updateprompt = true;
|
||||||
}
|
}
|
||||||
foreach($tmpprompt as $key => $val) {
|
foreach($tmpprompt as $key => $val) {
|
||||||
$num += $val;
|
$num += $val;
|
||||||
}
|
}
|
||||||
if($num) {
|
if($num) {
|
||||||
if($updateprompt) {
|
if($updateprompt) {
|
||||||
C::t('user')->update($uid, array('newprompt'=>$num));
|
C::t('user')->update($uid, array('newprompt'=>$num));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
C::t('user')->update($_G['uid'], array('newprompt'=>0));
|
C::t('user')->update($_G['uid'], array('newprompt'=>0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -1,89 +1,89 @@
|
|||||||
<?php
|
<?php
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
class dzz_process
|
class dzz_process
|
||||||
{
|
{
|
||||||
public static function islocked($process, $ttl = 0) {
|
public static function islocked($process, $ttl = 0) {
|
||||||
$ttl = $ttl < 1 ? 600 : intval($ttl);
|
$ttl = $ttl < 1 ? 600 : intval($ttl);
|
||||||
return dzz_process::_cmd('get', $name) || dzz_process::_find($process, $ttl);
|
return dzz_process::_cmd('get', $name) || dzz_process::_find($process, $ttl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function unlock($process) {
|
public static function unlock($process) {
|
||||||
//dzz_process::_status('rm', $process);
|
//dzz_process::_status('rm', $process);
|
||||||
dzz_process::_cmd('rm', $process);
|
dzz_process::_cmd('rm', $process);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _status($action, $process) {
|
private static function _status($action, $process) {
|
||||||
static $plist = array();
|
static $plist = array();
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'set' : $plist[$process] = true; break;
|
case 'set' : $plist[$process] = true; break;
|
||||||
case 'get' : return !empty($plist[$process]); break;
|
case 'get' : return !empty($plist[$process]); break;
|
||||||
case 'rm' : $plist[$process] = null; break;
|
case 'rm' : $plist[$process] = null; break;
|
||||||
case 'clear' : $plist = array(); break;
|
case 'clear' : $plist = array(); break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _find($name, $ttl) {
|
private static function _find($name, $ttl) {
|
||||||
|
|
||||||
if(!dzz_process::_cmd('get', $name)) {
|
if(!dzz_process::_cmd('get', $name)) {
|
||||||
dzz_process::_cmd('set', $name, $ttl);
|
dzz_process::_cmd('set', $name, $ttl);
|
||||||
$ret = false;
|
$ret = false;
|
||||||
} else {
|
} else {
|
||||||
$ret = true;
|
$ret = true;
|
||||||
}
|
}
|
||||||
//dzz_process::_status('set', $name);
|
//dzz_process::_status('set', $name);
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _cmd($cmd, $name, $ttl = 0) {
|
private static function _cmd($cmd, $name, $ttl = 0) {
|
||||||
static $allowmem;
|
static $allowmem;
|
||||||
if($allowmem === null) {
|
if($allowmem === null) {
|
||||||
$mc = memory('check');
|
$mc = memory('check');
|
||||||
$allowmem = $mc == 'memcache' || $mc == 'memcached' || $mc == 'redis';
|
$allowmem = $mc == 'memcache' || $mc == 'memcached' || $mc == 'redis';
|
||||||
}
|
}
|
||||||
if($allowmem) {
|
if($allowmem) {
|
||||||
return dzz_process::_process_cmd_memory($cmd, $name, $ttl);
|
return dzz_process::_process_cmd_memory($cmd, $name, $ttl);
|
||||||
} else {
|
} else {
|
||||||
return dzz_process::_process_cmd_db($cmd, $name, $ttl);
|
return dzz_process::_process_cmd_db($cmd, $name, $ttl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _process_cmd_memory($cmd, $name, $ttl = 0) {
|
private static function _process_cmd_memory($cmd, $name, $ttl = 0) {
|
||||||
$ret = '';
|
$ret = '';
|
||||||
switch ($cmd) {
|
switch ($cmd) {
|
||||||
case 'set' :
|
case 'set' :
|
||||||
$ret = memory('set', 'process_lock_'.$name, time(), $ttl);
|
$ret = memory('set', 'process_lock_'.$name, time(), $ttl);
|
||||||
break;
|
break;
|
||||||
case 'get' :
|
case 'get' :
|
||||||
$ret = memory('get', 'process_lock_'.$name);
|
$ret = memory('get', 'process_lock_'.$name);
|
||||||
break;
|
break;
|
||||||
case 'rm' :
|
case 'rm' :
|
||||||
$ret = memory('rm', 'process_lock_'.$name);
|
$ret = memory('rm', 'process_lock_'.$name);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function _process_cmd_db($cmd, $name, $ttl = 0) {
|
private static function _process_cmd_db($cmd, $name, $ttl = 0) {
|
||||||
$ret = '';
|
$ret = '';
|
||||||
switch ($cmd) {
|
switch ($cmd) {
|
||||||
case 'set':
|
case 'set':
|
||||||
$ret = C::t('process')->insert(array('processid' => $name, 'expiry' => time() + $ttl), FALSE, true);
|
$ret = C::t('process')->insert(array('processid' => $name, 'expiry' => time() + $ttl), FALSE, true);
|
||||||
break;
|
break;
|
||||||
case 'get':
|
case 'get':
|
||||||
$ret = C::t('process')->fetch($name);
|
$ret = C::t('process')->fetch($name);
|
||||||
if(empty($ret) || $ret['expiry'] < time()) {
|
if(empty($ret) || $ret['expiry'] < time()) {
|
||||||
$ret = false;
|
$ret = false;
|
||||||
} else {
|
} else {
|
||||||
$ret = true;
|
$ret = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'rm':
|
case 'rm':
|
||||||
$ret = C::t('process')->delete_process($name, time());
|
$ret = C::t('process')->delete_process($name, time());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,214 +1,214 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(!defined('IN_OAOOA')) {
|
if(!defined('IN_OAOOA')) {
|
||||||
exit('Access Denied');
|
exit('Access Denied');
|
||||||
}
|
}
|
||||||
|
|
||||||
class dzz_session {
|
class dzz_session {
|
||||||
|
|
||||||
public $sid = null;
|
public $sid = null;
|
||||||
public $var;
|
public $var;
|
||||||
public $isnew = false;
|
public $isnew = false;
|
||||||
private $newguest = array('sid' => 0, 'ip1' => 0, 'ip2' => 0, 'ip3' => 0, 'ip4' => 0,
|
private $newguest = array('sid' => 0, 'ip1' => 0, 'ip2' => 0, 'ip3' => 0, 'ip4' => 0,
|
||||||
'uid' => 0, 'username' => '', 'groupid' => 0, 'invisible' => 0, 'action' => 0,
|
'uid' => 0, 'username' => '', 'groupid' => 0, 'invisible' => 0, 'action' => 0,
|
||||||
'lastactivity' => 0, 'lastolupdate' => 0);
|
'lastactivity' => 0, 'lastolupdate' => 0);
|
||||||
|
|
||||||
private $old = array('sid' => '', 'ip' => '', 'uid' => 0);
|
private $old = array('sid' => '', 'ip' => '', 'uid' => 0);
|
||||||
|
|
||||||
private $table;
|
private $table;
|
||||||
|
|
||||||
public function __construct($sid = '', $ip = '', $uid = 0) {
|
public function __construct($sid = '', $ip = '', $uid = 0) {
|
||||||
$this->old = array('sid' => $sid, 'ip' => $ip, 'uid' => $uid);
|
$this->old = array('sid' => $sid, 'ip' => $ip, 'uid' => $uid);
|
||||||
$this->var = $this->newguest;
|
$this->var = $this->newguest;
|
||||||
|
|
||||||
$this->table = C::t('session');
|
$this->table = C::t('session');
|
||||||
|
|
||||||
if(!empty($ip)) {
|
if(!empty($ip)) {
|
||||||
$this->init($sid, $ip, $uid);
|
$this->init($sid, $ip, $uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($key, $value) {
|
public function set($key, $value) {
|
||||||
if(isset($this->newguest[$key])) {
|
if(isset($this->newguest[$key])) {
|
||||||
$this->var[$key] = $value;
|
$this->var[$key] = $value;
|
||||||
} elseif ($key == 'ip') {
|
} elseif ($key == 'ip') {
|
||||||
$ips = explode('.', $value);
|
$ips = explode('.', $value);
|
||||||
$this->set('ip1', $ips[0]);
|
$this->set('ip1', $ips[0]);
|
||||||
$this->set('ip2', $ips[1]);
|
$this->set('ip2', $ips[1]);
|
||||||
$this->set('ip3', $ips[2]);
|
$this->set('ip3', $ips[2]);
|
||||||
$this->set('ip4', $ips[3]);
|
$this->set('ip4', $ips[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($key) {
|
public function get($key) {
|
||||||
if(isset($this->newguest[$key])) {
|
if(isset($this->newguest[$key])) {
|
||||||
return $this->var[$key];
|
return $this->var[$key];
|
||||||
} elseif ($key == 'ip') {
|
} elseif ($key == 'ip') {
|
||||||
return $this->get('ip1').'.'.$this->get('ip2').'.'.$this->get('ip3').'.'.$this->get('ip4');
|
return $this->get('ip1').'.'.$this->get('ip2').'.'.$this->get('ip3').'.'.$this->get('ip4');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init($sid, $ip, $uid) {
|
public function init($sid, $ip, $uid) {
|
||||||
$this->old = array('sid' => $sid, 'ip' => $ip, 'uid' => $uid);
|
$this->old = array('sid' => $sid, 'ip' => $ip, 'uid' => $uid);
|
||||||
$session = array();
|
$session = array();
|
||||||
if($sid) {
|
if($sid) {
|
||||||
$session = $this->table->fetch($sid, $ip, $uid);
|
$session = $this->table->fetch($sid, $ip, $uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($session) || $session['uid'] != $uid) {
|
if(empty($session) || $session['uid'] != $uid) {
|
||||||
$session = $this->create($ip, $uid);
|
$session = $this->create($ip, $uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->var = $session;
|
$this->var = $session;
|
||||||
$this->sid = $session['sid'];
|
$this->sid = $session['sid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($ip, $uid) {
|
public function create($ip, $uid) {
|
||||||
|
|
||||||
$this->isnew = true;
|
$this->isnew = true;
|
||||||
$this->var = $this->newguest;
|
$this->var = $this->newguest;
|
||||||
$this->set('sid', random(6));
|
$this->set('sid', random(6));
|
||||||
$this->set('uid', $uid);
|
$this->set('uid', $uid);
|
||||||
$this->set('ip', $ip);
|
$this->set('ip', $ip);
|
||||||
$uid && $this->set('invisible', getuserprofile('invisible'));
|
$uid && $this->set('invisible', getuserprofile('invisible'));
|
||||||
$this->set('lastactivity', time());
|
$this->set('lastactivity', time());
|
||||||
$this->sid = $this->var['sid'];
|
$this->sid = $this->var['sid'];
|
||||||
|
|
||||||
return $this->var;
|
return $this->var;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
|
|
||||||
return $this->table->delete_by_session($this->var, getglobal('setting/onlinehold'), 60);
|
return $this->table->delete_by_session($this->var, getglobal('setting/onlinehold'), 60);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update() {
|
public function update() {
|
||||||
if($this->sid !== null) {
|
if($this->sid !== null) {
|
||||||
|
|
||||||
if($this->isnew) {
|
if($this->isnew) {
|
||||||
$this->delete();
|
$this->delete();
|
||||||
$this->table->insert($this->var, false, false, true);
|
$this->table->insert($this->var, false, false, true);
|
||||||
} else {
|
} else {
|
||||||
$this->table->update($this->var['sid'], $this->var);
|
$this->table->update($this->var['sid'], $this->var);
|
||||||
$this->table->delete_by_session($this->newguest, getglobal('setting/onlinehold'), 60);
|
$this->table->delete_by_session($this->newguest, getglobal('setting/onlinehold'), 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
setglobal('sessoin', $this->var);
|
setglobal('sessoin', $this->var);
|
||||||
dsetcookie('sid', $this->sid, 86400);
|
dsetcookie('sid', $this->sid, 86400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count($type = 0) {
|
public function count($type = 0) {
|
||||||
return $this->table->count($type);
|
return $this->table->count($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetch_member($ismember = 0, $invisible = 0, $start = 0, $limit = 0) {
|
public function fetch_member($ismember = 0, $invisible = 0, $start = 0, $limit = 0) {
|
||||||
return $this->table->fetch_member($ismember, $invisible, $start, $limit);
|
return $this->table->fetch_member($ismember, $invisible, $start, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count_invisible($type = 1) {
|
public function count_invisible($type = 1) {
|
||||||
return $this->table->count_invisible($type);
|
return $this->table->count_invisible($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update_by_ipban($ip1, $ip2, $ip3, $ip4) {
|
public function update_by_ipban($ip1, $ip2, $ip3, $ip4) {
|
||||||
return $this->table->update_by_ipban($ip1, $ip2, $ip3, $ip4);
|
return $this->table->update_by_ipban($ip1, $ip2, $ip3, $ip4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update_max_rows($max_rows) {
|
public function update_max_rows($max_rows) {
|
||||||
return $this->table->update_max_rows($max_rows);
|
return $this->table->update_max_rows($max_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clear() {
|
public function clear() {
|
||||||
return $this->table->clear();
|
return $this->table->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function fetch_by_uid($uid) {
|
public function fetch_by_uid($uid) {
|
||||||
return $this->table->fetch_by_uid($uid);
|
return $this->table->fetch_by_uid($uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetch_all_by_uid($uids, $start = 0, $limit = 0) {
|
public function fetch_all_by_uid($uids, $start = 0, $limit = 0) {
|
||||||
return $this->table->fetch_all_by_uid($uids, $start, $limit);
|
return $this->table->fetch_all_by_uid($uids, $start, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update_by_uid($uid, $data) {
|
public function update_by_uid($uid, $data) {
|
||||||
return $this->table->update_by_uid($uid, $data);
|
return $this->table->update_by_uid($uid, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function count_by_ip($ip) {
|
public function count_by_ip($ip) {
|
||||||
return $this->table->count_by_ip($ip);
|
return $this->table->count_by_ip($ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetch_all_by_ip($ip, $start = 0, $limit = 0) {
|
public function fetch_all_by_ip($ip, $start = 0, $limit = 0) {
|
||||||
return $this->table->fetch_all_by_ip($ip, $start, $limit);
|
return $this->table->fetch_all_by_ip($ip, $start, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updatesession() {
|
public static function updatesession() {
|
||||||
C::app()->session->update();
|
C::app()->session->update();
|
||||||
return true;
|
return true;
|
||||||
static $updated = false;
|
static $updated = false;
|
||||||
if(!$updated) {
|
if(!$updated) {
|
||||||
global $_G;
|
global $_G;
|
||||||
if($_G['uid']) {
|
if($_G['uid']) {
|
||||||
if($_G['cookie']['ulastactivity']) {
|
if($_G['cookie']['ulastactivity']) {
|
||||||
$ulastactivity = authcode($_G['cookie']['ulastactivity'], 'DECODE');
|
$ulastactivity = authcode($_G['cookie']['ulastactivity'], 'DECODE');
|
||||||
} else {
|
} else {
|
||||||
$ulastactivity = getuserprofile('lastactivity');
|
$ulastactivity = getuserprofile('lastactivity');
|
||||||
dsetcookie('ulastactivity', authcode($ulastactivity, 'ENCODE'), 31536000);
|
dsetcookie('ulastactivity', authcode($ulastactivity, 'ENCODE'), 31536000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$oltimespan = $_G['setting']['oltimespan'];
|
$oltimespan = $_G['setting']['oltimespan'];
|
||||||
$lastolupdate = C::app()->session->var['lastolupdate'];
|
$lastolupdate = C::app()->session->var['lastolupdate'];
|
||||||
if($_G['uid'] && $oltimespan && TIMESTAMP - ($lastolupdate ? $lastolupdate : $ulastactivity) > $oltimespan * 60) {
|
if($_G['uid'] && $oltimespan && TIMESTAMP - ($lastolupdate ? $lastolupdate : $ulastactivity) > $oltimespan * 60) {
|
||||||
$isinsert = false;
|
$isinsert = false;
|
||||||
if(C::app()->session->isnew) {
|
if(C::app()->session->isnew) {
|
||||||
$oldata = C::t('onlinetime')->fetch($_G['uid']);
|
$oldata = C::t('onlinetime')->fetch($_G['uid']);
|
||||||
if(empty($oldata)) {
|
if(empty($oldata)) {
|
||||||
$isinsert = true;
|
$isinsert = true;
|
||||||
} else if(TIMESTAMP - $oldata['lastupdate'] > $oltimespan * 60) {
|
} else if(TIMESTAMP - $oldata['lastupdate'] > $oltimespan * 60) {
|
||||||
C::t('onlinetime')->update_onlinetime($_G['uid'], $oltimespan, $oltimespan, TIMESTAMP);
|
C::t('onlinetime')->update_onlinetime($_G['uid'], $oltimespan, $oltimespan, TIMESTAMP);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$isinsert = !C::t('onlinetime')->update_onlinetime($_G['uid'], $oltimespan, $oltimespan, TIMESTAMP);
|
$isinsert = !C::t('onlinetime')->update_onlinetime($_G['uid'], $oltimespan, $oltimespan, TIMESTAMP);
|
||||||
}
|
}
|
||||||
if($isinsert) {
|
if($isinsert) {
|
||||||
C::t('onlinetime')->insert(array(
|
C::t('onlinetime')->insert(array(
|
||||||
'uid' => $_G['uid'],
|
'uid' => $_G['uid'],
|
||||||
'thismonth' => $oltimespan,
|
'thismonth' => $oltimespan,
|
||||||
'total' => $oltimespan,
|
'total' => $oltimespan,
|
||||||
'lastupdate' => TIMESTAMP,
|
'lastupdate' => TIMESTAMP,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
C::app()->session->set('lastolupdate', TIMESTAMP);
|
C::app()->session->set('lastolupdate', TIMESTAMP);
|
||||||
}
|
}
|
||||||
foreach(C::app()->session->var as $k => $v) {
|
foreach(C::app()->session->var as $k => $v) {
|
||||||
if(isset($_G['member'][$k]) && $k != 'lastactivity') {
|
if(isset($_G['member'][$k]) && $k != 'lastactivity') {
|
||||||
C::app()->session->set($k, $_G['member'][$k]);
|
C::app()->session->set($k, $_G['member'][$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isset($_G['action'])){
|
if(isset($_G['action'])){
|
||||||
foreach($_G['action'] as $k => $v) {
|
foreach($_G['action'] as $k => $v) {
|
||||||
C::app()->session->set($k, $v);
|
C::app()->session->set($k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
C::app()->session->update();
|
C::app()->session->update();
|
||||||
|
|
||||||
if($_G['uid'] && TIMESTAMP - $ulastactivity > 21600) {
|
if($_G['uid'] && TIMESTAMP - $ulastactivity > 21600) {
|
||||||
if($oltimespan && TIMESTAMP - $ulastactivity > 43200) {
|
if($oltimespan && TIMESTAMP - $ulastactivity > 43200) {
|
||||||
$onlinetime = C::t('onlinetime')->fetch($_G['uid']);
|
$onlinetime = C::t('onlinetime')->fetch($_G['uid']);
|
||||||
//C::t('user_count')->update($_G['uid'], array('oltime' => round(intval($onlinetime['total']) / 60)));
|
//C::t('user_count')->update($_G['uid'], array('oltime' => round(intval($onlinetime['total']) / 60)));
|
||||||
}
|
}
|
||||||
dsetcookie('ulastactivity', authcode(TIMESTAMP, 'ENCODE'), 31536000);
|
dsetcookie('ulastactivity', authcode(TIMESTAMP, 'ENCODE'), 31536000);
|
||||||
C::t('user_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastactivity' => TIMESTAMP, 'lastvisit' => TIMESTAMP));
|
C::t('user_status')->update($_G['uid'], array('lastip' => $_G['clientip'], 'lastactivity' => TIMESTAMP, 'lastvisit' => TIMESTAMP));
|
||||||
}
|
}
|
||||||
$updated = true;
|
$updated = true;
|
||||||
}
|
}
|
||||||
return $updated;
|
return $updated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user