code:
<?php
/**
 * @package Habari
 *
 */

/**
 * Habari UserHandler Class
 *
 */
class UserHandler extends ActionHandler
{

	/**
	 * Either just display the login form; or check a user's credentials, and
	 * create a session for them; or handle a password reset request.
	 */
	public function act_login()
	{
		// If we're a reset password request, do that.
		if ( isset( $_POST['submit_button'] ) && $_POST['submit_button'] === _t( 'Reset password' ) ) {
			Utils::check_request_method( array( 'POST' ) );

			$name = $this->handler_vars['habari_username'];
			if ( $name !== null ) {
				if ( !is_numeric( $name ) && $user = User::get( $name ) ) {
					$hash = Utils::random_password();

					$user->info->password_reset = md5( $hash );
					$user->info->commit();
					$message = _t( 'Please visit %1$s to reset your password.', array( URL::get( 'user', array( 'page' => 'password_reset', 'id' => $user->id, 'hash' => $hash ) ) ) );

					Utils::mail( $user->email, _t( '[%1$s] Password reset request for %2$s', array( Options::get( 'title' ), $user->displayname ) ), $message );
				}
				// Moving this inside the check for user existence would allow attackers to test usernames, so don't
				Session::notice( _t( 'A password reset request has been sent to the user.' ) );
			}
		}
		// Back to actual login.
		else {
			Utils::check_request_method( array( 'GET', 'HEAD', 'POST' ) );
			$name = $_POST['habari_username'];
			$pass = $_POST['habari_password'];

			if ( ( null != $name ) || ( null != $pass ) ) {
				$user = User::authenticate( $name, $pass );

				if ( ( $user instanceOf User ) && ( $user != false ) ) {

					// if there's an unused password reset token, unset it to make sure there's no possibility of a compromise that way
					if ( isset( $user->info->password_reset ) ) {
						unset( $user->info->password_reset );
					}

					/* Successfully authenticated. */
					// Timestamp last login date and time.
					$user->info->authenticate_time = HabariDateTime::date_create()->format( 'Y-m-d H:i:s' );
					$user->update();

					// Remove left over expired session error message.
					if ( Session::has_errors( 'expired_session' ) ) {
						Session::remove_error( 'expired_session' );
					}

					$login_session = Session::get_set( 'login' );
					if ( ! empty( $login_session ) ) {
						/* Now that we know we're dealing with the same user, transfer the form data so he does not lose his request */
						if ( ! empty( $login_session['post_data'] ) ) {
							Session::add_to_set( 'last_form_data', $last_form_data['post'], 'post' );
						}
						if ( ! empty( $login_session['get_data'] ) ) {
							Session::add_to_set( 'last_form_data', $last_form_data['get'], 'get' );
						}

						/* Redirect to the correct admin page */
						$dest = explode( '/', MultiByte::substr( $login_session['original'], MultiByte::strpos( $login_session['original'], 'admin/' ) ) );
						if ( '' == $dest[0] ) {
							$login_dest = Site::get_url( 'admin' );
						}
						else {
							// Replace '?' with '&' in $dest[1] before call URL::get()
							// Therefore calling URL::get() with a query string
							$dest[1] = str_replace( '?', '&', $dest[1] );
							$login_dest = URL::get( 'admin', 'page=' . $dest[1] );
						}
					}
					else {
						$login_session = null;
						$login_dest = Site::get_url( 'admin' );
					}

					// filter the destination
					$login_dest = Plugins::filter( 'login_redirect_dest', $login_dest, $user, $login_session );

					// finally, redirect to the destination
					Utils::redirect( $login_dest );

					return true;
				}

				/* Authentication failed. */
				// Remove submitted password, see, we're secure!
				$_POST['habari_password'] = '';
				$this->handler_vars['error'] = _t( 'Bad credentials' );
			}
		}

		// Display the login form.
		$this->login_form( $name );
	}

