Exemplo n.º 1
0
 public function init()
 {
     parent::init();
     // only works if you are in casino
     $ct = R::getCell('SELECT map FROM map_position WHERE user_id = ?', array($this->user->getID()));
     if ($ct != "casino") {
         Framework::redir("game/index");
         exit;
     }
 }
Exemplo n.º 2
0
 public function show_Main()
 {
     $error = "";
     if ($this->get(1) == 'ok') {
         Framework::TPL()->assign('ok', true);
     }
     if (isset($_POST["change"])) {
         $auto = isset($_POST["automatic"]) && $_POST["automatic"] == 1 ? 1 : 0;
         $this->myPremium->auto = $auto;
         R::store($this->myPremium);
         Framework::redir('game/premium/main');
     }
     if (isset($_POST["activate"])) {
         if ($_SESSION['secHash'] != $_POST['hash']) {
             Framework::TPL()->assign('pError', 'invalid hash');
             return;
         }
         $length = array(1 => array(3, 150), 2 => array(7, 300), 3 => array(14, 400), 4 => array(30, 500));
         $l = @$_POST['length'];
         if (!isset($length[$l])) {
             Framework::TPL()->assign('pError', 'invalid length');
             return;
         }
         $details = $length[$l];
         if ($details[1] > $this->myPremium->points) {
             $error = "Du hast nicht genügend Premium-Punkte.";
         } else {
             $this->myPremium->points -= $details[1];
             if ($this->myPremium->until < time()) {
                 $this->myPremium->until = time() + $details[0] * 24 * 3600;
             } else {
                 $this->myPremium->until += $details[0] * 24 * 3600;
             }
             R::store($this->myPremium);
             $_SESSION['secHash'] = md5(mt_rand(1000, 10000) . microtime(true));
             RCached::clear();
             // clear cache files
             Framework::redir('game/premium/main/ok');
         }
     }
     Framework::TPL()->assign('pError', $error);
 }