/** * 权限校验函数 */ function check_auth() { $license = get_shop_license(); // 取出网店 license信息 if (empty($license['certificate_id']) || empty($license['token']) || empty($license['certi'])) { api_err('0x006', 'no certificate'); //没有证书数据,输出系统级错误:用户权限不够 } if (!check_shopex_ac($_POST, $license['token'])) { api_err('0x009'); //输出系统级错误:签名无效 } /* 对应用申请的session进行验证 */ $certi['certificate_id'] = $license['certificate_id']; // 网店证书ID $certi['app_id'] = 'ecshop_b2c'; // 说明客户端来源 $certi['app_instance_id'] = 'webcollect'; // 应用服务ID $certi['version'] = VERSION . '#' . RELEASE; // 网店软件版本号 $certi['format'] = 'json'; // 官方返回数据格式 $certi['certi_app'] = 'sess.valid_session'; // 证书方法 $certi['certi_session'] = $_POST['app_session']; //应用服务器申请的session值 $certi['certi_ac'] = make_shopex_ac($certi, $license['token']); // 网店验证字符串 $request_arr = exchange_shop_license($certi, $license); if ($request_arr['res'] != 'succ') { api_err('0x001', 'session is invalid'); //输出系统级错误:身份验证失败 } }
/** * 功能:license 注册 * * @param array $certi_added 配置信息补充数组 array_key 登录信息的key;array_key => array_value; * @return array $return_array['flag'] = reg_succ、reg_fail、reg_ping_fail; * $return_array['request']; */ function license_reg($certi_added = '') { // 登录信息配置 $certi['certi_app'] = ''; // 证书方法 $certi['app_id'] = 'ecshop_b2c'; // 说明客户端来源 $certi['app_instance_id'] = ''; // 应用服务ID $certi['version'] = LICENSE_VERSION; // license接口版本号 $certi['shop_version'] = VERSION . '#' . RELEASE; // 网店软件版本号 $certi['certi_url'] = sprintf($GLOBALS['ecs']->url()); // 网店URL $certi['certi_session'] = $GLOBALS['sess']->get_session_id(); // 网店SESSION标识 $certi['certi_validate_url'] = sprintf($GLOBALS['ecs']->url() . 'certi.php'); // 网店提供于官方反查接口 $certi['format'] = 'json'; // 官方返回数据格式 $certi['certificate_id'] = ''; // 网店证书ID // 标识 $certi_back['succ'] = 'succ'; $certi_back['fail'] = 'fail'; // return 返回数组 $return_array = array(); if (is_array($certi_added)) { foreach ($certi_added as $key => $value) { $certi[$key] = $value; } } // 取出网店 license $license = get_shop_license(); // 注册 $certi['certi_app'] = 'certi.reg'; // 证书方法 $certi['certi_ac'] = make_shopex_ac($certi, ''); // 网店验证字符串 unset($certi['certificate_id']); $request_arr = exchange_shop_license($certi, $license); if (is_array($request_arr) && $request_arr['res'] == $certi_back['succ']) { // 注册信息入库 $sql = "UPDATE " . $GLOBALS['ecs']->table('shop_config') . "\n SET value = '" . $request_arr['info']['certificate_id'] . "' WHERE code = 'certificate_id'"; $GLOBALS['db']->query($sql); $sql = "UPDATE " . $GLOBALS['ecs']->table('shop_config') . "\n SET value = '" . $request_arr['info']['token'] . "' WHERE code = 'token'"; $GLOBALS['db']->query($sql); $return_array['flag'] = 'reg_succ'; $return_array['request'] = $request_arr; clear_cache_files(); } elseif (is_array($request_arr) && $request_arr['res'] == $certi_back['fail']) { $return_array['flag'] = 'reg_fail'; $return_array['request'] = $request_arr; } else { $return_array['flag'] = 'reg_ping_fail'; $return_array['request'] = array('res' => 'fail'); } return $return_array; }
/** * 功能:license 登录 * * @param array $certi_added 配置信息补充数组 array_key 登录信息的key;array_key => array_value; * @return array $return_array['flag'] = login_succ、login_fail、login_ping_fail、login_param_fail; * $return_array['request']; */ function license_login($certi_added = '') { // 登录信息配置 $certi['certi_app'] = ''; // 证书方法 $certi['app_id'] = 'ectouch_free'; // 说明客户端来源 $certi['app_instance_id'] = ''; // 应用服务ID $certi['version'] = LICENSE_VERSION; // license接口版本号 $certi['shop_version'] = VERSION . '#' . RELEASE; // 网店软件版本号 $certi['certi_url'] = sprintf(__URL__); // 网店URL $certi['certi_session'] = ECTouch::sess()->get_session_id(); // 网店SESSION标识 $certi['certi_validate_url'] = sprintf(__URL__ . url('api/certi')); // 网店提供于官方反查接口 $certi['format'] = 'json'; // 官方返回数据格式 $certi['certificate_id'] = ''; // 网店证书ID // 标识 $certi_back['succ'] = 'succ'; $certi_back['fail'] = 'fail'; // return 返回数组 $return_array = array(); if (is_array($certi_added)) { foreach ($certi_added as $key => $value) { $certi[$key] = $value; } } // 取出网店 license $license = model('LicenseBase')->get_shop_license(); // 检测网店 license if (!empty($license['certificate_id']) && !empty($license['token']) && !empty($license['certi'])) { // 登录 $certi['certi_app'] = 'certi.login'; // 证书方法 $certi['app_instance_id'] = 'cert_auth'; // 应用服务ID $certi['certificate_id'] = $license['certificate_id']; // 网店证书ID $certi['certi_ac'] = make_shopex_ac($certi, $license['token']); // 网店验证字符串 $request_arr = exchange_shop_license($certi, $license); if (is_array($request_arr) && $request_arr['res'] == $certi_back['succ']) { $return_array['flag'] = 'login_succ'; $return_array['request'] = $request_arr; } elseif (is_array($request_arr) && $request_arr['res'] == $certi_back['fail']) { $return_array['flag'] = 'login_fail'; $return_array['request'] = $request_arr; } else { $return_array['flag'] = 'login_ping_fail'; $return_array['request'] = array('res' => 'fail'); } } else { $return_array['flag'] = 'login_param_fail'; $return_array['request'] = array('res' => 'fail'); } return $return_array; }
/** * 功能:license 注册 * * @param array $certi_added 配置信息补充数组 array_key 登录信息的key;array_key => array_value; * @return array $return_array['flag'] = reg_succ、reg_fail、reg_ping_fail; * $return_array['request']; */ function license_reg($certi_added = '') { // 登录信息配置 $certi['certi_app'] = ''; // 证书方法 $certi['app_id'] = 'ectouch_free'; // 说明客户端来源 $certi['app_instance_id'] = ''; // 应用服务ID $certi['version'] = LICENSE_VERSION; // license接口版本号 $certi['shop_version'] = VERSION . '#' . RELEASE; // 网店软件版本号 $certi['certi_url'] = sprintf(__URL__); // 网店URL $certi['certi_session'] = ECTouch::sess()->get_session_id(); // 网店SESSION标识 $certi['certi_validate_url'] = sprintf(__URL__ . url('api/certi')); // 网店提供于官方反查接口 $certi['format'] = 'json'; // 官方返回数据格式 $certi['certificate_id'] = ''; // 网店证书ID // 标识 $certi_back['succ'] = 'succ'; $certi_back['fail'] = 'fail'; // return 返回数组 $return_array = array(); if (is_array($certi_added)) { foreach ($certi_added as $key => $value) { $certi[$key] = $value; } } // 取出网店 license $license = model('LicenseBase')->get_shop_license(); // 注册 $certi['certi_app'] = 'certi.reg'; // 证书方法 $certi['certi_ac'] = make_shopex_ac($certi, ''); // 网店验证字符串 unset($certi['certificate_id']); $request_arr = exchange_shop_license($certi, $license); if (is_array($request_arr) && $request_arr['res'] == $certi_back['succ']) { // 注册信息入库 $data['value'] = $request_arr['info']['certificate_id']; $condition['code'] = 'certificate_id'; model('Base')->table('touch_shop_config')->data($data)->where($condition)->update(); $data['value'] = $request_arr['info']['token']; $condition['code'] = 'certificate_id'; model('Base')->table('touch_shop_config')->data($data)->where($condition)->update(); $return_array['flag'] = 'reg_succ'; $return_array['request'] = $request_arr; clear_cache_files(); } elseif (is_array($request_arr) && $request_arr['res'] == $certi_back['fail']) { $return_array['flag'] = 'reg_fail'; $return_array['request'] = $request_arr; } else { $return_array['flag'] = 'reg_ping_fail'; $return_array['request'] = array('res' => 'fail'); } return $return_array; }
//收录商品详情 } else { $smarty->assign('msg', $request_arr['info']); //提示信息 $smarty->assign('case', 0); //开通服务页面 } } else { $smarty->assign('msg', $_LANG['no-open']); //提示信息 $smarty->assign('case', 0); //开通服务页面 } //合作网站列表 $certi['certi_app'] = 'co.show_se'; // 证书方法 $certi['certi_ac'] = make_shopex_ac($certi, $license['token']); // 网店验证字符串 $request_arr = exchange_shop_license($certi, $license, 1); if ($request_arr['res'] == 'succ') { $smarty->assign('site_arr', $request_arr['info']['se']); } else { $smarty->assign('site_msg', $request_arr['info']); } } else { $smarty->assign('msg', $_LANG['no-open']); //提示信息 $smarty->assign('case', 0); //开通服务页面 } $smarty->display('webcollect.htm');