Пример #1
0
 public function __construct(Options $options)
 {
     $this->token = $options->get('token');
     if (empty($this->token)) {
         SS_Envato_API()->notices->add_warning('Please, set up your Envato API token.', true);
     }
 }
Пример #2
0
 public function getOption($key)
 {
     if (null === $this->options) {
         return null;
     }
     return $this->options->getOption($key);
 }
Пример #3
0
 public static function initialize($idO, $idS, $new)
 {
     $OO = self::retrieveByPK($idO, $idS);
     if (!$OO instanceof Options) {
         $OO = new Options();
         $OO->setSiteId($idS);
     }
     return new OptionsForm($OO, array('IDS' => $idS, 'NEW' => $new));
 }
Пример #4
0
 public function addAction($question_id)
 {
     $this->view->poll = Questions::findFirst($question_id);
     if ($this->request->isPost()) {
         $option = new Options();
         $option->question_id = $question_id;
         $option->option_name = $this->request->getPost('name');
         $option->vote = 0;
         $option->save();
         return $this->dispatcher->forward(array('action' => 'show', 'params' => array($question_id)));
     }
 }
 /**
  * On plugin init
  **/
 public function action_init()
 {
     $this->class_name = strtolower(get_class($this));
     foreach (self::default_options() as $name => $value) {
         $this->config[$name] = Options::get($this->class_name . '__' . $name);
     }
 }
Пример #6
0
 public function __construct()
 {
     $this->connection = @mysqli_connect(Options::get("mysql_host"), Options::get("mysql_user"), Options::get("mysql_password"), Options::get("mysql_db"));
     if (!$this->connection) {
         throw new Exception("Couldn't connect to database.", 1);
     }
 }
Пример #7
0
 public function __construct(array $options = array(), Options $defaults = null)
 {
     $options = array_change_key_case($options, CASE_LOWER);
     if ($defaults) {
         $options += $defaults->get();
     }
     if (!empty($options['enable'])) {
         if (empty($options['plugins'])) {
             $options['plugins'] = $options['enable'];
         }
         unset($options['enable']);
     }
     foreach ($options + self::$standardOptions as $name => $value) {
         $this->__set($name, $value);
     }
 }
Пример #8
0
 public static function plot()
 {
     $gnuscript = Options::getOption("harvester_gnu_script");
     if (Options::getOption("useGnuplot")) {
         system("gnuplot {$gnuscript}");
     }
 }
Пример #9
0
	/**
	 * Determine if the database needs to be updated based on the source database version being newer than the schema last applied to the database
	 *
	 * @return boolean True if an update is needed
	 */
	public static function requires_upgrade()
	{
		if ( Options::get( 'db_version' ) < Version::DB_VERSION ) {
			return true;
		}
		return false;
	}
Пример #10
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id = false)
 {
     if ($id === false) {
         $model = new Picture();
     } else {
         $model = $this->loadModel($id);
     }
     $msg = '';
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Picture'])) {
         $model->attributes = $_POST['Picture'];
         $path = Options::getOption('imgPath') . '/' . date('Y') . '/' . date('m') . '/' . date('his') . '-';
         $model->image = $path . CUploadedFile::getInstance($model, 'image');
         if ($model->save()) {
             $pathTo = $_SERVER['DOCUMENT_ROOT'] . $model->image;
         }
         $pathFrom = $_FILES['Picture']['tmp_name']['image'];
         Controller::createPathUploadsNow();
         if (!copy($pathFrom, $pathTo)) {
             $msg = '<p style="color: red; margin: 5px; border: 1px solid red; text-align: center">Файл не был записан.</p>';
         } else {
             chmod($pathTo, 0777);
             $msg = '<p style="color: green; margin: 5px; border: 1px solid green; text-align: center">Файл был записан.</p>';
         }
     }
     $this->render('create', array('model' => $model, 'msg' => $msg));
 }
