Example #1
0
 /**
  * Get the blocks for this theme in teh specified area,
  * overrides the default handling to implement dashboard modules
  * @param string $area The area to return blocks for
  * @param string $scope The scope in which the blocks exist
  * @param Theme $theme The theme for which the blocks will be returned
  * @return array An array of Blocks
  */
 public function get_blocks($area, $scope, $theme)
 {
     if ($area == 'dashboard') {
         $area = 'dashboard_' . User::identify()->id;
     }
     return parent::get_blocks($area, $scope, $theme);
 }
	/**
	 * Ouputs the default menu in the template footer, and runs the 'habmin_bar' plugin filter.
	 * You can add menu items via the filter. See the 'filter_habminbar' method for
	 * an example.
	 */
	public function action_template_footer()
	{
		if ( User::identify()->loggedin ) {
			$bar = '<div id="habminbar"><div>';
			$bar.= '<div id="habminbar-name"><a href="' . Options::get('base_url') . '">' . Options::get('title') . '</a></div>';
			$bar.= '<ul>';

			$menu = array();
			$menu['dashboard']= array( 'Dashboard', URL::get( 'admin', 'page=dashboard' ), "view the admin dashboard" );
			$menu['write']= array( 'Write', URL::get( 'admin', 'page=publish' ), "create a new entry" );
			$menu['option']= array( 'Options', URL::get( 'admin', 'page=options' ), "configure site options" );
			$menu['comment']= array( 'Moderate', URL::get( 'admin', 'page=comments' ),"moderate comments" );
			$menu['user']= array( 'Users', URL::get( 'admin', 'page=users' ), "administer users" );
			$menu['plugin']= array( 'Plugins', URL::get( 'admin', 'page=plugins' ), "activate and configure plugins" );
			$menu['theme']= array( 'Themes', URL::get( 'admin', 'page=themes' ), "select a theme" );

			$menu = Plugins::filter( 'habminbar', $menu );

			$menu['logout']= array( 'Logout', URL::get( 'user', 'page=logout' ), "logout" );

			foreach ( $menu as $name => $item ) {
				list( $label, $url, $tooltip )= array_pad( $item, 3, "" );
				$bar.= "\n\t<li><a href=\"$url\" class=\"$name\"" .
				( ( $tooltip ) ? " title=\"$tooltip\"" : "" ) .">$label</a></li>";
			}
			$bar.= '</ul><br style="clear:both;" /></div></div>';

			echo $bar;
		}
	}
	/**
	 * Fetches active modules for display on the dashboard
	 */
	public function fetch_dashboard_modules()
	{
		if ( count( Modules::get_all() ) == 0 ) {
			$this->theme->modules = array();
			return;
		}

		// get the active module list
		$modules = Modules::get_active();

		if ( User::identify()->can( 'manage_dash_modules' ) ) {
			// append the 'Add Item' module
			$modules['nosort'] = 'Add Item';

			// register the 'Add Item' filter
			Plugins::register( array( $this, 'filter_dash_module_add_item' ), 'filter', 'dash_module_add_item' );
		}

		foreach ( $modules as $id => $module_name ) {
			$slug = Utils::slugify( (string) $module_name, '_' );
			$module = array(
				'name' => $module_name,
				'title' => $module_name,
				'content' => '',
				'options' => ''
				);

			$module = Plugins::filter( 'dash_module_' .$slug, $module, $id, $this->theme );

			$modules[$id] = $module;
		}

		$this->theme->modules = $modules;
	}
