Example #1
0
 /**
  * 保存一条用户记录至用户表中, 如果OpenID存在, 则更新记录
  * @param array $entity     用户数据
  * @return int|error        成功返回用户编号, 失败返回错误信息
  */
 public function save($entity)
 {
     global $_W;
     $rec = array_elements(array('openid', 'nickname', 'gender', 'state', 'city', 'country', 'avatar'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     $sql = 'SELECT * FROM ' . tablename('mbsk_fans') . ' WHERE `uniacid`=:uniacid AND `openid`=:openid';
     $pars = array();
     $pars[':uniacid'] = $rec['uniacid'];
     $pars[':openid'] = $rec['openid'];
     $exists = pdo_fetch($sql, $pars);
     if (!empty($exists)) {
         $filter = array();
         $filter['uniacid'] = $_W['uniacid'];
         $filter['uid'] = $exists['uid'];
         $ret = pdo_update('mbsk_fans', $rec, $filter);
         if ($ret !== false) {
             return $exists['uid'];
         } else {
             return error(-2, '数据更新失败, 请稍后重试');
         }
     }
     $ret = pdo_insert('mbsk_fans', $rec);
     if (!empty($ret)) {
         return pdo_insertid();
Example #2
0
 public function doWebAddInfo()
 {
     global $_W, $_GPC;
     load()->func('tpl');
     $infoid = intval($_GPC['infoid']);
     if ($infoid) {
         $info = pdo_fetch("SELECT * FROM " . tablename('water_query_info') . " WHERE id= " . $infoid);
     }
     if ($_GPC['op'] == 'delete') {
         $infoid = intval($_GPC['infoid']);
         $info = pdo_fetch("SELECT id FROM " . tablename('water_query_info') . " WHERE id = " . $infoid);
         if (empty($info)) {
             message('抱歉,信息不存在或是已经被删除!');
         }
         pdo_delete('water_query_info', array('id' => $infoid));
         message('删除成功!', referer(), 'success');
     }
     if (checksubmit()) {
         $data = array('keyword' => $_GPC['keyword'], 'info' => htmlspecialchars_decode($_GPC['info']), 'infophoto' => $_GPC['infophoto']);
         if (!empty($infoid)) {
             pdo_update('water_query_info', $data, array('id' => $infoid));
         } else {
             $data['uniacid'] = $_W['uniacid'];
             pdo_insert('water_query_info', $data);
             $infoid = pdo_insertid();
         }
         message('更新成功!', referer(), 'success');
     }
     include $this->template('addinfo');
 }
Example #3
0
 public function doMobilecomment()
 {
     global $_W, $_GPC;
     $id = intval($_GPC['id']);
     if ($_W['ispost']) {
         if (empty($_GPC['count'])) {
             $insert = array('content' => $_GPC['content'], 'from' => $_GPC['from'], 'weid' => $_W['weid'], 'list_id' => $_GPC['id'], 'create_time' => time(), 'from_user' => $_W['fans']['from_user']);
             pdo_insert('izc_lightbox_comment', $insert);
             $id = pdo_insertid();
             $return = array('data' => array('id' => $id, 'date' => date('Y-m-d H:i:s')), 'success' => 1, 'message' => '提交成功');
             if ($_GPC['iscomment'] == 0) {
                 pdo_update('izc_lightbox_list', array('iscomment' => 1), array('id' => $_GPC['id']));
             }
         } else {
             $pindex = intval($_GPC['start']);
             $count = pdo_fetchcolumn('SELECT count(id) FROM' . tablename('izc_lightbox_comment') . ' WHERE `list_id`=:id', array(':id' => $id));
             $list = pdo_fetchall('SELECT * FROM' . tablename('izc_lightbox_comment') . ' WHERE `list_id`=:id  order by create_time desc  LIMIT ' . $pindex * $psize . ',10', array(':id' => $id));
             $return = array('success' => 1, 'data' => array('count' => $count));
             foreach ($list as $v) {
                 $return['data']['data'][] = array('id' => $v['id'], 'from' => $v['from'], 'content' => $v['content'], 'date' => date('Y-m-d H:i:s', $v['create_time']));
             }
         }
     }
     echo json_encode($return);
 }
Example #4
0
 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $notawardtext = explode("\n", $_GPC['notawardtext']);
     $insert = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'ticket_information' => $_GPC['ticket_information'], 'description' => $_GPC['description'], 'repeat_lottery_reply' => $_GPC['repeat_lottery_reply'], 'start_picurl' => $_GPC['start_picurl'], 'end_theme' => $_GPC['end_theme'], 'end_instruction' => $_GPC['end_instruction'], 'end_picurl' => $_GPC['end_picurl'], 'notaward' => $_GPC['notaward'], 'notawardtext' => iserializer($notawardtext), 'notawardpic' => $_GPC['notawardpic'], 'adpic' => $_GPC['adpic'], 'adpicurl' => $_GPC['adpicurl'], 'award_times' => $_GPC['award_times'], 'number_times' => $_GPC['number_times'], 'most_num_times' => $_GPC['most_num_times'], "credit_times" => $_GPC['credit_times'], "credittype" => $_GPC['credittype'], "credit_type" => $_GPC['credit_type'], "credit1" => $_GPC['credit1'], "credit2" => $_GPC['credit2'], 'sn_rename' => $_GPC['sn_rename'], 'awardnum' => $_GPC['awardnum'], 'show_num' => $_GPC['show_num'], 'createtime' => time(), 'share_acid' => $_GPC['share_acid'], 'copyright' => $_GPC['copyright'], 'starttime' => strtotime($_GPC['datelimit']['start']), 'endtime' => strtotime($_GPC['datelimit']['end']), 'xuninumtime' => $_GPC['xuninumtime'], 'xuninuminitial' => $_GPC['xuninuminitial'], 'xuninumending' => $_GPC['xuninumending'], 'xuninum' => $_GPC['xuninum'], 'ticketinfo' => $_GPC['ticketinfo'], 'isrealname' => $_GPC['isrealname'], 'ismobile' => $_GPC['ismobile'], 'isqq' => $_GPC['isqq'], 'isemail' => $_GPC['isemail'], 'isaddress' => $_GPC['isaddress'], 'isgender' => $_GPC['isgender'], 'istelephone' => $_GPC['istelephone'], 'isidcard' => $_GPC['isidcard'], 'iscompany' => $_GPC['iscompany'], 'isoccupation' => $_GPC['isoccupation'], 'isposition' => $_GPC['isposition'], 'isfans' => $_GPC['isfans'], 'isfansname' => $_GPC['isfansname'], 'award_info' => $_GPC['award_info'], 'homepictime' => $_GPC['homepictime'], 'homepic' => $_GPC['homepic'], 'opportunity' => $_GPC['opportunity'], 'opportunity_txt' => $_GPC['opportunity_txt']);
     load()->func('communication');
     if (empty($id)) {
         if ($insert['starttime'] <= time()) {
             $insert['isshow'] = 1;
         } else {
             $insert['isshow'] = 0;
         }
         pdo_insert('stonefish_scratch_reply', $insert);
         $id = pdo_insertid();
     } else {
         pdo_update('stonefish_scratch_reply', $insert, array('id' => $id));
     }
     //查询规则
     //查询子公众号信息必保存分享设置
     $acid_arr = uni_accounts();
     $ids = array();
     $ids = array_map('array_shift', $acid_arr);
     //子公众账号Arr数组
     foreach ($ids as $acid => $idlists) {
         $insertshare = array('rid' => $rid, 'acid' => $acid, 'uniacid' => $_W['uniacid'], 'share_title' => $_GPC['share_title_' . $acid], 'share_desc' => $_GPC['share_desc_' . $acid], 'share_url' => $_GPC['share_url_' . $acid], 'share_imgurl' => $_GPC['share_imgurl_' . $acid], 'share_picurl' => $_GPC['share_picurl_' . $acid], 'share_pic' => $_GPC['share_pic_' . $acid], 'share_txt' => $_GPC['share_txt_' . $acid], 'sharenumtype' => $_GPC['sharenumtype_' . $acid], 'sharenum' => $_GPC['sharenum_' . $acid], 'sharetype' => $_GPC['sharetype_' . $acid], 'share_confirm' => $_GPC['share_confirm_' . $acid], 'share_fail' => $_GPC['share_fail_' . $acid], 'share_cancel' => $_GPC['share_cancel_' . $acid]);
         if (empty($_GPC['acid_' . $acid])) {
             pdo_insert('stonefish_scratch_share', $insertshare);
         } else {
             pdo_update('stonefish_scratch_share', $insertshare, array('id' => $_GPC['acid_' . $acid]));
         }
     }
     //查询子公众号信息必保存分享设置
     //奖品配置
     if (!empty($_GPC['prizetype'])) {
         foreach ($_GPC['prizetype'] as $index => $prizetype) {
             if (empty($prizetype)) {
                 continue;
             }
             $insertprize = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'prizetype' => $_GPC['prizetype'][$index], 'prizename' => $_GPC['prizename'][$index], 'prizepro' => $_GPC['prizepro'][$index], 'prizetotal' => $_GPC['prizetotal'][$index], 'prizepic' => $_GPC['prizepic'][$index], 'prizetxt' => $_GPC['prizetxt'][$index], 'credit' => $_GPC['credit'][$index], 'credit_type' => $_GPC['prize_type'][$index]);
             $updata['total_num'] += $_GPC['prizetotal'][$index];
             pdo_update('stonefish_scratch_prize', $insertprize, array('id' => $index));
         }
     }
     if (!empty($_GPC['prizetype_new']) && count($_GPC['prizetype_new']) > 1) {
         foreach ($_GPC['prizetype_new'] as $index => $credit_type) {
             if (empty($credit_type) || $index == 0) {
                 continue;
             }
             $insertprize = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'prizetype' => $_GPC['prizetype_new'][$index], 'prizename' => $_GPC['prizename_new'][$index], 'prizepro' => $_GPC['prizepro_new'][$index], 'prizetotal' => $_GPC['prizetotal_new'][$index], 'prizepic' => $_GPC['prizepic_new'][$index], 'prizetxt' => $_GPC['prizetxt_new'][$index], 'credit' => $_GPC['credit_new'][$index], 'credit_type' => $_GPC['prize_type_new'][$index]);
             $updata['total_num'] += $_GPC['prizetotal_new'][$index];
             pdo_insert('stonefish_scratch_prize', $insertprize);
         }
     }
     if ($updata['total_num']) {
         pdo_update('stonefish_scratch_reply', $updata, array('id' => $id));
     }
     //奖品配置
     return true;
 }
