Example #1
0
 public function receive()
 {
     global $_W;
     $type = $this->message['type'];
     //这里定义此模块进行消息订阅时的, 消息到达以后的具体处理过程, 请查看WORMWOOD文档来编写你的代码
     if ($type != "text" && $type != "image" && $type != "voice") {
         return;
     }
     $file = IA_ROOT . '/source/modules/mechat/function.php';
     if (!file_exists($file)) {
         return array();
     }
     include_once $file;
     $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `weid`=:weid";
     $row = pdo_fetch($sql, array(':weid' => $_W['weid']));
     if ($row) {
         $pdata = array("ToUserName" => $this->message['tousername'], "FromUserName" => $this->message['fromusername'], "CreateTime" => $this->message['createtime'], "MsgType" => $this->message['msgtype'], "Content" => $this->message['content'], "MsgId" => $this->message['msgid']);
         if ($type == "voice") {
             $pdata["MsgType"] = "text";
             $pdata["Content"] = "系统:微信公众号粉丝发送语音消息,系统暂不能接收请客服处理。";
         }
         $dat = array('unit' => $row["name"], 'msg' => json_encode($pdata));
         $dat2 = iunserializer($row["cdata"]);
         $actoken = account_mechat_token(array("weid" => $_W['weid'], "access_token" => $dat2["access_token"], "appid" => $dat2["appid"], "appsecret" => $dat2["appsecret"]));
         $url = sprintf($this->gateway['mechat_receive'], $actoken);
         $content = ihttp_post($url, $dat);
     }
 }
Example #2
0
 public function respond()
 {
     global $_W;
     $content = $this->message['content'];
     $reply = pdo_fetch('SELECT * FROM ' . tablename('cover_reply') . ' WHERE `rid`=:rid', array(':rid' => $this->rule));
     if (!empty($reply)) {
         load()->model('module');
         $module = module_fetch($reply['module']);
         if (empty($module) && !in_array($reply['module'], array('site', 'mc', 'card'))) {
             return '';
         }
         $url = $reply['url'];
         if (empty($reply['url'])) {
             $entry = pdo_fetch("SELECT eid FROM " . tablename('modules_bindings') . " WHERE module = :module AND do = :do", array(':module' => $reply['module'], ':do' => $reply['do']));
             $url = url('entry', array('eid' => $entry['eid']));
         }
         if (!strexists($url, '&j=') && !empty($_W['acid'])) {
             $url = str_replace("?i={$_W['uniacid']}&", "?i={$_W['uniacid']}&j={$_W['acid']}&", $url);
         }
         $news = array();
         $news[] = array('title' => $reply['title'], 'description' => $reply['description'], 'picurl' => $reply['thumb'], 'url' => $url);
         return $this->respNews($news);
     }
     return '';
 }
Example #3
0
 public function respond()
 {
     global $_W;
     $content = $this->message['content'];
     $foods = pdo_fetchall("SELECT * FROM " . tablename('jufeng_wcy_foods') . " WHERE weid = '{$_W['uniacid']}' AND title LIKE '%{$content}%' ");
     $pcate = pdo_fetchall("SELECT * FROM " . tablename('jufeng_wcy_category') . " WHERE weid = '{$_W['uniacid']}' AND parentid = '0' AND name LIKE '%{$content}%' ");
     $news[] = array('title' => '在线订餐', 'description' => '方便快捷,价格优惠', 'picurl' => '../addons/jufeng_wcy/images/dc.jpg', 'url' => $this->createMobileUrl('dianjia'));
     $foodsnum = count($foods);
     $pcatenum = count($pcate);
     if ($foodsnum == 0 && $pcatenum == 0) {
         $news[] = array('title' => '直接回复你想吃的,可搜索菜品和餐馆哦');
         $news[] = array('title' => '没有关于【' . $content . '】的菜品或餐馆');
     }
     if ($pcatenum < 9) {
         $printnum = $pcatenum;
     } else {
         $printnum = 9;
     }
     for ($i = 0; $i < $printnum; $i++) {
         $news[] = array('title' => "【" . $pcate[$i]['name'] . "】——" . "热度:" . $pcate[$i]['total'], 'description' => "", 'picurl' => $_W['attachurl'] . $pcate[$i]['thumb'], 'url' => $this->createMobileUrl('list', array('pcate' => $pcate[$i]['id'])));
     }
     $printnum = 9 - $printnum;
     if ($foodsnum < $printnum) {
         $printnum = $foodsnum;
     }
     for ($i = 0; $i < $printnum; $i++) {
         $dianjia = pdo_fetch("SELECT * FROM " . tablename('jufeng_wcy_category') . " WHERE weid = '{$_W['uniacid']}' AND id = '{$foods[$i]['pcate']}'");
         $news[] = array('title' => "【" . $foods[$i]['title'] . "】——" . $dianjia['name'], 'description' => "菜品热度:" . $foods[$i]['hits'], 'picurl' => $_W['attachurl'] . $foods[$i]['thumb'], 'url' => $this->createMobileUrl('list', array('pcate' => $foods[$i]['pcate'])));
     }
     return $this->respNews($news);
 }
