예제 #1
0
 /**
  * 微信分享和卡劵使用的签名包
  * @param unknown $jsApiTicket
  * @return multitype:string NULL number unknown Ambigous <boolean, string> 
  */
 public function getSignPackage($jsApiTicket)
 {
     // 注意 URL 一定要动态获取,不能 hardcode.
     $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
     $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $timestamp = time();
     $nonceStr = random::word(16);
     // 这里参数的顺序要按照 key 值 ASCII 码升序排序
     $string = 'jsapi_ticket=%s&noncestr=%s&timestamp=%s&url=%s';
     $string = sprintf($string, $jsApiTicket, $nonceStr, $timestamp, $url);
     $signature = sha1($string);
     $signPackage = array("appId" => $this->_appid, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "signature" => $signature, "rawString" => $string);
     return $signPackage;
 }
예제 #2
0
파일: user.php 프로젝트: jin123456bat/home
 /**
  * 微信用户注册数据模型
  * @auth felixchen
  */
 function registerWeiXin($openid, $oid = NULL, $client = 'weixin', $usernam = '', $img = '')
 {
     $salt = random::word(6);
     $password = md5($openid . $salt);
     $regtime = $_SERVER['REQUEST_TIME'];
     $logtime = $regtime;
     $email = '';
     $money = 0;
     $score = 0;
     $close = 0;
     $ordernum = 0;
     $cost = 0;
     $gravatar = $img;
     $username = $usernam;
     $telephone = NULL;
     $array = array(NULL, $gravatar, $username, $telephone, $email, $password, $openid, $regtime, $logtime, $money, $score, $ordernum, $cost, $salt, $close, $oid, $client);
     if ($this->insert($array)) {
         return $this->lastInsertId();
     }
     return false;
 }
예제 #3
0
 /**
  * 随机生成一个优惠代码
  */
 function randomcode()
 {
     $couponModel = $this->model('coupon');
     $code = strtoupper(date('ymdHis', $_SERVER['REQUEST_TIME']) . random::word(6, '', random::RANDOM_WORD_NUMBER));
     while ($couponModel->exist($code)) {
         $code = strtoupper(date('ymdHis', $_SERVER['REQUEST_TIME']) . random::word(6, '', random::RANDOM_WORD_NUMBER));
     }
     return new json(json::OK, NULL, $code);
 }
예제 #4
0
 /**
  * 输出微信浏览器中的支付验证器
  */
 function output($prepay_id)
 {
     $data = array('appId' => $this->_system->get('appid', 'weixin'), 'timeStamp' => $_SERVER['REQUEST_TIME'], 'nonceStr' => random::word(32), 'package' => 'prepay_id=' . $prepay_id, 'signType' => 'MD5');
     $data['paySign'] = $this->sign($data);
     return $data;
 }