public function receive() { global $_W; $type = $this->message['type']; //这里定义此模块进行消息订阅时的, 消息到达以后的具体处理过程, 请查看WORMWOOD文档来编写你的代码 if ($type != "text" && $type != "image" && $type != "voice") { return; } $file = IA_ROOT . '/source/modules/mechat/function.php'; if (!file_exists($file)) { return array(); } include_once $file; $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `weid`=:weid"; $row = pdo_fetch($sql, array(':weid' => $_W['weid'])); if ($row) { $pdata = array("ToUserName" => $this->message['tousername'], "FromUserName" => $this->message['fromusername'], "CreateTime" => $this->message['createtime'], "MsgType" => $this->message['msgtype'], "Content" => $this->message['content'], "MsgId" => $this->message['msgid']); if ($type == "voice") { $pdata["MsgType"] = "text"; $pdata["Content"] = "系统:微信公众号粉丝发送语音消息,系统暂不能接收请客服处理。"; } $dat = array('unit' => $row["name"], 'msg' => json_encode($pdata)); $dat2 = iunserializer($row["cdata"]); $actoken = account_mechat_token(array("weid" => $_W['weid'], "access_token" => $dat2["access_token"], "appid" => $dat2["appid"], "appsecret" => $dat2["appsecret"])); $url = sprintf($this->gateway['mechat_receive'], $actoken); $content = ihttp_post($url, $dat); } }
public function __construct() { global $_W; $sql = 'SELECT `settings` FROM ' . tablename('uni_account_modules') . ' WHERE `uniacid` = :uniacid AND `module` = :module'; $settings = pdo_fetchcolumn($sql, array(':uniacid' => $_W['uniacid'], ':module' => 'feng_fightgroups')); $this->settings = iunserializer($settings); }
/** * 存储全局 jsapi_ticket * * @return */ public static function get_jsapi_ticket() { global $_W; $item = pdo_fetch("SELECT jsapi_ticket FROM " . tablename('wechats') . " WHERE weid = :weid", array(':weid' => $weid)); $item = json_decode(iunserializer($item['jsapi_ticket']), 1); $jsapi_ticket = isset($_W['account']['jsapi_ticket']['ticket']) ? $_W['account']['jsapi_ticket']['ticket'] : $item['ticket']; $expire_time = isset($_W['account']['jsapi_ticket']['expire']) ? $_W['account']['jsapi_ticket']['expire'] : $item['expire']; if ($expire_time < time()) { $access_token = self::get_access_token(); $url = "http://api.weixin.qq.com/cgi-bin/ticket/getticket?type=1&access_token={$access_token}"; $arr = self::get_curl($url); if (empty($arr['ticket']) || empty($arr['expires_in'])) { message('获取微信公众号授权失败, 请稍后重试! 公众平台返回原始数据为: <br />' . $arr['errcode'] . $arr['errmsg']); } $record = array(); $record['ticket'] = $arr['ticket']; //保存全局票据 $record['expire'] = time() + $arr['expires_in']; //保存过期时间 $row = array(); $row['jsapi_ticket'] = iserializer($record); //序列化保存 pdo_update('wechats', $row, array('weid' => $_W['weid'])); $_W['account']['jsapi_ticket']['ticket'] = $record['ticket']; //写入全局 $_W['account']['jsapi_ticket']['expire'] = $record['expire']; $ticket = $record['ticket']; } else { $ticket = $jsapi_ticket; } return $ticket; }
private function getJsApiTicket() { global $_W; $data = array(); $wechat = pdo_fetch("SELECT access_token FROM " . tablename('wechats') . " WHERE weid = {$_W['weid']}"); $AccessToken = iunserializer($wechat['access_token']); $now = time(); if ($AccessToken['expire'] < $now || !$AccessToken['ticket']) { //失效时,从服务器获取最新的access_token和ticket $res = ihttp_get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appId}&secret={$this->appSecret}"); $content = @json_decode($res['content'], true); $access_token = $content['access_token']; $res1 = ihttp_get("https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token={$access_token}"); $content1 = @json_decode($res1['content'], true); $ticket = $content1['ticket']; $data['token'] = $access_token; $data['expire'] = $now + 7000; //是7200秒失效,这里取7000 $data['ticket'] = $ticket; pdo_update("wechats", array('access_token' => serialize($data)), array('weid' => $_W['weid'])); } else { $ticket = $AccessToken['ticket']; } return $ticket; }
/** * 读取缓存,并将缓存加载至 $_W 全局变量中 * @param string $key 缓存键名,如果键名以:结束,则做为分组名称读取所有缓存 * */ function cache_load($key, $unserialize = false) { global $_W; if (substr($key, -1) == ':') { $data = cache_search($key); foreach ($data as $k => $v) { $tmp =& cache_global($k); $tmp = $unserialize ? iunserializer($v) : $v; } return cache_global($key); } else { $data = cache_read($key); if ($key == 'setting') { $_W['setting'] = $data; return $_W['setting']; } elseif ($key == 'modules') { $_W['modules'] = $data; return $_W['modules']; } else { $tmp =& cache_global($key); $tmp = $unserialize ? iunserializer($data) : $data; return $unserialize ? iunserializer($data) : $data; } } }
function card_setting($uniacid = 0) { global $_W; $uniacid = intval($uniacid); if ($uniacid <= 0) { $uniacid = $_W['uniacid']; } $data = pdo_get('mc_card', array('uniacid' => $uniacid)); if (empty($data)) { return error(-1, '会员卡不存在或已经被删除'); } if (!empty($data['color'])) { $data['color'] = iunserializer($data['color']); } $data['color'] = iunserializer($data['color']); $data['background'] = iunserializer($data['background']); $data['fields'] = iunserializer($data['fields']); $data['discount'] = iunserializer($data['discount']); if (!empty($data['discount']) && $data['discount_type'] != 0) { $discount = array(); foreach ($data['discount'] as $key => $val) { $key_condition = 'condition_' . $data['discount_type']; $key_discount = 'discount_' . $data['discount_type']; $discount[$key] = array('condition' => $val[$key_condition], 'discount' => $data['discount_type'] == 1 ? $val[$key_discount] : $val[$key_discount] / 10); } $data['discount'] = $discount; } $data['grant'] = iunserializer($data['grant']); return $data; }
function module_build_privileges() { $uniacid_arr = pdo_fetchall('SELECT uniacid, groupid FROM ' . tablename('uni_account')); foreach ($uniacid_arr as $uniacid) { if (empty($uniacid['groupid'])) { $modules = pdo_fetchall("SELECT name FROM " . tablename('modules') . " WHERE issystem = 1 ORDER BY issystem DESC, mid ASC", array(), 'name'); } elseif ($uniacid['groupid'] == '-1') { $modules = pdo_fetchall("SELECT name FROM " . tablename('modules') . " ORDER BY issystem DESC, mid ASC", array(), 'name'); } else { $wechatgroup = pdo_fetch("SELECT `modules` FROM " . tablename('uni_group') . " WHERE id = '{$uniacid['groupid']}'"); $ms = ''; if (!empty($wechatgroup['modules'])) { $wechatgroup['modules'] = iunserializer($wechatgroup['modules']); if (!empty($wechatgroup['modules'])) { $ms = implode("','", array_keys($wechatgroup['modules'])); $ms = " OR `name` IN ('{$ms}')"; } } $modules = pdo_fetchall("SELECT name FROM " . tablename('modules') . " WHERE issystem = 1{$ms} ORDER BY issystem DESC, mid ASC", array(), 'name'); } $modules = array_keys($modules); $mymodules = pdo_fetchall("SELECT `module` FROM " . tablename('uni_account_modules') . " WHERE uniacid = '{$uniacid['uniacid']}' ORDER BY enabled DESC ", array(), 'module'); $mymodules = array_keys($mymodules); foreach ($modules as $module) { if (!in_array($module, $mymodules)) { $data['uniacid'] = $uniacid['uniacid']; $data['module'] = $module; $data['enabled'] = in_array($module, array('basic', 'news', 'userapi', 'music')) ? 1 : 0; $data['settings'] = ''; pdo_insert('uni_account_modules', $data); } } } return true; }
public function fieldsFormDisplay($rid = 0) { load()->model('mc'); global $_W, $_GPC; //要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0 $creditnames = uni_setting($_W['uniacid'], array('creditnames')); if ($creditnames) { foreach ($creditnames['creditnames'] as $index => $creditname) { if ($creditname['enabled'] == 0) { unset($creditnames['creditnames'][$index]); } } $scredit = implode(', ', array_keys($creditnames['creditnames'])); } else { $scredit = ''; } $groups = mc_groups($_W['uniacid']); $couponlists = pdo_fetchall('SELECT couponid,title,type,credittype,credit,endtime,amount,dosage FROM ' . tablename('activity_coupon') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime ORDER BY endtime ASC ', array(':uniacid' => $_W['uniacid'], ':type' => 1, ':endtime' => TIMESTAMP)); $tokenlists = pdo_fetchall('SELECT couponid,title,type,credittype,credit,endtime,amount,dosage FROM ' . tablename('activity_coupon') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime ORDER BY endtime ASC ', array(':uniacid' => $_W['uniacid'], ':type' => 2, ':endtime' => TIMESTAMP)); $goodslists = pdo_fetchall('SELECT id,title,type,credittype,endtime,total,num,credit FROM ' . tablename('activity_exchange') . ' WHERE uniacid = :uniacid AND type = :type AND endtime > :endtime ORDER BY endtime ASC', array(':uniacid' => $_W['uniacid'], ':type' => 3, ':endtime' => TIMESTAMP)); //print_r($couponlists); load()->func('tpl'); if ($rid == 0) { $reply = array('title' => '幸运大抽奖活动开始了!', 'description' => '幸运大抽奖活动开始啦!', 'tips' => '每次抽奖需要花费50积分,一等奖为39元的现金抵扣券,二等奖为100积分,三等奖为50积分,四等奖为30积分。每人每天限抽2次。', 'remark' => '中奖积分请到会员主页查看', 'starttime' => time(), 'endtime' => time() + 10 * 84400, 'reg' => '0', 'status' => '1', 'awardnum' => '1', 'playnum' => '5', 'dayplaynum' => '1', 'zfcs' => '1', 'zjcs' => '1', 'rate' => '10', 'need_type' => 'credit1', 'need_num' => '0', 'give_type' => 'credit1', 'give_num' => '0', 'onlynone' => '1', 'share_title' => '欢迎参加幸运大抽奖活动', 'share_content' => '亲,欢迎参加幸运大抽奖活动,祝您好运哦!! 亲,需要绑定账号才可以参加哦'); $prizes = array('p1_type' => 'credit1'); } else { $reply = pdo_fetch("SELECT * FROM " . tablename($this->table_reply) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); $prizes = iunserializer($reply['prizes']); } include $this->template('form'); }
public function receive() { global $_W, $_GPC; $type = $this->message['type']; $uniacid = $_W['uniacid']; $acid = $_W['acid']; $openid = $this->message['from']; $event = $this->message['event']; $cfg = $this->module['config']; file_put_contents(IA_ROOT . '/addons/fm_photosvote/test/fm_test.txt', iserializer($event)); if ($event == 'unsubscribe') { $record = array('updatetime' => TIMESTAMP, 'follow' => '0', 'unfollowtime' => TIMESTAMP); pdo_update('mc_mapping_fans', $record, array('openid' => $openid, 'acid' => $acid, 'uniacid' => $uniacid)); if ($cfg['isopenjsps']) { $fmvotelog = pdo_fetchall("SELECT tfrom_user FROM " . tablename('fm_photosvote_votelog') . " WHERE from_user = :from_user and uniacid = :uniacid LIMIT 1", array(':from_user' => $openid, ':uniacid' => $uniacid)); foreach ($fmvotelog as $log) { $fmprovevote = pdo_fetch("SELECT photosnum,hits FROM " . tablename('fm_photosvote_provevote') . " WHERE from_user = :from_user and uniacid = :uniacid LIMIT 1", array(':from_user' => $log['tfrom_user'], ':uniacid' => $uniacid)); pdo_update('fm_photosvote_provevote', array('lasttime' => TIMESTAMP, 'photosnum' => $fmprovevote['photosnum'] - 1, 'hits' => $fmprovevote['hits'] - 1), array('from_user' => $log['tfrom_user'], 'uniacid' => $uniacid)); } pdo_delete('fm_photosvote_votelog', array('from_user' => $openid)); pdo_delete('fm_photosvote_bbsreply', array('from_user' => $openid)); } } elseif ($event == 'subscribe') { if ($cfg['oauthtype'] == 2) { $wechats = pdo_fetch("SELECT * FROM " . tablename('account_wechats') . " WHERE uniacid = :uniacid ", array(':uniacid' => $_W['uniacid'])); $token = iunserializer($wechats['access_token']); $arrlog = pdo_fetch("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE uniacid = :uniacid AND openid = :openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid)); $access_token = $token['token']; $expire = $token['expire']; if (time() >= $expire || empty($access_token)) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $wechats['key'] . "&secret=" . $wechats['secret']; $html = file_get_contents($url); $arr = json_decode($html, true); $access_token = $arr['access_token']; $record = array(); $record['token'] = $access_token; $record['expire'] = time() + 3600; $row = array(); $row['access_token'] = iserializer($record); pdo_update('account_wechats', $row, array('uniacid' => $_W['uniacid'])); } $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $openid . "&lang=zh_CN"; $html = file_get_contents($url); $re = @json_decode($html, true); if (!empty($arrlog)) { $data = array('nickname' => $re['nickname'], 'unionid' => $re['unionid']); pdo_update('mc_mapping_fans', $data, array('openid' => $openid)); } else { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $nickname = $re['nickname']; $data = array('uniacid' => $_W['uniacid'], 'nickname' => $re['nickname'], 'avatar' => $re['headimgurl'], 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); pdo_insert('mc_members', $data); $id = pdo_insertid(); $data = array('nickname' => $re['nickname'], 'unionid' => $re['unionid'], 'uid' => $id); pdo_update('mc_mapping_fans', $data, array('openid' => $openid)); } } } }
function get_settings() { $value = pdo_fetchcolumn("SELECT value FROM " . tablename("core_settings") . " WHERE `key`=:key", array(":key" => "kim_financial")); if (empty($value)) { return array(); } return @iunserializer($value); }
public function __construct($uniAccount) { $this->account = $uniAccount; if (empty($this->account)) { trigger_error('error uniAccount id, can not construct ' . __CLASS__, E_USER_WARNING); } $this->account['access_token'] = iunserializer($this->account['access_token']); }
public function fieldsFormDisplay($rid = 0) { global $_W; $uniacid = $_W['uniacid']; load()->func('tpl'); $creditnames = array(); $unisettings = uni_setting($uniacid, array('creditnames')); foreach ($unisettings['creditnames'] as $key => $credit) { if (!empty($credit['enabled'])) { $creditnames[$key] = $credit['title']; } } if (!empty($rid)) { $reply = pdo_fetch("SELECT * FROM " . tablename('stonefish_planting_reply') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); $share = pdo_fetchall("SELECT * FROM " . tablename('stonefish_planting_share') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); $prize = pdo_fetchall("SELECT * FROM " . tablename('stonefish_planting_prize') . " WHERE rid = :rid ORDER BY `id` asc", array(':rid' => $rid)); //查询奖品是否可以删除 foreach ($prize as $mid => $prizes) { $prize[$mid]['fans'] = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('stonefish_planting_award') . " WHERE prizetype = :prizeid", array(':prizeid' => $prizes['id'])); $prize[$mid]['delete_url'] = $this->createWebUrl('deleteprize', array('rid' => $rid, 'id' => $prizes['id'])); } //查询奖品是否可以删除 } $seed = pdo_fetchall("SELECT * FROM " . tablename('stonefish_planting_seed') . " WHERE uniacid = :uniacid Or uniacid = 0 ORDER BY `id` asc", array(':uniacid' => $uniacid)); if (!$reply) { $now = time(); $reply = array("title" => "种值活动开始了!", "start_picurl" => "../addons/stonefish_planting/template/images/start.jpg", "description" => "欢迎参加种值活动", "repeat_lottery_reply" => "亲,继续努力哦~~", "ticket_information" => "请用力摇晃你的手机抽奖", "starttime" => $now, "endtime" => strtotime(date("Y-m-d H:i", $now + 7 * 24 * 3600)), "end_theme" => "种值活动已经结束了", "end_instruction" => "亲,活动已经结束,请继续关注我们的后续活动哦~", "end_picurl" => "../addons/stonefish_planting/template/images/end.jpg", "homepic" => "../addons/stonefish_planting/template/images/home.jpg", "adpic" => "../addons/stonefish_planting/template/images/banner.png", "award_times" => 1, "credit_times" => 5, "show_num" => 2, "awardnum" => 50, "xuninum" => 500, "xuninumtime" => 86400, "xuninuminitial" => 10, "xuninumending" => 100, "ticketinfo" => "请输入详细资料,兑换奖品", "isrealname" => 1, "ismobile" => 1, "isfans" => 1, "isfansname" => "真实姓名,手机号码,QQ号,邮箱,地址,性别,固定电话,证件号码,公司名称,职业,职位", "homepictime" => 0); } else { $reply['notawardtext'] = implode("\n", (array) iunserializer($reply['notawardtext'])); } //print_r(uni_modules($enabledOnly = true)); //exit; //查询是否有商户网点权限 $modules = uni_modules($enabledOnly = true); $modules_arr = array(); $modules_arr = array_reduce($modules, create_function('$v,$w', '$v[$w["mid"]]=$w["name"];return $v;')); if (in_array('stonefish_branch', $modules_arr)) { $stonefish_branch = true; } //查询是否有商户网点权限 //查询子公众号信息 $acid_arr = uni_accounts(); $ids = array(); $ids = array_map('array_shift', $acid_arr); //子公众账号Arr数组 $ids_num = count($ids); //多少个子公众账号 $one = current($ids); //查询子公众号信息 if (!$share) { $share = array(); foreach ($ids as $acid => $idlists) { $share[$acid] = array("acid" => $acid, "share_url" => $acid_arr[$acid]['subscribeurl'], "share_title" => "已有#参与人数#人参与本活动了,你的朋友#参与人# 还中了大奖:#奖品#,请您也来试试吧!", "share_desc" => "亲,欢迎参加种值活动,祝您好运哦!! 亲,需要绑定账号才可以参加哦", "share_picurl" => "../addons/stonefish_planting/template/images/share.png", "share_pic" => "../addons/stonefish_planting/template/images/img_share.png", "sharenumtype" => 0, "sharenum" => 0, "sharetype" => 1); } } include $this->template('form'); }
public function get($weid, $modulename) { $settings = null; $result = pdo_fetchcolumn("SELECT settings FROM " . tablename(self::$t_module) . " WHERE uniacid= :weid AND module= :name LIMIT 1", array(':name' => $modulename, ':weid' => $weid)); if (!empty($result)) { $settings = iunserializer($result); } return $settings; }
public function __construct($account) { $sql = 'SELECT * FROM ' . tablename('account_yixin') . ' WHERE `acid`=:acid'; $this->account = pdo_fetch($sql, array(':acid' => $account['acid'])); if (empty($this->account)) { trigger_error('error uniAccount id, can not construct ' . __CLASS__, E_USER_WARNING); } $this->account['access_token'] = iunserializer($this->account['access_token']); }
public function __construct($uniAccount) { $this->account = $uniAccount; if (empty($this->account)) { trigger_error('error uniAccount id, can not construct ' . __CLASS__, E_USER_WARNING); } $this->account['access_token'] = iunserializer($this->account['access_token']); $this->apis = array('barcode' => array('post' => 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=%s', 'display' => 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s')); }
function cache_build_setting() { $sql = 'SELECT * FROM ' . tablename('settings'); $setting = pdo_fetchall($sql, array(), 'key'); if(is_array($setting)) { foreach($setting as $k => $v) { $setting[$v['key']] = iunserializer($v['value']); } cache_write('setting', $setting); } }
public function getSet() { global $_W, $_GPC; $set = m('common')->getSetData(); $allset = iunserializer($set['plugins']); if (is_array($allset) && isset($allset[$this->pluginname])) { return $allset[$this->pluginname]; } return array(); }
function __secure_decode($post) { global $_W; $ret = iunserializer($post); $string = $ret['data'] . $_W['setting']['site']['token']; if (md5($string) == $ret['sign']) { return $ret['data']; } return false; }
public function fieldsFormDisplay($rid = 0) { //要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0 global $_W; if (!empty($rid)) { $reply = pdo_fetch("SELECT * FROM " . tablename($this->table_reply) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); $award = pdo_fetchall("SELECT * FROM " . tablename($this->table_gift) . " WHERE rid = :rid ORDER BY `id` ASC", array(':rid' => $rid)); if (!empty($award)) { foreach ($award as &$pointer) { if (!empty($pointer['activation_code'])) { $pointer['activation_code'] = implode("\n", (array) iunserializer($pointer['activation_code'])); } } } } else { $reply = array('periodlottery' => 1, 'maxlottery' => 1); } $reply['start_time'] = empty($reply['start_time']) ? strtotime(date('Y-m-d H:i')) : $reply['start_time']; $reply['end_time'] = empty($reply['end_time']) ? strtotime("+1 week") : $reply['end_time']; $reply['status'] = !isset($reply['status']) ? "1" : $reply['status']; $reply['subscribe'] = !isset($reply['subscribe']) ? "1" : $reply['subscribe']; $reply['opensubscribe'] = !isset($reply['opensubscribe']) ? "4" : $reply['opensubscribe']; $reply['share_shownum'] = !isset($reply['share_shownum']) ? "50" : $reply['share_shownum']; $reply['biaobiaonum'] = !isset($reply['biaobiaonum']) ? "50" : $reply['biaobiaonum']; $reply['picture'] = empty($reply['picture']) ? "./source/modules/stonefish_grabgifts/template/images/big_ads.jpg" : $reply['picture']; $reply['bgcolor'] = empty($reply['bgcolor']) ? "#eef3ef" : $reply['bgcolor']; $reply['textcolor'] = empty($reply['textcolor']) ? "#8d9695" : $reply['textcolor']; $reply['textcolort'] = empty($reply['textcolort']) ? "#f12500" : $reply['textcolort']; $reply['textcolorb'] = empty($reply['textcolorb']) ? "#cfd4d0" : $reply['textcolorb']; $reply['bgcolorbottom'] = empty($reply['bgcolorbottom']) ? "#ffffff" : $reply['bgcolorbottom']; $reply['bgcolorbottoman'] = empty($reply['bgcolorbottoman']) ? "#23cba8" : $reply['bgcolorbottoman']; $reply['textcolorbottom'] = empty($reply['textcolorbottom']) ? "#ffffff" : $reply['textcolorbottom']; $reply['bgcolorjiang'] = empty($reply['bgcolorjiang']) ? "#23cba8" : $reply['bgcolorjiang']; $reply['textcolorjiang'] = empty($reply['textcolorjiang']) ? "#ffffff" : $reply['textcolorjiang']; $reply['userinfo'] = empty($reply['userinfo']) ? "为了将奖品更快、更准确的送达您手中,请留下您的个人信息,谢谢!" : $reply['userinfo']; $reply['isrealname'] = !isset($reply['isrealname']) ? "1" : $reply['isrealname']; $reply['ismobile'] = !isset($reply['ismobile']) ? "1" : $reply['ismobile']; $reply['isfans'] = !isset($reply['isfans']) ? "1" : $reply['isfans']; $reply['copyrighturl'] = empty($reply['copyrighturl']) ? "http://" . $_SERVER['HTTP_HOST'] : $reply['copyrighturl']; $reply['iscopyright'] = !isset($reply['iscopyright']) ? "0" : $reply['iscopyright']; $reply['copyright'] = empty($reply['copyright']) ? $_W['account']['name'] : $reply['copyright']; $shouquan = base64_encode($_SERVER['HTTP_HOST'] . 'anquan_ma_grabgifts'); $reply['xuninum'] = !isset($reply['xuninum']) ? "500" : $reply['xuninum']; $reply['xuninumtime'] = !isset($reply['xuninumtime']) ? "86400" : $reply['xuninumtime']; $reply['xuninuminitial'] = !isset($reply['xuninuminitial']) ? "10" : $reply['xuninuminitial']; $reply['xuninumending'] = !isset($reply['xuninumending']) ? "50" : $reply['xuninumending']; $picture = $reply['picture']; if (substr($picture, 0, 6) == 'images') { $picture = $_W['attachurl'] . $picture; } if (substr($picture, 0, 6) == 'images') { $picture = $_W['attachurl'] . $picture; } include $this->template('form'); }
public function fieldsFormDisplay($rid = 0) { global $_W, $_GPC; if (!empty($rid)) { $reply = pdo_fetch("SELECT * FROM " . tablename('we7_photomaker') . " WHERE rid = :rid", array(':rid' => $rid)); $reply['adpics'] = iunserializer($reply['adpics']); } else { $reply = array('token' => random(6, 1), 'maxuse' => 1, 'status' => 1, 'enablemsg' => 1, 'enableauthcode' => 1, 'size' => '5', 'maxtotal' => '-1', 'adtype' => 1); } include $this->template('rule'); }
function card_credit_set() { global $_W; $set = array(); $set = pdo_get('mc_card_credit_set', array('uniacid' => $_W['uniacid'])); if (!empty($set)) { $set['sign'] = iunserializer($set['sign']); $set['share'] = iunserializer($set['share']); } return $set; }
/** * 检索缓存中指定层级或分组的所有缓存 * @param 缓存分组 * @return array */ function cache_search($prefix) { $sql = 'SELECT * FROM ' . tablename('cache') . ' WHERE `key` LIKE :key'; $params = array(); $params[':key'] = "{$prefix}%"; $rs = pdo_fetchall($sql, $params); $result = array(); foreach((array)$rs as $v) { $result[$v['key']] = iunserializer($v['value']); } return $result; }
function getMobileTypeForId($id) { $mobileType = pdo_fetch("SELECT * FROM " . tablename('mobile_type') . " WHERE `id`=:id", array('id' => $id)); $data = iunserializer($mobileType['field_score']); if (is_array($data)) { $mobileType['field_score'] = $data; } else { $mobileType['field_score'] = array(); } return $mobileType; }
public function fieldsFormDisplay($rid = 0) { global $_W; //要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0 if ($rid == 0) { $reply = array('title' => '集阅读活动开始了!', 'description' => '集阅读活动开始啦!', 'topimg' => $_W['siteroot'] . 'addons/ju_read/template/style/img/1.jpg', 'bgcolor' => '#266f98', 'starttime' => time(), 'endtime' => time() + 10 * 84400, 'status' => 1, 'tips' => '抵用劵都是在原价基础上抵用,特价产品不加入本次活动。'); } else { $reply = pdo_fetch("SELECT * FROM " . tablename($this->table_reply) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); $data = iunserializer($reply['prizes']); } include $this->template('form'); }
public function doDisplay() { //这个操作被定义用来呈现主导航栏上扩展菜单,每个模块只能呈现一个扩展菜单,有更多选项,请在页面内使用标签页来表示 global $_W, $_GPC; $mechat = array(); if (checksubmit('submit')) { $file = IA_ROOT . '/source/modules/mechat/function.php'; if (!file_exists($file)) { return array(); } include_once $file; $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `weid`=:weid"; $row = pdo_fetch($sql, array(':weid' => $_W['weid'])); if ($row) { $dat = iunserializer($row["cdata"]); $pass = $dat["pass"]; if ($_GPC['mechat-pass'] != $pass) { $pass = md5($_GPC['mechat-pass']); } $mechat = array("name" => $_GPC['mechat-user'], "pass" => $pass, "appid" => $_GPC['mechat-appid'], "appsecret" => $_GPC['mechat-appsecret']); $access_token = array("token" => $dat["access_token"]["token"], "expire" => $dat["access_token"]["expire"]); $update = array("name" => $_GPC['mechat-user'], "cdata" => iserializer($mechat), "access_token" => $access_token); pdo_update($this->tablename, $update, array('weid' => $_W['weid'])); } else { $pass = md5($_GPC['mechat-pass']); $mechat = array("name" => $_GPC['mechat-user'], "pass" => $pass, "appid" => $_GPC['mechat-appid'], "appsecret" => $_GPC['mechat-appsecret']); $access_token = array("token" => "", "expire" => ""); pdo_insert($this->tablename, array("weid" => $_W['weid'], "name" => $_GPC['mechat-user'], "cdata" => iserializer($mechat), "access_token" => $access_token, "createtime" => TIMESTAMP)); } //exit(json_encode($_W)); $dat = array("unit" => $_GPC['mechat-user'], "password" => $pass, "wxAppid" => $_W['account']['key'], "wxAppsecret" => $_W['account']['secret']); $actoken = account_mechat_token(array("weid" => $_W['weid'], "access_token" => $access_token, "appid" => $_GPC['mechat-appid'], "appsecret" => $_GPC['mechat-appsecret'])); $url = sprintf("http://open.mobilechat.im/cgi-bin/weixin/bind?access_token=%s", $actoken); $content = ihttp_post($url, $dat); $dat2 = $content['content']; $result = @json_decode($dat2, true); if ($result["errcode"] == "0") { message('恭喜,微信服务号与美洽企业帐号绑定成功!', create_url('index/module/display', array('name' => 'mechat')), 'success'); } else { message("微信服务号与美洽企业帐号绑定错误. <br />参数: " . json_encode($dat) . "<br />错误代码为: {$result['errcode']} <br />错误信息为: {$result['errmsg']}"); } } $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `weid`=:weid"; $row = pdo_fetch($sql, array(':weid' => $_W['weid'])); if ($row) { $mechat["name"] = $row["name"]; $dat = iunserializer($row["cdata"]); $mechat["pass"] = $dat["pass"]; $mechat["appid"] = $dat["appid"]; $mechat["appsecret"] = $dat["appsecret"]; } include $this->template('display'); }
/** * 获得打印任务列表 * @param $lasttime 最后创建时间 * @return array */ function biz_Print_getTask($module) { $sql = 'select id,title,copy,printtype,printid,printname,templateid,printdata,creator from ' . tablename('printtask'); $params = array(); $sql .= ' where moduleid=:moduleid and complate=0'; $params[':moduleid'] = $module['id']; $list = pdo_fetchall($sql, $params); foreach ($list as &$item) { $item['printdata'] = iunserializer($item['printdata']); } unset($item); return $list; }
function cache_load($key, $unserialize = false) { global $_W; $data = $_W['cache'][$key] = cache_read($key); if ($key == 'setting') { $_W['setting'] = $data; return $_W['setting']; } elseif ($key == 'modules') { $_W['modules'] = $data; return $_W['modules']; } else { return $unserialize ? iunserializer($data) : $data; } }
public function respond() { global $_W, $engine; $level = array(); if (!empty($_W['account']['modules'])) { foreach ($_W['account']['modules'] as $row) { if (!empty($row['displayorder']) && $row['displayorder'] < 127) { $level[$row['displayorder']] = $row; } } } if (!empty($level)) { $response = ''; for ($i = 1; $i <= 5; $i++) { if (!empty($response)) { $engine->response['module'] = $_W['module']; return $response; break; } if (empty($level[$i])) { continue; } $_W['module'] = $level[$i]['name']; $processor = WeUtility::createModuleProcessor($_W['module']); $processor->message = $this->message; $processor->inContext = false; $processor->rule = $this->rule; $engine->response['rule'] = $default['id']; $response = $processor->respond(); } } if (!empty($_W['account']['default_period']) && empty($_W['cache']['default_period'])) { return; } $response['FromUserName'] = $this->message['to']; $response['ToUserName'] = $this->message['from']; $response['MsgType'] = 'text'; $default = pdo_fetchcolumn("SELECT `default` FROM " . tablename('wechats') . " WHERE `weid`=:weid", array(':weid' => $_W['weid'])); if (is_array(iunserializer($default))) { $default = iunserializer($default); $_W['module'] = $default['module']; $processor = WeUtility::createModuleProcessor($default['module']); $processor->message = $this->message; $processor->inContext = $this->inContext; $processor->rule = $default['id']; return $processor->respond(); } $response['Content'] = stripslashes($default); return $response; }
function setting_load($key = '') { if (empty($key)) { $settings = pdo_fetchall('SELECT * FROM ' . tablename('settings'), array(), 'key'); } else { $key = is_array($key) ? $key : array($key); $settings = pdo_fetchall('SELECT * FROM ' . tablename('settings') . " WHERE `key` IN ('" . implode("','", $key) . "')", array(), 'key'); } if (is_array($settings)) { foreach ($settings as $k => &$v) { $settings[$k] = iunserializer($v['value']); } } return $settings; }
public function getAll() { global $_W; $path = IA_ROOT . "/addons/ewei_shop/data/perm"; if (!is_dir($path)) { load()->func('file'); @mkdirs($path); } $cachefile = $path . "/plugins"; $plugins = iunserializer(@file_get_contents($cachefile)); if (!is_array($plugins)) { $plugins = pdo_fetchall('select * from ' . tablename('ewei_shop_plugin') . ' order by displayorder asc'); file_put_contents($cachefile, iserializer($plugins)); } return $plugins; }