Example #4
0
 public function fieldsFormDisplay($rid = 0)
 {
     //要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0
     global $_W;
     $reply = pdo_fetch("SELECT * FROM " . tablename('game2048_reply') . " WHERE rid = :rid", array(':rid' => $rid));
     include $this->template('form');
 }
Example #5
0
function site_category($params = array())
{
    global $_GPC, $_W;
    extract($params);
    if (!isset($parentid)) {
        $condition = "";
    } else {
        $condition = " AND parentid = '{$parentid}'";
    }
    $category = array();
    $result = pdo_fetchall("SELECT * FROM " . tablename('article_category') . " WHERE weid = '{$_W['weid']}' {$condition} ORDER BY parentid ASC, displayorder ASC, id ASC ");
    if (!isset($parentid)) {
        if (!empty($result)) {
            foreach ($result as $row) {
                if (empty($row['parentid'])) {
                    $category[$row['id']] = $row;
                } else {
                    $category[$row['parentid']]['children'][$row['id']] = $row;
                }
            }
        }
    } else {
        $category = $result;
    }
    return $category;
}
Example #6
0
	public function respond() {
		global $_W;
		$rid = $this->rule;
		$sql = "SELECT id FROM " . tablename('news_reply') . " WHERE `rid`=:rid AND parentid = 0 ORDER BY RAND()";
		$main = pdo_fetch($sql, array(':rid' => $rid));
		if (empty($main['id'])) {
			return array();
		}
		$sql = "SELECT * FROM " . tablename('news_reply') . " WHERE id = :id OR parentid = :parentid ORDER BY parentid ASC, id ASC LIMIT 8";
		$commends = pdo_fetchall($sql, array(':id'=>$main['id'], ':parentid'=>$main['id']));
		$news = array();
		foreach($commends as $c) {
			$row = array();
			$row['title'] = $c['title'];
			$row['description'] = $c['description'];
			!empty($c['thumb']) && $row['picurl'] = $_W['attachurl'] . trim($c['thumb'], '/');
			$row['url'] = empty($c['url']) ? $_W['siteroot'] . create_url('index/module', array('do' => 'detail', 'name' => 'news', 'id' => $c['id'])) : $c['url'];
			$news[] = $row;
		}
		$r['FromUserName'] = $this->message['to'];
		$r['ToUserName'] = $this->message['from'];
		$r['MsgType'] = 'news';
		$r['ArticleCount'] = count($news);
		$r['Articles'] = array();
		foreach ($news as $row) {
			$r['Articles'][] = array(
				'Title' => $row['title'],
				'Description' => $row['description'],
				'PicUrl' => $row['picurl'],
				'Url' => $row['url'],
				'TagName' => 'item',
			);
		}
		return $r;
	}
