示例#1
0
 /**
  * callback  登陆后回调地址
  * @author:xjw129xjt(肖骏涛) xjt@ourstu.com
  */
 public function callback()
 {
     $code = I('get.code');
     $type = I('get.type');
     $is_login = is_login();
     $sns = \ThinkOauth::getInstance($type);
     //腾讯微博需传递的额外参数
     $extend = null;
     if ($type == 'tencent') {
         $extend = array('openid' => I('get.openid'), 'openkey' => I('get.openkey'));
     }
     $token = $sns->getAccessToken($code, $extend);
     if (empty($token)) {
         $this->error('参数错误');
     }
     $session = array('TOKEN' => $token, 'TYPE' => $type, 'OPENID' => $token['openid'], 'ACCESS_TOKEN' => $token['access_token']);
     session('SYNCLOGIN', $session);
     if ($is_login) {
         $this->dealIsLogin($is_login);
     } else {
         $addon_config = get_addon_config('SyncLogin');
         $check = $this->checkIsSync(array('type_uid' => $token['openid'], 'type' => $type));
         if ($addon_config['bind'] && !$check) {
             redirect(addons_url('SyncLogin://Base/bind'));
         } else {
             $this->unBind();
         }
     }
 }
示例#2
0
 /**
  * 登陆后回调地址
  * autor:xjw129xjt
  */
 public function callback()
 {
     $code = I('get.code');
     $type = I('get.type');
     $is_login = is_login();
     $sns = \ThinkOauth::getInstance($type);
     //腾讯微博需传递的额外参数
     $extend = null;
     if ($type == 'tencent') {
         $extend = array('openid' => I('get.openid'), 'openkey' => I('get.openkey'));
     }
     $token = $sns->getAccessToken($code, $extend);
     session('SYNCLOGIN_TOKEN', $token);
     session('SYNCLOGIN_TYPE', $type);
     session('SYNCLOGIN_OPENID', $token['openid']);
     session('SYNCLOGIN_ACCESS_TOKEN', $token['access_token']);
     $check = D('sync_login')->where("`type_uid`='" . $token['openid'] . "' AND type='" . $type . "'")->select();
     $addon_config = get_addon_config('SyncLogin');
     if ($is_login) {
         $this->dealIsLogin($is_login);
     } else {
         if ($addon_config['bind'] && !$check) {
             redirect(addons_url('SyncLogin://Base/bind'));
         } else {
             $this->unbind();
         }
     }
 }
