<?php require_once 'filter.php'; require_once 'shake.php'; $shake = new Shake(); $code = $_GET["code"]; //用此值进行下一步操作,可以获取openid $timestamp = time(); if ($code) { //setcookie("openid",$openid ,time()+60*60*24*365); $encode_auth_key = $config['hx_auth_key']; $get_token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $config["appid"] . '&secret=' . $config["secret"] . '&code=' . $code . '&grant_type=authorization_code'; $res = @file_get_contents($get_token_url); $json_obj = json_decode($res, true); if (!$json_obj && !is_array($json_obj)) { // header('location:http://weilink.huaxi100.com/hxdsb/hxsd/error.html'); echo "授权失败"; exit; } if ($json_obj["errcode"] != 0) { echo "授权失败"; error_log($json_obj["errcode"] . "|", 3, "auth_log.txt"); // header('Location:http://weilink.huaxi100.com/hxdsb/'); exit; } //根据openid和access_token查询用户信息 $access_token = $json_obj['access_token']; $refresh_token = $json_obj['refresh_token']; $expires_in = $json_obj['expires_in']; $openid = $json_obj['openid']; $get_user_info_url = 'https://api.weixin.qq.com/sns/userinfo?access_token=' . $access_token . '&openid=' . $openid . '&lang=zh_CN';
<?php require_once "filter.php"; require_once "shake2.php"; $shake = new Shake(); $uid = $_COOKIE[USER_COOKIE_ID]; //$config['redirect_uri'] = 'http://www.hx028.net/weixin-shake/xiangjiang2.0/callback.php'; $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $config["appid"] . '&redirect_uri=' . htmlspecialchars($config["redirect_uri"]) . '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'; if ($uid) { $user = $shake->getUser($uid, $config['appid']); if (!$user || $user['expiretime'] < time()) { //用户不存在或者过期 header("Location:" . $url); exit; } } else { header("Location:" . $url); exit; } //判断活动是否开始 date_default_timezone_set('Asia/Shanghai'); $current_time = time(); $current_day = intval(date("d", $current_time)); $current_hour = intval(date("H", $current_time)); $current_month = intval(date("m", $current_time)); $has_start = true; if (8 != $current_month) { $has_start = false; } if (!in_array($current_day, array(1, 2, 3, 5))) { $has_start = false;
<?php require_once 'filter.php'; require_once 'shake.php'; $action = $_GET['a']; $shake = new Shake(); switch ($action) { case "prize_change": header("Content-type:text/html;charset=utf-8"); if ("xjcbd321654" != $_POST['change_pass']) { echo "<script>window.alert('商家兑换密码输入有误!');" . "window.location.href='http://weilink.huaxi100.com/spe/weixin-shake/my_coupons.php';</script>"; exit; } $ids = $_POST['ids']; $success = $shake->change($ids); if ($success) { echo "<script>window.alert('兑换成功!');" . "window.location.href='http://weilink.huaxi100.com/spe/weixin-shake/my_coupons.php';</script>"; exit; } else { echo "<script>window.alert('兑换失败!');" . "window.location.href='http://weilink.huaxi100.com/spe/weixin-shake/my_coupons.php';</script>"; exit; } break; case "shake": $id = $_GET['id']; $shake->record_shake_time($id); break; case "contact": $id = $_POST['id']; $name = $_POST['name']; $phone = $_POST['phone'];
<?php require_once 'filter.php'; require_once 'shake2.php'; $action = $_GET['a']; $shake = new Shake($config); switch ($action) { case "get_prize": $uid = $_COOKIE[USER_COOKIE_ID]; if ('frank' == $_GET['test']) { $uid = '9fd4eda2fb47e99e6daa206cc325bd9b'; } $user = $shake->getUser($uid, $config['appid']); if (!$user) { echo json_encode(array('type' => -2, 'prize' => '用户信息读取失败')); exit; } $wecha_id = $user['openid']; // array($type,$prize) $type -1:活动暂未开始, 0:什么也没中,1:现金红包,2:购物卡,3:参与次数用完 list($type, $prize) = $shake->get_user_prize($wecha_id); echo json_encode(array('type' => $type, 'prize' => $prize)); break; }
<?php require_once("filter.php"); require_once("shake.php"); $shake = new Shake(); $uid=$_COOKIE[USER_COOKIE_ID]; $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$config["appid"].'&redirect_uri='.htmlspecialchars($config["redirect_uri"]).'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'; if($uid){ $user = $shake->getUser($uid,$config['appid']); if(!$user||$user['expiretime']<time()){//用户不存在或者过期 header("Location:".$url); exit; } }else{ header("Location:".$url); exit; } $openid = $user['openid']; $list = $shake->getPrizeList($openid); date_default_timezone_set('Asia/Shanghai'); ?> <!DOCTYPE html> <html> <head lang="en"> <meta http-equiv="Content-Type"> <meta content="text/html; charset=utf-8"> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"> <meta name="format-detection" content="telephone=no"> <meta name="format-detection" content="email=no"> <title>我的现金券</title>
<?php require_once "filter.php"; require_once "shake.php"; $shake = new Shake(); $uid = $_COOKIE[USER_COOKIE_ID]; $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $config["appid"] . '&redirect_uri=' . htmlspecialchars($config["redirect_uri"]) . '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'; if ($uid) { $user = $shake->getUser($uid, $config['appid']); if (!$user || $user['expiretime'] < time()) { //用户不存在或者过期 header("Location:" . $url); exit; } } else { header("Location:" . $url); exit; } $wecha_id = $user['openid']; $user_get_prize = $shake->get_user_prize($wecha_id); $tip = "很遗憾,您没有中奖<br/>更多精彩活动<br/>请关注香江全球家居CBC官方微信"; $status = $shake->get_user_prize_status($user_get_prize); if ($status == 3) { $tip = "您今日已领取过奖品<br/>" . $user_get_prize['prize_name'] . "<br/>谢谢参与"; } else { if ($status > 0) { $tip = "恭喜您<br/>已获得香江全球家居CBD<br/>" . $user_get_prize['prize_name']; } } ?> <!DOCTYPE html>