Example #7
0
function site_article($params = array())
{
    global $_GPC, $_W;
    extract($params);
    $pindex = max(1, intval($_GPC['page']));
    $psize = 20;
    $result = array();
    $condition = " WHERE weid = '{$_W['weid']}'";
    if (!empty($cid)) {
        $category = pdo_fetch("SELECT parentid FROM " . tablename('category') . " WHERE id = '{$cid}'");
        if (!empty($category['parentid'])) {
            $condition .= " AND ccate = '{$cid}'";
        } else {
            $condition .= " AND pcate = '{$cid}'";
        }
    }
    if ($iscommend == 'true') {
        $condition .= " AND iscommend = '1'";
    }
    if ($ishot == 'true') {
        $condition .= " AND ishot = '1'";
    }
    $sql = "SELECT * FROM " . tablename('article') . $condition . ' ORDER BY displayorder DESC, id DESC';
    $result['list'] = pdo_fetchall($sql . " LIMIT " . ($pindex - 1) * $psize . ',' . $psize);
    $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('article') . $condition);
    $result['pager'] = pagination($total, $pindex, $psize);
    if (!empty($result['list'])) {
        foreach ($result['list'] as &$row) {
            $row['url'] = create_url('mobile/module/hdetail', array('name' => 'shouse', 'id' => $row['id'], 'weid' => $_W['weid']));
        }
    }
    return $result;
}
Example #8
0
    private function getMember()
    {
        global $_W;
        $sql = 'SELECT `lastupdate`, `isblacklist`, `rid` FROM ' . tablename('wxwall_members') . ' WHERE `from_user` =
				:from_user AND `rid` = :rid';
        $params = array(':from_user' => $_W['openid'], ':rid' => $this->rule);
        $member = pdo_fetch($sql, $params);
        // 获取粉丝头像
        $account = WeAccount::create($_W['acid']);
        $fansInfo = $account->fansQueryInfo($_W['openid']);
        if (empty($member)) {
            $member = array('from_user' => $_W['openid'], 'rid' => $this->rule, 'isjoin' => 1, 'lastupdate' => TIMESTAMP, 'isblacklist' => 0);
            if (!is_error($fansInfo)) {
                $member['avatar'] = rtrim($fansInfo['headimgurl'], '0') . '132';
            }
            pdo_insert('wxwall_members', $member);
        } else {
            if (!is_error($fansInfo)) {
                $member['avatar'] = rtrim($fansInfo['headimgurl'], '0') . '132';
            }
            $member['lastupdate'] = TIMESTAMP;
            $params = array('from_user' => $_W['openid'], 'rid' => $this->rule);
            pdo_update('wxwall_members', $member, $params);
        }
        return $member;
    }
 public function respond()
 {
     global $_W;
     $content = $this->message['content'];
     //这里定义此模块进行消息处理时的具体过程, 请查看WORMWOOD文档来编写你的代码
     $isfill = pdo_fetchcolumn("SELECT isfill FROM " . tablename('feng_testingreply') . " WHERE rid =:rid AND testingid = '0'", array(':rid' => $this->rule));
     $reply = pdo_fetchall("SELECT * FROM " . tablename('feng_testingreply') . " WHERE rid = :rid", array(':rid' => $this->rule));
     if (!empty($reply)) {
         foreach ($reply as $row) {
             $ids[$row['testingid']] = $row['testingid'];
         }
         $article = pdo_fetchall("SELECT id,title,photo,smalltext FROM " . tablename('feng_testing') . " WHERE id IN (" . implode(',', $ids) . ")", array(), 'id');
     }
     if ($isfill && ($count = 8 - count($reply)) > 0) {
         $articlefill = pdo_fetchall("SELECT id,title,photo,smalltext FROM " . tablename('feng_testing') . " WHERE weid = '{$_W['weid']}' AND id NOT IN (" . implode(',', $ids) . ") ORDER BY id DESC LIMIT {$count}", array(), 'id');
         if (!empty($articlefill)) {
             foreach ($articlefill as $row) {
                 $article[$row['id']] = $row;
                 $reply[]['testingid'] = $row['id'];
             }
             unset($articlefill);
         }
     }
     if (!empty($reply)) {
         $response = array();
         foreach ($reply as $row) {
             $row = $article[$row['testingid']];
             if (!empty($row)) {
                 $response[] = array('title' => $row['title'], 'description' => $row['description'], 'picurl' => $row['thumb'], 'url' => $this->buildSiteUrl($this->createMobileUrl('detail', array('id' => $row['id']))));
             }
         }
     }
     return $this->respNews($response);
 }