Example #4
0
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('header_text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt.');
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify()->loggedin);
     }
     /*		if( !$this->template_engine->assigned( 'page' ) ) {
     			$this->assign('page', isset( $page ) ? $page : 1 );
     		}*/
     if (!$this->template_engine->assigned('all_tags')) {
         // List of all the tags
         $tags = Tags::get();
         $this->assign('all_tags', $tags);
     }
     //visiting page/2, /3 will offset to the next page of posts in the sidebar
     $page = Controller::get_var('page');
     $pagination = Options::get('pagination');
     if ($page == '') {
         $page = 1;
     }
     $this->assign('more_posts', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $pagination * $page, 'limit' => 5)));
     parent::add_template_vars();
     $this->add_template('formcontrol_text', dirname(__FILE__) . '/forms/formcontrol_text.php', true);
     $this->add_template('formcontrol_textarea', dirname(__FILE__) . '/forms/formcontrol_textarea.php', true);
 }
    function theme_footer()
    {
        if (URL::get_matched_rule()->entire_match == 'user/login') {
            // Login page; don't dipslay
            return;
        }
        if (User::identify()->loggedin) {
            // Only track the logged in user if we were told to
            if (Options::get('getclicky__loggedin')) {
                return;
            }
        }
        $siteid = Options::get('getclicky__siteid');
        $sitedb = Options::get('getclicky__sitedb');
        echo <<<ENDAD
<a title="Clicky Web Analytics" href="http://getclicky.com/{$siteid}">
  <img alt="Clicky Web Analytics" src="http://static.getclicky.com/media/links/badge.gif" border="0" />
</a>
<script src="http://static.getclicky.com/{$siteid}.js" type="text/javascript"></script>
<noscript>
  <p>
    <img alt="Clicky" src="http://static.getclicky.com/{$siteid}-{$sitedb}.gif" />
  </p>
</noscript>
ENDAD;
    }
Example #6
0
 public function filter_theme_call_header($return, $theme)
 {
     if (User::identify() != FALSE) {
         Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery');
     }
     return $return;
 }
 /**
  * Add additional controls to the publish page tab
  *
  * @param FormUI $form The form that is used on the publish page
  * @param Post $post The post being edited
  */
 public function action_form_publish($form, $post)
 {
     // If quote has been sent in the URL, insert the quote data in the post
     $this->handler_vars = Controller::get_handler_vars();
     if (array_key_exists('quote', $this->handler_vars)) {
         $form->title->value = $this->handler_vars['title'];
         // Get the user so that we can grab the saved templates and tags
         $user = User::identify();
         $title = $user->info->title__template;
         if (!$title) {
             $title = self::$default_title_template;
         }
         // Filter the quote title using the title template
         $form->title->value = preg_replace_callback('%\\{\\$(.+?)\\}%', array(&$this, 'replace_parts'), $title);
         // Only change the slug if the template is set. For example, you might have HTML in the title.
         $slug = $user->info->slug__template;
         if ($slug) {
             // Filter the quote title using the title template
             $form->newslug->value = preg_replace_callback('%\\{\\$(.+?)\\}%', array(&$this, 'replace_parts'), $slug);
         }
         $content = $user->info->content__template;
         if (!$content) {
             $content = self::$default_content_template;
         }
         // Filter the quote content using the content template
         $form->content->value = preg_replace_callback('%\\{\\$(.+?)\\}%', array(&$this, 'replace_parts'), $content);
         // Add tags for quotes
         $tags = $user->info->quote__tags;
         if ($tags) {
             $form->tags->value = $tags;
         }
     }
 }
 /**
  * Produce the content for the latest drafts block
  * @param Block $block The block object
  * @param Theme $theme The theme that the block will be output with
  */
 public function action_block_content_draft_posts($block, $theme)
 {
     $block->recent_posts = Posts::get(array('status' => 'draft', 'limit' => 8, 'user_id' => User::identify()->id));
     if (User::identify()->can('manage_entries')) {
         $block->link = URL::get('admin', array('page' => 'posts', 'status' => Post::status('draft'), 'user_id' => User::identify()->id));
     }
 }
 /**
  * Filter Atom Feed
  * @param SimpleXMLElement $feed_entry the Atom feed entry
  * @param Post $post The post
  * @return SimpleXMLElement the filtered Atom feed entry
  */
 public function action_atom_add_post($feed_entry, $post)
 {
     // Only apply changes to unauthenticated viewers.  This allows markdown to be used in atompub clients too.
     if (!User::identify()->loggedin) {
         $feed_entry->content = MarkdownFormat::markdown($post->content);
     }
     return $feed_entry;
 }
