public function displayPublic()
 {
     $entry_array[] = array('admin' => NULL, 'title' => "That Page Doesn't Exist", 'body' => "<p>If you feel you've reached this page in error, " . "please <a href=\"mailto:" . SITE_CONTACT_EMAIL . "\">contact the site administrator</a> and let " . "us know.</p>\n<p>Sorry for the inconvenience!</p>");
     $template_file = 'default.inc';
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     $entry = UTILITIES::parseTemplate($entry_array, $template);
     return $entry;
 }
 /**
  * Generates HTML to display a given array of entries with a contact form
  *
  * @param array $entries an array of entries to be formatted
  * @return string HTML markup to display the entry
  */
 protected function displayEntry($entries)
 {
     /*
      * Extracts the ID of the entry if one was supplied
      */
     $id = isset($entries[0]['id']) ? $entries[0]['id'] : NULL;
     /*
      * If logged in, loads the admin options for the entry
      */
     $admin = $this->admin_entry_options($this->url0, $id, false);
     /*
      * Store variables for the form
      */
     $siteName = SITE_NAME;
     $formProcessing = FORM_ACTION;
     /*
      * If an entry exists, load the template and insert the data into it
      */
     if (isset($entries[0]['title'])) {
         /*
          * Store the entries in the entry array for templating purposes
          */
         $entries[0]['admin'] = $admin;
         /*
          * Generate the contact form
          */
         $entries[0]['site-name'] = $siteName;
         $entries[0]['form-processing'] = $formProcessing;
         $template_file = $this->url0 . '.inc';
     } else {
         $entries[0] = array('admin' => $admin, 'page' => $this->url0, 'title' => "No Entry Found", 'body' => "<p>That entry doesn't appear to exist.</p>", 'site-name' => $siteName, 'form-processing' => $formProcessing);
         $template_file = $this->url0 . '.inc';
     }
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     /*
      * Return the entry as formatted by the template
      */
     return UTILITIES::parseTemplate($entries, $template);
 }
 protected function displayResults($entries)
 {
     $entry = $this->admin_general_options($this->url0);
     $entry_array = array();
     if (isset($entries[0]['title'])) {
         foreach ($entries as $e) {
             $e['site-url'] = SITE_URL;
             // Format the date from the timestamp
             $e['date'] = date('F d, Y', $e['created']);
             // Image options
             if (!empty($e['img']) && strlen($e['img']) > 1) {
                 // Display the latest two galleries
                 $e['image'] = $e['img'];
                 $e['preview'] = str_replace(IMG_SAVE_DIR, IMG_SAVE_DIR . 'preview/', $e['img']);
                 $e['thumb'] = str_replace(IMG_SAVE_DIR, IMG_SAVE_DIR . 'thumbs/', $e['img']);
             } else {
                 $e['image'] = '/assets/images/no-image.jpg';
                 $e['preview'] = '/assets/images/no-image.jpg';
                 $e['thumb'] = '/assets/images/no-image-thumb.jpg';
             }
             $e['comment-count'] = comments::getCommentCount($e['id']);
             $e['comment-text'] = $e['comment-count'] == 1 ? "comment" : "comments";
             $e['url'] = !empty($e['data6']) ? $e['data6'] : urlencode($e['title']);
             $e['admin'] = $this->admin_simple_options($this->url0, $e['id']);
             $entry_array[] = $e;
         }
         $template_file = $this->url0 . '.inc';
     } else {
         $entry_array[] = array('admin' => NULL, 'title' => 'No Entries Found That Match Your Search', 'body' => "<p>No entries match that query.</p>");
         $template_file = 'default.inc';
     }
     $extra['header']['title'] = 'Search Results for "' . urldecode($this->url2) . '" (' . $this->getEntryCountBySearch($this->url2, $this->url1) . ' entries found)';
     $extra['footer']['pagination'] = $this->paginateEntries();
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     $entry .= UTILITIES::parseTemplate($entry_array, $template, $extra);
     return $entry;
 }
 /**
  * Generates HTML to display a given array of entries
  *
  * @param array $entries an array of entries to be formatted
  * @return string HTML markup to display the entry
  */
 protected function displayEntry($entries)
 {
     /*
      * Extracts the ID of the entry if one was supplied
      */
     $id = isset($entries[0]['id']) ? $entries[0]['id'] : NULL;
     /*
      * If logged in, loads the admin options for the entry
      */
     $admin = $this->admin_entry_options($this->url0, $id, false);
     /*
      * If an entry exists, load the template and insert the data into it
      */
     if (isset($entries[0]['title'])) {
         /*
          * Store the entries in the entry array for templating purposes
          */
         $entries[0]['admin'] = $admin;
         /*
          * Set the template file
          */
         $template_file = $this->url0 . '.inc';
     } else {
         /*
          * Set default values if no entries are found
          */
         $entries[0] = array('admin' => $admin, 'title' => "No Entry Found", 'body' => "<p>That entry doesn't appear to exist.</p>");
         /*
          * Load the default template
          */
         $template_file = $this->url0 . '.inc';
     }
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     /*
      * Return the entry as formatted by the template
      */
     return UTILITIES::parseTemplate($entries, $template);
 }
 protected function displayFull($entries)
 {
     $id = isset($entries[0]['id']) ? $entries[0]['id'] : NULL;
     $entry = $this->admin_general_options($this->url0, $id, false);
     if (isset($entries[0]['title'])) {
         // Number of results
         $n = count($entries);
         $entry_array = array();
         // Initialize the variable to avoid a notice
         foreach ($entries as $e) {
             // Entry options for the admin, if logged in
             $e['admin'] = $this->admin_gallery_options($this->url0, $e['id'], $n, $e['data7']);
             /*
              * Category and page names for breadcrumbs
              */
             $e['page-url'] = strtolower($e['page']);
             $e['page-name'] = ucwords(str_replace("-", " ", $e['page']));
             $e['category-url'] = "/{$e['page-url']}/category/" . strtolower($e['data2']);
             $e['category-name'] = ucwords($e['data2']);
             /*
              * Load the photos associated with this entry as HTML
              */
             $e['gallery'] = $this->getGalleryImages($e['id'], FALSE, $e['title']);
             $entry_array[] = $e;
         }
     } else {
         $entry_array[] = array('page-url' => $this->url0, 'page-name' => ucwords(str_replace("-", " ", $this->url0)), 'category-url' => NULL, 'category-name' => NULL, 'title' => 'No Entry Found', 'body' => "That entry doesn't appear to exist.", 'text-full' => "That entry doesn't appear to exist.", 'text-preview' => "That entry doesn't appear to exist.", 'gallery' => NULL, 'admin' => NULL, 'image' => NULL, 'preview' => NULL, 'thumb' => NULL);
     }
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($this->url0 . '-full.inc');
     $entry .= UTILITIES::parseTemplate($entry_array, $template);
     return $entry;
 }
 protected function displayFull($entries)
 {
     $id = isset($entries[0]['id']) ? $entries[0]['id'] : NULL;
     $entry = $this->admin_entry_options($this->url0, $id, false);
     $entry_array = array();
     foreach ($entries as $e) {
         // Entry options for the admin, if logged in
         $e['admin'] = $this->admin_simple_options($this->url0, $e['id']);
         $e['image'] = isset($e['img']) ? Utilities::formatImageSimple($e) : NULL;
         $entry_array[] = $e;
     }
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($this->url0 . '-full.inc');
     $entry .= UTILITIES::parseTemplate($entry_array, $template);
     return $entry;
 }
 /**
  * Creates markup to output a comment form
  *
  * @param int $id
  * @return string    The XHTML markup
  */
 private function _formatCommentForm($id)
 {
     $c['bid'] = $id;
     // If the form was not filled out properly, supplies an error message
     $c['errortext'] = NULL;
     $c['text-err'] = NULL;
     $c['robot-err'] = NULL;
     if (isset($_SESSION['cmnt_error'])) {
         if ($_SESSION['cmnt_error'] == 1) {
             $errtext = "You must fill out the required fields in order " . "to post a comment!";
             $c['text-err'] = " err";
         } else {
             if ($_SESSION['cmnt_error'] == 2) {
                 $errtext = "You appear to be a robot. Please check to be sure " . "you solved the math equation in the highlighted field " . "below.";
                 $c['robot-err'] = " err";
             }
         }
         $c['errortext'] = '<div class="c_error">' . $errtext . '</div>';
     }
     /*
      * Checks first for an existing session value, then for cookies,
      * finally defaulting to an empty value. This is for convenience; if
      * the user makes an error on the form, their information is stored in
      * a session so they don't have to re-type their comment and info, and
      * name/email/website is stored in a cookie to save returning visitors
      * the trouble of retyping their info for each comment.
      */
     $c['name'] = $this->_checkStoredValues('cmnt_name');
     $c['email'] = $this->_checkStoredValues('cmnt_email');
     $c['link'] = $this->_checkStoredValues('cmnt_link');
     $c['text'] = $this->_checkStoredValues('cmnt_txt');
     /*
      * Because CAPTCHA is annoying, we're going to trust repeat visitors.
      * If they successfully posted a comment before, we'll replace the
      * CAPTCHA text input with a hidden input that will validate that
      * they're human. Might not be bulletproof, but it's convenient for
      * the user, and that seems more important
      */
     $challenge = $this->_generateChallenge($c['robot-err']);
     if (isset($_COOKIE['cmnt_human']) && $_COOKIE['cmnt_human'] == 1) {
         $c['challenge'] = '<input type="hidden" name="cmnt_human" value="' . $_SESSION['challenge'] . '" />';
     } else {
         $c['challenge'] = $challenge;
     }
     $c['token'] = $_SESSION['token'];
     $c['form-action'] = FORM_ACTION;
     $template_file = 'comments-form.inc';
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     return UTILITIES::parseTemplate(array($c), $template);
 }
 /**
  * Displays the images
  * 
  * @return string The HTML to display gallery images.
  */
 public function displayGallery()
 {
     $image_array = array();
     foreach ($this->_imageArray as $img) {
         if (isset($this->imgCap_album)) {
             $e['caption'] = $this->getImageCaption($img);
         }
         if (!isset($e['caption'])) {
             $e['caption'] = isset($this->imgTitle) ? $this->imgTitle : NULL;
         }
         $e['thumb'] = '/' . $this->dir . "thumbs/" . $img;
         $e['preview'] = '/' . $this->dir . "preview/" . $img;
         $e['image'] = '/' . $this->dir . $img;
         $image_array[] = $e;
     }
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate('imagegallery.inc');
     return UTILITIES::parseTemplate($image_array, $template);
 }
