コード例 #1
0
 private static function parse_data($block, $data)
 {
     // Unserialize and manipulate the data
     $flickrfeed = unserialize($data);
     $flickrfeed = array_slice($flickrfeed['items'], 0, $block->image_count);
     // Photo size
     foreach ($flickrfeed as &$image) {
         $image['image_sizes'] = array('thumbnail' => str_replace('_m.jpg', '_t.jpg', $image['m_url']), 'small' => $image['m_url'], 'medium' => $image['l_url'], 'medium_z' => str_replace('_m.jpg', '_z.jpg', $image['m_url']), 'large' => str_replace('_m.jpg', '_b.jpg', $image['m_url']), 'original' => $image['photo_url'], 'square' => $image['t_url'], 'default' => $image['t_url']);
         if (isset($image['image_sizes'][$block->image_size])) {
             $image['local_file'] = Site::get_dir('user', '/files/flickrfeed/' . $block->image_size . '/' . basename($image['image_sizes'][$block->image_size]));
             $image['local_url'] = Site::get_url('user', '/files/flickrfeed/' . $block->image_size . '/' . basename($image['image_sizes'][$block->image_size]));
             $image['image_url'] = $image['image_sizes'][$block->image_size];
         } else {
             $image['local_file'] = Site::get_dir('user', '/files/flickrfeed/default/' . basename($image['image_sizes']['default']));
             $image['local_url'] = Site::get_url('user', '/files/flickrfeed/default/' . basename($image['image_sizes']['default']));
             $image['image_url'] = $image['image_sizes']['default'];
         }
         if ($block->cache_locally) {
             if (!file_exists($image['local_file'])) {
                 if (!file_exists(dirname($image['local_file']))) {
                     $umask = umask(0);
                     mkdir(dirname($image['local_file']), 0777, true);
                     umask($umask);
                 }
                 if (is_writable(dirname($image['local_file']))) {
                     file_put_contents($image['local_file'], file_get_contents($image['image_url']));
                 }
             }
             if (file_exists($image['local_file'])) {
                 $image['image_url'] = $image['local_url'];
             }
         }
     }
     return $flickrfeed;
 }
コード例 #2
0
ファイル: theme.php プロジェクト: psaintlaurent/Habari
 /**
  * Add some variables to the template output
  */
 public function add_template_vars()
 {
     // Use theme options to set values that can be used directly in the templates
     // Don't check for constant values in the template code itself
     $this->assign('show_title_image', self::SHOW_TITLE_IMAGE);
     $this->assign('home_label', self::HOME_LABEL);
     $this->assign('show_powered', self::SHOW_POWERED);
     $this->assign('display_login', self::DISPLAY_LOGIN);
     $this->assign('tags_in_multiple', self::TAGS_IN_MULTIPLE);
     $this->assign('post_class', 'post' . (!self::SHOW_ENTRY_PAPERCLIP ? ' alt' : ''));
     $this->assign('page_class', 'post' . (!self::SHOW_PAGE_PAPERCLIP ? ' alt' : ''));
     $this->assign('show_post_nav', self::SHOW_POST_NAV);
     $locale = Options::get('locale');
     if (file_exists(Site::get_dir('theme', true) . $locale . '.css')) {
         $this->assign('localized_css', $locale . '.css');
     } else {
         $this->assign('localized_css', false);
     }
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => Post::status('published'), 'nolimit' => 1)));
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     // Add FormUI template placing the input before the label
     $this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php');
     parent::add_template_vars();
 }
コード例 #3
0
 public function action_init()
 {
     // gotta be an easier way of doing this
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', TRUE));
     $theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     if (!$theme->template_exists('admincontrol_select')) {
         $this->add_template('admincontrol_select', dirname(__FILE__) . '/admincontrol_select.php');
     }
 }
コード例 #4
0
 public function action_admin_header($theme)
 {
     // This is such a hack it's not even funny
     // But I am laughing inside. Laughing in a bad way.
     Stack::remove('admin_stylesheet', 'admin');
     $css = file_get_contents(Site::get_dir('admin_theme') . '/css/admin.css');
     $css = preg_replace('@#page input\\[type=button\\], #page input\\[type=submit\\], #page button {([^}]+)}@', '', $css, 1);
     $css = preg_replace('@#page input\\[type=button\\]:hover, #page input\\[type=submit\\]:hover, #page button:hover {([^}]+)}@', '', $css, 1);
     Stack::add('admin_stylesheet', array(preg_replace('@../images/@', Site::get_url('admin_theme') . '/images/', $css), 'screen'), 'admin', 'jquery');
 }