Example #10
0
 /**
  * Validation for the add_group form
  * @param mixed $unused This is technically the value of the form itself, which is unknown
  * @param FormUI $form The add_group form
  * @return array An array of errors, or an empty array if no errors
  */
 public function validate_add_group($unused, $form)
 {
     $errors = array();
     if (!User::identify()->can('manage_groups')) {
         $errors[] = _t('You have insufficient permissions to add groups.');
     }
     return $errors;
 }
 /**
  * Handles AJAX requests from the dashboard
  */
 public function ajax_dashboard($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $this->create_theme();
     $this->get_additem_form();
     $available_modules = Plugins::filter('dashboard_block_list', array());
     $user_id = User::identify()->id;
     $dashboard_area = 'dashboard_' . $user_id;
     switch ($handler_vars['action']) {
         case 'updateModules':
             $modules = $_POST['moduleOrder'];
             $order = 0;
             foreach ($modules as $module) {
                 $order++;
                 DB::query('UPDATE {blocks_areas} SET display_order = :display_order WHERE block_id = :id AND area = :dashboardarea', array('display_order' => $order, 'id' => $module, 'dashboardarea' => $dashboard_area));
             }
             $ar = new AjaxResponse(200, _t('Modules updated.'));
             break;
         case 'addModule':
             $type = $handler_vars['module_name'];
             $title = $available_modules[$type];
             $block = new Block(array('title' => $title, 'type' => $type));
             $block->insert();
             $max_display_order = DB::get_value('SELECT max(display_order) FROM {blocks_areas} WHERE area = :dashboardarea and scope_id = 0;', array('dashboardarea' => $dashboard_area));
             $max_display_order++;
             DB::query('INSERT INTO {blocks_areas} (block_id, area, scope_id, display_order) VALUES (:block_id, :dashboardarea, 0, :display_order)', array('block_id' => $block->id, 'display_order' => $max_display_order, 'dashboardarea' => $dashboard_area));
             $ar = new AjaxResponse(200, _t('Added module %s.', array($title)));
             $ar->html('modules', $this->theme->fetch('dashboard_modules'));
             break;
         case 'removeModule':
             $block_id = $handler_vars['moduleid'];
             DB::delete('{blocks}', array('id' => $block_id));
             DB::delete('{blocks_areas}', array('block_id' => $block_id));
             $ar = new AjaxResponse(200, _t('Removed module.'));
             $ar->html('modules', $this->theme->fetch('dashboard_modules'));
             break;
         case 'configModule':
             $block_id = $handler_vars['moduleid'];
             $block = DB::get_row('SELECT * FROM {blocks} b WHERE b.id = :id', array('id' => $block_id), 'Block');
             /** Block $block */
             $form = $block->get_form();
             $form->_ajax = true;
             $form->set_option('success_message', _t('Module Configuration Saved.') . '<script type="text/javascript">window.setTimeout(function(){$(".form_message").fadeOut();}, 2000);</script>');
             $control_id = new FormControlHidden('moduleid', 'null:null');
             $control_id->value = $block->id;
             $control_id->id = 'moduleid';
             $form->append($control_id);
             $control_action = new FormControlHidden('action', 'null:null');
             $control_action->value = 'configModule';
             $control_action->id = 'action';
             $form->append($control_action);
             $form->out();
             $form_id = $form->name;
             exit;
             break;
     }
     $ar->out();
 }
 public function action_add_template_vars($theme)
 {
     if ($theme->admin_page == 'livehelp') {
         $user = User::identify();
         $nick = $user->username;
         $nick = $nick == 'admin' ? substr($user->email, 0, strpos($user->email, '@')) : $nick;
         $theme->assign('nick', $nick);
     }
 }
 /**
  *
  */
 public function action_init()
 {
     if (User::identify()->loggedin) {
         header("X-Account-Management-Status: active; name='" . User::identify()->username . "'");
     } else {
         header("X-Account-Management-Status: passive");
     }
     header('X-Account-Management: ' . URL::get('amcd'));
 }
Example #14
0
 /**
  * Write an entry to the event log.
  *
  * @param string $message The message
  * @param string $severity The severity
  * @param string $type The type
  * @param string $module The module
  * @param mixed $data The data
  * @return object LogEntry The inserted LogEntry object
  */
 public static function log($message, $severity = 'info', $type = 'default', $module = null, $data = null)
 {
     $module = self::get_module($module);
     $log = new LogEntry(array('message' => $message, 'severity' => $severity, 'module' => $module, 'type' => $type, 'data' => $data, 'ip' => Utils::get_ip()));
     $user = User::identify();
     if ($user->loggedin) {
         $log->user_id = $user->id;
     }
     $log->insert();
     return $log;
 }
 /**
  * Handle register_success action
  */
 public function action_plugin_act_register_success($handler)
 {
     if (!User::identify()->loggedin) {
         Utils::redirect(URL::get('register_page'), false);
     }
     $handler->theme->user = User::identify();
     Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery', array('jquery'));
     // Stack::add( 'template_header_javascript', Site::get_url('admin_theme') . "/js/admin.js", 'admin', array('jquery', 'registration') );
     Stack::add('template_header_javascript', URL::get_from_filesystem(__FILE__) . '/registration.js', 'registration', array('jquery'));
     Stack::add('template_stylesheet', array(URL::get_from_filesystem(__FILE__) . '/registration.css', 'screen'), 'registration', array());
     $handler->theme->display('registration.success');
 }
