伪静态做个记录

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

 

RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]

参考来自 http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/

nginx的下面

http://stackoverflow.com/questions/1629231/nginx-rewrite-non-www-prefixed-domain-to-www-prefixed-domain

关于利用curl发送数据的兼容性问题

参考自 http://blog.csdn.net/fableboy/article/details/18973483

使用数组提供post数据时,CURL组件大概是为了兼容@filename这种上传文件的写法,默认把content_type设为了multipart/form-data。虽然对于大多数web服务器并没有影响,但是还是有少部分服务器不兼容。

本文得出的结论是,在没有需要上传文件的情况下,尽量对post提交的数据进行http_build_query,然后发送出去,能实现更好的兼容性,更小的请求数据包。

ecshop 的部分sql缓存read_static_cache和write_static_cache

可以利用read_static_cache和write_static_cache 来缓存一些不经常变化的数据来缓存

$data_attr = read_static_cache(‘all_attr_list_’.md5($_SERVER[‘REQUEST_URI’]));

if ($data_attr === false)
{
// 获得$all_attr_list的sql逻辑
write_static_cache(‘all_attr_list_’.md5($_SERVER[‘REQUEST_URI’]), $all_attr_list);
}else{
// 来自缓存的数据
$all_attr_list = $data_attr;
}

这样可以在 temp/static_cache/下生成缓存数据

记事狗微博的api/uc.php 同步登录的新注册用户问题

在记事狗微博的 api/uc.php 里面当记事狗本身用户不存在,而在uc里面存在的时候,当登录后自动注册到记事狗,需要修改代码实现。图中红线部分是重要的,必须的。
在api/uc.php 的 onsynlogin 同步登录函数里面的部分代码如下

jishigou

代码如下

 include_once(ROOT_PATH . 'uc_client/client.php');
            if($data = uc_get_user($get["username"]))
            {
                list($uid, $uname, $email) = $data;
 		        $this->db->query("REPLACE  INTO   `{$this->tablepre}members` (`uid`,`ucuid`,`username`,`nickname`,`email`,`role_id`) values ('$uid','$uid','$uid','$uname','$email','2')");
		        $query = $this->db->query("SELECT `uid`, `password` FROM `{$this->tablepre}members` WHERE `ucuid`='$uid'");
		        $UserFields = $this->db->fetch_array($query);
			    $auth = authcode("{$UserFields['password']}\t{$UserFields['uid']}","ENCODE",'',1209600);
                jsg_setcookie('sid', '', -311040000);
                jsg_setcookie('auth',$auth,311040000);
 
            }

discuz 插件速度慢的查找方法

source/function/function_core.php
的函数 hookscript


foreach($funcs as $hookkey => $hookfuncs) {
foreach($hookfuncs as $hookfunc) {
//起始时间
$a = time()

……

//结束时间
$b = time()-$a;
echo “==========”.$b.print_r($hookfuncs,true);
}
}

通过查看===== 标记后面$b值,如果$b过大,就查看$hookfuncs 是什么造成的,从而查出哪个插件,解决方法就是了可以临时跳过那个插件

if($hookfunc[0]==”cloudsearch”) continue;
上面的cloudsearch 就是 $hookfuncs[0] 查出来的

//PS 上面的方法不一定好使,可以用下面的

测试方法 用你的测试访问两次某个地址

可以通过改变某个参数, user-agent 等来对比生成的 zjpro.txt 文件的不一致性,从而确定哪一个plungin的问题!!!!

比如

curl -v -A “百度spider的UA” http://URI

curl -v -A “正常IE的UA” http://URI

对比生成的两次zjpro.txt 文件

 

阿里云的主机宝 php5.2 出现 502错误原因总结

  • sqlite 3  可能导致 php 5.2 版本出现 502错误 。解决方法:把/usr/lib/libsqlite-3 移走
  • openssl问题可能导致,解决方法,安装openssl-devel 然后重新编译 php ,附录为主机宝官方给的ssl方面的解决方法(未实验, 可能X86_64位需要修改)