Example #5
0
function user_register($user)
{
    if (empty($user) || !is_array($user)) {
        return 0;
    }
    if (isset($user['uid'])) {
        unset($user['uid']);
    }
    $user['salt'] = random(8);
    $user['password'] = user_hash($user['password'], $user['salt']);
    $user['joinip'] = CLIENT_IP;
    $user['joindate'] = TIMESTAMP;
    $user['lastip'] = CLIENT_IP;
    $user['lastvisit'] = TIMESTAMP;
    if (empty($user['status'])) {
        $user['status'] = 2;
    }
    $now = time();
    if (empty($user['endtime'])) {
        $user['endtime'] = $now + 7 * 24 * 3600;
    }
    $result = pdo_insert('users', $user);
    if (!empty($result)) {
        $user['uid'] = pdo_insertid();
    }
    return intval($user['uid']);
}
Example #6
0
 public function doMobileSaylove()
 {
     global $_W, $_GPC;
     $res_path = $this->res_path;
     $ops = array('submit', 'saylove');
     $op = in_array($_GPC['op'], $ops) ? $_GPC['op'] : 'saylove';
     if ($op == 'saylove') {
         $openid = $_SESSION['openid'];
         $sql = 'SELECT count(openid) FROM ' . tablename('mc_mapping_fans') . ' WHERE openid=:openid AND uniacid=:uniacid AND follow = 1';
         $params = array(':openid' => $openid, ':uniacid' => $_W['uniacid']);
         $isfollow = pdo_fetchcolumn($sql, $params);
         $dayBegin = mktime(0, 0, 0);
         $dayEnd = mktime(23, 59, 59);
         $sql = 'SELECT count(openid) FROM ' . tablename($this->tb_lovehelper_msg) . " WHERE openid=:openid AND uniacid=:uniacid AND createtime<{$dayEnd} AND createtime>{$dayBegin}";
         $params = array(':openid' => $openid, ':uniacid' => $_W['uniacid']);
         $count = pdo_fetchcolumn($sql, $params);
         $sql = 'SELECT * FROM ' . tablename($this->tb_lovehelper_res) . ' WHERE type=:type AND uniacid=:uniacid';
         $params = array(':type' => IMAGE, ':uniacid' => $_W['uniacid']);
         $bgimages = pdo_fetchall($sql, $params);
         include $this->template('saylove');
     }
     if ($op == 'submit') {
         $content = $_GPC["content"];
         $fromuser = $_GPC["fromuser"];
         $bgimage = $_GPC["bgimage"];
         $love = array('content' => $content, 'fromuser' => $fromuser, 'bgimage' => $bgimage, 'uniacid' => $_W['uniacid'], 'openid' => $_SESSION['openid'], 'createtime' => TIMESTAMP);
         pdo_insert($this->tb_lovehelper_msg, $love);
         echo pdo_insertid();
     }
 }
