public function testReturnsFormattedUriFromRequestObject()
 {
     $request = new Shows(get_token(), Carbon::now(), 7);
     $formattedUri = UriBuilder::format($request);
     $this->assertContains($formattedUri, $formattedUri);
     $this->assertContains(Carbon::now()->format("Y-m-d"), $formattedUri);
 }
 public function __construct()
 {
     parent::__construct();
     $this->token = get_token();
     $this->wecha_id = get_openid();
     // 读取配置
     $pay_config_db = M('payment_set');
     $paymentSet = $pay_config_db->where(array('token' => $this->token))->find();
     if ($paymentSet['wx_cert_pem'] && $paymentSet['wx_key_pem']) {
         $ids[] = $paymentSet['wx_cert_pem'];
         $ids[] = $paymentSet['wx_key_pem'];
         $map['id'] = array('in', $ids);
         $fileData = M('file')->where($map)->select();
         $downloadConfig = C(DOWNLOAD_UPLOAD);
         foreach ($fileData as $f) {
             if ($paymentSet['wx_cert_pem'] == $f['id']) {
                 $certpath = SITE_PATH . str_replace('/', '\\', substr($downloadConfig['rootPath'], 1) . $f['savepath'] . $f['savename']);
             } else {
                 $keypath = SITE_PATH . str_replace('/', '\\', substr($downloadConfig['rootPath'], 1) . $f['savepath'] . $f['savename']);
             }
         }
         $paymentSet['cert_path'] = $certpath;
         $paymentSet['key_path'] = $keypath;
     }
     $this->payConfig = $paymentSet;
     session('paymentinfo', $this->payConfig);
 }
 function reply($dataArr, $keywordArr = array())
 {
     $map['id'] = $keywordArr['aim_id'];
     $param['token'] = get_token();
     $param['openid'] = get_openid();
     if ($keywordArr['extra_text'] == 'custom_reply_mult') {
         // 多图文回复
         $mult = M('custom_reply_mult')->where($map)->find();
         $map_news['id'] = array('in', $mult['mult_ids']);
         $list = M('custom_reply_news')->where($map_news)->select();
         foreach ($list as $k => $info) {
             if ($k > 8) {
                 continue;
             }
             $articles[] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $this->_getNewsUrl($info, $param));
         }
         $res = $this->replyNews($articles);
     } elseif ($keywordArr['extra_text'] == 'custom_reply_news') {
         // 单条图文回复
         $info = M('custom_reply_news')->where($map)->find();
         // 组装微信需要的图文数据,格式是固定的
         $articles[0] = array('Title' => $info['title'], 'Description' => $info['intro'], 'PicUrl' => get_cover_url($info['cover']), 'Url' => $this->_getNewsUrl($info, $param));
         $res = $this->replyNews($articles);
     } else {
         // 增加积分
         add_credit('custom_reply', 300);
         // 文本回复
         $info = M('custom_reply_text')->where($map)->find();
         $contetn = replace_url(htmlspecialchars_decode($info['content']));
         $this->replyText($contetn);
     }
 }
 function credit_data()
 {
     $model = $this->getModel('credit_data');
     $map['token'] = get_token();
     session('common_condition', $map);
     parent::common_lists($model, 0, 'Addons/lists');
 }
 private function formText($user, $config)
 {
     if (!$user) {
         return '请先回复绑定并绑定真实信息以使用本功能.';
     }
     if ($user['user_type'] == 1) {
         return '老师是没有考试成绩的0.0';
     } else {
         $textArr = array();
         $userGrades = M('cjcx')->where(array('school_id' => $user['school_id'], 'term' => $config['term']))->select();
         if (0 == count($userGrades)) {
             return "空记录! 还没有更新呢!";
         }
         foreach ($userGrades as $item) {
             $_t = '';
             $_t .= "课程名称: {$item['course_name']},\n";
             $_t .= "课程属性: {$item['class_type']}, \n";
             $_t .= "学分: {$item['study_score']},\n";
             $_t .= "分数: {$item['stu_grade']}";
             array_push($textArr, $_t);
         }
         $basic = implode("\n\n", $textArr);
         $params['openid'] = get_openid();
         $params['token'] = get_token();
         $more = "\n\n" . "<a href='" . addons_url("Cjcx://Cjcx/center", $params) . "'>查看完整记录</a>";
         return $basic . $more;
     }
 }
 function init_follow($openid, $token = '', $has_subscribe = false)
 {
     empty($token) && ($token = get_token());
     addWeixinLog($openid . '::_' . $token, 'init_follow_in');
     if (empty($openid) || $openid == -1 || empty($token) || $token == -1) {
         return false;
     }
     $data['token'] = $token;
     $data['openid'] = $openid;
     $datas = $data;
     $uid = M('public_follow')->where($data)->getField('uid');
     addWeixinLog($uid, 'init_follow_check_uid');
     if ($uid) {
         return $uid;
     }
     // 自动注册
     $config = getAddonConfig('UserCenter', $token);
     $user = array('experience' => intval($config['experience']), 'score' => intval($config['score']), 'reg_ip' => get_client_ip(1), 'reg_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), 'last_login_time' => NOW_TIME, 'status' => 1, 'is_init' => 1, 'is_audit' => 1, 'come_from' => 1);
     $user2 = getWeixinUserInfo($openid);
     $user = array_merge($user, $user2);
     $data['uid'] = $uid = D('Common/User')->add($user);
     if ($has_subscribe !== false) {
         $data['has_subscribe'] = $has_subscribe;
     }
     M('public_follow')->add($data);
     return $uid;
 }
    public function testCheckIn()
    {
        $json = '{
  "watched_at": "2014-08-06T01:11:37.953Z",
  "sharing": {
    "facebook": true,
    "twitter": true,
    "tumblr": false
  },
  "movie": {
    "title": "Guardians of the Galaxy",
    "year": 2014,
    "ids": {
      "trakt": 28,
      "slug": "guardians-of-the-galaxy-2014",
      "imdb": "tt2015381",
      "tmdb": 118340
    }
  }
}';
        $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
        $request = Mockery::mock(stdClass::class . ", " . RequestInterface::class);
        $response = Mockery::mock(stdClass::class . ", " . ResponseInterface::class);
        $client->shouldReceive("createRequest")->once()->andReturn($request);
        $response->shouldReceive("getStatusCode")->once()->andReturn(200);
        $response->shouldReceive("json")->once()->andReturn(json_decode($json));
        $client->shouldReceive("send")->once()->andReturn($response);
        $auth = mock_auth();
        $trakt = new Trakt($auth, $client);
        $checkIn = $trakt->checkIn;
        $this->assertInstanceOf("Wubs\\Trakt\\Api\\CheckIn", $checkIn);
        $response = $checkIn->create(get_token(), movie($client), "nooo way!", ['facebook' => false, 'twitter' => false, 'tumblr' => false], "1200", "blablabla", "1.1", $this->today->format("Y-m-d"));
        $this->assertInstanceOf("Wubs\\Trakt\\Response\\CheckIn", $response);
    }
