Beispiel #1
0
 public function fieldsFormSubmit($rid)
 {
     global $_W, $_GPC;
     $id = intval($_GPC['replyid']);
     $data = array('rid' => $rid, 'weid' => $_W['weid'], 'sn' => $_GPC['sn'], 'token' => $_GPC['apitoken'], 'maxuse' => intval($_GPC['maxuse']), 'maxtotal' => intval($_GPC['maxtotal']), 'adtype' => intval($_GPC['adtype']), 'adurlv' => $_GPC['adurlv'], 'adurlh' => $_GPC['adurlh'], 'admsg' => $_GPC['admsg'], 'leavemsg' => $_GPC['leavemsg'], 'fontfamily' => $_GPC['fontfamily'], 'fontcolor' => $_GPC['fontcolor'], 'qrcode' => $_GPC['qrcode'], 'mainpic' => $_GPC['mainpic'], 'adpics' => '', 'width' => $_GPC['width'], 'height' => $_GPC['height'], 'size' => intval($_GPC['photosize']), 'status' => intval($_GPC['status']), 'enableauthcode' => intval($_GPC['enableauthcode']), 'enablemsg' => intval($_GPC['enablemsg']), 'content' => $_GPC['content'], 'tipsentry' => $_GPC['tipsentry'], 'tipssuccess' => $_GPC['tipssuccess'], 'tipserror' => $_GPC['tipserror']);
     if (!empty($_GPC['sort'])) {
         asort($_GPC['sort']);
         foreach ($_GPC['sort'] as $key => $value) {
             $data['adpics'][] = $_GPC['adpics'][$key];
         }
         $data['adpics'] = iserializer($data['adpics']);
     } else {
         $data['adpics'] = iserializer($_GPC['adpics']);
     }
     if (empty($id)) {
         pdo_insert('we7_photomaker', $data);
     } else {
         if (!empty($_GPC['qrcode'])) {
             file_delete($_GPC['qrcode-old']);
         }
         if (!empty($_GPC['mainpic'])) {
             file_delete($_GPC['mainpic-old']);
         }
         pdo_update('we7_photomaker', $data, array('id' => $id));
     }
 }
function account_mechat_token($acmechat)
{
    if (is_array($acmechat['access_token']) && !empty($acmechat['access_token']['token']) && !empty($acmechat['access_token']['expire']) && $acmechat['access_token']['expire'] > TIMESTAMP) {
        return $acmechat['access_token']['token'];
    } else {
        if (empty($acmechat['weid'])) {
            message('参数错误.');
        }
        if (empty($acmechat['appid']) || empty($acmechat['appsecret'])) {
            message('请填写开发者的appid及appsecret, (需要你的号码为美洽开发者)!', create_url('index/module/display', array('name' => 'mechat')), 'error');
        }
        $url = "http://open.mobilechat.im/cgi-bin/token?grant_type=client_credential&appid={$acmechat['appid']}&secret={$acmechat['appsecret']}";
        $content = ihttp_get($url);
        if (empty($content)) {
            message('获取美洽开发者授权失败, 请稍后重试!');
        }
        $token = @json_decode($content['content'], true);
        /*$insert = array('cdata' => json_encode($token));
        		pdo_insert('test', $insert);*/
        if (empty($token) || !is_array($token)) {
            message('获取美洽开发者授权失败, 请稍后重试! 公众平台返回原始数据为: <br />' . $token);
        }
        if (empty($token['access_token']) || empty($token['expire_in'])) {
            message("解析美洽开发者授权失败. <br />URL:{$url}<br />错误代码为: {$token['errcode']} <br />错误信息为: {$token['errmsg']}");
        }
        $record = array();
        $record['token'] = $token['access_token'];
        $record['expire'] = TIMESTAMP + $token['expires_in'];
        $row = array();
        $row['access_token'] = iserializer($record);
        pdo_update('mechat', $row, array('weid' => $acmechat['weid']));
        return $record['token'];
    }
}
Beispiel #3
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;
 }
