查看 Web应用 栏目文章
八月
1

[Hack]让article模组显示的文章打印功能和RSS输出功能使用站点Logo

Author Dominic    Category XOOPS     Tags , ,

article模组中显示的文章的时候下面的工具箱中的打印功能输出页面头部会打印个图片,而这个图片却是article模组xoops_version.php中配置的模块图片,打印出来实在是有些刺眼,RSS输出的地方也是这样。还是改成站点的Logo图片比较好

首先修改htdocs\modules\article\print.php文件90行处,

将原来的

$print_data["image"] = XOOPS_URL . “/modules/” . $xoopsModule->getVar(“dirname”) . “/” . $xoopsModule->getInfo( ‘image’ );

 修改成:

$print_data["image"] = XOOPS_URL . “/images/logo.jpg”;//Modified By XuYong 采用站点Logo

再修改htdocs\modules\article\xml.php 284行附近,

将原来的

“url”            => XOOPS_URL.”/modules/”.$GLOBALS["artdirname"].”/”.$xoopsModule->getInfo(“image”),

修改成:

“url”            => XOOPS_URL.”/images/logo.jpg”,

其中Logo的具体路径要根据实际情况调整。

八月
1

[Hack]解决article模组中添加文章时使用html标签导致段落换行不正确的问题

Author Dominic    Category XOOPS     Tags , ,

article模组发布文章是在编辑器下面有几个选项:“使用HTML标签”、“使用表情图”、“启用内置码”、“启用换行符(如果启用HTML标签,建议关闭) ”,一般都是选中状态(可能有配置项,但是好像默认是都选中),不明白的是为什么里面都提示“如果启用HTML标签,建议关闭”了就是不把第一个和第四个做成反选(加个Javascript控制一下就可以了),直接导致发布文章之后文章显示会换行2次,在HTML源代码中可以看到在行跟行之间出现了<BR><BR>2次,导致行与行之间多出一个br。

解决办法:编辑htdocs\modules\article\edit.article.php文件111行,

将原来的

$dobr = $article_obj->isNew() || $newpage;

改成:

//Modified By XuYong 根据 $dohtml 调整$dobr默认值
if($dohtml==0)
{
    $dobr = $article_obj->isNew() || $newpage;
}
else
{
    $dobr = 0;
}

 这样设置了“使用HTML标签”就会自动关闭“启用换行符”了。

七月
27

linux下常用查看Apache状态语句

Author Dominic    Category Web应用     Tags

收集linux下查看常用状态语句:

1、查看的并发请求数及其TCP连接状态:

netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’

返回结果一般如下:

SYN_RECV 28
CLOSE_WAIT 1
TIME_WAIT 9
ESTABLISHED 4
LAST_ACK 1
FIN_WAIT1 1

这里SYN_RECV表示正在等待处理的请求数;ESTABLISHED表示正常数据传输状态;TIME_WAIT表示处理完毕,等待超时结束的请求数。

2、查看运行进程数(prefork模式)

ps -ef | grep apache2 | wc -l

返回的数字就是进程数,如果系统中文件名是httpd则执行

ps -ef | grep httpd | wc -l

(待续)

七月
27

配置Apache2启用mod_expires模块给文件添加Expires头

Author Dominic    Category Web应用     Tags , ,

使用YSlow发现所在服务器上传输出来的文件Expires头都置为Expires: Thu, 19 Nov 1981 08:52:00 GMT了,非常奇怪的一个时间(莫非或者php某个开发人员是这个时候出生的),YSlow给出了加载expires模块的建议。

加载expires模块之后,编辑httpd.conf加入如下配置:

# enable expirations
ExpiresActive On
# expire GIF images after a day from the time they were accessed
ExpiresByType image/gif image/jpg A86400
# HTML documents are good for a hour from the  the time they were accessed
ExpiresByType text/html M3600
# expire all default from the time they were accessed
ExpiresDefault “A7200″