	/**
	* function logout
	* terminates a user's session, and deletes the Habari cookie
	* @param string the Action that was in the URL rule
	* @param array An associative array of settings found in the URL by the URL
	*/
	public function act_logout()
	{
		Utils::check_request_method( array( 'GET', 'HEAD', 'POST' ) );

		// get the user from their cookie
		$user = User::identify();
		if ( $user->loggedin ) {
			Plugins::act( 'user_logout', $user );
			// delete the cookie, and destroy the object
			$user->forget();
			$user = null;
		}
		Utils::redirect( Site::get_url( '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;
	}

	/**
	 * Helper function which automatically assigns all handler_vars
	 * into the theme and displays a theme template
	 *
	 * @param template_name Name of template to display (note: not the filename)
	 */
	protected function display( $template_name )
	{
		$this->theme->display( $template_name );
	}

	/**
	 * Handle password reset confirmations
	 */
	public function act_password_reset()
	{
		Utils::check_request_method( array( 'GET', 'HEAD', 'POST' ) );

		$id = $this->handler_vars['id'];
		$hash = $this->handler_vars['hash'];
		$name = '';

		if ( $user = User::get( $id ) ) {
			if ( is_string( $hash ) && ( $user->info->password_reset == md5( $hash ) ) ) {
				// Send a new random password
				$password = Utils::random_password();

				$user->password = Utils::crypt( $password );
				if ( $user->update() ) {
					$message = _t( "Your password for %1\$s has been reset.  Your credentials are as follows---\nUsername: %2\$s\nPassword: %3\$s", array( Site::get_url( 'habari' ), $user->username, $password ) );

					Utils::mail( $user->email, _t( '[%1$s] Password has been reset for %2$s', array( Options::get( 'title' ), $user->displayname ) ), $message );
					Session::notice( _t( 'A new password has been sent to the user.' ) );
				}
				else {
					Session::notice( _t( 'There was a problem resetting the password.  It was not reset.' ) );
				}

				// Clear the request - it should only work once
				unset( $user->info->password_reset );
				$user->info->commit();

				$name = $user->username;
			}
			else {
				Session::notice( _t( 'The supplied password reset token has expired or is invalid.' ) );
			}
		}
		// Display the login form.
		$this->login_form( $name );
	}

}
?>


code:
<?php
/**
 * @package Habari
 *
 */

/**
 * Class for handling default user theme actions.
 *
 * @note Any theme will be able to override these default actions by registering an override function with Theme->act_some_function()
 */
class UserThemeHandler extends ActionHandler
{

	/**
	 * Constructor for the default theme handler.
	 */
	public function __construct()
	{
		$this->setup_theme();
	}

	/**
	 * The UserThemeHandler's act() method differs from ActionHandler's
	 * act() method in one distinct way: if the Handler's theme variable
	 * registers an override action via Theme->register_action(), then
	 * that function is called instead of the default handler action.
	 *
	 * @param   action  the action that was in the URL rule
	 * @return  bool    did the action succeed?
	 */
	public function act( $action )
	{
		$this->action = $action;

		$action_method = 'act_' . $action;
		$before_action_method = 'before_' . $action_method;
		$after_action_method = 'after_' . $action_method;

		$this->theme->$before_action_method();
		try {
			$handled = false;
			$handled = Plugins::filter( 'theme_act_' . $action, $handled, $this->theme );
			if ( !$handled ) {
				$this->theme->$action_method();
			}
		}
		catch( Error $e ) {
			EventLog::log( $e->humane_error(), 'error', 'theme', 'habari', print_r( $e, 1 ) );
			Session::error( $e->humane_error() ); //Should we display any error here?
			if ( DEBUG ) {
				Utils::debug( $e );
			}
		}
		$this->theme->$after_action_method();
	}

	/**
	 * Helper function which automatically assigns all handler_vars
	 * into the theme and displays a theme template
	 *
	 * @param template_name Name of template to display ( note: not the filename )
	 */
	protected function display( $template_name )
	{
		/*
		 * Assign internal variables into the theme ( and therefore into the theme's template
		 * engine.  See Theme::assign().
		 */
		foreach ( $this->handler_vars as $key => $value ) {
			$this->theme->assign( $key, $value );
		}
		try {
			$this->theme->display( $template_name );
		}
		catch( Error $e ) {
			EventLog::log( $e->humane_error(), 'error', 'theme', 'habari', print_r( $e, 1 ) );
		}
	}
}

?>

repo_name: DaSourcerer/habari


code:
<?php
/**
 * Habari Index
 *
 * This is where all the magic happens:
 * 1. Validate the installation
 * 2. Set the locale
 * 3. Load the active plugins
 * 4. Parse and handle the incoming request
 * 5. Run the cron jobs
 * 6. Dispatch the request to the found handler
 *
 * @package Habari
 */

// Fail out if not included from root
if ( !defined( 'HABARI_PATH' ) ) {
	header( 'HTTP/1.1 403 Forbidden', true, 403 );
	die();
}

// Compares PHP version against our requirement.
if ( !version_compare( PHP_VERSION, '5.3.3', '>=' ) ) {
	die( 'Habari needs PHP 5.3.3 or higher to run. You are currently running PHP ' . PHP_VERSION . '.' );
}

// Increase the error reporting level: E_ALL, E_NOTICE, and E_STRICT
error_reporting( E_ALL | E_NOTICE | E_STRICT );

// set a default timezone for PHP. Habari will base off of this later on
date_default_timezone_set( 'UTC' );

/**
 * Start the profile time
 */
$profile_start = microtime( true );

/**
 * Make GLOB_BRACE available on platforms that don't have it. Use Utils::glob().
 */
if ( !defined( 'GLOB_BRACE' ) ) {
	define( 'GLOB_NOBRACE', true );
	define( 'GLOB_BRACE', 128 );
}

// We start up output buffering in order to take advantage of output compression,
// as well as the ability to dynamically change HTTP headers after output has started.
ob_start();

require( dirname( __FILE__ ) . '/autoload.php' );
spl_autoload_register( 'habari_autoload' );

// Replace all of the $_GET, $_POST and $_SERVER superglobals with object
// representations of each.  Unset $_REQUEST, which is evil.
// $_COOKIE must be set after sessions start
SuperGlobal::process_gps();

// Use our own error reporting class.
if ( !defined( 'SUPPRESS_ERROR_HANDLER' ) ) {
	Error::handle_errors();
}

/**
 * Initiate install verifications
 */

// Retrieve the configuration file's path.
$config = Site::get_dir( 'config_file' );

/**
 * We make sure the configuration file exist.
 * If it does, we load it and check its validity.
 *
 * @todo Call the installer from the database classes.
 */
if ( file_exists( $config ) ) {
	require_once( $config );
}

// Make sure we have a DSN string and database credentials.
// db_connection is an array with necessary informations to connect to the database.
if ( Config::exists('db_connection') ) {
	// Set the default locale.
	HabariLocale::set( Config::get('locale', 'en-us' ) );

	if ( !defined( 'DEBUG' ) ) {
		define( 'DEBUG', false );
	}

	// The connection details are registered. Try to connect to the database.
	try {
		DB::connect();
		// Make sure Habari is installed properly.
		// If the 'installed' option is missing, we assume the database tables are missing or corrupted.
		// @todo Find a decent solution, we have to compare tables and restore or upgrade them.
		if ( !@ Options::get( 'installed' ) ) {
			$installer = new InstallHandler();
			$installer->begin_install();
		}
	}
	catch( PDOException $e ) {
		// Error template.
		$error_template = '<title>%s</title><link rel="stylesheet" type="text/css" href="' . Site::get_url( 'system' ) . '/admin/css/admin.css" media="screen">

%s

%s

';

		// Format page with localized messages.
		$error_page = sprintf( $error_template,
			_t( "Habari General Error" ), // page title
			_t( "An error occurred" ), // H1 tag
			( defined( 'DEBUG' ) && DEBUG == true ) ?
				_t( "Unable to connect to database.  Error message: %s", array( $e->getMessage() ) ) :
				_t( "Unable to connect to database." )
			// Error message, more detail if DEBUG is defined.
		);

		// Set correct HTTP header and die.
		header( 'HTTP/1.1 500 Internal Server Error', true, 500 );
		die( $error_page );
	}
}
else {
	if ( !defined( 'DEBUG' ) ) {
		define( 'DEBUG', false );
	}

	// The configuration file does not exist.
	// Therefore we load the installer to create the configuration file and install a base database.
	$installer = new InstallHandler();
	$installer->begin_install();
}

/* Habari is installed and we established a connection with the database */

// Set the locale from config, database, then default english locale
HabariLocale::set( Config::get('locale', Options::get( 'locale', 'en-us' )) );
if ( Options::get( 'system_locale' ) ) {
	HabariLocale::set_system_locale( Options::get( 'system_locale' ) );
}

// Verify if the database has to be upgraded.
if ( Version::requires_upgrade() ) {
	$installer = new InstallHandler();
	$installer->upgrade_db();
}

// If we're doing unit testing, stop here
if ( defined( 'UNIT_TEST' ) ) {
	return;
}

// if this is an asyncronous call, ignore abort.
if ( isset( $_GET['asyncronous'] ) && Utils::crypt( Options::get( 'GUID' ), $_GET['asyncronous'] ) ) {
	ignore_user_abort( true );
}

// Send the Content-Type HTTP header.
// @todo Find a better place to put this.
header( 'Content-Type: text/html;charset=utf-8' );

// Load and upgrade all the active plugins.
spl_autoload_register( array( 'Plugins', '_autoload' ) );
Plugins::load_active();
Plugins::upgrade();

// All plugins loaded, tell the plugins.
Plugins::act( 'plugins_loaded' );

// Start the session.
Session::init();

// Replace the $_COOKIE superglobal with an object representation
SuperGlobal::process_c();

// Initiating request handling, tell the plugins.
Plugins::act( 'init' );

if ( defined( 'SUPPRESS_REQUEST' ) ) {
	return;
}

// Parse and handle the request.
Controller::parse_request();

// Run the cron jobs asyncronously.
CronTab::run_cron( true );

// Dispatch the request (action) to the matched handler.
Controller::dispatch_request();

// Flush (send) the output buffer.
$buffer = ob_get_clean();
$buffer = Plugins::filter( 'final_output', $buffer );
echo $buffer;
?>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php include( 'header.php' ); ?>
<form action="" method="post">
<?php
foreach ($this->engine_vars as $key => $val) {
	if ( is_scalar( $val ) ) {
		echo '<input type="hidden" name="' . htmlentities($key, ENT_COMPAT, 'UTF-8') . '" value="' . htmlentities($val, ENT_COMPAT, 'UTF-8') . '">';
	}
}
?>
<input type="hidden" name="locale" value="<?php echo Utils::htmlspecialchars($locale); ?>">

Config.php(<?php _e('help'); ?>)

			<?php _e('Your config.php file is not writable. In order to successfully install Habari, please paste the following into'); ?> <?php echo $config_file; ?>:

			<textarea class="config"><?php echo $file_contents; ?></textarea>

				<?php _e('config.php is a file that tells Habari how to connect to your database. Habari is not able to write this file to your server automatically, so you must create this file yourself to continute the installation.'); ?>
				<?php _e('Learn More…'); ?>

<?php _e('Install'); ?>

<?php _e('When you have successfully placed the config file, run the installer again.'); ?>

			<input type="submit" name="submit" value="<?php _e('Restart Installer'); ?>" />

</form>

<?php include( 'footer.php' ); ?>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php include( 'header.php' ); ?>
<?php if ( !isset( $form_errors ) ) $form_errors = array(); ?>
<?php function elem_if_set($a, $k) { if (isset($a[$k])) { return $a[$k]; } } ?>

<form action="" method="post" id="installform">
<input type="hidden" name="locale" value="<?php echo Utils::htmlspecialchars($locale); ?>" />

<?php _e('Database Setup'); ?>

	<?php _e('Help'); ?>

			<?php _e('Database Type'); ?> *
			<select id="db_type" name="db_type" tabindex="<?php echo $tab++; ?>">
			<?php
				foreach($pdo_drivers as $value => $text){
					echo '<option value="'.$value.'"';
					if ($db_type == (string)$value) {
						echo ' selected="selected"';
					}
					echo '>' . $text . "</option>\n";
				}
				foreach($pdo_missing_drivers as $value => $text){
					echo '<optgroup label="' . _t('%1$s - missing PDO driver, see help', array($text)) . '"></optgroup>';
				}
			?>
			</select>

				<?php _e('Database Type specifies the type of database to which Habari will connect.  Changing this setting may affect the other fields that are available here.  If the database engine that you wanted to use is not in this list, you may need to install a PDO driver to enable it.'); ?>
				<?php _e('Learn More…'); ?>

<?php _e('MySQL Settings'); ?>

<?php _e('Use the settings below only if you have selected MySQL as your database engine.'); ?>

			<?php _e('Database Host'); ?> *
			<input type="text" id="mysqldatabasehost" name="mysql_db_host" value="<?php echo $db_host; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'mysql_db_host'); ?>

				<?php _e('Database Host is the host (domain) name or server IP address of the server that runs the MySQL database to which Habari will connect.  If MySQL is running on your web server, and most of the time it is, "localhost" is usually a good value for this field.'); ?>
				<?php _e('Learn More…'); ?>

			<?php _e('Username'); ?> *
			<input type="text" id="mysqldatabaseuser" name="mysql_db_user" value="<?php echo $db_user; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'mysql_db_user'); ?>

				<?php _e('Database User is the username used to connect Habari to the MySQL database.'); ?>
				<?php _e('Learn More…'); ?>

			<?php _e('Password'); ?> *
			<input type="password" id="mysqldatabasepass" name="mysql_db_pass" value="<?php /* echo $db_pass; */ ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'mysql_db_pass'); ?>

				<?php _e('Database Password is the password used to connect the specified user to the MySQL database.'); ?>
				<?php _e('Learn More…'); ?>

			<?php _e('Database Name'); ?> *
			<input type="text" id="mysqldatabasename" name="mysql_db_schema" value="<?php echo $db_schema; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'mysql_db_schema'); ?>

				<?php _e('Database Name is the name of the MySQL database to which Habari will connect.'); ?>
				<?php _e('Learn More…'); ?>

<?php _e('PostgreSQL Settings'); ?>

<?php _e('Use the settings below only if you have selected PostgreSQL as your database engine.'); ?>

			<?php _e('Database Host'); ?> *
			<input type="text" id="pgsqldatabasehost" name="pgsql_db_host" value="<?php echo $db_host; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'pgsql_db_host'); ?>

				<?php _e('Database Host is the host (domain) name or server IP address of the server that runs the PostgreSQL database to which Habari will connect.  If PostgreSQL is running on your web server, and most of the time it is, "localhost" is usually a good value for this field.'); ?>
				<?php _e('Learn More…'); ?>

			<?php _e('Username'); ?> *
			<input type="text" id="pgsqldatabaseuser" name="pgsql_db_user" value="<?php echo $db_user; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'pgsql_db_user'); ?>

				<?php _e('Database User is the username used to connect Habari to the PostgreSQL database.'); ?>
				<?php _e('Learn More…'); ?>

			<?php _e('Password'); ?> *
			<input type="password" id="pgsqldatabasepass" name="pgsql_db_pass" value="<?php /* echo $db_pass; */ ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'pgsql_db_pass'); ?>

				<?php _e('Database Password is the password used to connect the specified user to the PostgreSQL database.'); ?>
				<?php _e('Learn More…'); ?>

			<?php _e('Database Name'); ?> *
			<input type="text" id="pgsqldatabasename" name="pgsql_db_schema" value="<?php echo $db_schema; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'pgsql_db_schema'); ?>

				<?php _e('Database Name is the name of the PostgreSQL database to which Habari will connect.'); ?>
				<?php _e('Learn More…'); ?>

<?php _e('SQLite Settings'); ?> *

<?php _e('Use the settings below only if you have selected SQLite as your database engine.'); ?>

			<?php _e('Data file'); ?> *
			<input type="text" id="databasefile" name="db_file" value="<?php echo $db_file; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'db_file'); ?>

				<?php _e('Data file is the SQLite file that will store your Habari data.  This should be the path to where your data file resides, relative to the Habari user directory.'); ?> <?php _e('Learn More…'); ?>

			<?php _e('Table Prefix'); ?>
			<input type="text" id="tableprefix" name="table_prefix" value="<?php echo $table_prefix; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'table_prefix'); ?>

				<?php _e('Table Prefix is a prefix that will be appended to each table that Habari creates in the database, making it easy to distinguish those tables in the database from those of other installations.'); ?>
				<?php _e('Learn More…'); ?>

			<button type="button" name="check_db_connection" id="check_db_connection" tabindex="<?php echo $tab++ ?>"><?php _e('Check Database Connection'); ?></button>

<?php _e('Site Configuration'); ?>

	<?php _e('Help'); ?>

			<?php _e('Site Name'); ?> *
			<input type="text" id="sitename" name="blog_title" value="<?php echo $blog_title; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'blog_title'); ?>

				<?php _e('Site Name is the name of your site as it will appear to your visitors.'); ?>  <?php _e('Learn More…'); ?>

			<?php _e('Username'); ?> *
			<input type="text" id="adminuser" name="admin_username" value="<?php echo $admin_username; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'admin_username'); ?>

				<?php _e('Username is the username of the initial user in Habari.'); ?>  <?php _e('Learn More…'); ?>

			<?php _e('Password'); ?> *
			<input type="password" id="adminpass1" name="admin_pass1" value="<?php echo $admin_pass1; ?>" tabindex="<?php echo $tab++ ?>" />
			<?php _e('Password (again)'); ?> *
			<input type="password" id="adminpass2" name="admin_pass2" value="<?php echo $admin_pass2; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'admin_pass'); ?>

				<?php _e('Password is the password of the initial user in Habari. Both password fields must match.'); ?>  <?php _e('Learn More…'); ?>

			<?php _e('Admin Email'); ?> *
			<input type="text" id="adminemail" name="admin_email" value="<?php echo $admin_email; ?>" tabindex="<?php echo $tab++ ?>" />
			<img class="status" src="<?php Site::out_url( 'habari' ); ?>/system/installer/images/ready.png" alt="" />

<?php echo elem_if_set( $form_errors, 'admin_email'); ?>

				<?php _e('Admin Email is the email address of the first user account.'); ?>
				<?php _e('Learn More…'); ?>

<?php _e('Theme Selection'); ?>

	<?php _e('Help'); ?>

		<?php foreach($themes as $key => $theme) { ?>
		<?php if ( !isset($theme['info']) ) { ?>

<?php printf( _t('The theme file %s is a legacy theme, and does not include an XML info file.'), $theme['file'] ); ?>

			<?php } else { ?>

						<input type="radio" name="theme" value="<?php echo $key; ?>"
																					id="theme_<?php echo $theme['dir']; ?>" tabindex="<?php echo $tab++ ?>" /><label for="theme_<?php echo $theme['dir']; ?>" class="name"><?php echo $theme['info']->name; ?> <?php echo $theme['info']->version; ?>
				<img src="<?php echo $theme['screenshot']; ?>" width="150px">

<?php echo $theme['info']->description; ?>

			<?php } ?>
		<?php } ?>

<?php _e('Plugin Activation'); ?>

	<?php _e('Help'); ?>

		<?php foreach($plugins as $plugin) { ?>
		<?php if ( !isset($plugin['info']) ) { ?>

<?php printf( _t('The plugin file %s is a legacy plugin, and does not include an XML info file.'), $plugin['file'] ); ?>

			<?php } else { ?>

						<input type="checkbox" name="plugin_<?php echo $plugin['plugin_id']; ?>"
																					id="plugin_<?php echo $plugin['plugin_id']; ?>"<?php if ($plugin['recommended']) echo ' checked="checked"'; ?> tabindex="<?php echo $tab++ ?>" /><label for="plugin_<?php echo $plugin['plugin_id']; ?>" class="name"><?php echo $plugin['info']->name; ?> <?php echo $plugin['info']->version; ?>

<?php echo $plugin['info']->description; ?>

			<?php } ?>
		<?php } ?>

			<input type="checkbox" name="checkbox_controller" id="checkbox_controller" tabindex="<?php echo $tab++ ?>" />
			None Selected

<?php _e('Install'); ?>

<?php _e('Habari now has all of the information needed to install itself on your server.'); ?>

			<input type="submit" name="submit" value="<?php _e('Install Habari'); ?>" id="submitinstall" tabindex="<?php echo $tab++ ?>" />

</form>

<?php include( 'footer.php' ); ?>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
	</div><!-- end wrapper -->
	<script type="text/javascript">
function _t() {
	var domain = <?php
		// retrieve only the translated strings that are used by this page's javascript functions.
		$messages = array_intersect_key( HabariLocale::get_messages(), array_flip( array( "All selected", "%s selected", "None selected" ) ) );
		echo json_encode( $messages );
	?>;
	var s = arguments[0];

	if(domain[s] != undefined) {
		s = domain[s][1][0];
	}

	for(var i = 1; i <= arguments.length; i++) {
		r = new RegExp('%' + (i) + '\\\\\$s', 'g');
		if(!s.match(r)) {
			r = new RegExp('%s');
		}
		s = s.replace(r, arguments[i]);
	}
	return s;
}
</script>
</body>
</html>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Language" content="en"/>
	<meta name="robots" content="no index,no follow" />
	<link rel="shortcut icon" href="<?php Site::out_url('habari'); ?>/favicon.ico" />
	<link href="<?php Site::out_url('habari'); ?>/system/installer/style.css" rel="stylesheet" type="text/css" />

	<title><?php _e('Install Habari'); ?></title>

		<?php $tab = 1; ?>

Habari

<a href="<?php Site::out_url( 'habari' ); ?>/doc/manual/index.html" onclick="popUp(this.href); return false;" title="<?php _e('Read the user manual'); ?>" tabindex="<?php echo $tab++ ?>"><?php _e('Manual'); ?> ·
					<a href="http://wiki.habariproject.org/" title="<?php _e('Read the Habari wiki'); ?>" tabindex="<?php echo $tab++ ?>"><?php _e('Wiki'); ?> ·
					<a href="http://groups.google.com/group/habari-users" title="<?php _e('Ask the community'); ?>" tabindex="<?php echo $tab++ ?>"><?php _e('Mailing List'); ?>

		<?php include "locale_dropdown.php"; ?>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php include( 'header.php' ); ?>

<form action="" method="post">
<input type="hidden" name="locale" value="<?php echo Utils::htmlspecialchars($locale); ?>">

.htaccess(<?php _e('help'); ?>)

			<?php _e('Your .htaccess file is not writable. In order to successfully install Habari, please paste the following into'); ?> <?php echo HABARI_PATH . '/.htaccess'; ?>:

			<textarea class="config" tabindex="<?php echo $tab++ ?>"><?php echo $file_contents; ?></textarea>

				<?php _e('.htaccess is a file that tells your Apache web server to send requests to Habari for handling. Habari is not able to write this file to your server automatically, so you must create this file yourself to continue the installation.'); ?>
				<a onclick="this.target='_blank';" href="<?php Site::out_url( 'habari' ); ?>/manual/index.html#Installation"><?php _e('Learn More…'); ?>

<?php _e('Install'); ?>

<?php _e('When you have successfully placed the .htaccess file, run the installer again.'); ?>

			<input type="submit" name="submit" value="<?php _e('Restart Installer'); ?>" tabindex="<?php echo $tab++ ?>">

</form>

<?php include( 'footer.php' ); ?>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>

<?php _e('Locale'); ?>

		<form method="post" action="" id="locale-form">

			<?php _e('Language'); ?>
			<?php
			$locs= array();
			foreach($locales as $loc):
				$locs[$loc]= $loc;
			endforeach;
			echo Utils::html_select( 'locale', $locs, $locale, array( 'tabindex' => $tab++ ) ); ?>

		</form>


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php include( 'header.php' ); ?>

<?php _e('Before you install Habari…'); ?>

<?php if (! $local_writable) {?>

<?php _e('Writable directory needed'); ?>…

	<?php if ($PHP_OS != 'WIN') {?>

			<?php _e('Before you can install Habari, you first need to make the install directory writable by php, so that the installation script can write your configuration information properly. The exact process depends on the web server and the ownership of the directory.'); ?>

			<?php _e('If your web server is part of the group which owns the directory, you\'ll need to add group write permissions to the directory. The procedure for this is as follows:'); ?>

				<?php _e('Open a terminal window, and then change to the installation directory:'); ?>

$> cd <?php echo $HABARI_PATH;?>

				<?php _e('Change the mode (permissions) of the current directory:'); ?>

$> chmod g+w .

$> chmod g+x .

					<?php _e('Note: You may need to use sudo and enter an administrator password if you do not own the directory.'); ?>

			<?php _e('If the web server is not part of the group which owns the directory, you will need to temporarily grant world write permissions to the directory:'); ?>

$> chmod o+w .

$> chmod o+x .

			<?php _e('Be sure to remove the write permissions on the directory as soon as the installation is completed.'); ?>

	<?php } else {?>
		@todo Windows instructions
	<?php }?>
<?php }?>

<?php if (! $php_version_ok) {?>

<?php _e('PHP Upgrade needed…'); ?>

		Habari <?php _e('requires PHP %s or newer. Your current PHP version is %s.', array(MIN_PHP_VERSION, PHP_VERSION)); ?>

	@todo Upgrading PHP instructions
<?php }?>

<?php if (! empty($missing_extensions)) {
	foreach ($missing_extensions as $ext_name => $ext_url) {
		$missing_ext_html[]= '' . $ext_name . '';
	}
	$missing_ext_html = implode( ', ', $missing_ext_html );
?>

<?php _e('Missing Extensions'); ?>

		Habari <?php _e('requires the following PHP extensions to be installed:'); ?> <?php echo $missing_ext_html; ?>. <?php _e('Please contact your web hosting provider if you do not have access to your server.'); ?>

<?php }?>

<?php if ( extension_loaded( 'pcre' ) && ! @preg_match( '/\p{L}/u', 'a' ) ) { ?>

Unicode support needed…

		Habari <?php _e('requires PHP\'s PCRE extension to have Unicode support enabled.'); ?> <?php _e('Please contact your web hosting provider if you do not have access to your server.'); ?>

<?php } ?>

<?php if ( ! $pdo_drivers_ok && ! array_key_exists( 'pdo', $missing_extensions )  ) { ?>

<?php _e('No PDO drivers enabled'); ?>

Habari <?php _e('requires that at least one PDO driver be installed. Please ask your hosting provider to enable one of the PDO drivers supported by Habari.'); ?>

<?php } ?>

<?php if ( ! $mod_rewrite ) { ?>

<?php _e('mod_rewrite not enabled'); ?>

 <?php _e('You have Apache, but mod_rewrite is not enabled. To use Habari, you must enable mod_rewrite in your server configuration. mod_rewrite is an Apache module that allows Habari (and other software) to handle URLs dynamically. You need a LoadModule rewrite_module line in your httpd.conf. Please ask your systems administrator or hosting provider to enable mod_rewrite.'); ?>

<?php } ?>

<?php include( 'footer.php' ); ?>


code:
var installer = {
	verifyDB: true,

	handleAjaxError: function(msg, status, err) {
		error_msg= '';
		if (msg.responseText != '') {
			error_msg= msg.responseText;
		}
		installer.showError(
			'Installation Issue'+
			'
The installer couldn\'t verify your settings, possibly because your server is not correctly configured.  See the manual for information on how to correct this problem, or continue without database verification.
' +
//			'
You might want to make sure mod_rewrite is enabled and that AllowOverride is at least set to FileInfo for the directory where .htaccess resides.
'+
			'Server Response'+
			'
'+error_msg.replace(/(<([^>]+)>)/ig,"")+'
'
		);
	},

	showError: function(error) {
		$('#installerror').html(error).fadeIn();
		$('html,body').animate({scrollTop: $('#installerror').offset().top},500);
	},

	setDatabaseType: function() {
		switch($('#db_type').val()) {
			case 'mysql':
				$('.forpgsql').hide();
				$('.forsqlite').hide();
				$('.formysql').show();
				break;
			case 'pgsql':
				$('.formysql').hide();
				$('.forsqlite').hide();
				$('.forpgsql').show();
				break;
			case 'sqlite':
				$('.formysql').hide();
				$('.forpgsql').hide();
				$('.forsqlite').show();
				break;
		}
		installer.checkDBFields();
	},

	checkDBCredentials: function() {
		switch ($('#db_type').val()) {
			case 'mysql':
				installer.mysql.checkDBCredentials();
				break;
			case 'pgsql':
				installer.pgsql.checkDBCredentials();
				break;
			case 'sqlite':
				installer.sqlite.checkDBCredentials();
				break;
		}
	},

	checkDBFields: function() {
		switch ($('#db_type').val()) {
			case 'mysql':
				installer.mysql.checkDBFields();
				break;
			case 'pgsql':
				installer.pgsql.checkDBFields();
				break;
			case 'sqlite':
				installer.sqlite.checkDBFields();
				break;
		}
	},

	checkSiteConfigurationCredentials: function() {
		var installok = true;

		// If admin passwords have been entered, check if they're the same
		var pass1 = $('#adminpass1');
		var pass2 = $('#adminpass2');

		if ( pass1.val().length > 0 && pass2.val().length > 0 && pass1.val() == pass2.val() ) {
			pass1.parents('.inputfield').removeClass('invalid').addClass('valid');
			installok = true;
		}
		else {
			pass1.parents('.inputfield').removeClass('valid').addClass('invalid');
			installok = false;
		}

		// Check other details have been entered
		$('#sitename, #adminuser').each(function(){
			if ($(this).val() != '') {
				$(this).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
			}
			else {
				$(this).parents('.inputfield').removeClass('valid').addClass('invalid');
				installok = false;
			}
		});

		// Very loosely check if the email is valid (don't be tempted to check this more strictly, you'll go mad, annoy people, or both).
		var regexemail = /.+@.+/;
		if (regexemail.test($('#adminemail').val())) {
			$('#adminemail').parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
		}
		else {
			$("#adminemail").parents('.inputfield').removeClass('valid').addClass('invalid');
			installok = false;
		}

		if (installok) {
//			installer.checkDBCredentials();
			$('#siteconfiguration, #themeselection').addClass('ready').addClass('done').children('.options').fadeIn().children('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
			$('#themeselection').children('.help-me').show();
		}
		else {
			$('#siteconfiguration').removeClass('done');
			$('#themeselection, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#themeselection').children('.help-me').hide();
		}
	},

	checkThemeConfiguration: function() {
		$('#siteconfiguration, #pluginactivation, #install').addClass('ready').addClass('done').children('.options').fadeIn().children('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
		$('#pluginactivation').children('.help-me').show();
		$('#submitinstall').removeAttr( 'disabled' );
	},

	noVerify: function() {
		installer.verifyDB = false;
		installer.showError('Verification Disabled
The installer will no longer attempt to verify the database settings.
' + $('#installerror').html());
	}

}

installer.mysql = {
	checkDBFields : function() {
		if ( ( $('#mysqldatabasehost').val() == '' ) || ( $('#mysqldatabaseuser').val() == '' ) || ( $('#mysqldatabasename').val() == '' ) ) {
			$('#check_db_connection').attr('disabled', true);
			$('#mysqldatabasename, #mysqldatabasehost, #mysqldatabasepass, #mysqldatabaseuser, #tableprefix').each(function() {
				$(this).parents('.inputfield').removeClass('invalid').removeClass('valid').find('.warning:visible').fadeOut();
			});
			$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
		}
		else {
			$('#check_db_connection').attr('disabled', false);
		}
	},

	checkDBCredentials : function() {
		if ( ( $('#mysqldatabasehost').val() != '' ) && ( $('#mysqldatabaseuser').val() != '' ) && ( $('#mysqldatabasename').val() != '' ) ) {
			if (installer.verifyDB) {
				$.ajax({
					type: 'POST',
					url: habari.url.check_mysql_credentials,
					data: { // Ask InstallHandler::ajax_check_mysql_credentials to check the credentials
						ajax_action: 'check_mysql_credentials',
						host: $('#mysqldatabasehost').val(),
						database: $('#mysqldatabasename').val(),
						user: $('#mysqldatabaseuser').val(),
						pass: $('#mysqldatabasepass').val(),
						table_prefix: $('#tableprefix').val()
					},
					success: function(xml) {
						$('#installerror').fadeOut();
						switch($('status',xml).text()) {
						case '0': // Show warning, fade the borders and hide the next step
							$('#mysqldatabasename, #mysqldatabasehost, #mysqldatabasepass, #mysqldatabaseuser, #tableprefix').each(function() {
								$(this).parents('.inputfield').addClass('valid').removeClass('invalid').find('.warning:visible').hide();
							});
							warningtext= $('message',xml).text();
							$('id',xml).each(function() {
								$($(this).text()).parents('.inputfield').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn();
								$($(this).text()).parents('.installstep').removeClass('done')
							});
							$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
							$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
							break;
						case '1': // Hide the warnings, highlight the borders and show the next step
							installer.mysql.validDBCredentials();
							break;
						}
					},
					error: installer.handleAjaxError
				});
			} else {
				installer.mysql.validDBCredentials();
			}
		} else {
			$('#mysqldatabasename, #mysqldatabasehost, #mysqldatabasepass, #mysqldatabaseuser, #tableprefix').each(function() {
				$(this).parents('.inputfield').removeClass('invalid').removeClass('valid').find('.warning:visible').fadeOut();
			});
			$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
		}
	},

	validDBCredentials: function() {
		$('#mysqldatabasename, #mysqldatabasehost, #mysqldatabasepass, #mysqldatabaseuser, #tableprefix').each(function() {
			$(this).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
			$(this).parents('.installstep').addClass('done');
		});
		$('#siteconfiguration').children('.options').fadeIn().addClass('ready');
		$('#siteconfiguration').children('.help-me').show();
		installer.checkSiteConfigurationCredentials();
	}
}

installer.pgsql = {
	checkDBFields : function() {
		if ( ( $('#pgsqldatabasehost').val() == '' ) || ( $('#pgsqldatabaseuser').val() == '' ) || ( $('#pgsqldatabasename').val() == '' ) ) {
			$('#check_db_connection').attr('disabled', true);
			$('#pgsqldatabasename, #pgsqldatabasehost, #pgsqldatabasepass, #pgsqldatabaseuser, #tableprefix').each(function() {
				$(this).parents('.inputfield').removeClass('invalid').removeClass('valid').find('.warning:visible').fadeOut();
			});
			$('.installstep:eq(1)').removeClass('done');
			$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
		}
		else {
			$('#check_db_connection').attr('disabled', false);
		}
	},

	checkDBCredentials : function() {
		if ( ( $('#pgsqldatabasehost').val() != '' ) && ( $('#pgsqldatabaseuser').val() != '' ) && ( $('#pgsqldatabasename').val() != '' ) ) {
			if (installer.verifyDB) {
				$.ajax({
					type: 'POST',
					url: habari.url.check_pgsql_credentials,
					data: { // Ask InstallHandler::ajax_check_pgsql_credentials to check the credentials
						ajax_action: 'check_pgsql_credentials',
						host: $('#pgsqldatabasehost').val(),
						database: $('#pgsqldatabasename').val(),
						user: $('#pgsqldatabaseuser').val(),
						pass: $('#pgsqldatabasepass').val(),
						table_prefix: $('#tableprefix').val()
					},
					success: function(xml) {
						$('#installerror').fadeOut();
						switch($('status',xml).text()) {
						case '0': // Show warning, fade the borders and hide the next step
							$('#pgsqldatabasename, #pgsqldatabasehost, #pgsqldatabasepass, #pgsqldatabaseuser, #tableprefix').each(function() {
								$(this).parents('.inputfield').addClass('valid').removeClass('invalid').find('.warning:visible').hide();
							});
							warningtext= $('message',xml).text();
							$('id',xml).each(function() {
								$($(this).text()).parents('.inputfield').addClass('invalid').find('.warning').html(warningtext).fadeIn();
								$($(this).text()).parents('.installstep').removeClass('done')
							});
							$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
							$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
							break;
						case '1': // Hide the warnings, highlight the borders and show the next step
							installer.pgsql.validDBCredentials();
							break;
						}
					},
					error: installer.handleAjaxError
				});
			} else {
				installer.pgsql.validDBCredentials();
			}
		} else {
			$('#pgsqldatabasename, #pgsqldatabasehost, #pgsqldatabasepass, #pgsqldatabaseuser, #tableprefix').each(function() {
				$(this).parents('.inputfield').removeClass('invalid').removeClass('valid').find('.warning:visible').fadeOut();
			});
			$('.installstep:eq(1)').removeClass('done');
			$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
		}
	},

	validDBCredentials: function() {
		$('#pgsqldatabasename, #pgsqldatabasehost, #pgsqldatabasepass, #pgsqldatabaseuser, #tableprefix').each(function() {
			$(this).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
			$(this).parents('.installstep').addClass('done')
		});
		$('#siteconfiguration').children('.options').fadeIn().addClass('ready');
		$('#siteconfiguration').children('.help-me').show();
		installer.checkSiteConfigurationCredentials();
	}
}

installer.sqlite = {
	checkDBFields : function() {
		if ( ( $('#databasefile').val() == '' ) ) {
			$('#check_db_connection').attr('disabled', true);
			$('#databasefile, #tableprefix').each(function() {
				$(this).parents('.inputfield').removeClass('invalid').removeClass('valid').find('.warning:visible').fadeOut();
			});
			$('.installstep:eq(1)').removeClass('done');
			$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
		}
		else {
			$('#check_db_connection').attr('disabled', false)
		}
	},

	checkDBCredentials : function() {
		if ( $('#databasefile').val() != '' ) {
			if (installer.verifyDB) {
				$.ajax({
					type: 'POST',
					url: habari.url.check_sqlite_credentials,
					data: { // Ask InstallHandler::ajax_check_sqlite_credentials to check the credentials
						ajax_action: 'check_sqlite_credentials',
						file: $('#databasefile').val()
					},
					success: function(xml) {
						$('#installerror').fadeOut();
						switch($('status',xml).text()) {
						case '0': // Show warning, fade the borders and hide the next step
							$('#databasefile, #tableprefix').each(function() {
								$(this).parents('.inputfield').addClass('valid').removeClass('invalid').find('.warning:visible').hide();
							});
							warningtext= $('message',xml).text();
							$('id',xml).each(function() {
								$($(this).text()).parents('.inputfield').removeClass('valid').addClass('invalid').find('.warning').html(warningtext).fadeIn();
								$($(this).text()).parents('.installstep').removeClass('done')
							});
							$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
							$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
							break;
						case '1': // Hide the warnings, highlight the borders and show the next step
							installer.sqlite.validDBCredentials();
							break;
						}
					},
					error: installer.handleAjaxError
				});
			} else {
				installer.sqlite.validDBCredentials();
			}
		} else {
			$('#databasefile, #tableprefix').each(function() {
				$(this).parents('.inputfield').removeClass('invalid').removeClass('valid').find('.warning:visible').fadeOut();
			});
			$('.installstep:eq(1)').removeClass('done');
			$('#siteconfiguration, #pluginactivation, #install').removeClass('ready').removeClass('done').children('.options').fadeOut();
			$('#siteconfiguration, #pluginactivation').children('.help-me').hide();
		}
	},

	validDBCredentials: function() {
		$('#databasefile, #tableprefix').each(function() {
			$(this).parents('.inputfield').removeClass('invalid').addClass('valid').find('.warning:visible').fadeOut();
			$(this).parents('.installstep').addClass('done')
		});
		$('#siteconfiguration').children('.options').fadeIn().addClass('ready');
		$('#siteconfiguration').children('.help-me').show();
		installer.checkSiteConfigurationCredentials();
	}
}

/* Handles the timers for verification */
var checktimer = null;
function queueTimer(timer){
	if(checktimer != null) {
		clearTimeout(checktimer);
	}
	checktimer = setTimeout(timer, 500);
}

/* Manages Plugin Activation Items */
var itemManage = {
	init: function() {
		if(!$('.item.controls input[type=checkbox]')) return;

		$('.item.controls input[type=checkbox]').change(function () {
			if($('.item.controls label').hasClass('all')) {
				itemManage.uncheckAll();
			} else {
				itemManage.checkAll();
			}
		});

		$('.item:not(.ignore):not(.controls) .checkbox input[type=checkbox]').change(function () {
			itemManage.changeItem();
		});

		itemManage.changeItem();
	},
	changeItem: function() {
		var selected = {};

		count = $('.item:not(.hidden):not(.ignore):not(.controls) .checkbox input[type=checkbox]:checked').length;

		if(count == 0) {
			$('.item.controls input[type=checkbox]').each(function() {
				this.checked = 0;
			});
			$('.item.controls label').addClass('none').removeClass('all').text(_t('None selected'));
		} else if(count == $('.item:not(.hidden):not(.ignore):not(.controls) .checkbox input[type=checkbox]').length) {
			$('.item.controls input[type=checkbox]').each(function() {
				this.checked = 1;
			});
			$('.item.controls label').removeClass('none').addClass('all').text(_t('All selected'));
		} else {
			$('.item.controls input[type=checkbox]').each(function() {
				this.checked = 0;
			});
			$('.item.controls label').removeClass('none').removeClass('all').text(_t('%s selected', count));
		}
	},
	uncheckAll: function() {
		$('.item:not(.hidden):not(.ignore):not(.controls) .checkbox input[type=checkbox]').each(function() {
			this.checked = 0;
		});
		itemManage.changeItem();
	},
	checkAll: function() {
		$('.item:not(.hidden):not(.ignore):not(.controls) .checkbox input[type=checkbox]').each(function() {
			this.checked = 1;
		});
		itemManage.changeItem();
	}
}

$(document).ready(function() {
	$('.help-me').click(function(){$(this).parents('.installstep').find('.help').slideToggle();return false;});
	$('.help').hide();
	$('.installstep').removeClass('ready');
	$('.installstep:eq(0), .installstep:eq(1)').addClass('ready');
	// Table Prefix is optional, it is always OK
	$('#tableprefix').parents('.inputfield').addClass('valid');
	$('.javascript-disabled').hide();
	$('#installform').before('

');
	$('#installerror').hide();
	$('form').attr('autocomplete', 'off');
	itemManage.init();
	installer.setDatabaseType();
//	installer.checkDBFields();
	$('#db_type').change(installer.setDatabaseType);
	$('#databasesetup input').keyup(function(){queueTimer(installer.checkDBFields)});
	$('#check_db_connection').click(function(){installer.checkDBCredentials()});
	$('#siteconfiguration input').keyup(function(){queueTimer(installer.checkSiteConfigurationCredentials)});
	$('#themeselection input').click(function(){queueTimer(installer.checkThemeConfiguration)})
	$('#locale').focus().change(function() { $('#locale-form').submit();	});
});


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php include( 'header.php' ); ?>

<form action="" method="post">
<input type="hidden" name="locale" value="<?php echo Utils::htmlspecialchars($locale); ?>">

.htaccess(<?php _e('help'); ?>)

			<?php _e('Your .htaccess file is not writable. In order to secure your SQLite database, please paste the following into %s:', array(HABARI_PATH . '/.htaccess')); ?>

			<textarea class="config"><?php echo $sqlite_contents; ?></textarea>

				<?php _e('Your SQLite database is a file on your server like any other file. You can enhance it\'s security by including a section in your .htaccess file that disallows access to it by readers on the web. Habari is not able to write this section in your .htaccess file automatically, so you must add this section yourself to gain the enhanced security it offers you.'); ?>
				<a onclick="this.target='_blank';" href="<?php Site::out_url( 'habari' ); ?>/manual/index.html#Installation"><?php _e('Learn More…'); ?>

<?php _e('Install'); ?>

<?php _e('When you have successfully placed the .htaccess file, run the installer again.'); ?>

			<input type="submit" name="submit" value="<?php _e('Restart Installer'); ?>" />

</form>

<?php include( 'footer.php' ); ?>


code:
/* @override style.css */

/* Force vertical scrollbars so that revealing help or errors don't move the form to the left */
html {
	height: 100%;
	margin-bottom: 1px;
	overflow-y: scroll
}

body {
	font-family: 'Helvetica Neue', Helvetica, Arial, Sans-Serif;
	padding: 0;
	margin: 0;
}

#installer {
	text-align: center;
	min-width: 600px;
	background: #f1f1f1;
}

a {
	color: #999;
}

#wrapper {
	width: 552px;
	margin: 0 auto 50px;
}

#masthead {
	margin: 30px 0;
}

#masthead h1 {
	font-size: 35px;
	line-height: 35px;
	color: #333;
	margin-bottom: 0px;
	text-transform: lowercase;
}

#masthead p {
	font-size: 11px;
	text-transform: lowercase;
	color: #666;
	margin: 0px;
}

.installstep {
	width: 552px;
	background: url(images/install-step.png) scroll repeat-y 0px 47px;
	margin-top: 20px;
	position: relative;
}

.installstep.done {
	background: url(images/install-step_done.png) scroll repeat-y 0px 47px;
}

.installstep h2 {
	color: #333;
	line-height: 30px;
	font-size: 18px;
	background: url(images/install-step_h2.png) scroll no-repeat top left;
	font-weight: normal;
	padding: 10px 22px 0px;
	margin: 0px;
}

.installstep.done h2 {
	background: url(images/install-step_h2_done.png) scroll no-repeat top left;
}

.help-me {
	float: right;
	position: absolute;
	top: 20px;
	right: 25px;
	display: none;
	height: 15px;
	width: 15px;
	text-indent: -3000px;
	background: url(../admin/images/help_icon.png) scroll no-repeat top left;
	outline: none;
}

.ready .help-me {
	display: block;
}

.help-me:hover {
	background: url(../admin/images/help_icon_over.png) scroll no-repeat top left;
}

.options, .advanced-options {
	text-align: left;
	font-size: 0.76em;
	padding: 0px 11px 0px 22px;
}

.options {
	background: url(images/options.png) scroll no-repeat 0px 0px;
}

.installstep.done .options {
	background: url(images/options_done.png) scroll no-repeat 0px 0px;
}

.installstep .options, .installstep .advanced-options, .installstep h2 .help-me {
	display: none;
}

.installstep.ready .options, .installstep.ready .advanced-options, .installstep.ready h2 .help-me {
	display: block;
}

.options .inputfield, .advanced-options .inputfield {
	margin-bottom: 5px;
	padding-top: 15px;
}

div.javascript-disabled {
	width: 440px;
	color: #666666;
	padding: 10px 15px;
	margin: 0px 5px 0px 15px;
	border: 1px solid #dedede;
	background: #f1f1f1;
	text-align: center;
}

.inputfield label, .item label {
	color: #666;
}

.inputfield label {
	padding: 3px 20px 0 0;
	display: block;
	width: 122px;
	float: left;
}

.inputfield label strong {
	color: #FF0000;
}

.inputfield select {
	width: 336px;
}

.inputfield input {
	width: 329px;
	padding-left: 2px
}

#sitename {
	font-weight: bold;
}

