示例#1
0
 public function indexAction()
 {
     // Start with row 0 at the beginning...
     $range = 0;
     /**
      * Feed Pagination
      */
     if ($this->config->feed_pagination) {
         /**
          * If the config option, feed_pagination is set, we will spit up the feed into pages.
          */
         // Get total number of publically available posts
         $sql = "SELECT count(`id`) FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}'";
         $this->total_posts = (int) Pixelpost_DB::get_var($sql);
         // Determine the total number of pages
         Pixelpost_Uri::$total_pages = (int) ceil($this->total_posts / $this->config->posts_per_page);
         // Verify that we're on a legitimate page to start with
         if (Pixelpost_Uri::$total_pages < Pixelpost_Uri::$page) {
             // @todo this error displays if the database call doesn't work.
             throw new Exception("Sorry, we don't have anymore pages to show!");
         }
         // The database needs to know which row we need to start with:
         $range = (int) (Pixelpost_Uri::$page - 1) * $this->config->posts_per_page;
     }
     $posts_sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC LIMIT {$range}, {$this->config->feed_items}";
     // Grab the data object from the DB.
     $this->posts = (array) Pixelpost_DB::get_results($posts_sql);
     /**
      * The RSS feed can't have altered published dates,
      * so we need to completely nuke "filter_published" 
      * before we can run processPosts().
      */
     Pixelpost_Plugin::removeFilterHook('filter_published');
     /**
      * Run the posts through the Plugin system, and apply any 
      * necessary data before sending the array to the view.
      */
     $this->processPosts();
     /**
      * If index is called, without specifying a feed type,
      * auto-run the default rss method.
      */
     if (empty($this->feed_type) || !method_exists($this, $this->feed_type . 'Action')) {
         $this->rssAction();
     }
 }
示例#2
0
 public function indexAction()
 {
     if (!is_array($this->posts)) {
         // Page Title
         $this->view->title = 'The Past';
         if ($this->config->posts_per_page > 0) {
             /**
              * If the config option, posts_per_page is set, we will spit up the archive into pages.
              */
             // Get total number of publically available posts
             $sql = "SELECT count(`id`) FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}'";
             $this->total_posts = (int) Pixelpost_DB::get_var($sql);
             // Determine the total number of pages
             Pixelpost_Uri::$total_pages = (int) ceil($this->total_posts / $this->config->posts_per_page);
             // Verify that we're on a legitimate page to start with
             if (Pixelpost_Uri::$total_pages < Pixelpost_Uri::$page) {
                 throw new Exception("Sorry, we don't have anymore pages to show!");
             }
             // The database needs to know which row we need to start with:
             $range = (int) (Pixelpost_Uri::$page - 1) * $this->config->posts_per_page;
             $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC LIMIT {$range}, {$this->config->posts_per_page}";
         } else {
             /**
              * the config option, posts_per_page, isn't set, so display ALL the posts
              */
             $sql = "SELECT * FROM `pixelpost` WHERE `published` <= '{$this->config->current_time}' ORDER BY `published` DESC";
         }
         /**
          * The posts to list:
          */
         $this->posts = (array) Pixelpost_DB::get_results($sql);
     }
     // !is_array($this->posts)
     /**
      * Run the posts through the Plugin system, and apply any 
      * necessary data before sending the array to the view.
      */
     $this->processPosts();
     /**
      * Assign the variables to be used in the view
      * $this->view->myVar can be accessed in the template as $myVar
      */
     $this->view->thumbnails = $this->_thumbnails();
     $this->view->posts = $this->posts;
 }
示例#3
0
 /**
  * Attempt to login, and set the session
  */
 public function login($username = '', $password = '')
 {
     // convert the plaintext password to a SHA1 encoded string
     $password = hash('sha1', $password);
     $username = Pixelpost_DB::escape($username);
     $old_sess_id = session_id();
     // First check if there is a session available with a login_hash.
     if ($this->session->get('login_vars')) {
         // There is login data present in the session so compare the username and password
         // with data stored in session
         $sess_loginarr = $this->session->get('login_vars');
         if ($sess_loginarr['login'] == $username && $sess_loginarr['password'] == $password) {
             // The given data corresponds with the data stored in the session
             // Next step is to establish if the hash can be confirmed
             session_regenerate_id();
             $this->session->db_destroy($old_sess_id);
             unset($old_sess_id);
             return $this->confirmAuth();
         } else {
             // The given data is not the data in the session, do not login the user.
             // destroy the current session
             $this->logout();
             return false;
         }
     } else {
         // If there isn't any session we need to check the given credentials against the database
         // In order to do so we select the status of a user. If that status == 1 then the user can login
         $status = (int) Pixelpost_DB::get_var("SELECT `status` FROM users WHERE username = '******' AND password = '******' LIMIT 1");
         if ($status == 1) {
             // We're good to go!
             // Store the username, password and hash into the session
             session_regenerate_id();
             $this->session->db_destroy($old_sess_id);
             unset($old_sess_id);
             $this->storeAuth($username, $password);
             return true;
         } else {
             // Login invalid, or the user is banned
             return false;
         }
     }
 }
示例#4
0
 /**
  *
  * @Add child node
  * @ adds a child to a node that has no children
  * @access public
  * @param string $node_name The node to add to
  * @param string $new_node The name of the new child node
  * @return array
  */
 public function addChildNode($node_name, $node_permalink, $new_node)
 {
     try {
         $sql = "SELECT left_node FROM " . $this->tablename . " \n\t\t\t\tWHERE name='" . Pixelpost_DB::escape($node_name) . "'";
         $myLeft = (int) Pixelpost_DB::get_var($sql);
         Pixelpost_DB::query("UPDATE " . $this->tablename . " SET right_node = right_node + 2 WHERE right_node > " . $myLeft);
         Pixelpost_DB::query("UPDATE " . $this->tablename . " SET left_node = left_node + 2 WHERE left_node > " . $myLeft);
         $new_left = $myLeft + 1;
         $new_right = $myLeft + 2;
         Pixelpost_DB::query("INSERT INTO " . $this->tablename . "(name, left_node, right_node, permalink) \n\t\t\t\tVALUES('{$new_node}', '{$new_left}', '{$new_right}', '{$node_permalink}')");
     } catch (exception $e) {
         throw new Exception($e);
     }
 }