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;
}
 /**
  * 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");
         }
     }
 }
Exemple #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");
 }
Exemple #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");
         }
     }
 }
Exemple #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");
     }
 }
Exemple #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");
         }
     }
 }
Exemple #7
0
 function team()
 {
     initiateSession();
     $this->set("title", "IEEE NIEC | Team");
 }
Exemple #8
0
 function home()
 {
     initiateSession();
     $this->set("title", "Sevasetu | Home");
     $this->set("slides", $this->Index->getSlides());
 }