コード例 #5
0
 /**
  * Check the requested gallery exists
  * @param RewriteRule $rule The matched rewrite rule
  * @param string The URL stub requested
  * @param array $params Some stuff
  * @todo Find a nicer way to assign thumbnails
  **/
 public static function rewrite_match_gallery($rule, $stub, $params)
 {
     // TODO It would be better to use the silo, but there's no way to check if a path is valid
     // $silo->get_dir() always returns at least an empty array, even for invalid paths
     $base = Site::get_dir('user') . '/files/simplegallery/';
     // Strip the base URL from the front of the stub, and add it to the base to get the full path.
     $sg = new SimpleGallery();
     $path = $base . substr($stub, strlen($sg->base));
     return file_exists($path);
 }
コード例 #6
0
ファイル: autoload.php プロジェクト: rynodivino/system
/**
 * Attempt to load the class before PHP fails with an error.
 * This method is called automatically in case you are trying to use a class which hasn't been defined yet.
 *
 * We look for the undefined class in the following folders:
 * - /system/classes/*.php
 * - /system/handlers/*.php
 * - /user/classes/*.php
 * - /user/handlers/*.php
 * - /user/sites/x.y.z/classes/*.php
 * - /user/sites/x.y.z/handlers/*.php
 *
 * @param string $class_name Class called by the user
 */
function habari_autoload( $class_name )
{
	static $files = null;

	$success = false;
	$class_file = strtolower( $class_name ) . '.php';

	if ( empty( $files ) ) {
		$files = array();
		$dirs = array(
			HABARI_PATH . '/system/classes',
			HABARI_PATH . '/system/handlers',
			HABARI_PATH . '/user/classes',
			HABARI_PATH . '/user/handlers',
		);

		// For each directory, save the available files in the $files array.
		foreach ( $dirs as $dir ) {
			$glob = glob( $dir . '/*.php' );
			if ( $glob === false || empty( $glob ) ) continue;
			$fnames = array_map( create_function( '$a', 'return strtolower(basename($a));' ), $glob );
			$files = array_merge( $files, array_combine( $fnames, $glob ) );
		}

		// Load the Site class, a requirement to get files from a multisite directory.
		if ( isset( $files['site.php'] ) ) {
			require( $files['site.php'] );
		}

		// Verify if this Habari instance is a multisite.
		if ( ( $site_user_dir = Site::get_dir( 'user' ) ) != HABARI_PATH . '/user' ) {
			// We are dealing with a site defined in /user/sites/x.y.z
			// Add the available files in that directory in the $files array.
			$glob_classes = glob( $site_user_dir . '/classes/*.php' );
			$glob_handlers = glob( $site_user_dir . '/handlers/*.php' );
			$glob = array_merge( $glob_classes, $glob_handlers );
			if ( $glob !== false && !empty( $glob ) ) {
				$fnames = array_map( create_function( '$a', 'return strtolower(basename($a));' ), $glob );
				$files = array_merge( $files, array_combine( $fnames, $glob ) );
			}
		}
	}

	// Search in the available files for the undefined class file.
	if ( isset( $files[$class_file] ) ) {
		require( $files[$class_file] );
		// If the class has a static method named __static(), execute it now, on initial load.
		if ( class_exists( $class_name, false ) && method_exists( $class_name, '__static' ) ) {
			call_user_func( array( $class_name, '__static' ) );
		}
		$success = true;
	}
}
コード例 #7
0
 /**
  * Handles AJAX from /admin/tags
  * Used to delete and rename tags
  */
 public function ajax_tags($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $wsse = Utils::WSSE($handler_vars['nonce'], $handler_vars['timestamp']);
     if ($handler_vars['digest'] != $wsse['digest']) {
         Session::error(_t('WSSE authentication failed.'));
         echo Session::messages_get(true, array('Format', 'json_messages'));
         return;
     }
     $tag_names = array();
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
     $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     $action = $this->handler_vars['action'];
     switch ($action) {
         case 'delete':
             foreach ($_POST as $id => $delete) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $delete) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->term_display;
                     Tags::vocabulary()->delete_term($tag);
                 }
             }
             $msg_status = _n(_t('Tag %s has been deleted.', array(implode('', $tag_names))), _t('%d tags have been deleted.', array(count($tag_names))), count($tag_names));
             Session::notice($msg_status);
             break;
         case 'rename':
             if (!isset($this->handler_vars['master'])) {
                 Session::error(_t('Error: New name not specified.'));
                 echo Session::messages_get(true, array('Format', 'json_messages'));
                 return;
             }
             $master = $this->handler_vars['master'];
             $tag_names = array();
             foreach ($_POST as $id => $rename) {
                 // skip POST elements which are not tag ids
                 if (preg_match('/^tag_\\d+/', $id) && $rename) {
                     $id = substr($id, 4);
                     $tag = Tags::get_by_id($id);
                     $tag_names[] = $tag->term_display;
                 }
             }
             Tags::vocabulary()->merge($master, $tag_names);
             $msg_status = sprintf(_n('Tag %1$s has been renamed to %2$s.', 'Tags %1$s have been renamed to %2$s.', count($tag_names)), implode($tag_names, ', '), $master);
             Session::notice($msg_status);
             break;
     }
     $this->theme->tags = Tags::vocabulary()->get_tree();
     $this->theme->max = Tags::vocabulary()->max_count();
     echo json_encode(array('msg' => Session::messages_get(true, 'array'), 'tags' => $this->theme->fetch('tag_collection')));
 }
