dedecms 负载性能优化实例,三招让你的dede快10倍以上

Filed under: PHP研究, dedecms专栏, 数据库技术 | 2 Comments »
Posted on

        助易网测评小组曾在08年4月对国内主流php类cms做了负载测评,参考我们的测评文章http://www.cmshelp.com.cn/cms/cms2008.htm,其中对dedecms表现出来的相对较差的性能也感觉比较迷惑,到底是什么在制约其负载效率?难道真的是某些脑残的dede论坛版主说的是因为mysql不堪重负的原因吗?还是因为一个表的大数据造成性能严重下降?难道我们必须通过分多个表来存储才能解决问题吗?以下我们通过一个实例来解析和优化dedecms的数据管理性能,千万别让mysql当替罪羊,罪莫大焉。

        欢迎转载本文,转载请注明本文出自助易网(http://www.cmshelp.com.cn)。

        测试数据是无意中得到的企业黄页的数据,数据量将近90万,都是完全真实的数据,测试使用的程序是dedecms4.0版本,你问为什么不用dedecms5.1?那是因为我们为了优化,针对dedecms做了很多修改,如果使用dedecms5.1,我们害怕收到法院传票……,补充一句,以下的优化方法均能在dedecms5.1中使用,请在理解其原理的基础上自行完成。

        未优化前我们测试发现主要有三个经常性的操作在dede大数据量的情况下影响管理性能,分别是文档生成、列表页生成和栏目列出所有文章,我们就针对这三个方面进行优化实践。

        欢迎转载本文,转载请注明本文出肥龙龙博客(http://www.blog-dragon.com/)。

        以下是测试数据的基本信息:

optimize-dede1.jpg

文档数量接近90万

阅读全文 »

Tags : , , ,

2008年最佳开源cms评选最终入围名单

Filed under: 开源研究 | 2 Comments »
Posted on

2008 Open Source CMS Award Finalists Announced

As usual, judging comes from a panel of experienced and respected figures from the Content Management and Open Source industry. They will be selecting their top three based on a number of factors including performance, usability, accessibility, ease of configuration and customization, scalability and security.

The final judge is made up of votes from customers and visitors to www.PacktPub.com. You have the chance to support your favourite CMS by submitting a vote when the final five are announced.

Voting will begin on September 1, to view more information about each finalist, please click below:

评选投票从9月1日开始。赶快选择你喜欢的开源cms吧。 阅读全文 »

助易网(www.cmshelp.com.cn)新站改版上线,欢迎访问

Filed under: 本站通告 | 1 Comment »
Posted on

前些日子动用了一下自己的设计功力,把助易网改版了,欢迎大家批评访问。

地址:http://www.cmshelp.com.cn

放一个截图,抢先预览:
助易网首页截图

整站使用supesite搭建。

dedecms5.1升级sp1出现IfTagNull()错误解决方法记录

Filed under: dedecms专栏 | No Comments »
Posted on

最近有报告错误说从dedecms5.1升级sp1出现错误,代码大致如下:
Fatal error: Call to undefined function IfTagNull() in /……/include/pub_dedetag.php(485) : eval()’d code on line 1
分析错误原因,是因为模板中调用了IfTagNull函数而程序中找不到这个函数导致出错,解决的办法很简单,两种,这里记录一下:
1、修改article_article.htm模板,把{dede:tag type=’current’ function=’IfTagNull(@me)’/} 换回原来的{dede:tag type=’current’ /}
2、修改include目录下的inc_functions.php文件,加入代码如下:

//这个函数根据自己需要进行修改
function IfTagNull($tag){
 
//这里直接输出了Tag:自行修改
 
if(!$tag=="")  $tag="Tag:".$tag;
 
return $tag;
}
Tags : , ,

SupeSite模块代码常见参数含义【转】

Filed under: PHP研究 | No Comments »
Posted on

在此为大家介绍模块代码里常见几个参数的含义,如果有其他的参数您不清楚什么含义的,可以跟帖询问,或者在SS安装使用区发帖询问。

order——————————以什么方式排序,常见的排序方式如下几种:
        displayorder————–以后台设置的显示顺序排序
        views DESC—————-以查看数递减的方式排序
        replies DESC————–以回复数递减的方式排序
        posts DESC—————-以帖子数递减的方式排序
        m.posts DESC————–以会员贴子数递减的方式排序
        m.oltime DESC————-以会员在线时间递减的方式排序
        u.dateline DESC———–以会员注册时间递减的方式排序
        i.goodrate DESC———–以信息好评数递减的方式排序
        u.spaceallnum DESC——–以会员个人空间的信息总数递减排序
        u.spaceblognum DESC——-以会员个人空间的日志总数递减排序
        g.usernum DESC————以圈子会员数递减的方式排序
        g.lastpost DESC———–以圈子最后更新时间递减的方式排序
limit——————————显示多少条信息
        0,100———————显示100条
dateline—————————发布时间范围,以秒(s)为单位
        2592000——————-2592000秒,即:3天
showdetail————————-是否显示信息摘要
        1————————-1为显示(0为不显示)
messagelen————————-摘要显示的长度,以字节数为单位
        160———————–显示160个字节信息
subjectlen————————-主题的显示长度,以字节数为单位
        40————————显示40个字节信息
type——————————-设置信息的类型
        forum———————二级版块的信息
        goods———————商品的信息
        news———————-资讯的信息
        video———————影音的信息
filetype—————————设置附件的类型
        image———————图片附件
lastpost—————————最后回复时间范围,以秒(s)为单位
        2592000——————-2592000秒,即:3天
subjectdot————————-显示主题时,如果主题长度大于显示长度,末尾是否加点
        1————————-末尾加点(0为末尾不加点)
messagedot————————-显示摘要时,如果摘要长度大于显示长度,末尾是否加点
        1————————-末尾加点(0为末尾不加点)
showattach————————-是否显示附件信息
        1————————-显示附件信息
haveattach————————-是否必须包含附件
        1————————-必须包含附件
isstar—————————–空间之星
        1————————-是
perpage—————————-每页显示的信息条数
        15————————显示15条
regdate—————————-注册时间范围,以秒(s)为单位
        2592000——————-2592000秒,即:3天

给大家一个技巧:一般可以通过英文意思来判断参数的含义,例如subjectlen,是subject length,即:主题长度。

Tags : , ,

dedecms中实现列表页面调用其它栏目的信息

Filed under: dedecms专栏 | No Comments »
Posted on

群里有人问如何在dedecms中实现列表页面调用不同栏目的文章信息,以下给出解决方法,针对dedecms4.0。

首先,为dedecma增加一个标签的属性,我修改的标签为【List 标记】增加属性addonid,使用方法为:

addonid= ‘调用的栏目编号’,不同的栏目请用半角“,”的分隔,这些栏目必须是最终列表栏目,同时不必在这个栏目编号中增加本栏目的编号。

例子:{dede:list pagesize=’2′ addonid=’1,2′} {/dede:list}

继续修改include/inc_arclist_view.php,这个比较麻烦,不会的话,直接拷贝粘贴。

第一步,新增$addonid变量,如下:

class ListView
{
 var $dsql;
 var $dtp;
 var $dtp2;
 var $TypeID;
 var $TypeLink;
 var $PageNo;
 var $TotalPage;
 var $TotalResult;
 var $PageSize;
 var $ChannelUnit;
 var $ListType;
 var $Fields;
 var $PartView;
 var $StartTime;
 var $addonid; //这里为新增的变量

……

第二步:获得模板中的addonid的值,并且统计文章总数,修改function CountRecord()函数:

原本代码为:

  //——————
  //统计列表里的记录
  //——————
  function CountRecord()
  {
   global $cfg_list_son;
   //统计数据库记录
   $this->TotalResult = -1;
   if(isset($GLOBALS[’TotalResult’])) $this->TotalResult = $GLOBALS[’TotalResult’];
   if(isset($GLOBALS[’PageNo’])) $this->PageNo = $GLOBALS[’PageNo’];
   else $this->PageNo = 1;
   
   if($this->TotalResult==-1)
   {
     $addSql  = ” arcrank > -1 “;
    
     if($cfg_list_son==’否’) $addSql .= ” And (typeid=’”.$this->TypeID.”‘ or typeid2=’”.$this->TypeID.”‘) “;
     else $addSql .= ” And (”.$this->TypeLink->GetSunID($this->TypeID,”#@__archives”,$this->Fields[’channeltype’]).” Or #@__archives.typeid2=’”.$this->TypeID.”‘) “;
    
     if($this->StartTime>0) $addSql .= ” And senddate>’”.$this->StartTime.”‘”;
     $cquery = “Select count(*) as dd From #@__archives where $addSql”;
    $row = $this->dsql->GetOne($cquery);
    if(is_array($row)) $this->TotalResult = $row[’dd’];
    else $this->TotalResult = 0;
   }
   
   //初始化列表模板,并统计页面总数
   $tempfile = $GLOBALS[’cfg_basedir’].$GLOBALS[’cfg_templets_dir’].”/”.$this->TypeLink->TypeInfos[’templist’];
   $tempfile = str_replace(”{tid}”,$this->TypeID,$tempfile);
   $tempfile = str_replace(”{cid}”,$this->ChannelUnit->ChannelInfos[’nid’],$tempfile);
   if(!file_exists($tempfile)){
       $tempfile = $GLOBALS[’cfg_basedir’].$GLOBALS[’cfg_templets_dir’].”/”.$GLOBALS[’cfg_df_style’].”/list_default.htm”;
    }
   if(!file_exists($tempfile)||!is_file($tempfile)){
    echo “模板文件:’”.$tempfile.”‘ 不存在,无法解析文档!”;
    exit();
   }
   $this->dtp->LoadTemplate($tempfile);
   $ctag = $this->dtp->GetTag(”page”);
   if(!is_object($ctag)){ $ctag = $this->dtp->GetTag(”list”); }
   if(!is_object($ctag)) $this->PageSize = 20;
   else{
     if($ctag->GetAtt(”pagesize”)!=”") $this->PageSize = $ctag->GetAtt(”pagesize”);
      else $this->PageSize = 20;
    }
    $this->TotalPage = ceil($this->TotalResult/$this->PageSize);
  }

修改为:

  //——————
  //统计列表里的记录
  //——————
  function CountRecord()
  {
   global $cfg_list_son;
  
   //初始化列表模板,并统计页面总数
   $tempfile = $GLOBALS[’cfg_basedir’].$GLOBALS[’cfg_templets_dir’].”/”.$this->TypeLink->TypeInfos[’templist’];
   $tempfile = str_replace(”{tid}”,$this->TypeID,$tempfile);
   $tempfile = str_replace(”{cid}”,$this->ChannelUnit->ChannelInfos[’nid’],$tempfile);
   if(!file_exists($tempfile)){
       $tempfile = $GLOBALS[’cfg_basedir’].$GLOBALS[’cfg_templets_dir’].”/”.$GLOBALS[’cfg_df_style’].”/list_default.htm”;
    }
   if(!file_exists($tempfile)||!is_file($tempfile)){
    echo “模板文件:’”.$tempfile.”‘ 不存在,无法解析文档!”;
    exit();
   }
   $this->dtp->LoadTemplate($tempfile);
   $ctag = $this->dtp->GetTag(”page”);
   if(!is_object($ctag)){ $ctag = $this->dtp->GetTag(”list”); }  
  if($ctag->GetAtt(”addonid”)!=”") $this->addonid = $ctag->GetAtt(”addonid”);
   if(!is_object($ctag)) $this->PageSize = 20;
   else{
     if($ctag->GetAtt(”pagesize”)!=”") {
     $this->PageSize = $ctag->GetAtt(”pagesize”);
   }
      else $this->PageSize = 20;
    }
 
   //统计数据库记录
   $this->TotalResult = -1;
   if(isset($GLOBALS[’TotalResult’])) $this->TotalResult = $GLOBALS[’TotalResult’];
   if(isset($GLOBALS[’PageNo’])) $this->PageNo = $GLOBALS[’PageNo’];
   else $this->PageNo = 1;
   
   if($this->TotalResult==-1)
   {
     $addSql  = ” arcrank > -1 “;
    
  if($this->addonid!=”") $isaddon = ” Or #@__archives.typeid in (”.$this->addonid.”)”;
  else $isaddon = “”;
    
     if($cfg_list_son==’否’) $addSql .= ” And (typeid=’”.$this->TypeID.”‘ or typeid2=’”.$this->TypeID.”‘ “.$isaddon.”) “;
     else $addSql .= ” And (”.$this->TypeLink->GetSunID($this->TypeID,”#@__archives”,$this->Fields[’channeltype’]).” Or #@__archives.typeid2=’”.$this->TypeID.”‘ “.$isaddon.”) “;

    
     if($this->StartTime>0) $addSql .= ” And senddate>’”.$this->StartTime.”‘”;
     $cquery = “Select count(*) as dd From #@__archives where $addSql”;
    $row = $this->dsql->GetOne($cquery);
    if(is_array($row)) $this->TotalResult = $row[’dd’];
    else $this->TotalResult = 0;
   }
 
    $this->TotalPage = ceil($this->TotalResult/$this->PageSize);
  }

说明,首先把统计数据库记录这部分代码后移,目的是为了利用获得的属性参数addonid,接着通过$this->addonid = $ctag->GetAtt(”addonid”);获得模板中的addonid的值,然后生成新的统计数据库的sql语句。

第三步,修改function GetArcList()函数,显示文档列表。

原文件为(代码片断):

  if($cfg_list_son==’否’) $orwhere .= ” And (arc.typeid=’”.$this->TypeID.”‘ or arc.typeid2=’”.$this->TypeID.”‘) “;
  else $orwhere .= ” And (”.$this->TypeLink->GetSunID($this->TypeID,”arc”,$this->Fields[’channeltype’]).” Or arc.typeid2=’”.$this->TypeID.”‘) “;

修改为:

  if($this->addonid!=”") $isaddon = ” Or arc.typeid in (”.$this->addonid.”)”;
  else $isaddon = “”;
  if($cfg_list_son==’否’) $orwhere .= ” And (arc.typeid=’”.$this->TypeID.”‘ or arc.typeid2=’”.$this->TypeID.”‘ “.$isaddon.”) “;
  else $orwhere .= ” And (”.$this->TypeLink->GetSunID($this->TypeID,”arc”,$this->Fields[’channeltype’]).” Or arc.typeid2=’”.$this->TypeID.”‘ “.$isaddon.”) “;

到此就可以实现列表页面调用其它栏目的信息。有问题的话Q我。

Tags : , ,
Page 1 of 3123»