public function settingsDisplay($settings) { global $_GPC, $_W; if (checksubmit()) { load()->func('file'); mkdirs(ZC_ROOT . '/cert'); $r = true; $pemname = isset($pemname) ? $pemname : time(); if (!empty($_GPC['cert'])) { $ret = file_put_contents(ZC_ROOT . '/cert/apiclient_cert.pem.' . $pemname, trim($_GPC['cert'])); $r = $r && $ret; } if (!empty($_GPC['key'])) { $ret = file_put_contents(ZC_ROOT . '/cert/apiclient_key.pem.' . $pemname, trim($_GPC['key'])); $r = $r && $ret; } if (!empty($_GPC['ca'])) { $ret = file_put_contents(ZC_ROOT . '/cert/rootca.pem.' . $pemname, trim($_GPC['ca'])); $r = $r && $ret; } if (!$r) { message('证书保存失败, 请保证 /addons/hx_zhongchou/cert/ 目录可写'); } $cfg = array('noticeemail' => $_GPC['noticeemail'], 'kfid' => $_GPC['kfid'], 'k_templateid' => $_GPC['k_templateid'], 'kfirst' => $_GPC['kfirst'], 'kfoot' => $_GPC['kfoot'], 'm_templateid' => $_GPC['m_templateid'], 'mfirst' => $_GPC['mfirst'], 'mfoot' => $_GPC['mfoot'], 'ispublish' => intval($_GPC['ispublish']), 'shopname' => $_GPC['shopname'], 'address' => $_GPC['address'], 'phone' => $_GPC['phone'], 'email' => $_GPC['email'], 'officialweb' => $_GPC['officialweb'], 'description' => htmlspecialchars_decode($_GPC['description']), 'appid' => trim($_GPC['appid']), 'secret' => trim($_GPC['secret']), 'mchid' => trim($_GPC['mchid']), 'password' => trim($_GPC['password']), 'ip' => trim($_GPC['ip']), 'pemname' => $pemname); if (!empty($_GPC['logo'])) { $cfg['logo'] = $_GPC['logo']; } if ($this->saveSettings($cfg)) { message('保存成功', 'refresh'); } } load()->func('tpl'); include $this->template('setting'); }
public function doWebRecord() { global $_GPC, $_W; checklogin(); load()->func('tpl'); $rid = intval($_GPC['id']); $condition = ''; if (!empty($_GPC['username'])) { $condition .= " AND username like '%{$_GPC['username']}%' "; } if (!empty($_GPC['sign_time'])) { $condition .= " AND sign_time = '%{$_GPC['username']}%' "; } if (empty($starttime) || empty($endtime)) { $starttime = strtotime('-1 month'); $endtime = TIMESTAMP; } if (!empty($_GPC['time'])) { $starttime = strtotime($_GPC['time']['start']); $endtime = strtotime($_GPC['time']['end']) + 86399; $condition .= " AND sign_time >= '{$starttime}' AND sign_time <= '{$endtime}' "; } $pindex = max(1, intval($_GPC['page'])); $psize = 20; $list = pdo_fetchall("SELECT * FROM " . tablename('bm_qrsign_record') . " WHERE rid = '{$rid}' {$condition} ORDER BY id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize); $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('bm_qrsign_record') . " WHERE rid = '{$rid}' "); $pager = pagination($total, $pindex, $psize); $memberlist = pdo_fetchall("SELECT distinct fromuser FROM " . tablename('bm_qrsign_record') . " WHERE rid = '{$rid}' "); $membertotal = count($memberlist); include $this->template('record'); }
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 settingsDisplay($settings) { // 声明为全局才可以访问到. global $_W, $_GPC; if (checksubmit()) { // $_GPC 可以用来获取 Cookies,表单中以及地址栏参数 $data = $_GPC['data']; // message() 方法用于提示用户操作提示 empty($data['name']) && message('请填写便利店名称'); empty($data['logo']) && message('请填写便利店 LOGO'); empty($data['linkman']) && message('请填写便利店联系人'); empty($data['phone']) && message('请填写便利店联系电话'); empty($data['address']) && message('请填写便利店地址'); empty($data['description']) && message('请填写便利店介绍'); //字段验证, 并获得正确的数据$dat if (!$this->saveSettings($data)) { message('保存信息失败', '', 'error'); } else { message('保存信息成功', '', 'success'); } } // 模板中需要用到 "tpl" 表单控件函数的话, 记得一定要调用此方法. load()->func('tpl'); //这里来展示设置项表单 include $this->template('setting'); }
public function doMobileLottery() { global $_GPC, $_W; $id = intval($_GPC['id']); $sql = 'SELECT * FROM ' . tablename('zzz_reply') . ' WHERE `rid` = :rid'; $params = array(':rid' => $id); $zzz = pdo_fetch($sql, $params); if (empty($zzz)) { message('非法访问,请重新发送消息进入!'); } checkauth(); load()->model("mc"); $profile = mc_require($_W['member']['uid'], array('nickname', 'mobile'), '需要完善资料后才能继续.'); $startgame = 1; if ($zzz['start_time'] > TIMESTAMP) { $startgame = 0; $str = "活动没开始"; } if ($zzz['end_time'] < TIMESTAMP) { $startgame = 0; $str = "活动已结束"; } if (empty($_W['fans']['fanid'])) { $sql = 'SELECT `fanid` FROM ' . tablename('mc_mapping_fans') . ' WHERE `uid` = :uid'; $params = array(':uid' => $_W['member']['uid']); $fansId = pdo_fetchcolumn($sql, $params); if (empty($fansId)) { message('必须关注公众号才可以进入游戏', $this->createMobileUrl('introduce', array('id' => $id)), 'error'); } $_W['fans']['fanid'] = $fansId; } $sql = 'SELECT * FROM ' . tablename('zzz_user') . ' WHERE `rid` = :rid AND `fanid` = :fanid'; $params = array(':rid' => $id, ':fanid' => $_W['fans']['fanid']); $myuser = pdo_fetch($sql, $params); // 用户不存在插入一条数据 if (empty($myuser)) { $zzz_user = array('rid' => $id, 'count' => 0, 'points' => 0, 'fanid' => $_W['fans']['fanid'], 'createtime' => TIMESTAMP); pdo_insert('zzz_user', $zzz_user); } $myph = ''; if (!empty($myuser)) { $sql = 'SELECT count(*) FROM ' . tablename('zzz_user') . ' WHERE `rid` = :rid AND `points` > :points'; $params = array(':rid' => $id, ':points' => $myuser['points']); $ph = pdo_fetchcolumn($sql, $params); $myph = intval($ph) + 1; } // 分享增加体力 $shareFid = intval($_GPC['shareuid']); if (!empty($shareFid)) { $sql = 'SELECT `id` FROM ' . tablename('zzz_share') . ' WHERE `rid` = :rid AND `fanid` = :fanid AND `sharefid` = :sharefid'; $params = array(':rid' => $id, ':fanid' => $_W['fans']['fanid'], 'sharefid' => $shareFid); $shareInfo = pdo_fetchcolumn($sql, $params); if (empty($shareInfo)) { pdo_insert('zzz_share', array('rid' => $id, 'fanid' => $_W['fans']['fanid'], 'sharefid' => $shareFid)); pdo_update('zzz_user', array('sharevalue' => $myuser['sharevalue'] + $zzz['sharevalue']), array('fanid' => $shareFid, 'rid' => $id)); } } $energylimit = ($zzz['maxlottery'] + $zzz['prace_times']) * 10; include $this->template('gamex'); }
function checkauth() { global $_W, $engine; load()->model('mc'); if (!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) { return true; } if (!empty($_W['openid'])) { $fan = mc_fansinfo($_W['openid'], $_W['acid'], $_W['uniacid']); if (_mc_login(array('uid' => intval($fan['uid'])))) { return true; } if (defined('IN_API')) { $GLOBALS['engine']->died("抱歉,您需要先登录才能使用此功能,点击此处 <a href='" . __buildSiteUrl(url('auth/login')) . "'>【登录】</a>"); } } $forward = base64_encode($_SERVER['QUERY_STRING']); if ($_W['isajax']) { $result = array(); $result['url'] = url('auth/login', array('forward' => $forward), true); $result['act'] = 'redirect'; exit(json_encode($result)); } else { header("location: " . url('auth/login', array('forward' => $forward)), true); } exit; }
function save() { include load('include.lang'); if ($this->file_error) { return $this->_('Error(21)' . $L['upload_failed'] . ' (' . $L['upload_error_' . $this->file_error] . ')'); } if ($this->maxsize > 0 && $this->file_size > $this->maxsize) { return $this->_('Error(22)' . $L['upload_size_limit'] . ' (' . intval($this->maxsize / 1024) . 'Kb)'); } if (!$this->is_allow()) { return $this->_('Error(23)' . $L['upload_not_allow']); } $this->set_savepath($this->savepath); $this->set_savename($this->savename); if (!is_writable(DT_ROOT . '/' . $this->savepath)) { return $this->_('Error(24)' . $L['upload_unwritable']); } if (!is_uploaded_file($this->file)) { return $this->_('Error(25)' . $L['upload_failed']); } if (!move_uploaded_file($this->file, DT_ROOT . '/' . $this->saveto)) { return $this->_('Error(26)' . $L['upload_failed']); } $this->image = $this->is_image(); if (DT_CHMOD) { @chmod(DT_ROOT . '/' . $this->saveto, DT_CHMOD); } return true; }
/** * author: codeMonkey QQ:631872807 * 全局access_token获取 * @return */ public function getAccessToken() { global $_W; $tokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->appid . "&secret=" . $this->secret; $accessToken = CRUD::findUnique(CRUD::$table_sin_token, array(":weid" => $_W['weid'])); load()->func('communication'); if (!empty($accessToken)) { $expires_in = $accessToken['expires_in']; if (TIMESTAMP - $accessToken['createtime'] >= $expires_in - 200) { // 过期 $content = ihttp_get($tokenUrl); $token = @json_decode($content['content'], true); $data = array('weid' => $_W['weid'], 'access_token' => $token['access_token'], 'expires_in' => $token['expires_in'], 'createtime' => TIMESTAMP); CRUD::updateById(CRUD::$table_sin_token, $data, $accessToken['id']); return $token['access_token']; } else { return $accessToken['access_token']; } } else { $content = ihttp_get($tokenUrl); $token = @json_decode($content['content'], true); $data = array('weid' => $_W['weid'], 'access_token' => $token['access_token'], 'expires_in' => $token['expires_in'], 'createtime' => TIMESTAMP); CRUD::create(CRUD::$table_sin_token, $data); return $token['access_token']; } }
function up() { $id = $this->_post('id', 'img_url'); $ids = $this->_post('ids', 0); $dir = $this->_get('path', ''); if (!checkPath($dir)) { $dir = 'user'; } if (isHave($_FILES['upimg']) && !isHave($_FILES['upimg']['error'])) { load('upload'); $myUpload = new Myupload(); $upload = $myUpload->upload($dir . '/u' . steadmin::$adminInfo['user_id']); $upload = parent::_sendImageToYunServer($upload); //同步图片到云存储 if ($upload) { if (!$upload[0]) { echo "<script>alert('" . $myUpload->getErrorMsg() . "');history.go(-1);</script>"; exit; } $upload[0]['savepath'] = str_replace('./', '', $upload[0]['savepath']); echo "<script>window.parent.document.getElementById('" . $id . "').value='" . $upload[0]['savepath'] . "';\r\n"; echo "window.location.href='" . U('upload/index', array('id' => $id, 'ids' => $ids, 'path' => $dir)) . "';</script>\r\n"; exit; } } else { echo "<script>alert('" . $_FILES['upimg']['error'] . "');history.go(-1);</script>"; exit; } }
public function settingsDisplay($settings) { global $_GPC, $_W; load()->func('tpl'); if (empty($settings['weisrc_pano'])) { $settings['weisrc_pano']['title'] = "360全景展示"; $settings['weisrc_pano']['bg'] = "../addons/weisrc_pano/template/images/bg.jpg"; $settings['weisrc_pano']['share_title'] = "360全景展示"; $settings['weisrc_pano']['share_image'] = "../addons/weisrc_pano/icon.jpg"; $settings['weisrc_pano']['share_desc'] = "360全景展示"; } if (checksubmit()) { $cfg = $settings; $cfg['weisrc_pano']['title'] = trim($_GPC['title']); $cfg['weisrc_pano']['bg'] = trim($_GPC['bg']); $cfg['weisrc_pano']['share_title'] = trim($_GPC['share_title']); $cfg['weisrc_pano']['share_image'] = trim($_GPC['share_image']); $cfg['weisrc_pano']['share_cancel'] = trim($_GPC['share_cancel']); $cfg['weisrc_pano']['share_desc'] = trim($_GPC['share_desc']); $cfg['weisrc_pano']['share_url'] = trim($_GPC['share_url']); if ($this->saveSettings($cfg)) { message('保存成功', 'refresh'); } } include $this->template('setting'); }
public function respond() { global $_W; $rid = $this->rule; $sql = "SELECT * FROM " . tablename('wxcard_reply') . " WHERE rid = :rid ORDER BY RAND() LIMIT 1"; $reply = pdo_fetch($sql, array(':rid' => $rid)); if (empty($reply)) { return false; } load()->classs('weixin.account'); load()->classs('coupon'); $coupon = new coupon($_W['acid']); if (is_error($coupon)) { $this->error($reply, $coupon['message']); die; } $card = $coupon->BuildCardExt($reply['cid']); if (is_error($card)) { $this->error($reply, $card['message']); die; } $data = array('touser' => $_W['openid'], 'msgtype' => 'wxcard', 'wxcard' => array('card_id' => $card['card_id'], 'card_ext' => $card['card_ext'])); $acc = WeAccount::create($_W['acid']); $status = $acc->sendCustomNotice($data); if (is_error($status)) { $this->error($reply, $status['message']); die; } if (!empty($reply['success'])) { return $this->respText($reply['success']); die; } return true; }
/** * __construct * * @param FCMS_Error $fcmsError * @param Database $fcmsDatabase * @param User $fcmsUser * * @return void */ public function __construct(FCMS_Error $fcmsError, Database $fcmsDatabase, User $fcmsUser) { $this->fcmsError = $fcmsError; $this->fcmsDatabase = $fcmsDatabase; $this->fcmsUser = $fcmsUser; load('facebook'); }
function __construct($modelid, $id) { $this->modelid = $modelid; $this->fields = F("Model_field_" . $modelid); $this->id = $id; load("@.treatfun"); }
public function receive() { global $_W, $_GPC; load()->model('mc'); load()->func('communication'); $event = $this->message['event']; $openid = $this->message['from']; $f_log = pdo_fetch("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE `uniacid` = '{$_W['uniacid']}' AND `openid` = '{$openid}'"); if ($f_log['uid'] != 0) { pdo_update('hx_subscribe_data', array('uid' => $f_log['uid']), array('openid' => $openid)); $uid = $f_log['uid']; } else { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'email' => md5($openid) . '@qdaygroup.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $uid = pdo_insertid(); pdo_update('mc_mapping_fans', array('uid' => $uid), array('openid' => $openid)); pdo_update('hx_subscribe_data', array('uid' => $uid), array('openid' => $openid)); } $credit_type = isset($this->module['config']['credit_type']) ? $this->module['config']['credit_type'] : 'credit1'; $credit_subscribe = isset($this->module['config']['credit_subscribe']) ? $this->module['config']['credit_subscribe'] : 5; $credit_lever_1 = isset($this->module['config']['credit_lever_1']) ? $this->module['config']['credit_lever_1'] : 2; $credit_lever_2 = isset($this->module['config']['credit_lever_2']) ? $this->module['config']['credit_lever_2'] : 1; if ($event == 'subscribe') { $s_log = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `openid`='{$openid}'"); if (empty($s_log)) { //如果没记录 $insert = array('uniacid' => $_W['uniacid'], 'openid' => $openid, 'uid' => $uid, 'from_uid' => '0', 'sn' => time(), 'follow' => '1', 'article_id' => '0', 'shouyi' => $credit_subscribe, 'createtime' => TIMESTAMP); pdo_insert('hx_subscribe_data', $insert); mc_credit_update($uid, $credit_type, $credit_subscribe, array('1', '关注增加积分')); } else { //如果有记录 if ($s_log['follow'] != 1) { //如果记录未关注 $insert = array('follow' => '1'); pdo_update('hx_subscribe_data', $insert, array('id' => $s_log['id'])); mc_credit_update($uid, $credit_type, $credit_subscribe, array('1', '关注增加积分')); } if (!empty($s_log['from_uid'])) { //如果来源ID不为空 $from_user = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `uid`='{$s_log['from_uid']}'"); if (!empty($from_user)) { $data = array('shouyi' => $from_user['shouyi'] + $credit_lever_1, 'zjrs' => $from_user['zjrs'] + 1); pdo_update('hx_subscribe_data', $data, array('id' => $from_user['id'])); mc_credit_update($s_log['from_uid'], $credit_type, $credit_lever_1, array('1', '推荐一级关注增加积分')); if (!empty($from_user['from_uid'])) { $from_user_2 = pdo_fetch("SELECT * FROM " . tablename('hx_subscribe_data') . " WHERE `uniacid`='{$_W['uniacid']}' AND `uid`='{$from_user['from_uid']}'"); if (!empty($from_user_2)) { $data2 = array('shouyi' => $from_user_2['shouyi'] + $credit_lever_2, 'jjrs' => $from_user_2['jjrs'] + 1); pdo_update('hx_subscribe_data', $data2, array('id' => $from_user_2['id'])); mc_credit_update($from_user['from_uid'], $credit_type, $credit_lever_2, array('1', '推荐二级关注增加积分')); } } } } } //pdo_update('hx_subscribe_data',array('follow'=>1),array('openid'=>$openid)); } }
public function fieldsFormSubmit($rid) { //规则验证无误保存入库时执行,这里应该进行自定义字段的保存。这里 $rid 为对应的规则编号 global $_W, $_GPC; load()->func('file'); $id = intval($_GPC['reply_id']); $insert = array("rid" => $rid, "weid" => $_W['uniacid'], "title" => $_GPC['title'], "description" => $_GPC['description'], "rule" => trim($_GPC['rule']), "end_title" => $_GPC['end_title'], "end_description" => $_GPC['end_description'], "starttime" => strtotime($_GPC['datelimit']['start']), "endtime" => strtotime($_GPC['datelimit']['end']), "total_times" => $_GPC['total_times'], "totaldayplay_times" => $_GPC['totaldayplay_times'], "totaldayshare_times" => $_GPC['totaldayshare_times'], "sharelottery_times" => $_GPC['sharelottery_times'], "gametime" => $_GPC['gametime'], "showusernum" => $_GPC['showusernum'], "share_title" => $_GPC['share_title'], "share_desc" => $_GPC['share_desc'], "share_url" => $_GPC['share_url'], "follow_url" => $_GPC['follow_url'], "gameovertext" => $_GPC['gameovertext'], "tips1text" => $_GPC['tips1text'], "tips2text" => $_GPC['tips2text'], "tips3text" => $_GPC['tips3text'], "signtext" => $_GPC['signtext'], "isneedfollow" => $_GPC['isneedfollow'], "awardtip" => $_GPC['awardtip'], "copyright" => $_GPC['copyright']); if (!empty($_GPC['start_picurl'])) { $insert['picture'] = $_GPC['start_picurl']; } if (!empty($_GPC['end_picurl'])) { $insert['end_picurl'] = $_GPC['end_picurl']; } if (!empty($_GPC['share_image'])) { $insert['share_image'] = $_GPC['share_image']; } if (empty($id)) { if ($insert['starttime'] <= time()) { $insert['status'] = 1; } else { $insert['status'] = 0; } pdo_insert($this->table_reply, $insert); } else { pdo_update($this->table_reply, $insert, array('id' => $id)); } }
private function getAccessToken() { global $_W, $_GPC; load()->func('cache'); $api = cache_load("ewei.money.api_share.json::" . $_W['uniacid'], true); $new = false; if (empty($api['appid']) || $api['appid'] !== $this->appId) { $new = true; } if (empty($api['appsecret']) || $api['appsecret'] !== $this->appSecret) { $new = true; } $data = cache_load("ewei.money.access_token.json::" . $_W['uniacid'], true); if (empty($data['expire_time']) || $data['expire_time'] < time() || $new) { $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appId}&secret={$this->appSecret}"; $res = json_decode($this->httpGet($url)); $access_token = $res->access_token; if ($access_token) { $data['expire_time'] = time() + 7000; $data['access_token'] = $access_token; cache_write("ewei.money.access_token.json::" . $_W['uniacid'], iserializer($data)); cache_write("ewei.money.api_share.json::" . $_W['uniacid'], iserializer(array("appid" => $this->appId, "appsecret" => $this->appSecret))); } } else { $access_token = $data['access_token']; } return $access_token; }
public function payResult($params) { load()->model('mc'); $status = pdo_fetchcolumn("SELECT status FROM " . tablename('mc_credits_recharge') . " WHERE tid = :tid", array(':tid' => $params['tid'])); if (empty($status)) { $fee = $params['fee']; $data = array('status' => $params['result'] == 'success' ? 1 : -1); if ($params['type'] == 'wechat') { $data['transid'] = $params['tag']['transaction_id']; $params['user'] = mc_openid2uid($params['user']); } pdo_update('mc_credits_recharge', $data, array('tid' => $params['tid'])); if ($params['result'] == 'success' && $params['from'] == 'notify') { $setting = uni_setting($_W['uniacid'], array('creditbehaviors')); $credit = $setting['creditbehaviors']['currency']; if (empty($credit)) { message('站点积分行为参数配置错误,请联系服务商', '', 'error'); } else { $paydata = array('wechat' => '微信', 'alipay' => '支付宝'); $record[] = $params['user']; $record[] = '用户通过' . $paydata[$params['type']] . '充值' . $fee; mc_credit_update($params['user'], $credit, $fee, $record); } } } if ($params['from'] == 'return') { if ($params['result'] == 'success') { message('支付成功!', '../../app/' . url('mc/home'), 'success'); } else { message('支付失败!', '../../app/' . url('mc/home'), 'error'); } } }
public function respond() { global $_W; load()->func('compat.biz'); $rid = $this->rule; $sql = "SELECT * FROM " . tablename('bm_qrsign_reply') . " WHERE `rid`=:rid LIMIT 1"; $reply = pdo_fetch($sql, array(':rid' => $rid)); if (empty($reply['id'])) { return $this->respText("系统升级中,请稍候!"); } if (time() > strtotime($reply['endtime'])) { if (empty($reply['memo2'])) { $msg = '对不起,活动已经于' . $reply['endtime'] . '结束,感谢您的参与!!!'; } else { $msg = $reply['memo2']; } return $this->respText($msg); } if (time() < strtotime($reply['starttime'])) { if (empty($reply['memo1'])) { $msg = '对不起,活动将于' . $reply['starttime'] . '开始,敬请期待!!!'; } else { $msg = $reply['memo1']; } return $this->respText($msg); } $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('show', array('rid' => $rid, 'from_user' => $this->message['from'])); $response['FromUserName'] = $this->message['to']; $response['ToUserName'] = $this->message['from']; $response['MsgType'] = 'news'; $response['ArticleCount'] = 1; $response['Articles'] = array(); $response['Articles'][] = array('Title' => $reply['title'], 'Description' => $reply['desc'], 'PicUrl' => !strexists($reply['picurl'], 'http://') ? $_W['attachurl'] . $reply['picurl'] : $reply['picurl'], 'Url' => $url, 'TagName' => 'item'); return $response; }
/** * 创建phprpc客户端 * @param string $url * @return object * @author wave */ public function client($url = '') { if (!load('phprpc_client.php', ROOT_PATH . DS . ROOT_LIBRARY . DS . 'phprpc' . DS)) { return load('404.tpl', ROOT_PATH . DS . ROOT_ERROR . DS . 'tpl'); } return new PHPRPC_Client($url); }
function logging($level = 'info', $message = '') { $filename = IA_ROOT . '/data/logs/' . date('Ymd') . '.log'; load()->func('file'); mkdirs(dirname($filename)); $content = date('Y-m-d H:i:s') . " {$level} :\n------------\n"; if (is_string($message)) { $content .= "String:\n{$message}\n"; } if (is_array($message)) { $content .= logging_implode($message); } if ($message == 'get') { $content .= "GET:\n"; foreach ($_GET as $key => $value) { $content .= sprintf("%s : %s ;\n", $key, $value); } } if ($message == 'post') { $content .= "POST:\n"; foreach ($_POST as $key => $value) { $content .= sprintf("%s : %s ;\n", $key, $value); } } $content .= "\n"; $fp = fopen($filename, 'a+'); fwrite($fp, $content); fclose($fp); }
public function doSwitch() { global $_W, $_GPC; $m = array_merge($_W['modules']['userapi'], $_W['account']['modules']['userapi']); $cfg = $m['config']; if ($_W['ispost']) { $rids = explode(',', $_GPC['rids']); if (is_array($rids)) { $cfg = array(); foreach ($rids as $rid) { $cfg[intval($rid)] = true; } $this->saveSettings($cfg); } exit; } load()->model('reply'); $rs = reply_search("uniacid = 0 AND module = 'userapi' AND `status`=1"); $ds = array(); foreach ($rs as $row) { $reply = pdo_fetch('SELECT * FROM ' . tablename($this->tablename) . ' WHERE `rid`=:rid', array(':rid' => $row['id'])); $r = array(); $r['title'] = $row['name']; $r['rid'] = $row['id']; $r['description'] = $reply['description']; $r['switch'] = $cfg[$r['rid']] ? ' checked="checked"' : ''; $ds[] = $r; } include $this->template('switch'); }
public function respond() { global $_W; load()->func('compat.biz'); $rid = $this->rule; $sql = "SELECT * FROM " . tablename('bm_top_reply') . " WHERE `rid`=:rid LIMIT 1"; $row = pdo_fetch($sql, array(':rid' => $rid)); if (empty($row['id'])) { return $this->respText("系统升级中,请稍候!"); } $desc = $row['desc']; //描述 $n = $row['n']; //粉丝基数 $fromuser = $this->message['from']; $num = mc_fansinfo($fromuser); $numx = $n + $num['fanid']; $name = $_W['account']['name']; //公众号名称 $str = str_replace('{name}', $name, $desc); $str = str_replace('{numx}', $numx, $str); if ($row['pictype'] == 1) { //$str = "嗨,欢迎关注【".$name."】,您是第".$numx."位关注人!\n".$desc."\n <a href='".$url."'>".$urltext."</a>"; return $this->respText($str); } else { $response['FromUserName'] = $this->message['to']; $response['ToUserName'] = $this->message['from']; $response['MsgType'] = 'news'; $response['ArticleCount'] = 1; $response['Articles'] = array(); $response['Articles'][] = array('Title' => $row['title'], 'Description' => $str, 'PicUrl' => !strexists($row['picurl'], 'http://') ? $_W['attachurl'] . $row['picurl'] : $row['picurl'], 'Url' => $row['urlx'], 'TagName' => 'item'); return $response; } }
public function respond() { global $_W; $content = $this->message['content']; $reply = pdo_fetch('SELECT * FROM ' . tablename('cover_reply') . ' WHERE `rid`=:rid', array(':rid' => $this->rule)); if (!empty($reply)) { load()->model('module'); $module = module_fetch($reply['module']); if (empty($module) && !in_array($reply['module'], array('site', 'mc', 'card'))) { return ''; } $url = $reply['url']; if (empty($reply['url'])) { $entry = pdo_fetch("SELECT eid FROM " . tablename('modules_bindings') . " WHERE module = :module AND do = :do", array(':module' => $reply['module'], ':do' => $reply['do'])); $url = url('entry', array('eid' => $entry['eid'])); } if (!strexists($url, '&j=') && !empty($_W['acid'])) { $url = str_replace("?i={$_W['uniacid']}&", "?i={$_W['uniacid']}&j={$_W['acid']}&", $url); } $news = array(); $news[] = array('title' => $reply['title'], 'description' => $reply['description'], 'picurl' => $reply['thumb'], 'url' => $url); return $this->respNews($news); } return ''; }
public function admin() { // $category = D ( 'Category' ); // $data = $category->select(); // load('@.tree'); // $data = getTree( $data ); // $this->assign ( 'data', $data ); // $this->display( 'admin' ); import ('ORG.Util.Page'); $cate = D('Category'); $count = $cate->count(); $page = new Page ($count, 11); $page->setConfig('header', '个分类'); $show = $page->show(); $this->assign('show', $show); $data = $cate->select(); // 加载函数文件 load ( '@.tree' ); // 生成树状结构 $data = getTree ( $data ); // 截取之后的数组 $list = array_slice ( $data, $page->firstRow, $page->listRows ); // 分配数组数据 $this->assign ( 'data', $list ); // 显示模板 $this->display ( 'admin' ); }
public function getJsApiTicket() { if (!empty($_W['account']['jsapi_ticket']) && is_array($_W['account']['jsapi_ticket']) && !empty($_W['account']['jsapi_ticket']['ticket']) && !empty($_W['account']['jsapi_ticket']['expire']) && $_W['account']['jsapi_ticket']['expire'] > TIMESTAMP) { return $_W['account']['jsapi_ticket']['ticket']; } load()->func('communication'); $access_token = $this->getAccessToken(); if (is_error($access_token)) { return $access_token; } $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={$access_token}&type=jsapi"; $content = ihttp_get($url); if (is_error($content)) { return error(-1, '调用接口获取微信公众号 jsapi_ticket 失败, 错误信息: ' . $content['message']); } $result = @json_decode($content['content'], true); if (empty($result) || intval($result['errcode']) != 0 || $result['errmsg'] != 'ok') { return error(-1, '获取微信公众号 jsapi_ticket 结果错误, 错误信息: ' . $result['errmsg']); } $record = array(); $record['ticket'] = $result['ticket']; $record['expire'] = TIMESTAMP + $result['expires_in'] - 200; $row = array(); $row['jsapi_ticket'] = iserializer($record); pdo_update('account_wechats', $row, array('acid' => $_W['account']['acid'])); $_W['account']['jsapi_ticket'] = $record; return $record['ticket']; }
public function settingsDisplay($settings) { global $_W, $_GPC; load()->func('tpl'); if (checksubmit()) { load()->func('file'); $r = mkdirs(MB_ROOT . '/cert/' . $_W['uniacid']); if (!empty($_GPC['cert'])) { $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_cert.pem', trim($_GPC['cert'])); $r = $r && $ret; } if (!empty($_GPC['key'])) { $ret = file_put_contents(MB_ROOT . '/cert/' . $_W['uniacid'] . '/apiclient_key.pem', trim($_GPC['key'])); $r = $r && $ret; } if (!$r) { message('证书保存失败, 请保证 /addons/feng_fightgroups/cert/ 目录可写'); } $dat = array('status' => $_GPC['status'], 'mode' => $_GPC['mode'], 'picmode' => $_GPC['picmode'], 'mchid' => $_GPC['mchid'], 'apikey' => $_GPC['apikey'], 'share_title' => $_GPC['share_title'], 'share_image' => $_GPC['share_image'], 'share_desc' => $_GPC['share_desc'], 'url' => $_GPC['url'], 'pay_suc' => $_GPC['pay_suc'], 'm_pay' => $_GPC['m_pay'], 'm_tuan' => $_GPC['m_tuan'], 'm_cancle' => $_GPC['m_cancle'], 'm_ref' => $_GPC['m_ref'], 'm_send' => $_GPC['m_send'], 'pay_remark' => $_GPC['pay_remark'], 'tuan_remark' => $_GPC['tuan_remark'], 'tuan_suc' => $_GPC['tuan_suc'], 'cancle_remark' => $_GPC['cancle_remark'], 'cancle' => $_GPC['cancle'], 'send_remark' => $_GPC['send_remark'], 'send' => $_GPC['send'], 'ref_remark' => $_GPC['ref_remark'], 'ref' => $_GPC['ref'], 'sname' => $_GPC['sname'], 'slogo' => $_GPC['slogo'], 'copyright' => $_GPC['copyright'], 'content' => htmlspecialchars_decode($_GPC['content'])); if ($this->saveSettings($dat)) { message('保存成功', 'refresh'); } } //这里来展示设置项表单 include $this->template('setting'); }
public function respond() { $content = $this->message['content']; global $_W; if (!$this->inContext) { $this->beginContext(60); return $this->respText('点击下方的“+”,发送您的地理位置。然后我们会返回您周边的酒店!'); } else { if (isset($this->message['location_x']) && isset($this->message['location_y'])) { $this->endContext(); load()->func('communication'); $data = ihttp_get("http://api.map.baidu.com/telematics/v3/local?location={$this->message['location_y']},{$this->message['location_x']}&keyWord=酒店&output=json&ak=jhSS7UjKAS9P9h2vDfhacjmr"); $data = json_decode($data['content'], true); if ($data['status'] === 'Success') { foreach ($data['pointList'] as $key => $val) { if ((int) $key > 7) { break; } $return[] = array('title' => $val['name'], 'description' => $val['address'], 'picurl' => '', 'url' => $val['additionalInformation']['link'][0]['url']); } return $this->respNews($return); } else { return $this->respText("没有查询结果。"); } } else { $this->endContext(); } return false; } }
public function fieldsFormDisplay($rid = 0) { global $_W; load()->func('tpl'); $replies = array(); $replies = pdo_fetchall("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid AND parent_id = -1 ORDER BY `displayorder` DESC, id ASC", array(':rid' => $rid)); if (!empty($replies)) { $parent_id = $replies[0]['id']; pdo_update($this->tablename, array('parent_id' => $parent_id), array('rid' => $rid)); pdo_update($this->tablename, array('parent_id' => 0), array('rid' => $rid, 'id' => $parent_id)); } $rows = pdo_fetchall("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `parent_id` ASC, `id` ASC", array(':rid' => $rid)); $replies = array(); foreach ($rows as &$row) { if (!empty($row['thumb'])) { $row['thumb'] = tomedia($row['thumb']); } if (empty($row['parent_id'])) { $replies[$row['id']][] = $row; } else { $replies[$row['parent_id']][] = $row; } } $replies = array_values($replies); include $this->template('display'); }
public function fieldsFormDisplay($rid = 0) { //要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0 global $_W; load()->func('tpl'); $reply = pdo_fetch("SELECT * FROM " . tablename('eso_runman_reply') . " WHERE rid = :rid", array(':rid' => $rid)); if (empty($reply)) { $reply['starttime'] = time(); $reply['endtime'] = time() + 2592000; $reply['setting'] = array(); } else { $reply['setting'] = string2array($reply['setting']); } $sql = "SELECT * FROM " . tablename('uni_account'); $uniaccounts = pdo_fetchall($sql); $accounts = array(); if (!empty($uniaccounts)) { foreach ($uniaccounts as $uniaccount) { $accountlist = uni_accounts($uniaccount['uniacid']); if (!empty($accountlist)) { foreach ($accountlist as $account) { if (!empty($account['key']) && !empty($account['secret']) && in_array($account['level'], array(3, 4))) { $accounts[$account['acid']] = $account['name']; } } } } } include $this->template('form'); }
function initializeModule($request_method, $request_data) { if (!empty($this->shared_data['group_info'])) { $this->gid = $this->shared_data['group_info']->collection_id; $this->view_type = "all"; if ($this->shared_data['group_info']->group_type == "typedgroup") { PA::$config->useTypedGroups = true; require_once 'api/Entity/TypedGroupEntity.php'; $this->entity = TypedGroupEntity::load_for_group((int) $this->gid); $this->entity_type = $this->entity->entity_type; PA::$group_noun = $this->entity->entity_type; // echo "<pre>".print_r($this->entity, 1)."</pre>";exit; } } $this->network_info = PA::$network_info; global $paging; $this->Paging["page"] = $paging["page"]; $this->Paging["show"] = $paging["show"]; $this->page_user = NULL; if (PA::$page_uid && PA::$page_uid != PA::$login_uid) { $user = new User(); ¤user - load(PA::$page_uid); $this->page_user = $user->get_name(); } }