コード例 #8
0
 public static function _autoload($class_name)
 {
     if (strtolower($class_name) == 'geshi') {
         $geshi_paths = array(dirname(__FILE__) . '/geshi', HABARI_PATH . '/3rdparty/geshi', Site::get_dir('vendor') . '/geshi');
         foreach ($geshi_paths as $gp) {
             if (file_exists($gp . '/geshi.php')) {
                 self::$geshi_path = $gp;
                 require $gp . '/geshi.php';
                 return;
             }
         }
     }
 }
コード例 #9
0
ファイル: theme.php プロジェクト: habari-extras/aligned
 public function theme_header_image()
 {
     $imglist = '';
     mt_srand((double) microtime() * 1000);
     $imgs = dir(Site::get_dir('theme') . "/headers/");
     while ($file = $imgs->read()) {
         if (preg_match("/(gif|jpe?g|png)\$/i", $file)) {
             $imglist .= "{$file} ";
         }
     }
     closedir($imgs->handle);
     $imglist = explode(" ", $imglist);
     $no = sizeof($imglist) - 2;
     $random = mt_rand(0, $no);
     return $imglist[$random];
 }
コード例 #10
0
ファイル: pbem.plugin.php プロジェクト: habari-extras/pbem
 public function action_plugin_activation($file)
 {
     if (realpath($file) == __FILE__) {
         CronTab::add_cron(array('name' => 'pbem_check_accounts', 'callback' => array(__CLASS__, 'check_accounts'), 'increment' => 600, 'description' => 'Check for new PBEM mail every 600 seconds.'));
         ACL::create_token('PBEM', 'Directly administer posts from the PBEM plugin', 'pbem');
         $dir = Site::get_dir('user') . '/files/PBEM';
         if (!is_dir($dir)) {
             if (!mkdir($dir, 0755)) {
                 EventLog::log('PBEM temporary storage directory ' . $dir . ' could not be created. Attachment processing will not work.', 'info', 'plugin', 'pbem');
                 Session::error('PBEM temporary storage directory ' . $dir . ' could not be created. Attachment processing will not work.');
             } else {
                 EventLog::log('PBEM temporary storage directory ' . $dir . ' created.', 'info', 'plugin', 'pbem');
             }
         }
     }
 }
コード例 #11
0
ファイル: themes.php プロジェクト: ringmaster/system
 /**
  * Returns the theme dir and path information
  * @return array An array of Theme data
  **/
 public static function get_all()
 {
     if (!isset(self::$all_themes)) {
         $dirs = array(HABARI_PATH . '/system/themes/*', HABARI_PATH . '/3rdparty/themes/*', HABARI_PATH . '/user/themes/*');
         if (Site::is('multi')) {
             $dirs[] = Site::get_dir('config') . '/themes/*';
         }
         $themes = array();
         foreach ($dirs as $dir) {
             $themes = array_merge($themes, Utils::glob($dir, GLOB_ONLYDIR | GLOB_MARK));
         }
         $themes = array_filter($themes, create_function('$a', 'return file_exists( $a . "/theme.xml" );'));
         $themefiles = array_map('basename', $themes);
         self::$all_themes = array_combine($themefiles, $themes);
     }
     return self::$all_themes;
 }
コード例 #12
0
 public function make_default_dirs($force = true)
 {
     $defaults = array('pb__dirs_photos' => Site::get_dir('user') . '/files/photoblog/photos', 'pb__dirs_thumbnails' => Site::get_dir('user') . '/files/photoblog/thumbnails');
     if ($force) {
         $dirs = $defaults;
     } else {
         /* This is ugly too */
         $dirs = Options::get(array('pb__dirs_photos', 'pb__dirs_thumbnails'));
         if (isset($dirs[0]) && !empty($dirs[0])) {
             $dirs['pb__dirs_photos'] = $dirs[0];
         }
         if (isset($dirs[1]) && !empty($dirs[1])) {
             $dirs['pb__dirs_thumbnails'] = $dirs[1];
         }
         $dirs = array_merge($defaults, $dirs);
     }
     return $this->make_dirs($dirs);
 }
