public function template($filename, $flag = TEMPLATE_INCLUDEPATH) { global $_W, $_GPC; $_W['template'] = $_W['account']['template']; $_W['template']['source'] = $_W['account']['template']; $source = IA_ROOT . "/addons/quicktemplate/{$this->mn}/{$_W['template']}/{$filename}.html"; $compile = IA_ROOT . "/data/tpl/app/{$_W['template']}/{$this->mn}/{$filename}.tpl.php"; if (!empty($_GPC['__template'])) { $source = IA_ROOT . "/addons/quicktemplate/{$this->mn}/{$_GPC['__template']}/{$filename}.html"; if (!is_file($source)) { die('invalid debug template ' . $_GPC['__template']); } } if (!is_file($source)) { $source = IA_ROOT . "/addons/{$this->mn}/template/mobile/{$filename}.html"; if (!is_file($source)) { $source = "{$_W['template']['source']}/mobile/default/{$this->mn}/{$filename}.html"; if (!is_file($source)) { $source = "{$_W['template']['source']}/mobile/{$_W['account']['template']}/{$filename}.html"; if (!is_file($source)) { $source = "{$_W['template']['source']}/mobile/default/{$filename}.html"; if (!is_file($source)) { exit("Error: template source '{$filename}' is not exist!"); } } } } } WeUtility::logging('compile source', array($source, $compile)); if (DEVELOPMENT || !is_file($compile) || filemtime($source) > filemtime($compile)) { template_compile($source, $compile, true); } return $compile; }
private function fans_search($user, $fields = array()) { global $_W; $fields_str = self::$select_fields; $sql = "SELECT {$fields_str} FROM " . tablename(self::$t_sys_fans) . " a, " . tablename(self::$t_sys_member) . " b WHERE a.openid = :openid AND a.uniacid= :uniacid AND a.uid = b.uid"; $fans = pdo_fetch($sql, array(':openid' => $user, ':uniacid' => $_W['uniacid'])); WeUtility::logging('sql', $fans); return $fans; }
public function receive() { if ($this->message['msgtype'] == 'event') { if ($this->message['event'] == 'subscribe' && !empty($this->message['ticket'])) { $scene_id = $this->message['eventkey']; WeUtility::logging("Receiver:SUBSCRIBE", $scene_id); } elseif ($this->message['event'] == 'SCAN') { $scene_id = $this->message['eventkey']; WeUtility::logging("Receiver:SCAN", $scene_id); } } }
private function refreshUserInfo($from_user) { $follower = $from_user; $qr_mgr = new UserManager(''); $userInfo = $qr_mgr->getUserInfo($follower); if (empty($userInfo) or empty($userInfo['nickname']) or empty($userInfo['avatar'])) { $weapi = new WechatAPI(); $userInfo = $weapi->getUserInfo($follower); $qr_mgr->saveUserInfo($userInfo); } WeUtility::logging('refresh', $userInfo); }
function moduleInit($name, $params = array()) { if (empty($name)) { return false; } $site = WeUtility::createModuleSite($name); if (!is_error($site)) { $method = 'shareResult'; if (method_exists($site, $method)) { $site->{$method}($params); exit('success'); } } }
public function respond() { global $_W, $engine; $level = array(); if (!empty($_W['account']['modules'])) { foreach ($_W['account']['modules'] as $row) { if (!empty($row['displayorder']) && $row['displayorder'] < 127) { $level[$row['displayorder']] = $row; } } } if (!empty($level)) { $response = ''; for ($i = 1; $i <= 5; $i++) { if (!empty($response)) { $engine->response['module'] = $_W['module']; return $response; break; } if (empty($level[$i])) { continue; } $_W['module'] = $level[$i]['name']; $processor = WeUtility::createModuleProcessor($_W['module']); $processor->message = $this->message; $processor->inContext = false; $processor->rule = $this->rule; $engine->response['rule'] = $default['id']; $response = $processor->respond(); } } if (!empty($_W['account']['default_period']) && empty($_W['cache']['default_period'])) { return; } $response['FromUserName'] = $this->message['to']; $response['ToUserName'] = $this->message['from']; $response['MsgType'] = 'text'; $default = pdo_fetchcolumn("SELECT `default` FROM " . tablename('wechats') . " WHERE `weid`=:weid", array(':weid' => $_W['weid'])); if (is_array(iunserializer($default))) { $default = iunserializer($default); $_W['module'] = $default['module']; $processor = WeUtility::createModuleProcessor($default['module']); $processor->message = $this->message; $processor->inContext = $this->inContext; $processor->rule = $default['id']; return $processor->respond(); } $response['Content'] = stripslashes($default); return $response; }
public static function curl_file_get_contents($durl) { $r = null; if (function_exists('curl_init') && function_exists('curl_exec')) { WeUtility::logging("using curl"); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $durl); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $r = curl_exec($ch); curl_close($ch); } return $r; }
public function respond() { global $_W, $engine; $sql = "SELECT `welcome` FROM " . tablename('wechats') . " WHERE `weid`=:weid"; $default = pdo_fetchcolumn($sql, array(':weid' => $_W['weid'])); if (is_array(iunserializer($default))) { $default = iunserializer($default); $_W['module'] = $default['module']; $processor = WeUtility::createModuleProcessor($default['module']); $processor->message = $this->message; $processor->inContext = $this->inContext; $processor->rule = $default['id']; $processor->module = $_W['account']['modules'][$default['module']]; $engine->response['rule'] = $default['id']; return $processor->respond(); } return $this->respText($default); }
public static function fsock_http_request($url, $timeout = 30) { $parsed = parse_url($url); $host = $parsed['host']; $path = $parsed['path'] . '?' . $parsed['query']; $cookie = ''; $fp = fsockopen($host, 80, $errno, $errstr, $timeout); WeUtility::logging('fsockopen', array($url, $errno, $errstr, $fp)); if (!$fp) { return -1; } $out = "GET " . $path . " HTTP/1.1\r\n"; $out .= "Host: " . $host . "\r\n"; $out .= "Connection: Close\r\n"; $out .= "Cookie: " . $cookie . "\r\n\r\n"; fwrite($fp, $out); fclose($fp); }
public function respond() { global $_W, $engine; $r['FromUserName'] = $this->message['to']; $r['ToUserName'] = $this->message['from']; $r['MsgType'] = 'text'; $sql = "SELECT `welcome` FROM " . tablename('wechats') . " WHERE `weid`=:weid"; $default = pdo_fetchcolumn($sql, array(':weid' => $_W['weid'])); if (is_array(iunserializer($default))) { $default = iunserializer($default); $_W['module'] = $default['module']; $processor = WeUtility::createModuleProcessor($default['module']); $processor->message = $this->message; $processor->inContext = $this->inContext; $processor->rule = $default['id']; $engine->response['rule'] = $default['id']; return $processor->respond(); } $r['Content'] = $default; return $r; }
public function doWebDelete() { global $_GPC, $_W; $rid = intval($_GPC['rid']); $rule = pdo_fetch("SELECT id, module FROM " . tablename('rule') . " WHERE id = :id and uniacid=:uniacid", array(':id' => $rid, ':uniacid' => $_W['uniacid'])); if (empty($rule)) { message('抱歉,要修改的规则不存在或是已经被删除!'); } if (pdo_delete('rule', array('id' => $rid))) { pdo_delete('rule_keyword', array('rid' => $rid)); //删除统计相关数据 pdo_delete('stat_rule', array('rid' => $rid)); pdo_delete('stat_keyword', array('rid' => $rid)); //调用模块中的删除 $module = WeUtility::createModule($rule['module']); if (method_exists($module, 'ruleDeleted')) { $module->ruleDeleted($rid); } } message('规则操作成功!', $this->createWebUrl('manage'), 'success'); }
<div><span style="display:inline-block; width:150px; font-weight:600;">[to]</span>当前公众号的OpenID</div> <div><span style="display:inline-block; width:150px; font-weight:600;">[rule]</span>当前回复的回复编号</div> </div> <span class="help-block hide adv-setting" style="margin:5px 0;">可在回复内容的任何地方使用预定义标记来表示特定内容</span> <div id="module-form"> <?php if (!empty($rid)) { ?> <?php $rule['reply']->fieldsFormDisplay($rule['rule']['id']); ?> <?php } else { ?> <?php WeUtility::createModule($defaultmodule)->fieldsFormDisplay(); ?> </script> <?php } ?> </div> </td> </tr> <tr> <th></th> <td> <button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button> <input type="hidden" name="token" value="<?php echo $_W['token']; ?>
$cfg = $m['config']; $ds = reply_search("`uniacid` = 0 AND module = 'userapi' AND `status`=1"); $apis = array(); foreach ($ds as $row) { $apis[$row['id']] = $row; } if ($_W['ispost'] && $_W['isajax']) { $rids = explode(',', $_GPC['rids']); if (is_array($rids)) { $cfg = array(); foreach ($rids as $rid) { if (!empty($apis[$rid])) { $cfg[intval($rid)] = true; } } $module = WeUtility::createModule('userapi'); $module->saveSettings($cfg); } exit; } $ds = array(); foreach ($apis as $row) { $reply = pdo_fetch('SELECT * FROM ' . tablename('userapi_reply') . ' WHERE `rid`=:rid', array(':rid' => $row['id'])); $r = array(); $r['title'] = $row['name']; $r['rid'] = $row['id']; $r['description'] = $reply['description']; $r['switch'] = $cfg[$r['rid']] ? ' checked="checked"' : ''; $ds[] = $r; } template('platform/service');
public function doWebDeleteAll() { global $_GPC, $_W; foreach ($_GPC['idArr'] as $k => $rid) { $rid = intval($rid); if ($rid == 0) { continue; } $rule = pdo_fetch("SELECT id, module FROM " . tablename('rule') . " WHERE id = :id and uniacid=:uniacid", array(':id' => $rid, ':uniacid' => $_W['uniacid'])); if (empty($rule)) { $this->webmessage('抱歉,要修改的规则不存在或是已经被删除!'); } if (pdo_delete('rule', array('id' => $rid))) { pdo_delete('rule_keyword', array('rid' => $rid)); //删除统计相关数据 pdo_delete('stat_rule', array('rid' => $rid)); pdo_delete('stat_keyword', array('rid' => $rid)); //调用模块中的删除 $module = WeUtility::createModule($rule['module']); if (method_exists($module, 'ruleDeleted')) { $module->ruleDeleted($rid); } } } $this->webmessage('选择中的活动删除成功!', '', 0); }
private function process($param) { global $_W; if (empty($param['module']) || !in_array($param['module'], $this->modules)) { return false; } $processor = WeUtility::createModuleProcessor($param['module']); $processor->message = $param['message']; $processor->rule = $param['rule']; $processor->priority = intval($param['priority']); $processor->inContext = $param['context'] === true; $response = $processor->respond(); if (empty($response)) { return false; } return $response; }
} if (checksubmit('submit')) { if (empty($_GPC['name'])) { message('必须填写服务名称.'); } $keywords = @json_decode(htmlspecialchars_decode($_GPC['keywords']), true); if (empty($keywords)) { message('必须填写有效的触发关键字.'); } $rule = array('uniacid' => 0, 'name' => $_GPC['name'], 'module' => $m, 'status' => intval($_GPC['status'])); if (!empty($_GPC['istop']) && $_GPC['istop'] == 'true') { $rule['displayorder'] = 255; } else { $rule['displayorder'] = range_limit($_GPC['displayorder'], 0, 254); } $module = WeUtility::createModule($m); if (empty($module)) { message('抱歉,模块不存在请重新其它模块!'); } $msg = $module->fieldsFormValidate(); if (is_string($msg) && trim($msg) != '') { message($msg); } if (!empty($rid)) { $result = pdo_update('rule', $rule, array('id' => $rid)); } else { $result = pdo_insert('rule', $rule); $rid = pdo_insertid(); } if (!empty($rid)) { $sql = 'DELETE FROM ' . tablename('rule_keyword') . ' WHERE `rid`=:rid AND `uniacid`=:uniacid';
$log = pdo_fetch($sql, $pars); if (!empty($log) && $log['status'] == '0') { if ($log['is_usecard'] == 1 && $log['card_type'] == 1 && !empty($log['encrypt_code']) && $_W['acid']) { load()->classs('coupon'); $acc = new coupon($_W['acid']); $codearr['encrypt_code'] = $log['encrypt_code']; $codearr['module'] = $log['module']; $codearr['card_id'] = $log['card_id']; $acc->PayConsumeCode($codearr); } if ($log['is_usecard'] == 1 && $log['card_type'] == 2) { $now = time(); $log['card_id'] = intval($log['card_id']); pdo_query('UPDATE ' . tablename('activity_coupon_record') . " SET status = 2, usetime = {$now}, usemodule = '{$log['module']}' WHERE uniacid = :aid AND couponid = :cid AND uid = :uid AND status = 1 LIMIT 1", array(':aid' => $_W['uniacid'], ':uid' => $log['openid'], ':cid' => $log['card_id'])); } $site = WeUtility::createModuleSite($log['module']); if (!is_error($site)) { $site->weid = $_W['weid']; $site->uniacid = $_W['uniacid']; $site->inMobile = true; $method = 'payResult'; if (method_exists($site, $method)) { $ret = array(); $ret['result'] = 'failed'; $ret['type'] = $log['type']; $ret['from'] = 'return'; $ret['tid'] = $log['tid']; $ret['user'] = $log['openid']; $ret['fee'] = $log['fee']; $ret['weid'] = $log['weid']; $ret['uniacid'] = $log['uniacid'];
} } else { $solutions[] = $module; } } } $m = $_GPC['m']; if (!empty($m)) { load()->model('module'); $error = module_solution_check($m); if (is_error($error)) { message($error['message']); } $solution = module_fetch($m); $title = ' 行业解决方案 - ' . $solution['title']; $site = WeUtility::createModuleSite($m); if (!is_error($site)) { $method = 'doWebWelcome'; $welcome = @$site->{$method}(); } if (empty($welcome)) { $entries = module_entries($m, array('menu', 'home', 'profile', 'shortcut', 'cover')); if ($_W['role'] == 'operator') { foreach ($entries as $index1 => &$entry1) { if ($index1 == 'cover') { continue; } foreach ($entry1 as $index2 => &$entry2) { $url_arr = parse_url($entry2['url']); $url_query = $url_arr['query']; parse_str($url_query, $query_arr);
*/ defined('IN_IA') or exit('Access Denied'); if ($_GPC['type'] == 'rule') { $rid = intval($_GPC['id']); $rule = pdo_fetch("SELECT id, module FROM " . tablename('rule') . " WHERE id = :id", array(':id' => $rid)); if (empty($rule)) { message('抱歉,要修改的规则不存在或是已经被删除!'); } //删除回复,关键字及规则 if (pdo_delete('rule', array('id' => $rid))) { pdo_delete('rule_keyword', array('rid' => $rid)); //删除统计相关数据 pdo_delete('stat_rule', array('rid' => $rid)); pdo_delete('stat_keyword', array('rid' => $rid)); //调用模块中的删除 $module = WeUtility::createModule($rule['module']); if (method_exists($module, 'ruleDeleted')) { $module->ruleDeleted($rid); } } message('规则操作成功!', create_url('rule/display', array('module' => $rule['module']))); } elseif ($_GPC['type'] == 'keyword') { $rid = intval($_GPC['rid']); $kid = intval($_GPC['kid']); $rule = pdo_fetch("SELECT id, module FROM " . tablename('rule') . " WHERE id = :id", array(':id' => $rid)); if (empty($rule)) { message('抱歉,要修改的规则不存在或是已经被删除!'); } pdo_delete('rule_keyword', array('rid' => $rid, 'id' => $kid)); pdo_delete('stat_keyword', array('kid' => $kid)); message('关键字删除成功!', '', 'success');
} } else { $row['items'][] = array($opt['title'], create_url("rule/cover", array('eid' => $opt['eid']))); } } } if (!empty($m['rule']) || $mg['isrulefields']) { $row['items'][] = array('关键字触发列表', create_url('rule/display', array('module' => $row['name'])), 'childItems' => array('<i class="icon-plus"></i>', create_url('rule/post', array('module' => $row['name'])))); } if (!empty($m['home']) || !empty($m['profile']) || !empty($m['shortcut'])) { $row['items'][] = array('微站导航设置', create_url('site/nav', array('name' => $row['name']))); } if (!empty($m['menu']) && is_array($m['menu'])) { foreach ($m['menu'] as $opt) { if (!empty($opt['call'])) { $site = WeUtility::createModuleSite($row['name']); if (method_exists($site, $opt['call'])) { $ret = $site->{$opt}['call'](); if (is_array($ret)) { foreach ($ret as $et) { $row['items'][] = array($et['title'], $et['url']); } } } } else { $row['items'][] = array($opt['title'], create_url("site/entry", array('eid' => $opt['eid']))); } } } if ($mg['settings']) { $row['items'][] = array('参数设置', create_url('member/module/setting', array('mid' => $mg['mid'])));
<?php /** * 微站管理 * [WDL] Copyright (c) 2013 B2CTUI.COM */ define('IN_SYS', true); require '../framework/bootstrap.inc.php'; require IA_ROOT . '/web/common/bootstrap.sys.inc.php'; load()->web('common'); load()->web('template'); header('Content-Type: text/html; charset=GBK'); $modulename = 'weisrc_dish'; $site = WeUtility::createModuleSite($modulename); if (!is_error($site)) { $method = 'doWebPrint'; //$site->module = array_merge($_W['modules'][$modulename], $_W['account']['modules'][$_W['modules'][$modulename]['mid']]); $site->weid = $_W['uniacid']; $site->inMobile = false; if (method_exists($site, $method)) { exit($site->{$method}()); } } exit("访问的方法 {$method} 不存在.");
echo $exit; exit; } if ($do == 'end') { $fanid = intval($_GPC['fanid']); $fans = pdo_fetch('SELECT fanid,acid,openid FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND fanid = :id', array(':uniacid' => $_W['uniacid'], ':id' => $fanid)); $account = account_fetch($fans['acid']); $message['from'] = $_W['openid'] = $fans['openid']; $message['to'] = $account['original']; if (!empty($message['to'])) { $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']); load()->classs('wesession'); load()->classs('account'); session_id($sessionid); WeSession::start($_W['uniacid'], $_W['openid'], 300); $processor = WeUtility::createModuleProcessor('chats'); $processor->end(); } if (!empty($_GPC['from'])) { $url = base64_decode($_GPC['from']); } else { $url = url('mc/fans/', array('acid' => $fans['acid'])); } header('Location:' . $url); exit; } function iurldecode($str) { if (!is_array($str)) { return urldecode($str); }
<?php /** * [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. */ defined('IN_IA') or exit('Access Denied'); load()->func('cron'); $id = intval($_GPC['id']); $cron = cron_check($id); if (is_error($cron)) { message($cron, '', 'ajax'); } $_W['uniacid'] = $cron['uniacid']; $_W['uniaccount'] = $_W['account'] = uni_fetch($_W['uniacid']); $_W['acid'] = $_W['account']['acid']; $_W['weid'] = $_W['uniacid']; $_W['cron'] = $cron; $moduleCron = WeUtility::createModuleCron($cron['module']); if (!is_error($moduleCron)) { define('IN_MODULE', $cron['module']); $method = 'doCron' . ucfirst($cron['filename']); $moduleCron->{$method}(); exit; } else { message($moduleCron, '', 'ajax'); }
define('FRAME', 'ext'); define('CRUMBS_NAV', 1); $ptr_title = $entry['title']; $module_types = module_types(); define('ACTIVE_FRAME_URL', url('home/welcome/ext', array('m' => $entry['module']))); } $frames = buildframes(array(FRAME), $entry['module']); $frames = $frames[FRAME]; } if (!empty($entry['module'])) { load()->model('extension'); if (ext_module_checkupdate($entry['module'])) { message('系统检测到该模块有更新,请点击“<a href="' . url('extension/module/upgrade', array('m' => $entry['module'])) . '">更新模块</a>”后继续使用!', '', 'error'); } } $_GPC['__entry'] = $entry['title']; $_GPC['__state'] = $entry['state']; if (!empty($_W['modules'][$entry['module']]['handles']) && (count($_W['modules'][$entry['module']]['handles']) > 1 || !in_array('text', $_W['modules'][$entry['module']]['handles']))) { $handlestips = true; } $site = WeUtility::createModuleSite($entry['module']); define('IN_MODULE', $entry['module']); if (!is_error($site)) { $sysmodule = system_modules(); if (in_array($m, $sysmodule)) { $site_urls = $site->getTabUrls(); } $method = 'doWeb' . ucfirst($entry['do']); exit($site->{$method}()); } exit("访问的方法 {$method} 不存在.");
function module_build_form($name, $rid) { $rid = intval($rid); $m = WeUtility::createModule($name); return $m->fieldsFormDisplay($rid); }
pdo_insert('rule_keyword', $krow); } $rowtpl['incontent'] = $_GPC['incontent']; $module->fieldsFormSubmit($rid); message('回复规则保存成功!', url('platform/reply/post', array('m' => $m, 'rid' => $rid))); } else { message('回复规则保存失败, 请联系网站管理员!'); } } template('platform/reply-post'); } if ($do == 'delete') { $rid = intval($_GPC['rid']); if (empty($rid)) { message('非法访问.'); } $reply = reply_single($rid); if (empty($reply) || $reply['uniacid'] != $_W['uniacid']) { message('抱歉,您操作的规则不在存或是已经被删除!', url('platform/reply', array('m' => $m)), 'error'); } if (pdo_delete('rule', array('id' => $rid))) { pdo_delete('rule_keyword', array('rid' => $rid)); pdo_delete('stat_rule', array('rid' => $rid)); pdo_delete('stat_keyword', array('rid' => $rid)); $module = WeUtility::createModule($reply['module']); if (method_exists($module, 'ruleDeleted')) { $module->ruleDeleted($rid); } } message('规则操作成功!', referer()); }
public function doMobileOAuth() { global $_W, $_GPC; $account = $this->getAccount(); $code = trim($_GPC['code']); if (!empty($code)) { $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$account['key']}&secret={$account['secret']}&code={$code}&grant_type=authorization_code"; WeUtility::logging('trace', 'url:' . $url); $ret = ihttp_get($url); if (!is_error($ret)) { $auth = @json_decode($ret['content'], true); if (is_array($auth) && !empty($auth['openid'])) { $row = array(); $row['weid'] = $_W['weid']; $row['openid'] = $auth['openid']; $row['from_user'] = $auth['openid']; if ($auth['scope'] == 'snsapi_userinfo') { $user = $this->getFansInfo($auth['access_token'], $auth['openid']); $row['nickname'] = $user['nickname']; $row['avatar'] = $user['headimgurl']; } WeUtility::logging('trace', 'user:'******'query']); header('location: ' . $_W['siteroot'] . 'mobile.php?' . $forward . '&' . $this->cookiename . '=' . $auth['openid'] . '&wxref=mp.weixin.qq.com#wechat_redirect'); exit; } else { message($ret['content']); } } } message('微信授权失败!'); }
/** * [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. */ defined('IN_IA') or exit('Access Denied'); $moduels = uni_modules(); $params = @json_decode(base64_decode($_GPC['id']), true); $params['m'] = trim($params['m']); $params['id'] = intval($params['id']); if (empty($params) || !array_key_exists($params['m'], $moduels)) { message('访问错误.'); } load()->model('activity'); $check = false; $site = WeUtility::createModuleSite($params['m']); if (!is_error($site)) { $site->weid = $_W['weid']; $site->uniacid = $_W['uniacid']; $site->inMobile = true; $method = 'grantCherk'; if (method_exists($site, $method)) { $ret = array(); $ret['couponid'] = $status['couponid']; $ret['type'] = $status['type']; $ret['uid'] = $_W['member']['uid']; $ret['weid'] = $_W['weid']; $ret['uniacid'] = $_W['uniacid']; $status = $site->{$method}($ret); if (!is_error($status)) { $check = true;
private function genImage($weapi, $scene_id, $channel, $from_user) { global $_W; $rand_file = $from_user . rand() . '.jpg'; $att_target_file = 'qr-image-' . $rand_file; $att_head_cache_file = 'head-image-' . $rand_file; $target_file = ATTACH_DIR . $att_target_file; $target_file_url = $_W['attachurl'] . $att_target_file; $head_cache_file = ATTACH_DIR . $att_head_cache_file; $qr_file = $weapi->getLimitQR($scene_id); $ch = pdo_fetch("SELECT * FROM " . tablename(self::$t_channel) . " WHERE channel=:channel AND weid=:weid", array(":channel" => $channel, ":weid" => $_W['weid'])); $ch = WechatUtil::decode_channel_param($ch, $ch['bgparam']); $enableHead = $ch['avatarenable']; $enableName = $ch['nameenable']; if (empty($ch)) { $ret = $weapi->sendText($from_user, "您所请求的专属海报二维码已经失效, 请联系客服人员"); exit(0); } else { if (empty($ch['bg'])) { $bg_file = APP_PHP . 'images/bg.jpg'; } else { $bg_file = $_W['attachurl'] . $ch['bg']; } } // 基础模式 WeUtility::logging('step merge 1', "merge bgfile {$bg_file} and qrfile {$qr_file}"); $this->mergeImage($bg_file, $qr_file, $target_file, array('left' => $ch['qrleft'], 'top' => $ch['qrtop'], 'width' => $ch['qrwidth'], 'height' => $ch['qrheight'])); WeUtility::logging('step merge 1 done', ''); // 扩展功能:昵称、图像 if (1) { $fans = WechatUtil::fans_search($from_user, array('nickname', 'avatar')); if (!empty($fans)) { // 昵称 if ($enableName) { if (strlen($fans['nickname']) > 0) { WeUtility::logging('step wirte text 1', $fans); // $this->writeText($target_file, $target_file, '我是' . $fans['nickname'], array('size'=>30, 'left'=>150, 'top'=>50)); $this->writeText($target_file, $target_file, $fans['nickname'], array('size' => $ch['namesize'], 'left' => $ch['nameleft'], 'top' => $ch['nametop'])); WeUtility::logging('step wirte text 1 done', ''); } } // 头像 if ($enableHead) { if (strlen($fans['avatar']) > 10) { $head_file = $fans['avatar']; $head_file = preg_replace('/\\/0$/i', '/96', $head_file); WeUtility::logging('step merge 2', $head_file); $this->mergeImage($target_file, $head_file, $target_file, array('left' => $ch['avatarleft'], 'top' => $ch['avatartop'], 'width' => $ch['avatarwidth'], 'height' => $ch['avatarheight'])); WeUtility::logging('step merge 2 done', ''); WeUtility::logging('IamInMergeFile', $target_file . $head_file); } else { WeUtility::logging('NoAvatarFile', $fans['avatar']); } } } else { WeUtility::logging('NOT merge avatar and nickname', $from_user); } } WeUtility::logging('step upload 1', ''); $media_id = $weapi->uploadImage($target_file); WeUtility::logging('step upload 1 done', ''); WeUtility::logging('genImage', $media_id); if (!empty($media_id)) { $nowtime = time(); pdo_query("INSERT INTO " . tablename('core_attachment') . " (uniacid,uid,filename,attachment,type,createtime) VALUES " . "({$_W['weid']}, {$_W['weid']}, 'head_cache', '{$att_head_cache_file}', 1, {$nowtime})," . "({$_W['weid']}, {$_W['weid']}, 'post_cache', '{$att_target_file}', 1, {$nowtime})"); } else { // in case 45009, api freq out of limit ; $ret = $weapi->sendText($from_user, "专属二维码已经生成, 点击这里:<a href='{$target_file_url}'>查看您的专属二维码</a>, 保存到手机后转发给好友就能拿话费!"); } return array($media_id, $target_file_url); }
exit; } if ($do == 'setting') { $name = $_GPC['m']; $module = $modulelist[$name]; if (empty($module)) { message('抱歉,你操作的模块不能被访问!'); } if (!uni_user_module_permission_check($name . '_settings', $name)) { message('您没有权限进行该操作'); } define('CRUMBS_NAV', 1); $ptr_title = '参数设置'; $module_types = module_types(); $config = $module['config']; $obj = WeUtility::createModule($module['name']); $obj->settingsDisplay($config); exit; } if ($do == 'shortcut') { $name = $_GPC['m']; $module = $modulelist[$name]; if (empty($module)) { message('抱歉,你操作的模块不能被访问!'); } $setting = uni_setting($_W['uniacid'], array('shortcuts')); $shortcuts = $setting['shortcuts']; if (!is_array($shortcuts)) { $shortcuts = array(); } if ($_GPC['shortcut'] == '1') {