Example #7
0
/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
function site_cover($coverparams = array())
{
    $where = '';
    $params = array(':uniacid' => $coverparams['uniacid'], ':module' => $coverparams['module']);
    if (!empty($coverparams['multiid'])) {
        $where .= " AND multiid = :multiid";
        $params[':multiid'] = $coverparams['multiid'];
    }
    $cover = pdo_fetch("SELECT * FROM " . tablename('cover_reply') . " WHERE `module` = :module AND uniacid = :uniacid {$where}", $params);
    if (empty($cover['rid'])) {
        $rule = array('uniacid' => $coverparams['uniacid'], 'name' => $coverparams['title'], 'module' => 'cover', 'status' => 1);
        pdo_insert('rule', $rule);
        $rid = pdo_insertid();
    } else {
        $rule = array('name' => $coverparams['title']);
        pdo_update('rule', $rule, array('id' => $cover['rid']));
        $rid = $cover['rid'];
    }
    if (!empty($rid)) {
        $sql = 'DELETE FROM ' . tablename('rule_keyword') . ' WHERE `rid`=:rid AND `uniacid`=:uniacid';
        $pars = array();
        $pars[':rid'] = $rid;
        $pars[':uniacid'] = $coverparams['uniacid'];
        pdo_query($sql, $pars);
        $keywordrow = array('rid' => $rid, 'uniacid' => $coverparams['uniacid'], 'module' => 'cover', 'status' => 1, 'displayorder' => 0, 'type' => 1, 'content' => $coverparams['keyword']);
        pdo_insert('rule_keyword', $keywordrow);
    }
    $entry = array('uniacid' => $coverparams['uniacid'], 'multiid' => $coverparams['multiid'], 'rid' => $rid, 'title' => $coverparams['title'], 'description' => $coverparams['description'], 'thumb' => $coverparams['thumb'], 'url' => $coverparams['url'], 'do' => '', 'module' => $coverparams['module']);
    if (empty($cover['id'])) {
        pdo_insert('cover_reply', $entry);
    } else {
        pdo_update('cover_reply', $entry, array('id' => $cover['id']));
    }
    return true;
}
Example #8
0
 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));
     }
 }
Example #9
0
 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));
             }
         }
     }
 }
Example #10
0
 public function doMobileget()
 {
     global $_GPC, $_W;
     $insert = array('rid' => intval($_GPC['rid']), 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'loops' => intval($_GPC['loop']), 'items' => $_GPC['items'], 'createtime' => time());
     pdo_insert($this->list, $insert);
     $id = pdo_insertid();
     exit(json_encode(array('state' => 'ok', 'mid' => $id)));
 }
Example #11
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     //$content = $this->message['content'];
     $openid = $this->message['from'];
     load()->model('mc');
     $uid = mc_openid2uid($openid);
     $row = pdo_fetch("SELECT awardprompt,currentprompt,floorprompt,setting FROM " . tablename('superman_floor') . " WHERE rid={$rid}");
     $rule_name = pdo_fetchcolumn("SELECT name FROM " . tablename('rule') . " WHERE id={$rid}");
     if ($row) {
         $setting = unserialize($row['setting']);
         if (!$setting['repeat_floor']) {
             $floor = $this->get_floor();
             if ($floor) {
                 $result = str_replace('{RULENAME}', $rule_name, $row['floorprompt']);
                 $result = str_replace('{FLOOR}', $floor['id'], $result);
                 $result = str_replace('{TIME}', date('Y-m-d H:i:s', $floor['dateline']), $result);
                 $winninginfo = $_W['siteroot'] . 'app/' . $this->createMobileUrl('winninginfo', array('rid' => $rid));
                 //return $this->respText($result);
                 $news = array(array('title' => '您已参与过本活动!', 'description' => $result, 'picurl' => '', 'url' => $winninginfo));
                 return $this->respNews($news);
             }
         }
     }
     $new_data = array('dateline' => $_W['timestamp'], 'openid' => $openid);
     pdo_insert("superman_floor_{$rid}", $new_data, false);
     $new_id = pdo_insertid();
     if ($new_id <= 0) {
         return $this->respText('系统异常,请稍后重试!');
     }
     $awards = pdo_fetchall("SELECT * FROM " . tablename('superman_floor_award') . " WHERE rid={$rid}");
     $prompt = pdo_fetch("SELECT awardprompt,currentprompt,floorprompt,setting FROM " . tablename('superman_floor') . " WHERE rid={$rid}");
     if ($awards) {
         foreach ($awards as $item) {
             $floors = explode(',', $item['floors']);
             if (in_array($new_id, $floors)) {
                 $new_data = array('rid' => $rid, 'floor' => $new_id, 'uid' => $uid, 'uniacid' => $_W['uniacid'], 'openid' => $openid, 'award_id' => $item['id'], 'ip' => $_W['clientip'], 'dateline' => $_W['timestamp']);
                 pdo_insert('superman_floor_winner', $new_data);
                 $winner_id = pdo_insertid();
                 $result = str_replace('{RULENAME}', $rule_name, $row['awardprompt']);
                 $result = str_replace('{FLOOR}', $new_id, $result);
                 $result = str_replace('{AWARD}', $item['title'], $result);
                 $result = str_replace('{DESCRIPTION}', $item['description'], $result);
                 $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$winner_id}|{$openid}", 'ENCODE'), 'rid' => $rid));
                 $winninginfo = $_W['siteroot'] . 'app/' . $this->createMobileUrl('winninginfo', array('rid' => $rid));
                 $news = array(array('title' => '恭喜您,获得' . $item['title'] . '!', 'description' => $result, 'picurl' => '', 'url' => $url));
                 return $this->respNews($news);
             }
         }
     }
     $result = str_replace('{RULENAME}', $rule_name, $row['currentprompt']);
     $result = str_replace('{FLOOR}', $new_id, $result);
     $winninginfo = $_W['siteroot'] . 'app/' . $this->createMobileUrl('winninginfo', array('rid' => $rid));
     $news = array(array('title' => '未中奖,再接再厉!', 'description' => $result, 'picurl' => '', 'url' => $winninginfo));
     return $this->respNews($news);
 }