Example #16
0
 public function get_form()
 {
     $users = Users::get_all();
     $users = Utils::array_map_field($users, 'username', 'id');
     $form = new FormUI('sudo');
     $form->append(new FormControlSelect('userlist', 'null:null', 'Become User:'******'submit', 'Submit'));
     $form->set_option('form_action', URL::get('sudo'));
     $form->onsubmit = 'return dosudo.setuser();';
     return $form;
 }
Example #17
0
 /**
  * Get the jambo form
  */
 public function get_jambo_form($attrs, $context = null)
 {
     // borrow default values from the comment forms
     $commenter_name = '';
     $commenter_email = '';
     $commenter_url = '';
     $commenter_content = '';
     $user = User::identify();
     if (isset($_SESSION['comment'])) {
         $details = Session::get_set('comment');
         $commenter_name = $details['name'];
         $commenter_email = $details['email'];
         $commenter_url = $details['url'];
         $commenter_content = $details['content'];
     } elseif ($user->loggedin) {
         $commenter_name = $user->displayname;
         $commenter_email = $user->email;
         $commenter_url = Site::get_url('habari');
     }
     // Process settings from shortcode and database
     $settings = array('subject' => Options::get('jambo__subject'), 'send_to' => Options::get('jambo__send_to'), 'success_message' => Options::get('jambo__success_msg', 'Thank you contacting me. I\'ll get back to you as soon as possible.'));
     $settings = array_merge($settings, $attrs);
     // Now start the form.
     $form = new FormUI('jambo');
     // 		$form->set_option( 'form_action', URL::get( 'submit_feedback', array( 'id' => $this->id ) ) );
     // Create the Name field
     $form->append('text', 'jambo_name', 'null:null', _t('Name'), 'formcontrol_text')->add_validator('validate_required', _t('Your Name is required.'))->id = 'jambo_name';
     $form->jambo_name->tabindex = 1;
     $form->jambo_name->value = $commenter_name;
     // Create the Email field
     $form->append('text', 'jambo_email', 'null:null', _t('Email'), 'formcontrol_text')->add_validator('validate_email', _t('Your Email must be a valid address.'))->id = 'jambo_email';
     $form->jambo_email->tabindex = 2;
     $form->jambo_email->caption = _t('Email');
     $form->jambo_email->value = $commenter_email;
     // Create the Subject field, if requested
     if (self::ask_subject($settings['subject'])) {
         $form->append('text', 'jambo_subject', 'null:null', _t('Subject'), 'formcontrol_text')->id = 'jambo_subject';
         $form->jambo_subject->tabindex = 32;
     }
     // Create the Message field
     $form->append('text', 'jambo_message', 'null:null', _t('Message', 'jambo'), 'formcontrol_textarea')->add_validator('validate_required', _t('Your message cannot be blank.', 'jambo'))->id = 'jambo_message';
     $form->jambo_message->tabindex = 4;
     // Create the Submit button
     $form->append('submit', 'jambo_submit', _t('Submit'), 'formcontrol_submit');
     $form->jambo_submit->tabindex = 5;
     // Set up form processing
     $form->on_success(array($this, 'process_jambo'), $settings);
     Plugins::act('jambo_build_form', $form, $this);
     // Allow modification of form
     // Return the form object
     return $form;
 }
 /**
  * Output the content of the block, and nothing else.
  **/
 public function action_block_content($block, $theme)
 {
     if (User::identify()->loggedin) {
         $block_id = 'inline_block_' . $block->id;
         $href = URL::get('admin', array('page' => 'configure_block', 'blockid' => $block->id, 'inline' => 1, 'iframe' => 'true', 'width' => 600, 'height' => 400, 'block' => $block_id));
         if ($_GET['inline'] == 1) {
             $block->content = '<a class="editable-block-link" href="' . $href . '" onclick="$.prettyPhoto.open($(this).attr(\'href\'),\'Edit Content\',\'Hello!\');return false;">Edit</a>' . $block->content;
         } else {
             $block->content = '<div class="editable-inline-block" id="' . $block_id . '"><a class="editable-block-link" href="' . $href . '" onclick="$.prettyPhoto.open($(this).attr(\'href\'),\'Edit Content\',\'Edit the content, then click Save.  Reload the page to see the changes.\');return false;">Edit</a>' . $block->content . '</div>';
         }
     }
     return $block;
 }
    /**
     * Lilina installer
     *
     * Installs Lilina after going through many complicated checks
     *
     * @param string $sitename Name of the site
     * @param string $username Initial username of the admin user
     * @param string $password Initial password of the admin user
     * @return bool True if the installer succeeded, false otherwise
     */
    public function install($sitename, $username, $password)
    {
        require_once LILINA_INCPATH . '/core/version.php';
        $settings = $this->generate_default_settings($sitename, $username, $password);
        if (!is_writable(LILINA_PATH . '/content/system/config/') || !($settings_file = @fopen(LILINA_PATH . '/content/system/config/settings.php', 'w+'))) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/settings.php', $sitename, $username, $password);
            return false;
        }
        fputs($settings_file, $settings);
        fclose($settings_file);
        if (file_exists(LILINA_PATH . '/content/system/config/feeds.data')) {
            echo "<p>Using existing feeds data</p>\n";
        } else {
            $feeds_file = new DataHandler(LILINA_CONTENT_DIR . '/system/config/');
            $feeds_file = $feeds_file->save('feeds.json', json_encode(array()));
            if (!$feeds_file) {
                $this->file_error_notice(LILINA_PATH . '/content/system/config/feeds.json', $sitename, $username, $password);
                return false;
            }
        }
        /** Make sure it's writable now */
        if (!$this->make_writable(LILINA_PATH . '/content/system/config/feeds.json')) {
            echo "<p>Couldn't make <code>content/system/config/feeds.json</code> writable. Please ensure you make it writable yourself</p>\n";
        }
        default_options();
        Options::lazy_update('sitename', $sitename);
        if (!Options::save()) {
            $this->file_error_notice(LILINA_PATH . '/content/system/config/options.data', $sitename, $username, $password);
            return false;
        }
        $user = new User($username, $password);
        $user->identify();
        ?>
	<h1 id="title">Installation Complete!</h1>
	<p>Lilina has been installed and is now ready to go. Please note your username and password below, as it <strong>won't be shown again</strong>!</p>
	<dl id="logindetails">
		<dt>Your username is</dt>
		<dd id="username"><?php 
        echo $username;
        ?>