Beispiel #4
0
 public function respond()
 {
     global $_W;
     $msgtype = $this->message['type'];
     $allow = array('text', 'image', 'location', 'link', 'trace');
     if (!in_array($msgtype, $allow)) {
         return $this->respText('抱歉,系统仅支持 文字,图片,地理位置,链接类型的消息!');
     }
     $close = 0;
     if ($msgtype == 'text') {
         $content = $this->message['content'];
         if ($content == '关闭') {
             $content = '<span class="text-danger">系统消息:粉丝关闭了对话</span>';
             $close = 1;
         }
     } elseif ($msgtype == 'image') {
         $content = $this->message['picurl'];
     } elseif ($msgtype == 'location') {
         $content = iserializer(array('location_x' => $this->message['location_x'], 'location_y' => $this->message['location_y'], 'scale' => $this->message['scale']));
     } elseif ($msgtype == 'link') {
         $content = $this->message['url'];
     }
     if (!empty($content)) {
         $insert = array('uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'openid' => $_W['openid'], 'msgtype' => $msgtype, 'flag' => 2, 'content' => $content, 'createtime' => TIMESTAMP);
         pdo_insert('mc_chats_record', $insert);
     }
     $this->refreshContext(300);
     if ($close == 1) {
         $this->endContext();
         return $this->respText('您成功关闭回话。');
     }
     return $this->respText('');
 }
Beispiel #5
0
 public function calculate($orderid = 0, $update = true)
 {
     global $_W;
     $set = $this->getSet();
     $levels = $this->getLevels();
     $goods = pdo_fetchall("select og.id,og.realprice,og.total,g.hascommission, g.commission1_rate,g.commission1_pay,g.commission2_rate,g.commission2_pay,g.commission3_rate,g.commission3_pay from " . tablename('ewei_shop_order_goods') . '  og ' . ' left join ' . tablename('ewei_shop_goods') . ' g on g.id = og.goodsid' . ' where og.orderid=:orderid and og.uniacid=:uniacid', array(':orderid' => $orderid, ':uniacid' => $_W['uniacid']));
     if ($set['level'] > 0) {
         foreach ($goods as &$cinfo) {
             $price = $cinfo['realprice'];
             if ($cinfo['hascommission'] == 1) {
                 $cinfo['commission1'] = array('default' => $set['level'] >= 1 ? $cinfo['commission1_rate'] > 0 ? round($cinfo['commission1_rate'] * $price / 100, 2) . "" : round($cinfo['commission1_pay'] * $cinfo['total'], 2) : 0);
                 $cinfo['commission2'] = array('default' => $set['level'] >= 2 ? $cinfo['commission2_rate'] > 0 ? round($cinfo['commission2_rate'] * $price / 100, 2) . "" : round($cinfo['commission2_pay'] * $cinfo['total'], 2) : 0);
                 $cinfo['commission3'] = array('default' => $set['level'] >= 3 ? $cinfo['commission3_rate'] > 0 ? round($cinfo['commission3_rate'] * $price / 100, 2) . "" : round($cinfo['commission3_pay'] * $cinfo['total'], 2) : 0);
             } else {
                 $cinfo['commission1'] = array('default' => $set['level'] >= 1 ? round($set['commission1'] * $price / 100, 2) . "" : 0);
                 $cinfo['commission2'] = array('default' => $set['level'] >= 2 ? round($set['commission2'] * $price / 100, 2) . "" : 0);
                 $cinfo['commission3'] = array('default' => $set['level'] >= 3 ? round($set['commission3'] * $price / 100, 2) . "" : 0);
                 foreach ($levels as $level) {
                     $cinfo['commission1']['level' . $level['id']] = $set['level'] >= 1 ? round($level['commission1'] * $price / 100, 2) . "" : 0;
                     $cinfo['commission2']['level' . $level['id']] = $set['level'] >= 2 ? round($level['commission2'] * $price / 100, 2) . "" : 0;
                     $cinfo['commission3']['level' . $level['id']] = $set['level'] >= 3 ? round($level['commission3'] * $price / 100, 2) . "" : 0;
                 }
             }
             if ($update) {
                 pdo_update('ewei_shop_order_goods', array('commission1' => iserializer($cinfo['commission1']), 'commission2' => iserializer($cinfo['commission2']), 'commission3' => iserializer($cinfo['commission3'])), array('id' => $cinfo['id']));
             }
         }
         unset($cinfo);
     }
     return $goods;
 }
 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'];
 }
Beispiel #7
0
 public function doWebAdd()
 {
     global $_GPC, $_W;
     $id = intval($_GPC['id']);
     if (!empty($id)) {
         $item = pdo_fetch("SELECT * FROM " . tablename($this->headtable) . " WHERE id = :id", array(':id' => $id));
         if (empty($item)) {
             message('抱歉,喜帖不存在或是已经删除!', '', 'error');
         }
         $hslists = unserialize($item['hs_pic']);
         if (is_array($hslists)) {
             //兼容0.5数据
             foreach ($hslists as &$h) {
                 if (is_array($h) && isset($h['attachment'])) {
                     $h = $h['attachment'];
                 }
             }
             unset($h);
         }
     }
     if (checksubmit('submit')) {
         if (empty($_GPC['title'])) {
             message('请输入喜帖标题!');
         }
         $data = array('weid' => $_W['uniacid'], 'title' => $_GPC['title'], 'xl_name' => $_GPC['xl_name'], 'xn_name' => $_GPC['xn_name'], 'is_front' => $_GPC['is_front'], 'tel' => $_GPC['tel'], 'hy_time' => $_GPC['hy_time'], 'hy_addr' => $_GPC['hy_addr'], 'jw_addr' => $_GPC['hy_addr'], 'lng' => $_GPC['baidumap']['lng'], 'lat' => $_GPC['baidumap']['lat'], 'video' => $_GPC['video'], 'music' => $_GPC['music'], 'pwd' => $_GPC['pwd'], 'word' => htmlspecialchars_decode($_GPC['word']), 'province' => $_GPC['district']['province'], 'city' => $_GPC['district']['city'], 'dist' => $_GPC['district']['dist'], 'createtime' => TIMESTAMP, 'sendtitle' => $_GPC['sendtitle'], 'senddescription' => $_GPC['senddescription'], 'copyright' => htmlspecialchars_decode($_GPC['copyright']));
         load()->func('file');
         //上传图片
         if (!empty($_GPC['art_pic']) && $_GPC['art_pic'] != $_GPC['art_pic_old']) {
             file_delete($_GPC['art_pic_old']);
             $data['art_pic'] = $_GPC['art_pic'];
         }
         if (!empty($_GPC['bg_pic']) && $_GPC['bg_pic'] != $_GPC['bg_pic_old']) {
             file_delete($_GPC['bg_pic_old']);
             $data['bg_pic'] = $_GPC['bg_pic'];
         }
         if (!empty($_GPC['donghua_pic']) && $_GPC['donghua_pic'] != $_GPC['donghua_pic_old']) {
             file_delete($_GPC['donghua_pic_old']);
             $data['donghua_pic'] = $_GPC['donghua_pic'];
         }
         if (!empty($_GPC['suolue_pic']) && $_GPC['suolue_pic'] != $_GPC['suolue_pic_old']) {
             file_delete($_GPC['suolue_pic_old']);
             $data['suolue_pic'] = $_GPC['suolue_pic'];
         }
         if (!empty($_GPC['music']) && $_GPC['music'] != $_GPC['music_old']) {
             file_delete($_GPC['music_old']);
             $data['music'] = $_GPC['music'];
         }
         if (is_array($_GPC['thumbs'])) {
             $data['hs_pic'] = iserializer($_GPC['thumbs']);
         }
         if (empty($id)) {
             pdo_insert($this->headtable, $data);
         } else {
             unset($data['createtime']);
             pdo_update($this->headtable, $data, array('id' => $id));
         }
         message('喜帖信息更新成功!', $this->createWebUrl('manager'), 'success');
     }
     include $this->template('add');
 }