Example #12
0
 public function doMobileGrabseat()
 {
     global $_GPC, $_W;
     $rid = $_GPC['rid'];
     $weid = $_W['weid'];
     $sql = "SELECT * FROM " . tablename('grabseat_reply') . " WHERE `rid`=:rid";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     $row['picture'] = $_W['attachurl'] . trim($row['picture'], '/');
     $fromuser = $_W['fans']['from_user'];
     $profile = fans_search($fromuser);
     if (!empty($_GPC['submit'])) {
         if ($_GPC['sel'] == 'grab') {
             if (empty($profile['from_user'])) {
                 message('您还没有关注,请先关注再参与活动~', 'refresh', 'error');
             }
             $graber = pdo_fetch("SELECT * FROM " . tablename('grabseat_record') . " WHERE rid = :rid AND (graberopenid = :graberopenid OR fiteropenid = :fiteropenid) ", array(':rid' => $rid, ':graberopenid' => $fromuser, ':fiteropenid' => $fromuser));
             if (empty($graber)) {
                 $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'gender' => $_GPC['gender']);
                 fans_update($fromuser, $data);
                 $insert = array('weid' => $_GPC['weid'], 'rid' => $rid, 'graberopenid' => $fromuser, 'grabername' => $_GPC['realname'], 'grabermobile' => $_GPC['mobile'], 'grabtime' => time(), 'status' => 0);
                 if (pdo_insert('grabseat_record', $insert)) {
                     $id = pdo_insertid();
                 }
                 die('<script>location.href = "' . $this->createMobileUrl('showseat', array('rid' => $_GPC['rid'], 'id' => $id)) . '";</script>');
             } else {
                 message('不能重复抢座或者您已经就坐~~', 'refresh', 'error');
             }
         } else {
             if (empty($profile['from_user'])) {
                 message('您还没有关注,请先关注再参与活动~', 'refresh', 'error');
             }
             $fiter = pdo_fetch("SELECT * FROM " . tablename('grabseat_record') . " WHERE rid = :rid AND (graberopenid = :graberopenid OR fiteropenid = :fiteropenid) ", array(':rid' => $rid, ':graberopenid' => $fromuser, ':fiteropenid' => $fromuser));
             if (empty($fiter)) {
                 $id = $_GPC['tablenum'];
                 if (empty($id)) {
                     message('座位号忘了填写哟~~', 'refresh', 'error');
                 }
                 $tableid = pdo_fetch("SELECT * FROM " . tablename('grabseat_record') . " WHERE rid = :rid AND id = :id", array(':rid' => $rid, ':id' => $id));
                 if (empty($tableid['id'])) {
                     message('没有这个座位号哦~~', 'refresh', 'error');
                 }
                 if (!empty($tableid['fiteropenid'])) {
                     message('您来晚了,这个座位已经有人做了哟~~', 'refresh', 'error');
                 }
                 $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'gender' => $_GPC['gender']);
                 fans_update($fromuser, $data);
                 $insert = array('fiteropenid' => $fromuser, 'fitername' => $_GPC['realname'], 'fitermobile' => $_GPC['mobile'], 'fittime' => time(), 'status' => 1);
                 pdo_update('grabseat_record', $insert, array('id' => $id));
                 die('<script>location.href = "' . $this->createMobileUrl('fitseat', array('rid' => $_GPC['rid'], 'id' => $id)) . '";</script>');
             } else {
                 message('您已经就坐,不能换座位了哟~~', 'refresh', 'error');
             }
         }
     }
     include $this->template('grabseat');
 }
Example #13
0
 public function doWebList()
 {
     global $_GPC, $_W;
     load()->func('tpl');
     $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
     if ($operation == 'display') {
         if (!empty($_GPC['displayorder'])) {
             foreach ($_GPC['displayorder'] as $id => $displayorder) {
                 pdo_update('meepomailattachment', array('displayorder' => $displayorder), array('id' => $id));
             }
             message('分类排序更新成功!', $this->createWebUrl('List', array('op' => 'display')), 'success');
         }
         $list = pdo_fetchall("SELECT * FROM " . tablename('meepomailattachment') . " WHERE weid = '{$_W['weid']}' ORDER BY id ASC, displayorder DESC");
         include $this->template('list');
     } elseif ($operation == 'post') {
         $id = intval($_GPC['id']);
         if (!empty($id)) {
             $list = pdo_fetch("SELECT * FROM " . tablename('meepomailattachment') . " WHERE id = '{$id}'");
         } else {
             $list = array('displayorder' => 0);
         }
         if (checksubmit('submit')) {
             if (empty($_GPC['attachmentname']) || empty($_GPC['description'])) {
                 message('文件名称以及文件描述是必填项!', $this->createWebUrl('list'), 'error');
             }
             $data = array('weid' => $_W['weid'], 'attachmentname' => $_GPC['attachmentname'], 'isshow' => intval($_GPC['isshow']), 'displayorder' => intval($_GPC['displayorder']), 'description' => $_GPC['description']);
             if (!empty($_FILES['thumb']['tmp_name'])) {
                 load()->func('file');
                 file_delete($_GPC['thumb_old']);
                 $upload = $this->file_upload($data['attachmentname'], $_FILES['thumb']);
                 if (is_error($upload)) {
                     message($upload['message'], '', 'error');
                 }
                 $data['thumb'] = $upload['path'];
             }
             if (!empty($id)) {
                 unset($data['id']);
                 pdo_update('meepomailattachment', $data, array('id' => $id));
             } else {
                 pdo_insert('meepomailattachment', $data);
                 $id = pdo_insertid();
             }
             message('更新附件成功!', $this->createWebUrl('list', array('op' => 'display')), 'success');
         }
         include $this->template('list');
     } elseif ($operation == 'delete') {
         $id = intval($_GPC['id']);
         $category = pdo_fetch("SELECT id FROM " . tablename('meepomailattachment') . " WHERE id = '{$id}'");
         if (empty($category)) {
             message('抱歉,附件不存在或是已经被删除!', $this->createWebUrl('list', array('op' => 'display')), 'error');
         }
         pdo_delete('meepomailattachment', array('id' => $id), 'OR');
         message('附件信息删除成功!', $this->createWebUrl('list', array('op' => 'display')), 'success');
     }
 }
Example #14
0
 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'weid' => $_W['weid'], 'title' => $_GPC['title'], 'description' => $_GPC['description'], 'votetype' => $_GPC['votetype'], 'votelimit' => $_GPC['votelimit'], 'votetimes' => $_GPC['votetimes'], 'votetotal' => $_GPC['votetotal'], 'isimg' => $_GPC['isimg'], 'share_title' => $_GPC['share_title'], 'share_desc' => $_GPC['share_desc'], 'share_url' => $_GPC['share_url'], 'share_txt' => $_GPC['share_txt'], 'starttime' => strtotime($_GPC['datelimit-start']), 'endtime' => strtotime($_GPC['datelimit-end']));
     if (!empty($_GPC['thumb'])) {
         $insert['thumb'] = $_GPC['thumb'];
         file_delete($_GPC['thumb-old']);
     }
     if (empty($id)) {
         if ($insert['starttime'] <= time()) {
             $insert['isshow'] = 1;
         } else {
             $insert['isshow'] = 0;
         }
         $id = pdo_insert($this->tablename, $insert);
     } else {
         pdo_update($this->tablename, $insert, array('id' => $id));
     }
     $options = array();
     $option_ids = $_POST['option_id'];
     $option_titles = $_POST['option_title'];
     $option_thumb_olds = $_POST['option_thumb_old'];
     $files = $_FILES;
     $len = count($option_ids);
     $ids = array();
     for ($i = 0; $i < $len; $i++) {
         $item_id = $option_ids[$i];
         $a = array("title" => $option_titles[$i], "rid" => $rid);
         $f = 'option_thumb_' . $item_id;
         $old = $_GPC['option_thumb_' . $item_id];
         if (!empty($files[$f]['tmp_name'])) {
             $upload = file_upload($files[$f]);
             if (is_error($upload)) {
                 message($upload['message'], '', 'error');
             }
             $a['thumb'] = $upload['path'];
         } else {
             if (!empty($old)) {
                 $a['thumb'] = $old;
             }
         }
         if ((int) $item_id == 0) {
             pdo_insert("vote_option", $a);
             $item_id = pdo_insertid();
         } else {
             pdo_update("vote_option", $a, array('id' => $item_id));
         }
         $ids[] = $item_id;
     }
     if (!empty($ids)) {
         pdo_query("delete from " . tablename('vote_option') . " where id not in ( " . implode(',', $ids) . ") and rid = " . $rid);
     }
     return true;
 }