Пример #11
0
 public function filter_default_rewrite_rules($rules)
 {
     if ($this->current_load() > self::KILL_LOAD) {
         foreach ($rules as $key => $rule) {
             if (strpos($rule['build_str'], 'admin') !== false) {
                 $rules[$key]['handler'] = 'UserThemeHandler';
                 $rules[$key]['action'] = 'display_throttle';
             }
         }
         if (Options::get('throttle') == '') {
             EventLog::log(sprintf(_t('Kill - Load is %s'), $this->current_load()));
             Options::set('throttle', 'kill');
         }
     } elseif ($this->current_load() > self::MAX_LOAD) {
         foreach ($rules as $key => $rule) {
             if ($rule['name'] == 'search') {
                 unset($rules[$key]);
             }
         }
         $rules[] = array('name' => 'search', 'parse_regex' => '%^search(?:/(?P<criteria>[^/]+))?(?:/page/(?P<page>\\d+))?/?$%i', 'build_str' => 'search(/{$criteria})(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_throttle', 'priority' => 8, 'description' => 'Searches posts');
         if (Options::get('throttle') == '') {
             EventLog::log(sprintf(_t('Restrict - Load is %s'), $this->current_load()));
             Options::set('throttle', 'restrict');
         }
     } else {
         if (Options::get('throttle') != '') {
             EventLog::log(sprintf(_t('Normal - Load is %s'), $this->current_load()));
             Options::set('throttle', '');
         }
     }
     return $rules;
 }
Пример #12
0
 public function extractPage($pageID, $pageTitle, $pageSource)
 {
     $this->extractor->setPageURI($pageID);
     if (!$this->extractor->isActive()) {
         return $result = new ExtractionResult($pageID, $this->extractor->getLanguage(), $this->getExtractorID());
     }
     Timer::start($this->extractor->getExtractorID());
     $result = $this->extractor->extractPage($pageID, $pageTitle, $pageSource);
     Timer::stop($this->extractor->getExtractorID());
     Timer::start('validation');
     //$this->extractor->check();
     if (Options::getOption('validateExtractors')) {
         ValidateExtractionResult::validate($result, $this->extractor);
     }
     Timer::stop('validation');
     Statistics::increaseCount($this->extractor->getExtractorID(), 'created_Triples', count($result->getTriples()));
     Statistics::increaseCount('Total', 'created_Triples', count($result->getTriples()));
     if ($this->extractor->isGenerateOWLAxiomAnnotations()) {
         $triples = $result->getTriples();
         if (count($triples) > 0) {
             foreach ($triples as $triple) {
                 $triple->addDCModifiedAnnotation();
                 $triple->addExtractedByAnnotation($this->extractor->getExtractorID());
             }
         }
     }
     return $result;
 }
function users_list_alm_users_user_photo_BeforeShow(&$sender)
{
    $users_list_alm_users_user_photo_BeforeShow = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $users_list;
    //Compatibility
    //End users_list_alm_users_user_photo_BeforeShow
    //Custom Code @31-2A29BDB7
    // -------------------------
    // Write your own code here.
    $db = new clsDBdbConnection();
    $user_guid = $users_list->alm_users->guid->GetValue();
    $photo = trim(CCDLookup("photo", "alm_users", "guid = '{$user_guid}'", $db));
    //Default photo
    if (strlen($photo) <= 0) {
        $photo = "user128.png";
    }
    $options = Options::getConsoleOptions();
    $url = $options["console_internal_url"] . $options["console_users_url"] . $photo;
    $users_list->alm_users->user_photo->SetValue($url);
    $db->close();
    // -------------------------
    //End Custom Code
    //Close users_list_alm_users_user_photo_BeforeShow @30-EE399A43
    return $users_list_alm_users_user_photo_BeforeShow;
}
 public function action_post_update_before($post)
 {
     $aliases = self::get_aliases();
     if (Options::get('tagrewriter__plurals') != NULL && Options::get('tagrewriter__plurals') == 1) {
         $pluralize = true;
     } else {
         $pluralize = false;
     }
     $tags = array();
     foreach ($post->tags as $tag) {
         if (isset($aliases[$tag])) {
             $tags[] = $aliases[$tag];
             continue;
         }
         if ($pluralize) {
             if (Tags::get_by_slug($tag . 's') != false) {
                 $tags[] = $tag . 's';
                 continue;
             } elseif (Tags::get_by_slug(rtrim($tag, 's')) != false) {
                 $tags[] = rtrim($tag, 's');
                 continue;
             }
         }
         $tags[] = $tag;
     }
     $post->tags = $tags;
 }