コード例 #13
0
ファイル: autoload.php プロジェクト: habari/system
 /**
  * SPL Autoload function, includes a file to meet requirement of loading a class by name
  * @param string $class_name The name of a class, including (if present) a namespace
  * @return bool True if this function successfully autoloads the class in question
  */
 public static function habari_autoload($class_name)
 {
     $success = false;
     $full_class_name = $class_name;
     if (!preg_match('#^\\\\?Habari\\\\#', $class_name)) {
         return false;
     }
     $class_name = preg_replace('#^\\\\?Habari\\\\#', '', $class_name);
     $class_file = strtolower($class_name) . '.php';
     if (empty(self::$files)) {
         $dirs = array(HABARI_PATH . '/system/classes', HABARI_PATH . '/system/controls', HABARI_PATH . '/system/handlers', HABARI_PATH . '/user/classes', HABARI_PATH . '/user/controls', HABARI_PATH . '/user/handlers');
         // Queue these directories to find the Site class
         self::queue_dirs($dirs);
         // Load the Site class, a requirement to get files from a multisite directory.
         if (isset(self::$files['site.php'])) {
             require self::$files['site.php'];
             unset(self::$files['site.php']);
         }
         // Verify if this Habari instance is a multisite.
         if (($site_user_dir = Site::get_dir('user')) != HABARI_PATH . '/user') {
             // We are dealing with a site defined in /user/sites/x.y.z
             // Add those directories to the end of the $dirs array so they can override previous entries
             $dirs[] = $site_user_dir . '/classes';
             $dirs[] = $site_user_dir . '/controls';
             $dirs[] = $site_user_dir . '/handlers';
         }
         self::queue_dirs($dirs);
     }
     // Search in the available files for the undefined class file.
     if (isset(self::$files[$class_file])) {
         require self::$files[$class_file];
         unset(self::$files[$class_file]);
         // Remove the file from the list to expose duplicate class names // @todo remove this line
         // If the class has a static method named __static(), execute it now, on initial load.
         if (class_exists($full_class_name, false) && method_exists($full_class_name, '__static')) {
             call_user_func(array($full_class_name, '__static'));
         }
         $success = true;
     }
     return $success;
 }
コード例 #14
0
ファイル: theme.php プロジェクト: ringmaster/system
 /**
  * Add some variables to the template output
  */
 public function 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 (file_exists(Site::get_dir('theme', true) . $locale . '.css')) {
         $this->assign('localized_css', $locale . '.css');
     } else {
         $this->assign('localized_css', false);
     }
     if (!$this->template_engine->assigned('pages')) {
         $this->assign('pages', Posts::get(array('content_type' => 'page', 'status' => 'published', 'nolimit' => 1)));
     }
     $this->assign('post_id', isset($this->post) && $this->post->content_type == Post::type('page') ? $this->post->id : 0);
     if ($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)));
             }
         }
     }
     // Add FormUI template placing the input before the label
     $this->add_template('charcoal_text', dirname(__FILE__) . '/formcontrol_text.php');
 }
コード例 #15
0
 /**
  * Handles AJAX requests from the dashboard
  */
 public function ajax_dashboard($handler_vars)
 {
     Utils::check_request_method(array('POST'));
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
     $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     switch ($handler_vars['action']) {
         case 'updateModules':
             $modules = array();
             foreach ($_POST as $key => $module) {
                 // skip POST elements which are not module names
                 if (preg_match('/^module\\d+$/', $key)) {
                     list($module_id, $module_name) = explode(':', $module, 2);
                     // remove non-sortable modules from the list
                     if ($module_id != 'nosort') {
                         $modules[$module_id] = $module_name;
                     }
                 }
             }
             Modules::set_active($modules);
             $ar = new AjaxResponse(200, _t('Modules updated.'));
             break;
         case 'addModule':
             $id = Modules::add($handler_vars['module_name']);
             $this->fetch_dashboard_modules();
             $ar = new AjaxResponse(200, _t('Added module %s.', array($handler_vars['module_name'])));
             $ar->html('modules', $this->theme->fetch('dashboard_modules'));
             break;
         case 'removeModule':
             Modules::remove($handler_vars['moduleid']);
             $this->fetch_dashboard_modules();
             $ar = new AjaxResponse(200, _t('Removed module.'));
             $ar->html('modules', $this->theme->fetch('dashboard_modules'));
             break;
     }
     $ar->out();
 }