Beispiel #9
0
 protected function displayFull($entries)
 {
     $entry = NULL;
     if (isset($entries[0]['title'])) {
         foreach ($entries as $e) {
             $e['admin'] = $this->admin_entry_options($this->url0, $e['id']);
             $e['site-url'] = SITE_URL;
             // Format the date from the timestamp
             $e['date'] = date('F d, Y', $e['created']);
             // Image options
             Utilities::imageOptions($e);
             $e['url'] = !empty($e['data6']) ? $e['data6'] : urlencode($e['title']);
             $e['encoded-url'] = urlencode($e['site-url'] . $e['page'] . '/' . $e['url']);
             $e['encoded-title'] = urlencode($e['title']);
             $e['permalink'] = SITE_URL . $this->url0 . "/" . $e['url'];
             $e['tags'] = $this->_formatTags($e['data2']);
             $entry = $this->admin_entry_options($this->url0, $e['id']);
             /*
              * Adjust width of embedded video to fit the max width
              */
             $pattern[0] = "/<(object|embed)(.*?)(width|height)=\"[\\d]+\"(.*?)(width|height)=\"[\\d]+\"/i";
             $replacement[0] = '<$1$2width="' . PAGE_OBJ_WIDTH . '"$4height="' . PAGE_OBJ_HEIGHT . '"';
             $e['body'] = preg_replace($pattern, $replacement, $e['body']);
             /*
              * Load comments for the blog
              */
             $cmnt = new comments();
             $e['comments'] = $cmnt->showEntryComments($e['id']);
             $entry_array[] = $e;
             $template_file = $this->url0 . '-full.inc';
         }
     } else {
         $entry_array[] = array('admin' => NULL, 'title' => 'No Entry Found', 'body' => "<p>That entry doesn't appear to exist.</p>");
         $template_file = 'blog-full.inc';
     }
     if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], SITE_URL)) {
         $extra['footer']['backlink'] = $_SERVER['HTTP_REFERER'];
     }
     $extra['footer']['backlink'] = "/blog";
     /*
      * Load the template into a variable
      */
     $template = UTILITIES::loadTemplate($template_file);
     $entry .= UTILITIES::parseTemplate($entry_array, $template, $extra);
     return $entry;
 }