Пример #15
0
    public function action_comment_insert_after($comment)
    {
        // we should only execute on comments, not pingbacks
        // and don't bother if the comment is know to be spam
        if ($comment->type != Comment::COMMENT || $comment->status == Comment::STATUS_SPAM) {
            return;
        }
        $post = Post::get(array('id' => $comment->post_id));
        $author = User::get_by_id($post->user_id);
        $status = $comment->status == Comment::STATUS_UNAPPROVED ? ' UNAPPROVED' : ' approved';
        $title = sprintf(_t('[%1$s] New%3$s comment on: %2$s'), Options::get('title'), $post->title, $status);
        $message = <<<MESSAGE
The following comment was added to the post "%1\$s".
%2\$s

Author: %3\$s <%4\$s>
URL: %5\$s

%6\$s

-----
Moderate comments: %7\$s
MESSAGE;
        $message = _t($message);
        $message = sprintf($message, $post->title, $post->permalink, $comment->name, $comment->email, $comment->url, $comment->content, URL::get('admin', 'page=comments'));
        $headers = array('MIME-Version: 1.0', 'Content-type: text/plain; charset=utf-8', 'Content-Transfer-Encoding: 8bit', 'From: ' . $this->mh_utf8($comment->name) . ' <' . $comment->email . '>');
        mail($author->email, $this->mh_utf8($title), $message, implode("\r\n", $headers));
    }
Пример #16
0
 /**
  * Upload Proccess Function.
  * This will do the upload proccess. This function need some variables, eg: 
  * @param string $input This is the input field name.
  * @param string $path This is the path the file will be stored.
  * @param array $allowed This is the array of the allowed file extension.
  * @param false $uniq Set to true if want to use a unique name.
  * @param int $size File size maximum allowed.
  * @param int $width The width of the dimension.
  * @param int $height The height of the dimension.
  * 
  * @return array
  *
  * @author Puguh Wijayanto (www.metalgenix.com)
  * @since 0.0.1
  */
 public static function go($input, $path, $allowed = '', $uniq = false, $size = '', $width = '', $height = '')
 {
     $filename = Typo::cleanX($_FILES[$input]['name']);
     $filename = str_replace(' ', '_', $filename);
     if (isset($_FILES[$input]) && $_FILES[$input]['error'] == 0) {
         if ($uniq == true) {
             $site = Typo::slugify(Options::get('sitename'));
             $uniqfile = $site . '-' . sha1(microtime() . $filename) . '-';
         } else {
             $uniqfile = '';
         }
         $extension = pathinfo($_FILES[$input]['name'], PATHINFO_EXTENSION);
         $filetmp = $_FILES[$input]['tmp_name'];
         $filepath = GX_PATH . $path . $uniqfile . $filename;
         if (!in_array(strtolower($extension), $allowed)) {
             $result['error'] = 'File not allowed';
         } else {
             if (move_uploaded_file($filetmp, $filepath)) {
                 $result['filesize'] = filesize($filepath);
                 $result['filename'] = $uniqfile . $filename;
                 $result['path'] = $path . $uniqfile . $filename;
                 $result['filepath'] = $filepath;
                 $result['fileurl'] = Site::$url . $path . $uniqfile . $filename;
             } else {
                 $result['error'] = 'Cannot upload to directory, please check 
                 if directory is exist or You had permission to write it.';
             }
         }
     } else {
         //$result['error'] = $_FILES[$input]['error'];
         $result['error'] = '';
     }
     return $result;
 }