============1======================
wget dl2.admin5.com/php/curl-7.37.1.tar.gz
tar zxvf curl-7.37.1.tar.gz
cd curl-7.37.1
./configure –prefix=/usr/local/curl
make && make install
cd ..
rm -rf curl-7.37.1*
============2======================
cd /a/apps/
wget dl2.admin5.com/php/php-5.2.17-have.tar.gz
rm -rf php-5.2.17
tar zxvf php-5.2.17-have.tar.gz
rm -rf php-5.2.17-have.tar.gz

===========3(镜像1.0)==============
cd /root
wget dl2.admin5.com/php/openssl-1.0.1h.tar.gz
tar zxvf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
./config –prefix=/usr/local/ssl shared zlib
make && make install
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo “/usr/local/ssl/lib” >> /etc/ld.so.conf
ldconfig -v
cd ..
rm -rf openssl-1.0.1h*
===========4=======================
killall -9 php-cgi
killall -9 php-cgi
service php-fpm start
service zadmin start

zhujibao

iframe自适应学习一例子

首先感谢 http://www.ccvita.com/376.html 现在说下跨域的iframe 自适应,
代码下载 http://www.ccvita.com/usr/uploads/demo/iframe/iframe.zip
解压后 main.html 和 agent.html 是在一个域名下,假设a.com
iframe.html 在另外域名下假设 b.com

A 站a.com 在main.html 里面用iframe框住b.com 下的iframe.html
iframe1

agent.html 直接上传就可以 B站 b.com 在b.com 下的iframe.html 里面要加入

 
function sethash(){     
hashH = document.documentElement.scrollHeight;      
urlC = "http://a.com/agent.html"; //注意这里!!!     
document.getElementById("iframeC").src=urlC+"#"+hashH; 
} 
window.onload=sethash;

在IE6、IE7、IE8、IE9、Firefox全系列、Chrome全系列均可以成功跨域控制高度

redhat 6 使用 centos yum

curl -o yum-3.2.29-40.el6.centos.noarch.rpm   http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
curl -o yum-metadata-parser-1.1.2-16.el6.x86_64.rpm  http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
curl -o yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
curl -o python-iniparse-0.3.1-2.1.el6.noarch.rpm  http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

rpm -Uvh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -Uvh yum-3.2.29-40.el6.centos.noarch.rpm  yum-metadata-parser-1.1.2-16.el6.x86_64.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

cd /etc/yum.repos.d/
wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo
vi CentOS6-Base-163.repo
把文件里面的$releasever全部替换为版本号,即6 最后保存

yum clean all
yum makecache

参考文章
http://down.chinaz.com/server/201111/1321_1.htm

dedecms 生成栏目html缓慢的一个可能原因

在dede\makehtml_list_action.php 的文件行 101 处
//$lv->CountRecord();
有这样一处注释掉的代码,似乎DEDECMS的程序猿同学欲言又止
这一个计算某个栏目类有多少分页的代码居然不运行,从而导致后面一行

if($lv->TypeLink->TypeInfos[‘ispart’]==0 && $lv->TypeLink->TypeInfos[‘isdefault’]!=-1) $ntotalpage = $lv->TotalPage;
else $ntotalpage = 1;

导致这里面的 $ntotalpage 根本得不到值 (NULL),
因为 $lv->TotalPage 是在$lv->CountRecord  函数里面赋值
所以感觉特别奇怪。

从而想到,取消此处注释,让栏目生成HTML 分批进行

 //如果栏目的文档太多,分多批次更新
    if($ntotalpage <= $maxpagesize || $lv->TypeLink->TypeInfos['ispart']!=0 || $lv->TypeLink->TypeInfos['isdefault']==-1)
    {
        $reurl = $lv->MakeHtml('', '', $isremote);
        $finishType = TRUE;
    }
    else
    {
// 让代码进入此执行才是分批生成html
        $reurl = $lv->MakeHtml($mkpage, $maxpagesize, $isremote);
        $finishType = FALSE;
        $mkpage = $mkpage + $maxpagesize;
        if( $mkpage >= ($ntotalpage+1) ) $finishType = TRUE;
    }