示例#3
0
 /**
  * @param 
  * @param $uid int 评论给谁?
  * @author caipeichao
  */
 public function localComment($param)
 {
     $uid = $param['uid'];
     $app = $param['app'];
     $mod = $param['con'];
     $row_id = $param['id'];
     //获取参数
     $p = $_REQUEST[C('VAR_PAGE')] ? $_REQUEST[C('VAR_PAGE')] : 1;
     $count = 7;
     //调用接口获取评论列表
     $list = $this->getCommentList($app, $mod, $row_id, $p, $count);
     $total_count = $this->getCommentCount($app, $mod, $row_id);
     //增加用户信息
     foreach ($list as &$e) {
         $e['user'] = query_user(array('uid', 'avatar64', 'nickname', 'space_url'), $e['uid']);
     }
     unset($e);
     $config = get_addon_config('LocalComment');
     $can_guest_comment = $config['can_guest_comment'];
     $this->assign('can_guest_comment', $can_guest_comment);
     //显示页面
     $loginuser = query_user(array('uid', 'avatar64', 'nickname', 'space_url'), $uid);
     $this->assign('loginuser', $loginuser);
     $this->assign('list', $list);
     $this->assign('total_count', $total_count);
     $this->assign('count', $count);
     $this->assign('app', $app);
     $this->assign('mod', $mod);
     $info = D($app . '/' . $mod)->get_info($row_id);
     $this->assign('info', $info);
     $this->assign('row_id', $row_id);
     $this->assign('uid', $uid);
     $this->display('comment');
 }
 public function addComment()
 {
     $config = get_addon_config('LocalComment');
     $can_guest_comment = $config['can_guest_comment'];
     if (!$can_guest_comment) {
         //不允许游客评论
         if (!is_login()) {
             $this->error('请登录后评论。');
         }
     }
     //获取参数
     $app = strval($_REQUEST['app']);
     $mod = strval($_REQUEST['mod']);
     $row_id = intval($_REQUEST['row_id']);
     $content = strval($_REQUEST['content']);
     $uid = intval($_REQUEST['uid']);
     //调用API接口,添加新评论
     $data = array('app' => $app, 'mod' => $mod, 'row_id' => $row_id, 'content' => $content, 'uid' => is_login());
     D($app . '/' . $mod)->where(array('id' => $row_id))->setInc('reply_count');
     $commentModel = D('Addons://LocalComment/LocalComment');
     $data = $commentModel->create($data);
     if (!$data) {
         $this->error('评论失败:' . $commentModel->getError());
     }
     $commentModel->add($data);
     if (!is_login()) {
         if ($uid) {
             $title = '游客' . '评论了您';
             $message = '评论内容:' . $content;
             $url = $_SERVER['HTTP_REFERER'];
             D('Common/Message')->sendMessage($uid, $message, $title, $url, 0, 0, $app);
         }
         //返回结果
         $this->success('评论成功', 'refresh');
     } else {
         //给评论对象发送消息
         if ($uid) {
             $user = D('User/UcenterMember')->find(get_uid());
             $title = $user['username'] . '评论了您';
             $message = '评论内容:' . $content;
             $url = $_SERVER['HTTP_REFERER'];
             D('Common/Message')->sendMessage($uid, $message, $title, $url, get_uid(), 0, $app);
         }
     }
     //通知被@到的人
     $uids = get_at_uids($content);
     $uids = array_unique($uids);
     $uids = array_subtract($uids, array($uid));
     foreach ($uids as $uid) {
         $user = D('User/UcenterMember')->find($uid);
         $title = $user['username'] . '@了您';
         $message = '评论内容:' . $content;
         $url = $_SERVER['HTTP_REFERER'];
         D('Common/Message')->sendMessage($uid, $message, $title, $url, get_uid(), 0, $app);
     }
     //返回结果
     $this->success('评论成功', 'refresh');
 }
 public function view()
 {
     $current = U('/home/addons/adminlist/name/Message');
     $this->assign('current', $current);
     //获取配置文件信息
     $config_info = (include_once ONETHINK_ADDON_PATH . 'Message/config.inc.php');
     $this->assign('group_type', $config_info['type']);
     $id = I('get.id', '');
     $info = D('Addons://Message/Message')->detail($id);
     $this->assign('info', $info);
     $config = get_addon_config('Message');
     $this->assign('config', $config);
     $this->display(T('Addons://Message@Message/view'));
 }
 public function getList()
 {
     if (!extension_loaded('curl')) {
         $this->error('糗事百科插件需要开启PHP的CURL扩展');
     }
     $lists = S('QiuBai_content');
     if (!$lists) {
         $config = get_addon_config('QiuBai');
         $HTTP_Server = "www.qiushibaike.com/8hr";
         $HTTP_URL = "/";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, "http://" . $HTTP_Server . $HTTP_URL);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
         // curl_setopt($ch,CURLOPT_COOKIE,$HTTP_SESSION);
         $content = curl_exec($ch);
         curl_close($ch);
         if ($content) {
             preg_match_all('/<div class="content" title="(.*?)">\\s*(.*?)\\s*<\\/div>/is', $content, $match);
             unset($match[0]);
             $lists = array_map(function ($a, $b) {
                 return array('time' => $a, 'content' => $b);
             }, $match[1], $match[2]);
             S('QiuBai_content', $lists, $config['cache_time']);
         }
     }
     #dom对象方式匹配内容
     // if($content){
     //     $dom = new \DOMDocument();
     //     $dom->loadHTML($content);
     //     $body = $dom->getElementsByTagName('body');
     //     $body = simplexml_import_dom($body->item(0));
     //     $list = $body->xpath("//div[@class='main']/div[@class='content-block']/div[@class='col1']/div/div[@class='content']");
     //     foreach ($list as $key => $value) {
     //         $attr = $value->attributes();
     //         $lists[] = array('time'=>strval($attr['title']),'content'=>trim(strval($value)));
     //     }
     // }
     if ($lists) {
         $this->success('成功', '', array('data' => $lists));
     } else {
         $this->error('获取糗事百科列表失败');
     }
     $this->assign('qiubai_list', $lists);
 }
 public function deleteImage()
 {
     $config = get_addon_config("ImageManager");
     if ($config['delete_switch'] != 1) {
         $this->error('没有开启删除选项!');
     }
     $id = I("id", 0, "intval");
     if ($config['delete_mode'] == 1) {
         $pic = M("Picture")->find($id);
         if (file_exists($_SERVER['DOCUMENT_ROOT'] . $pic['path'])) {
             @unlink($_SERVER['DOCUMENT_ROOT'] . $pic['path']);
         }
         M("Picture")->delete($id);
     } else {
         M("Picture")->where(array('id' => $id))->setField("status", 0);
     }
     $this->success('ok');
 }
 public function bind()
 {
     $addon_config = get_addon_config('SyncLogin');
     $arr = array();
     foreach ($addon_config['type'] as &$v) {
         $arr[$v]['name'] = strtolower($v);
         $arr[$v]['is_bind'] = $this->check_is_bind_account(is_login(), strtolower($v));
         if ($arr[$v]['is_bind']) {
             $token = D('sync_login')->where(array('type' => strtolower($v), 'uid' => is_login()))->find();
             $user_info = D('Addons://SyncLogin/Info')->{$arr}[$v]['name'](array('access_token' => $token['oauth_token'], 'openid' => $token['oauth_token_secret']));
             $arr[$v]['info'] = $user_info;
         }
     }
     unset($v);
     $this->assign('list', $arr);
     $this->assign('addon_config', $addon_config);
     $this->assign('tabHash', 'bind');
     $this->display(T('Addons://SyncLogin@Ucenter/bind'));
 }
 public function vote()
 {
     $config = get_addon_config('Digg');
     $id = intval(I('id'));
     $type = intval(I('type'));
     $uid = is_login();
     if (!$uid) {
         $this->error('请先登录再投票');
     }
     $has_vote = M('Digg')->where("document_id={$id} AND uids like '%,{$uid},%'")->find();
     if (!$has_vote) {
         $field = $type == '1' ? 'good' : 'bad';
         $data = array($field => array('exp', "{$field}+1"), "uids" => array('exp', "concat(uids,'{$uid},')"));
         M('Digg')->where("document_id={$id}")->save($data);
         $this->success($config['post_sucess_tip']);
     } else {
         $this->error($config['post_error_tip']);
     }
 }
 public function indexAliPlay($param)
 {
     $config = $this->getConfig();
     // 检查插件是否开启
     if ($config['codelogin']) {
         $post = get_addon_config('AliPlay');
         if ($config['PARTNER']) {
             // 判断用户选择的接口类型,决定配置文件的写入路径
             $pay_type = '';
             switch ($config['pay_type']) {
                 case 1:
                     $pay_type = 'danbao';
                     break;
                 case 2:
                     $pay_type = 'jishi';
                     break;
                 case 3:
                     $pay_type = 'wangguan';
                     break;
             }
             // 读取文件中的内容
             $str = file_get_contents("./Addons/AliPlay/Play/" . $pay_type . "/lib/aliplay.php");
             $zz = array();
             $rep = array();
             foreach ($post as $key => $value) {
                 $zz[] = "/define\\(\"{$key}\",\\s*.*?\\);/i";
                 $rep[] = "define(\"{$key}\", \"{$value}\");";
             }
             // 改写文件中的内容
             $str = preg_replace($zz, $rep, $str);
             file_put_contents("./Addons/AliPlay/Play/" . $pay_type . "/lib/aliplay.php", $str);
             $this->assign('pay_type', $pay_type);
             $this->assign('config', $config);
             $this->display('AliPlay');
         }
     }
 }
