PHP微信公众号投票管理系统源码独立版.zip资源

   日期:2024-12-26    作者:zzwfhg 移动:http://ljhr2012.riyuangf.com/mobile/quote/36710.html
<?php

PHP微信公众号投票管理系统源码独立版.zip资源

class cls_weixin { static $perms; static $config = array(); static function get_perms($key , $site_id = null) { if( empty(self::$perms) || ($site_id !== null && $site_id != self::$perms['site_id']) ) { self::$perms = fun_kj::get_site( $site_id ); } $arr_return = array(); if(isset(self::$perms[$key])) $arr_return = self::$perms[$key]; return $arr_return; } static function get_access_token() { if(!defined('cls_klkkdj::KJ_VERISION')) { fun_base::url_jump("http://www.kjcms.com/api.php?app=copy&app_act=verify.none"); exit; } $site_id = self::get_perms('site_id'); $token = cls_cache::get('access_token' , 'weixin/' . $site_id , 3); if(empty($token)) { $appid = self::get_perms('appid'); $appsecret = self::get_perms('appsecret'); if(empty($appid) || empty($appsecret)) return ''; $cont = file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $appsecret); if(empty($cont)) return ''; $arr = fun_format::toarray($cont); if(isset($arr['access_token'])) { $token = $arr['access_token']; cls_cache::set($token ,'access_token' , 'weixin/' . $site_id); } } return $token; } //上传媒体文件 static function on_media_upload($path , $type , $site_id = 0) { $arr_type = self::get_perms('mediatype'); if(!isset($arr_type[$type])) return array('code' => 500 , 'msg' => '上传类型不存在'); $real_path = fun_get::real_path($path); $ext = strtolower(end(explode("." , $real_path))); $exts = implode(',' , $arr_type[$type]); if(!in_array($ext , $arr_type[$type])) return array('code' => 500 , 'msg' => '只允许上传扩展名为' . $exts . '的文件'); if(!is_file($real_path)) return array("code" => 500 , "msg" => "上传失败"); $access_token = self::get_access_token(); if(empty($access_token)) return array('code' => 500 , 'msg' => '微信权限不够'); $url = 'http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=' . $access_token . '&type=' . $type; $arr_return = fun_base::post($url , array() , array(basename($real_path) => $real_path) ); if($arr_return['code'] == 0) { $arr_media = fun_format::toarray($arr_return['cont']); if(isset($arr_media['media_id'])) { $size = filesize($real_path); //保存进数据库媒体表 $arr_fields = array( 'media_id' => $arr_media['media_id'], 'media_type' => $arr_media['type'] , 'media_time' => $arr_media['created_at'], 'media_uid' => cls_obj::get('cls_user')->uid, 'media_file' => $path, 'media_size' => $size, 'media_site_id' => $site_id, ); $arr_save = cls_obj::db_w()->on_insert(cls_config::DB_PRE."weixin_media",$arr_fields); $arr_media['code'] = 0; } else { $arr_media['msg'] = (isset($arr_media['errmsg'])) ? $arr_media['errmsg'] : ''; $arr_media['code'] = 500; } } else { $arr_media = $arr_return; } return $arr_media; } //下载媒体文件 static function get_media($mid) { $access_token = self::get_access_token(); if(empty($access_token)) return ''; $cont = file_get_contents('http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=' . $access_token . '&media_id=' . $mid); return $cont; } //接收消息 static function get_msg() { $arr_return = array(); $cont = file_get_contents("php://input"); //$cont = file_get_contents(KJ_DIR_ROOT . "/test.txt"); if(empty($cont)) return $arr_return; $request = simplexml_load_string($cont , 'SimpleXmlElement' , LIBXML_NOCDATA); $arr_return = fun_format::toarray($request); return $arr_return; } //验证 static function check_signature() { $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = self::get_access_token(); $tmpArr = array($token, $timestamp, $nonce); sort($tmpArr); $tmpStr = implode( $tmpArr ); $tmpStr = sha1( $tmpStr ); if( $tmpStr == $signature ){ return fun_get::get("echostr"); } else { return ''; } } //处理消息 static function on_exe() { $arr_msg = self::get_msg(); //$arr_msg = array('ToUserName'=>'dkd','FromUserName'=>'bbb','MsgType'=>'text','Content'=>'d'); if(empty($arr_msg['ToUserName'])) return; self::$config['wx_id'] = $arr_msg['FromUserName']; $arr_message = $arr_cont = array(); if($arr_msg['MsgType'] == 'text') { $arr = explode(",",str_replace("," , "," , $arr_msg['Content'])); if(is_numeric($arr[0])) { //是店铺用户 $obj_shop = cls_obj::db()->get_one("select shop_id from " . cls_config::DB_PRE . "meal_shop where shop_weixin_id='" . $arr_msg['FromUserName'] . "'"); if(!empty($obj_shop)) { $oid = $arr[0]; if(count($arr)>1) { unset($arr[0]); $beta = implode("," , $arr); } else { $beta = ''; } $state = (empty($beta)) ? 1 : -1; $where = " order_shop_id='" . $obj_shop['shop_id'] . "' and right(order_id," . strlen($oid) . ")='" . $oid . "'"; //查看订单是否存在 $obj_order = cls_obj::db()->get_one("select order_id,order_state from " . cls_config::DB_PRE . "meal_order where" . $where); if(empty($obj_order)) { $arr_cont['cont'] = '订单不存在'; } else { if($obj_order['order_state']!=0) { $arr_cont['cont'] = '无效订单或已处理过'; } else { $where .= " and order_state=0"; $arr_re = tab_meal_order::on_state('' , $state , $beta , $where); $arr_cont = array(); if($arr_re['code'] == 0) { $arr_cont['cont'] = ($state==-1) ? '取消订单成功' : '成功接收订单,请尽快配送'; } else { $arr_cont['cont'] = '处理失败,原因:' . $arr_msg['msg']; } } } } } if(empty($arr_cont)) { $msgmode = self::get_perms('msgmode'); $site_id = self::get_perms('site_id'); $shop_id = self::get_perms('shop_id'); //取自动回复消息或关键词消息 $arr_1 = tab_weixin_message::get_rekeywords($arr_msg['Content'] , $site_id); $count = count($arr_1)-1; if($count>0) { $ii = rand(0,$count); $arr_message = $arr_1[$ii]; } else if(!empty($arr_1)) { $arr_message = $arr_1[0]; } else if(!empty($msgmode)){ //主站才搜索店铺 $arr_message = array('message_type' => 'news' , 'news' => array()); if(empty($site_id)) { $obj_result = cls_obj::db()->select("select shop_id,shop_name,shop_desc,shop_area,shop_pic,shop_pic_small from " . cls_config::DB_PRE . "meal_shop where shop_name like '%" . $arr_msg['Content'] . "%' or shop_jian like '" . strtolower($arr_msg['Content']) . "%' limit 0,10"); while($obj_rs = cls_obj::db()->fetch_array($obj_result)) { if(empty($obj_rs['shop_pic_small'])) $obj_rs['shop_pic_small'] = $obj_rs['shop_pic']; if(empty($arr_message['news'])) { if(empty($obj_rs['shop_pic'])) $obj_rs['shop_pic'] = $obj_rs['shop_pic_small']; $pic = fun_get::html_url($obj_rs['shop_pic'] , 1); } else { $pic = fun_get::html_url($obj_rs['shop_pic_small'] , 1); } $url = cls_config::get('url') . '/index.php?app_weixin=1&app_act=shop&id=' . $obj_rs['shop_id']; $shop_id = $obj_rs['shop_id']; $arr_message['news'][] = array( 'title' => $obj_rs['shop_name'], "desc" => strip_tags(fun_get::filter($item['shop_desc'],true)), "pic" => $pic, "url" => $url, ); } if(count($arr_message['news']) == 1) { //搜索该店菜品 $obj_result = cls_obj::db()->select("select menu_title,menu_price,menu_pic,menu_pic_small,menu_intro from " . cls_config::DB_PRE . "meal_menu where menu_shop_id='" . $shop_id . "' and menu_tj=1 and menu_state>0 and menu_isdel=0 order by menu_price limit 0,4"); while($obj_rs = cls_obj::db()->fetch_array($obj_result)) {

特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


举报收藏 0评论 0
0相关评论
相关最新动态
推荐最新动态
点击排行
{
网站首页  |  关于我们  |  联系方式  |  使用协议  |  隐私政策  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号