Beispiel #8
0
 public function fieldsFormSubmit($rid)
 {
     //规则验证无误保存入库时执行,这里应该进行自定义字段的保存。这里 $rid 为对应的规则编号
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'title' => $_GPC['title'], 'credit' => $_GPC['credit'], 'picture' => $_GPC['picture'], 'upfansdataurl' => $_GPC['upfansdataurl'], 'description' => $_GPC['description'], 'content' => $_GPC['content'], 'start_time' => strtotime($_GPC['start_time']), 'end_time' => strtotime($_GPC['end_time']), 'status' => $_GPC['status']);
     if (!empty($_GPC['fields'])) {
         foreach ($_GPC['fields']['title'] as $index => $row) {
             if (empty($_GPC['fields']['title'])) {
                 continue;
             }
             $insert['fields'][] = array('title' => $_GPC['fields']['title'][$index], 'require' => intval($_GPC['fields']['require'][$index]), 'bind' => $_GPC['fields']['bind'][$index]);
         }
         $insert['fields'] = iserializer($insert['fields']);
     }
     if (empty($id)) {
         pdo_insert($this->table_reply, $insert);
     } else {
         if (!empty($_GPC['picture'])) {
             file_delete($_GPC['picture-old']);
         } else {
             unset($insert['picture']);
         }
         pdo_update($this->table_reply, $insert, array('id' => $id));
     }
 }
Beispiel #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));
             }
         }
     }
 }
Beispiel #10
0
function cache_write($key, $data)
{
    if (empty($key) || !isset($data)) {
        return false;
    }
    $record = array();
    $record['key'] = $key;
    $record['value'] = iserializer($data);
    return pdo_insert('core_cache', $record, true);
}
Beispiel #11
0
 private function post()
 {
     global $_W, $engine;
     if (!in_array($this->message['msgtype'], array('text', 'image'))) {
         return false;
     }
     $member = $this->getMember();
     $wall = pdo_fetch("SELECT * FROM " . tablename('wxwall_reply') . " WHERE rid = :rid LIMIT 1", array(':rid' => $member['rid']));
     if (!empty($wall['timeout']) && $wall['timeout'] > 0 && TIMESTAMP - $member['lastupdate'] >= $wall['timeout']) {
         $this->endContext();
         return $this->respText('由于您长时间未操作,请重新进入微信墙!');
     }
     $this->refreshContext();
     if (empty($wall['quit_command']) && $this->message['content'] == '退出' || !empty($wall['quit_command']) && $this->message['content'] == $wall['quit_command']) {
         $this->endContext();
         return $this->respText($wall['quit_tips']);
     }
     if (empty($member['nickname']) || empty($member['avatar'])) {
         return $this->respText('发表话题前请完善您的基本信息,<a target="_blank" href="' . $this->createMobileUrl('register') . '">点击完善</a>。');
     }
     $data = array('rid' => $member['rid'], 'from_user' => $_W['member']['uid'], 'type' => $this->message['type'], 'createtime' => TIMESTAMP);
     if (empty($wall['isshow']) && empty($member['isblacklist'])) {
         $data['isshow'] = 1;
     } else {
         $data['isshow'] = 0;
     }
     if ($this->message['type'] == 'text') {
         $data['content'] = $this->message['content'];
     }
     if ($this->message['type'] == 'image') {
         load()->func('communication');
         $image = ihttp_request($this->message['picurl']);
         $partPath = IA_ROOT . '/' . $_W['config']['upload']['attachdir'] . '/';
         do {
             $filename = "images/{$_W['uniacid']}/" . date('Y/m/') . random(30) . '.jpg';
         } while (file_exists($partPath . $filename));
         file_write($filename, $image['content']);
         $data['content'] = $filename;
     }
     if ($this->message['type'] == 'link') {
         $data['content'] = iserializer(array('title' => $this->message['title'], 'description' => $this->message['description'], 'link' => $this->message['link']));
     }
     pdo_insert('wxwall_message', $data);
     if (!empty($member['isblacklist'])) {
         $content .= '你已被列入黑名单,发送的消息需要管理员审核!';
     } elseif (!empty($wall['isshow'])) {
         $content = '发送消息成功,请等待管理员审核';
     } elseif (!empty($wall['send_tips'])) {
         $content = $wall['send_tips'];
     } else {
         $content = '发送消息成功。';
     }
     return $this->respText($content);
 }
