本插件费用请参考 /aboutfee
baofoo.jpg 放置在 images\
baofoo.php 放置 includes\modules\payment
baofoo_lang.php 放置 languages\zh_cn\payment\
QQ 733905 联系购买
本插件费用请参考 /aboutfee
baofoo.jpg 放置在 images\
baofoo.php 放置 includes\modules\payment
baofoo_lang.php 放置 languages\zh_cn\payment\
QQ 733905 联系购买
rewrite ^(.*)/([a-zA-Z]+)-(.*.html.*)$ $1/$2.php?$3 last;
背景:
一家网站,帝国程序CMS,网站发布内容数据较多,症状是8核心cpu常常都满载
top 查看的情况是 php-cgi 进程满载,判断可能是1)访问量大或者被攻击,2)php代码问题
网站经过CDN,按理说,不应该造成大量的访问,出现问题完全是php代码访问造成,
本来服务器运行的是 spawn-cgi 来启动的php-cgi进程 , 后来改为php-fpm 也仍然是cpu满载,判断问题在php程序,开启 php-fpm 的slow.log 功能,把运行缓慢的php代码,记录起来,立刻发现了问题!!!
根据slow.log 的情况,发现是一些更新网页代码,被当作 script 脚本 在网页里面,而那个更新脚本运行缓慢,当大量用户来的时候,造成了cpu满载,经过更换脚本名称,cpu立刻下降到正常水平。
解决方案:
把一些更新操作用linux的定时任务去完成,从而避免了放到网页里面。
tail -n 10000 access.log | egrep -vi "GET .*\.gif|\.jpg|\.png|\.css" | awk '{print $1}' | sort | uniq -c | sort -rn | head -n 20
grep “\.jpg|\.gif|\.png”
要想使用包含模式匹配字 +, ?, |, (, 和 ) 中的一个扩展模式,需要用 反斜线
grep “.\+\?\([a-Z]|[0-9]\)
呵呵,挺复杂
cpanel 修改用户密码的方法 ,参考
http://geeksterminal.com/change-cpanel-password-command/
具体命令如下:
export ALLOW_PASSWORD_CHANGE=1
/scripts/chpass username password
/scripts/ftpupdate
一些服务器出问题,如服务器死机,如网站瘫痪,如被挂木马
整体思路是 如果正在攻击的服务器,就查看当前的 webserver 的log ,根据特征进行屏蔽
有的是 user-agent 一致 有的是 ip 一致,有的是 refer 一致
apache的相应设置可以做如下调整
BrowserMatchNoCase 特征1 bad_bot BrowserMatchNoCase 特征2 bad_bot Order Deny,Allow Deny from env=bad_bot 可以写到 .htaccess 或者配置文件里面 关于特征字串有几点要说的 就是括号和加号 需要加\ 斜线 比如 "Mozilla/5.0 \(compatible; Googlebot/2.1; \+http://www.google.com/bot.html\)" 才可以 同样也可以用rewrite 方法来对付这些 RewriteCond %{HTTP_USER_AGENT} "特征串1" RewriteRule ^(.*)$ http://127.0.0.1 RewriteCond %{HTTP_USER_AGENT} "特征串2" RewriteRule ^(.*)$ http://127.0.0.1 用的参数很多 http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} “^特征字符串正则表达式$”
RewriteRule ^(.*)$ http://127.0.0.1
nginx 的配置如下
if ( $http_user_agent = “特征串”) { return 444; };
或者
if ( $http_user_agent ~* “特征串”) { return 444; }
注意特征串如果这正则情况下 斜线 / 括号 () 都是要加斜线的
类youbutu 系统需要linux服务器里面支持mplayer 来把各类音视频文件转换为flv ,mplayer 里面的mencoder 调用ffmpg的方法实现,下面介绍安装方法
首先安装yasm
安装yasm
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar zxvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
安装git
yum -y install git
安装mplay
wget http://www.mplayerhq.hu/MPlayer/releases/mplayer-export-snapshot.tar.bz2
tar jxvf mplayer-export-snapshot.tar.bz2
cd mplayer-export-2013-03-15
./configure
make
make install
安装x264
git clone git://git.videolan.org/x264.git
cd x264
./configure -enable-shared -prefix=/usr
make && make install
安装 mplayer
wget http://www.mplayerhq.hu/MPlayer/releases/mplayer-export-snapshot.tar.bz2
tar jxvf mplayer-export-snapshot.tar.bz2
cd mplayer-export-XXXXXXXXXX
./configure –enable-x264 –extra-libs=”-lx264″
make
make install
安装ffmpeg
下面这个地址很好 https://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide
修改 core\shop\controller\ctl.cart.php
行305起
if(!$this->member[‘member_id’] && !$_COOKIE[‘ST_ShopEx-Anonymity-Buy’]){
//$this->redirect(‘cart’,’loginBuy’,array($_POST[‘isfastbuy’]));
// exit;
}
上面注释掉了 跳出到登陆界面的语句就实现了
get_order_id_by_sn 函数在通过order_id 在pay_log 表里查找支付记录的时候,不够严格,导致可能一个order_id 对应多个pay_log记录,需要找到的是最后也就是log_id 最大的那个。那么从这个角度看,这个代码就需要加一句 order by log_id DESC 的字样
return $GLOBALS[‘db’]->getOne(“SELECT log_id FROM ” . $GLOBALS[‘ecs’]->table(‘pay_log’) . ” WHERE order_id=” . $order_sn . ‘ AND order_type=1’);
就需要修改为
return $GLOBALS[‘db’]->getOne(“SELECT log_id FROM ” . $GLOBALS[‘ecs’]->table(‘pay_log’) . ” WHERE order_id=” . $order_sn . ‘ AND order_type=1 order by log_id DESC ‘);
一台php + mssql 2005
经常 mssql_connect 出现时断时续的连接错误
查资料去除 php.ini 里面的 pdo mssql 和 pdo odbc 后重启 iis,
问题解决
今天碰到一个phpcms v9 用户无法登录会员中心,查来查去,居然是
phpcms\templates\default\content\message.html 文件缺失造成的,
真丫带劲
经常见有写php 的 header 是 301,结果出现302的情形
现在查询发现,似乎这样写才是对的
header(“Location: http://someurl.com”,TRUE,301);
也就是说需要在最后加 301的状态码
最土团购网站的项目编辑部分,本单详情的内容编辑器采用的kindeditor 比较简陋,可以用最新版本的替换,
下载最新版放入 static/kindeditornew 目录 ,然后修改 include/template/manage/manage_header.html
加入定制内容
注意里面的 textarea[name=”detail”] 是关键
<link rel="stylesheet" href="/static/js/kindeditornew/themes/default/default.css" /> <script type="text/javascript" src="/static/js/kindeditornew/kindeditor-min.js"></script> <script charset="utf-8" src="/static/js/kindeditornew/lang/zh_CN.js"></script> <script> var editor; KindEditor.ready(function(K) { editor = K.create('textarea[name="detail"]', { allowFileManager : true }); }); </script>
nginx 配置 ecshop 伪静态 if (!-e $request_filename) { rewrite "^/index\.html" /index.php last; rewrite "^/category$" /index.php last; rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last; rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last; rewrite "^/feed\.xml$" /feed.php last; rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last; rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last; rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last; rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last; rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last; rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last; rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last; rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last; rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last; rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last; rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last; rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last; rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last; rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last; rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last; rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last; rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last; rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last; rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last; rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last; rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last; rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last; rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last; rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last; }
假设 A库 同步到 B 库,就是说A库发生变化了,B库就要和A保持一致,相同goods_sn的商品价格也变化到和A相同,那么A 为sorce_table,B 为 target_table ,相应的SQL为 :
update b.ecs_goods target_table ,a.ecs_goods source_table set target_table.shop_price = source_table.shop_price where source_table.goods_sn = target_table.goods_sn;
简单一句话:
支付通道一般都有两种通知应用程序支付结果,一个叫PDT,一个叫IPN,
有些名称不一定叫这个,但是一般来说,原理是一致的,我们这里采用的是Paypal 的叫法
PDT 就是所谓的客户端通过网页返回付款数据
IPN 就是服务器之间的数据通知,一般来说IPN 有重复通知的,如果没有通知到,可能回发出多次通知
而且一般来说 IPN 速度要快过 PDT,这就是为什么有些支付后,显示订单已经被处理过的情况,其实我们认为,好的程序设计只要采用IPN通知来处理付款后的逻辑,这样比较安全,而网页返回部分逻辑可以用,仅仅查看本系统内的订单支付状态,根据订单支付状态来告知客户是否已经支付成功,就不必去处理更改订单状态的逻辑部分。当然,万一IPN通知出现了延迟,那么可以告知客户过一会再看,不必多次支付,免得对一个订单多次支付。
在user.php 的注册成功信息显示前面,大概是 show_message(sprintf($_LANG['register_success'].............前面加入 注意下下面的 $bonus_type_id = 1; 需要先在后台加入对应的红包的id //phpsir 1111 $bonus_type_id=1; $bonus = $db->getRow('SELECT * FROM ' . $ecs->table("bonus_type") . " WHERE send_type = 0 And type_id = $bonus_type_id", true); if($bonus){ if(time()<($bonus['send_end_date']+28800)){ $sql = "INSERT INTO " . $ecs->table('user_bonus') . "(bonus_type_id, bonus_sn, user_id, used_time, order_id, emailed) " . "VALUES ('$bonus[type_id]', 0, '$_SESSION[user_id]', 0, 0, 0)"; $db->query($sql); } } //phpsir 1111_end
其实很简单,就一句话,见招拆招
假设php安装在c:\php,在cmd 里面测试php是否有配置问题,
c:\php\php.exe -i
看下是否有一些错误蹦出来
然后调整 php.ini ,把这些错误修正,over
朋友的phpcms 在sso 登陆设置中,出现通信失败,最终调试发现,服务器本机linux,无法访问本身域名的ip,这个vps是虚拟的ip,内部ip,蛋疼的是,他无法访问外部隐射ip,从而导致,file_get_contents(“http://域名/api.php………”);无法得到结果
解决方法是手动在本地 hosts 里面加入一行
10.0.8.99 www.domainname.com
也就是虚拟ip和域名的对应关系
程序无需修改,自动就通信成功了。
发现此类问题的服务器是 息壤VPS,不知道其他的VPS商是否也有此类问题,并且,是否如DiscuZ Ucenter 也会出现此类问题,不得而知,在此记录一下心得
curl -s http://XXXXXXXXXX/ | head -1 | sed -n l
curl -s http://XXXXXXXXXX/ | head -1 | hexdump -C
head 后面数字 1
sed 后面字母 L