.inputfield .status {
	position: relative;
	top: 2px;
	width: 34px;
	height: 15px;
}

.valid .status {
	background: url(images/ok.png);
}

.invalid .status {
	background: url(images/warningsmall.png) no-repeat center;
}

.inputfield .warning {
	display: block;
	padding: 3px 45px 0px 145px;
	line-height: 120%;
	text-align: left;
	color: #cc0000;
}

.inputfield .help {

	/* display: none; */
	padding: 10px 45px 10px 145px;
	color: #666;
	font-size: 11px;
	line-height: 15px;
}

.inputfield .config {
	width: 507px;
	height: 150px;
	margin: 10px 0px 0px
}

.installstep .bottom {
	height: 10px;
	background: url(images/options_bottom.png) scroll no-repeat left bottom;
}

.installstep.done .bottom {
	height: 15px;
	background: url(images/options_bottom_done.png) scroll no-repeat left bottom;
}

.installstep.ready .bottom {
	height: 15px;
}

.bottom {
	clear: both;
}

.next-section {
	height: 14px;
	width: 100%;
	margin: 20px 0px 0px 0px;
	background: url(images/next-section.png) scroll no-repeat center bottom;
}

.inputfield.submit p {
	display: none;
}

.submit {
	text-align: center;
}

.submit input {
	width: 40%;
	margin: 0 0 10px;
}

