public function refer() { //获取系统菜单 $menu = service('menu')->menus(); $cur = current($menu); go(__ROOT__ . $cur['url']); }
/** * 运行钓子 * * @param $options */ public function run(&$options) { //检测安装 if (!file_exists(APP_PATH . 'Install/Lock.php')) { if (MODULE != 'Install') { go(__ROOT__ . '/index.php?m=Install&c=Index&a=index'); } } else { if (session('user')) { //登录 define('IS_LOGIN', true); //管理员 define('IS_ADMIN', $_SESSION['user']['admin'] == 1); //超级管理员 define('IS_SUPER_ADMIN', $_SESSION['user']['rid'] == 1); //站长 define('IS_WEBMASTER', strtoupper($_SESSION['user']['username']) == strtoupper(C('WEB_MASTER'))); } else { //登录 define('IS_LOGIN', false); //管理员 define('IS_ADMIN', false); //超级管理员 define('IS_SUPER_ADMIN', false); //站长 define('IS_WEBMASTER', false); } //加载插件 $this->loadAddons(); } }
public function index() { if (site()->users()->count() > 0) { go(panel()->urls()->login()); } if ($problems = installation::check()) { $content = view('installation/check', array('problems' => $problems)); } else { $form = panel()->form('installation', array('language' => kirby()->option('panel.language', 'en'))); $form->cancel = false; $form->save = l('installation.signup.button'); $form->centered = true; foreach (panel()->languages() as $lang) { $form->fields()->get('language')->options[$lang->code()] = $lang->title(); } $form->on('submit', function ($form) { try { // fetch all the form data $data = $form->serialize(); // make sure that the first user is an admin $data['role'] = 'admin'; // try to create the new user $user = panel()->site()->users()->create($data); // store the new username for the login screen s::set('username', $user->username()); // redirect to the login go(panel()->urls()->login() . '/welcome'); } catch (Exception $e) { $form->alert($e->getMessage()); } }); $content = view('installation/signup', array('form' => $form)); } return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content)); }
public function __construct($kirby, $dir) { static::$instance = $this; $this->kirby = $kirby; $this->site = $kirby->site(); $this->roots = new Panel\Roots($dir); $this->urls = new Panel\Urls($kirby->urls()->index() . '/' . basename($dir)); $this->load(); // load all available routes $this->routes = array_merge($this->routes, require $this->roots->routes . DS . 'api.php'); $this->routes = array_merge($this->routes, require $this->roots->routes . DS . 'views.php'); // setup the blueprint root blueprint::$root = $this->kirby->roots()->blueprints(); // setup the form plugin form::setup($this->roots->fields, $this->kirby->roots()->fields()); // start the router $this->router = new Router($this->routes); // register router filters $this->router->filter('auth', function () use($kirby) { $user = $kirby->site()->user(); if (!$user or !$user->hasPanelAccess()) { if ($user) { $user->logout(); } go('panel/login'); } }); // check for a completed installation $this->router->filter('isInstalled', function () use($kirby) { if ($kirby->site()->users()->count() == 0) { go('panel/install'); } }); }
/** * 显示登录页 */ public function index() { if (Q("session.adminname") || Q("session.aid")) { go("Admin/Index/index"); } $this->display(); }
public function lists() { if (!isset($_SESSION['user']['user_id'])) { go('Home/User/login'); } //分配模板文件配置 $tplData['title'] = "购物车"; $tplData['css'] = "cart|order"; View::with('tplData', $tplData); //购物车列表信息 $cart = $_SESSION['cart']; $price = 0; foreach ($cart as $k => $v) { $cart[$k]['goods'] = Db::table('goods')->where('goods_id', $v['goods_id'])->first(); $attrs = explode('-', $v['stock_attr']); foreach ($attrs as $key => $value) { $attrs[$key] = Db::table('goods_attr')->where('goods_attr_id', $value)->first(); $attrs[$key]['attr_name'] = Db::table('shop_attr')->where('attr_id', $attrs[$key]['attr_id'])->pluck('attr_name'); } $cart[$k]['attr'] = $attrs; $price += $v['goods_price'] * $v['buy_num']; //总价 } View::with('cart', $cart); View::with('price', $price); //收货地址列表 $address = new \Home\Model\Address(); $addressData = $address->getAll(); View::with('addressData', $addressData); // p($addressData); View::make($this->tpl . 'order.html'); }
public function checkAccess() { //未登录 if (!IS_LOGIN) { go(U("Member/Login/login")); } //状态 if (!USER_STATE) { $this->error('帐号审核中...'); } //锁定 if (IS_LOCK) { $this->error('帐号已锁定...'); } //管理员 if (WEB_MASTER || IN_ADMIN) { return true; } //会员中心关闭 if (C("MEMBER_OPEN") == 0) { $this->display("template/system/member_close.html"); exit; } //邮箱验证 if (C('MEMBER_EMAIL_VALIDATE') && $_SESSION['user_state'] == 0) { go(U('Member/Email/VaifyMail')); } return true; }
public function logout() { if ($user = app::$site->user()) { $user->logout(); } go('panel/login'); }
public function logout() { if ($user = panel()->site()->user()) { $user->logout(); } go(panel()->urls()->login()); }
/** * 获取评论信息 * @param $module 模型 * @param $contentid 文章ID * @param $siteid 站点ID */ function get_info($module, $contentid, $siteid) { list($module, $catid) = explode('_', $module); if (empty($contentid) || empty($catid)) { return false; } //判断栏目是否存在 s $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); if (!$CATEGORYS[$catid]) { return false; } //判断模型是否存在 $this_modelid = $CATEGORYS[$catid]['modelid']; $MODEL = getcache('model', 'commons'); if (!$MODEL[$this_modelid]) { return false; } $this->db->set_catid($catid); $r = $this->db->get_one(array('catid' => $catid, 'id' => $contentid), '`title`'); $category = getcache('category_content_' . $siteid, 'commons'); $model = getcache('model', 'commons'); $cat = $category[$catid]; $data_info = array(); if ($cat['type'] == 0) { if ($model[$cat['modelid']]['tablename']) { $this->db->table_name = $this->db->db_tablepre . $model[$cat['modelid']]['tablename'] . '_data'; $data_info = $this->db->get_one(array('id' => $contentid)); } } if ($r) { return array('title' => $r['title'], 'url' => go($catid, $contentid, 1), 'allow_comment' => isset($data_info['allow_comment']) ? $data_info['allow_comment'] : 1); } else { return false; } }
public function __init() { if (empty($_SESSION['user'])) { go("Index/Index/index"); } $this->db = M('upload'); }
public function category() { $mid = Q('mid', 0, 'intval'); $cid = Q('cid', 0, 'intval'); $cache = cache('category'); if (!$mid || !$cid || !isset($cache[$cid])) { _404(); } $cachetime = C('CACHE_CATEGORY') >= 1 ? C('CACHE_CATEGORY') : null; if (!$this->isCache()) { $category = $cache[$cid]; //外部链接,直接跳转 if ($category['cattype'] == 3) { go($category['cat_redirecturl']); } else { $Model = ContentViewModel::getInstance($category['mid']); $catid = getCategory($category['cid']); $category['content_num'] = $Model->join()->where("cid IN(" . implode(',', $catid) . ")")->count(); $category['comment_num'] = intval(M('comment')->where("cid IN(" . implode(',', $catid) . ")")->count()); $this->assign("hdcms", $category); $this->display($category['template'], $cachetime); } } else { $this->display(null, $cachetime); } }
/** * 后台权限验证 * * @return bool */ protected function checkAdminAccess() { //没登录或普通用户 if (!IS_ADMIN) { go("Login/login"); } /** * 超级管理员与站长不受限制 */ if (IS_SUPER_ADMIN || IS_WEB_MASTER) { return true; } /** * 普通管理员权限检查 */ $nodeModel = M("node"); $nodeModel->where = array("MODULE" => MODULE, "controller" => CONTROLLER, "action" => ACTION, 'type' => 1); $node = $nodeModel->field("nid")->find(); /** * 当节点不存时,表示不需要验证 * 这时直接允许操作 */ if (!$node) { return true; } else { $map['nid'] = $node['nid']; $map['rid'] = $_SESSION['user']['rid']; return M('access')->where($map)->find(); } }
public function __construct() { if (!session('user')) { go('Login/login'); } parent::__construct(); }
public function __construct() { if (!$_SESSION['user_id']) { go('Login/index'); } parent::__construct(); }
public function login() { if (session('aid')) { go("Index/index"); } if (IS_POST) { $username = Q("post.username"); //对登录帐号的验证 if (!($user = $this->_db->where("username='******'")->find())) { $this->error('帐号输入错误'); } //对密码的验证 if ($user['password'] != md5($_POST['password'])) { $this->error('密码输入错误'); } //当帐号密码输入正确时记录登录状态 $_SESSION['aid'] = $user['aid']; $_SESSION['username'] = $user['username']; //跳转到后台界面 go('Index/index'); } else { //显示登录界面 $this->display(); } }
public function index() { if (app::$site->users()->count() > 0) { go('panel/login'); } if ($problems = installation::check()) { $content = view('installation/check', array('problems' => $problems)); } else { $form = app::form('installation', array('language' => c::get('panel.language', 'en'))); $form->cancel = false; $form->save = l::get('installation.signup.button'); $form->centered = true; foreach (app::languages() as $lang) { $form->fields()->get('language')->options[$lang->code()] = $lang->title(); } $form->on('submit', function ($form) { try { app::$site->users()->create($form->serialize()); go('panel/login/welcome'); } catch (Exception $e) { $form->alert($e->getMessage()); } }); $content = view('installation/signup', array('form' => $form)); } return layout('installation', array('meta' => new Snippet('meta'), 'content' => $content)); }
/** * 获取评论信息 * @param $module 模型 * @param $contentid 文章ID * @param $siteid 站点ID */ function get_info($module, $contentid, $siteid) { $category = getcache('category_content_' . $siteid, 'commons'); list($module, $catid) = explode('_', $module); $cat = $category[$catid]; if ($cat['type'] == 1) { //单网页 3.28 增加评论模块对单网页的支持 return array('title' => $cat['catname'], 'url' => $cat['url'], 'allow_comment' => 1); } else { //不是单网页 if (empty($contentid) || empty($catid)) { return false; } $this->db->set_catid($catid); $r = $this->db->get_one(array('catid' => $catid, 'id' => $contentid), '`title`'); //$category = getcache('category_content_'.$siteid, 'commons'); $model = getcache('model', 'commons'); //$cat = $category[$catid]; $data_info = array(); if ($cat['type'] == 0) { $this->db->table_name = $this->db->db_tablepre . $model[$cat['modelid']]['tablename'] . '_data'; $data_info = $this->db->get_one(array('id' => $contentid)); } if ($r) { return array('title' => $r['title'], 'url' => go($catid, $contentid, 1), 'allow_comment' => isset($data_info['allow_comment']) ? $data_info['allow_comment'] : 1); } else { return false; } } }
/** * 返回登录 */ public function callback() { require_once COMMON_LIB_PATH . "QqConnect/API/qqConnectAPI.php"; $qc = new QC(); $callback = $qc->qq_callback(); $openid = $qc->get_openid(); $user = K("user")->field("uid,username,password,qqau,userlock,uuid,usergroup")->where(array("qqau" => $openid))->find(); session("qqau", $openid); if (empty($user["qqau"])) { //首次登录或没有绑定账号 $qc = new QC($callback, $openid); $arr = $qc->get_user_info(); session("UserInfo", $arr["nickname"]); go("Passport/Qqlogin/index"); } elseif ($user["qqau"] == $openid) { //数据库比对正确 if ($user["userlock"] == 1) { $this->error("您已经被锁定,请联系管理员!"); } //$this->eve_exp($user["uid"]); $loginData = array("logintime" => time(), "loginip" => ip::getClientIp(), "qqau" => $openid); M("user")->where(array("uid" => $user["uid"]))->save($loginData); // p($_POST); session("username", $user["username"]); session("uid", $user["uid"]); session("uuid", $user["uuid"]); session("usergroup", $user["usergroup"]); $this->success("登录成功!正在跳转...", U(__WEB__)); } }
public function __init() { if (is_file(MODULE_PATH . 'Lock.php') && ACTION != 'isLock') { go('isLock'); } $this->step = Q('step', 1, 'intval'); }
public function sort() { $db = M('cate'); foreach ($_POST as $id => $sort) { $db->where(array('id' => $id))->setField('sort', $sort); } go(U('Category/index')); }
/** * Log out the user * * @return void */ public function logout() { if (site()->user()) { site()->user()->logout(); } flash('messages.success', 'Logged out!'); go('login'); }
public function getDay($date) { $Date = str::split($date, '-'); // If day folder doesn't exists, create it $this->field()->check_day($this->model(), $date); // Go to day edit page go(purl($this->model(), 'year-' . $Date[0] . '/day-' . $date . '/edit/')); }
/** * 会员中心首页 */ public function index() { if (isset($_SESSION['uid'])) { go(U('Member/Dynamic/index')); } else { go(U('Member/Login/login')); } }
function error_go($url, $message) { if ($url === false) { $url = hoturl("index"); } Conf::msg_error($message); go($url); }
function index($c, $obj) { $c->drop(); $c->ensureIndex("x"); go($c, $obj); $c->drop(); $c->ensureIndex("x"); go_find_one($c, $obj); }
/** * 跳转风云直播 */ public function getfy() { if (!IS_GET) { $this->error("页面不存在!"); } $id = Q("get.id"); $file = "http://resource.ws.kukuplay.com/players/2013/09/04/40806/fengyun.swf?cid=" . $id; go($file); }
public function add() { if (!site()->user()->isAdmin()) { go(purl('error')); } $form = $this->form(); $form->back = purl('users'); return view('users/edit', array('topbar' => new Snippet('topbar', array('breadcrumb' => new Snippet('breadcrumb', array('items' => array(array('title' => l('users'), 'url' => purl('users')), array('title' => l('users.index.add'), 'url' => purl('users/add'))))))), 'user' => null, 'writable' => is_writable(kirby()->roots()->accounts()), 'form' => $form)); }
public function doWEbOpenidLogin() { //微信自动登录 if (service('member')->weixinLogin()) { $url = q('get.backurl', web_url('entry/home', ['siteid' => SITEID])); go($url); } message('微信登录失败,请检查微信公众号是否验证', 'back', 'error'); }
function error_go($url, $message) { global $Conf; if ($url === false) { $url = hoturl("index"); } $Conf->errorMsg($message); go($url); }