示例#1
0
 /**
  * login.
  *
  * @param bool $remember default to false
  *
  * @return bool
  */
 public function login($remember = false)
 {
     global $_lang;
     if (!$this->exists()) {
         return false;
     }
     $this->sessionLogin($remember ? $this->cookie() : $this->id, $remember);
     $this->updateLastLogin();
     if (empty($this->language)) {
         $this->language = $_lang->id;
         $this->save();
     } elseif ($_lang->id !== $this->language) {
         $_lang = new Lang();
         $_lang->getFromId($this->language);
         $_lang->setCookie();
     }
     return true;
 }
示例#2
0
<?php

/*
 * Copyright (c) 2014 Alberto González
 * Distributed under MIT License
 * (see README for details)
 */
namespace Quaver\Controller;

use Quaver\Model\Lang;
$language = new Lang();
$langCurrent = $language->getFromSlug($this->url_var[1]);
if ($langCurrent) {
    $language->setCookie();
    if (!empty($_SERVER['HTTP_REFERER'])) {
        header("Location: " . $_SERVER['HTTP_REFERER']);
        exit;
    } else {
        $newLang = new url();
        header("Location: " . $newLang->getFromId(1)->url);
        exit;
    }
} else {
    header("Location: " . $this->getUrlFromId(2) . "?ref=" . $this->getUrl());
    exit;
}
示例#3
0
 /**
  * @param bool $_mvc
  */
 public function start($_mvc = true)
 {
     global $_lang;
     // Set user_default global
     global $_user;
     $_user = new User();
     if (!empty($_COOKIE[COOKIE_NAME . "_log"])) {
         $_user->getFromCookie($_COOKIE[COOKIE_NAME . "_log"]);
     }
     // Load language
     $_lang = new Lang();
     if (!empty($_GET['lang'])) {
         $lang_slug = substr($_GET['lang'], 0, 3);
         $_lang->getFromSlug($lang_slug);
         $_lang->setCookie();
     } else {
         $_lang->getSiteLanguage();
     }
     $this->language = $_lang->id;
     // Assoc URL to MVC
     if ($_mvc) {
         $this->loadMVC();
     }
 }