ecshop的ucenter同步登陆uc.php 一点错误勘误

在ecshop的会员整合ucenter的set_cookie函数有问题
文件在 /api/uc.php 搜索 set_cookie

function set_cookie($user_id=”, $user_name = ”, $email = ”)
{
if (empty($user_id))
{
/* 摧毁cookie */
$time = time() – 3600;
setcookie(‘ECS[user_id]’, ”, $time);//这里有问题
setcookie(‘ECS[username]’, ”, $time);//这里有问题
setcookie(‘ECS[email]’, ”, $time);//这里有问题
}
else
{
/* 设置cookie */
$time = time() + 3600 * 24 * 30;
setcookie(“ECS[user_id]”, $user_id, $time, $GLOBALS[‘cookie_path’], $GLOBALS[‘cookie_domain’]);
setcookie(“ECS[username]”, $user_name, $time, $GLOBALS[‘cookie_path’], $GLOBALS[‘cookie_domain’]);
setcookie(“ECS[email]”, $email, $time, $GLOBALS[‘cookie_path’], $GLOBALS[‘cookie_domain’]);
}
}

因为假设这样的架构
http://域名/ 是 ecshop ,http://域名/bbs/ 为论坛dzX2, 那么,在ec登陆后,dzX2 点退出,
会发送一个javascript申请到 /api/uc.php的 logout请求 ( 如果setcookie 只是在 /api/ 下 设置cookie 为空,那么就清空不了cookie
严格的应该是
setcookie(‘ECS[user_id]’, ”, $time,$GLOBALS[‘cookie_path’], $GLOBALS[‘cookie_domain’]);

那么代码可以修改为

还有要修改ecshop的 ucenter插件,includes/modules/integrates/ucenter.php
如图两部分


另外还要看 这一篇
/ucenter-sync.html

phpwind 的一个小错误导致cookie失效的解决,表象是无法注册登录

一个phpwind 8.0 utf8 系统错误表现为无法注册登录,费老劲调试,发现 data/sql_config.php 文件由于在windows 记事本编辑后导致被自动增加了bom ,前端cookie 输出因为bom 的 原因,导致浏览器无法生成cookie,从而无法登录和注册

在editplus 另存成utf-8 无bom ,上传问题解决

参看 /ecshop-utf8-bom.html

总结: 要多用 linux curl 去查看文件输出

 

ecshop系列:后台导出程序错误,ecshop应该认错

今天一个客户给我发来ecshop后台导出出现

ERROR 1052 (23000): Column ‘brand_id’ in where clause is ambiguous

经查发现是不同表存在相同字段而在where 语句中未区分造成

测试运行语句

SELECT g.*, b.brand_name as brandname FROM `usason`.`ecs_goods` AS g LEFT JOIN `usason`.`ecs_brand` AS b ON g.brand_id = b.brand_id WHERE is_delete = 0 AND brand_id = ’17’;

修改为

SELECT g.*, b.brand_name as brandname FROM `usason`.`ecs_goods` AS g LEFT JOIN `usason`.`ecs_brand` AS b ON g.brand_id = b.brand_id WHERE is_delete = 0 AND g.brand_id = ’17’;

红色部分注意

那么就只有去查后台程序代码了

发现在admin/includes/lib_main.php 的get_where_sql($filter)的函数中出现了

$where .= isset($filter->brand_id) && $filter->brand_id > 0 ? ” AND brand_id = ‘” . $filter->brand_id . “‘” : ”;

修改为

$where .= isset($filter->brand_id) && $filter->brand_id > 0 ? ” AND g.brand_id = ‘” . $filter->brand_id . “‘” : ”;

问题解决

目前还不知道有其他副作用

好在ecshop命名还算规范

 

phpwind 批量上传解决一例,上传后文件列表消失,mbstring 问题

朋友网站phpwind 7.5 sp3出现批量上传文件后上传文件的列表消失,但是文件已经上传上去了,调试后发现没有写入数据库

跟踪代码在 lib/upload/mutiupload.class.php 文件的update函数中加入调试语句,确认没有写入数据库 ,

原因是 $value[‘name’] = pwConvert($value[‘name’], $db_charset, ‘utf-8’); 行有错

经调试 pwConvert 是因为 php没有启用 mbstring 造成,启用后,问题解决

 

ecshop系列:二次开发,扩展分类商品后置

ecshop 的商品是可以属于多个分类,在内部称谓是扩展分类,被记录到ecs_goods_cat 表
现在需求是将某个分类category.php?id=某某的商品列表中含有扩展分类的商品后置
思路: 首先找到存在扩展属性的商品id,形成数组,然后在 $arr 变量里面查找后unset数组的部分key,
并附加array_merge到原来的$arr后

修改category.php 的 category_get_goods 函数
代码如图:

ecshop系列:购买商品增加留言备注功能

在购买商品时候增加对此商品购买的留言备注功能
如图:

开发方法如下:
1) 在goods.dwt 里面加留言字段

2)修改 js/common.js 里面的addToCart 函数

3)修改flow.php 里面关于 if ($_REQUEST[‘step’] == ‘add_to_cart’) 的处理部分