Beispiel #12
0
function cache_write($key, $data) {
	if (empty($key) || empty($data)) {
		return false;
	}
	$record = array();
	$record['key'] = $key;
	$record['value'] = iserializer($data);
	$tmp = &cache_global($key);
	$tmp = $data;
	return pdo_insert('cache', $record, true);
}
Beispiel #13
0
 public function doDisplay()
 {
     //这个操作被定义用来呈现主导航栏上扩展菜单,每个模块只能呈现一个扩展菜单,有更多选项,请在页面内使用标签页来表示
     global $_W, $_GPC;
     $mechat = array();
     if (checksubmit('submit')) {
         $file = IA_ROOT . '/source/modules/mechat/function.php';
         if (!file_exists($file)) {
             return array();
         }
         include_once $file;
         $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `weid`=:weid";
         $row = pdo_fetch($sql, array(':weid' => $_W['weid']));
         if ($row) {
             $dat = iunserializer($row["cdata"]);
             $pass = $dat["pass"];
             if ($_GPC['mechat-pass'] != $pass) {
                 $pass = md5($_GPC['mechat-pass']);
             }
             $mechat = array("name" => $_GPC['mechat-user'], "pass" => $pass, "appid" => $_GPC['mechat-appid'], "appsecret" => $_GPC['mechat-appsecret']);
             $access_token = array("token" => $dat["access_token"]["token"], "expire" => $dat["access_token"]["expire"]);
             $update = array("name" => $_GPC['mechat-user'], "cdata" => iserializer($mechat), "access_token" => $access_token);
             pdo_update($this->tablename, $update, array('weid' => $_W['weid']));
         } else {
             $pass = md5($_GPC['mechat-pass']);
             $mechat = array("name" => $_GPC['mechat-user'], "pass" => $pass, "appid" => $_GPC['mechat-appid'], "appsecret" => $_GPC['mechat-appsecret']);
             $access_token = array("token" => "", "expire" => "");
             pdo_insert($this->tablename, array("weid" => $_W['weid'], "name" => $_GPC['mechat-user'], "cdata" => iserializer($mechat), "access_token" => $access_token, "createtime" => TIMESTAMP));
         }
         //exit(json_encode($_W));
         $dat = array("unit" => $_GPC['mechat-user'], "password" => $pass, "wxAppid" => $_W['account']['key'], "wxAppsecret" => $_W['account']['secret']);
         $actoken = account_mechat_token(array("weid" => $_W['weid'], "access_token" => $access_token, "appid" => $_GPC['mechat-appid'], "appsecret" => $_GPC['mechat-appsecret']));
         $url = sprintf("http://open.mobilechat.im/cgi-bin/weixin/bind?access_token=%s", $actoken);
         $content = ihttp_post($url, $dat);
         $dat2 = $content['content'];
         $result = @json_decode($dat2, true);
         if ($result["errcode"] == "0") {
             message('恭喜,微信服务号与美洽企业帐号绑定成功!', create_url('index/module/display', array('name' => 'mechat')), 'success');
         } else {
             message("微信服务号与美洽企业帐号绑定错误. <br />参数: " . json_encode($dat) . "<br />错误代码为: {$result['errcode']} <br />错误信息为: {$result['errmsg']}");
         }
     }
     $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `weid`=:weid";
     $row = pdo_fetch($sql, array(':weid' => $_W['weid']));
     if ($row) {
         $mechat["name"] = $row["name"];
         $dat = iunserializer($row["cdata"]);
         $mechat["pass"] = $dat["pass"];
         $mechat["appid"] = $dat["appid"];
         $mechat["appsecret"] = $dat["appsecret"];
     }
     include $this->template('display');
 }
Beispiel #14
0
function db_table_serialize($db, $dbname)
{
    $tables = $db->fetchall('SHOW TABLES');
    if (empty($tables)) {
        return '';
    }
    $struct = array();
    foreach ($tables as $value) {
        $structs[] = db_table_schema($db, substr($value['Tables_in_' . $dbname], strpos($value['Tables_in_' . $dbname], '_') + 1));
    }
    return iserializer($structs);
}
Beispiel #15
0
 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'picture' => $_GPC['picture'], 'description' => $_GPC['description'], 'periodlottery' => intval($_GPC['periodlottery']), 'maxlottery' => intval($_GPC['maxlottery']), 'rule' => htmlspecialchars_decode($_GPC['rule']), 'hitcredit' => intval($_GPC['hitcredit']), 'misscredit' => intval($_GPC['misscredit']), 'background' => $_GPC['bg']);
     if (!empty($insert['background'])) {
         file_image_crop(IA_ROOT . '/resource/attachment/' . $insert['background'], IA_ROOT . '/resource/attachment/' . $insert['background'], 310, 190, 5);
     }
     if (empty($id)) {
         pdo_insert($this->tablename, $insert);
     } else {
         if (!empty($_GPC['picture'])) {
             file_delete($_GPC['picture-old']);
         } else {
             unset($insert['picture']);
         }
         pdo_update($this->tablename, $insert, array('id' => $id));
     }
     if (!empty($_GPC['award-title'])) {
         foreach ($_GPC['award-title'] as $index => $title) {
             if (empty($title)) {
                 continue;
             }
             $update = array('title' => $title, 'description' => $_GPC['award-description'][$index], 'probalilty' => $_GPC['award-probalilty'][$index], 'total' => $_GPC['award-total'][$index], 'activation_code' => '', 'activation_url' => '');
             if (empty($update['inkind']) && !empty($_GPC['award-activation-code'][$index])) {
                 $activationcode = explode("\n", $_GPC['award-activation-code'][$index]);
                 $update['activation_code'] = iserializer($activationcode);
                 $update['total'] = count($activationcode);
                 $update['activation_url'] = $_GPC['award-activation-url'][$index];
             }
             pdo_update('scratchcard_award', $update, array('id' => $index));
         }
     }
     //处理添加
     if (!empty($_GPC['award-title-new'])) {
         foreach ($_GPC['award-title-new'] as $index => $title) {
             if (empty($title)) {
                 continue;
             }
             $insert = array('rid' => $rid, 'title' => $title, 'description' => $_GPC['award-description-new'][$index], 'probalilty' => $_GPC['award-probalilty-new'][$index], 'inkind' => intval($_GPC['award-inkind-new'][$index]), 'total' => intval($_GPC['award-total-new'][$index]), 'activation_code' => '', 'activation_url' => '');
             if (empty($insert['inkind'])) {
                 $activationcode = explode("\n", $_GPC['award-activation-code-new'][$index]);
                 $insert['activation_code'] = iserializer($activationcode);
                 $insert['total'] = count($activationcode);
                 $insert['activation_url'] = $_GPC['award-activation-url-new'][$index];
             }
             pdo_insert('scratchcard_award', $insert);
         }
     }
 }
