function initiateSession($recurs = 0)
{
    global $session;
    if (isset($_SESSION['session'])) {
        $session = unserialize($_SESSION['session']);
        //If the unserialize failed, $session will be false;
        if ($session === false) {
            return 1;
        }
        $session->update_session();
        if (!$session->session_exists($session->sid) || $session->get_var("logged_in") != 1) {
            return 1;
        } else {
            //Our session is valid, and logged in == 1
            return 0;
        }
    } else {
        if (!$recurs) {
            $session = new iSession();
            return initiateSession(1);
        } else {
            return 1;
        }
    }
    return 1;
}
Exemplo n.º 2
0
 /**
  * Get all the categories
  */
 function getcategories()
 {
     initiateSession();
     if (!isset($_SESSION['user_id'])) {
         $this->set("message", "User is not logged in");
     } else {
         $data = $this->Categorie->getCategories();
         if ($data == false) {
             $this->set("message", "Unable to retrieve categories");
         } else {
             $this->set("categories", $data);
             $this->set("message", "Categories retrieved successfully");
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Logout processor for admin panel
  */
 function logout()
 {
     initiateSession();
     $this->set("title", "Admin Logout");
     if (!isset($_SESSION['admin_hash'])) {
         header("LOCATION: /admins/index");
     }
     closeSession();
     header("LOCATION: /admins/index");
 }
Exemplo n.º 4
0
 /**
  * Remove the post from the database
  *
  * @param Int $id The ID of the post to be removed
  */
 function remove($id)
 {
     $this->set("title", "Blog");
     initiateSession();
     if (!isset($_SESSION['user_id'])) {
         $this->set("message", "No permission to remove post");
     } else {
         if ($this->Blog->removePost(sqlSafe($id)) == false) {
             $this->set("message", "Unable to remove post");
         } else {
             $this->set("message", "Post removed");
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Logs the user out
  */
 function logout()
 {
     initiateSession();
     $this->set("title", "IEEE NIEC");
     if (isset($_SESSION['user_id'])) {
         foreach ($_SESSION as $vals) {
             $vals = null;
         }
         closeSession();
         $this->set("message", "You have been logged out");
     } else {
         $this->set("message", "User not logged in");
     }
 }
Exemplo n.º 6
0
 /**
  * Remove Image
  *
  * @param Int $id The ID of the image to be removed
  */
 function remove($id)
 {
     initiateSession();
     if (!isset($_SESSION['user_id'])) {
         $this->set("message", "User not logged in");
     } else {
         $id = sqlSafe($id);
         if ($this->Picture->removePicture($id) == false) {
             $this->set("message", "Unable to remove picture");
         } else {
             $this->set("message", "Picture removed");
         }
     }
 }
Exemplo n.º 7
0
 function team()
 {
     initiateSession();
     $this->set("title", "IEEE NIEC | Team");
 }
Exemplo n.º 8
0
 function home()
 {
     initiateSession();
     $this->set("title", "Sevasetu | Home");
     $this->set("slides", $this->Index->getSlides());
 }