Example #10
0
function __buildSiteUrl($url)
{
    global $_W, $engine;
    $mapping = array('[from]' => $engine->message['from'], '[to]' => $engine->message['to'], '[uniacid]' => $_W['uniacid']);
    $url = str_replace(array_keys($mapping), array_values($mapping), $url);
    $pass = array();
    $pass['openid'] = $engine->message['from'];
    $pass['acid'] = $_W['acid'];
    $sql = 'SELECT `fanid`,`salt`,`uid` FROM ' . tablename('mc_mapping_fans') . ' WHERE `acid`=:acid AND `openid`=:openid';
    $params = array();
    $params[':acid'] = $_W['acid'];
    $params[':openid'] = $pass['openid'];
    $fan = pdo_fetch($sql, $params);
    if (empty($fan) || !is_array($fan) || empty($fan['salt'])) {
        $fan = array('salt' => '');
    }
    $pass['time'] = TIMESTAMP;
    $pass['hash'] = md5("{$pass['openid']}{$pass['time']}{$fan['salt']}{$_W['config']['setting']['authkey']}");
    $auth = base64_encode(json_encode($pass));
    $vars = array();
    $vars['uniacid'] = $_W['uniacid'];
    $vars['__auth'] = $auth;
    $vars['forward'] = base64_encode($url);
    return $_W['siteroot'] . 'app/' . url('auth/forward', $vars);
}
Example #11
0
 public function fieldsFormSubmit($rid)
 {
     //规则验证无误保存入库时执行,这里应该进行自定义字段的保存。这里 $rid 为对应的规则编号
     global $_GPC, $_W;
     $currentprompt = trim($_GPC['currentprompt']) ? trim($_GPC['currentprompt']) : '当前数字是 {LUCKYNUM}!';
     $awardprompt = trim($_GPC['awardprompt']) ? trim($_GPC['awardprompt']) : '恭喜您,当前数字是 {LUCKYNUM},获得 {AWARD} 奖品!';
     $data = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'luckynumstart' => $_GPC['luckynumstart'], 'luckynumfilter' => $_GPC['luckynumfilter'], 'show_instruction' => $_GPC['show_instruction'], 'time_instruction' => $_GPC['time_instruction'], 'limit_instruction' => $_GPC['limit_instruction'], 'end_instruction' => $_GPC['end_instruction'], 'awardnum_instruction' => $_GPC['awardnum_instruction'], 'award_instruction' => $_GPC['award_instruction'], 'starttime' => strtotime($_GPC['datelimit']['start']), 'endtime' => strtotime($_GPC['datelimit']['end']), 'limittype' => $_GPC['limittype'], 'awardnum' => $_GPC['awardnum'], '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'], 'currentprompt' => $currentprompt, 'awardprompt' => $awardprompt, 'sponsors1' => $_GPC['sponsors1'], 'sponsors1link' => $_GPC['sponsors1link'], 'sponsors2' => $_GPC['sponsors2'], 'sponsors2link' => $_GPC['sponsors2link'], 'sponsors3' => $_GPC['sponsors3'], 'sponsors3link' => $_GPC['sponsors3link'], 'sponsors4' => $_GPC['sponsors4'], 'sponsors4link' => $_GPC['sponsors4link'], 'sponsors5' => $_GPC['sponsors5'], 'sponsors5link' => $_GPC['sponsors5link'], 'ruletext' => $_GPC['ruletext'], 'title' => $_GPC['title'], 'shareimg' => $_GPC['shareimg'], 'sharetitle' => $_GPC['sharetitle'], 'sharedesc' => $_GPC['sharedesc']);
     $id = pdo_fetchcolumn("SELECT id FROM " . tablename('stonefish_luckynum') . " WHERE rid = :rid", array(':rid' => $rid));
     //if ($_GPC['shouquan']==$_GPC['we7_ValidCode_server']){
     if (empty($id)) {
         $data['isshow'] = 1;
         pdo_insert('stonefish_luckynum', $data);
     } else {
         pdo_update('stonefish_luckynum', $data, array('id' => $id));
     }
     //}
     //update
     if (!empty($_GPC['award_number'])) {
         foreach ($_GPC['award_number'] as $key => $val) {
             $update_data = array('numbers' => $_GPC['award_number'][$key], 'title' => $_GPC['award_title'][$key], 'description' => $_GPC['award_desc'][$key]);
             //if ($_GPC['shouquan']==$_GPC['we7_ValidCode_server']){
             pdo_update($this->tablename, $update_data, array('id' => $key));
             //}
         }
     }
     //insert
     if (!empty($_GPC['newaward_number'])) {
         foreach ($_GPC['newaward_number'] as $key => $val) {
             $new_data = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'numbers' => $_GPC['newaward_number'][$key], 'title' => $_GPC['newaward_title'][$key], 'description' => $_GPC['newaward_desc'][$key], 'dateline' => $_W['timestamp']);
             //if ($_GPC['shouquan']==$_GPC['we7_ValidCode_server']){
             pdo_insert($this->tablename, $new_data);
             //}
         }
     }
 }
Example #12
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $sql = "SELECT title,description,start_picurl,isshow,starttime,endtime,end_theme,end_instruction,end_picurl FROM " . tablename('smashegg_reply') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     if ($row == false) {
         return array();
     }
     if ($row['isshow'] == 0) {
         return array();
     }
     if ($row['endtime'] < time()) {
         if (substr($row['end_picurl'], 0, 7) == "http://") {
             $picurl = $row['end_picurl'];
         } else {
             $picurl = $_W['siteroot'] . trim($row['end_picurl'], '/');
         }
         return $this->respNews(array('Title' => $row['end_theme'], 'Description' => $row['end_instruction'], 'PicUrl' => $picurl, 'Url' => $this->createMobileUrl('index', array('id' => $rid))));
     } else {
         if (substr($row['start_picurl'], 0, 7) == "http://") {
             $picurl = $row['start_picurl'];
         } else {
             $picurl = $_W['siteroot'] . trim($row['start_picurl'], '/');
         }
         return $this->respNews(array('Title' => $row['title'], 'Description' => $row['description'], 'PicUrl' => $picurl, 'Url' => $this->createMobileUrl('index', array('id' => $rid))));
     }
 }
Example #13
0
 private function reply_kaquanDetail($card_id)
 {
     $sql = "SELECT card_detail FROM " . tablename($this->tb_cards) . " WHERE card_id = :card_id";
     $param[':card_id'] = $card_id;
     $card_detail = pdo_fetch($sql, $param);
     return $card_detail['card_detail'];
 }