コード例 #16
0
ファイル: userhandler.php プロジェクト: psaintlaurent/Habari
 /**
  * Display the login form
  *
  * @param string $name Pre-fill the name field with this name
  */
 protected function login_form($name)
 {
     // Display the login form.
     $this->theme = Themes::create();
     if (!$this->theme->template_exists('login')) {
         $this->theme = Themes::create('admin', 'RawPHPEngine', Site::get_dir('admin_theme', TRUE));
         $this->theme->assign('admin_page', 'login');
     }
     $request = new StdClass();
     foreach (URL::get_active_rules() as $rule) {
         $request->{$rule->name} = $rule->name == URL::get_matched_rule()->name;
     }
     if (isset($this->handler_vars['error'])) {
         $this->theme->assign('error', Utils::htmlspecialchars($this->handler_vars['error']));
     }
     $this->theme->assign('request', $request);
     $this->theme->assign('habari_username', htmlentities($name, ENT_QUOTES, 'UTF-8'));
     $this->display('login');
     return TRUE;
 }
コード例 #17
0
 /**
  * function get_image_url
  * Given the filesystem path to the image to an image, obtain a URL 
  * @param String the filesystem path to the image
  * @return String the image URL
  **/
 public function get_image_url($image)
 {
     return substr_replace($image, Site::get_url('user'), 0, strlen(Site::get_dir('user')));
 }
コード例 #18
0
	/**
	 * Handles AJAX requests from the manage comments page.
	 */
	public function ajax_comments()
	{
		Utils::check_request_method( array( 'GET', 'HEAD' ) );

		$theme_dir = Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', true ) );
		$this->theme = Themes::create( 'admin', 'RawPHPEngine', $theme_dir );
		$this->theme->theme = $this->theme;

		$params = $_GET;

		$this->fetch_comments( $params );
		$items = $this->theme->fetch( 'comments_items' );
		$timeline = $this->theme->fetch( 'timeline_items' );

		$item_ids = array();

		foreach ( $this->theme->comments as $comment ) {
			$item_ids['p' . $comment->id] = 1;
		}

		$ar = new AjaxResponse();
		$ar->data = array(
			'items' => $items,
			'item_ids' => $item_ids,
			'timeline' => $timeline,
		);
		$ar->out();
	}
コード例 #19
0
ファイル: site.php プロジェクト: nerdfiles/habari_boilerplate
	/**
	 * our_dir echos our a filesystem directory
	 * @param string the filesystem directory to display
	 * @param bool whether or not to include a trailing slash.  Default: No
	 */
	public static function out_dir( $dir, $trail = false )
	{
		echo Site::get_dir( $dir, $trail );
	}
コード例 #20
0
 public function theme_route_download_addon($theme, $url_args)
 {
     $addon = Post::get(array('slug' => $url_args['slug']));
     if (!$addon) {
         return;
         // Don't let people pass weird stuff into here
     }
     $version = $url_args['version'];
     $terms = $this->vocabulary->get_object_terms('addon', $addon->id);
     foreach ($terms as $term) {
         if ($version == $this->version_slugify($term)) {
             if (!isset($term->info->url) || !isset($term->info->hash)) {
                 Utils::debug($term);
                 return;
                 // We must have a download url and a hash to get
             }
             // zip file of the requested version is located in /user/files/addon_downloads/{$addonslug}/{$versionslug}/{$hash}/{$addonslug}_{$versionslug}.zip
             $versiondir = '/files/addon_downloads/' . $addon->slug . '/' . $version . '/';
             $dir = $versiondir . $term->info->hash . '/';
             $zipfile = Site::get_dir('user') . $dir . $addon->slug . '_' . $version . '.zip';
             $zipurl = Site::get_url('user') . $dir . $addon->slug . '_' . $version . '.zip';
             if (!is_file($zipfile) || isset($url_args['refresh']) && $url_args['refresh'] == 'refresh') {
                 // File does not yet exist, prepare directories and create it
                 if (is_writable(Site::get_dir('user') . '/files/')) {
                     if (!is_dir(Site::get_dir('user') . $versiondir)) {
                         mkdir(Site::get_dir('user') . $versiondir, 0755, true);
                     }
                     $tmp_dir = sys_get_temp_dir() . '/' . $addon->slug;
                     // Cleanup: Remove copies from older commits
                     exec('rm -rf ' . Site::get_dir('user') . $versiondir . '*');
                     exec('rm -rf ' . $tmp_dir);
                     exec('rm -rf ' . $zipfile);
                     if (!is_dir(Site::get_dir('user') . $dir)) {
                         mkdir(Site::get_dir('user') . $dir, 0755, true);
                     }
                     Plugins::act('addon_download', $term->info->source, $addon, $term, $tmp_dir);
                     if (count(scandir($tmp_dir)) > 2) {
                         exec('cd ' . $tmp_dir . ' && zip -9 -r ' . $zipfile . ' *');
                     }
                 }
             }
             if (is_file($zipfile)) {
                 // Everything worked fine - or the file already existed
                 Utils::redirect($zipurl);
             }
         }
     }
 }
