public static function start($uniacid, $openid, $expire = 3600) { WeSession::$uniacid = $uniacid; WeSession::$openid = $openid; WeSession::$expire = $expire; $sess = new WeSession(); session_set_save_handler(array(&$sess, 'open'), array(&$sess, 'close'), array(&$sess, 'read'), array(&$sess, 'write'), array(&$sess, 'destroy'), array(&$sess, 'gc')); session_start(); }
public static function start($uniacid, $openid, $expire = 3600) { if (empty($GLOBALS['_W']['config']['setting']['memcache']['session'])) { WeSession::$uniacid = $uniacid; WeSession::$openid = $openid; WeSession::$expire = $expire; $sess = new WeSession(); session_set_save_handler(array(&$sess, 'open'), array(&$sess, 'close'), array(&$sess, 'read'), array(&$sess, 'write'), array(&$sess, 'destroy'), array(&$sess, 'gc')); register_shutdown_function('session_write_close'); } session_start(); }
public function start() { global $_W; if (empty($this->account)) { exit('Miss Account.'); } if (!$this->account->checkSign()) { exit('Check Sign Fail.'); } if (strtolower($_SERVER['REQUEST_METHOD']) == 'get') { $row = array(); $row['isconnect'] = 1; pdo_update('account', $row, array('acid' => $_W['acid'])); exit($_GET['echostr']); } if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $postStr = file_get_contents('php://input'); if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { $postStr = $this->account->decryptMsg($postStr); } $message = $this->account->parse($postStr); $this->message = $message; if (empty($message)) { WeUtility::logging('waring', 'Request Failed'); exit('Request Failed'); } $_W['openid'] = $message['from']; $_W['fans'] = array('from_user' => $_W['openid']); $this->booking($message); if ($message['event'] == 'unsubscribe') { $this->receive(array(), array(), array()); exit; } $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']); session_id($sessionid); WeSession::start($_W['uniacid'], $_W['openid']); $_SESSION['openid'] = $_W['openid']; WeUtility::logging('trace', $message); $pars = $this->analyze($message); $pars[] = array('message' => $message, 'module' => 'default', 'rule' => '-1'); $hitParam['rule'] = -2; $hitParam['module'] = ''; $hitParam['message'] = $message; $hitKeyword = array(); $response = array(); foreach ($pars as $par) { if (empty($par['module'])) { continue; } $par['message'] = $message; $response = $this->process($par); if ($this->isValidResponse($response)) { $hitParam = $par; if (!empty($par['keyword'])) { $hitKeyword = $par['keyword']; } break; } } if ($hitParam['module'] == 'default' && is_array($response) && is_array($response['params'])) { foreach ($response['params'] as $par) { if (empty($par['module'])) { continue; } $response = $this->process($par); if ($this->isValidResponse($response)) { $hitParam = $par; if (!empty($par['keyword'])) { $hitKeyword = $par['keyword']; } break; } } } WeUtility::logging('params', $hitParam); WeUtility::logging('response', $response); $resp = $this->account->response($response); $resp = $this->clip($resp, $hitParam); if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { $resp = $this->account->encryptMsg($resp); $resp = $this->account->xmlDetract($resp); } echo $resp; ob_flush(); flush(); $this->receive($hitParam, $hitKeyword, $response); ob_end_clean(); exit; } WeUtility::logging('waring', 'Request Failed'); exit('Request Failed'); }
} echo $exit; exit; } if ($do == 'end') { $fanid = intval($_GPC['fanid']); $fans = pdo_fetch('SELECT fanid,acid,openid FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND fanid = :id', array(':uniacid' => $_W['uniacid'], ':id' => $fanid)); $account = account_fetch($fans['acid']); $message['from'] = $_W['openid'] = $fans['openid']; $message['to'] = $account['original']; if (!empty($message['to'])) { $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']); load()->classs('wesession'); load()->classs('account'); session_id($sessionid); WeSession::start($_W['uniacid'], $_W['openid'], 300); $processor = WeUtility::createModuleProcessor('chats'); $processor->end(); } if (!empty($_GPC['from'])) { $url = base64_decode($_GPC['from']); } else { $url = url('mc/fans/', array('acid' => $fans['acid'])); } header('Location:' . $url); exit; } function iurldecode($str) { if (!is_array($str)) { return urldecode($str);
protected function refreshContext($expire = 1800) { if (!$this->inContext) { return false; } $expire = intval($expire); WeSession::$expire = $expire; $_SESSION['__contextexpire'] = TIMESTAMP + $expire; return true; }
if (isset($_GPC['state']) && !empty($_GPC['state']) && strexists($_GPC['state'], 'we7sid-')) { $pieces = explode('-', $_GPC['state']); $_W['session_id'] = $pieces[1]; unset($pieces); } if (empty($_W['session_id'])) { $_W['session_id'] = $_COOKIE[session_name()]; } if (empty($_W['session_id'])) { $_W['session_id'] = "{$_W['uniacid']}-" . random(20); $_W['session_id'] = md5($_W['session_id']); setcookie(session_name(), $_W['session_id']); } session_id($_W['session_id']); load()->classs('wesession'); WeSession::start($_W['uniacid'], CLIENT_IP); if (empty($_W['acid'])) { $_W['acid'] = intval($_GPC['j']); } if (empty($_W['acid']) && !empty($_SESSION['acid'])) { $_W['acid'] = intval($_SESSION['acid']); } if (!empty($_W['acid'])) { $_W['account'] = account_fetch($_W['acid']); if (empty($_W['account']) || intval($_W['account']['uniacid']) != intval($_W['uniacid'])) { $_W['acid'] = 0; $_W['account'] = null; } } if (empty($_W['account'])) { $accounts = uni_accounts();
$_W['session_id'] = ''; if (isset($_GPC['state']) && !empty($_GPC['state']) && strexists($_GPC['state'], 'we7sid-')) { $pieces = explode('-', $_GPC['state']); $_W['session_id'] = $pieces[1]; unset($pieces); } if (empty($_W['session_id'])) { $_W['session_id'] = $_COOKIE[session_name()]; } if (empty($_W['session_id'])) { $_W['session_id'] = "{$_W['uniacid']}-" . random(20); $_W['session_id'] = md5($_W['session_id']); } session_id($_W['session_id']); load()->classs('wesession'); WeSession::start($_W['uniacid'], 'APP'); if (empty($_W['acid']) && !empty($_SESSION['acid'])) { $sql = 'SELECT * FROM ' . tablename('account') . ' WHERE `uniacid`=:uniacid AND `acid`=:acid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':acid'] = $_SESSION['acid']; if (pdo_fetch($sql, $pars)) { $_W['acid'] = $_SESSION['acid']; } } if (!empty($_SESSION['openid'])) { $_W['openid'] = $_SESSION['openid']; $where = ' WHERE `uniacid`=:uniacid AND `openid`=:openid '; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':openid'] = $_W['openid'];
<?php /** * 微小区模块 * * [晓锋] Copyright (c) 2013 qfinfo.cn */ /** * 注册短信验证 */ load()->classs('wesession'); defined('IN_IA') or exit('Access Denied'); global $_GPC, $_W; WeSession::start($_W['uniacid'], $_W['fans']['from_user'], 60); $mobile = $_GPC['mobile']; if ($_GPC['type'] == 'verify') { $member = pdo_fetch("select * from" . tablename("xcommunity_member") . "where weid='{$_W['uniacid']}' and mobile=:mobile", array(':mobile' => $mobile)); } else { $member = pdo_fetch("select * from" . tablename("xcommunity_business") . "where weid='{$_W['uniacid']}' and mobile=:mobile", array(':mobile' => $mobile)); } if (!empty($member)) { message('该号码已经注册,请更换号码,重新注册', referer(), 'success'); exit; } if ($mobile == $_SESSION['mobile']) { $code = $_SESSION['code']; } else { $code = random(6, 1); $_SESSION['mobile'] = $mobile; $_SESSION['code'] = $code; }
<?php /** * 详情 * * @author 超级无聊 * @url */ WeSession::$expire = 600; WeSession::start(); if (isset($_SESSION['code'])) { $code = $_SESSION['code']; } else { $code = random(6, 1); $_SESSION['code'] = $code; } $data = array('errno' => 0, 'code' => $code); echo json_encode($data);
public function start() { global $_W; if (empty($this->account)) { exit('Miss Account.'); } if (!$this->account->checkSign()) { exit('Check Sign Fail.'); } if (strtolower($_SERVER['REQUEST_METHOD']) == 'get') { $row = array(); $row['isconnect'] = 1; pdo_update('account', $row, array('acid' => $_W['acid'])); exit(htmlspecialchars($_GET['echostr'])); } if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $postStr = file_get_contents('php://input'); if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { $postStr = $this->account->decryptMsg($postStr); } WeUtility::logging('trace', $postStr); $message = $this->account->parse($postStr); $this->message = $message; if (empty($message)) { WeUtility::logging('waring', 'Request Failed'); exit('Request Failed'); } $_W['openid'] = $message['from']; $_W['fans'] = array('from_user' => $_W['openid']); $this->booking($message); if ($message['event'] == 'unsubscribe') { $this->receive(array(), array(), array()); exit; } $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']); session_id($sessionid); WeSession::start($_W['uniacid'], $_W['openid']); $_SESSION['openid'] = $_W['openid']; $pars = $this->analyze($message); $pars[] = array('message' => $message, 'module' => 'default', 'rule' => '-1'); $hitParam['rule'] = -2; $hitParam['module'] = ''; $hitParam['message'] = $message; $hitKeyword = array(); $response = array(); foreach ($pars as $par) { if (empty($par['module'])) { continue; } $par['message'] = $message; $response = $this->process($par); if ($this->isValidResponse($response)) { $hitParam = $par; if (!empty($par['keyword'])) { $hitKeyword = $par['keyword']; } break; } } $response_debug = $response; $pars_debug = $pars; if ($hitParam['module'] == 'default' && is_array($response) && is_array($response['params'])) { foreach ($response['params'] as $par) { if (empty($par['module'])) { continue; } $response = $this->process($par); if ($this->isValidResponse($response)) { $hitParam = $par; if (!empty($par['keyword'])) { $hitKeyword = $par['keyword']; } break; } } } WeUtility::logging('params', $hitParam); WeUtility::logging('response', $response); $resp = $this->account->response($response); if (!empty($_GET['encrypt_type']) && $_GET['encrypt_type'] == 'aes') { $resp = $this->account->encryptMsg($resp); $resp = $this->account->xmlDetract($resp); } if ($_W['debug']) { $_W['debug_data'] = array('resp' => $resp, 'is_default' => 0); if (count($pars_debug) == 1) { $_W['debug_data']['is_default'] = 1; $_W['debug_data']['params'] = $response_debug['params']; } else { array_pop($pars_debug); $_W['debug_data']['params'] = $pars_debug; } $_W['debug_data']['hitparam'] = $hitParam; $_W['modules']['cover'] = array('title' => '入口封面', 'name' => 'cover'); load()->web('template'); $process = template('utility/emulator', TEMPLATE_FETCH); echo json_encode(array('resp' => $resp, 'process' => $process)); exit; } ob_start(); echo $resp; ob_start(); $this->receive($hitParam, $hitKeyword, $response); ob_end_clean(); exit; } WeUtility::logging('waring', 'Request Failed'); exit('Request Failed'); }
public function payResult($params) { global $_W; WeSession::start($_W['uniacid'], $_W['fans']['from_user'], 60); $fee = intval($params['fee']); $data = array('status' => $params['result'] == 'success' ? 1 : 0); $paytype = array('credit' => '1', 'wechat' => '2', 'alipay' => '2', 'delivery' => '3'); $data['paytype'] = $paytype[$params['type']]; if ($params['type'] == 'wechat') { $data['transid'] = $params['tag']['transaction_id']; } //判断是否是缴纳物业费用 if ($_SESSION['type'] == 'profree') { pdo_update('xcommunity_propertyfree', array('status' => 1), array('id' => $params['tid'])); if ($params['from'] == 'return') { if ($params['type'] == $credit) { message('缴费成功!', $this->createMobileUrl('propertyfree', array('op' => 'display')), 'success'); } else { message('缴费成功!', '../../app/' . $this->createMobileUrl('propertyfree', array('op' => 'display')), 'success'); } } exit; } if ($params['type'] == 'delivery') { $data['status'] = 1; } $sql = 'SELECT `goodsid` FROM ' . tablename('xcommunity_shopping_order_goods') . ' WHERE `orderid` = :orderid'; $goodsId = pdo_fetchcolumn($sql, array(':orderid' => $params['tid'])); $sql = 'SELECT `total`, `totalcnf` FROM ' . tablename('xcommunity_shopping_goods') . ' WHERE `id` = :id'; $goodsInfo = pdo_fetch($sql, array(':id' => $goodsId)); // 更改库存 if ($goodsInfo['totalcnf'] == '1' && !empty($goodsInfo['total'])) { pdo_update('xcommunity_shopping_goods', array('total' => $goodsInfo['total'] - 1), array('id' => $goodsId)); } pdo_update('xcommunity_shopping_order', $data, array('id' => $params['tid'])); if ($params['from'] == 'return') { //积分变更 $this->setOrderCredit($params['tid']); //邮件提醒 if (!empty($this->module['config']['noticeemail'])) { $order = pdo_fetch("SELECT `price`, `paytype`, `from_user`, `addressid` FROM " . tablename('xcommunity_shopping_order') . " WHERE id = '{$params['tid']}'"); $ordergoods = pdo_fetchall("SELECT goodsid, total FROM " . tablename('xcommunity_shopping_order_goods') . " WHERE orderid = '{$params['tid']}'", array(), 'goodsid'); $goods = pdo_fetchall("SELECT id, title, thumb, marketprice, unit, total FROM " . tablename('xcommunity_shopping_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')"); $address = pdo_fetch("SELECT * FROM " . tablename('xcommunity_shopping_address') . " WHERE id = :id", array(':id' => $order['addressid'])); $body = "<h3>购买商品清单</h3> <br />"; if (!empty($goods)) { foreach ($goods as $row) { $body .= "名称:{$row['title']} ,数量:{$ordergoods[$row['id']]['total']} <br />"; } } $paytype = $order['paytype'] == '3' ? '货到付款' : '已付款'; $body .= "<br />总金额:{$order['price']}元 ({$paytype})<br />"; $body .= "<h3>购买用户详情</h3> <br />"; $body .= "真实姓名:{$address['realname']} <br />"; $body .= "地区:{$address['province']} - {$address['city']} - {$address['area']}<br />"; $body .= "详细地址:{$address['address']} <br />"; $body .= "手机:{$address['mobile']} <br />"; load()->func('communication'); ihttp_email($this->module['config']['noticeemail'], '微商城订单提醒', $body); } $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credit = $setting['creditbehaviors']['currency']; if ($params['type'] == $credit) { message('支付成功!', $this->createMobileUrl('shopping', array('op' => 'myorder')), 'success'); } else { message('支付成功!', '../../app/' . $this->createMobileUrl('shopping', array('op' => 'myorder')), 'success'); } } }