Example #14
0
 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'weid' => $this->weid, 'title' => $_GPC['title'], 'kptime' => strtotime($_GPC['kptime']), 'rztime' => strtotime($_GPC['rztime']), 'kfs' => $_GPC['kfs'], 'price' => $_GPC['price'], 'lpaddress' => $_GPC['lpaddress'], 'sltel' => $_GPC['sltel'], 'zxtel' => $_GPC['zxtel'], 'news_title' => $_GPC['news_title'], 'news_icon' => $_GPC['news_icon'], 'news_content' => $_GPC['news_content'], 'share_title' => $_GPC['share_title'], 'share_icon' => $_GPC['share_icon'], 'share_content' => $_GPC['share_content'], 'order_title' => $_GPC['order_title'], 'order_remark' => $_GPC['order_remark'], 'cover_img' => $_GPC['cover_img'], 'overview_img' => $_GPC['overview_img'], 'intro_img' => $_GPC['intro_img'], 'dt_img' => $_GPC['dt_img'], 'dt_intro' => htmlspecialchars_decode($_GPC['dt_intro']), 'intro' => htmlspecialchars_decode($_GPC['intro']), 'createtime' => TIMESTAMP);
     if (empty($id)) {
         $id = pdo_insert($this->table_hosue, $insert);
     } else {
         pdo_update($this->table_hosue, $insert, array('id' => $id));
     }
     ///说明项处理
     $house_ids = $_GPC['house_ids'];
     $house_names = $_GPC['house_iname'];
     $house_conents = $_GPC['house_icontent'];
     $house_sorts = $_GPC['house_sort'];
     pdo_query("delete from " . tablename($this->table_house_item) . " where hid=:hid", array(":hid" => $id));
     if (is_array($house_ids)) {
         foreach ($house_ids as $key => $value) {
             $value = intval($value);
             $d = array("rid" => $rid, "hid" => $id, "iname" => $house_names[$key], "icontent" => $house_conents[$key], "sort" => $house_sorts[$key]);
             pdo_insert($this->table_house_item, $d);
         }
     }
     return true;
 }
Example #15
0
 public function respond()
 {
     global $_W;
     load()->func('compat.biz');
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('bm_top_reply') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     if (empty($row['id'])) {
         return $this->respText("系统升级中,请稍候!");
     }
     $desc = $row['desc'];
     //描述
     $n = $row['n'];
     //粉丝基数
     $fromuser = $this->message['from'];
     $num = mc_fansinfo($fromuser);
     $numx = $n + $num['fanid'];
     $name = $_W['account']['name'];
     //公众号名称
     $str = str_replace('{name}', $name, $desc);
     $str = str_replace('{numx}', $numx, $str);
     if ($row['pictype'] == 1) {
         //$str = "嗨,欢迎关注【".$name."】,您是第".$numx."位关注人!\n".$desc."\n <a href='".$url."'>".$urltext."</a>";
         return $this->respText($str);
     } else {
         $response['FromUserName'] = $this->message['to'];
         $response['ToUserName'] = $this->message['from'];
         $response['MsgType'] = 'news';
         $response['ArticleCount'] = 1;
         $response['Articles'] = array();
         $response['Articles'][] = array('Title' => $row['title'], 'Description' => $str, 'PicUrl' => !strexists($row['picurl'], 'http://') ? $_W['attachurl'] . $row['picurl'] : $row['picurl'], 'Url' => $row['urlx'], 'TagName' => 'item');
         return $response;
     }
 }
Example #16
0
 public function getCategory()
 {
     global $_W;
     $shopset = m('common')->getSysset('shop');
     $allcategory = array();
     $category = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_category') . " WHERE uniacid=:uniacid and enabled=1 ORDER BY parentid ASC, displayorder DESC", array(':uniacid' => $_W['uniacid']));
     $category = set_medias($category, array('thumb', 'advimg'));
     foreach ($category as $c) {
         if (empty($c['parentid'])) {
             $children = array();
             foreach ($category as $c1) {
                 if ($c1['parentid'] == $c['id']) {
                     if (intval($shopset['catlevel']) == 3) {
                         $children2 = array();
                         foreach ($category as $c2) {
                             if ($c2['parentid'] == $c1['id']) {
                                 $children2[] = $c2;
                             }
                         }
                         $c1['children'] = $children2;
                     }
                     $children[] = $c1;
                 }
             }
             $c['children'] = $children;
             $allcategory[] = $c;
         }
     }
     return $allcategory;
 }