七月
27

配置Apache2启用deflate压缩加快传输

Author Dominic    Category Web应用     Tags ,

今天下载了Yahoo的给Firefox开发的YSlow插件,这个插件确实不错,能够给出不少优化建议,发现所在主机没有开启压缩。

首先加载mod_deflate。

在httpd.conf中加入

<Location />

# Insert filter
SetOutputFilter

# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|exe|bmp|mp3|rar|zip|swf|cab|t?gz|bz2|sit)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

</Location>

再重启即可,/etc/init.d/apache2 restart

经过port80software的在线检测,首页大小从91977 bytes压缩到13376 bytes,传输速度提高6.8X,传输速度从原来12.832 s缩减到1.866 s。

如果修改配置之后提示“Invalid command ‘Header’, perhaps mis-spelled or defined by a module not included in the server configuration”,则加载Header模块即可,不过最好还是在编译模块时直接加上–enable- –enable-headers就省事多了。

七月
26

[Hack]让Article模组子分类的文章可以加入到上级分类的专题中

Author Dominic    Category XOOPS     Tags , ,

当在article的某个分类添加了一个专题之后,目前的限制了将该分类下级分类的文章添加到这个专题中,这点限制在我看来不是很合理,作为拥有下级分类的分类,从隶属关系上讲下级分类的文章也应当属于该分类的,而且作为拥有下级分类的文章,这个分类所直接隶属的文章应当非常少,只有放到其下所有分类都不合适的时候,才放入该分类中。

修改htdocs\modules\article\cp.article.php文件212行附近,