</dd>
		<dt>and your password is</dt>
		<dd id="password"><?php 
        echo $password;
        ?>
</dd>
	</dl>
	<p><a href="admin/">Head to the admin panel</a> to get started!</p>
	<?php 
        return true;
    }
Example #20
0
 /**
  * Handles incoming ajax requests for which the user must be authenticated.
  * Forwards the request to plugin actions for the "context" portion of the URL.
  *
  * @see act_ajax()
  */
 public function act_auth_ajax()
 {
     $user = User::identify();
     if ($user->loggedin) {
         /**
          * Triggers the ajax plugin action for the context if user is authenticated.
          *
          * @see act_auth_ajax()
          * @action ajax_auth_{$context}
          */
         Plugins::act('auth_ajax_' . $this->handler_vars['context'], $this);
         exit;
     }
 }
 function check_comment($comment)
 {
     // don't blacklist logged-in users: they can speak freely
     if (User::identify()->loggedin) {
         return true;
     }
     // and if the person has more than 5 comments approved,
     // they're likely not a spammer, so don't blacklist them
     $bypass = Options::get('simpleblacklist__frequency', false);
     if ($bypass) {
         $comments = Comments::get(array('email' => $comment->email, 'name' => $comment->name, 'url' => $comment->url, 'status' => Comment::STATUS_APPROVED));
         if ($comments->count >= 5) {
             return true;
         }
     }
     $allow = true;
     $reason = "";
     $blacklist = explode("\n", Options::get('simpleblacklist__blacklist'));
     foreach ($blacklist as $item) {
         $item = trim(strtolower($item));
         if ('' == $item) {
             continue;
         }
         // check against the commenter name
         if (false !== strpos(strtolower($comment->name), $item)) {
             $allow = false;
         }
         // check against the commenter email
         if (false !== strpos(strtolower($comment->email), $item)) {
             $allow = false;
         }
         // check against the commenter URL
         if (false !== strpos(strtolower($comment->url), $item)) {
             $allow = false;
         }
         // check against the commenter IP address
         if ((strpos($comment->ip, '.') > 0 ? $comment->ip : long2ip($comment->ip)) == $item) {
             $allow = false;
         }
         // now check the body of the comment
         if (false !== strpos(strtolower($comment->content), $item)) {
             $allow = false;
         }
         if ($allow === false) {
             break;
         }
     }
     return $allow;
 }