Example #17
0
 public function doMobileshow()
 {
     global $_W, $_GPC;
     $rid = $_GPC['id'];
     $sql = "SELECT * FROM " . tablename($this->tablename_log) . " WHERE `rid`=:rid";
     $info = pdo_fetchall($sql, array(':rid' => $rid));
     $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `rid`=:rid LIMIT 1";
     $quiz = pdo_fetch($sql, array(':rid' => $rid));
     $sql = "SELECT * FROM " . tablename($this->tablename_question) . " WHERE `id`=:id";
     $q = pdo_fetch($sql, array(':id' => $quiz['qid']));
     //var_dump($q);
     $arr = array();
     foreach ($info as $key => $value) {
         $arr[] = $info[$key]['chk_answer'];
     }
     $per = array_count_values($arr);
     ksort($per);
     //var_dump($per);
     $total_count = sizeof($info);
     $config = $this->get_config($q);
     //foreach($per as $key => $value){
     //$str .= '选项'.$key.'次数'.$value;
     //}
     //var_dump($str);
     //var_dump($per);
     include $this->template('show');
 }
Example #18
0
 private function getShowID()
 {
     global $_W;
     $sql = 'select showID from ' . tablename('ice_picWallMain') . ' where uniacid = :uniacid order by showID DESC';
     $result = pdo_fetchcolumn($sql, array('uniacid' => $_W['uniacid']), 0) + 1;
     return $result;
 }
Example #19
0
 public function getGroupName($uid = 0)
 {
     $uid = $uid ?: v('user.uid');
     $sql = "SELECT title,id FROM " . tablename('member') . " m JOIN " . tablename('member_group') . " g ON m.group_id = g.id WHERE m.uid={$uid}";
     $d = Db::query($sql);
     return $d ? $d[0] : NULL;
 }
Example #20
0
/**
 * 获取单条用户信息,如果查询参数多于一个字段,则查询满足所有字段的用户
 * PS:密码字段不要加密
 * @param array $member 要查询的用户字段,可以包括  uid, username, password, status
 * @param bool 是否要同时获取状态信息
 * @return array 完整的用户信息
 */
function member_single($member)
{
    $sql = 'SELECT * FROM ' . tablename('members') . " WHERE 1";
    $params = array();
    if (!empty($member['uid'])) {
        $sql .= ' AND `uid`=:uid';
        $params[':uid'] = intval($member['uid']);
    }
    if (!empty($member['username'])) {
        $sql .= ' AND `username`=:username';
        $params[':username'] = $member['username'];
    }
    if (!empty($member['email'])) {
        $sql .= ' AND `email`=:email';
        $params[':email'] = $member['email'];
    }
    if (!empty($member['status'])) {
        $sql .= " AND `status`=:status";
        $params[':status'] = intval($member['status']);
    }
    $sql .= " LIMIT 1";
    $record = pdo_fetch($sql, $params);
    if (!$record) {
        return false;
    }
    if (!empty($member['password'])) {
        $password = member_hash($member['password'], $record['salt']);
        if ($password != $record['password']) {
            return false;
        }
    }
    return $record;
}
Example #21
0
 public function doWebWelcome()
 {
     global $_W;
     $sql = 'select pretype,count(*) as num from ' . tablename('chips');
     $sql .= ' where projguid=:projguid and deleted=0 group by pretype ';
     $cnt = pdo_fetchall($sql, array(':projguid' => $_W['project']['projguid']), 'pretype');
     $status = array(0 => '登记', 1 => '付款', 2 => '无交款');
     $count = array(0 => 0);
     foreach ($status as $k => $v) {
         $count[$k + 1] = 0;
         if (isset($cnt[$k])) {
             $count[$k + 1] = $cnt[$k]['num'];
         }
         $count[0] += $count[$k];
     }
     // 诚意金统计
     $sql = "select count(*) as num, sum(premoney) as total from " . tablename('chips');
     $sql .= ' where premoney>0 and projguid=:projguid and deleted=0';
     $premoney = pdo_fetch($sql, array(':projguid' => $_W['project']['projguid']));
     // 认购统计
     $sql = "select count(*) as num, coalesce(SUM(ordermoney),0) as total from " . tablename('chips');
     $sql .= ' where ordermoney>0 and projguid=:projguid and deleted=0';
     $ordermoney = pdo_fetch($sql, array(':projguid' => $_W['project']['projguid']));
     include $this->template('welcome');
 }
Example #22
0
 public function doMobileIndex()
 {
     global $_W, $_GPC;
     $sql = "select * from" . tablename('chax') . "where weid='{$_W['weid']}' and status =1";
     $navs = pdo_fetchall($sql);
     include $this->template('index');
 }