Example #15
0
 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     if (!empty($_GPC['news-title'])) {
         foreach ($_GPC['news-title'] as $groupid => $items) {
             if (empty($items)) {
                 continue;
             }
             foreach ($items as $itemid => $row) {
                 if (empty($row)) {
                     continue;
                 }
                 $update = array('title' => $_GPC['news-title'][$groupid][$itemid], 'description' => $_GPC['news-description'][$groupid][$itemid], 'thumb' => $_GPC['news-picture-old'][$groupid][$itemid], 'content' => htmlspecialchars_decode($_GPC['news-content'][$groupid][$itemid]), 'url' => $_GPC['news-url'][$groupid][$itemid]);
                 if (!empty($_GPC['news-picture'][$groupid][$itemid])) {
                     $update['thumb'] = $_GPC['news-picture'][$groupid][$itemid];
                     file_delete($_GPC['news-picture-old'][$groupid][$itemid]);
                 }
                 pdo_update($this->tablename, $update, array('id' => $itemid));
                 //处理新增子项
                 if (!empty($_GPC['news-title-new'][$groupid])) {
                     foreach ($_GPC['news-title-new'][$groupid] as $index => $title) {
                         if (empty($title)) {
                             continue;
                         }
                         unset($_GPC['news-title-new'][$groupid]);
                         $insert = array('rid' => $rid, 'parentid' => $itemid, 'title' => $title, 'description' => $_GPC['news-description-new'][$groupid][$index], 'thumb' => $_GPC['news-picture-new'][$groupid][$index], 'content' => htmlspecialchars_decode($_GPC['news-content-new'][$groupid][$index]), 'url' => $_GPC['news-url-new'][$groupid][$index]);
                         pdo_insert($this->tablename, $insert);
                     }
                 }
             }
         }
     }
     //处理添加
     if (!empty($_GPC['news-title-new'])) {
         foreach ($_GPC['news-title-new'] as $itemid => $titles) {
             if (!empty($titles)) {
                 $parentid = 0;
                 foreach ($titles as $index => $title) {
                     if (empty($title)) {
                         continue;
                     }
                     $insert = array('rid' => $rid, 'parentid' => $parentid, 'title' => $title, 'description' => $_GPC['news-description-new'][$itemid][$index], 'thumb' => $_GPC['news-picture-new'][$itemid][$index], 'content' => htmlspecialchars_decode($_GPC['news-content-new'][$itemid][$index]), 'url' => $_GPC['news-url-new'][$itemid][$index]);
                     pdo_insert($this->tablename, $insert);
                     if (empty($parentid)) {
                         $parentid = pdo_insertid();
                     }
                 }
             }
         }
     }
     return true;
 }
Example #16
0
 public function doMobileimgupload()
 {
     global $_W, $_GPC;
     if (!empty($_GPC['pic'])) {
         $is = pdo_insert('weizp_images', array('file' => $_GPC['pic']));
         $id = pdo_insertid();
         if (empty($is)) {
             exit(json_encode(array('errCode' => 1, 'message' => '上传出现错误', 'data' => array('id' => $_GPC['t'], 'picId' => $id))));
         } else {
             exit(json_encode(array('errCode' => 0, 'message' => '作品上传成功', 'data' => array('id' => $_GPC['id'], 'picId' => $id))));
         }
     }
 }
Example #17
0
 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $sid = $_GPC['sin_id'];
     $data = array('title' => $_GPC['title'], 'rid' => $rid, 'starttime' => strtotime($_GPC['starttime']), 'endtime' => strtotime($_GPC['endtime']), 'follow_credit_allow' => $_GPC['follow_credit_allow'], 'follow_credit' => $_GPC['follow_credit'], 'leave_credit_clear' => $_GPC['leave_credit_clear'], 'sign_credit' => $_GPC['sign_credit'], 'sync_credit' => $_GPC['sync_credit'], 'sin_suc_msg' => $_GPC['sin_suc_msg'], 'sin_suc_fail' => $_GPC['sin_suc_fail'], 'sin_suc_member' => $_GPC['sin_suc_member'], 'rule' => htmlspecialchars_decode($_GPC['rule']), 'uniacid' => $this->uniacid, 'copyright' => $_GPC['copyright'], 'new_icon' => $_GPC['new_icon'], 'new_title' => $_GPC['new_title'], 'new_content' => $_GPC['new_content'], 'createtime' => TIMESTAMP);
     if (empty($sid)) {
         CRUD::create(CRUD::$table_sign, $data);
         $sid = pdo_insertid();
     } else {
         CRUD::updateById(CRUD::$table_sign, $data, $sid);
     }
     //连续 签到处理
     $serialids = array();
     $serial_ids = $_GPC['serial_ids'];
     $serial_days = $_GPC['serial_day'];
     $serial_credits = $_GPC['serial_credit'];
     if (is_array($serial_ids)) {
         foreach ($serial_ids as $key => $value) {
             $value = intval($value);
             $d = array('sid' => $sid, 'day' => $serial_days[$key], 'credit' => $serial_credits[$key], 'createtime' => TIMESTAMP);
             if (empty($value)) {
                 CRUD::create(CRUD::$table_sign_serial, $d);
                 $serialids[] = pdo_insertid();
             } else {
                 CRUD::updateById(CRUD::$table_sign_serial, $d, $value);
                 $serialids[] = $value;
             }
         }
         if (count($serialids) > 0) {
             pdo_query("delete from " . tablename(CRUD::$table_sign_serial) . " where sid='{$sid}' and id not in (" . implode(",", $serialids) . ")");
         } else {
             pdo_query("delete from " . tablename(CRUD::$table_sign_serial) . " where sid='{$sid}' ");
         }
     }
     //快捷菜单处理
     $link_ids = $_GPC['link_ids'];
     $link_urls = $_GPC['link_url'];
     $link_names = $_GPC['link_name'];
     $link_sorts = $_GPC['link_sort'];
     pdo_query("delete from " . tablename(CRUD::$table_sign_link) . " where sid=:sid", array(":sid" => $sid));
     if (is_array($link_ids)) {
         foreach ($link_ids as $key => $value) {
             $value = intval($value);
             $d = array("sid" => $sid, "sort" => $link_sorts[$key], "link_name" => $link_names[$key], "link_url" => $link_urls[$key], 'createtime' => TIMESTAMP);
             CRUD::create(CRUD::$table_sign_link, $d);
         }
     }
     return true;
 }
