查看 Web应用 栏目文章
四月
25

调整Smarty 模板引擎参数提高cache、templates_c目录读写性能

Author Dominic    Category Web应用, XOOPS     Tags , , ,

在用Xoops建立一个站点(只用Smarty引擎也一样)时,开启缓存之后cache和templates_c这两个目录用不了多长时间就充满了上千个文件乃至几十万个文件,操作一个包含数量巨大的文件的目录本来就很慢,这样会导致这两个目录的文件读取、删除、更新都很慢,本打算写一个cache handler来解决这个问题,在跟踪Smarty代码的时候发现Smarty已经解决了这个问题,那就是Smarty的use_sub_dirs属性,将该属性设置为true即可。示例代码

[coolcode lang=""]<?
 
require ‘../libs/Smarty.class.’;
 
$smarty = new Smarty;
 
$smarty->use_sub_dirs = true;
 
$smarty->compile_check = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 60;
$smarty->assign(“Name”,”Fred Irving Johnathan Bradley Peppergill”);
$smarty->assign(“FirstName”,array(“John”,”Mary”,”James”,”Henry”));
$smarty->assign(“LastName”,array(“Doe”,”Smith”,”Johnson”,”Case”));
$smarty->assign(“Class”,array(array(“A”,”B”,”C”,”D”), array(“E”, “F”, “G”, “H”),
      array(“I”, “J”, “K”, “L”), array(“M”, “N”, “O”, “P”)));
 
$smarty->assign(“contacts”, array(array(“phone” => “1″, “fax” => “2″, “cell” => “3″),
      array(“phone” => “555-4444″, “fax” => “555-3333″, “cell” => “760-1234″)));
 
$smarty->assign(“option_values”, array(“NY”,”NE”,”KS”,”IA”,”OK”,”TX”));
$smarty->assign(“option_output”, array(“New York”,”Nebraska”,”Kansas”,”Iowa”,”Oklahoma”,”Texas”));
$smarty->assign(“option_selected”, “NE”);
 
$smarty->display(‘index.tpl’);
 
?>
[/coolcode]

对应Xoops中编辑Class\template.文件第58行附近更改var $use_sub_dirs = false;var $use_sub_dirs = true;即可。

四月
18

向Google、Yahoo、MSN提交sitemap.xml文件另外一种方法

Author Dominic    Category Web应用     Tags ,

一般我们在给google、Yahoo提交sitemap.xml文件是通过各自的管理页面或者用ping的方式提交。一种更简单的方法可以实现Google、Yahoo、MSN等支持sitemap.xml的搜索引擎来优先利用sitemap.xml文件索引网站:

在网站根目录的robots.txt(如果没有这个文件,请新建一个)添加如下行:
      Sitemap: http://www.yoursite.com/sitemap.xml

将www.yoursite.com替换成实际的域名,主流搜索引擎都会优先处理robots.txt文件。

四月
18

WordPress Tag插件(UltimateTagWarrior) 不能使用中文tag的解决办法

今天加入了模组加入Tag,但是只要Tag是中文的,启用rewrite之后,均不能正常显示,全部报404错误。经过长时间的跟踪终于发现问题了。以下以http://xuplus.com/tag/合肥 为例。

wp-includesclasses.文件61行附近
             $req_uri = str_replace($pathinfo, ”, $req_uri);