Example #22
0
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'))));
     }
     if (!$this->template_engine->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', isset($page) ? $page : 1);
     }
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 8, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
     parent::add_template_vars();
 }
/**
 * lilina_login_form() - Check authentication and display a login form if needed
 *
 * @param string $user Supplied username
 * @param string $pass Supplied password
 * @return null
 */
function lilina_login_form($user, $pass)
{
    $user = new User($user, $pass);
    $result = $user->identify();
    if ($result === true) {
        define('LILINA_AUTHED', true);
        return;
    }
    if (!defined('LILINA_LOGIN')) {
        header('HTTP/1.1 302 Found');
        header('Location: ' . get_option('baseurl') . 'admin/login.php');
        header('Connection: close');
        die;
    }
    define('LILINA_AUTH_ERROR', $result);
}
Example #24
0
 /**
  * Check if a user is authenticated for Atom editing
  *
  * @todo This entire function should be put into the User class somehow.
  * @todo X-WSSE
  * @param bool $force Force authorization? If so, basic HTTP_AUTH is displayed if not authed
  * @return User The logged-in user
  */
 function is_auth($force = FALSE)
 {
     if ($this->user == NULL || $force != FALSE) {
         if (isset($_SERVER['PHP_AUTH_USER'])) {
             User::authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
         }
         $this->user = User::identify();
         if ($force != FALSE && !$this->user->loggedin) {
             header('HTTP/1.1 401 Unauthorized');
             header('Status: 401 Unauthorized');
             header('WWW-Authenticate: Basic realm="Habari"');
             die;
         }
     }
     return $this->user->loggedin;
 }
Example #25
0
 public function add_template_vars()
 {
     $this->assign('home_tab', 'Blog');
     //Set to whatever you want your first tab text to be.
     if (!$this->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     if (!$this->assigned('user')) {
         $this->assign('user', User::identify());
     }
     if (!$this->assigned('recent_entries')) {
         $this->assign('recent_entries', Posts::get(array('limit' => 10, 'content_type' => 'entry', 'status' => Post::status('published'), 'orderby' => 'pubdate DESC')));
     }
     $this->add_template('binadamu_submit', dirname(__FILE__) . '/formcontrol_submit.php');
     parent::add_template_vars();
 }
Example #26
0
 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     parent::add_template_vars();
     // Use theme options to set values that can be used directly in the templates
     $opts = Options::get_group(__CLASS__);
     $this->assign('show_title_image', $opts['show_title_image']);
     $this->assign('home_label', $opts['home_label']);
     $this->assign('show_powered', $opts['show_powered']);
     $this->assign('display_login', $opts['display_login']);
     $this->assign('tags_in_multiple', $opts['tags_in_multiple']);
     $this->assign('post_class', 'post' . (!$opts['show_entry_paperclip'] ? ' alt' : ''));
     $this->assign('page_class', 'post' . (!$opts['show_page_paperclip'] ? ' alt' : ''));
     $this->assign('show_post_nav', $opts['show_post_nav']);
     $this->assign('loggedin', User::identify()->loggedin);
     $locale = Options::get('locale');
     if ($this->get_url($locale . '.css')) {
         $this->assign('localized_css', $locale . '.css');
     } else {
         $this->assign('localized_css', false);
     }
     if ($opts['show_title_image']) {
         if ($this->get_url('images.' . $locale . '/title-image.png')) {
             $this->assign('title_image', 'images.' . $locale . '/title-image.png');
         } else {
             if ($this->get_url('images/title-image.png')) {
                 $this->assign('title_image', 'images/title-image.png');
             } else {
                 $this->assign('title_image', 'images/sample-title.png');
             }
         }
     }
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get('page_list'));
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     if (is_object($this->request) && $this->request->display_entries_by_tag) {
         if (count($this->include_tag) && count($this->exclude_tag) == 0) {
             $this->tags_msg = _t('Displaying posts tagged: %s', array(Format::tag_and_list($this->include_tag)));
         } else {
             if (count($this->exclude_tag) && count($this->include_tag) == 0) {
                 $this->tags_msg = _t('Displaying posts not tagged: %s', array(Format::tag_and_list($this->exclude_tag)));
             } else {
                 $this->tags_msg = _t('Displaying posts tagged: %s and not %s', array(Format::tag_and_list($this->include_tag), Format::tag_and_list($this->exclude_tag)));
             }
         }
     }
 }
