예제 #1
0
 public function order()
 {
     if (session::has('order')) {
         $order = session::get('order');
     } else {
         $order = 0;
     }
     return $order;
 }
예제 #2
0
 public function title()
 {
     if (session::has('title')) {
         $title = ' - ' . session::get('title');
     } else {
         $title = '';
     }
     return $title;
 }
예제 #3
0
 public static function UserValidate($email, $password)
 {
     $valid = false;
     $sql = 'SELECT u.* , r.role FROM users u JOIN roles r ON r.user_id = u.id WHERE u.email = ?';
     if ($user = \DB::select($sql, [$email])) {
         if (Hash::check($password, $user[0]->password)) {
             session::set('user_id', $user[0]->id);
             session::set('user_name', $user[0]->name);
             session::flash('sm', 'welcome ' . $user[0]->name . '!');
             if ($user[0]->role == 1) {
                 session::set('is_admin', true);
             }
             $valid = true;
         }
     }
     return $valid;
 }
예제 #4
0
 public function savePosition($pos)
 {
     $rpta = array('numpos' => session::get('numpos'), 'status' => 'saved');
     $tbluser = session::get('tbluser');
     if ($tbluser[$pos] == 1) {
         $tbluser[$pos] = 0;
         $rpta['numpos']--;
         $rpta['status'] = 'overwrote';
     } else {
         if ($rpta['numpos'] < 6) {
             $tbluser[$pos] = 1;
             $rpta['numpos']++;
             $rpta['status'] = 'saved';
         } else {
             $rpta['status'] = 'failed';
         }
     }
     session::put('numpos', $rpta['numpos']);
     session::put('tbluser', $tbluser);
     return $rpta;
 }
예제 #5
0
 public function attackme($pos)
 {
     //implementar
     $tbluser = session::get('tbluser');
     if ($tbluser[$pos] == 0) {
         //if is empty
         $tbluser[$pos] = 2;
         //means have been used,
         session::put('tbluser', $tbluser);
         return 'miss';
     } elseif ($tbluser[$pos] == 1) {
         $tbluser[$pos] = 3;
         //means have been shot
         session::put('tbluser', $tbluser);
         $score = array_count_values(str_split($tbluser));
         if ($score[3] == 6) {
             return 'lose';
         } else {
             return 'shot';
         }
     } else {
         //used before
         return 'again';
     }
 }