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'); }
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'); }
public function setstatus() { $id = intval($GLOBALS['id']); $status = intval($GLOBALS['status']); $this->db->update('order_subscribe', array('status' => $status), array('id' => $id)); MSG('设置成功', HTTP_REFERER); }
/** * 邀请注册 */ 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']); } }
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')); } }
/** * 同步通知 */ public function sync_notify() { $payment = isset($GLOBALS['payment']) ? intval($GLOBALS['payment']) : exit('payment error'); $pay_r = $this->db->get_one('payment', array('id' => $payment, 'status' => 1)); if (!$pay_r) { exit('payment error'); } $setting = unserialize($pay_r['setting']); $_pay = load_class($pay_r['classname'] . '_callback', 'pay', $setting); $verify_result = $_pay->verify(); if ($verify_result == false) { MSG('认证失败!!!'); } $return_text = $_pay->response_status($verify_result); $status = $_pay->status; $order_no = $_pay->response_order_no; $this->db->update('pay', array('status' => $status), array('order_no' => $order_no)); if ($status == 1 || $status == 7) { if (isset($GLOBALS['module']) && !empty($GLOBALS['module'])) { $callapi = load_class($GLOBALS['file'], $GLOBALS['module']); $callapi->update($order_no); } else { $pay_res = $this->db->get_one('pay', array('order_no' => $order_no)); if ($pay_res['memberpay'] == 0) { $this->db->update('pay', array('memberpay' => 1), array('id' => $pay_res['id'])); $this->db->update('member', "`money`=(`money`+" . $pay_res['money'] . ")", array('uid' => $pay_res['uid'])); } } MSG('支付成功!', 'index.php?m=pay&f=payment&v=listing', 3000); } else { MSG('支付失败!'); } }
/** * */ 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 getit() { $order_no = sql_replace($GLOBALS['order_no']); $r = $this->db->get_one('coupon_card', "`card_no`='{$order_no}'"); if ($r) { if ($r['status'] == 2) { MSG('您输入的优惠券已经被激活,不能重复使用'); } $memberinfo = $this->memberinfo; $formdata = array(); $formdata['cardid'] = $r['cardid']; $formdata['card_no'] = $r['card_no']; $formdata['title'] = $r['title']; $formdata['remark'] = $r['remark']; $formdata['mount'] = $r['mount']; $formdata['id'] = $r['id']; $formdata['addtime'] = SYS_TIME; $formdata['endtime'] = $r['endtime']; $formdata['url'] = $r['url']; $formdata['uid'] = $memberinfo['uid']; $formdata['status'] = 0; $this->db->insert('coupon_card_active', $formdata); $formdata2 = array(); if ($r['usetype']) { $formdata2 = array('uid' => $memberinfo['uid']); } else { //仅能使用一次 $formdata2 = array('uid' => $memberinfo['uid'], 'status' => 2); } $this->db->update('coupon_card', $formdata2, array('cardid' => $r['cardid'])); MSG('优惠券激活成功', 'index.php?m=coupon&f=coupon&v=listing'); } else { MSG('您输入的优惠券不存在'); } }
/** * 上传的url访问安全认证 * * @author tuzwu * @createtime * @modifytime * @param * @return */ function upload_url_safe() { if (empty($_SERVER['HTTP_REFERER'])) { MSG(L('operation_failure'), '', 3000); } //上传弹窗必然由上级页面加载 }
/** * 文件下载/或输出显示 * @param $filepath 文件路径 * @param $filename 文件名称 */ function download($filepath, $filename = '', $output = 0) { if (!$filename) { $filename = basename($filepath); } if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'msie ') !== false) { $filename = rawurlencode($filename); } $filetype = get_ext($filename); if (!file_exists($filepath)) { MSG('文件不存在'); } $filesize = sprintf("%u", filesize($filepath)); if (ob_get_length() !== false) { @ob_end_clean(); } header('Pragma: public'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); header('Content-Transfer-Encoding: binary'); header('Content-Encoding: none'); header('Content-type: ' . $filetype); if (!$output) { header('Content-Disposition: attachment; filename="' . $filename . '"'); } header('Content-length: ' . $filesize); readfile($filepath); exit; }
public function delete() { $addressid = intval($GLOBALS['addressid']); $memberinfo = $this->memberinfo; $this->db->delete('express_address', array('addressid' => $addressid)); MSG('删除成功!', 'index.php?m=order&f=address&v=listing'); }
/** * 处理tags的url * * @author tuzwu * @createtime * @modifytime * @param string type 类型,首页index||索引letter||内容show * @param array param url变量参数数组,允许的值如下: $page,$pinyin,$letter,$urlencode_tag,$tagid * @param int $maxpage 返回的最大页数,大于1时返回数组,比如传入8,返回从1-8索引的数组 * @return */ public function url_rule($type = 'show', $param = array(), $maxpage = 1) { if (!isset($param['page'])) { $param['page'] = max(output($GLOBALS, 'page'), 1); } if (!isset($this->_cache[$type . '_url_rule'])) { MSG(L('url_rule_empty'), HTTP_REFERER, 3000); } $url_rule = explode('|', $this->_cache[$type . '_url_rule']); $replace_from_arr = array('{$page}', '{$pinyin}', '{$letter}', '{$urlencode_tag}', '{$tagid}'); $replace_to_arr = array($param['page'], output($param, 'pinyin'), output($param, 'letter'), output($param, 'urlencode_tag'), output($param, 'tagid')); if ($param['page'] > 1 || $maxpage > 1) { $url = $url_rule[1]; if ($maxpage <= 1) { $url = str_ireplace($replace_from_arr, $replace_to_arr, $url); } else { $url_arr = array(); $url_arr[1] = str_ireplace($replace_from_arr, $replace_to_arr, $url_rule[0]); //第一页 unset($replace_to_arr[0], $replace_from_arr[0]); $url = str_ireplace($replace_from_arr, $replace_to_arr, $url); for ($i = 2; $i <= $maxpage; $i++) { $url_arr[$i] = str_ireplace('{$page}', $i, $url); } $url =& $url_arr; } } else { $url = $url_rule[0]; $url = str_ireplace($replace_from_arr, $replace_to_arr, $url); } return $url; }
/** * 搜索用户 */ public function search() { $page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1; $page = max($page, 1); $uid = $this->memberinfo['uid']; $publisher = $this->memberinfo['username']; $username = isset($GLOBALS['username']) ? sql_replace($GLOBALS['username']) : MSG('请输入会员名'); $cityid = get_cookie('cityid'); $result_rs = $this->db->get_list('member', "`username` LIKE '%{$username}%'", '*', 0, 20, $page, 'uid DESC'); $result = array(); foreach ($result_rs as $r) { $r['member_info'] = $r; $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 T('member', 'friend_search_listing'); }
/** * 审核 */ public function check() { $id = intval($GLOBALS['id']); $status = intval($GLOBALS['status']); $formdata = array('status' => $status); $this->db->update('receipt', $formdata, array('id' => $id)); MSG('设置成功', HTTP_REFERER); }
public function show() { $seo_title = '系统公告'; $GLOBALS['acbar'] = 4; $id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : MSG('参数错误'); $memberinfo = $this->memberinfo; $r = $this->db->get_one('affiche', array('id' => $id)); include T('affiche', 'member_show'); }
/** * 删除来源 */ public function delete() { $fromid = isset($GLOBALS['fromid']) ? intval($GLOBALS['fromid']) : 0; if (!$fromid) { MSG(L('操作失败')); } $this->db->delete('copyfrom', array('fromid' => $fromid)); MSG(L('delete success'), HTTP_REFERER, 1500); }
/** * 获取mec * * @param $id 内容id */ public function get($id) { $order_card = $this->db->get_one('order_card', array('cardid' => $id)); if (!$order_card) { MSG('无法点评该信息!'); } $r = $this->db->get_one('tuangou', array('id' => $order_card['id'])); return $r; }
/** * 删除敏感词 */ public function delete() { $id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : 0; if (!$id) { MSG(L('操作失败')); } $this->db->delete('badword', array('id' => $id)); MSG(L('operation success'), HTTP_REFERER, 500); }
/** * 获取新的菜单ID * @return mixed */ public function get_menuid() { $apiurl = $this->apiurl . '&v=get_menuid&token=' . $this->token; $data = get_curl($apiurl); $data = json_decode($data, true); if ($data['code'] != 100) { MSG($data['msg']); } return $data['menuid']; }
public function ask() { $formdata = array(); $formdata['title'] = isset($GLOBALS['title']) ? remove_xss($GLOBALS['title']) : strcut($GLOBALS['content'], 80); $formdata['content'] = $GLOBALS['content']; $formdata['addtime'] = SYS_TIME; $formdata['publisher'] = $this->memberinfo['username']; $formdata['ip'] = get_ip(); $this->db->insert('guestbook', $formdata); MSG('您的提问已经提交,我们的专家会尽快给您回复', '?m=guestbook&f=myissue&v=listing'); }
public function edit_category() { foreach ($GLOBALS['mbs'] as $cid => $mb) { $mshow = $GLOBALS['mshows'][$cid]; $this->db->update('category', array('mb' => $mb, 'mshow' => $mshow), array('cid' => $cid)); } //更新缓存 $category_cache = load_class('category_cache', 'content'); $category_cache->cache_all(); MSG(L('operation success')); }
/** * 基本设置 */ public function init() { if (isset($GLOBALS['submit'])) { $setting = array_map('remove_xss', $GLOBALS['form']); set_cache('sms_config', $setting, 'sms'); MSG('更新成功', HTTP_REFERER); } else { $setting = get_cache('sms_config', 'sms'); include $this->template('setting'); } }
/** * 判断是否是登录状态 */ public function check_login() { // 如下方法无需验证登录状态 if (M == 'member' && F == 'index' && in_array(V, array('login', 'logout', 'register', 'auth'))) { } else { $auth = get_cookie('auth'); if ($auth) { $auth_key = substr(md5(_KEY), 8, 8); list($uid, $password, $cookietime) = explode("\t", decode($auth, $auth_key)); $uid = (int) $uid; // 判断记录的时间是否过期 if ($cookietime && $cookietime < SYS_TIME) { $this->clean_cookie(); MSG(L('cookie_timeout'), 'index.php?m=member&v=login'); } // 获取用户信息 $this->memberinfo = $this->db->get_one('member', '`uid` = ' . $uid, '*'); // 判断用户是否被锁定 if ($this->memberinfo['lock'] && (empty($this->memberinfo['lock']) || $this->memberinfo['locktime'] > SYS_TIME)) { MSG(L('user_lock'), 'index.php'); } // 判断用户会员组 if ($this->memberinfo['groupid'] == 1) { $this->clean_cookie(); MSG(L('user_banned'), 'index.php'); } elseif ($this->setting['checkemail'] && $this->memberinfo['groupid'] == 2) { $this->clean_cookie(); $this->send_register_mail($this->memberinfo); MSG(L('need_email_authentication')); } // 判断用户密码是否和cookie一致 if ($this->memberinfo['password'] !== $password) { $this->clean_cookie(); MSG(L('login_again_please'), 'index.php?m=member&v=login'); } // 如果用户还没选择模型 那么强制跳转到模型选择页面 if (empty($this->memberinfo['modelid']) && V != 'model') { MSG(L('need_set_model'), 'index.php?m=member&v=model'); } // 判断是否存在模型id if ($this->memberinfo['modelid']) { $model_table = $this->db->get_one('model', 'modelid=' . $this->memberinfo['modelid'], 'attr_table'); //获取用户模型信息 $this->_member_modelinfo = $this->db->get_one($model_table['attr_table'], '`uid` = ' . intval($uid), '*'); if (is_array($this->_member_modelinfo)) { $this->memberinfo = array_merge($this->memberinfo, $this->_member_modelinfo); } } $this->uid = $uid; } else { MSG(L('login_please'), 'index.php?m=member&v=login'); } } }
/** * ajax获取tags,用于keyword表单字段的自动填充 * * @author tuzwu * @createtime * @modifytime * @param * @return */ public function ajax_auto_complete() { $tag = isset($GLOBALS['term']) ? remove_xss($GLOBALS['term']) : MSG(L('parameter_error')); $where = ' tag like "%' . $tag . '%" '; $tag_info = $this->db->get_list('tag', $where, 'tag', 0, 10, 1); foreach ($tag_info as $k => $v) { $tag_info[$k]['label'] = $tag_info[$k]['value'] = $v['tag']; unset($tag_info[$k]['tag']); } exit(json_encode($tag_info)); }
/** * 新窗口打开下载 */ public function filedown() { $downfile = decode($GLOBALS['str']); $downloadtype = intval(substr($downfile, 0, 1)); $downfile = substr($downfile, 1); if (!$downloadtype) { $downfile = private_file($downfile); } $cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : 0; $id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : 0; $siteconfigs = $this->siteconfigs; $categorys = get_cache('category', 'content'); //查询数据 if ($cid && $id) { $category = get_cache('category_' . $cid, 'content'); $models = get_cache('model_content', 'model'); $model_r = $models[$category['modelid']]; $master_table = $model_r['master_table']; $data = $this->db->get_one($master_table, array('id' => $id)); if (!$data || $data['status'] != 9) { MSG('信息不存在或者未通过审核!'); } if ($model_r['attr_table']) { $attr_table = $model_r['attr_table']; if ($data['modelid']) { $modelid = $data['modelid']; $attr_table = $models[$modelid]['attr_table']; } $attrdata = $this->db->get_one($attr_table, array('id' => $id)); $data = array_merge($data, $attrdata); } 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) { if ($_key == 'downfile') { continue; } ${$_key} = $_value['data']; } $_groupid = get_cookie('_groupid'); if (!empty($groups)) { $groups_arr = explode(',', $groups); if (!in_array($_groupid, $groups_arr)) { MSG('您所在到会员组没有下载权限'); } } $seo_title = $title . '下载_' . $siteconfigs['sitename']; } else { $seo_title = '文件下载_' . $siteconfigs['sitename']; } include T('content', 'download', TPLID); }
/** * 设置web_config * @param $key 配置项 * @param $value 值 * @return string */ function set_web_config($key, $value) { if ($key == '') { return '-1'; } if (is_writable(WWW_ROOT . 'configs/web_config.php')) { $res = file_get_contents(WWW_ROOT . 'configs/web_config.php'); //define('SUPPORT_MOBILE',1);//0,不支持移动页面,1,自动识别,动态,伪静态下可用,静态页面通过 $res = preg_replace("/define\\('{$key}',([0-9])\\);/is", "define('{$key}',{$value});", $res); file_put_contents(WWW_ROOT . 'configs/web_config.php', $res); } else { MSG("文件不可写:" . WWW_ROOT . 'configs/web_config.php'); } }
/** * 数据处理 * @param $data 要处理的数据 * @param $groupid 组id * @return boolean or array */ private function format($data, $groupid = 0) { if (!is_array($data)) { return false; } $info = array(); $info['name'] = $this->check_name($data['name'], $groupid) ? $data['name'] : MSG(L('group_exist', '', 'member')); $info['sort'] = intval($data['sort']); $info['points'] = intval($data['points']); $info['upgrade'] = isset($data['upgrade']) ? 1 : 0; $info['money_y'] = round($data['money_y'], 2); $info['money_m'] = round($data['money_m'], 2); $info['money_d'] = round($data['money_d'], 2); return $info; }
public function show() { $keyid = $GLOBALS['keyid']; if (!preg_match('/^([a-z]{1,}[a-z0-9]+)/', $keyid)) { MSG('keyid参数错误'); } load_function('common', 'member'); //$dianping_array = array(1=>'很差',2=>'差',3=>'一般',4=>'好',5=>'很好'); $page = isset($GLOBALS['page']) ? intval($GLOBALS['page']) : 1; $page = max($page, 1); if (!preg_match('/([a-z0-9_\\-])/', $GLOBALS['template'])) { exit('模板错误'); } $template = $GLOBALS['template']; include T('dianping', $template); }
public function show() { $seo_title = '公告'; $id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : MSG('参数错误'); $this->db = load_class('db'); $r = $this->db->get_one('affiche', array('id' => $id)); $_uid = get_cookie('_uid'); if ($r['status'] == 2 || is_numeric($_uid)) { extract($r, EXTR_SKIP); include T('affiche', 'show'); } elseif ($r['status'] == 1) { MSG('需要登录才可以查看', 'index.php?m=member&f=index&v=login'); } else { MSG('参数错误'); } }
/** * edit */ public function edit() { $siteid = intval($GLOBALS['siteid']); if (isset($GLOBALS['submit'])) { $formdata = array(); $formdata['name'] = $GLOBALS['form']['name']; $formdata['logo'] = $GLOBALS['form']['logo']; $this->db->update('site', $formdata, array('siteid' => $siteid)); MSG(L('operation success'), '?m=core&f=site&v=listing' . $this->su()); } else { $show_formjs = 1; $form = load_class('form'); $r = $this->db->get_one('site', array('siteid' => $siteid)); include $this->template('site_edit'); } }