4)修改includes/lib_order.php 里面的 addto_cart 函数

 

首先修改函数定义

其次修改内容

至此增加memo部分完成,下面是在flow.php 购物车里面显示此留言
5)修改 flow.dwt

ecshop系列:一行代码解决财付通3006错

问题描述:
修改价格后再次点击使用财付通支付时出现“[3006]您的请求无效,请重新再试。”
解决方案
\includes\modules\payment\tenpay.php 行 104
原来的为
$bill_no = str_pad($order[‘log_id’], 10, 0, STR_PAD_LEFT);
现在修改为
$bill_no = str_pad(rand(1,99),2,0,STR_PAD_LEFT).str_pad($order[‘log_id’], 8, 0, STR_PAD_LEFT);
问题解决
点击下图看大图

ecshop系列:search的静态化

一般说来搜索的结果静态化可以持久的保持搜索结果,给客户良好的印象

ecshop 的搜索结果是 search.php?encode=base64编码字符串

我们希望用 /search_搜索关键字_p页码.html 来做静态优化

那么方法是什么呢:

首先写 .htaccess 文件

RewriteRule ^search_(.+?)_p([0-9]+).html$  search2\.php\?keywords=$1&page=$2 [QSA,L]

我们复制 search.php 成 search2.php 注释掉行18-行66

然后加入

 $string["keywords"]=addslashes($_GET["keywords"]); 

 $string["page"]=addslashes($_GET["page"]); 

 $string["search_encode_time"] = $_SERVER["REQUEST_TIME"];

测试 http://域名/search_关键字_p1.html
如果和 http://域名/search2.php?keywords=关键字&page=1
的结果一致
然后我们去修改页码处的连接
行 501

$pager = get_pager2('search_', $pager['search'], $count, $page, $size);

在include/lib_main.php 里面 复制get_pager 函数成 get_pager2
然后修改成如下

 $url_format = $url . $param_url . 'page=';
        $url_format2 = $url . $param['keywords'] . '_p';
        $pager['page_first'] = ($page - $_offset > 1 && $_pagenum < $page_count) ? $url_format2 . "1.html" : '';
        $pager['page_prev']  = ($page > 1) ? $url_format2 . $page_prev.".html" : '';
        $pager['page_next']  = ($page < $page_count) ? $url_format2 . $page_next.".html" : '';
        $pager['page_last']  = ($_to < $page_count) ? $url_format2 . $page_count.".html" : '';
        $pager['page_kbd']  = ($_pagenum < $page_count) ? true : false;
        $pager['page_number'] = array();
        for ($i=$_from;$i<=$_to;++$i)
        {
            $pager['page_number'][$i] = $url_format2 . $i.".html";
        }

ecshop 对采用指定支付方式(alipay,tenpay)增加积分的修改

进入后台 SQL查询

INSERT INTO `你的前缀_shop_config` (`parent_id`, `code`, `type`, `store_range`, `store_dir`, `value`, `sort_order` ) VALUES   ( ‘2’, ‘onlinepay_points’, ‘text’, ”, ”, ‘100’, ‘1’);

在后台 商店设置->基本设置->会出现 onlinepay_points 为100的项目

respond.php  修改如下

$payment = new $pay_code();
$pay_result = $payment->respond();
$msg     = $pay_result ? $_LANG[‘pay_success’] : $_LANG[‘pay_fail’];
if($pay_result){
if($pay_code == “alipay” || $pay_code == “tenpay” || $pay_code == “chinabank” ){
log_account_change($_SESSION[‘

user_id’], 0, 0, $GLOBALS[‘_CFG’][‘onlinepay_points’], $GLOBALS[‘_CFG’][‘onlinepay_points’],”会员在线支付送”.$GLOBALS[‘_CFG’][‘onlinepay_points’].”积分”);
}
}

ecshop的支付宝alipay免掉单接口,最新版,采用服务器间通知模式

问题描述:

ecshop 在启用支付宝 alipay 支持方式 后,通过支付宝付费返回网站发生fail 错误,而支付宝已经扣费的问题

解决方案:

通过修改支付宝支付插件,结合支付宝特有的服务器间对账功能,彻底免除掉单烦恼,减少客服工作量。

联系方式: QQ  733905

费用 300元

功能:

1) 解决ecshop 支付宝插件返回时候显示付费不成功
2) 解决支付宝异步同步,彻底解除掉单困扰,省客服工作量
3) gbk utf-8 双版本

ecshop 验证码不显示的解决方案

问题都是一个,结论总是奇形怪状.
状况: ecshop 验证码不显示

1) 原因1: 有客户试图用前台英文后台中文模式工作,他就仿照一些方法,覆盖了语言文件
导致一些CFG 后台设置的变量无法读取,
解决方法,修改 captcha.php 文件,不包含 init.php, 然后手动传入宽高变量
首先定义 ROOT_PATH
define(‘ROOT_PATH’, “绝对路径”);
然后
$img = new captcha(ROOT_PATH . ‘data/captcha/’, $_CFG[‘captcha_width’], $_CFG[‘captcha_height’]);
变为
$img = new captcha(ROOT_PATH . ‘data/captcha/’, 100, 20);

