同一paypal 在多个ecshop站点使用代码修改

症状: 同一个paypal账号在多个ecshop 站点使用,出现paypal订单已经支付从而无法支付的状况

includes\modules\payment\paypal.php

修改 function get_code($order, $payment) 函数内

$data_order_id = $order['log_id'];
改为
$data_order_id = 'site2'. $order['log_id'];
修改 function respond() 函数内
$order_sn = substr($_POST['invoice'],5); // 5 是 'site2' 这5个字符的长度,要根据这个修改

ecshop 批量传相册 swfupload 插件

ecshop 相册不是太方便,可以用如下swfupload 批量上传

需要修改  admin/includes/lib_goods.php 的 handle_gallery_image 函数
另外修改下 admin/templates/goods_info.htm 加个到批量的链接

然后下载本插件,本插件为有偿差价,价格 100,可以联系QQ 733905 得到

视频地址

截屏如下

 

 

 

 

ecshop 后台登陆自动退出的一种可能情况,目录大小写,win 注意了

问题描述:
某客户的ecshop后台登陆后,显示成功,但是自动退出到登陆界面。
问题解决:
因为 windows 系统不区分目录大小写,而php是区分大小写的
那么 http://你的域名/admin/ 和 http://你的域名/Admin/ 就不一样

如果你用后者登陆系统,就会出现自动退出的情况
具体原因在 admin/includes/init.php 里面代码决定,

要求是 data/config.php 里面的 ADMIN_PATH 必须严格和你的登陆地址一致,包括大小写!!!

 

if ($_REQUEST['act'] != 'login' && $_REQUEST['act'] != 'signin' &&
    $_REQUEST['act'] != 'forget_pwd' && $_REQUEST['act'] != 'reset_pwd' && $_REQUEST['act'] != 'check_order')
{
    $admin_path = preg_replace('/:\d+/', '', $ecs->url()) . ADMIN_PATH;
    if (!empty($_SERVER['HTTP_REFERER']) &&
        strpos(preg_replace('/:\d+/', '', $_SERVER['HTTP_REFERER']), $admin_path) === false)
    {
        if (!empty($_REQUEST['is_ajax']))
        {
            make_json_error($_LANG['priv_error']);
        }
        else
        {
            ecs_header("Location: privilege.php?act=login\n");
        }

        exit;
    }
}

51ecshop助理登陆 ecshop 2.7.3 出错的修复

51EC助手, 提示:连接失败,请检查用户名是否正确。注:请不要使用中文密码!

ecaService.php 文件需要更新

function checkLogin($username, $password)
{
	$username = base64_decode($username);
	$password = base64_decode($password);

	//$username = str_iconv(ECS_CHARSET, EC_CHARSET, $username);
	//$password = str_iconv(ECS_CHARSET, EC_CHARSET, $password);

	//return true;
	$sql="SELECT `ec_salt` FROM ". $GLOBALS['ecs']->table('admin_user') ." WHERE user_name = '" . $username ."'";
	$ec_salt =$GLOBALS['db']->getOne($sql);

	$sql = "SELECT user_id, user_name, password, last_login, action_list, last_login".
			" FROM " . $GLOBALS['ecs']->table('admin_user') .
			" WHERE user_name = '" . $username. "' AND password = '" . md5(md5($password).$ec_salt). "'";

	$row = $GLOBALS['db']->getRow($sql);
	if ($row)
	{
		return true;
	}else{
		return false;
	}
}

					

ecshop:DEBUG_MODE在后台图片上传fckeditor的错误

因为 includes\fckeditor\editor\filemanager\connectors\php\upload.php 没有执行 init.php 所以 DEBUG_MODE变量没赋值,所以
导致 http://域名/includes/fckeditor/editor/filemanager/connectors/php/upload.php?Type=ImageImage 出错
显示为 lib_base.php 的read_static_cache 和 write_static_cache 函数为定义DEBUG_MODE 常量
所以保险的办法是在 upload.php 第一行加入

define(‘DEBUG_MODE’, 0);

这个错误的表现行为是: 上传图片可以正常上传,但是进度条图片一直滚动, 原因就是输出了错误提示,导致

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

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命名还算规范

 

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 对采用指定支付方式(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.