ecshop 属性筛选在category.php 页面显示顺序错误,调整和后台排序一致

在category.php 行 272处查找

$attr_list = $db->getAll($sql);
字样然后下面增加如下代码 
从phpsir_filter_code_start 到 phpsir_filter_code_end 中间部分
$attr_list = $db->getAll($sql);
//phpsir_filter_code_start
                $phpsir_tmp=$attr_list[0];
                $phpsir_sql= "select attr_values from " . $ecs->table('attribute') . " WHERE attr_id = '$phpsir_tmp[attr_id]' ";
                $phpsir_attribute = $db->getOne($phpsir_sql);  
                $phpsir_ga = explode("\n",$phpsir_attribute);
                $phpsir_new_attr_list = array();
                foreach($attr_list as $kk=>$vv)
                {
                    foreach($phpsir_ga as $kkk => $vvv){
                        if(trim($vv['attr_value']) == trim($vvv))
                        {
                            $phpsir_new_attr_list[$kkk] = $vv;
                        }
                    }
                }
                ksort($phpsir_new_attr_list);
                $attr_list = $phpsir_new_attr_list;
//phpsir_filter_code_end

前台显示例子如下

phpsir_filter_code1

 

代码在上面,或者如下图

phpsir_filter_code

 

 

linux下邮件服务器配置的各个部件的关系

postfix 毫无疑问这个MTA (Mail Transfer Agent) 是用来做邮件传输的
maildrop 用来做本地的邮件投递投递工作,MDA (Mail delivery agent)
courier-authdaemon 用于认证 配置文件是 /etc/courier/authdaemonrc
courier-authlib 认证库支持
courier-authlib-mysql 支持mysql的认证库 配置文件 /etc/courier/authmysqlrc
saslauthd 用于 SMTP 认证,支持courier-authlib 配置文件 /etc/default/saslauthd
courier-pop courier-pop-ssl pop3 和 pop-ssl 的认证服务 配置文件 /etc/courier/pop3d
courier-imap courier-imap-ssl imap 和 imap-ssl 的 认证服务 配置文件 /etc/courier/imapd

需要启动的服务
/etc/init.d/postfix start
/etc/init.d/courier-authdaemon start
/etc/init.d/saslauthd start
/etc/init.d/courier-imap start
/etc/init.d/courier-pop start

测试方法
测试下Courier-Authlib是否能成功连接mysql

authtest -s login 邮件地址 或者 authtest -s login 邮件地址 密码

测试sasl 的smtp
testasaslauthd -s smtp -u xxxx -p xxxxx

ubuntu 下安装 postfix extmail 系统参考
http://www.mike.org.cn/articles/ubuntu-configure-postfix-mailserver/

nginx 的 substitutions4nginx 在gzip的问题上的处理

nginx 的代理功能不错,但是有些类似小偷的程序,可以利用
substitutions4nginx 来改写目标页面的html代码,
subs_filter www.a.com www.b.com;
但是有时候居然无法匹配 www.a.com ,发现源文件里面是gzip的从而无法匹配
那么只需要修改proxy的指令,告知源,我这里不收取gzip的资料,请发我未压缩的版本
proxy_set_header Accept-Encoding “”;
可以解决
完整的如下

server
{
listen 80;
server_name www.a.com;
location / {
subs_filter www.a.com www.b.com ;
proxy_set_header Accept-Encoding “”;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://www.a.com;
index index.html index.htm;
}
}

 

有关apache的proxy时候碰到gzip,看 http://www.zjpro.com/apache-2-4-substitute.html

yum安装的proftpd无法登录系统用户

默认安装的proftpd 的 pam_stack.so 模块文件不存在
我经过参考 http://cosmicb.no/2014/05/09/proftpd-pam-unable-to-dlopenlib64securitypam_stack-so-in-centos-6-5/
修改 /etc/pam.d/proftpd 为
auth required pam_listfile.so item=user sense=deny file=/etc/ftpusers onerr=succeed
auth required pam_shells.so
auth include system-auth
account include system-auth
session required pam_loginuid.so