Example #23
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('news_reply') . " WHERE rid = :id AND parent_id = -1 ORDER BY displayorder DESC, id ASC LIMIT 8";
     $commends = pdo_fetchall($sql, array(':id' => $rid));
     if (empty($commends)) {
         $sql = "SELECT * FROM " . tablename('news_reply') . " WHERE rid = :id AND parent_id = 0 ORDER BY RAND()";
         $main = pdo_fetch($sql, array(':id' => $rid));
         if (empty($main['id'])) {
             return false;
         }
         $sql = "SELECT * FROM " . tablename('news_reply') . " WHERE id = :id OR parent_id = :parent_id ORDER BY parent_id ASC, displayorder DESC, id ASC LIMIT 8";
         $commends = pdo_fetchall($sql, array(':id' => $main['id'], ':parent_id' => $main['id']));
     }
     if (empty($commends)) {
         return false;
     }
     $news = array();
     foreach ($commends as $c) {
         $row = array();
         $row['title'] = $c['title'];
         $row['description'] = $c['description'];
         !empty($c['thumb']) && ($row['picurl'] = tomedia($c['thumb']));
         $row['url'] = empty($c['url']) ? $this->createMobileUrl('detail', array('id' => $c['id'])) : $c['url'];
         $news[] = $row;
     }
     return $this->respNews($news);
 }
Example #24
0
 public function respond()
 {
     if ($this->message['event'] == 'scancode_waitmsg') {
         $qrtype = $this->message['scancodeinfo']['scantype'];
         if ($qrtype == 'barcode') {
             $CodeInfo = $this->message['scancodeinfo']['scanresult'];
             $Codearr = explode(",", $CodeInfo);
             $Code = $Codearr['1'];
         } else {
             $Code = $this->message['scancodeinfo']['scanresult'];
         }
     } else {
         $rid = $this->rule;
         $sql = "SELECT * FROM " . tablename('rule_keyword') . " WHERE `rid`=:rid LIMIT 1";
         $row = pdo_fetch($sql, array(':rid' => $rid));
         $keywords = $row['content'];
         // 取得正则表达式
         //查询防伪码
         preg_match('/' . $keywords . '(.*)/', $this->message['content'], $match);
         $Code = $match[1];
     }
     //return $this->respText($Code);
     $express = new Express();
     $result = $express->getorder($Code);
     if ($result['status'] == '200') {
         $time = $result['updatetime'];
         foreach ($result['data'] as $trace) {
             $reply .= "{$trace['time']}\n{$trace['context']}\n-------\n";
         }
         $msg = "快递单号:\n" . $Code . "\n最后更新:\n" . $time . "\n流转情况:\n" . $reply;
     } else {
         $msg = '查询失败 ' . $result['message'];
     }
     return $this->respText($msg);
 }
Example #25
0
function cron_run($cronid = 0)
{
    if (empty($cronid)) {
        $cron = pdo_fetch('SELECT * FROM ' . tablename('cron') . ' WHERE available > 0 AND nextrun <= ' . TIMESTAMP . ' ORDER BY nextrun ASC');
    } else {
        $cron = pdo_fetch('SELECT * FROM ' . tablename('cron') . ' WHERE cronid = :id', array(':id' => intval($cronid)));
    }
    if (empty($cron)) {
        return false;
    }
    if ($cron['type'] == 'system') {
        //定义系统内置的计划任务文件放在哪个路径
        $cronfile = IA_ROOT . '/cron/' . $cron['filename'];
    } elseif ($cron['type'] == 'module') {
        //定义模块的计划任务文件放在哪个路径
        $cronfile = IA_ROOT . '/cron/' . $cron['filename'];
    }
    if (is_file($cronfile)) {
        $cron['minute'] = explode("\t", $cron['minute']);
        //设置下次执行时间
        cron_setnexttime($cron);
        @set_time_limit(1000);
        //@ignore_user_abort(TRUE);
        if (!@(include $cronfile)) {
            return false;
        }
    }
}
Example #26
0
 public function respond()
 {
     global $_W;
     load()->func('compat.biz');
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('bm_qrsign_reply') . " WHERE `rid`=:rid LIMIT 1";
     $reply = pdo_fetch($sql, array(':rid' => $rid));
     if (empty($reply['id'])) {
         return $this->respText("系统升级中,请稍候!");
     }
     if (time() > strtotime($reply['endtime'])) {
         if (empty($reply['memo2'])) {
             $msg = '对不起,活动已经于' . $reply['endtime'] . '结束,感谢您的参与!!!';
         } else {
             $msg = $reply['memo2'];
         }
         return $this->respText($msg);
     }
     if (time() < strtotime($reply['starttime'])) {
         if (empty($reply['memo1'])) {
             $msg = '对不起,活动将于' . $reply['starttime'] . '开始,敬请期待!!!';
         } else {
             $msg = $reply['memo1'];
         }
         return $this->respText($msg);
     }
     $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('show', array('rid' => $rid, 'from_user' => $this->message['from']));
     $response['FromUserName'] = $this->message['to'];
     $response['ToUserName'] = $this->message['from'];
     $response['MsgType'] = 'news';
     $response['ArticleCount'] = 1;
     $response['Articles'] = array();
     $response['Articles'][] = array('Title' => $reply['title'], 'Description' => $reply['desc'], 'PicUrl' => !strexists($reply['picurl'], 'http://') ? $_W['attachurl'] . $reply['picurl'] : $reply['picurl'], 'Url' => $url, 'TagName' => 'item');
     return $response;
 }