这行代码主要作用是将$reg_uri赋值/tag,但运行时 pathinfo为 合肥 req_url为/tag/%E5%90%88%E8%82%A5,这样并不能完成替换操作给$reg_uri赋值/tag。替换成
             $req_uri = urldecode(str_replace(urlencode($pathinfo), ”, str_replace(‘/’,'%2F’,$req_uri)));
             //Modified By XuYong 修正url中有中文字符的问题$pathinfo被urldecode了,导致不能正常工作的问题

即可正常访问。

四月
18

WordPress 2.1添加自定义文件上传类型(允许上传rar文件方法)

Author Dominic    Category Web应用     Tags , , ,

注意,2.1中修改允许上传文件文件类型的的位置变了,以前的版本是wp-includes\functions-post.,2.1之后的版本改成了wp-includes\functions.

wordpress2.1.3默认不支持上传文件,修改方法如下:
打开wp-includes\functions.,查找

   ‘zip’ => ‘application/zip’,

(第1106行左右),在这一行的下面加上这一行

’ => ‘application/’,

注意后面有个半角的逗号,别复制漏了,引号是半角单引号。

保存就可以了,如果是用ftp管理别忘了上传哦。

四月
18

XOOPS中article模块 文章管理界面 的友好模板

D.J. 开发的模块确实很好用,但是他的文章管理界面不太符合中国人使用习惯(被ASP CMS 惯坏了),充分发扬XOOPS的全部模板定制精神,做了一个针对文章管理的功能的友好模板。采用了表格显示文章列表的方式。如图:

 

下载附件解压到themes\你的主题名称\modules\覆盖或者解压到modules\\templates覆盖并在后台更新模块.

 下载地址:article_cparticle.html 

四月
16

执行多个OnLoad方法的用法

Author Dominic    Category Web应用     Tags

在同一个页面要用到两个onload事件的方法,一个是初始化对象,一个要隐藏一个div.结果怎么也不能在ie和firefox下面同时实现隐藏这个div.

   

下面的方法可以解决一次执行多个onload方法: 

<script type=”text/”> 

//onload 方法

function generic()

{

alert(‘onload 方法’);

};

if(typeof window.addEventListener != ‘undefined’)

{

//.. gecko, safari, konqueror, Mozilla/Firefox and 标准 浏览器

window.addEventListener(‘load’, generic, false);

}

else if(typeof document.addEventListener != ‘undefined’)

{

//.. opera 7 浏览器

document.addEventListener(‘load’, generic, false);

}

else if(typeof window.attachEvent != ‘undefined’)

{

//.. win/ie 浏览器

window.attachEvent(‘onload’, generic);

}

else

{

//.. mac/ie5及更早的浏览器

   

//if there’s an existing onload function

if(typeof window.onload == ‘function’)

{

//保留以前的方法

var existing = onload;

   

//添加新方法

window.onload = function()

{

//调用以前的方法

existing();

   

//调用新加的方法

generic();

};

}

else

{

//设置Onload方法

window.onload = generic;

}

}

 </script> 

完整的多个Onload方法和OnUnload方法用法

<script type=”text/”>

function applyst() {

load();

if( window.XTRonload ) { window.XTRonload(); }

}

function savest() {

Unload();

if( window.XTRonunload ) { window.XTRonunload(); }

}

   

if( window.addEventListener ) {

window.addEventListener( ‘load’, applyst, false );

window.addEventListener( ‘unload’, savest, false );

} else if( document.addEventListener ) {

document.addEventListener(‘load’ , applyst, false );

document.addEventListener( ‘unload’, savest, false );

} else if( window.attachEvent ) {

window.attachEvent( ‘onload’, applyst );

window.attachEvent( ‘onunload’, savest );

} else {

if( window.onload ) { window.XTRonload = window.onload; }

if( window.onunload ) { window.XTRonunload = window.onunload; }

window.onload = applyst;

window.onunload = savest;

}

function load() {

}

function Unload() {

}

</script>

四月
12

Xoops中FCKeditor的上传文件时中文文件名解决方案

Author Dominic    Category XOOPS     Tags , , , ,

使用FCKeditor上传图片、Flash等文件时,文件名中的中文会显示为乱码并在在服务器上面保存有些全部为乱码文件,不能正常显示,在网上搜了一下前辈们的解决方法,没找到很好的解决办法。看来还有N多的人和我一样的困惑,但解决办法又如此的简单:

将 editor\filemanager\browser\default\frmupload.html 文件的编码改为UTF-8即可。

如果不能解决则

编辑upload.文件

// Compose the file path.

//Modifyed By XuYong 修正UTF-8的问题

$sFileName =iconv(“utf-8″,”gbk”,$sFileName);

//End Modifyed

环境XOOPS 2.0.16 UTF-8

四月
12

XOOPS中Fckeditor 在arctile模组中上传失败解决方法

Author Dominic    Category XOOPS     Tags , , ,

上传过程提示信息:

This file uploader is disabled. Please check the “editor/filemanager/upload//config.” file

使用过程中可能出现问题。有以下几个地方要修改

modules\\fckeditor.upload.

中必须定义

define(“FCKUPLOAD_DISABLED”, 1);

修改class\xoopseditor\FCKeditor\editor\filemanager\upload\\upload.

文件头部为

//Modifyed By XuYong 解决有时不能顺利获取config.等文件

$current_path =dirname(__FILE__);

if ( DIRECTORY_SEPARATOR != “/” ) $current_path = str_replace( DIRECTORY_SEPARATOR, “/”, $current_path);

require($current_path.’/config.’) ;

require($current_path.’/util.’) ;

/*

require(‘config.’) ;

require(‘util.’) ;

*/

//End Modifyed

修改class\xoopseditor\FCKeditor\editor\filemanager\upload\\connector.

文件头部为

//Modifyed By XuYong 解决有时不能顺利获取config.等文件

$current_path =dirname(__FILE__);

if ( DIRECTORY_SEPARATOR != “/” ) $current_path = str_replace( DIRECTORY_SEPARATOR, “/”, $current_path);

require($current_path.’/config.’) ;

require($current_path.’/util.’) ;

require($current_path.’/io.’) ;

require($current_path.’/basexml.’) ;

require($current_path.’/commands.’) ;

/*

include(‘config.’) ;

include(‘util.’) ;

include(‘io.’) ;

include(‘basexml.’) ;

include(‘commands.’) ;

*/

//End Modifyed

环境:XOOPS 2.0.16 UTF-8

四月
12

IE下页面无端端空出一行及utf8页面无法显示的解决方法

Author Dominic    Category Web应用     Tags

  页面采用UTF8编码,头部和尾部用了模板包含文件的方法,结果头部和尾部无端端各多出一个约10px的空行,什么也没有。
  原因是全部采用utf8编码,包含文件的时候,最后的二进制流中包含了多次UTF8 BOM标记,IE不能正常解析包含多个UTF8 BOM 标记的页面,直接替换成实际显示的回车,这样导致一个空行,而firefox却没有这个问题。
  故如果模板采用包含的方法包含多个utf8文件需要用ultraedit保存时另存为功能 选择utf8 无bom格式保存即可。
  另外,如果中文页面在html head标记中将title标记放在<meta http-equiv=”content-type” content=”text/html; charset=UTF-8″ />前面会导致页面空白。
  所以utf8页面应该使用标准顺序

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="zh-CN" />
<meta name="robots" content="index,follow" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="rating" content="general" />
<meta name="author" content="" />
<meta name="copyright" content="" />
<meta name="generator" content="" />
<title></title>



 

专题推荐

标签

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 上传 个人 中文 中文习惯 关键词 分享 合肥 域名 安全 工作 插件 文章管理 时区 未分类 模块 模板 模组 电子地图 界面友好 禅意花园 网速 腾讯 配置管理

分类目录

新浪微博

存档

最近文章

近期评论

友情链接

分享按钮