Example #27
0
	/**
	 * Check if a user is authenticated for Atom editing
	 *
	 * @todo This entire function should be put into the User class somehow.
	 * @todo X-WSSE
	 * @param bool $force Force authorization? If so, basic HTTP_AUTH is displayed if not authed
	 * @return User The logged-in user
	 */
	function is_auth( $force = false )
	{
		if ( ( $this->user == null ) || ( $force != false ) ) {
			if ( isset( $_SERVER['PHP_AUTH_USER'] ) ) {
				User::authenticate( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] );
			}

			$this->user = User::identify();
			if ( ( $force != false ) && ( !$this->user->loggedin ) ) {
				header( 'HTTP/1.1 401 Unauthorized', true, 401 );
				header( 'Status: 401 Unauthorized' );
				header( 'WWW-Authenticate: Basic realm="Habari"' );
				die();
			}
		}
		return $this->user->loggedin;
	}
Example #28
0
/**
 * lilina_login_form() - Check authentication and display a login form if needed
 *
 * @param string $user Supplied username
 * @param string $pass Supplied password
 * @return null
 */
function lilina_login_form($user, $pass)
{
    $user = new User($user, $pass);
    $result = $user->identify();
    if ($result === true) {
        define('LILINA_AUTHED', true);
        return;
    }
    if (!defined('LILINA_LOGIN')) {
        preg_match_all('#(.*?)/(admin/.*)#i', $_SERVER['REQUEST_URI'], $current);
        $current = $current[2][0];
        header('HTTP/1.1 302 Found');
        header('Location: ' . get_option('baseurl') . 'admin/login.php?return=' . $current);
        header('Connection: close');
        die;
    }
    define('LILINA_AUTH_ERROR', $result);
}
Example #29
0
 /**
  * instapaper method
  */
 public static function page()
 {
     $user = new User();
     if (!$user->identify()) {
         Instapaper::error(sprintf(_r('Please <a href="%s">log in</a> first', 'instapaper'), get_option('baseurl') . 'admin/login.php'));
     }
     if (get_option('instapaper_user') === null) {
         Instapaper::error(sprintf(_r('Please set your username in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
     }
     if (empty($_GET['item'])) {
         Instapaper::error(_r('No item ID specified.', 'instapaper'));
     }
     try {
         Instapaper::submit();
     } catch (Exception $e) {
         Instapaper::error($e->getMessage());
     }
 }
Example #30
-1
 public function filter_post_content($content, Post $post)
 {
     if ($post->info->password) {
         // if user logged in, show post
         // make sure it's not just the anonymous user!
         $user = User::identify();
         if ($user instanceof User && $user != User::anonymous()) {
             return $content;
         }
         $session = Session::get_set('post_passwords', false);
         $token = Utils::crypt('42' . $post->info->password . $post->id . Options::get('GUID'));
         // if password was submitted verify it
         if (Controller::get_var('post_password') && Controller::get_var('post_password_id') == $post->id) {
             $pass = InputFilter::filter(Controller::get_var('post_password'));
             if (Utils::crypt($pass, $post->info->password)) {
                 Session::add_to_set('post_passwords', $token, $post->id);
                 $session[$post->id] = $token;
             } else {
                 Session::error(_t('That password was incorrect.', 'postpass'));
             }
         }
         // if password is stored in session verify it
         if (isset($session[$post->id]) && $session[$post->id] == $token) {
             return $content;
         } else {
             $theme = Themes::create();
             $theme->post = $post;
             return $theme->fetch('post_password_form');
         }
     } else {
         return $content;
     }
 }