Пример #17
0
 public static function check_posts($nolimit = false)
 {
     $autoclosed = array();
     $age_in_days = Options::get('autoclose__age_in_days');
     if (is_null($age_in_days)) {
         return;
     }
     $age_in_days = abs(intval($age_in_days));
     $search = array('content_type' => 'entry', 'before' => HabariDateTime::date_create()->modify('-' . $age_in_days . ' days'), 'nolimit' => true, 'status' => 'published');
     if (!$nolimit) {
         $search['after'] = HabariDateTime::date_create()->modify('-' . ($age_in_days + 30) . ' days');
     }
     $posts = Posts::get($search);
     foreach ($posts as $post) {
         if (!$post->info->comments_disabled && !$post->info->comments_autoclosed) {
             $post->info->comments_disabled = true;
             $post->info->comments_autoclosed = true;
             $post->info->commit();
             $autoclosed[] = sprintf('<a href="%s">%s</a>', $post->permalink, htmlspecialchars($post->title));
         }
     }
     if (count($autoclosed)) {
         if (count($autoclosed) > 5) {
             Session::notice(sprintf(_t('Comments autoclosed for: %s and %d other posts', 'autoclose'), implode(', ', array_slice($autoclosed, 0, 5)), count($autoclosed) - 5));
         } else {
             Session::notice(sprintf(_t('Comments autoclosed for: %s', 'autoclose'), implode(', ', $autoclosed)));
         }
     } else {
         Session::notice(sprintf(_t('Found no posts older than %d days with comments enabled.', 'autoclose'), $age_in_days));
     }
     return true;
 }
Пример #18
0
 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     $page = Controller::get_var('page');
     $page = isset($page) ? $page : 1;
     if (!$this->template_engine->assigned('page')) {
         $this->assign('page', $page);
     }
     $this->assign('show_previously', false);
     $this->assign('show_latest', false);
     $action = Controller::get_action();
     if ($action == 'display_home' || $action == 'display_entries') {
         $offset = (int) (($page + 1 - 1) * Options::get('pagination'));
         $this->assign('previously', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => $offset, 'limit' => self::PREVIOUSLY_ITEMS)));
         $this->assign('show_previously', true);
     }
     if ($action != 'display_home') {
         $this->assign('latest', Posts::get(array('status' => 'published', 'content_type' => 'entry', 'offset' => 0, 'limit' => self::LATEST_ITEMS)));
         $this->assign('show_latest', true);
     }
     $this->assign('controller_action', $action);
     parent::add_template_vars();
 }
Пример #19
0
 public function deleteAction()
 {
     $app = App::getInstance();
     $id = (int) $app->getUrlParam('id');
     Options::delete($id);
     $app->redirect(__HOME__ . '/options/');
 }
Пример #20
0
 /**
  * parse the request URL
  *
  * @return array Matched route
  */
 public static function parseRequest()
 {
     $routes = array('index' => array('url' => '/\\A\\z/', 'controller' => 'SiteHandler', 'action' => 'display_sites'), 'site' => array('url' => '%^site/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site'), 'cron_run' => array('url' => '%^cron/?\\z%', 'controller' => 'CronTab', 'action' => 'act_poll_cron'), 'site_create' => array('url' => '%^site/create/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site_create'), 'site_update' => array('url' => '%^site/update/?\\z%', 'controller' => 'SiteHandler', 'action' => 'site_update'), 'site_delete' => array('url' => '%^site/delete/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site_delete'), 'site_create_from_page' => array('url' => '%^site/from-page/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site_create_from_page'), 'site_create_from_sitemap' => array('url' => '%^site/from-sitemap/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site_create_from_sitemap'), 'site_page' => array('url' => '%^site/page/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site_page'), 'site_keyword_add' => array('url' => '%^site/keyword/add/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_site_keyword_add'), 'site_page_update' => array('url' => '%^site/page/update/?\\z%', 'controller' => 'SiteHandler', 'action' => 'site_page_update'), 'site_page_inlink_update' => array('url' => '%^site/page/inlink/update/?\\z%', 'controller' => 'SiteHandler', 'action' => 'site_page_inlink_update'), 'settings' => array('url' => '%^settings/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_settings'), 'logs' => array('url' => '%^logs/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_logs'), 'login' => array('url' => '%^login/?\\z%', 'controller' => 'SiteHandler', 'action' => 'display_login'), 'logout' => array('url' => '%^logout/?\\z%', 'controller' => 'SiteHandler', 'action' => 'do_logout'), '404' => array('url' => '/\\A.*$/', 'controller' => 'SiteHandler', 'action' => 'display_404'));
     // get the request parts, 404 on error
     if (!($request_parts = parse_url($_SERVER['REQUEST_URI']))) {
         trigger_error('Unable to parse the request URI.', E_USER_ERROR);
         return $routes['404'];
     }
     // format the request url before matching
     $base_path = parse_url(Options::get('base_url'), PHP_URL_PATH);
     $request_url = substr($request_parts['path'], strlen($base_path));
     // match a route
     foreach ($routes as $route) {
         if (preg_match($route['url'], $request_url, $route['params']) == 1) {
             // remove numeric keys
             foreach (array_keys($route['params']) as $k) {
                 if (is_int($k)) {
                     unset($route['params'][$k]);
                 }
             }
             if (isset($request_parts['query'])) {
                 parse_str($request_parts['query'], $query_params);
                 $route['params'] = array_merge($route['params'], $query_params);
             }
             return $route;
         }
     }
     return $routes['404'];
 }