Beispiel #16
0
 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'picture' => $_GPC['picture'], 'description' => $_GPC['description'], 'periodlottery' => intval($_GPC['periodlottery']), 'maxlottery' => intval($_GPC['maxlottery']), 'rule' => htmlspecialchars_decode($_GPC['rule']), 'default_tips' => $_GPC['default_tips'], 'hitcredit' => intval($_GPC['hitcredit']), 'misscredit' => intval($_GPC['misscredit']), 'starttime' => strtotime($_GPC['time']['start']), 'endtime' => strtotime($_GPC['time']['end']));
     if (empty($id)) {
         pdo_insert($this->tablename, $insert);
     } else {
         if (!empty($_GPC['picture']) && $_GPC['picture'] != $_GPC['picture-old']) {
             load()->func('file');
             file_delete($_GPC['picture-old']);
         } else {
             unset($insert['picture']);
         }
         pdo_update($this->tablename, $insert, array('id' => $id));
     }
     if (!empty($_GPC['award-title'])) {
         foreach ($_GPC['award-title'] as $index => $title) {
             if (empty($title)) {
                 continue;
             }
             $update = array('title' => $title, 'description' => $_GPC['award-description'][$index], 'probalilty' => $_GPC['award-probalilty'][$index], 'total' => $_GPC['award-total'][$index], 'activation_code' => '', 'activation_url' => '');
             if (empty($update['inkind']) && !empty($_GPC['award-activation-code'][$index])) {
                 $activationcode = explode("\n", $_GPC['award-activation-code'][$index]);
                 $update['activation_code'] = iserializer($activationcode);
                 // $update['total'] = count($activationcode);
                 $update['activation_url'] = $_GPC['award-activation-url'][$index];
             }
             pdo_update('egg_award', $update, array('id' => $index));
         }
     }
     //处理添加
     if (!empty($_GPC['award-title-new'])) {
         foreach ($_GPC['award-title-new'] as $index => $title) {
             if (empty($title)) {
                 continue;
             }
             $insert = array('rid' => $rid, 'title' => $title, 'description' => $_GPC['award-description-new'][$index], 'probalilty' => $_GPC['award-probalilty-new'][$index], 'inkind' => intval($_GPC['award-inkind-new'][$index]), 'total' => intval($_GPC['award-total-new'][$index]), 'activation_code' => '', 'activation_url' => '');
             if (empty($insert['inkind'])) {
                 $activationcode = explode("\n", $_GPC['award-activation-code-new'][$index]);
                 $insert['activation_code'] = iserializer($activationcode);
                 // $insert['total'] = count($activationcode);
                 $insert['activation_url'] = $_GPC['award-activation-url-new'][$index];
             }
             pdo_insert('egg_award', $insert);
         }
     }
 }
Beispiel #17
0
 public function getAll()
 {
     global $_W;
     $path = IA_ROOT . "/addons/ewei_shop/data/perm";
     if (!is_dir($path)) {
         load()->func('file');
         @mkdirs($path);
     }
     $cachefile = $path . "/plugins";
     $plugins = iunserializer(@file_get_contents($cachefile));
     if (!is_array($plugins)) {
         $plugins = pdo_fetchall('select * from ' . tablename('ewei_shop_plugin') . ' order by displayorder asc');
         file_put_contents($cachefile, iserializer($plugins));
     }
     return $plugins;
 }
 private function post()
 {
     global $_W, $engine;
     if (!in_array($this->message['msgtype'], array('text', 'image'))) {
         return false;
     }
     $member = $this->getMember();
     $wall = pdo_fetch("SELECT * FROM " . tablename('wxwall_reply') . " WHERE rid = '{$member['rid']}' LIMIT 1");
     if (!empty($wall['timeout']) && $wall['timeout'] > 0 && TIMESTAMP - $member['lastupdate'] >= $wall['timeout']) {
         $this->endContext();
         return $this->respText('由于您长时间未操作,请重新进入微信墙!');
     }
     $this->refreshContext();
     if (empty($wall['quit_command']) && $this->message['content'] == '退出' || !empty($wall['quit_command']) && $this->message['content'] == $wall['quit_command']) {
         $this->endContext();
         return $this->respText($wall['quit_tips']);
     }
     if (empty($member['nickname'])) {
         return $this->respText('发表话题前请<a target="_blank" href="' . $this->createMobileUrl('register') . '">登记</a>您的信息。');
     }
     $data = array('rid' => $member['rid'], 'from_user' => $this->message['from'], 'type' => $this->message['type'], 'createtime' => TIMESTAMP);
     if (empty($wall['isshow']) && empty($member['isblacklist'])) {
         $data['isshow'] = 1;
     } else {
         $data['isshow'] = 0;
     }
     if ($this->message['type'] == 'text') {
         $data['content'] = $this->message['content'];
     }
     if ($this->message['type'] == 'image') {
         $image = ihttp_request($this->message['picurl']);
         $filename = 'wxwall/' . $member['rid'] . '/' . random(30) . '.jpg';
         file_write($filename, $image['content']);
         $data['content'] = $filename;
     }
     if ($this->message['type'] == 'link') {
         $data['content'] = iserializer(array('title' => $this->message['title'], 'description' => $this->message['description'], 'link' => $this->message['link']));
     }
     pdo_insert('wxwall_message', $data);
     pdo_update('wxwall_members', array('lastupdate' => TIMESTAMP), array('from_user' => $this->message['from']));
     $content = $wall['send_tips'];
     if (!empty($member['isblacklist'])) {
         $content .= '你已被列入黑名单,发送的消息需要管理员审核!';
     }
     return $this->respText($content);
 }
