中山php|最优网络中山做网站 中山php建站

最优良人

2012/05/19 at 17:46

ie6下,浮动的li里面文字不换行

在ie6下,浮动的li里面文字在结尾出宽度不够,但是不自动换行,而是往下挤,使后面的li乱掉。

解决的方法是在li里面定义样式 white-space: nowrap;

comments Comments (192)    -
2012/05/05 at 18:20

最简单的设为首页,加入收藏代码

只要一句代码,可以实现设为首页,加入收藏的功能,并且通用其他网站,自动识别标题和链接,不用手动修改。但是只兼容ie浏览器。

<a href="#" onClick="this.style.behavior='url(#default#homepage)'; this.setHomePage(window.location.href);">设为首页</a> | <a href="#" onClick="window.external.addFavorite(window.location.href,document.title)">加入收藏</a>

comments Comments (45)    -
2012/04/06 at 09:23

PHP删除指定文件夹所有文件的方法

以下代码实现删除指定文件夹所有文件

$cacheDir = '../cache/runtime';
$dh = opendir($cacheDir);
while ( $file = readdir($dh) ) {

if (($file == '.') || ($file == '..')) { continue; }

if (file_exists( $cacheDir . '/' .$file)) {
if (!unlink($cacheDir . '/' . $file)) {
break;
}
}
}

标签:
comments Comments (12)    -
2012/03/14 at 11:05

ecshop前后台去掉版权powered by信息

1,去除标题power by ecshop