Пример #21
0
 /**
  * Add additional template variables to the template output.
  *
  *  You can assign additional output values in the template here, instead of
  *  having the PHP execute directly in the template.  The advantage is that
  *  you would easily be able to switch between template types (RawPHP/Smarty)
  *  without having to port code from one to the other.
  *
  *  You could use this area to provide "recent comments" data to the template,
  *  for instance.
  *
  *  Note that the variables added here should possibly *always* be added,
  *  especially 'user'.
  *
  *  Also, this function gets executed *after* regular data is assigned to the
  *  template.  So the values here, unless checked, will overwrite any existing
  *  values.
  */
 public function add_template_vars()
 {
     //Theme Options
     $this->assign('home_tab', 'Home');
     //Set to whatever you want your first tab text to be.
     $this->assign('show_author', false);
     //Display author in posts
     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('page')) {
         $page = Controller::get_var('page');
         $this->assign('page', isset($page) ? $page : 1);
     }
     parent::add_template_vars();
     //from mzingi
     //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)));
     //from mzingi
     //for recent comments loop in sidebar.php
     $this->assign('recent_comments', Comments::get(array('limit' => 5, 'status' => Comment::STATUS_APPROVED, 'orderby' => 'date DESC')));
 }
Пример #22
0
 /**
  * Do any wrapper-like things to the Atom feed proper.
  * @param SimpleXMLElement $xml the Atom feed document
  * @return SimpleXMLElement the modified Atom feed document
  */
 public function action_atom_create_wrapper($xml)
 {
     if ($iconurl = Options::get('atomicon_iconurl')) {
         $xml->addChild('icon', $iconurl);
     }
     return $xml;
 }
 /**
  * Create the bookmarklet that is appropriate for the client's User Agent
  *
  * @return array The array of actions to attach to the specified $plugin_id
  */
 private function get_bookmarklet()
 {
     $admin_url = Site::get_url('admin');
     $link_name = Options::get('title');
     $bookmarklet = "\n\t\t<p>Bookmark this link to leave the page when quoting:\n\t\t<a href=\"javascript:var w=window,d=document,gS='getSelection';location.href='{$admin_url}/publish?quote='+encodeURIComponent((''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text)).replace(/(^\\s+|\\s+\$)/g,''))+'&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(d.title);\">Quote on {$link_name}</a>\n\t\t<br>\n\t\tBookmark this link to open a new tab or window when quoting:\n\t\t<a href=\"javascript:var w=window,d=document,gS='getSelection';window.open('{$admin_url}/publish?quote='+encodeURIComponent((''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text)).replace(/(^\\s+|\\s+\$)/g,''))+'&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(d.title));void(0);\">Quote on {$link_name}</a>\n\t\t</p>";
     return $bookmarklet;
 }
Пример #24
0
 public static function getDefaultConnection()
 {
     $dataSourceName = Options::getOption('Store.dsn');
     $username = Options::getOption('Store.user');
     $password = Options::getOption('Store.pw');
     return new ODBC($dataSourceName, $username, $password);
 }