Beispiel #19
0
 public function receive()
 {
     global $_W;
     $cfg = $this->module['config'];
     if (!is_array($cfg) || empty($cfg)) {
         $cfg = array();
         $cfg['msg_maxday'] = 0;
         $cfg['msg_history'] = 1;
         $cfg['use_ratio'] = 1;
     }
     if (!empty($cfg['msg_maxday']) && $cfg['msg_maxday'] > 0) {
         pdo_delete('stat_msg_history', " createtime < " . TIMESTAMP . ' - ' . $cfg['msg_maxday'] * 86400);
     }
     if ($cfg['msg_history']) {
         switch ($this->message['type']) {
             case 'image':
                 $content = $this->message['picurl'];
                 break;
             case 'location':
                 $content = iserializer(array('x' => $this->message['location_x'], 'y' => $this->message['location_y']));
                 break;
             case 'link':
                 $content = iserializer(array('title' => $this->message['title'], 'description' => $this->message['description'], 'link' => $this->message['link']));
                 break;
             case 'event':
                 $content = iserializer(array('event' => $this->message['event'], 'key' => $this->message['eventkey']));
                 break;
             default:
                 $content = $this->message['content'];
         }
         pdo_insert('stat_msg_history', array('weid' => $_W['weid'], 'module' => $this->params['module'], 'from_user' => $this->message['from'], 'rid' => intval($this->params['rule']), 'kid' => $this->keyword['id'], 'message' => $content, 'type' => $this->message['msgtype'], 'createtime' => $this->message['time']));
     }
     if (!empty($cfg['use_ratio'])) {
         $updateid = pdo_query("UPDATE " . tablename('stat_rule') . " SET hit = hit + 1, lastupdate = '" . TIMESTAMP . "' WHERE rid = :rid AND createtime = :createtime", array(':rid' => $this->params['rule'], ':createtime' => strtotime(date('Y-m-d'))));
         if (empty($updateid)) {
             pdo_insert('stat_rule', array('weid' => $_W['weid'], 'rid' => $this->params['rule'], 'createtime' => strtotime(date('Y-m-d')), 'hit' => 1, 'lastupdate' => $this->message['time']));
         }
         if (!empty($this->keyword['id'])) {
             $updateid = pdo_query("UPDATE " . tablename('stat_keyword') . " SET hit = hit + 1, lastupdate = '" . TIMESTAMP . "' WHERE kid = :kid AND createtime = :createtime", array(':kid' => $this->keyword['id'], ':createtime' => strtotime(date('Y-m-d'))));
             if (empty($updateid)) {
                 pdo_insert('stat_keyword', array('weid' => $_W['weid'], 'rid' => $this->params['rule'], 'kid' => $this->keyword['id'], 'createtime' => strtotime(date('Y-m-d')), 'hit' => 1, 'lastupdate' => $this->message['time']));
             }
         }
     }
 }
Beispiel #20
0
 public function doWebFinancialCenter()
 {
     global $_W, $_GPC;
     //这个操作被定义用来呈现 管理中心导航菜单
     if ($_W['ispost'] && $_W['isajax']) {
         $setting = uni_setting($_W['uniacid'], array('groupdata'));
         $setting["groupdata"]["is_auto"] = $_GPC["is_auto"];
         pdo_update("uni_settings", array("groupdata" => iserializer($setting["groupdata"])), array("uniacid" => $_W['uniacid']));
         die(json_encode(array("code" => 1, "message" => "操作成功.")));
     }
     $settings = get_settings();
     $service = explode("|", $settings["service_qqs"]);
     $qqs = array();
     foreach ($service as $ser) {
         list($name, $qq) = explode("-", $ser);
         $qqs[] = array("name" => $name, "qq" => $qq);
     }
     include $this->template('financial_center');
 }
Beispiel #21
0
 public function fieldsFormSubmit($rid)
 {
     //规则验证无误保存入库时执行,这里应该进行自定义字段的保存。这里 $rid 为对应的规则编号
     global $_W, $_GPC;
     //print_r($_GPC);exit();
     $id = intval($_GPC['reply_id']);
     $p1_key = 'p1_' . $_GPC['p1_type'];
     $p2_key = 'p2_' . $_GPC['p2_type'];
     $p3_key = 'p3_' . $_GPC['p3_type'];
     $p4_key = 'p4_' . $_GPC['p4_type'];
     $data = array('p1_type' => $_GPC['p1_type'], 'p1_score' => intval($_GPC[$p1_key]), 'p1_num' => intval($_GPC['p1_num']), 'p1_thumb' => $_GPC['p1_thumb'], 'p2_type' => $_GPC['p2_type'], 'p2_score' => intval($_GPC[$p2_key]), 'p2_num' => intval($_GPC['p2_num']), 'p2_thumb' => $_GPC['p2_thumb'], 'p3_type' => $_GPC['p3_type'], 'p3_score' => intval($_GPC[$p3_key]), 'p3_num' => intval($_GPC['p3_num']), 'p3_thumb' => $_GPC['p3_thumb'], 'p4_type' => $_GPC['p4_type'], 'p4_score' => intval($_GPC[$p4_key]), 'p4_num' => intval($_GPC['p4_num']), 'p4_thumb' => $_GPC['p4_thumb']);
     $insert = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'thumb' => $_GPC['thumb'], 'description' => $_GPC['description'], 'groupid' => intval($_GPC['groupid']), 'starttime' => strtotime($_GPC['time'][start]), 'endtime' => strtotime($_GPC['time'][end]), 'status' => intval($_GPC['status']), 'reg' => intval($_GPC['reg']), 'need_type' => $_GPC['need_type'], 'need_num' => intval($_GPC['need_num']), 'give_type' => $_GPC['give_type'], 'give_num' => intval($_GPC['give_num']), 'onlynone' => intval($_GPC['onlynone']), 'awardnum' => intval($_GPC['awardnum']), 'playnum' => intval($_GPC['playnum']), 'dayplaynum' => intval($_GPC['dayplaynum']), 'zfcs' => intval($_GPC['zfcs']), 'zjcs' => intval($_GPC['zjcs']), 'tips' => $_GPC['tips'], 'prizeinfo' => $_GPC['prizeinfo'], 'remark' => $_GPC['remark'], 'share_title' => $_GPC['share_title'], 'share_img' => $_GPC['share_img'], 'share_url' => $_GPC['share_url'], 'share_content' => $_GPC['share_content'], 'rate' => intval($_GPC['rate']), 'prizes' => iserializer($data), 'createtime' => time());
     if (empty($id)) {
         pdo_insert($this->table_reply, $insert);
     } else {
         unset($insert['createtime']);
         pdo_update($this->table_reply, $insert, array('id' => $id));
     }
 }
Beispiel #22
0
 private function getWxAccessToken()
 {
     $rep = pdo_fetch("SELECT `acid`,`access_token` FROM " . tablename("account_wechats") . " WHERE `key`=:key AND `secret`=:secret", array(":key" => $this->appId, ":secret" => $this->appSecret));
     $access_token = iunserializer($rep["access_token"]);
     if (empty($access_token) || $access_token["expire"] <= time()) {
         $appId = $this->appId;
         $secret = $this->appSecret;
         $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appId}&secret={$secret}";
         $content = ihttp_get($url);
         if (!empty($content)) {
             $token = @json_decode($content['content'], true);
             if (!empty($token) && is_array($token) && !empty($token['access_token']) && !empty($token['expires_in'])) {
                 $record = array("token" => $token['access_token'], "expire" => TIMESTAMP + $token['expires_in']);
                 pdo_update('account_wechats', array("access_token" => iserializer($record)), array('acid' => $rep['acid']));
                 return $token['access_token'];
             }
         }
     }
     return $access_token;
 }
