昨天拿到了Z-BLOG PHP1.4beta版本,已经在本站安装实现,除了大量的代码优化、界面优化、备注完善之外,值得一看的变更内容整理如下。
login.php中增加了
$zbp->CheckGzip();
以完善页面gzip检测。
cmd.php中大量增加了
$zbp->SaveCache();
以提高缓存特性。
c_system_admin.php中,原系统管理菜单挂接到$zbp->loadmanage,以下内容移动:
Add_Filter_Plugin('Filter_Plugin_Admin_PageMng_SubMenu','Zbp_Admin_Addpagesubmenu');
Add_Filter_Plugin('Filter_Plugin_Admin_TagMng_SubMenu','Zbp_Admin_Addtagsubmenu');
Add_Filter_Plugin('Filter_Plugin_Admin_CategoryMng_SubMenu','Zbp_Admin_Addcatesubmenu');
Add_Filter_Plugin('Filter_Plugin_Admin_MemberMng_SubMenu','Zbp_Admin_Addmemsubmenu');
Add_Filter_Plugin('Filter_Plugin_Admin_ModuleMng_SubMenu','Zbp_Admin_Addmodsubmenu');
Add_Filter_Plugin('Filter_Plugin_Admin_CommentMng_SubMenu','Zbp_Admin_Addcmtsubmenu');后台增加大数据管理支持接口,并抽风般的把一个代码写的让人看了发疯:
$s='';
$or=array('log_PostTime'=>'DESC');
$l=array(($p->PageNow-1) * $p->PageCount,$p->PageCount);
$op=array('pagebar'=>$p);
foreach ($GLOBALS['Filter_Plugin_LargeData_Aritcle'] as $fpname => &$fpsignal) {
$fpreturn = $fpname($s,$w,$or,$l,$op);
}
$array=$zbp->GetArticleList(
$s,
$w,
$or,
$l,
$op,
false
);不仅是文章页,page页面管理也加入了大数据支持接口:
$s='';
$or=array('log_PostTime'=>'DESC');
$l=array(($p->PageNow-1) * $p->PageCount,$p->PageCount);
$op=array('pagebar'=>$p);
foreach ($GLOBALS['Filter_Plugin_LargeData_Page'] as $fpname => &$fpsignal) {
$fpreturn = $fpname($s,$w,$or,$l,$op);
}
$array=$zbp->GetPageList(
$s,
$w,
$or,
$l,
$op
);评论管理处同上:
$s='';
$or=array('comm_ID'=>'DESC');
$l=array(($p->PageNow-1) * $p->PageCount,$p->PageCount);
$op=array('pagebar'=>$p);
foreach ($GLOBALS['Filter_Plugin_LargeData_Comment'] as $fpname => &$fpsignal) {
$fpreturn = $fpname($s,$w,$or,$l,$op);
}
$array=$zbp->GetCommentList(
$s,
$w,
$or,
$l,
$op
);创始人,或者用户ID最小的一个管理员,将不再被允许删除:
if($member->IsGod!==true){
echo ' ';
echo '<a onclick="return window.confirm(\''.$zbp->lang['msg']['confirm_operating'] .'\');" href="../cmd.php?act=MemberDel&id='. $member->ID .'&token='. $zbp->GetToken() .'"><img src="../image/admin/delete.png" alt="'.$zbp->lang['msg']['del'] .'" title="'.$zbp->lang['msg']['del'] .'" width="16" /></a>';
}插件/主题管理页面的提示插入方法有变化(更新)
echo '<script type="text/javascript">ActiveLeftMenu("aPluginMng");';
echo 'AddHeaderIcon("'. $zbp->host . 'zb_system/image/common/plugin_32.png' . '");$(".plugin-note").tooltip();</script>';c_system_base.php中:
Config表增加ID主键,妈妈再也不用担心pma不能编辑啦。
'Config'=>array(
'ID'=>array('conf_ID','integer','',0),
'Name'=>array('conf_Name','string',50,''),
'Value'=>array('conf_Value','string','',''),
),c_system_common.php,加了一大堆define,新增了几个小函数,方便使用啦~
/**
* Operation System
*/
define('IS_WINDOWS', in_array(strtoupper(PHP_OS), array('WINNT', 'WIN32', 'WINDOWS')));
define('IS_UNIX', (strtoupper(PHP_OS) === 'UNIX'));
define('IS_LINUX', (strtoupper(PHP_OS) === 'LINUX'));
define('IS_DARWIN', (strtoupper(PHP_OS) === 'DARWIN'));
define('IS_CYGWIN', (strtoupper(substr(PHP_OS, 0, 6)) === 'CYGWIN'));
define('IS_BSD', in_array(strtoupper(PHP_OS), array('NETBSD', 'OPENBSD', 'FREEBSD')));
/**
* Web Server
*/
define('IS_APACHE', preg_match("/apache/i", $_SERVER['SERVER_SOFTWARE']));
define('IS_IIS', preg_match("/microsoft-iis/i", $_SERVER['SERVER_SOFTWARE']));
define('IS_NGINX', preg_match("/nginx/i", $_SERVER['SERVER_SOFTWARE']));
define('IS_LIGHTTPD', preg_match("/lighttpd/i", $_SERVER['SERVER_SOFTWARE']));
define('IS_KANGLE', preg_match("/kangle/i", $_SERVER['SERVER_SOFTWARE']));
/**
* 自动加载类文件
* @api Filter_Plugin_Autoload
* @param string $classname 类名
* @return mixed
*/
function AutoloadClass($classname){
foreach ($GLOBALS['Filter_Plugin_Autoload'] as $fpname => &$fpsignal) {
$fpreturn=$fpname($classname);
if ($fpsignal==PLUGIN_EXITSIGNAL_RETURN) {$fpsignal=PLUGIN_EXITSIGNAL_NONE;return $fpreturn;}
}
if (is_readable($f=ZBP_PATH . 'zb_system/function/lib/' . strtolower($classname) .'.php'))
require $f;
}
/**
* 记录日志
* @param string $s
* @param bool $iserror
*/
function Logs($s,$iserror=false) {
global $zbp;
foreach ($GLOBALS['Filter_Plugin_Logs'] as $fpname => &$fpsignal) {
$fpreturn=$fpname($s,$iserror);
if ($fpsignal==PLUGIN_EXITSIGNAL_RETURN) {$fpsignal=PLUGIN_EXITSIGNAL_NONE;return $fpreturn;}
}
if($zbp->guid){
if($iserror)
$f = $zbp->usersdir . 'logs/' . $zbp->guid . '-error' . date("Ymd") . '.txt';
else
$f = $zbp->usersdir . 'logs/' . $zbp->guid . '-log' . date("Ymd") . '.txt';
}else{
if($iserror)
$f = $zbp->usersdir . 'logs/' . md5($zbp->path) . '-error.txt';
else
$f = $zbp->usersdir . 'logs/' . md5($zbp->path) . '.txt';
}
ZBlogException::SuspendErrorHook();
if($handle = @fopen($f, 'a+')){
$t=date('Y-m-d') . ' ' . date('H:i:s') . ' ' . substr(microtime(),1,9) . ' ' . date('P');
@fwrite($handle, '[' . $t . ']' . "\r\n" . $s . "\r\n");
@fclose($handle);
}
ZBlogException::ResumeErrorHook();
}
/**
* 页面运行时长
* @return array
*/
function RunTime() {
global $zbp;
$rt=array();
$rt['time']=number_format(1000 * (microtime(1) - $_SERVER['_start_time']), 2);
$rt['query']=$_SERVER['_query_count'];
$rt['memory']=$_SERVER['_memory_usage'];
$rt['error']=$_SERVER['_error_count'];
if(function_exists('memory_get_usage')){
$rt['memory']=(int)((memory_get_usage()-$_SERVER['_memory_usage'])/1024);
}
if(isset($zbp->option['ZC_RUNINFO_DISPLAY'])&&$zbp->option['ZC_RUNINFO_DISPLAY']==false){
$_SERVER['_runtime_result']=$rt;
return $rt;
}
echo '<!--' . $rt['time'] . 'ms , ';
echo $rt['query'] . ' query';
if(function_exists('memory_get_usage'))
echo ' , ' . $rt['memory'] . 'kb memory';
echo ' , ' . $rt['error'] . ' error';
echo '-->';
return $rt;
}
/**
* 获得系统信息
* @return string 系统信息
* @since 1.4
*/
function GetEnvironment(){
global $zbp;
$ajax = Network::Create();
if ($ajax) $ajax = substr(get_class($ajax), 7);
$system_environment = PHP_OS . '; ' .
GetValueInArray(
explode(' ',str_replace(array('Microsoft-','/'), array('',''), GetVars('SERVER_SOFTWARE', 'SERVER'))), 0
) . '; ' .
'PHP ' . phpversion() . '; ' . $zbp->option['ZC_DATABASE_TYPE'] . '; ' . $ajax ;
return $system_environment;
}
/**
* 通过文件获取应用URL地址
* @param string $file 文件名
* @return string 返回URL地址
*/
function plugin_dir_url($file) {
global $zbp;
$s1=$zbp->path;
$s2=str_replace('\\','/',dirname($file).'/');
$s3='';
$s=substr($s2,strspn($s1,$s2,0));
if(strpos($s,'zb_users/plugin/')!==false){
$s=substr($s,strspn($s,$s3='zb_users/plugin/',0));
}else{
$s=substr($s,strspn($s,$s3='zb_users/theme/',0));
}
$a=explode('/',$s);
$s=$a[0];
$s=$zbp->host . $s3 . $s . '/';
return $s;
}
/**
* 通过文件获取应用目录路径
* @param $file
* @return string
*/
function plugin_dir_path($file) {
global $zbp;
$s1=$zbp->path;
$s2=str_replace('\\','/',dirname($file).'/');
$s3='';
$s=substr($s2,strspn($s1,$s2,0));
if(strpos($s,'zb_users/plugin/')!==false){
$s=substr($s,strspn($s,$s3='zb_users/plugin/',0));
}else{
$s=substr($s,strspn($s,$s3='zb_users/theme/',0));
}
$a=explode('/',$s);
$s=$a[0];
$s=$zbp->path . $s3 . $s . '/';
return $s;
}完善了SetHttpStatusCode($number)函数---太长,自己看源码去。
完善了CheckRegExp($source, $para) 函数... 其实是洁癖使然。
增加了一个修正错误名字的函数
/**
* 对数组内的字符串进行htmlspecialchars
* @param array $array 待过滤字符串
* @return array
* @since 1.4
*/
function htmlspecialchars_array($array) {
foreach ($array as $key => &$value) {
if (is_array($value)) {
$value = htmlspecialchars_array($value);
}
else if (is_string($value)) {
$value = htmlspecialchars($value);
}
}
return $array;
}修改debug错误处理接口
//原代码
foreach ($GLOBALS['Filter_Plugin_Debug_Shutdown_Handler'] as $fpname => &$fpsignal) {
$fpreturn=$fpname();
}
//改为
foreach ($GLOBALS['Filter_Plugin_Debug_Handler'] as $fpname => &$fpsignal) {
$fpreturn=$fpname('Exception',$exception);
}验证登录函数VerifyLogin删除了
if (isset($zbp->membersbyname[GetVars('username', 'POST')]))目测这个版本删掉了这个数组。
完善了文章置顶的处理规则,具体需要使用一下才知道到底是什么样。
if($zbp->option['ZC_LISTONTOP_TURNOFF']==false){
$articles_top_notorder=$zbp->GetTopArticle();
foreach($articles_top_notorder as $articles_top_notorder_post)
if($articles_top_notorder_post->TopType == 'global')
$articles_top[]=$articles_top_notorder_post;
if ($type == 'index' && $page == 1)
foreach($articles_top_notorder as $articles_top_notorder_post)
if($articles_top_notorder_post->TopType == 'index')
$articles_top[]=$articles_top_notorder_post;
if ($type == 'category')
foreach($articles_top_notorder as $articles_top_notorder_post)
if($articles_top_notorder_post->TopType == 'category' && $articles_top_notorder_post->CateID == $category->ID)
$articles_top[]=$articles_top_notorder_post;
}后面不写哪个文件了,大家看看就好。
修复移动分类后RootID不更新的问题。
//刷新RootID $cate->Level;
新建用户如果与已有用户同名,则提示:
if (isset($_POST['Name'])) {
//zbp自带数据检测同名
if (isset($zbp->membersbyname[$_POST['Name']])) {
if ($zbp->membersbyname[$_POST['Name']]->ID <> $_POST['ID']) {
$zbp->ShowError(62, __FILE__, __LINE__);
}
}
}文章提交时过滤文章标题:
$article->Title = htmlspecialchars($article->Title);
用户别名不再允许250个字符。新的是50个。
$member->Alias = substr($member->Alias, 0, (int)$zbp->datainfo['Member']['Alias'][2]);
后台指定字体,由语言包决定:
/**
* 输出后台指定字体family(内置插件函数)
*/
function Include_AddonFontfamily(){
global $zbp;
if(isset($zbp->lang['font-family'])&&trim($zbp->lang['font-family']))
echo'<style type="text/css">body{font-family:'.$zbp->lang['font-family'].'!important;}</style>';
}c_system_misc.php,管理员增加phpinfo选项。
case 'phpinfo':
if (!$zbp->CheckRights('root')) {
echo $zbp->ShowError(6, __FILE__, __LINE__);
die();
}
phpinfo();
break;增加接口
foreach ($GLOBALS['Filter_Plugin_Misc_Begin'] as $fpname => &$fpsignal) {$fpname($type);}模块编辑增加接口
/*
'**************************************************<
'类型:Filter
'名称:Filter_Plugin_Module_Edit_Response
'参数:
'说明:模块编辑页输出接口
'调用:
'**************************************************>
*/
DefinePluginFilter('Filter_Plugin_Module_Edit_Response');
/*
'**************************************************<大数据:文章、页面、评论、标签,独立的GetList。
app.php,应用打包之前,先去除BOM
$ext=pathinfo($value,PATHINFO_EXTENSION);
if($ext=='php'||$ext=='inc'){
$c=base64_encode(RemoveBOM(file_get_contents($value)));
}else{
$c=base64_encode(file_get_contents($value));
}支持打包为gzip格式。
public function PackGZip(){
return gzencode($this->Pack(),9,FORCE_GZIP);
}增加config类。
增加pdo_SQLite数据库操作类。
$zbp->GetList改名为$zbp->GetListType
function GetList($type,$sql){
$this->SetHint('tips','$zbp->GetList()已改名为GetListType(),下个版本将会取消,请在相关源码中改用新名称.');
return $this->GetListType($type,$sql);
}dbsql修复了大量问题.
应用支持语言包:
/**
* 载入指定应用语言包
* @param string $type 应用类型(theme|plugin)
* @param string $id 应用ID
* @return App
*/
public function LoadAppLanguage($type,$id,$default='SimpChinese'){
if(is_readable($f=$this->path . 'zb_users/'.$type.'/'.$id.'/language/' . $this->option['ZC_BLOG_LANGUAGEPACK'] . '.php'))
$this->lang[$id] = require($f);
elseif(is_readable($f=$this->path . 'zb_users/'.$type.'/'.$id.'/language/' . $default . '.php'))
$this->lang[$id] = require($f);
elseif(is_readable($f=$this->path . 'zb_users/'.$type&'/'.$id.'/language/' . 'English'. '.php'))
$this->lang[$id] = require($f);
}更多功能? 等1.4正式发布之后,自己装一个试试吧。
转载请注明:鸟儿博客 » ZBLOG PHP1.4版本主要变更内容一览