function switch_theme()
{
    global $themes;
    if (isset($_COOKIE['adminer_theme'])) {
        $THEME = $_COOKIE['adminer_theme'];
    } else {
        $THEME = "default";
    }
    echo "<form style='' action='' method='post' id='themes-form'>\n<div id='themes'>";
    echo lang('Themes: ');
    echo "<select name='theme' onchange='this.form.submit();'>";
    echo "<option value='default'>Default</option>";
    foreach ($themes as $key => $value) {
        $selected = "";
        if ($key == $THEME) {
            $selected = " selected='selected' ";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>";
    }
    echo "</select>";
    echo " <input type='submit' value='" . lang('Use') . "' class='hidden'>\n";
    echo "<input type='hidden' name='token' value='" . get_token() . "'>\n";
    // $token may be empty in auth.inc.php
    echo "</div>\n</form>\n";
}
 function _initialize()
 {
     //模板初始化
     C('DEFAULT_THEME', session('DEFAULT_THEME'));
     $token = get_token();
     $param = array('lists', 'config', 'nulldeal');
     if (in_array(_ACTION, $param) && (empty($token) || $token == '-1')) {
         $url = U('Public/lists?from=2');
         redirect($url);
     }
     // 管理员需要对插件的管理权限进行判断
     if (is_login()) {
         $token_status = D('Common/AddonStatus')->getList(false);
         if ($token_status[_ADDONS] == -1) {
             $this->error('你没有权限管理和配置该插件');
         }
         return true;
     }
     C('EDITOR_UPLOAD.rootPath', './Uploads/Editor/' . $token . '/');
     if ($GLOBALS['is_wap']) {
         // 默认错误跳转对应的模板文件
         C('TMPL_ACTION_ERROR', 'Addons:dispatch_jump_mobile');
         // 默认成功跳转对应的模板文件
         C('TMPL_ACTION_SUCCESS', 'Addons:dispatch_jump_mobile');
     } else {
         $this->_nav();
     }
 }
 function show($widget)
 {
     $map['token'] = get_token();
     if ($widget['data_from'] == 2) {
         // 部分商品 cate_id=1,2,3&search_key=[search_key]&shopping_list=1
         $condition = str_replace(array('[cate_id]', '[search_key]'), array($_REQUEST['cate_id'], $_REQUEST['search_key']), $widget['data_condition']);
         parse_str($condition, $output);
         if (!empty($output['cate_id'])) {
             $map = getIdsForMap($output['cate_id'], $map, 'cate_id_1');
         }
         if (!empty($output['search_key'])) {
             $key = safe($output['search_key']);
             $map['title'] = array('like', "%{$key}%");
         }
         if (isset($output['shopping_list'])) {
             // 购物清单 TODO
         }
     } elseif ($widget['data_from'] == 1) {
         // 指定商品
         $map = getIdsForMap($widget['data_ids'], $map);
     }
     if (isset($_REQUEST['cate_id'])) {
         $cid = intval($_REQUEST['cate_id']);
         $map['_string'] = ' (cate_id_1=' . $cid . ' or cate_id_2=' . $cid . ') ';
     }
     $list = M('shop_product')->where($map)->order($widget['order'])->selectPage($widget['list_row']);
     // dump ( $list );
     $this->assign('list', $list);
     // dump ( $widget );
     return $this->getWidgetHtml($widget);
 }
 function add_qr_code($action_name = 'QR_SCENE', $addon = '', $aim_id = '', $extra_int = '', $extra_text = '')
 {
     set_time_limit(30);
     $data['scene_id'] = $this->get_scene_id($action_name);
     if (!$data['scene_id']) {
         return -1;
         // 场景值已满
     }
     $data['addon'] = $addon;
     $data['aim_id'] = $aim_id;
     $data['action_name'] = $action_name;
     $data['extra_text'] = $extra_text;
     $data['extra_int'] = $extra_int;
     $data['cTime'] = time();
     $data['token'] = get_token();
     $data['qr_code'] = $this->QrcodeCreate($data['scene_id'], $data['action_name']);
     // dump ( $data );
     // exit ();
     if (!$data['qr_code']) {
         return -2;
         // 获取二维码失败
     }
     $res = $this->add($data);
     if (!$res) {
         return -3;
         // 保存数据失败
     }
     return $data['qr_code'];
 }
Exemple #12
0
 /**
  * 编辑器挂载的后台文档模型文章内容钩子
  *
  * type=db&table=common_category&module=shop_category&value_field=id
  * type=text&data=[广西[南宁,桂林], 广东[广州, 深圳[福田区, 龙岗区, 宝安区]]]
  */
 public function cascade($data)
 {
     $key = $data['name'] . '_' . get_token();
     $json = S($key);
     if ($json === false) {
         parse_str($data['extra'], $arr);
         empty($arr['type']) && ($arr['type'] = 'db');
         if ($arr['type'] == 'db') {
             $table = !empty($arr['table']) ? $arr['table'] : 'common_category';
             $value_field = !empty($arr['value_field']) ? $arr['value_field'] : 'id';
             $custom_field = !empty($arr['custom_field']) ? $arr['custom_field'] : 'id,title,pid,sort';
             $custom_pid = !empty($arr['custom_pid']) ? $arr['custom_pid'] : 0;
             unset($arr['type'], $arr['table'], $arr['value_field'], $arr['custom_field'], $arr['custom_pid']);
             // dump($arr);
             $arr['token'] = get_token();
             $list = M($table)->where($arr)->field($custom_field)->order('pid asc, sort asc')->select();
             // lastsql();
             // dump($list);
             $tree = $this->makeTree($list, $custom_pid, $value_field);
         } else {
             $tree = $this->str2json($arr['data']);
         }
         // dump ( $tree );
         $json = json_encode($tree);
         S($key, $json, 86400);
     }
     // dump ( $json );
     $this->assign('json', $json);
     $data['default_value'] = $data['value'];
     empty($data['default_value']) || ($data['default_value'] = '"' . str_replace(',', '","', $data['default_value']) . '"');
     $this->assign($data);
     $this->display('content');
 }
 public function getCommonArticles($extra_int)
 {
     $map['token'] = get_token();
     $extra_int && ($map['id'] = $extra_int);
     $data = M('scratch')->where($map)->order('id desc')->select();
     if (!$data) {
         return true;
     }
     // 其中token和openid这两个参数一定要传,否则程序不知道是哪个微信用户进入了系统
     //$param ['token'] = get_token ();
     //$param ['openid'] = get_openid ();
     foreach ($data as $key => $vo) {
         $param['id'] = $vo['id'];
         $url = addons_url('Scratch://Scratch/show', $param);
         $articles[$key] = array('Title' => $vo['title'], 'Url' => $url);
         $now = time();
         if ($vo['end_time'] > $now) {
             $articles[$key]['Description'] = $vo['intro'];
             $articles[$key]['PicUrl'] = !empty($vo['cover']) ? get_cover_url($vo['cover']) : SITE_URL . '/Addons/Scratch/View/default/Public/cover_pic.jpg';
         } else {
             $articles[$key]['Description'] = $vo['end_tips'];
             $articles[$key]['PicUrl'] = !empty($vo['end_cover']) ? get_cover_url($vo['end_cover']) : SITE_URL . '/Addons/Scratch/View/default/Public/cover_pic_over.png';
         }
     }
     //foreach
     $this->replyNews($articles);
 }
 function move_group($id, $group_id)
 {
     is_array($id) || ($id = explode(',', $id));
     $data['uid'] = $map['uid'] = array('in', $id);
     // $data ['group_id'] = $group_id; //TODO 前端微信用户只能有一个微信组
     $res = M('auth_group_access')->where($data)->delete();
     $data['group_id'] = $group_id;
     foreach ($id as $uid) {
         $data['uid'] = $uid;
         $res = M('auth_group_access')->add($data);
         // 更新用户缓存
         D('Common/User')->getUserInfo($uid, true);
     }
     $group = $this->find($group_id);
     // 同步到微信端
     if (C('USER_GROUP') && !empty($group['wechat_group_id'])) {
         $url = 'https://api.weixin.qq.com/cgi-bin/groups/members/update?access_token=' . get_access_token();
         $map['token'] = get_token();
         $follow = M('public_follow')->where($map)->field('openid, uid')->select();
         foreach ($follow as $v) {
             if (empty($v['openid'])) {
                 continue;
             }
             $param['openid'] = $v['openid'];
             $param['to_groupid'] = $group['wechat_group_id'];
             $param = JSON($param);
             $res = post_data($url, $param);
         }
     }
     return $group;
 }
 public function ImageManager()
 {
     $name = I("name");
     $id = I("id");
     $times = I("times", 0, "intval");
     $where = array();
     if (!empty($times)) {
         $where = $this->getTimeMap($times);
     }
     /*wzh2015年8月13日15:24:46增加token筛选,避免不同账号图片错乱*/
     $where['token'] = get_token();
     $strTimes = $this->getPictureTimes(array('token' => $where['token']));
     $PictureResult = $this->getAllPictureData($where);
     $config = $this->config;
     //var_dump($PictureResult);die;
     $this->assign("addon_path", "./Plugins/ImageManager/");
     $this->assign("curtime", $times);
     $this->assign("strTimes", $strTimes);
     $arrname = strpos($name, '[') == false ? $name : explode('[', trim($name, ']'));
     is_array($arrname) && ($name = $arrname[1]);
     $this->assign("name", $name);
     $this->assign("id", $id);
     $this->assign("config", $config);
     $this->assign($PictureResult);
     $this->display('index');
 }
 public function testWithDaysAndStartDate()
 {
     $startDate = Carbon::createFromFormat("Y-m-d", "2014-03-01");
     $request = new Shows(get_token(), $startDate, 25);
     $this->assertContains("25", (string) $request->getDays());
     $this->assertContains("2014-03-01", (string) $request->getStartDate());
 }
 function updateFollowTotalCredit($uid)
 {
     $map['uid'] = $map2['id'] = $uid;
     $map['token'] = get_token();
     $info = $this->where($map)->field('sum(score) as score, sum(experience) as experience')->find();
     D('Common/Follow')->update($uid, $info);
 }
 function subscribe($dataArr)
 {
     $config = getAddonConfig('Wecome');
     // 获取后台插件的配置参数
     // 其中token和openid这两个参数一定要传,否则程序不知道是哪个微信用户进入了系统
     $param['token'] = get_token();
     $param['openid'] = get_openid();
     $sreach = array('[follow]', '[website]');
     $replace = array(addons_url('UserCenter://UserCenter/edit', $param), addons_url('WeiSite://WeiSite/index', $param));
     $config['description'] = str_replace($sreach, $replace, $config['description']);
     switch ($config['type']) {
         case '3':
             $articles[0] = array('Title' => $config['title'], 'Description' => $config['description'], 'PicUrl' => $config['pic_url'], 'Url' => str_replace($sreach, $replace, $config['url']));
             $res = $this->replyNews($articles);
             break;
             // 			case '2' :
             // 				$media_id = 1;
             // 				$res = $this->replyImage ( $media_id );
             // 				break;
         // 			case '2' :
         // 				$media_id = 1;
         // 				$res = $this->replyImage ( $media_id );
         // 				break;
         default:
             $res = $this->replyText($config['description']);
     }
     return $res;
 }
Exemple #19
0
 public function productDetail($map)
 {
     $token = get_token();
     $map['token'] = $token;
     $list = M('product')->where($map)->select();
     return $list[0];
 }
Exemple #20
0
 public function getUnitCost($id)
 {
     $map['token'] = get_token();
     $map['id'] = $id;
     $price = M('shop_product')->where($map)->field('discount_price')->limit(1)->select();
     return $price[0]['discount_price'];
 }
 public function __construct()
 {
     if ($_REQUEST['doNotInit']) {
         return true;
     }
     $content = wp_file_get_contents('php://input');
     !empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效');
     if ($_GET['encrypt_type'] == 'aes') {
         vendor('WXBiz.wxBizMsgCrypt');
         $this->sReqTimeStamp = I('get.timestamp');
         $this->sReqNonce = I('get.nonce');
         $this->sEncryptMsg = I('get.msg_signature');
         $map['id'] = I('get.id');
         $info = M('member_public')->where($map)->find();
         get_token($info['token']);
         // 设置token
         $this->wxcpt = new \WXBizMsgCrypt('weiphp', $info['encodingaeskey'], $info['appid']);
         $sMsg = "";
         // 解析之后的明文
         $errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg);
         if ($errCode != 0) {
             addWeixinLog($_GET, "DecryptMsg Error: " . $errCode);
             exit;
         } else {
             // 解密成功,sMsg即为xml格式的明文
             $content = $sMsg;
         }
     }
     $data = new \SimpleXMLElement($content);
     // $data || die ( '参数获取失败' );
     foreach ($data as $key => $value) {
         $this->data[$key] = strval($value);
     }
 }
     // dump($list_data);
     $this->display('Addons/lists');
 }
 public function edit($id = 0)
 {
     $model = $this->getModel('credit_config');
     $id || ($id = I('id'));
     // 获取数据
     $data = M(get_table_name($model['id']))->find($id);
     $data || $this->error('数据不存在!');
     if (IS_POST) {
         $act = 'save';
         if ($data['token'] == 0) {
             $_POST['token'] = get_token();
             unset($_POST['id']);
             $act = 'add';
         }
         $Model = D(parse_name(get_table_name($model['id']), 1));
         // 获取模型的字段信息
         $Model = $this->checkAttr($Model, $model['id']);
         if ($Model->create() && $Model->{$act}()) {
             // dump($Model->getLastSql());
             $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name']));
         } else {
             // dump($Model->getLastSql());
             $this->error($Model->getError());
         }
     } else {
         $fields = get_model_attribute($model['id']);
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->meta_title = '编辑' . $model['title'];
 public function execute($_addons = null, $_controller = null, $_action = null)
 {
     if (!empty($_action) && !empty($_addons) && empty($_controller)) {
         $_controller = $_GET['_controller'] = $_addons;
         $_REQUEST['_controller'] = $_REQUEST['_addons'];
     }
     if (C('URL_CASE_INSENSITIVE')) {
         $_addons = ucfirst(parse_name($_addons, 1));
         $_controller = parse_name($_controller, 1);
     }
     define('ADDON_PUBLIC_PATH', __ROOT__ . '/Addons/' . $_addons . '/View/default/Public');
     defined('_ADDONS') or define('_ADDONS', $_addons);
     defined('_CONTROLLER') or define('_CONTROLLER', $_controller);
     defined('_ACTION') or define('_ACTION', $_action);
     $token = get_token();
     if (in_array($_action, array('lists', 'config', 'nulldeal')) && (empty($token) || $token == '-1')) {
         $this->error('请先增加公众号!', U('Home/MemberPublic/lists'));
     }
     $this->_nav();
     if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
         tongji($_addons);
         A("Addons://{$_addons}/{$_controller}")->{$_action}();
     } else {
         $this->error('没有指定插件名称,控制器或操作!');
     }
 }
 function reply($dataArr, $keywordArr = array())
 {
     $config = getAddonConfig('Draw');
     // 获取后台插件的配置参数
     //dump($config);
     $map['token'] = get_token();
     $keywordArr['aim_id'] && ($map['id'] = $keywordArr['aim_id']);
     $data = M('lottery_games')->where($map)->find();
     // 其中token和openid这两个参数一定要传,否则程序不知道是哪个微信用户进入了系统
     $param['token'] = get_token();
     $param['openid'] = get_openid();
     $param['games_id'] = $data['id'];
     $url = addons_url('Draw://Wap/index', $param);
     $articles[0] = array('Title' => $data['title'], 'Url' => $url, 'Description' => $data['intro']);
     switch ($data['game_type']) {
         case 1:
             $articles[0]['PicUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/guaguale_cover.jpg';
             break;
         case 2:
             $articles[0]['PicUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/dzp_cover.jpg';
             break;
         case 3:
             $articles[0]['PicUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/zjd_cover.jpg';
             break;
         case 4:
             $articles[0]['PicUrl'] = SITE_URL . '/Addons/Draw/View/default/Public/nine_cover.jpg';
             break;
     }
     $this->replyNews($articles);
 }
 function edit()
 {
     $id = $this->shop_id;
     $model = $this->getModel();
     if (IS_POST) {
         // $_POST ['update_time'] = NOW_TIME;
         $Model = D(parse_name(get_table_name($model['id']), 1));
         if ($Model->create() && $Model->save()) {
             $this->_saveKeyword($model, $id);
         }
         // 清空缓存
         method_exists($Model, 'clear') && $Model->clear($id, 'edit');
         $this->success('保存' . $model['title'] . '成功!');
     } else {
         $fields = get_model_attribute($model['id']);
         // 获取数据
         $data = D('Shop')->getInfo($id, true);
         $data || $this->error('数据不存在!');
         $token = get_token();
         if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) {
             $this->error('非法访问!');
         }
         $this->assign('fields', $fields);
         $this->assign('data', $data);
         $this->display();
     }
 }
 function reply($dataArr, $keywordArr = array())
 {
     $config = getAddonConfig('Dg');
     // 获取后台插件的配置参数
     // 其中token和openid这两个参数一定要传,否则程序不知道是哪个微信用户进入了系统
     $param['token'] = get_token();
     $param['openid'] = get_openid();
     $keyword = $keywordArr['keyword'];
     //设置的关键词
     $myword = trim($dataArr['Content']);
     //用户输入的内容
     $myword = str_replace($keyword, '', $myword);
     //过滤匹配词
     if (empty($myword) || empty($keyword)) {
         $randgqinfoarr = $this->getBaiDurand();
         //随机歌曲
         $songName = $randgqinfoarr['songName'];
         $artistName = $randgqinfoarr['artistName'];
         $songLink = $this->getBaiDugqurl($randgqinfoarr['songLink']);
         $this->replyMusicnothumb($songName, $artistName, $songLink, $songLink);
     } elseif ($keyword == '点歌') {
         $arr = $this->getBaiDugqlist($myword);
         $mygqinfoarr = $this->getBaiDugqinfo($arr['0']['song_id']);
         $songName = $mygqinfoarr['songName'];
         $artistName = $mygqinfoarr['artistName'];
         $songLink = $this->getBaiDugqurl($mygqinfoarr['songLink']);
         $this->replyMusicnothumb($songName, $artistName, $songLink, $songLink);
         $this->replyText($msg);
     } else {
         $this->replyText("系统指令出错\n发送【点歌】随机听歌,\n发送【点歌+歌曲名】点歌");
     }
 }
 function reply($dataArr, $keywordArr = array())
 {
     $map['token'] = get_token();
     $keywordArr['aim_id'] && ($map['id'] = $keywordArr['aim_id']);
     $data = M('sendredpack')->where($map)->order('id desc')->select();
     foreach ($data as $key => $vo) {
         $param['id'] = $vo['id'];
         $url = addons_url('Sendredpack://Sendredpack/index', $param);
         $articles[$key] = array('Title' => $vo['title'], 'Url' => $url);
         $now = time();
         if ($vo['end_time'] > $now) {
             $articles[$key]['Description'] = $vo['intro'];
             $articles[$key]['PicUrl'] = !empty($vo['cover']) ? get_cover_url($vo['cover']) : SITE_URL . '/Addons/Scratch/View/default/Public/cover_pic.jpg';
         } else {
             $articles[$key]['Description'] = $vo['end_tips'];
             $articles[$key]['PicUrl'] = !empty($vo['end_cover']) ? get_cover_url($vo['end_cover']) : SITE_URL . '/Addons/Scratch/View/default/Public/cover_pic_over.png';
         }
     }
     //foreach
     if ($articles) {
         $this->replyNews($articles);
     } else {
         $this->replyText('Sorry,当前无红包活动!');
     }
 }
 function suggest()
 {
     $config = getAddonConfig('Suggestions');
     $this->assign($config);
     // dump ( $config );
     $map['id'] = $data['uid'] = $this->mid;
     $user = get_followinfo($this->mid);
     $this->assign('user', $user);
     if (IS_POST) {
         // 保存用户信息
         $nickname = I('nickname');
         if ($config['need_nickname'] && !empty($nickname)) {
             $data['nickname'] = $nickname;
         }
         $mobile = I('mobile');
         if ($config['need_mobile'] && !empty($mobile)) {
             $data['mobile'] = $mobile;
         }
         // 保存内容
         $data['cTime'] = time();
         $data['content'] = I('content');
         $data['token'] = get_token();
         $res = M('suggestions')->add($data);
         if ($res) {
             // 增加积分
             add_credit('suggestions');
             $this->success('增加成功,谢谢您的反馈');
         } else {
             $this->error('增加失败,请稍后再试');
         }
     } else {
         $this->display();
     }
 }
 function show()
 {
     $map['token'] = get_token();
     $list = M('card_notice')->where($map)->order('id desc')->select();
     $this->assign('list', $list);
     $this->display();
 }
 function detail()
 {
     if (!isset($_GET['invite_uid'])) {
         $param['id'] = I('id');
         $param['invite_uid'] = $this->mid;
         $param['token'] = get_token();
         redirect(U('detail', $param));
     }
     $map['invite_id'] = I('id');
     $map['uid'] = $this->mid;
     // $map ['token'] = get_token ();
     $info = D('Invite')->getInfo($map['invite_id']);
     $this->assign('info', $info);
     $this->deal($info);
     $recode = M('invite_user')->where($map)->find();
     if (empty($_GET['invite_uid'])) {
         $recode['invite_uid'] = $info['uid'];
     } else {
         $recode['invite_uid'] = I('get.invite_uid');
     }
     $this->assign('recode', $recode);
     //	dump ( $recode );
     // get_nickname ();
     // dump ( D ( 'Common/SnCode' )->getInfoById ( 30109 ) );
     $this->display();
 }