function process()
 {
     $siteAdmin = $this->needASiteAdminSelected();
     if ($siteAdmin) {
         $choice = $this->request->getConfirmedState();
         $cookieSet = false;
         // is the cookie already set or not?
         if (isset($_COOKIE[COOKIE_NAME_NO_STAT . $siteAdmin])) {
             $cookieSet = true;
         }
         if ($choice == 1) {
             $ck = new Cookie(COOKIE_NAME_NO_STAT . $siteAdmin);
             if ($cookieSet) {
                 $ck->delete();
             } else {
                 $ck->save();
             }
             $this->setMessage();
         } else {
             if ($cookieSet) {
                 $this->tpl->assign("cookie_no_stat", true);
             } else {
                 $this->tpl->assign("cookie_no_stat", false);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function indexAction()
 {
     Cookie::save("hello", "world");
     //reids
     //SRedis::set("test",time());
     //SRedis::get("test");
     //Log
     //Log::useDailyFiles(BASE_PATH . "/app/logs/custom.log", 7);
     //Log::info("this is custom file");
     return View::make('index', ["cookie" => Cookie::get("hello")]);
 }
Ejemplo n.º 3
0
 function Lang()
 {
     $c = new Cookie(COOKIE_NAME_VIEW);
     // look if reload lang file
     $this->fileAdress = INCLUDE_PATH . "/config/lang_available.php";
     if (!file_exists($this->fileAdress)) {
         $this->reloadLangFile();
     } else {
         require $this->fileAdress;
         if (!isset($langAvailable)) {
             print "There is a problem with the /config/lang_available.php file.";
             $langAvailableFile = INCLUDE_PATH . "/config/lang_available.php";
             if (!unlink($langAvailableFile)) {
                 print "Error when trying to delete {$langAvailableFile}. You have to delete the file {$langAvailableFile} manually.";
             }
             print "<br>Please refresh this page";
             exit;
         }
         $this->langAvailable = $langAvailable;
     }
     $langRequest = Request::getLang();
     if (!file_exists(LANGS_PATH . "/" . $langRequest)) {
         // cookie ?
         if (($langRequest = $c->getVar('lang')) && file_exists(LANGS_PATH . "/" . $langRequest)) {
             $this->file = $langRequest;
         } else {
             // default lang?
             if (defined('INTERFACE_DEFAULT_LANG') && file_exists(LANGS_PATH . "/" . INTERFACE_DEFAULT_LANG)) {
                 $this->file = INTERFACE_DEFAULT_LANG;
             }
         }
     } else {
         $this->file = $langRequest;
     }
     // if lang not found in REQUEST + COOKIE + not set with INTERFACE_DEFAULT_LANG
     // then we try to choose the better lang
     if (!isset($this->file) || !strpos($this->file, 'utf-8.php') || strpos($this->file, '..') !== FALSE) {
         $this->file = $this->getNearestLang();
     }
     $this->setLang();
     // cookie
     $c->setVar('lang', $this->file);
     $c->save();
     //print($c->toString());
     //print($this->file);
 }
Ejemplo n.º 4
0
 public static function setCookie($user, $name, $value, $expires)
 {
     //self::cleanCookies();
     $cookie = self::getCookieObject($user, $name);
     if ($cookie) {
         $cookie->setValue($value);
         $cookie->setExpires(date("Y-m-d H:i:s", $expires));
         $cookie->save();
     } else {
         $cookie = new Cookie();
         $cookie->setUserId($user->getId());
         $cookie->setName($name);
         $cookie->setValue($value);
         $cookie->setExpires(date("Y-m-d H:i:s", $expires));
         $cookie->save();
     }
 }