コード例 #21
0
	/**
	 * Retreive the Theme used to display the form component
	 *
	 * @param boolean $forvalidation If true, perform validation on control and add error messages to output
	 * @param FormControl $control The control to output using a template
	 * @return Theme The theme object to display the template for the control
	 */
	function get_theme( $forvalidation = false, $control = null )
	{
		if ( !isset( $this->theme_obj ) ) {
			$theme_dir = Plugins::filter( 'control_theme_dir', Plugins::filter( 'admin_theme_dir', Site::get_dir( 'admin_theme', true ) ) . 'formcontrols/', $control );
			$this->theme_obj = Themes::create( 'admin', 'RawPHPEngine', $theme_dir );
		}
		$this->theme_obj->start_buffer();
		if ( $control instanceof FormControl ) {
			// PHP doesn't allow __get() to return pointers, and passing this array to foreach directly generates an error.
			$properties = $control->properties;
			foreach ( $properties as $name => $value ) {
				$this->theme_obj->$name = $value;
			}
			$this->theme_obj->field = $control->field;
			$this->theme_obj->value = $control->value;
			$this->theme_obj->caption = $control->caption;
			$this->theme_obj->id = (string) $control->id;
			$class = (array) $control->class;

			$message = '';
			if ( $forvalidation ) {
				$validate = $control->validate();
				if ( count( $validate ) != 0 ) {
					$class[] = 'invalid';
					$message = implode( '<br>', (array) $validate );
				}
			}
			$this->theme_obj->class = implode( ' ', (array) $class );
			$this->theme_obj->message = $message;
		}
		return $this->theme_obj;
	}
コード例 #22
0
ファイル: theme.php プロジェクト: habari/system
 /**
  * Convert a theme directory or resource into a URL
  * @param string $dir The pathname to convert
  * @return bool|string The URL to use, or false if none was found
  */
 public function dir_to_url($dir)
 {
     static $tomatch = false;
     if (!$tomatch) {
         $tomatch = array(Site::get_dir('config') . '/themes/' => Site::get_url('user') . '/themes/', HABARI_PATH . '/user/themes/' => Site::get_url('habari') . '/user/themes/', HABARI_PATH . '/3rdparty/themes/' => Site::get_url('habari') . '/3rdparty/themes/', HABARI_PATH . '/system/themes/' => Site::get_url('habari') . '/system/themes/', HABARI_PATH . '/system/admin/' => Site::get_url('habari') . '/system/admin/');
     }
     if (preg_match('#^(' . implode('|', array_map('preg_quote', array_keys($tomatch))) . ')(.*)$#', $dir, $matches)) {
         return $tomatch[$matches[1]] . $matches[2];
     }
     return false;
 }
コード例 #23
0
ファイル: plugins.php プロジェクト: rynodivino/system
	/**
	 * function list_all
	 * Gets a list of all plugin filenames that are available
	 * @return array An array of filenames
	 */
	public static function list_all()
	{
		$plugins = array();
		$plugindirs = array( HABARI_PATH . '/system/plugins/', HABARI_PATH . '/3rdparty/plugins/', HABARI_PATH . '/user/plugins/' );
		if ( Site::CONFIG_LOCAL != Site::$config_type ) {
			// include site-specific plugins
			$plugindirs[] = Site::get_dir( 'config' ) . '/plugins/';
		}
		$dirs = array();
		foreach ( $plugindirs as $plugindir ) {
			if ( file_exists( $plugindir ) ) {
				$dirs = array_merge( $dirs, Utils::glob( $plugindir . '*', GLOB_ONLYDIR | GLOB_MARK ) );
			}
		}
		foreach ( $dirs as $dir ) {
			$dirfiles = Utils::glob( $dir . '*.plugin.php' );
			if ( ! empty( $dirfiles ) ) {
				$dirfiles = array_combine(
					// Use the basename of the file as the index to use the named plugin from the last directory in $dirs
					array_map( 'basename', $dirfiles ),
					// massage the filenames so that this works on Windows
					array_map( create_function( '$s', 'return str_replace(\'\\\\\', \'/\', $s);' ), $dirfiles )
				);
				$plugins = array_merge( $plugins, $dirfiles );
			}
			$dirfiles = Utils::glob( $dir . '*.phar' );
			foreach($dirfiles as $filename) {
				if(preg_match('/\.phar$/i', $filename)) {
					$d = new DirectoryIterator('phar://' . $filename);
					foreach ($d as $fileinfo) {
						if ($fileinfo->isFile() && preg_match('/\.plugin.php$/i', $fileinfo->getFilename())) {
							$plugins[$fileinfo->getFilename()] = str_replace('\\', '/', $fileinfo->getPathname());
						}
					}

				}
			}
		}
		ksort( $plugins );
		return $plugins;
	}
