public function rmdir($paths) { foreach ($paths as $path) { if (false == rmdir($path)) { throw new Exception(php::message(sprintf('Kan map (%s) niet verwijderen !', $path), 'error')); } } return true; }
<?php /************************************************** Coppermine 1.5.x Plugin - forum ************************************************* Copyright (c) 2010 foulu (Le Hoai Phuong), eenemeenemuu ************************************************* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. ******************************************** $HeadURL$ $Revision$ $LastChangedBy$ $Date$ **************************************************/ echo table::open(); echo form::open('forum.php?c=profile&id=' . $user['user_id'], 'profile', 'post', TRUE); echo table::td(Lang::item('profile.profile_title'), 4); echo table::td(Lang::item('profile.avatar'), 4, 'tableh2'); echo table::tds(array(array('class' => 'tableb', 'width' => '5%', 'align' => 'center', 'text' => form::radio('avatar_type', 'url', '', $user['fr_avatar'] ? 'url' : '')), array('class' => 'tableb', 'width' => '20%', 'text' => Lang::item('profile.url')), array('class' => 'tableb', 'width' => '50%', 'text' => form::text('fr_avatar_url', $user['fr_avatar'])), array('class' => 'tableb', 'width' => '25%', 'align' => 'center', 'rowspan' => 2, 'text' => !php::is_empty_string($user['fr_avatar']) ? html::img($user['fr_avatar'], Config::item('fr_avatar_size')) . BR . BR . html::button('forum.php?c=profile&m=remove_avatar', Lang::item('profile.remove_avatar')) : ''))); echo table::tds(array(array('class' => 'tableb', 'align' => 'center', 'text' => form::radio('avatar_type', 'file')), array('class' => 'tableb', 'text' => Lang::item('profile.file')), array('class' => 'tableb', 'text' => form::file('fr_avatar_file')))); echo table::td(Lang::item('profile.profile'), 4, 'tableh2'); echo table::tds(array(array('class' => 'tableb', 'colspan' => 2, 'rowspan' => 3, 'text' => Lang::item('profile.signature')), array('class' => 'tableb', 'colspan' => 2, 'text' => forum::generate_bbcode_tags('profile', 'fr_signature')))); echo table::tds(array(array('class' => 'tableb', 'colspan' => 2, 'align' => 'center', 'text' => form::textarea('fr_signature', $user['fr_signature'])))); echo table::tds(array(array('class' => 'tableb', 'colspan' => 2, 'text' => generate_smilies('profile', 'fr_signature')))); echo table::tds(array(array('class' => 'tablef', 'colspan' => 4, 'text' => form::submit(Lang::item('common.change'), 'submit')))); echo form::close(); echo table::close();
/** * Sets up the PHP environment. Adds error/exception handling, output * buffering, and adds an auto-loading method for loading classes. * * This method is run immediately when this file is loaded, and is * benchmarked as environment_setup. * * For security, this function also destroys the $_REQUEST global variable. * Using the proper global (GET, POST, COOKIE, etc) is inherently more secure. * The recommended way to fetch a global variable is using the Input library. * @see http://www.php.net/globals * * @return void */ public static function setup() { static $run; // Only run this function once if ($run === TRUE) { return; } $run = TRUE; // Start the environment setup benchmark Benchmark::start(SYSTEM_BENCHMARK . '_environment_setup'); define('KOHANA_VERSION', Kohana::VERSION); // Define Kohana error constant define('E_KOHANA', 42); // Define 404 error constant define('E_PAGE_NOT_FOUND', 43); // Define database error constant define('E_DATABASE_ERROR', 44); // Set the default charset for mb_* functions mb_internal_encoding(Kohana::CHARSET); if (Kohana_Config::instance()->loaded() === FALSE) { // Re-parse the include paths Kohana::include_paths(TRUE); } if (Kohana::$cache_lifetime = Kohana::config('core.internal_cache')) { // Are we using encryption for caches? Kohana::$internal_cache_encrypt = Kohana::config('core.internal_cache_encrypt'); if (Kohana::$internal_cache_encrypt === TRUE) { Kohana::$internal_cache_key = Kohana::config('core.internal_cache_key'); // Be sure the key is of acceptable length for the mcrypt algorithm used Kohana::$internal_cache_key = substr(Kohana::$internal_cache_key, 0, 24); } // Set the directory to be used for the internal cache if (!(Kohana::$internal_cache_path = Kohana::config('core.internal_cache_path'))) { Kohana::$internal_cache_path = APPPATH . 'cache/'; } // Load cached configuration and language files Kohana::$internal_cache['configuration'] = Kohana::cache('configuration', Kohana::$cache_lifetime); Kohana::$internal_cache['language'] = Kohana::cache('language', Kohana::$cache_lifetime); // Load cached file paths Kohana::$internal_cache['find_file_paths'] = Kohana::cache('find_file_paths', Kohana::$cache_lifetime); // Enable cache saving Event::add('system.shutdown', array('Kohana', 'internal_cache_save')); } // Start output buffering ob_start(array('Kohana', 'output_buffer')); // Save buffering level Kohana::$buffer_level = ob_get_level(); // Set autoloader spl_autoload_register(array('Kohana', 'auto_load')); // Register a shutdown function to handle system.shutdown events register_shutdown_function(array('Kohana', 'shutdown')); // Send default text/html UTF-8 header header('Content-Type: text/html; charset=' . Kohana::CHARSET); // Load i18n new I18n(); // Enable exception handling Kohana_Exception::enable(); // Enable error handling Kohana_PHP_Exception::enable(); // Load locales $locales = Kohana::config('locale.language'); // Make first locale the defined Kohana charset $locales[0] .= '.' . Kohana::CHARSET; // Set locale information Kohana::$locale = setlocale(LC_ALL, $locales); // Default to the default locale when none of the user defined ones where accepted Kohana::$locale = !Kohana::$locale ? Kohana::LOCALE . '.' . Kohana::CHARSET : Kohana::$locale; // Set locale for the I18n system I18n::set_locale(Kohana::$locale); // Set and validate the timezone php::date_default_timezone_set(Kohana::config('locale.timezone')); // register_globals is enabled if (ini_get('register_globals')) { if (isset($_REQUEST['GLOBALS'])) { // Prevent GLOBALS override attacks exit('Global variable overload attack.'); } // Destroy the REQUEST global $_REQUEST = array(); // These globals are standard and should not be removed $preserve = array('GLOBALS', '_REQUEST', '_GET', '_POST', '_FILES', '_COOKIE', '_SERVER', '_ENV', '_SESSION'); // This loop has the same effect as disabling register_globals foreach (array_diff(array_keys($GLOBALS), $preserve) as $key) { global ${$key}; ${$key} = NULL; // Unset the global variable unset($GLOBALS[$key], ${$key}); } // Warn the developer about register globals Kohana_Log::add('debug', 'Disable register_globals! It is evil and deprecated: http://php.net/register_globals'); } // Enable Kohana routing Event::add('system.routing', array('Router', 'find_uri')); Event::add('system.routing', array('Router', 'setup')); // Enable Kohana controller initialization Event::add('system.execute', array('Kohana', 'instance')); // Enable Kohana 404 pages Event::add('system.404', array('Kohana_404_Exception', 'trigger')); if (Kohana::config('core.enable_hooks') === TRUE) { // Find all the hook files $hooks = Kohana::list_files('hooks', TRUE); foreach ($hooks as $file) { // Load the hook include $file; } } // Stop the environment setup routine Benchmark::stop(SYSTEM_BENCHMARK . '_environment_setup'); }
/** * @return boolean * * @since 3.0 */ function _createConfiguration($options) { // Create a new registry to build the configuration options. $registry = new JRegistry(); /* Site Settings */ $registry->set('offline', $options->site_offline); $registry->set('offline_message', JText::_('INSTL_STD_OFFLINE_MSG')); $registry->set('display_offline_message', 1); $registry->set('offline_image', ''); $registry->set('sitename', $options->site_name); $registry->set('editor', 'tinymce'); $registry->set('captcha', '0'); $registry->set('list_limit', 20); $registry->set('access', 1); /* Debug Settings */ $registry->set('debug', 0); $registry->set('debug_lang', 0); /* Database Settings */ $registry->set('dbtype', $options->db_type); $registry->set('host', $options->db_host); $registry->set('user', $options->db_user); $registry->set('password', $options->db_pass); $registry->set('db', $options->db_name); $registry->set('dbprefix', $options->db_prefix); /* Server Settings */ $registry->set('live_site', ''); $registry->set('secret', JUserHelper::genRandomPassword(16)); $registry->set('gzip', 0); $registry->set('error_reporting', 'default'); $registry->set('helpurl', 'http://help.joomla.org/proxy/index.php?option=com_help&keyref=Help{major}{minor}:{keyref}'); $registry->set('ftp_host', $options->ftp_host); $registry->set('ftp_port', $options->ftp_port); $registry->set('ftp_user', $options->ftp_save ? $options->ftp_user : ''); $registry->set('ftp_pass', $options->ftp_save ? $options->ftp_pass : ''); $registry->set('ftp_root', $options->ftp_save ? $options->ftp_root : ''); $registry->set('ftp_enable', $options->ftp_enable); /* Locale Settings */ $registry->set('offset', 'UTC'); /* Mail Settings */ $registry->set('mailer', 'mail'); $registry->set('mailfrom', $options->admin_email); $registry->set('fromname', $options->site_name); $registry->set('sendmail', '/usr/sbin/sendmail'); $registry->set('smtpauth', 0); $registry->set('smtpuser', ''); $registry->set('smtppass', ''); $registry->set('smtphost', 'localhost'); $registry->set('smtpsecure', 'none'); $registry->set('smtpport', '25'); /* Cache Settings */ $registry->set('caching', 0); $registry->set('cache_handler', 'file'); $registry->set('cachetime', 15); /* Meta Settings */ $registry->set('MetaDesc', $options->site_metadesc); $registry->set('MetaKeys', $options->site_metakeys); $registry->set('MetaTitle', 1); $registry->set('MetaAuthor', 1); $registry->set('MetaVersion', 0); $registry->set('robots', ''); /* SEO Settings */ $registry->set('sef', 1); $registry->set('sef_rewrite', 0); $registry->set('sef_suffix', 0); $registry->set('unicodeslugs', 0); /* Feed Settings */ $registry->set('feed_limit', 10); $registry->set('log_path', JPATH_ROOT . '/logs'); $registry->set('tmp_path', JPATH_ROOT . '/tmp'); /* Session Setting */ $registry->set('lifetime', 15); $registry->set('session_handler', 'database'); // Generate the configuration class string buffer. $buffer = $registry->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)); // Build the configuration file path. $path = JPATH_CONFIGURATION . '/configuration.php'; // Determine if the configuration file path is writable. if (file_exists($path)) { $canWrite = is_writable($path); } else { $canWrite = is_writable(JPATH_CONFIGURATION . '/'); } /* * If the file exists but isn't writable OR if the file doesn't exist and the parent directory * is not writable we need to use FTP */ $useFTP = false; if (file_exists($path) && !is_writable($path) || !file_exists($path) && !is_writable(dirname($path) . '/')) { $useFTP = true; } // Check for safe mode if (ini_get('safe_mode')) { $useFTP = true; } // Enable/Disable override if (!isset($options->ftpEnable) || $options->ftpEnable != 1) { $useFTP = false; } if ($useFTP == true) { // Connect the FTP client jimport('joomla.filesystem.path'); $ftp = installation / models / configuration . php::getInstance($options->ftp_host, $options->ftp_port); $ftp->login($options->ftp_user, $options->ftp_pass); // Translate path for the FTP account $file = JPath::clean(str_replace(JPATH_CONFIGURATION, $options->ftp_root, $path), '/'); // Use FTP write buffer to file if (!$ftp->write($file, $buffer)) { // Set the config string to the session. $session = JFactory::getSession(); $session->set('setup.config', $buffer); } $ftp->quit(); } else { if ($canWrite) { file_put_contents($path, $buffer); $session = JFactory::getSession(); $session->set('setup.config', null); } else { // Set the config string to the session. $session = JFactory::getSession(); $session->set('setup.config', $buffer); } } return true; }