Example #18
0
/**
 * 打印机注册
 *    检查打印机是否注册,
 *    没有注册插入打印机信息,返回注册id
 * @param $data
 * @return array
 */
function biz_Print_Register($data, $module)
{
    $sql = " select * from " . tablename('printer');
    $where = ' where `moduleid`=:moduleid and `index`=:index';
    $param = array(':moduleid' => $module['id'], ':index' => $data['index']);
    $print = pdo_fetch($sql . $where, $param);
    if (empty($print)) {
        $insert = array('title' => $data['name'], 'index' => $data['index'], 'moduleid' => $module['id'], 'type' => $data['type'], 'createtime' => TIMESTAMP, 'reporttime' => TIMESTAMP, 'status' => '创建');
        pdo_insert('printer', $insert);
        $id = pdo_insertid();
        $print = pdo_fetch($sql . " where id=:id", array(':id' => $id));
    }
    //PrinterName,printerId,type
    return $print;
}
Example #19
0
 public function create($entity)
 {
     global $_W;
     $rec = array_elements(array('activity', 'uid'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     $rec['item'] = 'key';
     $rec['status'] = 'created';
     $rec['created'] = TIMESTAMP;
     $rec['completed'] = 0;
     $ret = pdo_insert('mbrp_trades', $rec);
     if (!empty($ret)) {
         return pdo_insertid();
     } else {
         return error(-1, '数据保存失败, 请稍后重试');
     }
 }
Example #20
0
/**
 * 用户注册
 * PS:密码字段不要加密
 * @param array $member 用户注册信息,需要的字段必须包括 username, password, remark
 * @return int 成功返回新增的用户编号,失败返回 0
 */
function member_register($member) {
	$member['salt'] = random(8);
	$member['joindate'] = TIMESTAMP;
	$member['password'] = member_hash($member['password'], $member['salt']);
    $member['status'] = 0;
    $member['joinip'] = CLIENT_IP;
    $member['lastvisit'] = TIMESTAMP;
    $member['lastip'] = CLIENT_IP;
	$result = pdo_insert('members', $member);
	if($result) {
		if(empty($member['uid'])) {
			$member['uid'] = pdo_insertid();
		}
	}
	return $member['uid'];
}
Example #21
0
 public function doMobileset()
 {
     global $_GPC, $_W;
     $_GPC['title'] = urldecode($_GPC['title']);
     $_GPC['content'] = urldecode($_GPC['content']);
     $_GPC['author'] = urldecode($_GPC['author']);
     $_GPC['cardName'] = urldecode($_GPC['cardName']);
     $insert = array('rid' => $_GPC['id'], 'weid' => $_GPC['weid'], 'title' => $_GPC['title'], 'card' => $_GPC['card'], 'content' => $_GPC['content'], 'author' => $_GPC['author'], 'cardName' => $_GPC['cardName'], 'from_user' => $_W['fans']['from_user'], 'create_time' => time());
     $temp = pdo_insert('heka_list', $insert);
     if ($temp == false) {
         $this->_message(0, '保存数据失败');
     } else {
         $id = pdo_insertid();
         $this->_message($id, '保存数据成功', 1, $_GPC['author']);
     }
 }
Example #22
0
 public function doMobilecomment()
 {
     global $_W, $_GPC;
     $tid = $_GPC['id'];
     $comment = $_GPC['cont'];
     $uniacid = $_W['uniacid'];
     $openid = $_W['openid'];
     $ulist = $this->auth($uniacid, $openid);
     $data = array('uniacid' => $uniacid, 'tid' => $tid, 'comment' => $comment, 'nickname' => $ulist['nickname'], 'cuid' => $ulist['uid'], 'createtime' => TIMESTAMP);
     $res = pdo_insert('enjoy_circle_comment', $data);
     $data['cid'] = pdo_insertid();
     $data['fuc'] = "todelpop('p_" . $data['cid'] . "')";
     if ($res > 0) {
         echo json_encode($data);
     }
 }
Example #23
0
 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'thumb' => $_GPC['thumb'], 'description' => $_GPC['description'], 'heading' => $_GPC['heading'], 'smallheading' => $_GPC['smallheading'], 'followurl' => $_GPC['followurl'], 'tel' => $_GPC['tel'], 'num' => intval($_GPC['num']), 'beforenum' => intval($_GPC['beforenum']), 'intro' => $_GPC['intro'], 'screenbg' => $_GPC['screenbg'], 'templateid' => $_GPC['templateid'], 'qrcode' => $_GPC['qrcode'], 'qrcodetype' => intval($_GPC['qrcodetype']), 'status' => 1);
     if (empty($id)) {
         pdo_insert('xwz_queue_reply', $insert);
     } else {
         pdo_update('xwz_queue_reply', $insert, array('id' => $id));
     }
     //自定义字段
     $type_ids = $_GPC['type_id'];
     $type_tags = $_GPC['type_tag'];
     $type_titles = $_GPC['type_title'];
     $type_nums = $_GPC['type_num'];
     $type_status = $_GPC['type_status'];
     $typeids = array();
     if (is_array($type_ids)) {
         foreach ($type_ids as $key => $value) {
             $d = array('uniacid' => $_W['uniacid'], 'rid' => $rid, 'tag' => $type_tags[$key], 'title' => $type_titles[$key], 'num' => $type_nums[$key], 'status' => $type_status[$key]);
             if (empty($value)) {
                 pdo_insert('xwz_queue_type', $d);
                 $typeids[] = pdo_insertid();
             } else {
                 pdo_insert('xwz_queue_type', $d);
                 $typeids[] = $value;
             }
         }
     }
     if (count($typeids) > 0) {
         pdo_query('delete from ' . tablename('xwz_queue_type') . ' where uniacid=:uniacid and rid=:rid and id not in (' . implode(',', $typeids) . ')', array(':uniacid' => $_W['uniacid'], ':rid' => $rid));
     } else {
         pdo_query('delete from ' . tablename('xwz_queue_type') . ' where uniacid=:uniacid and rid=:rid', array(':uniacid' => $_W['uniacid'], ':rid' => $rid));
     }
     //管理二维码
     $path = IA_ROOT . '/addons/xwz_queue/mqrcode';
     if (!is_dir($path)) {
         load()->func('file');
         mkdirs($path);
     }
     $file = $path . '/qrcode_' . $_W['uniacid'] . '_' . $rid . '.png';
     require_once IA_ROOT . '/framework/library/qrcode/phpqrcode.php';
     $url = $_W['siteroot'] . 'app/' . substr($this->createMobileUrl('manage', array('rid' => $rid)), 2);
     QRcode::png($url, $file);
     return true;
 }