コード例 #24
0
ファイル: fileman.php プロジェクト: habari-extras/fileman
<?php

// Display Habari header
$theme->display('header');
// Set file to work with
if (!isset($_GET['file'])) {
    // If no file selected, set default theme's
    // home page as edit file
    $file = Site::get_dir("theme") . "/home.php";
} else {
    // Otherwise set the chosen file
    $file = $_GET['file'];
}
// Get Javascripts
include 'fileman.js.php';
// Get CSS
include 'fileman.css.php';
?>
<div class="container">
 <h2>File Manager</h2>
 <table class="fileman">
  <tr>
   <td class="editor">
    <div class="fileman">
     <form class="fileman">
      <p style="margin-bottom:7px;">Currently editing: <?php 
echo $file;
?>
</p>
      <p class="status">Status: <span>File not saved.</span></p>
      <textarea name="contents"><?php 
コード例 #25
0
ファイル: plugins.php プロジェクト: wwxgitcat/habari
 /**
  * function list_all
  * Gets a list of all plugin filenames that are available
  * @return array An array of filenames
  */
 public static function list_all()
 {
     $plugins = array();
     $plugindirs = array(HABARI_PATH . '/system/plugins/', HABARI_PATH . '/3rdparty/plugins/', HABARI_PATH . '/user/plugins/');
     if (Site::CONFIG_LOCAL != Site::$config_type) {
         // include site-specific plugins
         $plugindirs[] = Site::get_dir('config') . '/plugins/';
     }
     $dirs = array();
     foreach ($plugindirs as $plugindir) {
         if (file_exists($plugindir)) {
             $dirs = array_merge($dirs, Utils::glob($plugindir . '*', GLOB_ONLYDIR | GLOB_MARK));
         }
     }
     foreach ($dirs as $dir) {
         $dirfiles = Utils::glob($dir . '*.plugin.php');
         if (!empty($dirfiles)) {
             $dirfiles = array_combine(array_map('basename', $dirfiles), array_map(function ($s) {
                 return str_replace('\\', '/', $s);
             }, $dirfiles));
             $plugins = array_merge($plugins, $dirfiles);
         }
         $dirfiles = Utils::glob($dir . '*.phar');
         foreach ($dirfiles as $filename) {
             if (preg_match('/\\.phar$/i', $filename)) {
                 $d = new DirectoryIterator('phar://' . $filename);
                 foreach ($d as $fileinfo) {
                     if ($fileinfo->isFile() && preg_match('/\\.plugin.php$/i', $fileinfo->getFilename())) {
                         $plugins[$fileinfo->getFilename()] = str_replace('\\', '/', $fileinfo->getPathname());
                     }
                 }
             }
         }
     }
     ksort($plugins);
     return $plugins;
 }
コード例 #26
0
ファイル: adminhandler.php プロジェクト: wwxgitcat/habari
 public function create_theme()
 {
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
     $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
 }
コード例 #27
0
<?php

/**
 * 读取读取跳转代码 --boboit  2015.11.30
 */
include "checkParameter.php";
define('HABARI_PATH', dirname(__FILE__));
define("habari", dirname(__FILE__));
ob_start();
require dirname(__FILE__) . '/system/autoload.php';
spl_autoload_register('habari_autoload');
SuperGlobal::process_gps();
if (!defined('SUPPRESS_ERROR_HANDLER')) {
    Error::handle_errors();
}
$config = Site::get_dir('config_file');
require_once $config;
HabariLocale::set(Config::get('locale', 'en-us'));
if (!defined('DEBUG')) {
    define('DEBUG', false);
}
DB::connect();
$start_time = strtotime(date("Y-m-d 00:00:00", strtotime("-1 day")));
$end_time = strtotime(date("Y-m-d 23:59:59", strtotime("-1 day")));
if (isset($_GET['st']) && !empty($_GET['st'])) {
    $start_time = strtotime($_GET['st']);
}
if (isset($_GET['et']) && !empty($_GET['et'])) {
    $end_time = strtotime($_GET['et']);
}
$hbslf_visit = DB::get_results('SELECT distinct ip FROM `hbslf_visit` where date_add >=' . $start_time . ' AND  date_add <=' . $end_time);
コード例 #28
0
 /**
  * Handles AJAX requests from the groups page.
  */
 public function ajax_groups($handler_vars)
 {
     Utils::check_request_method(array('GET', 'HEAD'));
     $theme_dir = Plugins::filter('admin_theme_dir', Site::get_dir('admin_theme', true));
     $this->theme = Themes::create('admin', 'RawPHPEngine', $theme_dir);
     $output = '';
     foreach (UserGroups::get_all() as $group) {
         $this->theme->group = $group;
         $group = UserGroup::get_by_id($group->id);
         $users = array();
         foreach ($group->members as $id) {
             $user = $id == 0 ? User::anonymous() : User::get_by_id($id);
             if ($user->id == 0) {
                 $users[] = '<strong>' . $user->displayname . '</strong>';
             } else {
                 $users[] = '<strong><a href="' . URL::get('admin', 'page=user&id=' . $user->id) . '">' . $user->displayname . '</a></strong>';
             }
         }
         $this->theme->users = $users;
         $output .= $this->theme->fetch('groups_item');
     }
     echo json_encode(array('items' => $output));
 }