在 include/lib_main.php 里面找到 function assign_ur_here($cat = 0, $str = ''){ ....} 大概在142行
$page_title = $GLOBALS['_CFG']['shop_title']. ' - ' . 'Powered by ECShop';
$ur_here = '<a href=".">' . $GLOBALS['_LANG']['home'] . '</a>';
把上面改成:
$page_title = $GLOBALS['_CFG']['shop_title';
$ur_here = '<a href=".">' . $GLOBALS['_LANG']['home'] . '</a>';
2,ECSHOP底部随机出现版权信息去除方法
第一步:删除该函数即可,该函数位置:js/common.js
第244行函数如下:
onload = function()
{
var link_arr = document.getElementsByTagName(String.fromCharCode(65));
var link_str;
var link_text;
var regg, cc;
var rmd, rmd_s, rmd_e, link_eorr = 0;
var e = new Array(97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122
);

try
{
for(var i = 0; i < link_arr.length; i++)
{
link_str = link_arr.href;
if (link_str.indexOf(String.fromCharCode(e[22], 119, 119, 46, e[4], 99, e[18], e[7], e[14],
e[15], 46, 99, 111, e[12])) != -1)
{
if ((link_text = link_arr.innerText) == undefined)
{
throw "noIE";
}
regg = new RegExp(String.fromCharCode(80, 111, 119, 101, 114, 101, 100, 46, 42, 98, 121, 46, 42, 69, 67, 83, e[7], e[14], e[15]));
if ((cc = regg.exec(link_text)) != null)
{
if (link_arr.offsetHeight == 0)
{
break;
}
link_eorr = 1;
break;
}
}
else
{
link_eorr = link_eorr ? 0 : link_eorr;
continue;
}
}
} // IE
catch(exc)
{
for(var i = 0; i < link_arr.length; i++)
{
link_str = link_arr.href;
if (link_str.indexOf(String.fromCharCode(e[22], 119, 119, 46, e[4], 99, 115, 104, e[14],
e[15], 46, 99, 111, e[12])) != -1)
{
link_text = link_arr.textContent;
regg = new RegExp(String.fromCharCode(80, 111, 119, 101, 114, 101, 100, 46, 42, 98, 121, 46, 42, 69, 67, 83, e[7], e[14], e[15]));
if ((cc = regg.exec(link_text)) != null)
{
if (link_arr.offsetHeight == 0)
{
break;
}
link_eorr = 1;
break;
}
}
else
{
link_eorr = link_eorr ? 0 : link_eorr;
continue;
}
}
} // FF

try
{
rmd = Math.random();
rmd_s = Math.floor(rmd * 10);
if (link_eorr != 1)
{
rmd_e = i - rmd_s;
link_arr[rmd_e].href = String.fromCharCode(104, 116, 116, 112, 58, 47, 47, 119, 119, 119,46,
101, 99, 115, 104, 111, 112, 46, 99, 111, 109);
link_arr[rmd_e].innerHTML = String.fromCharCode(
80, 111, 119, 101, 114, 101, 100,38, 110, 98, 115, 112, 59, 98,
121,38, 110, 98, 115, 112, 59,60, 115, 116, 114, 111, 110, 103,
62, 60,115, 112, 97, 110, 32, 115, 116, 121,108,101, 61, 34, 99,
111, 108, 111, 114, 58, 32, 35, 51, 51, 54, 54, 70, 70, 34, 62,
69, 67, 83, 104, 111, 112, 60, 47, 115, 112, 97, 110, 62,60, 47,
115, 116, 114, 111, 110, 103, 62);
}
}
catch(ex)
{
}
}

这是随机在底部产生版权的函数,删掉就可以了!!
直接把这个函数去掉,底部的Powered by ECShop 就没了
第二步,打开themes/default/library/ 这里default为你当前的主题,找到page_footer.lbi,里面内容全部删掉,添加上你想添加的代码。支持html代码的。完毕。

第三步,如果你只想简单的改下就弄第一步就行,然后去\languages\zh_cn 找common.php找到ecshop.com改成你网址,E CSho p对应改成你的网站名称就行,最后去themes\default\images里把logo1.gif改成你想要的图片,也就是左下角的那张.

 

 

修改ecshop后台的版权信息
在languages/zh_cn/admin/common.php文件修改
admin/templates/index.htm

Line 4

*/
<title>{$lang.cp_home}</title>

将下部版权修改为自己的
/*

admin/templates/login.htm

Line 4

*/

<title>{$lang.cp_home}</title>
删除<img src="images/login.png" width="178" height="256" border="0" alt="ECSHOP" />

/*

admin/templates/top.htm

Line 132

Line 135

*/

删除图片<img src=”images/ecshop_logo.gif” alt=”ECSHOP - power for e-commerce” />

删除<li><a href=”index.php?act=about_us” target=”main-frame”>{$lang.about}</a></li>
删除<li><a href="javascript:web_address();">{$lang.help}</a></li>
/*

admin/templates/start.htm

将{$lang.ecs_version}修改为:网站版本

Line 6

*/

<script type=”text/javascript” src=”http://api.ecshop.com/checkver.php?ver={$ecs_version}&lang={$ecs_lang}&release={$ecs_release}&php_ver={$sys_info.php_ver}&mysql_ver={$sys_info.mysql_ver}&ocount={$order.stats.oCount}&oamount={$order.stats.oAmount}&gcount={$goods.total}&charset={$ecs_charset}” ></script>
/*

Line 184-195

*/

<tr>
<td>{$lang.ecs_version}</td>
<td>{$ecs_version} RELEASE {$ecs_release}</td>
<td>{$lang.install_date}</td>
<td>{$install_date}</td>
</tr>
<tr>
<td>{$lang.ec_charset}</td>
<td>{$ecs_charset}</td>
<td></td>
<td></td>
</tr>
/*

admin/tempaltes/pageheader.htm

Line 24

*/

<span class=”action-span1″><a href=”index.php?act=main”>{$lang.cp_home}</a> {if $ur_here} - {$ur_here} {/if}</span>
/*

admin/templates/pagefooter.htm

Line 3

*/

{$lang.copyright}
/*

admin/templates/menu.htm

Line 143

*/

<script language=”JavaScript” src=”http://api.ecshop.com/menu_ext.php?charset={$charset}&lang={$help_lang}”></script>
admin/templates/filecheck.htm
将{$lang.filecheck_tips_step1}修改:为文件校验是针对 原始网站文件 为基础进行核对,点击下面按钮开始进行校验。
admin\includes\inc_menu.php
删除:
$modules['11_system']['shp_webcollect'] = 'webcollect.php';
$modules['11_system']['shop_authorized'] = 'license.php?act=list_edit';
也可以删除$modules['13_backup']['convert'] = 'convert.php?act=main';
admin\sms_url.php
将$url = 'http://service.shopex.cn/sms/index.php?certificate_id='.$certi_id.'&sess_id='.$sess_id.'&auth='.$auth.'&ac='.$ac;
的连接修改掉或删除 这个是申请短信连接的地址
includes\modules
下所有文件中的 ECSHOP TEAM 和其连接删除

 

 

 

ecshop 后台管理左侧菜单添加新栏目
先说几个相关文件admin 文件下admin/includes/inc_menu.php

languages\zh_cn\admin\common.php

admin/includes/common.php

接下来说添加的方法,首先

先在languages\zh_cn\admin\common.php添加栏目的名字,关于这个是添加后台在页面显示所需的文字的文件

打开看看,再看看模板就明白了

然后在admin/includes/common.php文件中添加一级栏目的数字名字就数组

再在admin/includes/inc_menu.php 文件中添加对应的二级栏目的数组链接

链接为一级的数组元素,不明白的话,最好先看看这两个文件

然后说怎样实现在分配权限里面管理它,

打开admin/includes/inc_priv.php文件

新建栏目权限数组 数组元素和admin/includes/inc_menu.php页面的数组相同,对应的值自定义

并比自定义的该值添加的表ecs_admin_action表中

首先在表中新建你的一级栏目parent_id 为0 action_code 为数组元素的名字

然后添加二级栏目的 信息 parent_id为你的一级菜单的action_id

action_code 为打开admin/includes/inc_priv.php文件中 自定义的值

好了,就样你就添加的一个后台管理栏目,并可在新建管理后进行权限管理

标签:
comments Comments (84)    -
2012/03/08 at 14:56

CSS border-collapse 属性,细边线table表格样式

border-collapse 属性设置表格的边框是否被合并为一个单一的边框,还是象在标准的 HTML 中那样分开显示。

可能的值

描述
separate 默认值。边框会被分开。不会忽略 border-spacing 和 empty-cells 属性。
collapse 如果可能,边框会合并为一个单一的边框。会忽略 border-spacing 和 empty-cells 属性。
inherit 规定应该从父元素继承 border-collapse 属性的值。

细边线table表格样式

table {width:100%; border:1px solid #ccc; border-collapse:collapse;}
table td {border:1px solid #ccc; border-collapse:collapse; padding:10px 15px; color:#999;}

标签:, ,
comments Comments (374)    -
2012/03/07 at 11:34

prompt弹出对话框,获取输入的值

定义和用法

prompt() 方法用于显示可提示用户进行输入的对话框。

语法

prompt(text,defaultText)

text 可选。要在对话框中显示的纯文本(而不是 HTML 格式的文本)。
defaultText 可选。默认的输入文本。也可以不输入值,如果不输入值,则返回null。

说明

如果用户单击提示框的取消按钮,则返回 null。如果用户单击确认按钮,则返回输入字段当前显示的文本。   在用户点击确定按钮或取消按钮把对话框关闭之前,它将阻止用户对浏览器的所有输入。在调用 prompt() 时,将暂停对 JavaScript 代码的执行,在用户作出响应之前,不会执行下一条语句。

以下的代码弹出一个对话框,用户输入密码,然后提交表单
 function fn_check( theForm )
  {
	var m = prompt ( "请输入新密码" , "" ) ;
	if ( m )
	{
		m = trimString(m);
		if ( m != "" )
		{
			theForm.newftppassword1.value = m;
			theForm.doftppasswordupdate.value = '1';
			theForm.submit();
			return true;
		}
	}
	return ;
  }
<form id="frm_sitedetail" name="frm_sitedetail" action="siteadmin.php" method="POST">
		<input type="hidden" name="newftppassword1" value="">
<input type="hidden" name="doftppasswordupdate" value="">
</form>
标签:,
comments Comments (267)    -
2012/02/24 at 17:31

CSS hack之!important;下划线,星号

星号" * " :ie6 ie7支持 hirefox不支持

下划线"_":ie6支持 ie7 firefox不支持

!important; : firefox ie7支持 ,ie6部分支持

IE6支持重定义中的!important,例如:   .yuanxin {color:#e00!important;}   .yuanxin {color:#000;}   你将会发现定义了样式class="yuanxin"时,在IE下,字体显示为红色(#e00)。   但不支持同一定义中的!important。例如:   .yuanxin {color:#e00!important;color:#000}   此时在IE6下不支持,你将会发现定义了样式class="yuanxin"时,字体显示为黑色(#000)。

 

HTML头部引用(if IE)Hack:针对所有IE:<!--[if IE]><!--您的代码--><![endif]-->,针对IE6及以下版本:<!--[if lt IE 7]><!--您的代码--><![endif]-->,这类Hack不仅对CSS生效,对写在判断语句里面的所有代码都 会生效。

选择器Hack:比如 IE6能识别*html .class{},IE7能识别*+html .class{}或者*:first-child+html .class{}。等等

浏览器优先级别:FF<IE7<IE6,CSS hack书写顺序一般为FF IE7 IE6

以: " #demo {width:100px;} "为例;

#demo {width:100px;} /*被FIREFOX,IE6,IE7执行.*/

* html #demo {width:120px;} /*会被IE6执行,之前的定义会被后来的覆盖,所以#demo的宽度在IE6就为120px; */

*+html #demo {width:130px;} /*会被IE7执行*/ ---------------

所以最后,#demo的宽度在三个浏览器的解释为:

FIREFOX:100px;

ie6:120px;

ie7:130px;

IE8 最新css hack:

"\9" 例:"border:1px \9;".这里的"\9"可以区别所有IE和FireFox.

"\0" IE8识别,IE6、IE7不能.

IE6 hack

_background-color:#CDCDCD; /* ie 6*/

IE7 hack

*background-color:#dddd00; /* ie 7*/

IE8 hack

background-color:red\0; /* ie 8/9*/

IE9 hack

background-color:blue\9\0;

标签:,
comments Comments (287)    -
2012/02/24 at 17:25

绝对定位的div显示在屏幕中间

使用绝对定位position: absolute;定义元素时,可以用top,bottom,left,right控制元素在页面上下左右的位置,有时我们需要元素无论页面大小都是显示在页面中间时,可以使用百分比来定义,如

#purr-container {
position: absolute;
top: 50%;
right: 50%;
z-index: 99999999 !important;
}

注: !important;ie7和FF可以识别,ie6不识别,可以用来区分火狐和ie6

comments Comments (409)    -
2012/02/10 at 09:07

Apache自带的ab(ApacheBench)性能测试工具对网站进行访问压力测试

1 概述

ab(ApacheBench)是Apache自带的超文本传输协议(HTTP)性能测试工具。 其设计意图是描绘当前所安装的Apache的执行性能, 主要是显示你安装的Apache每秒可以处理多少个请求。

2 使用
2.1 安装

Apache服务器套件自带ab,只要安装Apache即可,无需另行安装ab。ab位于%ApacheHome%/bin目录下(“%ApacheHome%”为Aapche安装路径),你也可以把ab.exe文件copy出来,独立使用。

2.2 参数列表

-A auth-username:password
向服务器提供基本认证信息。用户名和密码之间由一个":"隔开,并将被以base64编码形式发送。无论服务器是否需要(即是否发送了401认证需求代码),此字符串都会被发送。
-c concurrency
一次产生的请求个数。默认是一次一个。
-C cookie-name=value
对请求附加一个"Cookie:"头行。其典型形式是 name=value 的一个参数对。此参数可以重复。
-d
不显示"percentage served within XX [ms] table"消息(为以前的版本提供支持)。
-e csv-file
产生一个逗号分隔(CSV)文件,其中包含了处理每个相应百分比请求(从1%到100%)所需要的相应百分比时间(以微秒为单位)。由于这种格式已经"二进制化",所以比"gnuplot"格式更有用。
-g gnuplot-file
把所有测试结果写入一个"gnuplot"或者TSV(以Tab分隔)文件。此文件可以方便地导入到 Gnuplot, IDL, Mathematica, Excel中。其中的第一行为标题。
-h
显示使用方法的帮助信息。
-H custom-header
对请求附加额外的头信息。此参数的典型形式是一个有效的头信息行,其中包含了以冒号分隔的字段和值(如:"Accept-Encoding: zip/zop;8bit")。
-i
执行HEAD请求,而不是GET
-k
启用KeepAlive功能,即在一个HTTP会话中执行多个请求。默认不启用KeepAlive功能。
-n requests
在测试会话中所执行的请求个数。默认仅执行一个请求,此时其结果不具有意义。
-p POST-file
包含了POST数据的文件。
-P proxy-auth-username:password
对一个中转代理提供基本认证信息。用户名和密码由一个":"隔开,并将被以base64编码形式发送。无论服务器是否需要(即是否发送了407代理认证需求代码),此字符串都会被发送。
-q
如果处理的请求数大于150,ab每处理大约10%或者100个请求时,会在stderr输出一个进度计数。此 -q 标记可以屏蔽这些信息。
-s
用于编译中(ab -h 会告诉你)使用了SSL的受保护的https ,而不是http协议的时候。此功能是实验性的,最好不要用。
-S
不显示中值和标准偏差值,而且在均值和中值为标准偏差值的1到2倍时,也不显示警告或出错信息。默认时,会显示最小值/均值/最大值等数值。(为以前的版本提供支持)
-t timelimit
测试所进行的最大秒数。内部隐含值是"-n 50000"。它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。
-T content-type
POST数据时所使用的"Content-type"头信息。
-v verbosity
设置显示信息的详细程度,4或更大值会显示头信息,3或更大值可以显示响应代码(404,200等),2或更大值可以显示警告和其他信息。
-V
显示版本号并退出。
-w
以HTML表格形式输出结果。默认时,它是白色背景的两列宽度的一张表。
-x <table>-attributes
设置<table>属性的字符串。此属性被填入<table 这里 >
-X proxy[:port]
对请求使用代理服务器。
-y <tr>-attributes
设置<tr>属性的字符串。
-z <td>-attributes
设置<td>属性的字符串。

以上参数最常用的是-n 在测试会话中所执行的请求个数;和-c 一次同时产生的并发请求个数。

2.3 实例

假设我们要测试一下本网站,其中一个性能测试用例是:“同时处理50个并发请求并运行 100 次index.php 首页”,我们可以在cmd shell中输入 ab -n 1000 -c 50 http://www.zui88.com/index.php,运行结束后,ab会自动显示测试结果,如下:

C:\wamp\Apache2\bin>ab -n 100 -c 50 http://www.zui88.com/index.php
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.zui88.com (be patient).....done
Server Software: Apache/2.0.52
Server Hostname: www.zui88.com
Server Port: 80

Document Path: /index.php
Document Length: 21380 bytes

Concurrency Level: 50
Time taken for tests: 66.328125 seconds
Complete requests: 100
Failed requests: 15
(Connect: 0, Length: 15, Exceptions: 0)
Write errors: 0
Non-2xx responses: 15
Total transferred: 1856980 bytes
HTML transferred: 1822145 bytes
Requests per second: 1.51 [#/sec] (mean)
Time per request: 33164.063 [ms] (mean)
Time per request: 663.281 [ms] (mean, across all concurrent requests)
Transfer rate: 27.33 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 31 41 8.5 46 62
Processing: 32 20242 9776.5 22015 43890
Waiting: 31 1637 1327.6 1156 6078
Total: 78 20283 9778.3 22046 43921

Percentage of the requests served within a certain time (ms)
50% 22046
66% 24812
75% 26656
80% 27796
90% 30421
95% 30734
98% 31921
99% 43921
100% 43921 (longest request)

C:\wamp\Apache2\bin>

以上结果指出,在并发50个请求的情况下,完成100次的访问请求,共花了66.328125秒,这个程序每秒可处理1.51个请求。

2.4 问题

在实际使用中,我发现-c 参数,即一次同时产生的并发请求个数最多设置成64,大于等于65就会报错,不知道为什么。

标签:, , ,
comments Comments (205)    -
2012/02/08 at 14:28

php生成二维码

php生成二维码可以有以下几种方式

1.google开放api
$urlToEncode="http://bbs.lewanchina.com";
generateQRfromGoogle($urlToEncode);
function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
{
$url = urlencode($url);
echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" alt="QR code" widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>';
}

2.php类库PHP QR Code
PHP QR Code is open source (LGPL) library for generating QR Code,
2-dimensional barcode. Based on libqrencode C library,
provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2).
Implemented purely in PHP, with no external dependencies (except GD2 if needed).

地址:http://phpqrcode.sourceforge.net/
下载:http://sourceforge.net/projects/phpqrcode/

3.libqrencode

地址:http://fukuchi.org/works/qrencode/index.en.html
php支持请参考:http://hirokawa.netflowers.jp/entry/4900/

4.QRcode Perl CGI & PHP scripts
地址:http://www.swetake.com/qr/qr_cgi.html

标签:
comments Comments (20)    -