Example #24
0
 public function doMobileIndex()
 {
     global $_GPC, $_W;
     $from = $_W['fans']['from_user'];
     $rid = intval($_GPC['rid']);
     $weid = intval($_GPC['weid']);
     $date = date('Y-m-d');
     $date = strtotime($date);
     $now = time();
     $profile = fans_search($from);
     $sql = "SELECT * FROM " . tablename('exchange_reply') . " WHERE `rid`=:rid";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     $row['picture'] = $_W['attachurl'] . trim($row['picture'], '/');
     $title = $row['title'];
     //$newcredit = $profile['credit1'] - $row['price'];
     $numax = floor($profile['credit1'] / $row['price']);
     $exchanged = pdo_fetchall("SELECT sum(nums) as enum FROM " . tablename('exchange_record') . " WHERE rid = :rid ", array(':rid' => $rid));
     $userexchangeinfo = pdo_fetchall("SELECT nums, cprice, time FROM " . tablename('exchange_record') . " WHERE rid = :rid AND openid = :openid ", array(':rid' => $rid, ':openid' => $from));
     $usertodayexchang = pdo_fetchall("SELECT * FROM " . tablename('exchange_record') . " WHERE rid = :rid AND openid = :openid AND `time` >= :date ", array(':rid' => $rid, ':openid' => $from, ':date' => $date));
     $usertodaynum = count($usertodayexchang);
     $allowexchange = $row['amount'] - $exchanged['0']['enum'];
     if ($numax >= 1) {
         for ($i = 1; $i <= $numax; $i++) {
             $n = $i;
             $nn[] = $n;
         }
     }
     if (!empty($_GPC['submit'])) {
         if ($usertodaynum >= $row['times']) {
             message('每天只能兑换' . $row['times'] . '次哟~~', 'refresh', 'error');
         }
         if ($_GPC['nums'] <= $allowexchange) {
             $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'credit1' => $profile['credit1'] - $_GPC['cprice']);
             fans_update($from, $data);
             $insert = array('weid' => $weid, 'rid' => $rid, 'openid' => $from, 'name' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'nums' => $_GPC['nums'], 'cprice' => $_GPC['cprice'], 'time' => $now);
             if (pdo_insert('exchange_record', $insert)) {
                 $id = pdo_insertid();
             }
         } else {
             die('<script>location.href = "' . $this->createMobileUrl('error', array('rid' => $_GPC['rid'], 'id' => $id)) . '";</script>');
         }
         die('<script>location.href = "' . $this->createMobileUrl('success', array('rid' => $_GPC['rid'], 'id' => $id)) . '";</script>');
     }
     include $this->template('index');
 }
Example #25
0
 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'weid' => $_W['uniacid'], 'title' => $_GPC['title'], 'description' => $_GPC['description'], 'votetype' => $_GPC['votetype'], 'votelimit' => $_GPC['votelimit'], 'votetimes' => $_GPC['votetimes'], 'votetotal' => $_GPC['votetotal'], 'isimg' => $_GPC['isimg'], 'share_title' => $_GPC['share_title'], 'share_desc' => preg_replace('/\\s/i', '', str_replace('	', '', cutstr(str_replace('&nbsp;', '', ihtmlspecialchars(strip_tags($_GPC['share_desc']))), 60))), 'share_url' => $_GPC['share_url'], 'share_txt' => $_GPC['share_txt'], 'starttime' => strtotime($_GPC['datelimit']['start']), 'endtime' => strtotime($_GPC['datelimit']['end']));
     if (!empty($_GPC['thumb'])) {
         $insert['thumb'] = $_GPC['thumb'];
         load()->func('file');
         file_delete($_GPC['thumb-old']);
     }
     if (empty($id)) {
         if ($insert['starttime'] <= TIMESTAMP) {
             $insert['isshow'] = 1;
         } else {
             $insert['isshow'] = 0;
         }
         $id = pdo_insert($this->tablename, $insert);
     } else {
         pdo_update($this->tablename, $insert, array('id' => $id));
     }
     $options = array();
     $option_ids = $_POST['option_id'];
     $option_titles = $_POST['option_title'];
     $option_thumb_olds = $_POST['option_thumb_old'];
     $files = $_FILES;
     $len = count($option_ids);
     $ids = array();
     for ($i = 0; $i < $len; $i++) {
         $item_id = $option_ids[$i];
         $a = array("title" => $option_titles[$i], "rid" => $rid, "thumb" => $_GPC['option_thumb_' . $item_id]);
         if ((int) $item_id == 0) {
             pdo_insert("vote_option", $a);
             $item_id = pdo_insertid();
         } else {
             pdo_update("vote_option", $a, array('id' => $item_id));
         }
         $ids[] = $item_id;
     }
     if (!empty($ids)) {
         pdo_query("delete from " . tablename('vote_option') . " where  rid = {$rid} and  id not in ( " . implode(',', $ids) . ")");
     }
     return true;
 }
Example #26
0
 public function fieldsFormSubmit($rid)
 {
     global $_GPC;
     $egid = $_GPC['egid'];
     $data = array('rid' => $rid, 'weid' => $this->weid, 'title' => $_GPC['title'], 'starttime' => strtotime($_GPC['starttime']), 'endtime' => strtotime($_GPC['endtime']), 'follow_url' => $_GPC['follow_url'], 'copyright' => $_GPC['copyright'], 'follow_btn_name' => $_GPC['follow_btn_name'], 'follow_dlg_tip' => $_GPC['follow_dlg_tip'], 'new_title' => $_GPC['new_title'], 'new_icon' => $_GPC['new_icon'], 'new_content' => $_GPC['new_content'], 'share_title' => $_GPC['share_title'], 'share_icon' => $_GPC['share_icon'], 'share_content' => $_GPC['share_content'], 'intro' => htmlspecialchars_decode($_GPC['intro']), 'banner_bg' => $_GPC['banner_bg'], 'bg_img' => $_GPC['bg_img'], 'share_bg' => $_GPC['share_bg'], 'day_count' => $_GPC['day_count'], 'prize_limit' => $_GPC['prize_limit'], 'dpassword' => $_GPC['dpassword'], 'share_enable' => $_GPC['share_enable'], 'share_times' => $_GPC['share_times'], 'share_award_count' => $_GPC['share_award_count'], 'music' => $_GPC['music'], 'exchangeEnable' => $_GPC['exchangeEnable'], 'updatetime' => TIMESTAMP);
     if (empty($egid)) {
         $data['createtime'] = TIMESTAMP;
         DBUtil::create(DBUtil::$TABLE_EGG, $data);
         $egid = pdo_insertid();
     } else {
         DBUtil::updateById(DBUtil::$TABLE_EGG, $data, $egid);
     }
     $prizids = array();
     $pids = $_GPC['pids'];
     $display_orders = $_GPC['display_orders'];
     $plevels = $_GPC['plevels'];
     $pnames = $_GPC['pnames'];
     $pimgs = $_GPC['pimgs'];
     $ptypes = $_GPC['ptypes'];
     $jfs = $_GPC['jfs'];
     $pcounts = $_GPC['pcounts'];
     $pbs = $_GPC['pbs'];
     $pimgs = $_GPC['pimgs'];
     if (is_array($pids)) {
         foreach ($pids as $key => $value) {
             $value = intval($value);
             $d = array("egid" => $egid, "plevel" => $plevels[$key], 'display_order' => $display_orders[$key], 'pname' => $pnames[$key], 'pimg' => $pimgs[$key], 'pcount' => $pcounts[$key], 'ptype' => $ptypes[$key], 'pb' => $pbs[$key], 'jf' => $jfs[$key], "createtime" => TIMESTAMP);
             if (empty($value)) {
                 DBUtil::create(DBUtil::$TABLE_EGG_PRIZE, $d);
                 $prizids[] = pdo_insertid();
             } else {
                 DBUtil::updateById(DBUtil::$TABLE_EGG_PRIZE, $d, $value);
                 $prizids[] = $value;
             }
         }
         if (count($prizids) > 0) {
             pdo_query("delete from " . tablename(DBUtil::$TABLE_EGG_PRIZE) . " where egid='{$egid}' and id not in (" . implode(",", $prizids) . ")");
         } else {
             pdo_query("delete from " . tablename(DBUtil::$TABLE_EGG_PRIZE) . " where egid='{$egid}'");
         }
     }
     return true;
 }
