一整套应用程序图标f3 Silk Icons 下载
这是由famfamfam提供 的一套完整的应用程序操作图标库。
该作品基于 Creative Commons Attribution 2.5 License 协议发布.
图标库的下载地址为:图 标库下载
不会ps的朋友有福了
自动开设虚拟主机的bash脚本
脚本很简单,功能是,自动增加一个以输入域名命名的www根目录,自动生成一个ftp用户,自动创建一个mysql数据库,自动创建一个mysql用户
#!/bin/bash
#输入要增加的域名
echo “Input The Domain”
read
domain=$REPLY
#这里输入ftp密码
echo “Input The Password”
read
ftp_password=$REPLY
#mysql的超级用户名和密码
mysql_root=”root”
mysql_root_pass=”abcdefg”
database_name=${domain//./_}
database_user=${domain//./_}
vhost_file=”${domain}.conf”
echo “Input Mysql Password for Database ${database_name}”
read
database_password=$REPLY
cd /www/wwwroot/
mkdir $domain
chown daemon:daemon $domain
chmod 700 $domain
#生成虚拟机的配置文件
cd /usr/local/apache2/conf/vhost
cp 51rego.com.conf $vhost_file
sed “s/51rego.com/$domain/ig” $vhost_file >temp
cat temp>$vhost_file
#增加ftp虚拟用户和密码
cd /www/users/conf
echo $domain>>vusers.txt
echo $ftp_password>>vusers.txt
db_load -T -t hash -f vusers.txt /etc/vsftpd_login.db
#增加一个ftp账户
cd /etc/vsftpd_user_conf
cp 51rego.com $domain
sed “s/51rego.com/$domain/ig” $domain >temp
cat temp>$domain
#创建mysql数据库
mysql -u${mysql_root} -p${mysql_root_pass} -e “create database ${database_name}”
#创建mysql用户和密码
mysql -u${mysql_root} -p${mysql_root_pass} -e “grant all privileges on ${database_name}.* to ${database_user}@localhost identified by ‘${database_password}’”
echo “Ftp User Name: ${domain}”
echo “Ftp Password: ${ftp_password}”
echo “Mysql database: ${database_name}”
echo “Mysql user: ${database_user}”
echo “Mysql password: ${database_password}”
echo “success! restart httpd…”
#重启httpd
/usr/local/apache2/bin/httpd -S
service httpd graceful
exit
不得不说的360金山门
周鸿祎与金山之间的口水战还是战的不可开交,透过他们的周的口水炮弹,再次感受到了他的伟大人格魅力,赤裸裸的报复性的语言让我看清了他疯狂的报复心态,我感觉以前”迫害过”3721 的人是不是都头皮麻了一下,自认为一个人格端正的人是不会这样的,即便不相信金山网盾,但我宁愿相信可牛,和遨游,正式他们让我毫无犹豫的立刻卸载了360,这确实很恐怖,但一个软件控制了绝大部分电脑的时候,就像一个重磅炸弹,你不知道它什么时候就在你的电脑里爆炸。想当年3721在很多善良的国人心目中确实算是一个非常不错的软件,想上某一个网站的时候直接输入中文就行了,这是多么好的一款软件啊,为中国互联网也做出了不小的贡献,可是当它的狰狞面目露出来的时候,人们才恍然大悟,原来这款软件的背后竟是如此的肮脏龌龊不可告人。。。
顺便说句,最近电脑中了木马,经常刷新桌面时弹出网页广告窗口,用360杀了N遍,无效,在一个网友的推荐下用了下window的清理助手,成功解决,出现这种情况的网友不妨试试。
javascript 获取滚动条高度+常用js页面宽度与高度[转]
/********************
* 取窗口滚动条高度
******************/
function getScrollTop()
{
var scrollTop=0;
if(document.documentElement&&document.documentElement.scrollTop)
{
scrollTop=document.documentElement.scrollTop;
}
else if(document.body)
{
scrollTop=document.body.scrollTop;
}
return scrollTop;
}
/********************
* 取窗口可视范围的高度
*******************/
function getClientHeight()
{
var clientHeight=0;
if(document.body.clientHeight&&document.documentElement.clientHeight)
{
var clientHeight = (document.body.clientHeight<document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
}
else
{
var clientHeight = (document.body.clientHeight>document.documentElement.clientHeight)?document.body.clientHeight:document.documentElement.clientHeight;
}
return clientHeight;
}
/********************
* 取文档内容实际高度
*******************/
function getScrollHeight()
{
return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight);
}
////////////////////////////////////////////////////
在IE中:
document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度
document.documentElement.clientWidth ==> 可见区域宽度
document.documentElement.clientHeight ==> 可见区域高度
在FireFox中:
document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度
document.documentElement.clientWidth ==> 可见区域宽度
document.documentElement.clientHeight ==> 可见区域高度
?
在 Opera中:
document.body.clientWidth ==> 可见区域宽度
document.body.clientHeight ==> 可见区域高度
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)
document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
而如果没有定义W3C的标准,则
IE为:
document.documentElement.clientWidth ==> 0
document.documentElement.clientHeight ==> 0
FireFox为:
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
Opera为:
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
真是一件麻烦事情,其实就开发来看,宁可少一些对象和方法,不使用最新的标 准要方便许多啊。
//////////////////////////////////////////////////////////////////////////////////////
网页可见区域宽:
document.body.clientWidth
网页可见区域高:
document.body.clientHeight
网页可见区域宽:
document.body.offsetWidth(包 括边线的宽)
网页可见区域高:
document.body.offsetHeight(包括边线的宽)
网页 正文全文宽:
document.body.scrollWidth
网页正文全文高:
document.body.scrollHeight
网 页被卷去的高:
document.body.scrollTop
网页被卷去的左:
document.body.scrollLeft
网 页正文部分上:
window.screenTop
网页正文部分左:
window.screenLeft
屏 幕分辨率的高:
window.screen.height
屏幕分辨率的宽:
window.screen.width
屏 幕可用工作区高度:
window.screen.availHeight
屏幕可用工作区宽度:
window.screen.availWidth
再写关于无限分类
数据表里的结构还是非常简单
三个字段id , parentid ,name
算法也很简单递归,以前用递归的时候很傻,应该说极傻,因为在递归中通过查询数据表来获得子类的所有,最近开窍了,想到了一个地球人都能想得到的方法,下面是代码,一个class
<?php
class Tree {/**
* 从数据库查询出的所有分类信息
* @var array
*/
var $arr;
/**
* 如下格式
* var $arr = array(
1 => array(‘id’=>’1′,’parentid’=>0,’name’=>’一级栏目一’),
2 => array(‘id’=>’2′,’parentid’=>0,’name’=>’一级栏目二’),
3 => array(‘id’=>’3′,’parentid’=>1,’name’=>’二级栏目一’),
);*//**
* 输出结构
* @var array
*/
var $tree = array();
/**
* 树形递归的深度
* @var int
*/
var $deep = 1;/**
* 生成树形的修饰符号
* @var array
*/
var $icon = array(‘│’,'├’,'└’);
/**
* 生成指定id的下级树形结构
* @param int $rootid 要获取树形结构的id
* @param string $add 递归中使用的前缀
* @param bool $parent_end 标识上级分类是否是最后一个
*/
function getTree($rootid = 0,$add = ”,$parent_end =true){
$is_top = 1;
$child_arr = $this->getChild($rootid);
if(is_array($child_arr)){
$cnt = count($child_arr);
foreach($child_arr as $key => $child){
$cid = $child['id'];
$child_child = $this->getChild($cid);
if($this->deep >1){
if($is_top == 1 && $this->deep > 1){
$space = $this->icon[1];
if(!$parent_end)
$add .= $this->icon[0];
else $add .= ‘ ’;
}if($is_top == $cnt){
$space = $this->icon[2];
$parent_end = true;
}else {
$space = $this->icon[1];
$parent_end = false;
}
}
$this->tree[] = array(‘spacer’=>$add.$k.$space,
‘name’=>$child['name'],
‘id’=>$cid
);
$is_top++;$this->deep++;
if($this->getChild($cid))
$this->getTree($cid,$add,$parent_end);
$this->deep–;}
}
return $this->tree;
}/**
* 获取下级分类数组
* @param int $root
*/
function getChild($root = 0){$a = $child = array();
foreach($this->arr as $id=>$a){
if($a['parentid'] == $root){
$child[$a['id']] = $a;
}
}
return $child?$child:false;
}
/**
* 设置源数组
* @param $arr
*/
function setArr($arr = array()){
$this->arr = $arr;
}
}
通过一次查询把结构保存进一个数组,再数组进行递归运算,无疑极大的提高了程序运行效率
使用代码很简单,得到查询结构后setArr,直接调用getTree, 皆可以得到按照程序排序号并带有前缀修饰等信息的数组,到这里通过foreach这个数组就可以得到如下的树状列表了
水果
├香蕉
├苹果
│├红富士
│└海南苹果
└桃子
smarty中使用fckeditor
网上最常用的做法是先在php中调用fckeditor类的createHtml方法生成一段html,直接assign给一个samrty变量即可
这里我通过smarty的插件机制,可以更方便的在smarty中集成fckeditor,在smarty的plugin目录中新建文件function.fck.php
内容如下
<?php
function smarty_function_fck($params, &$smarty)
{
if(!isset($params['InstanceName']) || empty($params['InstanceName']))
{
$smarty->trigger_error(‘fckeditor: required parameter “InstanceName” missing’);
}static $base_arguments = array();
static $config_arguments = array();if(!count($base_arguments))
$init = TRUE;
else
$init = FALSE;if(isset($params['BasePath']))
{
$base_arguments['BasePath'] = $params['BasePath'];
}
else if(empty($base_arguments['BasePath']))
{//这里设置默认的fck所在的目录,相对于要使用fck的程序的目录
$base_arguments['BasePath'] = ‘../plugins/fckeditor/’;
}$base_arguments['InstanceName'] = $params['InstanceName'];
if(isset($params['Value'])) $base_arguments['Value'] = $params['Value'];
if(isset($params['Width'])) $base_arguments['Width'] = $params['Width'];
if(isset($params['Height'])) $base_arguments['Height'] = $params['Height'];
if(isset($params['ToolbarSet'])) $base_arguments['ToolbarSet'] = $params['ToolbarSet'];
if(isset($params['CheckBrowser'])) $base_arguments['CheckBrowser'] = $params['CheckBrowser'];
if(isset($params['DisplayErrors'])) $base_arguments['DisplayErrors'] = $params['DisplayErrors'];// Use all other parameters for the config array (replace if needed)
$other_arguments = array_diff_assoc($params, $base_arguments);
$config_arguments = array_merge($config_arguments, $other_arguments);$out = ”;
if($init)
{
$out .= ‘<script type=”text/javascript” src=”‘ . $base_arguments['BasePath'] . ‘fckeditor.js”></script>’;
}$out .= “\n<script type=\”text/javascript\”>\n”;
$out .= “var oFCKeditor = new FCKeditor(‘” . $base_arguments['InstanceName'] . “‘);\n”;foreach($base_arguments as $key => $value)
{
if(!is_bool($value))
{
// Fix newlines, javascript cannot handle multiple line strings very well.
$value = ‘”‘ . preg_replace(“/[\r\n]+/”, ‘” + $0″‘, addslashes($value)) . ‘”‘;
}
$out .= “oFCKeditor.$key = $value; “;
}foreach($config_arguments as $key => $value)
{
if(!is_bool($value))
{
$value = ‘”‘ . preg_replace(“/[\r\n]+/”, ‘” + $0″‘, addslashes($value)) . ‘”‘;
}
$out .= “oFCKeditor.Config[\"$key\"] = $value; “;
}$out .= “\noFCKeditor.Create();\n”;
$out .= “</script>\n”;return $out;
}
?>
使用代码
{fck InstanceName=”body” BasePath=“../plugins/fckeditor/” Value=$news_info.body Width=”100%” Height=”400″}
可以自定义参数 ToolbarSet-使用的工具栏, BasePath-fck相对于当前脚本的目录,InstanceName-要赋予的$_POST变量名, Value-默认值等
ubuntu 服务器中修改mysql数据目录的方法
停止mysql服务
sudo /etc/init.d/mysql stop
建新数据库目录
mkdir /media/hda11/db
复制linux下原数据到新目录下
cp -r /var/lib/mysql/* /media/hda11/db
给新目录重命属性(很 重要,不然出现无法访问目录情况)
chown mysql:mysql /media/hda11/db
修改 配置文件
sudo nano /etc/mysql/my.cnf
把
datadir = /var/mysql换成datadir = /media/hda11/db
#在my.cnf中有提到如果修改了 datadir这几部分,最好也调整/etc/apparmor.d/usr.sbin.mysqld
修改文件 /etc/apparmor.d/usr.sbin.mysqld(似乎跟安全配置有关)
sudo nano /etc/apparmor.d/usr.sbin.mysqld
把
/var/lib/mysql r,
/var/lib/mysql/** rwk,
改成
/media/hda11/db r,
/media/hda11/db/** rwk,
再开服务器(这一步很重要)
sudo /etc/init.d/apparmor restart
重启mysql服务
sudo /etc/init.d/mysql restart
附:apparmor也是个权限控制的东东。。
参考文章:http://forum.ubuntu.org.cn/viewtopic.php?f=44&p=1074517
判断一个数是否是2的次方
经典的:
int IsPower(unsigned n)
{
if(n==0)
return 1;
while(n)
{
if(n%2==0)
{
n = n/2;
if(n==1)
return 1;
}
else return 0;
}
}
不必解释
超强的:
int IsPower(unsigned n)
{
return (n&&!(n&(n-1)));
}
解释:
如果一个数是2的次方,则转成2进制是首位为1,其余都为0,比如:
2(10) 4(100) 8(1000) 16(10000)……
如果一个数和全1的相与还是等于自己,则这个数就是2的次方
n&(n-1)计算的是全零的情况,故!(n&(n-1))是全1的情况
转自 http://hi.baidu.com/mzyse/blog/item/6b5f5517d5d9d30cc83d6da3.html
有关IIS下zencart的伪静态设置
公司的zencart 项目放在了window2003的服务器上,为了seo的考虑,开启了搜索引擎优化模块,可是碰到了一个问题,url的伪静态是通过网站根目录下的.htaccess文件来实现的,这需要apache的rewrite模块,可是iis中怎么实现?其实可以通过iis的ISAPI_Rewrite扩展来实现,下载一个ISAPI Rewrite的安装包,Lite免费版本ISAPI_Rewrite Lite (freeware)即可。安装运行后,打开IIS,在网站单击右键选属性,就可以看到ISAPI_Rewrite已经被加入到了ISAPI筛选器中。在ISAPI_Rewrite的安装目录下,找到 httpd.ini 在此文件中输入Rewrite的规则即可,这里的规则基本跟apache的rewrite差不多,不过在我的测试过程中,发现了一些问题,例如http.ini中不能使用%{QUERY_STRING}这样的服务器变量,也不知道是不是我服务器配置的原因,这里我对 zencart 里的.htaccess文件需要经过一些修改解决了这个问题
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
修改为,无非是一个简单的正则替换
RewriteRule ^(.*)-p-(.*).html(\?(.*))?$ index\.php?main_page=product_info&products_id=$2&$4 [L]
有关zen cart集成支付宝借口时提示ILLEGAL_SIGN 错误解决
这次开发zencart的过程中要用过国内大名鼎鼎的支付宝接口,从zencart.cn上下了jack的 zen cart 支付宝模块从后台安装一切ok,可是测试购物的时候遇到了 ILLEGAL_SIGN错误,找了很多答案,仔仔细细看了阿里提供的api文档,还是找不出问题所在。看来得靠自己了,对着firebug,一个个核对网站传输给支付宝的post数据,发现多了 btn_submit.x,btn_submit.x 这两个参数,我把form 的method改成get,从地址栏中去掉这两个参数再打开,成功转向支付宝收银台页面,看来果然是两个参数搞得鬼!
google了下submit.x,得到如下答案
根据图形提交按钮行为W3C的描述 :
When a pointing device is used to click on the image, the form is submitted and the click coordinates passed to the server.
当指针设备用于在图像上点击,表单提交和点击坐标传递给服务器。The x value is measured in pixels from the left of the image, and the y value in pixels from the top of the image.
在x值的单位是像素从左边的形象,以像素为单位从图像的顶部y值。The submitted data includes name.x=x-value and name.y=y-value where “name” is the value of the name attribute, and x-value and y-value are the x and y coordinate values, respectively.
提交的数据包括name.x = x值和name.y = y值在“名称”的名称属性值和x值和y值是x和y坐标值。
于是这还是W3C的标准,现在的问题就是如何避免浏览器“多此一举”了,很简单,在表单添加onsubmit=”this.submit();return false;”,即修改zencart的订单确认页面模板tpl_checkout_confirmation_default.php文件中的
echo zen_draw_form(‘checkout_confirmation’, $form_action_url, ‘post’, ‘id=”checkout_confirmation” onsubmit=”submitonce();”‘);
修改为
echo zen_draw_form(‘checkout_confirmation’, $form_action_url, ‘post’, ‘id=”checkout_confirmation” onsubmit=”this.submit();return false;”‘);
近期评论