2) 原因2,修改了某些utf-8文件,结果保存成 utf-8+ 也就是传说中的 utf-8 with bom
解决方法,找到对应文件,应 editplus 重新保存成 utf-8 无bom

ecshop系列:同步ucenter,一步登陆discuzX

看到太多的各类系统整合ucenter出现的各种各样的问题,比如无法同步登入,同步退出,注册用户时候出现问题

研读过ucenter 的原理后,再结合测试 ucenter + modoer + discuz X 1.5 + ecshop 2.7.2 实现了完美的同步登入和退出

发现一个简单的方法就是,把ucenter 的data/cache/apps.php 文件复制到各个系统的 uc_client/data/cache/apps.php

就可以解决大半的同步问题
检查过上面问题后,再检查各个系统的关于ucenter 的配置处,确保key和uc里面的一致,然后清空各系统缓存,测试

另外还要看 这一篇
/ecshop-api-uc.html

 

paypal ipn的精髓 关于ecshop 的paypal 贝宝支付模块错误的问题

With IPN the code will run regardless of whether or not the  buyer reaches your final checkout page or not.   Again, it is server-to-server communication and is entirely separate  from the user’s interaction with your application.

翻译来的意思就是
ipn 代码不管客户端(浏览器) 购买者是否到达最终的反馈页面,IPN是服务器到服务器端的通信,IPN完全独立于用户浏览器和网站应用程序之间的交互(指购买者浏览器和商品网站)

如下文章可以解释的很清晰 IPN 和 PDT 的区别了

一句话解释就是 PDT 是依靠客户浏览器返回到商品网站来确认付款成功,而IPN则可独立于浏览器和服务器之间,IPN 是端到端(Paypal 到 网站) 的沟通,他可防止所谓的掉单现象的发生,对于一些需要自动化的任务有较好的效果,(比如游戏币的自动发卡,自动充值)。

看图

英文的

详细的上下文如下https://www.x.com/docs/DOC-2502
中文说明在
http://paypal.ebay.cn/integrationcenter/list__resource_2.html

How is IPN Different from PDT?

I’d like to backup just a little bit now and discuss some of  the differences between Instant Payment Notification (IPN) and Payment Data  Transfer (PDT).  They are very similar in  the way they work so if you’re already familiar with PDT you may feel right at  home with IPN.  There is really one major  difference that is very important to understand.

PDT was designed with one simple goal in mind: provide  transaction data to checkout systems using Payments Standard so that it can be  displayed on the merchant’s “thank you” or “completed” page.  When utilizing PDT you have the option of data  being returned as form data (POST) or as URL parameters (GET).  You can then build your thank you page in a  dynamic fashion so that users can print the page as a receipt, simply save it  for their records, etc.  It is a very  useful tool when this is necessary, however, you cannot rely on PDT for  automating tasks because there is no guarantee that the user will ever make it  to your “thank you” page when working with PayPal Standard Payments.  Even with Auto-Return enabled in your PayPal  profile the user could close the browser before being redirected and the code  on your thank you page will never run.

With IPN the code will run regardless of whether or not the  buyer reaches your final checkout page or not.   Again, it is server-to-server communication and is entirely separate  from the user’s interaction with your application.  Once that transaction is complete the data  will be sent to your IPN listener and will be handled accordingly.  This is why it is highly recommended you  utilize Instant Payment Notification instead of Payment Data Transfer when  automating tasks on the back-end.

eaccelerator not install 问题解决思路一例

一句话说就是
妈的,默认没开启 eAccelerator_get  和 eAccelerator_put
这个链接 http://eaccelerator.net/ticket/37 是说明

这里人解释的更清晰了
http://www.vbseo.com/blogs/danny-bembibre/enable-caching-functions-get-put-eaccelerator-45/

翻译成中国话就是

现在默认禁用了 eAccelerator_get  和 eAccelerator_put
想启用就加
–with-eaccelerator-shared-memory

共勉吧 php兄弟们

例子来源于我在给一个朋友配置服务器时候 一个电影程序 skyuc 的缓存需要配置 datastore_eaccelerator
而此程序检测 eAccelerator_get 函数是否存在以判断 eaccelerator 是否安装,
在phpinfo 里面即使看到了 eaccelerator ,仍然导致程序失败,调试后发现此原因.

另外发现 0.9.6 的eaccelerator 似乎即使加了这个也不好使,只能降级用 0.9.5 版本的eaccelerator

php程序之die调试法

经常看到有初入PHP道朋友对于php程序出现问题素手无策的情况
这是稍微有经验的phper 都会采用如下方式来解决问题
1. 看错误输出, 从输出项 反查源码,在源码处上下文加入调试代码,代码可以是最简单的
$debuglineno =  __LINE__;
die($debuglineno);
2. 根据错误输出  Google 之 或者 百度一下

错误的做法:
1. 直接问你的上级,或者同事
2. 直接!上论坛求助 而不是首先经过自己排查
3. 不去分析问题,而是发牢骚