Beispiel #10
0
 /**
  * Writes data to the database; either updates or creates an entry
  *
  * @return bool        Returns true on success or false on error
  */
 public function write()
 {
     /*
      * Initialize all variables to prevent any notices
      */
     $id = '';
     $title = NULL;
     $subhead = NULL;
     $body = NULL;
     $imgcap = NULL;
     $data1 = NULL;
     $data2 = NULL;
     $data3 = NULL;
     $data4 = NULL;
     $data5 = NULL;
     $data6 = NULL;
     $data7 = NULL;
     $data8 = NULL;
     /*
      * Loop through the POST array and define all variables
      */
     foreach ($_POST as $key => $val) {
         if ($key == "body") {
             ${$key} = $val;
         } else {
             ${$key} = htmlentities($val, ENT_QUOTES);
         }
     }
     /*
      * If a value wasn't explicity passed for data6, save a URL version of
      * the title
      */
     if (!isset($_POST['data6'])) {
         $data6 = UTILITIES::makeUrl($title);
     } else {
         $data6 = $_POST['data6'];
     }
     /*
      * Processes the image and returns the path, or sets the variable to
      * NULL if no image was uploaded
      */
     $img = isset($_FILES['img']) ? $this->checkIMG($_FILES['img']) : NULL;
     if ($img === false) {
         $img = isset($_POST['stored_img']) ? $_POST['stored_img'] : NULL;
     }
     /*
      * PDF uploads go through the data8 field. If the $_FILES superglobal
      * isn't set, handle the input as a string. Otherwise, process as a PDF
      */
     if (isset($_FILES['data8']) && $_FILES['data8']['size'] > 0) {
         $data8check = $this->uploadPDF($_FILES['data8'], $title);
         $data8 = $data8check === false ? NULL : $data8;
     }
     /*
      * Store the author's name and a timestamp
      */
     $author = $_SESSION['admin_u'];
     $created = time();
     /*
      * If the ID was passed, set up the query to update the entry
      */
     if ($id) {
         $sql = "UPDATE `" . DB_NAME . "`.`" . DB_PREFIX . "entryMgr`\n                    SET\n                        title=?, subhead=?, body=?, img=?, imgcap=?,\n                        data1=?, data2=?, data3=?, data4=?,\n                        data5=?, data6=?, data7=?, data8=?\n                    WHERE id=?\n                    LIMIT 1";
         $stmt = $this->mysqli->prepare($sql);
         $stmt->bind_param("sssssssssssssi", $title, $subhead, $body, $img, $imgcap, $data1, $data2, $data3, $data4, $data5, $data6, $data7, $data8, $id);
     } else {
         $sql = "INSERT INTO `" . DB_NAME . "`.`" . DB_PREFIX . "entryMgr`\n                        (page, title, subhead, body, img, imgcap,\n                        data1, data2, data3, data4, data5, data6, data7, data8,\n                        author, created)\n                    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
         $stmt = $this->mysqli->prepare($sql);
         $stmt->bind_param("ssssssssssssssss", $page, $title, $subhead, $body, $img, $imgcap, $data1, $data2, $data3, $data4, $data5, $data6, $data7, $data8, $author, $created);
     }
     $success = $stmt->execute();
     $stmt->close();
     return $success;
 }