#check_db_connection {
	margin-left: 180px;
	width: 50%;
}

.error {
	padding: .8em;
	margin-bottom: 1em;
	border: 2px solid #ddd;
	background: #FBE3E4;
	border-color: #FBC2C4;
}

.error, .error a {
	color: #D12F19;
}

#footer a {
	font-size: 11px !important;
	text-transform: lowercase;
	color: #999;
	padding: 0 3px;
}

#footer a:hover {
	color: #666;
}

/* item selection */
.items div.item {
	padding: 5px 0;
}

.items span.checkbox {
	position: absolute;
}

.items label {
	position: relative;
	top: 3px;
}

.items label, .items div.help {
	padding-left: 30px;
}

.items .controls {
	margin-top: 20px;
}

.items .controls label {
	color: #888888;
}

optgroup {
	font-style: normal;
	color: #aaaaaa;
	font-weight: normal;
	padding-left: 3px;
}

.clearfix:after {
	visibility: hidden;
	display: block;
	font-size: 0;
	content: " ";
	clear: both;
	height: 0;
}

* html .clearfix {
	zoom: 1;
}

/* IE6 */
*:first-child+html .clearfix {
	zoom: 1;
}

/* IE7 */

#themeselection .item {
	width: 170px;
	float: left;
}

#themeselection .item img {
	display: block;
}