/**
 * 通过ProjGUID从erp中导入数据
 * 序列化存储产品、房型数据
 * @param $guid
 * @return bool
 */
function importErp_Project($guid)
{
    $state = false;
    $project = erp_getProject($guid);
    $housetype = erp_getBuildHuXing($guid);
    $product = erp_getBuildProduct($guid);
    $data = array('projguid' => $project['ProjGUID'], 'projname' => $project['ProjShortName'], 'ProjCode' => $project['ProjCode'], 'ParentCode' => $project['ParentCode'], 'Level' => $project['Level'], 'BUGUID' => $project['BUGUID'], 'product' => iserializer($product), 'housetype' => iserializer($housetype), 'createtime' => TIMESTAMP, 'changetime' => TIMESTAMP, 'status' => 9);
    //状态为关闭
    if (!empty($data['ParentCode'])) {
        $p = erp_getProjectByCode($data['ParentCode']);
        if (!empty($p)) {
            $data['ParentGUID'] = $p['ProjGUID'];
            unset($p);
        }
    }
    if (is_array($project)) {
        $state = pdo_insert('project', $data, true);
    }
    return $state;
}
Beispiel #24
0
 public function updateSet($data = array())
 {
     global $_W;
     $uniacid = $_W['uniacid'];
     $set = m('common')->getSetData();
     if (empty($set)) {
         pdo_insert('ewei_shop_sysset', array('uniacid' => $uniacid, 'sets' => iserializer(array()), 'plugins' => iserializer(array($this->pluginname => $data))));
     } else {
         $sets = unserialize($set['plugins']);
         $sets[$this->pluginname] = $data;
         pdo_update('ewei_shop_sysset', array('plugins' => iserializer($sets)), array('uniacid' => $uniacid));
     }
     $set = pdo_fetch("select * from " . tablename('ewei_shop_sysset') . ' where uniacid=:uniacid limit 1', array(':uniacid' => $uniacid));
     $path = IA_ROOT . "/addons/ewei_shop/data/sysset";
     $cachefile = $path . "/sysset_" . $uniacid;
     if (!is_dir($path)) {
         load()->func('file');
         @mkdirs($path);
     }
     file_put_contents($cachefile, iserializer($set));
 }
Beispiel #25
0
function setting_save($data = '', $key = '')
{
    if (empty($data) && empty($key)) {
        return FALSE;
    }
    if (is_array($data) && empty($key)) {
        foreach ($data as $key => $value) {
            $record[] = "('{$key}', '" . iserializer($value) . "')";
        }
        if ($record) {
            $return = pdo_query("REPLACE INTO " . tablename('core_settings') . " (`key`, `value`) VALUES " . implode(',', $record));
        }
    } else {
        $record = array();
        $record['key'] = $key;
        $record['value'] = iserializer($data);
        $return = pdo_insert('core_settings', $record, TRUE);
    }
    cache_build_setting();
    return $return;
}
Beispiel #26
0
 public function fieldsFormSubmit($rid)
 {
     //规则验证无误保存入库时执行,这里应该进行自定义字段的保存。这里 $rid 为对应的规则编号
     global $_W, $_GPC;
     $id = intval($_GPC['reply_id']);
     $i = 1;
     foreach ($_GPC['prizename'] as $index => $row) {
         if (empty($row)) {
             continue;
         }
         $data[$i] = array('id' => $index + 1, 'prizename' => $_GPC['prizename'][$index], 'neednum' => $_GPC['neednum'][$index], 'prizenum' => $_GPC['prizenum'][$index], 'prizesy' => $_GPC['prizesy'][$index]);
         $i++;
     }
     $insert = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'title' => $_GPC['title'], 'thumb' => $_GPC['thumb'], 'description' => $_GPC['description'], 'starttime' => strtotime($_GPC['time'][start]), 'endtime' => strtotime($_GPC['time'][end]), 'status' => intval($_GPC['status']), 'topimg' => $_GPC['topimg'], 'bgcolor' => $_GPC['bgcolor'], 'pagestyle' => htmlspecialchars_decode($_GPC['pagestyle']), 'address' => htmlspecialchars_decode($_GPC['address']), 'tips' => $_GPC['tips'], 'linkurl' => $_GPC['linkurl'], 'adimg' => $_GPC['adimg'], 'tel' => $_GPC['tel'], 'copyright' => $_GPC['copyright'], 'prizes' => iserializer($data), 'createtime' => TIMESTAMP);
     if (empty($id)) {
         pdo_insert($this->table_reply, $insert);
     } else {
         unset($insert['createtime']);
         pdo_update($this->table_reply, $insert, array('id' => $id));
     }
 }