示例#11
0
 public function getList()
 {
     $lists = S('Weather_content');
     if (!$lists) {
         $config = get_addon_config('Weather');
         $url = "http://api.map.baidu.com/telematics/v2/weather?location=" . $config['city'] . "&ak=" . $config['ak'] . "";
         $result = file_get_contents($url);
         $content = simplexml_load_string($result);
         $lists['city'] = (string) $content->currentCity;
         $lists['showday'] = $config['showday'];
         foreach ($content->results->result as $result) {
             $lists['date'][] = (string) $result->date;
             $lists['weather'][] = (string) $result->weather;
             $lists['wind'][] = (string) $result->wind;
             $lists['temperature'][] = (string) $result->temperature;
             $lists['pictureUrl'][] = (string) $result->dayPictureUrl;
         }
     }
     if ($lists) {
         $this->success('成功', '', array('data' => $lists));
     } else {
         $this->error('天气列表失败');
     }
 }
示例#12
0
 public function index()
 {
     //JSSDK 初始部分
     $param['mp_id'] = I('mp_id');
     //$param ['id'] = I('id');                                          //如有插件中数据id,分享url中应加入id参数
     //$url = addons_url ( 'Jssdk://Jssdk/index', $param );  //分享的url需要和自定义回复入口url保持相同
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $info = get_mpid_appinfo($param['mp_id']);
     $options['appid'] = $info['appid'];
     //初始化options信息
     $options['appsecret'] = $info['secret'];
     $options['encodingaeskey'] = $info['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $addon_config = get_addon_config('Jssdk');
     $this->assign('addon_config', $addon_config);
     //微信支付部分
     //此处可以动态获取数据库中的MCHID和KEY
     $jssdkpay = new JsSdkPay($options);
     $jssdkpay->MCHID = "";
     // 动态MCHID;微信支付分配的商户号
     $jssdkpay->KEY = "";
     // 动态KEY;
     //=========步骤2:使用统一支付接口,获取prepay_id============
     //使用统一支付接口
     $jssdkpay->parameters['openid'] = get_openid();
     //trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
     $jssdkpay->parameters['body'] = "订单支付";
     //商品或支付单简要描述
     $jssdkpay->parameters['out_trade_no'] = "outtradeno" . time();
     //商户系统内部的订单号,32个字符内、可包含字母,不可重复
     $jssdkpay->parameters['total_fee'] = 100;
     //收款金额,此处单位为分 出现小数点接口报错必须是整数
     $jssdkpay->parameters['notify_url'] = 'http://test.uctoo.com/index.php/addon/Jssdk/Jssdk/alarmnotify';
     //接收微信支付异步通知回调地址
     $jssdkpay->parameters['trade_type'] = "JSAPI";
     //取值如下:JSAPI,NATIVE,APP
     $jssdkpay->parameters['spbill_create_ip'] = get_client_ip();
     //APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
     //以下非必填参数根据需要添加
     //$jssdkpay->parameters['device_info'] = "013467007045764";            //微信支付分配的终端设备号,商户自定义
     //$jssdkpay->parameters['detail'] = "UCToo   蓝色";                     //商品名称明细列表
     //$jssdkpay->parameters['attach'] = "说明";                             //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
     //$jssdkpay->parameters['fee_type'] = "CNY";                           //符合ISO 4217标准的三位字母代码,默认人民币:CNY
     //$jssdkpay->parameters['time_start'] = "20091225091010";              //订单生成时间,格式为yyyyMMddHHmmss
     //$jssdkpay->parameters['time_expire'] = "20091227091010";             //订单失效时间,格式为yyyyMMddHHmmss
     //$jssdkpay->parameters['goods_tag'] = "WXG";                          //商品标记,代金券或立减优惠功能的参数
     //$jssdkpay->parameters['product_id'] = "12235413214070356458058";     //trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。
     $jssdkpay->prepay_id = $jssdkpay->getPrepayId();
     //微信生成的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时
     //=========步骤3:使用jsapi调起支付============
     $jsApiParameters = $jssdkpay->getParameters();
     //JSSDK 用户支付完成后的一些系统操作
     $param1['dcnum'] = $jssdkpay->parameters['out_trade_no'];
     $param1['openid'] = $jssdkpay->parameters['openid'];
     $ajaxurl = addons_url('Jssdk://Jssdk/orderpaid', $param1);
     //用户支付完成后,在微信支付返回alarmnotify之前(不保证时序),可以通过ajax调用,进行一些预处理操作
     $jsApiParameters = substr($jsApiParameters, 1, -1) . ",success: function (res) {\n                // 支付成功后的js回调函数\n               \n                }";
     $this->assign("jsApiParameters", $jsApiParameters);
     //向页面传整理好的调起支付参数
     $this->display();
 }
示例#13
0
 public function addComment()
 {
     $config = get_addon_config('LocalComment');
     $can_guest_comment = $config['can_guest_comment'];
     if (!$can_guest_comment) {
         //不允许游客评论
         if (!is_login()) {
             $this->error('请登录后评论。');
         }
     }
     //获取参数
     $app = strval($_REQUEST['app']);
     $mod = strval($_REQUEST['con']);
     $row_id = intval($_REQUEST['row_id']);
     $content = strval($_REQUEST['content']);
     $uid = intval($_REQUEST['uid']);
     $pid = intval($_REQUEST['pid']);
     if (M($mod)->where(array('id' => $row_id))->getField('status') != 1) {
         $this->error('该文章尚未审核通过!');
     }
     $data = array('app' => $app, 'con' => $mod, 'row_id' => $row_id, 'content' => $content, 'uid' => is_login(), 'pid' => $pid);
     $commentModel = D('Addons://LocalComment/LocalComment');
     $data = $commentModel->create($data);
     if (!$data) {
         $this->error('评论失败:' . $commentModel->getError());
     } else {
         D($app . '/' . $mod)->where(array('id' => $row_id))->setInc('reply_count');
         $rowinfo = D($app . '/' . $mod)->where(array('id' => $row_id))->find();
         $data['content'] = op_h($data['content'], 'font');
         $commentModel->add($data);
         if (!is_login()) {
             if ($uid) {
                 $title = '游客' . '评论了您';
                 $message = '评论内容:' . $content;
                 $url = $_SERVER['HTTP_REFERER'];
                 if (strtolower($mod) == 'article') {
                     $rowurl = U('Home/Index/artc', array('id' => $row_id));
                 }
                 if (strtolower($mod) == 'music') {
                     $rowurl = U('Home/Index/musicc', array('id' => $row_id));
                 }
                 if (strtolower($mod) == 'group') {
                     $rowurl = U('Home/Index/groupc', array('id' => $row_id));
                 }
                 sendMessage($rowinfo['uid'], '0', $title, $message . ',链接地址:<a href="' . $rowurl . '">' . $rowinfo['title'] . '</a>', 0);
             }
             //返回结果
             $this->success('评论成功', 'refresh');
         } else {
             //给评论对象发送消息
             if ($uid) {
                 $user = D('Member')->find(getnowUid());
                 $title = $user['nickname'] . '评论了您';
                 $message = '评论内容:' . $content;
                 $url = $_SERVER['HTTP_REFERER'];
                 if ($rowinfo['uid'] != getnowUid()) {
                     if (strtolower($mod) == 'article') {
                         $rowurl = U('Home/Index/artc', array('id' => $row_id));
                     }
                     if (strtolower($mod) == 'music') {
                         $rowurl = U('Home/Index/musicc', array('id' => $row_id));
                     }
                     if (strtolower($mod) == 'group') {
                         $rowurl = U('Home/Index/groupc', array('id' => $row_id));
                     }
                     sendMessage($rowinfo['uid'], getnowUid(), $title, $message . ',链接地址:<a href="' . $rowurl . '">' . $rowinfo['title'] . '</a>', 0);
                 }
             }
         }
         //通知被@到的人
         $uids = get_at_uids($content);
         $uids = array_unique($uids);
         $uids = array_subtract($uids, array($uid));
         foreach ($uids as $uid) {
             $user = D('Member')->find(getnowUid());
             $title = $user['nickname'] . '@了您';
             $message = '评论内容:' . $content;
             $url = $_SERVER['HTTP_REFERER'];
             sendMessage($uid, getnowUid(), $title, $message . ',链接地址:<a href="' . U('Index/artc', array('id' => $row_id)) . '">' . $rowinfo['title'] . '</a>', 0);
         }
         //返回结果
         $this->success('评论成功');
     }
 }
示例#14
0
 public function indexAliPlay($param)
 {
     $config = $this->getConfig();
     //检查插件是否开启
     if ($config['codelogin']) {
         $post = get_addon_config('AliPlay');
         if ($config['PARTNER']) {
             //判断用户选择的接口类型,决定配置文件的写入路径
             $pay_type = '';
             switch ($config['pay_type']) {
                 case 1:
                     $pay_type = 'AliPlayEscow';
                     break;
                 case 2:
                     $pay_type = 'AliPlayDirect';
                     break;
                 case 3:
                     $pay_type = 'wangguan';
                     break;
             }
             //读取文件中的内容
             $str = file_get_contents("./Addons/AliPlay/Play/" . $pay_type . "/lib/aliplay.php");
             $zz = array();
             $rep = array();
             foreach ($post as $key => $value) {
                 $zz[] = "/define\\(\"{$key}\",\\s*.*?\\);/i";
                 $rep[] = "define(\"{$key}\", \"{$value}\");";
             }
             //改写文件中的内容
             $str = preg_replace($zz, $rep, $str);
             file_put_contents("./Addons/AliPlay/Play/" . $pay_type . "/lib/aliplay.php", $str);
             $data['out_trade_no'] = $this->createOrderNo();
             //订单号
             $data['subject'] = "账户充值";
             //订单名称;
             $data['price'] = "";
             //付款金额;
             $data['logistics_fee'] = 0;
             //物流费用;
             $data['logistics_type'] = "POST";
             //物流类型;
             $data['logistics_payment'] = "SELLER_PAY";
             //物流支付方式;
             $data['body'] = "账户充值";
             //订单描述;
             $data['show_url'] = "";
             //商品展示地址;
             $data['receive_name'] = "";
             //收货人姓名;
             $data['receive_address'] = "";
             //收货人地址;
             $data['receive_zip'] = "";
             //收货人邮编;
             $data['receive_mobile'] = "";
             //收货人手机号码;
             $data['receive_phone'] = "";
             //收货人电话号码;
             // echo '<pre>'; print_r($data); echo '</pre>';
             $this->assign('data', $data);
             $this->assign('pay_type', $pay_type);
             $this->assign('config', $config);
             $this->display('AliPlay');
         }
     }
 }
 public function view()
 {
     error_reporting(0);
     $config = get_addon_config('AdaptiveImages');
     $document_root = __ROOT__;
     $resolutions = $this->resolutions = explode(',', trim($config['resolutions']));
     $this->cache_path = $config['cache_path'];
     $this->jpg_quality = $config['jpg_quality'];
     $this->sharpen = $config['sharpen'];
     $this->watch_cache = $config['watch_cache'];
     $this->browser_cache = $config['browser_cache'];
     $requested_uri = parse_url(urldecode($_SERVER['REQUEST_URI']), PHP_URL_PATH);
     $requested_uri = str_replace($document_root, '', $requested_uri);
     $requested_file = basename($requested_uri);
     $this->source_file = $source_file = '.' . $requested_uri;
     $resolution = FALSE;
     // 检测源文件是否存在
     if (!file_exists($source_file)) {
         header("Status: 404 Not Found");
         exit;
     } else {
         if ($config['status'] == 0) {
             $this->sendImage($this->source_file);
         }
     }
     /* 检测环境里是否有GD库 */
     if (!extension_loaded('gd')) {
         if (!function_exists('dl') || !dl('gd.so')) {
             trigger_error('你必须启用 GD 扩展来使用Adaptive Images', E_USER_WARNING);
             $this->sendImage($source_file, $this->browser_cache);
         }
     }
     //$cache_path是否已经存在?
     if (!is_dir($this->cache_path)) {
         // no
         if (!@mkdir($this->cache_path, 0755, true)) {
             if (!is_dir($this->cache_path)) {
                 $this->sendErrorImage("Failed to create cache directory at: {$this->cache_path}");
             }
         }
     }
     /* 检查是否合法的cookie */
     if (isset($_COOKIE['resolution'])) {
         $cookie_value = $_COOKIE['resolution'];
         // 格式是否正确 [whole number, comma, potential floating number]
         if (!preg_match("/^[0-9]+[,]*[0-9\\.]+\$/", "{$cookie_value}")) {
             // no it doesn't look valid
             setcookie("resolution", "{$cookie_value}", time() - 100);
             // delete the mangled cookie
         } else {
             // the cookie is valid, do stuff with it
             $cookie_data = explode(",", $_COOKIE['resolution']);
             $client_width = (int) $cookie_data[0];
             // the base resolution (CSS pixels)
             $total_width = $client_width;
             $pixel_density = 1;
             // set a default, used for non-retina style JS snippet
             if (@$cookie_data[1]) {
                 // the device's pixel density factor (physical pixels per CSS pixel)
                 $pixel_density = $cookie_data[1];
             }
             rsort($resolutions);
             // make sure the supplied break-points are in reverse size order
             $resolution = $resolutions[0];
             // by default use the largest supported break-point
             // if pixel density is not 1, then we need to be smart about adapting and fitting into the defined breakpoints
             if ($pixel_density != 1) {
                 $total_width = $client_width * $pixel_density;
                 // required physical pixel width of the image
                 // the required image width is bigger than any existing value in $resolutions
                 if ($total_width > $resolutions[0]) {
                     // firstly, fit the CSS size into a break point ignoring the multiplier
                     foreach ($resolutions as $break_point) {
                         // filter down
                         if ($total_width <= $break_point) {
                             $resolution = $break_point;
                         }
                     }
                     // now apply the multiplier
                     $resolution = $resolution * $pixel_density;
                 } else {
                     foreach ($resolutions as $break_point) {
                         // filter down
                         if ($total_width <= $break_point) {
                             $resolution = $break_point;
                         }
                     }
                 }
             } else {
                 // pixel density is 1, just fit it into one of the breakpoints
                 foreach ($resolutions as $break_point) {
                     // filter down
                     if ($total_width <= $break_point) {
                         $resolution = $break_point;
                     }
                 }
             }
         }
     }
     //是否是手机
     if (!$this->is_mobile()) {
         $is_mobile = FALSE;
     } else {
         $is_mobile = TRUE;
     }
     /* 没有响应式断点发现 (没有合法的cookie) */
     if (!$resolution) {
         // 我们发送给手机端最小的宽度,非手机端最大的
         $resolution = $is_mobile ? min($resolutions) : max($resolutions);
     }
     if (substr($requested_uri, 0, 1) == "/") {
         $requested_uri = substr($requested_uri, 1);
     }
     $cache_file = "{$this->cache_path}/{$resolution}/" . $requested_uri;
     /* 使用响应值作为路径变量,并且检测同名图片是否存在其中 */
     if (file_exists($cache_file)) {
         if ($this->watch_cache) {
             //监视原图改变的话
             $cache_file = $this->refreshCache($source_file, $cache_file, $resolution);
         }
         $this->sendImage($cache_file, $this->browser_cache);
     }
     /* 原图存在无缓存时创建缓存: */
     $file = $this->generateImage($source_file, $cache_file, $resolution);
     $this->sendImage($file, $this->browser_cache);
 }
示例#16
0
 public function native()
 {
     $order_id = I('order_id');
     if (empty($order_id)) {
         $this->error('非法订单参数...');
     }
     $map = array('order_status' => 4, 'order_id' => $order_id);
     $order_info = M('Order')->field('order_id,order_price,product_id,order_type')->where($map)->find();
     if (empty($order_info)) {
         $this->error('订单不存在...');
     }
     switch ($order_info['order_type']) {
         case 'line':
             $info = M('Line')->field('title,sub_title')->find($order_info['product_id']);
             if ($info) {
                 $order_info['title'] = $info['title'];
                 $order_info['sub_title'] = $info['sub_title'];
             } else {
                 $order_info['title'] = '旅游线路';
                 $order_info['sub_title'] = '旅游线路资费';
             }
             break;
         case 'visa':
             $info = M('Visa')->field('title,sub_title')->find($order_info['product_id']);
             if ($info) {
                 $order_info['title'] = $info['title'];
                 $order_info['sub_title'] = $info['sub_title'];
             } else {
                 $order_info['title'] = '旅游线路';
                 $order_info['sub_title'] = '旅游线路资费';
             }
             break;
         default:
             break;
     }
     //模式二
     import('Com.Wxpay.lib.NativePay');
     import('Com.Wxpay.lib.WxPayApi');
     import('Com.Wxpay.lib.WxPayDataBase');
     $notify = new \Com\WxPay\lib\NativePay();
     $get_notify_url = addons_url("Wxpay://Index/notify");
     $get_notify_url = preg_replace('/.html/i', '', $get_notify_url);
     $get_notify_url = "http://" . $_SERVER['HTTP_HOST'] . $get_notify_url;
     $notify_url = $get_notify_url;
     //获取公众号信息,jsApiPay初始化参数
     $config = get_addon_config('Wxpay');
     $input = new \Com\WxPay\lib\WxPayUnifiedOrder();
     $input->SetBody($order_info['title']);
     $input->SetAttach($order_info['sub_title']);
     $input->SetOut_trade_no($order_info['order_id']);
     $input->SetTotal_fee(intval($order_info['order_price'] * 100));
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     $input->SetGoods_tag($order_info['title']);
     $input->SetNotify_url($notify_url);
     $input->SetTrade_type("NATIVE");
     $input->SetProduct_id("123456789");
     $result = $notify->GetPayUrl($input);
     if ($result['result_code'] == 'FAIL') {
         $this->error($result['err_code_des'], U('User/orderShow', array('order_id' => $order_info['order_id'])));
     }
     $url2 = $result["code_url"];
     $this->assign('url2', $url2);
     // echo '<pre>'; print_r($result); echo '</pre>'; exit;
     $this->display(T('Addons://Wxpay@Index/native'));
     exit;
     // echo '<pre>'; print_r($result); echo '</pre>';
     // $url = 'http://paysdk.weixin.qq.com/example/qrcode.php?data=' . urlencode($url2);
     // $url = "http://".$_SERVER['HTTP_HOST'] . addons_url("Wxpay://Index/qrcode", array('data'=>base64_encode($url2)));
     // exit($url);
     // $url = 'http://wwb.sypole.com/Addons/execute/_addons/Wxpay/_controller/Index/_action/qrcode?data=' . urlencode($url2);
     // header('Content-type: image/png');
     // echo file_get_contents($url);
 }
示例#17
0
 /**
  * 提交评论
  * 提交网址:./addComment?app=&mod=&row_id=&uid=&pid=&token=
  */
 public function addComment()
 {
     $config = get_addon_config('LocalComment');
     $can_guest_comment = $config['can_guest_comment'];
     $post_uid = get_uid();
     if (!$can_guest_comment) {
         //不允许游客评论
         if (!$post_uid) {
             $this->error('请登录后评论。');
         }
     }
     //获取参数
     $app = I('request.app', '', 'trim,htmlspecialchars');
     $mod = I('request.mod', '', 'trim,htmlspecialchars');
     $row_id = I('request.row_id', 0, 'intval');
     $content = I('request.content', '', 'trim,htmlspecialchars');
     $pid = I('request.pid', 0, 'intval');
     $uid = I('request.uid', 0, 'intval');
     if (!$this->_verifyToken($app, $mod, $row_id, $uid)) {
         $this->error('参数被篡改。');
     }
     //调用API接口,添加新评论
     $data = array('app' => $app, 'mod' => $mod, 'row_id' => $row_id, 'content' => $content, 'uid' => $post_uid, 'pid' => $pid);
     if ($post_uid > 0) {
         $data['nickname'] = D('Member')->where(array('uid' => $post_uid))->getField('nickname');
     } else {
         $data['nickname'] = I('request.nickname', '', 'trim,htmlspecialchars');
         if ($data['nickname'] === '') {
             $this->error('请请输入您的名称。');
         }
     }
     if (!preg_match('/^[\\w]+$/', $app)) {
         $this->error('app的值不正确');
     }
     if (!preg_match('/^[\\w]+$/', $mod)) {
         $this->error('mod的值不正确');
     }
     D($app . '/' . $mod)->where(array('id' => $row_id))->setInc('reply_count');
     $commentModel = D('Addons://LocalComment/LocalComment');
     $data = $commentModel->create($data);
     if (!$data) {
         $this->error('评论失败:' . $commentModel->getError());
     }
     $commentModel->add($data);
     $referer_url = htmlspecialchars($_SERVER['HTTP_REFERER']);
     //游客逻辑直接跳过@环节
     if ($post_uid <= 0) {
         if ($uid) {
             $title = '游客「' . $data['nickname'] . '」评论了您';
             $message = '评论内容:' . $content;
             D('Common/Message')->sendMessage($uid, $message, $title, $referer_url, 0, 0, $app);
         }
         //返回结果
         $this->success('评论成功', 'refresh');
         exit;
     } else {
         //给评论对象发送消息
         $title = '用户「' . $data['nickname'] . '」评论了您';
         $message = '评论内容:' . $content;
         D('Common/Message')->sendMessage($uid, $message, $title, $referer_url, $post_uid, 0, $app);
     }
     //通知被@到的人
     $uids = get_at_uids($content);
     if ($uids) {
         foreach ($uids as $_uid) {
             if ($_uid == $uid || $_uid == $post_uid) {
                 continue;
             }
             $title = '用户「' . $data['nickname'] . '」@了您';
             $message = '评论内容:' . $content;
             D('Common/Message')->sendMessage($_uid, $message, $title, $referer_url, $post_uid, 0, $app);
         }
     }
     //返回结果
     $this->success('评论成功', 'refresh');
 }
 public function getCheckRank()
 {
     $getranktime = get_addon_config('Rank_checkin');
     $set_ranktime = $getranktime['ranktime'];
     $y = date("Y", time());
     $m = date("m", time());
     $d = date("d", time());
     $start_time = mktime($set_ranktime, 0, 0, $m, $d, $y);
     $this->assign("ss", $start_time);
     $rank = S('check_rank');
     if (empty($rank)) {
         $rank = D('Check_info')->where('ctime>' . $start_time)->order('ctime asc')->limit(5)->select();
         S('check_rank', $rank, 60);
     }
     if (time() <= $start_time) {
         $return = array('time' => $start_time);
     } else {
         foreach ($rank as &$v) {
             $v['userInfo'] = query_user(array('avatar128', 'space_url', 'nickname', 'uid'), $v['uid']);
         }
         $return = array('list' => $rank);
     }
     if (isset($return['time'])) {
         $this->apiError('签到还未开始。', '8000', $return);
     } else {
         $this->apiSuccess('获取成功。', $return);
     }
 }