code:
<?php if ( !defined( 'HABARI_PATH' ) ) { die('No direct access'); } ?>
<?php

/**
 * InstallerTheme is a custom Theme class for the installer.
 *
 * @package Habari
 */

// We must tell Habari to use MyTheme as the custom theme class:

/**
 * A custom theme for the installer
 */
class InstallerTheme extends Theme
{

/**
	 * Add additional template variables to the template output.
	 * For the installer, we don't want any extra template variables added.
	 *
	 */
	public function add_template_vars()
	{

	}

}

?>


code:
<?xml version="1.0" encoding="utf-8" ?>
<pluggable type="theme" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schemas.habariproject.org/pluggable/0.8">
	<name>Installer Theme</name>
	<license url="http://www.apache.org/licenses/LICENSE-2.0.html">Apache Software License 2.0</license>

	<author url="http://habariproject.org/">The Habari Project</author>

	<version>1.0</version>
	<url>http://habariproject.org/</url>
	<description><![CDATA[The theme used to install Habari.]]></description>

	<template_engine>rawphpengine</template_engine>

	<copyright>2011</copyright>
</pluggable>


code:
msgid ""
msgstr ""
"Project-Id-Version: Habari 0.1\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: 2006-10-30 20:33-0500\n"
"Last-Translator: Owen Winkler <epithet+habari@midnightcircus.com>\n"
"Language-Team: Habari\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: system/classes/urlparser.php:162
msgid "The thing you were looking for was not found.  We should probably display some kind of intelligent error here."
msgstr "The thing you were looking for was not found, yo.  We a 'telligent error here, a'ight?"