Example #27
0
 public function respond()
 {
     if ($this->rule == -1) {
         return $this->respCustom();
     }
     $sql = "SELECT * FROM " . tablename('custom_reply') . " WHERE `rid` IN ({$this->rule})  ORDER BY RAND() LIMIT 1";
     $reply = pdo_fetch($sql);
     $nhour = date('H', TIMESTAMP);
     $flag = 0;
     if ($reply['start1'] == 0 && $reply['end'] == 24) {
         $flag = 1;
     } elseif ($reply['start1'] != '-1' && $nhour >= $reply['start1'] && $nhour < $reply['end1']) {
         $flag = 1;
     } elseif ($reply['start2'] != '-1' && $nhour >= $reply['start2'] && $nhour < $reply['end2']) {
         $flag = 1;
     }
     if ($flag == 1) {
         return $this->respCustom();
     } else {
         $content = '多客服接入时间为:' . intval($reply['start1']) . '时~' . $reply['end1'] . '时';
         if ($reply['start2'] != '-1') {
             $content .= ',' . $reply['start2'] . '时~' . $reply['end2'] . '时';
         }
         $reply['content'] = $content;
         return $this->respText($reply['content']);
     }
 }
Example #28
0
 public function respond()
 {
     global $_W, $_GPC;
     $rid = $this->rule;
     $row = pdo_fetch("SELECT * FROM " . tablename($this->reply_table) . " WHERE weid = :acid AND rid = :rid", array(':acid' => $_W['uniacid'], ':rid' => $rid));
     return $this->respNews(array('title' => $row['title'], 'description' => $row['description'], 'picurl' => $row['avatar'], 'url' => $this->createMobileUrl('Index')));
 }
Example #29
0
 public function fieldsFormDisplay($rid = 0)
 {
     //要嵌入规则编辑页的自定义内容,这里 $rid 为对应的规则编号,新增时为 0
     global $_W;
     load()->func('tpl');
     $reply = pdo_fetch("SELECT * FROM " . tablename('eso_runman_reply') . " WHERE rid = :rid", array(':rid' => $rid));
     if (empty($reply)) {
         $reply['starttime'] = time();
         $reply['endtime'] = time() + 2592000;
         $reply['setting'] = array();
     } else {
         $reply['setting'] = string2array($reply['setting']);
     }
     $sql = "SELECT * FROM " . tablename('uni_account');
     $uniaccounts = pdo_fetchall($sql);
     $accounts = array();
     if (!empty($uniaccounts)) {
         foreach ($uniaccounts as $uniaccount) {
             $accountlist = uni_accounts($uniaccount['uniacid']);
             if (!empty($accountlist)) {
                 foreach ($accountlist as $account) {
                     if (!empty($account['key']) && !empty($account['secret']) && in_array($account['level'], array(3, 4))) {
                         $accounts[$account['acid']] = $account['name'];
                     }
                 }
             }
         }
     }
     include $this->template('form');
 }
Example #30
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $reply = pdo_fetch("SELECT * FROM " . tablename('vote_reply') . " WHERE `rid`=:rid LIMIT 1", array(':rid' => $rid));
     if ($reply == false) {
         return $this->respText('活动已经取消...');
     }
     $nowtime = time();
     $endtime = $reply['endtime'] + 86399;
     if ($reply['status'] == 0) {
         return $this->respText("投票已暂停,请等待...");
     }
     if ($reply['votelimit'] == 1) {
         if ($reply['votetotal'] > 0 && $reply['votenum'] >= $reply['votetotal']) {
             return $this->respText("投票人数已满,活动结束...");
         }
     } else {
         if ($reply['starttime'] > $nowtime) {
             return $this->respText("投票未开始,请等待...");
         } elseif ($endtime < $nowtime) {
             return $this->respText("投票已结束...");
         } else {
             //                if ($reply['status'] != 1) {
             //                     return $this->respText("投票已暂停,请等待...");
             //                }
         }
     }
     return $this->respNews(array('Title' => $reply['title'], 'Description' => $reply['description'], 'PicUrl' => tomedia($reply['thumb']), 'Url' => $this->createMobileUrl("index", array("id" => $rid))));
 }