Пример #25
0
 public function testRequires_upgrade()
 {
     Options::set('db_version', Version::DB_VERSION - 1);
     $this->assertEquals(true, Version::requires_upgrade());
     Options::set('db_version', Version::DB_VERSION);
     $this->assertEquals(false, Version::requires_upgrade());
 }
Пример #26
0
 /**
  * Plugin init action, executed when plugins are initialized.
  */
 public function action_init()
 {
     $this->class_name = strtolower(get_class($this));
     foreach ($this->default_options as $name => $unused) {
         $this->config[$name] = Options::get($this->class_name . '__' . $name);
     }
 }
Пример #27
0
 /**
  * Handles get requests for the dashboard
  * @todo update check should probably be cron'd and cached, not re-checked every load
  */
 public function get_dashboard()
 {
     // Not sure how best to determine this yet, maybe set an option on install, maybe do this:
     $firstpostdate = DB::get_value('SELECT min(pubdate) FROM {posts} WHERE status = ?', array(Post::status('published')));
     $this->theme->active_time = HabariDateTime::date_create($firstpostdate);
     // get the active theme, so we can check it
     // @todo this should be worked into the main Update::check() code for registering beacons
     $active_theme = Themes::get_active();
     $active_theme = $active_theme->name . ':' . $active_theme->version;
     // check to see if we have updates to display
     $this->theme->updates = Options::get('updates_available', array());
     // collect all the stats we display on the dashboard
     $this->theme->stats = array('author_count' => Users::get(array('count' => 1)), 'page_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('published'))), 'entry_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('published'))), 'comment_count' => Comments::count_total(Comment::STATUS_APPROVED, false), 'tag_count' => Tags::vocabulary()->count_total(), 'page_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('page'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'entry_draft_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('entry'), 'status' => Post::status('draft'), 'user_id' => User::identify()->id)), 'unapproved_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_UNAPPROVED, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_UNAPPROVED), 'spam_comment_count' => User::identify()->can('manage_all_comments') ? Comments::count_total(Comment::STATUS_SPAM, false) : Comments::count_by_author(User::identify()->id, Comment::STATUS_SPAM), 'user_entry_scheduled_count' => Posts::get(array('count' => 1, 'content_type' => Post::type('any'), 'status' => Post::status('scheduled'), 'user_id' => User::identify()->id)));
     $this->fetch_dashboard_modules();
     // check for first run
     $u = User::identify();
     if (!isset($u->info->experience_level)) {
         $this->theme->first_run = true;
         $u->info->experience_level = 'user';
         $u->info->commit();
     } else {
         $this->theme->first_run = false;
     }
     $this->display('dashboard');
 }
Пример #28
0
 public function filter_post_content_out($content, $post)
 {
     $option = Options::get('acronyms__acronyms');
     // if option is empty, populate it with the defaults
     if (empty($option)) {
         $this->action_plugin_activation(null);
         $option = Options::get('acronyms__acronyms');
     }
     $option = explode("\n", $option);
     $acronyms = array();
     foreach ($option as $line) {
         $line = explode('||', $line);
         if (count($line) < 2) {
             continue;
         }
         $acronyms[$line[0]] = $line[1];
     }
     $content = " {$content} ";
     foreach ($acronyms as $acronym => $text) {
         $text = trim($text);
         $preg_acronym = preg_quote($acronym, '|');
         $content = preg_replace('|(?!<[^<>]*?)(?<![?.&])\\b' . $preg_acronym . '(?!\\w)(?!:)(?![^<>]*?>)|msU', "<abbr title=\"{$text}\">{$acronym}</abbr>", $content);
     }
     $content = trim($content);
     return $content;
 }
 /**
  * Failsafe, if $theme->switcher() was not called, display the template in the footer.
  * If you enabled it.
  */
 function theme_footer($theme)
 {
     if (!$this->shown && Options::get('themeswitcher__show')) {
         $this->shown = true;
         return $theme->fetch('switcher');
     }
 }
Пример #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;
     }
 }