Example #27
0
 public function create($entity)
 {
     global $_W;
     $rec = array_elements(array('title', 'type', 'remark', 'tag'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     $condition = '`uniacid`=:uniacid AND `title`=:title';
     $pars = array();
     $pars[':uniacid'] = $rec['uniacid'];
     $pars[':title'] = $rec['title'];
     $sql = 'SELECT * FROM ' . tablename('mbrp_gifts') . " WHERE {$condition}";
     $exists = pdo_fetch($sql, $pars);
     if (!empty($exists)) {
         return error(-1, '这个礼品名称已经使用, 请更换');
     }
     $ret = pdo_insert('mbrp_gifts', $rec);
     if (!empty($ret)) {
         $id = pdo_insertid();
         return $id;
     }
     return false;
 }
Example #28
0
 public function get_user_info($uid, $openid)
 {
     global $_W;
     load()->func('communication');
     if ($uid == 0) {
         $f_log = pdo_fetch("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE `uniacid` = '{$_W['uniacid']}' AND `openid` = '{$openid}'");
         if (!empty($f_log['uid'])) {
             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) . '@012wz.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));
         }
     }
     $info = mc_fetch($uid);
     if (empty($info['nickname'])) {
         $account = account_fetch($_W['acid']);
         $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $account['access_token']['token'] . "&openid=" . $openid . "&lang=zh_CN";
         $re = ihttp_get($url);
         if ($re['code'] == 200) {
             $content = json_decode($re['content'], true);
             if ($content['subscribe'] == 1) {
                 //此人已关注
                 $data = array('nickname' => $content['nickname'], 'gender' => $content['sex'], 'avatar' => $content['headimgurl'], 'resideprovince' => $content['province'], 'residecity' => $content['city'], 'nationality' => $content['country']);
                 pdo_update('mc_members', $data, array('uid' => $_W['member']['uid']));
                 pdo_update('mc_mapping_fans', array('follow' => 1), array('acid' => $_W['acid'], 'openid' => $openid));
             }
         }
         $info = mc_fetch($uid);
         return $info;
     } else {
         return $info;
     }
 }
Example #29
0
 /**
  * 增加一次助力记录
  *      如果owner, helper 已经存在, 失败
  *   id uniacid owner helper dateline
  *
  * @param $entity 助力结构 owner, helper, dateline
  * @return int|error
  */
 public function createHelp($entity)
 {
     global $_W;
     $rec = array_elements(array('owner', 'helper', 'dateline'), $entity);
     $rec['uniacid'] = $_W['uniacid'];
     $rec['activity'] = $this->activity['actid'];
     require_once MB_ROOT . '/source/Fans.class.php';
     $f = new Fans();
     $ownerExists = $f->getOne($entity['owner']);
     $helperExists = $f->getOne($entity['helper']);
     if (!empty($ownerExists) && !empty($helperExists)) {
         $pars = array();
         $pars[':uniacid'] = $_W['uniacid'];
         $pars[':activity'] = $this->activity['actid'];
         $pars[':helper'] = $rec['helper'];
         if (!empty($this->activity['tag']['limit'])) {
             $sql = 'SELECT COUNT(*) FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `activity`=:activity AND `helper` =:helper';
             $count = pdo_fetchcolumn($sql, $pars);
             if ($this->activity['tag']['limit'] <= $count) {
                 return error(-1, "超过次数限制, 本次活动限制每人帮助好友次数不能超过 {$this->activity['tag']['limit']} 次");
             }
         }
         $pars[':owner'] = $rec['owner'];
         $sql = 'SELECT * FROM ' . tablename('mbrp_helps') . ' WHERE `uniacid`=:uniacid AND `activity`=:activity AND `owner`=:owner AND `helper` =:helper';
         $exists = pdo_fetch($sql, $pars);
         if (!empty($exists)) {
             return error(-3, '已经帮助过这位好友了');
         }
         $ret = pdo_insert('mbrp_helps', $rec);
         if (!empty($ret)) {
             return pdo_insertid();
         } else {
             return error(-2, '数据保存失败, 请稍后重试');
         }
     } else {
         return error(-1, '用户不存在');
     }
 }
Example #30
0
 public function doMobileIndex()
 {
     global $_W, $_GPC;
     if (empty($_W['fans']['openid'])) {
         message('请先关注公众号再来参加活动吧!');
     }
     $rid = intval($_GPC['rid']);
     $sql = 'SELECT * FROM ' . tablename('weihaom_wb_reply') . ' WHERE `rid` = :rid';
     $params = array(':rid' => $rid);
     $set = pdo_fetch($sql, $params);
     if (empty($set)) {
         message('活动不存在或已经被删除');
     }
     $sql = 'SELECT * FROM ' . tablename('weihaom_wb_user') . ' WHERE `weid` = :weid AND `rid` = :rid AND
             `from_user` = :openid';
     $params[':weid'] = $_W['uniacid'];
     $params[':openid'] = $_W['fans']['openid'];
     $user = pdo_fetch($sql, $params);
     if (intval($_GPC['id'])) {
         $score = intval($_GPC['score']);
         if ($user['score'] < $score) {
             $user['score'] = $score;
             $update = array('score' => $score);
             pdo_update('weihaom_wb_user', $update, array('id' => intval($_GPC['id'])));
         }
         message($user['score'], '', 'ajax');
     }
     if (empty($user)) {
         $result = mc_fetch($_W['member']['uid'], array('nickname'));
         $insert = array('weid' => $_W['uniacid'], 'rid' => $params[':rid'], 'from_user' => $_W['fans']['openid'], 'realname' => $result['nickname'], 'score' => 0);
         pdo_insert('weihaom_wb_user', $insert);
         $user = array('id' => pdo_insertid());
     }
     $realname = $_W['fans']['nickname'];
     $set['description'] = str_replace("\r\n", '', $set['description']);
     include $this->template('index');
 }