コード例 #29
0
ファイル: habarilocale.php プロジェクト: psaintlaurent/Habari
 /**
  * function list_all
  * Retrieves an array of the Habari locales that are installed
  * 
  * @return array. An array of Habari locales in the installation
  **/
 public static function list_all()
 {
     $localedirs = array(HABARI_PATH . '/system/locale/', HABARI_PATH . '/3rdparty/locale/', HABARI_PATH . '/user/locale/');
     if (Site::CONFIG_LOCAL != Site::$config_type) {
         // include site-specific locales
         $localedirs[] = Site::get_dir('config') . '/locale/';
     }
     $dirs = array();
     foreach ($localedirs as $localedir) {
         if (file_exists($localedir)) {
             $dirs = array_merge($dirs, Utils::glob($localedir . '*', GLOB_ONLYDIR | GLOB_MARK));
         }
     }
     $dirs = array_filter($dirs, create_function('$a', 'return file_exists($a . "LC_MESSAGES/habari.mo");'));
     $locales = array_map('basename', $dirs);
     ksort($locales);
     return $locales;
 }
コード例 #30
0
ファイル: installhandler.php プロジェクト: habari/system
 /**
  * Writes the configuration file with the variables needed for
  * initialization of the application
  *
  * @param Bool $ignore_registry skip the configuration registry check (used in config rewrite)
  * @return  bool  Did the file get written?
  */
 private function write_config_file($ignore_registry = false)
 {
     // first, check if a config.php file exists
     if (file_exists(Site::get_dir('config_file'))) {
         // set the defaults for comparison
         $db_host = $this->handler_vars['db_host'];
         $db_file = $this->handler_vars['db_file'];
         $db_type = $this->handler_vars['db_type'];
         $db_schema = $this->handler_vars['db_schema'];
         $db_user = $this->handler_vars['db_user'];
         $db_pass = $this->handler_vars['db_pass'];
         $table_prefix = $this->handler_vars['table_prefix'];
         // set the connection string
         switch ($db_type) {
             case 'mysql':
                 $connection_string = "{$db_type}:host={$db_host};dbname={$db_schema}";
                 break;
             case 'pgsql':
                 $connection_string = "{$db_type}:host={$db_host} dbname={$db_schema}";
                 break;
             case 'sqlite':
                 $connection_string = "{$db_type}:{$db_file}";
                 break;
         }
         // load the config.php file
         include Site::get_dir('config_file');
         // and now we compare the values defined there to
         // the values POSTed to the installer
         if (!$ignore_registry && Config::exists('db_connection') && Config::get('db_connection')->connection_string == $connection_string && Config::get('db_connection')->username == $db_user && Config::get('db_connection')->password == $db_pass && Config::get('db_connection')->prefix == $table_prefix) {
             // the values are the same, so don't bother
             // trying to write to config.php
             return true;
         }
     }
     if (!($file_contents = file_get_contents(HABARI_PATH . "/system/schema/" . $this->handler_vars['db_type'] . "/config.php"))) {
         return false;
     }
     if ($file_contents = html_entity_decode($this->get_config_file())) {
         if ($file = @fopen(Site::get_dir('config_file'), 'w')) {
             if (fwrite($file, $file_contents, strlen($file_contents))) {
                 fclose($file);
                 return true;
             }
         }
         $this->handler_vars['config_file'] = Site::get_dir('config_file');
         $this->handler_vars['file_contents'] = Utils::htmlspecialchars($file_contents);
         $this->display('config');
         return false;
     }
     return false;
     // Only happens when config.php template does not exist.
 }