Beispiel #27
0
 public function receive()
 {
     global $_W;
     //这里定义此模块进行消息订阅时的, 消息到达以后的具体处理过程, 请查看微赞文档来编写你的代码
     $stat_setting = uni_setting($_W['uniacid'], 'stat');
     $stat_setting = $stat_setting['stat'];
     if (!is_array($stat_setting) || empty($stat_setting)) {
         $stat_setting = array();
         $stat_setting['msg_maxday'] = 0;
         $stat_setting['msg_history'] = 1;
         $stat_setting['use_ratio'] = 1;
     }
     if (!empty($stat_setting['msg_maxday']) && $stat_setting['msg_maxday'] > 0) {
         pdo_delete('stat_msg_history', " createtime < " . TIMESTAMP . ' - ' . $stat_setting['msg_maxday'] * 86400);
     }
     if ($stat_setting['msg_history']) {
         switch ($this->message['type']) {
             case 'text':
                 $content = iserializer(array('content' => $this->message['content'], 'redirection' => $this->message['redirection'], 'source' => $this->message['source']));
                 break;
             default:
                 $content = $this->message['content'];
         }
         pdo_insert('stat_msg_history', array('uniacid' => $_W['uniacid'], 'module' => $this->params['module'], 'from_user' => $this->message['from'], 'rid' => intval($this->params['rule']), 'kid' => $this->keyword['id'], 'message' => $content, 'type' => $this->message['type'], 'createtime' => $this->message['time']));
     }
     if (!empty($stat_setting['use_ratio'])) {
         $updateid = pdo_query("UPDATE " . tablename('stat_rule') . " SET hit = hit + 1, lastupdate = '" . TIMESTAMP . "' WHERE rid = :rid AND createtime = :createtime", array(':rid' => $this->params['rule'], ':createtime' => strtotime(date('Y-m-d'))));
         if (empty($updateid)) {
             pdo_insert('stat_rule', array('uniacid' => $_W['uniacid'], 'rid' => $this->params['rule'], 'createtime' => strtotime(date('Y-m-d')), 'hit' => 1, 'lastupdate' => $this->message['time']));
         }
         if (!empty($this->keyword['id'])) {
             $updateid = pdo_query("UPDATE " . tablename('stat_keyword') . " SET hit = hit + 1, lastupdate = '" . TIMESTAMP . "' WHERE kid = :kid AND createtime = :createtime", array(':kid' => $this->keyword['id'], ':createtime' => strtotime(date('Y-m-d'))));
             if (empty($updateid)) {
                 pdo_insert('stat_keyword', array('uniacid' => $_W['uniacid'], 'rid' => $this->params['rule'], 'kid' => $this->keyword['id'], 'createtime' => strtotime(date('Y-m-d')), 'hit' => 1, 'lastupdate' => $this->message['time']));
             }
         }
     }
 }
Beispiel #28
0
 public function getSetData($uniacid = 0)
 {
     global $_W;
     if (empty($uniacid)) {
         $uniacid = $_W['uniacid'];
     }
     $path = IA_ROOT . "/addons/ewei_shop/data/sysset";
     $cachefile = $path . "/sysset_" . $uniacid;
     if (is_file($cachefile)) {
         $set = iunserializer(file_get_contents($cachefile));
     } else {
         $set = pdo_fetch("select * from " . tablename('ewei_shop_sysset') . ' where uniacid=:uniacid limit 1', array(':uniacid' => $uniacid));
         if (empty($set)) {
             $set = array();
         }
         if (!is_dir($path)) {
             load()->func('file');
             @mkdirs($path);
         }
         file_put_contents($cachefile, iserializer($set));
     }
     return $set;
 }
Beispiel #29
0
 public function doCard()
 {
     global $_GPC, $_W;
     $setting = pdo_fetch("SELECT * FROM " . tablename('card') . " WHERE weid = '{$_W['weid']}'");
     if (!empty($setting)) {
         $setting['color'] = iunserializer($setting['color']);
         $setting['background'] = iunserializer($setting['background']);
         $setting['fields'] = iunserializer($setting['fields']);
     }
     if (checksubmit('submit')) {
         if (empty($_GPC['title'])) {
             message('请输入会员卡名称!');
         }
         if (empty($_GPC['format'])) {
             message('请输入会员卡的卡号生成格式!');
         }
         $data = array('title' => $_GPC['title'], 'color' => iserializer(array('title' => $_GPC['color-title'], 'number' => $_GPC['color-number'])), 'background' => iserializer(array('background' => $_GPC['background'], 'image' => $_GPC[$_GPC['background'] . '-bg'])), 'logo' => $_GPC['logo'], 'format' => $_GPC['format']);
         if (!empty($_GPC['fields'])) {
             foreach ($_GPC['fields']['title'] as $index => $row) {
                 if (empty($_GPC['fields']['title'])) {
                     continue;
                 }
                 $data['fields'][] = array('title' => $_GPC['fields']['title'][$index], 'require' => intval($_GPC['fields']['require'][$index]), 'bind' => $_GPC['fields']['bind'][$index]);
             }
             $data['fields'] = iserializer($data['fields']);
         }
         if (!empty($setting)) {
             pdo_update('card', $data, array('weid' => $_W['weid']));
         } else {
             $data['weid'] = $_W['weid'];
             pdo_insert('card', $data);
         }
         message('会员卡设置成功!', referer(), 'success');
     }
     $fields = fans_fields();
     include $this->template('card');
 }
Beispiel #30
0
     $fan['uid'] = $uid;
     $fan['openid'] = $auth['openid'];
     $fan['salt'] = random(8);
     $fan['follow'] = 0;
     $fan['followtime'] = 0;
     pdo_insert('mc_mapping_fans', $fan);
 }
 if ($scope == 'userinfo') {
     $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$auth['access_token']}&openid={$auth['openid']}&lang=zh_CN";
     $response = ihttp_get($url);
     if (!is_error($response)) {
         $userinfo = json_decode($response['content'], true);
         $userinfo['nickname'] = stripcslashes($userinfo['nickname']);
         $record['updatetime'] = TIMESTAMP;
         $record['nickname'] = stripslashes($userinfo['nickname']);
         $record['tag'] = base64_encode(iserializer($userinfo));
         pdo_update('mc_mapping_fans', $record, array('openid' => $auth['openid']));
         if (!empty($fan['uid'])) {
             $user = mc_fetch($fan['uid'], array('nickname', 'gender', 'residecity', 'resideprovince', 'nationality', 'avatar'));
             $rec = array();
             if (empty($user['nickname']) && !empty($userinfo['nickname'])) {
                 $rec['nickname'] = stripslashes($userinfo['nickname']);
             }
             if (empty($user['gender']) && !empty($userinfo['sex'])) {
                 $rec['gender'] = $userinfo['sex'];
             }
             if (empty($user['residecity']) && !empty($userinfo['city'])) {
                 $rec['residecity'] = $userinfo['city'] . '市';
             }
             if (empty($user['resideprovince']) && !empty($userinfo['province'])) {
                 $rec['resideprovince'] = $userinfo['province'] . '省';