/** * 邀请注册 */ function index() { $uid = intval($GLOBALS['uid']); if (!$uid) { header("Location:" . WEBURL); exit; } $_uid = get_cookie('_uid'); if ($_uid && is_numeric($_uid)) { //已经登录的用户不算成功推广的下线 header("Location:" . WEBURL); exit; } else { $times = SYS_TIME + 86400 * 7; set_cookie('ppc_uid', $uid, $times); $db = load_class('db'); $ip = get_ip(); $db->insert('ppc', array('uid' => $uid, 'addtime' => SYS_TIME, 'ip' => $ip)); //后台配置推广页面跳转地址 $setting = get_cache('setting', 'ppc'); if (empty($setting['redirect_url'])) { MSG('请在后台配置推广页面地址'); } header("Location:" . $setting['redirect_url']); } }
/** * 获取配置中的配置内容content * @param string $cKey 配置key */ function get_pro_config_content($cKey) { $conf = get_cache('ProConfig'); $conf = $conf[$cKey]; $content = $conf['content']; return unserialize($content); }
public function active_email() { if (!isset($GLOBALS['auth']) || !isset($GLOBALS['uid']) || !isset($GLOBALS['email']) || !isset($GLOBALS['t'])) { MSG('验证失败!'); } $auth = $GLOBALS['auth']; $uid = intval($GLOBALS['uid']); $email = $GLOBALS['email']; $t = $GLOBALS['t']; if (decode($auth) != $t . $uid . $email) { MSG('验证失败!'); } if ($t < SYS_TIME - 3600) { MSG('邮件验证超时,请重新验证!', 'index.php?m=member&f=index&v=edit_email'); } $this->db->update('member', array('ischeck_email' => 1), array('uid' => $uid)); $point_config = get_cache('point_config'); $credit_api = load_class('credit_api', 'credit'); $keyid = 'em' . $uid; //验证邮箱,只送一次 if (!$credit_api->get($keyid)) { $credit_api->handle($uid, '+', $point_config['email_check'], '验证邮箱:' . $email, '', $keyid); } MSG('邮件验证成功!', 'index.php?m=member&f=index&v=account_safe'); }
function track($data) { $cache_key = 'click_' . $data['h'] . ''; if (MAD_TRACK_UNIQUE_CLICKS) { $cache_result = get_cache($cache_key); if ($cache_result && $cache_result == 1) { return false; } else { set_cache($cache_key, 1, 500); } } if (!is_numeric($data['zone_id'])) { return false; } /* Get the Publication */ $query = "SELECT publication_id FROM md_zones WHERE entry_id='" . $data['zone_id'] . "'"; $zone_detail = simple_query_maindb($query, true, 1000); if (!$zone_detail or $zone_detail['publication_id'] < 1) { return false; } switch ($data['type']) { case 'normal': reporting_db_update($zone_detail['publication_id'], $data['zone_id'], $data['campaign_id'], $data['ad_id'], '', 0, 0, 0, 1); break; case 'network': reporting_db_update($zone_detail['publication_id'], $data['zone_id'], $data['campaign_id'], '', $data['network_id'], 0, 0, 0, 1); break; case 'backfill': reporting_db_update($zone_detail['publication_id'], $data['zone_id'], '', '', $data['network_id'], 0, 0, 0, 1); break; } }
public function listing() { $where = ''; $keywords = ''; $cid = intval($GLOBALS['cid']); $categorys = get_cache('category', 'content'); $modelid = $categorys[$cid]['modelid']; $model_r = $this->db->get_one('model', array('modelid' => $modelid)); $master_table = $model_r['master_table']; $where = "cid='{$cid}'"; if (isset($GLOBALS['keywords'])) { if (isset($GLOBALS['charset']) && strtolower(CHARSET) == 'gbk') { $keywords = iconv('utf-8', 'gbk', $GLOBALS['keywords']); } else { $keywords = $GLOBALS['keywords']; } $keywords = trim(sql_replace($keywords)); // $master_table = 'content_share'; if (isset($GLOBALS['keytype']) && $GLOBALS['keytype'] == 'username') { $where .= " AND `publisher` = '{$keywords}'"; } else { $GLOBALS['keytype'] = 'keywords'; $where .= "AND `title` LIKE '%{$keywords}%'"; } } $page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1; $result = $this->db->get_list($master_table, $where, '*', 0, 10, $page, 'id DESC'); $form = load_class('form'); include $this->template('relation_listing'); }
/** * 支付宝: 跳转到支付界面 * @param $config */ function alipay_redirect($config) { /* * @var Omnipay\Alipay\WapExpressGateway */ try { // $gateway = \Omnipay\Omnipay::create('Alipay_WapExpress') $gateway = new \Omnipay\Baifu\ExpressGateway(); $gateway->setPartner($config['partner']); $gateway->setKey($config['key']); $gateway->setNotifyUrl($config['notify_url']); $gateway->setReturnUrl($config['return_url']); $gateway->setCertPath($config['cert_path']); $opts = array('sp_pass_through' => '%7B%22offline_pay%22%3A1%7D', 'subject' => $_GET['subject'], 'description' => '暂无', 'total_fee' => $_GET['total_fee'], 'out_trade_no' => $_GET['out_trade_no']); $res = $gateway->purchase($opts)->send(); // $res = $gateway->completePurchase($opts)->send(); // $abc = [ 'result' => $res->getTransactionReference(), 'trade_status' => $res->isTradeStatusOk()]; // var_dump($abc); $cache = get_cache(); $cache->save($_GET['out_trade_no'], $opts); $res->redirect(); // header("Content-type: application/json"); // echo json_encode([ // 'url' => $res->getRedirectUrl(), // 'opts' => $opts, // 'config' => $config, // 'info_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/demo/info.php?out_trade_no=' . $out_trade_no, // ]); } catch (\Exception $e) { var_dump($e->getMessage()); } }
function list_centers() { //HTML flow $html = ""; //Get centers from DWBN or cache if (@$_GET['source'] == 'cache') { //Get from cache $members = get_cache(); //Be beware! It's cache $html .= "<span class='warning'>Pay attention! This is from cache!</span><br/><br/>"; } else { //Collect information from DWBN $members = dwbn_collect(); } //Show collected information{ //Number of centers $html .= "Number of centers: " . count($members) . "<br/><br/>"; //Example of center{ $html .= "<pre>" . print_r($members[0], true) . "</pre><br/>"; //} //Centers info foreach ($members as $center) { $html .= $center['email'] . "<br/>"; } //} //Return return $html; }
public function editAction() { $userid = (int) $this->get('userid'); $data = $this->db->setTableName('admin')->find($userid); $auth = string2array($data['auth']); $cats = get_cache('category'); if (empty($data)) { $this->show_message('该用户不存在', 2); } if ($this->post('submit')) { $data = $this->post('data'); if (!empty($data['password'])) { if (strlen($data['password']) < 6) { $this->show_message('密码最少6位数', 2, 1); } $data['password'] = md5(md5($data['password'])); } else { unset($data['password']); } $auth = $this->post('auth'); $data['auth'] = array2string($auth); $this->db->setTableName('admin')->update($data, 'userid=?', $userid); $this->cacheAction(); $this->show_message('修改成功', 1); } include $this->admin_tpl('admin_add'); }
/** * 支付宝: 跳转到支付界面 * @param $config */ function alipay_redirect($config) { /* * @var Omnipay\Alipay\WapExpressGateway */ try { // $gateway = \Omnipay\Omnipay::create('Alipay_WapExpress') $gateway = new \Omnipay\Alipay\WapExpressGateway(); $gateway->setPartner($config['partner']); $gateway->setKey($config['key']); $gateway->setSellerEmail($config['seller_email']); $gateway->setNotifyUrl($config['notify_url']); $gateway->setReturnUrl($config['return_url']); $gateway->setCancelUrl($config['cancel_url']); $opts = array('subject' => $_GET['subject'], 'description' => '暂无', 'total_fee' => $_GET['total_fee'], 'out_trade_no' => $_GET['out_trade_no']); $res = $gateway->purchase($opts)->send(); $cache = get_cache(); $cache->save($_GET['out_trade_no'], $opts); $res->redirect(); // header("Content-type: application/json"); // echo json_encode([ // 'url' => $res->getRedirectUrl(), // 'opts' => $opts, // 'config' => $config, // 'info_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/demo/info.php?out_trade_no=' . $out_trade_no, // ]); } catch (\Exception $e) { var_dump($e->getMessage()); } }
public function show() { load_function('common', 'member'); $siteconfigs = $this->siteconfigs; $id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : MSG(L('parameter_error')); $categorys = get_cache('category', 'content'); //查询数据 $models = get_cache('model_guestbook', 'model'); $model_r = $models[15]; $master_table = $model_r['master_table']; $data = $this->db->get_one($master_table, array('id' => $id)); require get_cache_path('content_format', 'model'); $form_format = new form_format($model_r['modelid']); $data = $form_format->execute($data); foreach ($data as $_key => $_value) { ${$_key} = $_value['data']; } $_template = TPLID . ':show'; $styles = explode(':', $_template); $project_css = isset($styles[0]) ? $styles[0] : 'default'; $_template = isset($styles[1]) ? $styles[1] : 'show'; $seo_title = $title . '_' . $siteconfigs['sitename']; $seo_keywords = !empty($keywords) ? implode(',', $keywords) : ''; $seo_description = $remark; $this->db->update($master_table, "`hits`=(`hits`+1)", array('id' => $id)); include T('guestbook', 'show'); }
function notify_callback($config, $get, $raw_post) { $cache = get_cache(); try { $gateway = new \Omnipay\Wechat\ExpressGateway(); $gateway->setAppId($config['app_id']); $gateway->setKey($config['pay_sign_key']); $gateway->setPartner($config['partner']); $gateway->setPartnerKey($config['partner_key']); $cache->save(LAST_NOTIFY_CACHE_KEY, func_get_args()); $response = $gateway->completePurchase(array('request_params' => $get, 'body' => $raw_post))->send(); if ($response->isSuccessful() && $response->isTradeStatusOk()) { //todo success $serial = $cache->fetch($get['out_trade_no']); $serial['notify'] = array('status' => 'success', 'param' => http_build_query($get), 'body' => $raw_post); $data = json_decode(json_encode(simplexml_load_string($raw_post, 'SimpleXMLElement', LIBXML_NOCDATA)), true); $cache->save($get['out_trade_no'], $serial); $cache->save(LAST_NOTIFY_CACHE_KEY, array('param' => http_build_query($get), 'body' => $raw_post, 'data' => $data, 'status' => $response->getMessage())); $cache->delete(LAST_ERROR_CACHE_KEY); die($response->getMessage()); // die('success'); } else { die($response->getMessage()); } } catch (\Exception $e) { $cache->save(LAST_ERROR_CACHE_KEY, $e->getLine() . ': ' . $e->getMessage()); die('exception: ' . $e->getLine() . ' - ' . $e->getMessage()); } }
/** * 列表标签 * * @param $c * @return array */ public function listing($c) { if (!isset($c['keyid'])) { return array(); } if (isset($c['urlrule'])) { $urlrule = $c['urlrule']; } else { $urlrule = 'javascript:dp_page({$page});'; } $rule_arr = array('page' => $c['page']); $result = $this->db->get_list('dianping', array('keyid' => $c['keyid']), '*', $c['start'], $c['pagesize'], $c['page'], 'id DESC', '', '', $urlrule, $rule_arr); $groups = get_cache('group', 'member'); $newdata = array(); foreach ($result as $rs) { if ($rs['uid']) { $r = $this->db->get_one('member', array('uid' => $rs['uid'])); $rs['username'] = $r['username']; $rs['groupid'] = $r['groupid']; $rs['groupname'] = $groups[$r['groupid']]['name']; } $newdata[] = $rs; } if ($c['page']) { $this->pages = $this->db->pages; $this->number = $this->db->number; } return $newdata; }
function clean_terms($terms) { # if we've got a cached version of the results from this function use it... $id = md5(implode(',', $terms)); $cached = get_cache($id); if ($cached) { return unserialize($cached); } # go through the terms in sequence to see what the counts with non-duplicated posts are... $posts_seen = array(); foreach ($terms as $term => $freq) { $term = mysql_escape_string($term); $query = "SELECT DISTINCT post_id FROM terms WHERE term='{$term}'"; $results = mysql_query($query); while ($row = mysql_fetch_assoc($results)) { $post_id = $row['post_id']; if ($posts_seen[$post_id]) { $terms[$term]--; if ($terms[$term] <= 0) { unset($terms[$term]); } } $posts_seen[$post_id] = true; } } arsort($terms); # cache results $cached = serialize($terms); cache($id, $cached); return $terms; }
/** * 推荐的用户 */ public function listing() { $page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1; $page = max($page, 1); $uid = $this->memberinfo['uid']; $categorys = get_cache('category', 'content'); $publisher = $this->memberinfo['username']; $result_rs = $this->db->get_list('friend_elite', "`cityid` IN (0)", '*', 0, 20, $page, 'id DESC'); $result = array(); foreach ($result_rs as $r) { $r['member_info'] = $this->db->get_one('member', array('uid' => $r['uid'])); $v1 = $this->db->get_one('myfriend', array('myuid' => $r['uid'], 'uid' => $uid)); $v2 = $this->db->get_one('myfriend', array('myuid' => $uid, 'uid' => $r['uid'])); if ($v2 && $v1) { //相互关注 $r['rtype'] = 1; } elseif ($v2) { $r['rtype'] = 2; //已添加 } elseif ($v1) { $r['rtype'] = 3; //请求添加 } $result[] = $r; } $pages = $this->db->pages; $total = $this->db->number; include $this->template('friend_listing'); }
public function cache_select() { $uid = $_SESSION['uid']; if (isset($GLOBALS['setcache'])) { $ids = get_cache('cache_all-' . $uid); } else { if (!isset($GLOBALS['ids']) || empty($GLOBALS['ids'])) { $where = array('keyid' => 'cache_all'); $result = $this->db->get_list('setting', $where, '*', 0, 100); $ids = array(); foreach ($result as $r) { $ids[] = $r['id']; } } else { $ids = array_map('intval', $GLOBALS['ids']); } set_cache('cache_all-' . $uid, $ids); } if (empty($ids)) { MSG('缓存更新完成', '?m=core&f=cache_all&v=index' . $this->su(), 2000); } $id = array_shift($ids); $r = $this->db->get_one('setting', array('id' => $id)); $caches = load_class($r['f'], $r['m']); if ($caches->{$r}['v']()) { set_cache('cache_all-' . $uid, $ids); MSG($r['data'] . L('update success'), '?m=core&f=cache_all&v=cache_select&setcache=1&' . $this->su(), 200); } else { MSG(L('operation failure')); } }
function listing() { // query db version $dbversion = $this->db->version(); //$total_member $total_member = $this->db->count_result('member'); $regtime = strtotime(date('Y-m-d')); $today_member = $this->db->count_result('member', "regtime>{$regtime}"); $modellist = get_cache('model_content', 'model'); $total_number = $this->db->count_result('content_share', "`status`=9"); $status_number = $this->db->count_result('content_share', "`status`<4"); foreach ($modellist as $model) { $master_table = $model['master_table']; if ($master_table == 'content_share') { continue; } $tmp = $this->db->count_result($master_table, "`status`=9"); $tmp2 = $this->db->count_result($master_table, "`status`<4"); $total_number += $tmp; $status_number += $tmp2; } ob_start(); include $this->template('listing'); $content = ob_get_contents(); ob_end_clean(); echo $content; }
/** * */ public function init() { $id = intval($GLOBALS['id']); $siteid = intval($GLOBALS['siteid']); $res = $this->db->get_one('copyfrom', array('fromid' => $id)); $siteconfigs = $this->siteconfigs; $seo_title = $siteconfigs['sitename']; $seo_keywords = $siteconfigs['seo_keywords']; $seo_description = $siteconfigs['seo_description']; $categorys = get_cache('category', 'content'); $cids = array(); foreach ($categorys as $cid => $r) { if ($r['siteid'] == $siteid) { $cids[] = $cid; } } if (!empty($cids)) { $cids = implode(',', $cids); $where = "`copyfrom`='" . $res['fromid'] . "' AND `status`=9 AND `cid` IN ({$cids})"; $rs = $this->db->get_list('content_share', array('copyfrom' => $id), '*', 0, 20, 0, 'id DESC'); } else { MSG('参数错误'); } $rs = $this->db->get_list('content_share', $where, '*', 0, 100, 0, 'id DESC'); include T('content', 'copyfrom', TPLID); }
/** * 首页 */ public function index() { $siteconfigs = $this->siteconfigs; $seo_title = $siteconfigs['sitename']; $seo_keywords = $siteconfigs['seo_keywords']; $seo_description = $siteconfigs['seo_description']; $categorys = get_cache('category', 'content'); $city = substr(rtrim($_SERVER["REQUEST_URI"], '/'), 6); $hotcity = hotcity(0); if (empty($city)) { $cityid = get_cookie('cityid'); $city = $categorys[$cityid]['catdir']; //$table, $where = '', $field = '*', $startid = 0, $pagesize $category_result = $this->db->get_list('category', array('modelid' => 3), '*', 0, 1000); include T('city', 'index', TPLID); } else { foreach ($categorys as $cid => $rs) { if ($rs['catdir'] == $city) { $cityid = $cid; set_cookie('cityname', $rs['name'], SYS_TIME + 86400 * 7); set_cookie('cityid', $cityid, SYS_TIME + 86400 * 7); $cityname = $rs['name']; break; } } //header("Location:http://www.h1jk.cn/list-69/"); include T('content', 'index-city', TPLID); } }
function __construct() { $this->member = load_class('member', 'member'); load_function('common', 'member'); $this->member_setting = get_cache('setting', 'member'); parent::__construct(); }
public function surplus($cid, $id) { $category = get_cache('category_' . $cid, 'content'); $models = get_cache('model_content', 'model'); $modelid = $category['modelid']; $master_table = $models[$modelid]['master_table']; $this->db->update($master_table, "`surplus`=(`surplus`-1)", array('id' => $id)); }
public function config_url_view($date) { global $_CACHE; get_cache('version'); foreach ($_CACHE['version'] as $row) { return $row[$date]; } }
/** * * 初始化接口类 * @param int $uid 用户id * @param int $sms_pid 产品id * @param string $sms_key 密钥 */ public function __construct() { $this->smsapi_url = 'http://sms.phpip.com/api.php?'; $sms_config = get_cache('sms_config', 'sms'); $this->sms_uid = $sms_config['sms_uid']; $this->sms_pid = $sms_config['sms_pid']; $this->sms_key = $sms_config['sms_passwd']; }
function __construct() { $this->member = load_class('member', M); $this->db = load_class('db'); $this->group = get_cache('group', M); $this->model = $this->db->get_list('model', '`m`="member"', 'modelid,name,attr_table', 0, 200, 0, '', '', 'modelid'); $this->setting = get_cache('setting', 'member'); }
/** * 公共模型搜索 */ public function init() { $siteconfigs = $this->siteconfigs; $seo_title = '搜索 - ' . $siteconfigs['sitename']; $seo_keywords = $siteconfigs['seo_keywords']; $seo_description = $siteconfigs['seo_description']; $categorys = get_cache('category', 'content'); $keywords = sql_replace($GLOBALS['keywords']); $starttime = isset($GLOBALS['starttime']) ? intval($GLOBALS['starttime']) : 0; $runtime = ''; $history_result = array(); $search_cookie = get_cookie('search_cookie'); $history_result = explode('||', $search_cookie); $models = get_cache('model_content', 'model'); $modelid = isset($GLOBALS['modelid']) ? intval($GLOBALS['modelid']) : 0; if ($keywords) { if ($starttime) { $stime = SYS_TIME - $starttime * 86400; $where = "`status`=9 AND (`addtime`>{$stime} AND `title` LIKE '%{$keywords}%') or (`addtime`>{$stime} AND `remark` LIKE '%{$keywords}%')"; } else { $where = "`status`=9 AND `title` LIKE '%{$keywords}%' or `remark` LIKE '%{$keywords}%'"; } $page = intval($GLOBALS['page']); if ($modelid) { $tablename = $models[$modelid]['master_table']; } else { $tablename = 'content_share'; } $result = $this->db->get_list($tablename, $where, '*', 0, 20, $page, 'id DESC'); $result_pages = $this->db->pages; $total_number = $this->db->number; if ($search_cookie) { if (!in_array($keywords, $history_result)) { $search_cookie = $keywords . "||" . $search_cookie; } } else { $search_cookie = $keywords; } set_cookie('search_cookie', $search_cookie, SYS_TIME + 86400 * 30); $_endTime = microtime(true); $runtime = $_endTime - $GLOBALS['_startTime']; $runtime = sprintf("%.3f", $runtime); } else { $result = array(); $page = 0; $result_pages = ''; $total_number = 0; $runtime = '0.00001'; } if ($search_cookie) { if (count($history_result) > 10) { array_pop($history_result); $search_cookie = implode('||', $history_result); set_cookie('search_cookie', $search_cookie, SYS_TIME + 86400 * 30); } } include T('content', 'search', TPLID); }
function tpl_function_qishi_subsite($params, &$smarty) { $subsite = get_cache('subsite'); $list = array(); foreach ($subsite as $key => $value) { $list[] = $value; } $smarty->assign('list', $list); }
function get_from_cache($id) { $file = get_cache($id); if ($file) { return file_get_contents($file); } else { return false; } }
function __construct($modelid) { $this->db = load_class('db'); $this->tablepre = $this->db->tablepre; $this->modelid = $modelid; $this->fields = get_cache('field_' . $modelid, 'model'); $this->extdata = ''; //TODO 初始化勾子,在程序提交前处理 }
function __construct($modelid) { $this->db = load_class('db'); $this->tablepre = $this->db->tablepre; $this->modelid = $modelid; $this->fields = get_cache('field_' . $modelid, 'model'); $this->extdata = ''; $this->hook = load_class('hook'); }
function __construct() { $this->member = load_class('member', 'member'); $this->setting = get_cache('setting', 'member'); parent::__construct(); $this->payments_res = $this->db->get_list('payment', "id>1 AND status=1"); $this->payments = key_value($this->payments_res, 'id', 'name'); $this->status_arr = array(0 => '回收站', 1 => '交易成功', 2 => '交易失败', 3 => '交易错误', 4 => '交易超时', 5 => '交易取消', 6 => '等待用户付款', 7 => '待商家发货', 8 => '待用户确认收货'); }
/** * 链接首页 */ public function init() { $siteconfigs = $this->siteconfigs; $seo_title = '友情链接-' . $siteconfigs['sitename']; $seo_keywords = '友情链接,' . $siteconfigs['seo_keywords']; $seo_description = $siteconfigs['seo_description']; $categorys = get_cache('category', 'content'); include T('link', 'index', TPLID); }