原来为:

    unset($subCategories_obj);
    if(!empty($category_id)){
        $criteria = new CriteriaCompo(new Criteria("top_expire", time(), ">"));
        $topics_obj =& $topic_handler->getByCategory($category_id, $xoopsModuleConfig["topics_max"], 0, $criteria, array("top_title"));
        if(count($topics_obj)>0) foreach($topics_obj as $id=>$topic){
            $topics[] = array(

修改为:

    unset($subCategories_obj);
    if(!empty($category_id)){
        $criteria = new CriteriaCompo(new Criteria("top_expire", time(), ">"));
        // by XuYong 子分类的文章可以加入到上级分类的专题中
        $category_pid= 0;
        if(!empty($category_id))$category_pid = $category_obj->getVar("cat_pid");
        //        $topics_obj =& $topic_handler->getByCategory($category_id, $xoopsModuleConfig["topics_max"], 0, $criteria, array("top_title"));
                $topics_obj =& $topic_handler->getByCategory($category_pid, $xoopsModuleConfig["topics_max"], 0, $criteria, array("top_title"));
        //End 
        if(count($topics_obj)>0) foreach($topics_obj as $id=>$topic){
            $topics[] = array(
七月
26

[Hack]更改article模组输出feed时时间不对的缺陷

Author Dominic    Category XOOPS     Tags , , , ,

服务时区设置为+8,在命令行行下显示正常,中设置服务器所在时区为+0800,可article输出的feed时时间却怎么也不对,导致outlookRSS订阅中显示的文章时间也不对均为GMT+1600时区,哪有这样的时区哦,时区范围GMT-1200~GMT+1200。

修改方法如下:

1、修改htdocs\modules\article\class\feedcreator.class.php文件中739行附近FeedDate类的构造函数FeedDate如下:

   1: function FeedDate($dateString="") {
   2:     $tzOffset = 0;
   3:     if ($dateString=="") $dateString = date("r");
   4:  
   5:     //if (is_integer($dateString)) {
   6:     if (is_numeric($dateString)) {
   7:         $this->unix = $dateString;
   8:         return;
   9:     }
  10:    // By XuYong 调整日期格式
  11:     if (preg_match("~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?(\\d{1,2})\\s+([a-zA-Z]{3})\\s+(\\d{4})\\s+(\\d{2}):(\\d{2}):(\\d{2})\\s+(.*)~",$dateString,$matches)) {
  12:         $months = Array("Jan"=>1,"Feb"=>2,"Mar"=>3,"Apr"=>4,"May"=>5,"Jun"=>6,"Jul"=>7,"Aug"=>8,"Sep"=>9,"Oct"=>10,"Nov"=>11,"Dec"=>12);
  13:         $this->unix = gmmktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]);
  14:         if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
  15:             $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
  16:         } else {
  17:             if (strlen($matches[7])==1) {
  18:                 $oneHour = 3600;
  19:                 $ord = ord($matches[7]);
  20:                 if ($ord < ord("M")) {
  21:                     $tzOffset = (ord("A") - $ord - 1) * $oneHour;
  22:                 } elseif ($ord >= ord("M") AND $matches[7]!="Z") {
  23:                     $tzOffset = ($ord - ord("M")) * $oneHour;
  24:                 } elseif ($matches[7]=="Z") {
  25:                     $tzOffset = 0;
  26:                 }
  27:             }
  28:             switch ($matches[7]) {
  29:                 case "UT":
  30:                 case "GMT":    $tzOffset = 0;
  31:             }
  32:         }
  33:
  34:         $tzOffset += date("Z",0);
  35:         $this->unix += $tzOffset;
  36:  
  37:         if (TIME_ZONE!="")
  38:         {
  39:             $server_TZ = abs(intval($GLOBALS['xoopsConfig']['server_TZ'] * 3600.0));
  40:             $this->unix += ($server_TZ - date("Z", 0)) % 43200;
  41:         }
  42:  
  43:         return;
  44:     }
  45:     if (preg_match("~(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(.*)~",$dateString,$matches)) {
  46:         $this->unix = gmmktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
  47:         if (substr($matches[7],0,1)=='+' OR substr($matches[7],0,1)=='-') {
  48:             $tzOffset = (substr($matches[7],0,3) * 60 + substr($matches[7],-2)) * 60;
  49:         } else {
  50:             if ($matches[7]=="Z") {
  51:                 $tzOffset = 0;
  52:             }
  53:         }
  54:         $tzOffset += date("Z",0);
  55:         $this->unix += $tzOffset;
  56:  
  57:         if (TIME_ZONE!="")
  58:         {
  59:             $server_TZ = abs(intval($GLOBALS['xoopsConfig']['server_TZ'] * 3600.0));
  60:             $this->unix += ($server_TZ - date("Z", 0)) % 43200;
  61:         }
  62:         return;
  63:     }
  64:     $this->unix = 0;
  65: }

2、修改htdocs\modules\article\class\xml.php文件58行,

原来为:

$TIME_ZONE = $prefix.date(“H:i”, $server_TZ);

修改为:

$TIME_ZONE = $prefix.date(“H:i”, ($server_TZ – date(“Z”, 0)) % 43200); // By XuYong 调整时区显示,防止出现+1600时区

七月
26

[Fixed]Article模组取某个分类的子分类时出错的Bug

Author Dominic    Category XOOPS     Tags , ,

当我们使用的article模组时,如果我们想获取某个分类的所有子分类时,会发现取到的数据有可能不是我们所需要的,返回的却是所有分类,当然这个Bug只存在于article模组1.0版本中,下个版本中可能会被修正。(不知道D.J.什么时候出下个版本呢)

修改htdocs\modules\article\class\category.php文件中378行附近,

原来为:

$category_array = $tree->getAllChild(0);

修改之后:

$category_array = $tree->getAllChild($pid);//Modifyed By XuYong 没有使用$pid,导致没有起到任何作用

即可。

七月
26

XOOPS中修正获取真实用户名的Bug (Fixed)

Author Dominic    Category XOOPS     Tags ,

调用中返回用户姓名时,通过getUnameFromId返回用户姓名时,如果希望返回用户真实姓名时,但是当用户没有填写真实姓名的时候返回的将会是空串,下面这个就用于解决这个问题,当用户没有填写真实姓名时返回用户登录名。

htdocs\kernel\user.php文件,139行附近将getUnameFromId函数做如下修改即可:

原函数:

   1: function getUnameFromId( $userid, $usereal = 0 )
   2: {
   3:     $userid = intval($userid);
   4:     $usereal = intval($usereal);
   5:     if ($userid > 0) {
   6:         $member_handler =& xoops_gethandler('member');
   7:         $user =& $member_handler->getUser($userid);
   8:         if (is_object($user)) {
   9:             $ts =& MyTextSanitizer::getInstance();
  10:             if ( $usereal ) {
  11:                 return $ts->htmlSpecialChars($user->getVar('name'));
  12:             } else {
  13:                 return $ts->htmlSpecialChars($user->getVar('uname'));
  14:             }
  15:         }
  16:     }
  17:     return $GLOBALS['xoopsConfig']['anonymous'];
  18: }

修改之后函数为:

   1: function getUnameFromId( $userid, $usereal = 0 )
   2:     {
   3:         $userid = intval($userid);
   4:         $usereal = intval($usereal);
   5:         if ($userid > 0) {
   6:             $member_handler =& xoops_gethandler('member');
   7:             $user =& $member_handler->getUser($userid);
   8:             if (is_object($user)) {
   9:                 $ts =& MyTextSanitizer::getInstance();
  10:                 if ( $usereal ) {
  11:                     if(trim($user->getVar('name')) != '') {
  12:                         return $ts->htmlSpecialChars($user->getVar('name'));
  13:                     } else {
  14:                         return $ts->htmlSpecialChars($user->getVar('uname'));
  15:                     }
  16:                 } else {
  17:                     return $ts->htmlSpecialChars($user->getVar('uname'));
  18:                 }
  19:             }
  20:         }
  21:         return $GLOBALS['xoopsConfig']['anonymous'];
  22:     }
七月
26

[Hack]给XOOPS的Transfer服务书签应用增加几种在线书签

Author Dominic    Category XOOPS     Tags , , ,

中的 API非常好,但是其书签功能中支持的在线书签服务实在太少,我添加了几种现在流行的在线书签服务,当然我们还可以添加更多。

修改htdocs\Frameworks\\plugin\bookmark\language\schinese_utf8.php文件如下,支持google书签、美味书签、Sina Vivi、365Key、BlogChina、Poco、Sohu、天极、和讯、QQ、百度。如果采用gb2312编码或者gbk编码则编辑htdocs\Frameworks\\plugin\bookmark\language\schinese.php这个文件。

<?php
/**
 *  handler for 
 *
 * This is intended to handle content intercommunication between modules as well as components
 * There might need to be a more explicit name for the handle since it is always confusing
 *
 * @copyright    The  project http://www..org/
 * @license        http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author        Taiwen Jiang (phppp or D.J.) <php_pp@hotmail.com>
 * @since        3.00
 * @version        $Id$
 * @package        Frameworks::
 */ 

define("_MD_TRANSFER_BOOKMARK", "书签");
define("_MD_TRANSFER_BOOKMARK_DESC", "添加到书签"); 

/* Chinese */
define("_MD_TRANSFER_BOOKMARK_ITEMS",
    "<span id=\"article-bookmarkit\"><ul class=\"list-bookmark\" id=\"bookmarkit\">"
    . "<li><a href=\"javascript:void(google = window.open('http://www.google.com/bookmarks/mark?op=edit&output=popup&title=' + encodeURIComponent('%1\$s')+ '&bkmk=' + encodeURIComponent('%2\$s') , 'google')); google.focus();\">[<strong style='color:red'>Google</strong>]</a>  </li>"
. "<li><a title=\"Delicious\" href=\"javascript:void(delicious=window.open('http://del.icio.us/post?url='+encodeURIComponent('%2\$s')+'&title='+encodeURIComponent('%1\$s'), 'delicious'));delicious.focus();\">[<strong style='color:#0000FF'>del.icio.us</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(vivi = window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=28&title=' + encodeURIComponent('%1\$s') + '&url=' + encodeURIComponent('%2\$s') + '&desc=' + encodeURIComponent(t), 'vivi')); vivi.focus();\">[<strong style='color:red'>新浪 VIVI</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(365key = window.open('http://www.365key.com/storeit.aspx?t=' + encodeURIComponent('%1\$s') +'&u=' + encodeURIComponent('%2\$s') + '&c=' + encodeURIComponent(t), 'keyit')); 365key.focus();\">[<strong style='color:#a287be'>365k</strong><strong style='color:#00CC00'>e</strong><strong style='color:#9575B6'>y</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(blogchina = window.open('http://blogmark.blogchina.com/jsp/key/quickaddkey.jsp?k=' + encodeURI('%1\$s') + '&u='+encodeURI('%2\$s') + '&c='+encodeURI(t), 'blogchina')); keyit.focus();\">[<strong style='color:#74B779'>博采中心</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(poco = window.open('http://my.poco.cn/fav/storeIt.php?t=' + encodeURIComponent('%1\$s') + '&u=' + encodeURIComponent('%2\$s') + '&c=' + encodeURIComponent(t), 'keyit')); poco.focus();\">[<strong style='color:#29B5DE'>Poco</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(sohu = window.open('http://z.sohu.com/storeit.do?t=' + encodeURIComponent('%1\$s') + '&u=' + encodeURIComponent('%2\$s') +'&c=' + encodeURIComponent(t), 'sohu')); sohu.focus();\">[<strong style='color:#505050'>SOHU狐摘</strong>]</A>  </li>"
. "<li><a href=\"javascript:void(yesky = window.open('http://hot.yesky.com/dp.aspx?t=' + encodeURIComponent('%1\$s') + '&u=' + encodeURIComponent('%2\$s') + '&c=' + encodeURIComponent(t) + '&st=2', 'yesky')); yesky.focus();\">[<strong style='color:#99CF17'>天极</strong><strong style='color:#FF7F00'>网摘</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(hexun = window.open('http://bookmark.hexun.com/post.aspx?title=' + encodeURIComponent(t) + '&url=' + encodeURIComponent(u) + '&excerpt=' + encodeURIComponent(e), 'HexunBookmark')); hexun.focus();\">[<strong style='color:#3366CC'>和讯网摘</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(qq = window.open('http://shuqian.qq.com/post?title=' + encodeURIComponent('%1\$s')+ '&uri=' + encodeURIComponent('%2\$s') +'&jumpback=2&noui=1', 'qq')); qq.focus();\">[QQ<strong style='color:#74B779'>书签</strong>]</a>  </li>"
. "<li><a href=\"javascript:void(baidu = window.open('http://cang.baidu.com/do/add?it=' + encodeURIComponent('%1\$s')+ '&iu=' + encodeURIComponent('%2\$s') +'&dc=&fr=ien#nw=1'', 'baidu')); baidu.focus();\">[<strong style='color:red'>百度搜藏</strong>]</a>  </li>"
. "</ul></span>"
    );
?>

专题推荐

标签

apache article CSS dotNet fckeditor Hack iOS iTouch javascript PayPal PHP rar ubuntu utf8 VMware VMware Tools weblinks Win2008 Windows Server 2008 Wordpress xajax XOOPS 上传 个人 中文 中文习惯 关键词 分享 合肥 域名 安全 工作 插件 文章管理 时区 未分类 模块 模板 模组 电子地图 界面友好 禅意花园 网速 腾讯 配置管理

分类目录

新浪微博

存档

最近文章

近期评论

友情链接

分享按钮