<script language=”JavaScript” src=”/include/jquery-latest.pack.js”></script>
<script language=JavaScript>
var tmp=”";
function formatn(n){
if (n<10)
return “0″+n;
else
return “”+n;
}
$(document).ready(function() {
var f=document.form1.elements;
var n_i=1;
var s_i=”";
var n_v=1;
for(var i=0;i<f.length;i++){
//tmp+=f[i].value+”\n”;
if (f[i].type==”hidden”||f[i].name==”reg_no” ){
continue;
}
if (f[i].type==”text”||f[i].type==”textarea”){
f[i].name=f[i].id=”text_”+formatn(n_i);
n_i++; continue;
}
if (f[i].type==”radio”||f[i].type==”checkbox”){
var oname=f[i].name;
f[i].name=f[i].id=”check_”+formatn(n_i);
f[i].value=formatn(n_v);
if (i<f.length){
if (oname!=f[i+1].name||f[i].type!=f[i+1].type){
n_i++;
n_v=1;
}
else
n_v++;
}
continue;
}
}
});
</script>
Archive for the ‘原创技术文章’ Category
备份一段js代码
六月 26th, 2009ecshop 2.6.2 sitemaps.php的一个bug
五月 16th, 2009生成的sitemap文件,商品分类文件,如果是
http://www.abc.com/category-1-b0.html
在sitemap文件里面少了一个”/”
结果变成了
http://www.abc.comcategory-1-b0.html
分类是
修改代码
sitemaps.php大约第66行
把
- 'loc' => "$site_url" . build_uri('category', array('cid' => $row['cat_id'])),
改成
- 'loc' => "$site_url/" . build_uri('category', array('cid' => $row['cat_id'])),
即可
FCKEditor XML Request Error:Internal Server Error(500)
五月 1st, 2009原来一直能用的ecshop后台信息发布里面的fckeditor上传功能,换了个机器后不能用了。以为是文件损坏,上传一边不行。
什么xml错误,还弹出一个大的JavaScript alert警告框,内容就是服务器端错误的500内容
网上搜,又说是配置问题,主题问题,想想都不应该,直接请求
filemanager/connectors/php/connector.php
出了服务器的500错误,html文件能访问,txt也行。
后来从根目录开始查,发现到fckeditor目录里面的php文件开始不能访问。
改了fckeditor目录的属性为755,问题解决。
如何在wordpress的the_excerpt中使用nextgen-gallery(NGG)图片
三月 5th, 2009NextGEN gallery是个很不错的wordpress相册插件。
新版本的wordpress有了一个the_excerpt的方法可以用,原来就有?不知道。
the_excerpt主要是调用原来的摘要部分,供模板调用。但是和the_content的区别是,the_excerpt里面不支持nextgen-gallery(NGG)的singpic,gallery等标签不能用。如果在模板里面用了the_excerpt,但是又想显示图片就不方便了。
用的是1.1.0版本,查了一下代码,找到
lib\shortcodes.php
的
class NextGEN_shortcodes
大概在18行,看到一行注释,说如果在the_excerpt里面用会有不期望的输出。如果你高兴就去掉下面的注释。
- // add_filter('the_excerpt', array(&$this, 'convert_shortcode'));
- // add_filter('the_excerpt', 'do_shortcode', 11);
改成
- add_filter('the_excerpt', array(&$this, 'convert_shortcode'));
- add_filter('the_excerpt', 'do_shortcode', 11);
测试可以,没发现啥异常。先用着吧。
ecshop关闭版本检查的功能
二月 27th, 2009要修改如下几个文件
\upload\admin\shop_config.php(205):
\upload\install\includes\lib_installer.php(734):
\upload\admin\templates\start.htm
\upload\admin\templates\menu.htm
备案
ecshop和discuz的2段代码
二月 24th, 2009最近想装一下ecshop和discuz2个程序,装的时候看到2段代码
ecshop的
- <script type=”text/javascript” src=”http://api.ecshop.com/checkver.php?ver=<?php
- echo $this->_var['ecs_version']; ?>&lang=<?php
- echo $this->_var['ecs_lang']; ?>&release=<?php
- echo $this->_var['ecs_release']; ?>&php_ver=<?php
- echo $this->_var['sys_info']['php_ver']; ?>&mysql_ver=<?php
- echo $this->_var['sys_info']['mysql_ver']; ?>&ocount=<?php
- echo $this->_var['order']['stats']['oCount']; ?>&oamount=<?php
- echo $this->_var['order']['stats']['oAmount']; ?>&gcount=<?php
- echo $this->_var['goods']['total']; ?>&charset=<?php
- echo $this->_var['ecs_charset']; ?>”></script>
discuz的
- <script src=”http://<?=$insenz[url]?>/news.php?id=<?=$insenz[siteid]?>&t=<?=$timestamp?>&k=<?=md5($insenz[authkey].$insenz[siteid].$timestamp.’Discuz!’)?>&insenz_version=<?=INSENZ_VERSION?>&discuz_version=<?=DISCUZ_VERSION.’ - ‘.DISCUZ_RELEASE?>&random=<?=random(4)?>”
- type=”text/javascript” charset=”UTF-8″></script>
- echo ‘<sc’
- .'ript language=”Jav’.'aScript” src=”
- ht’.'tp:/’.'/cus’.'tome’.'r.disc’.'uz.n’.'et/n’
- .'ews’.’.p’.'hp?’.bbsinformation().’”></s’.'cri’.'pt>’;
恩,很好很强大
google脑子进水了
一月 31st, 20092009年1月31号23点30分左右,想看一下网站的收录情况,一看,居然网站说“该网站可能含有恶意软件,有可能会危害您的电脑。”,换英文Google,说”This site may harm your computer.”,问别人也说看到的是同样的内容。
把我吓坏了,看别的网站,很多也有这种情况。
过了几分钟看,发现好了。
真是进水
python版本的jquery
一月 5th, 2009jquery在做html内容提取,分析的时候很方便。而python做类似的工作就麻烦一点,原来我都是用正则表达式或者HtmlParser的。
两者用着都不是太爽,今天发现了一个好东西 pyquery ,一个类似jquery的python库。
摘抄一段使用说明
- >>> from pyquery import PyQuery as pq
- >>> from lxml import etree
- >>> d = pq("<html></html>")
- >>> d = pq(etree.fromstring("<html></html>"))
- >>> d = pq(url='http://google.com/')
- >>> d = pq(filename=path_to_html_file)
Now d is like the $ in jquery:
- >>> d("#hello")
- [<p#hello.hello>]
- >>> p = d("#hello")
- >>> p.html()
- 'Hello world !'
- >>> p.html("you know <a href='http://python.org/'>Python</a> rocks")
- [<p#hello.hello>]
- >>> p.html()
- 'you know <a href="http://python.org/">Python</a> rocks'
- >>> p.text()
- 'you know Python rocks'
简单吧,安装也很简单
下载
http://pypi.python.org/packages/source/p/pyquery/pyquery-0.3.tar.gz
解压缩
python setup.py install
就可以了,可能要安装ezsetup
现在的版本是0.3,还有一些jquery的东西没有实现,比如:radio,:password,以及一些ajax的功能,但是已经够用了,强烈推荐。
赶紧试试吧。
还有一个BeautifulSoup,也推荐一下
wordpress如何显示和分类相关的热门文章
十二月 3rd, 2008Popularity Contest是个不错的插件,可以根据点击量,评价次数,trackbacks等计算一个文章的受欢迎程度,然后列出来。为了跟用户当前浏览的页面相关性更好,我做了一些修改。
这个插件有2个function可用
akpc_most_popular_in_cat和akpc_most_popular,分别是指定一个分类id或取当前分类和所有的排名。
但是akpc_most_popular_in_cat有一点问题,就是原来的sql语句是在show_top_ranked_in_cat里面的sql是
WHERE tt.term_id = ‘”.intval($cat_ID).”‘
这样,只能在一个分类里面查找,需要修改成支持多个分类id的。改成如下
WHERE tt.term_id in (”.$cat_ID.”)
这样就支持多个分类id了,还有一个问题是取的当前的相关分类id,我们已经解决了。在sidebar.php里面加入如下代码,即可。根据不同的theme,可能需要做些调整。
<h2 class="widgettitle">热门文章</h2><ul class="pop">
<?php if ( function_exists('akpc_most_popular') ) : ?>
<?php if (is_category()) {
//echo $cat;
$categories= get_categories('child_of='.$cat);
$categoryIDS = array($cat);
foreach ($categories as $category) {
array_push($categoryIDS, $category->term_id);
}
$categoryIDS = implode(",", $categoryIDS);
akpc_most_popular_in_cat(10, "<li>", "</li>", $categoryIDS) ;
}else if ( is_single()){
$categories = get_the_category();
$categoryIDS = array();
foreach ($categories as $category) {
array_push($categoryIDS, $category->term_id);
}
$categoryIDS = implode(",", $categoryIDS);
akpc_most_popular_in_cat(10, "<li>", "</li>", $categoryIDS) ;
}else{
?>
<?php akpc_most_popular($limit=10); ?>
<?php }
endif; ?></ul>
</li>
wordpress如何取得当前的分类id
十二月 1st, 2008wordpress的很多sidebar展示内容都是静态的,比如最新评论,最新文章等。不管首页,分类,还是单页都是一样的。原来写过一篇如何显示wordpress当前分类的文章列表?,这是针对single page的。其实还可以在分类页面做一些工作。
单个的文章页面很简单就用
get_the_category
返回的是一个对象的数组,因为一个文章可能属于多个分类。
分类页面简单的可以直接用
$cat
这个变量,但是这样其实是不完美的,因为当前分类还可以有子分类,怎么拿当前分类的所有子分类id呢?用
get_categories(’child_of=’.$cat);
下一篇贴一个把分类相关的热门文章列在侧边栏的代码。

