public function display_public() { // See if the uer is logged in already if (AdminUtilities::check_clearance(1)) { // If so, send them to the index unless they're creating a new user if ($this->url1 === 'create' && AdminUtilities::check_clearance(2)) { return $this->_create_user_form(); } else { if ($this->url1 === 'logout') { $this->logout(); header('Location: /'); exit; } else { header('Location: /'); exit; } } } else { if ($this->url1 === 'verify') { return $this->_verify_user_form(); } else { return $this->_display_login_form(); } } }
/** * Loads the page entry and outputs HTML markup to display it * * @return string the formatted entry */ public function display_public() { // Check if the user is logged in and attempting to edit an entry if (isset($this->url1) && $this->url1 === 'admin' && AdminUtilities::check_clearance(1)) { // Load the entry ID if one was passed $id = isset($this->url2) ? (int) $this->url2 : NULL; // Output the admin controls return $this->display_admin($id); } // Load the entries $this->get_all_entries(); // Add the admin options for preview entries $entry_id = array_key_exists(0, $this->entries) ? $this->entries[0]->entry_id : NULL; $extra->header->admin = $this->admin_entry_options($this->url0, $entry_id, FALSE); // Set the template file $this->template = $this->url0 . '.inc'; // Organize the data $this->generate_template_tags(); // Return the entry as formatted by the template return $this->generate_markup($extra); }
public function display_site_options() { // Make sure the user is logged in before showing any options if (AdminUtilities::check_clearance(1)) { // Set up the break for menu items $tab = str_repeat(' ', 4); $break = "</li>\n{$tab}<li>"; // Create the unordered list and display user info $options = '<ul id="admin-site-options">' . "\n" . $tab . '<li class="info-box">You are logged in as <strong>' . $_SESSION['user']['name'] . '</strong>' . $break; // If the user has clearance, allow for site page & category editing if (AdminUtilities::check_clearance(2)) { $options .= '<a href="/siteadmin/pages">Edit Site Pages</a>' . $break . '<a href="/siteadmin/categories">Edit Entry ' . 'Categories<a/>' . $break; } // If the user has high enough clearance, they can manage admins if (AdminUtilities::check_clearance(2)) { $options .= '<a href="/admin/manage">Manage Administrators</a>' . $break; } return $options . '<a href="/admin/logout">Logout</a></li>' . "\n" . '</ul><!-- end #admin-site-options -->'; } else { return NULL; } }
/** * Loads the page entries and outputs HTML markup to display them * * @return string the formatted entries */ public function display_public() { // If logged in, show the admin options (if JavaScript is disabled) if (isset($this->url1) && $this->url1 === 'admin' && AdminUtilities::check_clearance(1)) { // Load the entry ID if one was passed $id = isset($this->url2) ? (int) $this->url2 : NULL; // Output the admin controls return $this->display_admin($id); } else { if (isset($this->url1) && $this->url1 !== 'more') { // Load the entry by its URL $this->get_entry_by_url($this->url1); // Avoid a notice $extra = (object) array(); // Set the template $this->template = $this->url0 . '-full.inc'; } else { // If the entries are paginated, this determines what page to show if (isset($this->url1) && $this->url1 === 'more') { $offset = isset($this->url2) ? $limit * ($this->url2 - 1) : 0; } else { $offset = 0; } // Load most recent entries for a preview if no entry was selected $this->get_all_entries($offset); // Add the admin options for preview entries $extra->header->admin = $this->admin_general_options($this->url0); // Set the template $this->template = $this->url0 . '-preview.inc'; } } // Organize the data $this->generate_template_tags(); // Return the entry as formatted by the template return $this->generate_markup($extra); }
<!-- Additional scripts for site enhancement. These are optional. --> <script type="text/javascript" src="/assets/js/jquery.loadflickr.js"></script> <script type="text/javascript" src="/assets/js/jquery.cookie.js"></script> <!--[if IE]> <script type="text/javascript" src="/assets/js/selectivizr.js"></script> <![endif]--> <?php // If the user is logged in, load JavaScript for the admin controls if ($main_content->url0 == "admin" || AdminUtilities::check_clearance(1)) { ?> <!-- Admin JS Files --> <script type="text/javascript" src="/assets/js/tiny_mce/jquery.tinymce.js"></script> <script type="text/javascript" src="/assets/js/hlx.admin.js"></script> <?php } ?> <!-- Initialization JS File --> <script type="text/javascript" src="/assets/js/hlx.init.js"></script> <?php
/** * Checks for the existence of a cached file with the ID passed * * @param string $cache_id A string by which the cache is identified * @return mixed The cached data if saved, else boolean FALSE */ public static function check_cache($cache_id) { $cache_filepath = self::_generate_cache_filepath($cache_id); /* * If the cached file exists and is within the time limit defined in * CACHE_EXPIRES, load the cached data. Does not apply if the user is * logged in */ if (file_exists($cache_filepath) && time() - filemtime($cache_filepath) <= CACHE_EXPIRES && !AdminUtilities::check_clearance(1)) { $cache = file_get_contents($cache_filepath); FB::warn("Data loaded from cache ({$cache_filepath})"); return unserialize($cache); } return FALSE; }
private function _display_comment_form() { $form = new Form(); $form->page = 'comments'; $form->legend = 'Add a Comment'; $form->action = 'comment-write'; $form->entry_id = $this->_entry_id; $form->form_id = 'add-comment'; if (isset($this->_sdata->error) && $this->_sdata->error !== '0000') { $form->notice = '<p class="comment-error">' . $this->_get_comment_error_message() . '</p>'; } // Make the entry values available to the form if they exist $form->entry = $this->_get_comment_data(); // If the admin is trying to reply to a comment, add the thread ID if (AdminUtilities::check_clearance(1) && isset($_GET['thread_id'])) { $form->entry->thread_id = (int) $_GET['thread_id']; } // If the commenter is new and no cookies exist, do a spam challenge if ($this->_is_verified_human() === TRUE) { $challenge = array('name' => 'challenge', 'type' => 'hidden', 'value' => 1); } else { $challenge = array('name' => 'challenge', 'class' => 'input-text', 'label' => $this->_generate_spam_challenge()); } // Set up input information $form->input_arr = array(array('name' => 'name', 'class' => 'input-text', 'label' => 'Your Name (Not Your Business Name)'), array('type' => 'email', 'name' => 'email', 'class' => 'input-text', 'label' => 'Your Email (Required, Never Shared)'), array('name' => 'url', 'class' => 'input-text', 'label' => 'Your Website (Optional)'), array('type' => 'textarea', 'name' => 'comment', 'class' => 'input-textarea', 'label' => 'Your Comment'), $challenge, array('type' => 'checkbox', 'name' => 'subscribe', 'id' => 'subscribe', 'label' => 'Receive an email when new comments are posted', 'value' => 1), array('type' => 'submit', 'name' => 'comment-submit', 'class' => 'input-submit', 'value' => 'Post a Comment'), array('type' => 'hidden', 'name' => 'comment_id'), array('type' => 'hidden', 'name' => 'thread_id'), array('type' => 'hidden', 'name' => 'return-url', 'value' => $this->_redirect_url)); return $form; }