<?php
/*
* Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2007 The Nucleus Group
+ * Copyright (C) 2002-2012 The Nucleus Group
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
*
* This script will install the Nucleus tables in your SQL-database,
* and initialize the data in those tables.
- *
- * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
- * ?><div style="font-size: xx-large;"> Your web server is not properly configured to run PHP scripts and will not be able to install Nucleus. </div> <div style="display: none;"><?php
*/
-
/**
* @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2007 The Nucleus Group
- * @version $Id$
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group
+ * @version $Id: index.php 1889 2012-06-17 08:46:45Z sakamocchi $
*/
-// don't give warnings for uninitialized vars
-error_reporting(E_ERROR | E_WARNING | E_PARSE);
+/* global values initialize */
+$CONF = array();
+/* reporting all errors for support */
+error_reporting(E_ALL);
$minimum_php_version = '5.0.6';
$minimum_mysql_version = '3.23';
+$page_footer_copyright = '© 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00';
+
// begin if: server's PHP version is below the minimum; halt installation
if ( version_compare(PHP_VERSION, $minimum_php_version, '<') )
{
- exit('<div style="font-size: xx-large;"> Nucleus requires at least PHP version '. $minimum_php_version .'</div>');
-} // end if
+ exit('<div style="font-size: xx-large;"> Nucleus requires at least PHP version ' . $minimum_php_version . '</div>');
+}
// make sure there's no unnecessary escaping: # set_magic_quotes_runtime(0);
if ( version_compare(PHP_VERSION, '5.3.0', '<') )
{
- ini_set('magic_quotes_runtime', '0');
-} // end if
-
-
-/**
- * This part of the ./install/index.php code allows for customization of the install process.
- * When distributing plugins or skins together with a Nucleus installation, the
- * configuration below will instruct to install them
- *
- * -- Start Of Configurable Part --
- **/
-
-/**
- * array with names of plugins to install. Plugin files must be present in the nucleus/plugin/ directory
- *
- * example:
- * array('NP_TrackBack', 'NP_MemberGoodies')
- **/
-$aConfPlugsToInstall = array('NP_SkinFiles', 'NP_SecurityEnforcer', 'NP_Text');
-
-/**
- * array with skins to install. skins must be present under the skins/ directory with
- * a subdirectory having the same name that contains a skinbackup.xml file
- *
- * example:
- * array('base', 'rsd')
- **/
-$aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default');
-
-/**
- * -- End Of Configurable Part --
- **/
+ ini_set('magic_quotes_runtime', '0');
+}
+/* default installed plugins and skins */
+$aConfPlugsToInstall = array('NP_SecurityEnforcer', 'NP_SkinFiles', 'NP_Medium');
+$aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default', 'admin/default', 'admin/bookmarklet');
// Check if some important files
-doCheckFiles();
-
-// if there are some plugins or skins to import, do not include vars in globalfunctions.php again... so set a flag
-if ( (count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) )
-{
- global $CONF;
- $CONF['installscript'] = 1;
-} // end if
-
-// we will use postVar, getVar, ... methods instead of $_GET, $_POST ...
-include_once('../nucleus/libs/vars4.1.0.php');
+do_check_files();
-// include core classes that are needed for internationalization
+/* i18n class is needed for internationalization */
include_once('../nucleus/libs/i18n.php');
-
-if ( !i18n::init('UTF-8', './locales') )
+if ( !i18n::init('UTF-8', '../nucleus/locales') )
{
exit('<div style="font-size: xx-large;"> Failed to initialize iconv or mbstring extension. Would you please contact the administrator of your PHP server? </div>');
-} // end if
-
-// check if mysql support is installed; this check may not make sense, as is, in a version past 3.5x
-if ( !function_exists('mysql_query') && !function_exists('mysqli_query') )
-{
- exit('<div style="font-size: xx-large;"> Your PHP version does not have support for MySQL :( </div>');
-} // end if
+}
// include core classes that are needed for login & plugin handling
-include_once('../nucleus/libs/mysql.php');
// added for 3.5 sql_* wrapper
global $MYSQL_HANDLER;
-//set the handler if different from mysql (or mysqli) # $MYSQL_HANDLER = array('pdo','mysql');
if ( !isset($MYSQL_HANDLER) )
{
$MYSQL_HANDLER = array('mysql', '');
-} // end if
+
+ // check if mysql support is installed; this check may not make sense, as is, in a version past 3.5x
+ if ( !function_exists('mysql_query') && !function_exists('mysqli_query') )
+ {
+ exit('<div style="font-size: xx-large;"> Your PHP version does not have support for MySQL :( </div>');
+}
+}
+include_once('../nucleus/libs/sql/sql.php');
-include_once('../nucleus/libs/sql/' . $MYSQL_HANDLER[0] . '.php');
-// end new for 3.5 sql_* wrapper
+session_start();
+if ( count($_GET) == 0 && count($_POST) == 0 )
+{
+ unset($_SESSION['param_manager']);
+}
-
-doAction();
+// restore the $param from the session
+if ( array_key_exists('param_manager', $_SESSION) )
+{
+ $param = $_SESSION['param_manager'];
+}
+else
+{
+ $param = new ParamManager();
+}
+
+// include translation file
+$param->set_locale();
+do_action();
+
+// $param is saved to the session
+if ( isset($param) )
+{
+ $_SESSION['param_manager'] = $param;
+}
+else
+{
+ unset($_SESSION['param_manager']);
+}
exit;
/**
+ * installer action
+ */
+function do_action()
+{
+ global $param;
+
+ if ( array_key_exists('action', $_POST) )
+ {
+ $isPostback = true;
+ }
+ else
+ {
+ $isPostback = false;
+ }
+
+ // mode change
+ if ( array_key_exists('mode', $_REQUEST) )
+ {
+ if ( $_REQUEST['mode'] == 'detail' )
+ {
+ $param->set_state('detail');
+ }
+ elseif ( $_REQUEST['mode'] == 'simple' )
+ {
+ $param->set_state('mysql');
+ }
+ }
+
+ // input parameter check
+ if ( $isPostback )
+ {
+ switch ( $param->state )
+ {
+ case 'locale':
+ $param->set_state('mysql');
+ $isPostback = false;
+ break;
+ case 'mysql':
+ if ( count($param->check_mysql_parameters()) == 0 )
+ {
+ $param->set_state('weblog');
+ $isPostback = false;
+ }
+ break;
+ case 'weblog':
+ if ( count($param->check_user_parameters()) == 0
+ && count($param->check_weblog_parameters()) == 0 )
+ {
+ $param->set_state('install');
+ $isPostback = false;
+ }
+ break;
+ case 'detail':
+ if ( $param->check_all_parameters() )
+ {
+ $param->set_state('install');
+ $isPostback = false;
+ }
+ break;
+ }
+ }
+
+ // page render
+ show_header();
+ switch ( $param->state )
+ {
+ case 'locale':
+ show_select_locale_form();
+ break;
+ case 'mysql':
+ show_database_setting_form($isPostback);
+ break;
+ case 'weblog':
+ show_blog_setting_form($isPostback);
+ break;
+ case 'detail':
+ show_detail_setting_form($isPostback);
+ break;
+ case 'install':
+ show_install_complete_form();
+ break;
+ }
+ show_footer();
+}
+
+/**
* header tag of the installation screens
**/
-function showHeader()
+function show_header()
{
- /* send HTTP header */
- header('Content-Type: text/html; charset=' . i18n::get_current_charset());
+ global $param;
+ /* HTTP 1.1 application for no caching */
+ header("Cache-Control: no-cache, must-revalidate");
+ header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+ header('Content-Type: text/html; charset=' . i18n::get_current_charset());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo i18n::get_current_charset(); ?>" />
<title><?php echo _TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="./styles/inst.css" />
<style type="text/css">
<?php echo _BODYFONTSTYLE; ?>
-->
</style>
+ <script type="text/javascript">
+ function SelectText( element ) {
+ window.setTimeout( function() { element.select() }, 0 );
+ }
+ var isSubmit = false;
+ function OnceSubmit() {
+ if (!isSubmit) {
+ isSubmit = true;
+ window.setTimeout( function() { isSubmit = false; }, 10000 );
+ return true;
+ }
+ return false;
+ }
+ </script>
</head>
<body>
+ <div id="header">
+ <div id="navigation">
+ <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
+ <ul>
+<?php
+ echo '<li>';
+ $label = '_LOCALE_' . strtoupper($param->locale);
+ if ( !defined($label) )
+ {
+ echo $param->locale;
+ }
+ else
+ {
+ echo constant($label);
+ }
+ echo "</li>\n";
+
+ if ( in_array($param->state, array('mysql', 'weblog', 'install')) )
+ {
+ echo '<li> > ' . _STEP1, '</li><li';
+ if ( $param->state == 'mysql' )
+ {
+ echo ' class="gry"';
+ }
+ echo '> > ', _STEP2, '</li><li';
+ if ( in_array($param->state, array('mysql', 'weblog')) )
+ {
+ echo ' class="gry"';
+ }
+ echo '> > ', _STEP3, "</li>\n";
+ }
+ if ( in_array($param->state, array('mysql', 'weblog', 'detail')) )
+ {
+ echo '<li class="rightbox">';
+ if ( in_array($param->state, array('mysql', 'weblog')) )
+ {
+ echo '<a href="./?mode=detail">', _MODE2, '</a>';
+ }
+ else
+ {
+ echo '<a href="./?mode=simple">', _MODE1, '</a>';
+ }
+ echo '</li>';
+ }
+?>
+ </ul>
+ </div>
+ </div>
<?php
}
/**
* footer tag of the installation screens
**/
-function showFooter()
+function show_footer()
{
+ global $page_footer_copyright;
?>
<div id="footer">
- © 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00
+ <?php echo $page_footer_copyright; ?>
</div>
</body>
</html>
<?php
}
-
/**
- * installer action
+ * Display the form for language select
*/
-function doAction()
+function show_select_locale_form()
{
- global $errors;
- $errors = array();
-
- session_start();
-
- if ( postVar('locale') )
- {
- $_SESSION['locale'] = postVar('locale');
- }
-
- /* TODO: if something input related to locale, set it, else set default */
- i18n::set_current_locale($_SESSION['locale'] ? $_SESSION['locale'] : 'en_Latn_US');
- $translation_file = './locales/' . i18n::get_current_locale() . '.' . i18n::get_current_charset() . '.php';
- if ( !file_exists($translation_file) )
- {
- $translation_file = './locales/en_Latn_US.UTF-8.php';
- }
- include($translation_file);
-
+ global $param;
+?>
+ <div id="container">
+ <p style="font-size:152%;font-weight:bold;">
+ <?php echo _LOCALE_HEADER; ?>
+ </p>
+ <form method="post" action="./index.php">
- showHeader();
-
- if ( !postVar('action') && !requestVar('mode') )
- {
- // Initialize the session
- $_SESSION = array();
- $_SESSION['mode'] = 'simple';
- $_SESSION['mysql_host'] = _hsc(@ini_get('mysql.default_host'));
- getURLAndPath();
- showSelectLocaleForm();
- }
- else
+ <div class="prt">
+ <select name="locale">
+<?php
+ $locales = i18n::get_available_locale_list();
+ foreach ( $locales as $locale )
{
- // mode change
- if ( requestVar('mode') )
+ if ( $param->locale != $locale )
{
- $_SESSION['mode'] = requestVar('mode');
+ echo "<option value=\"{$locale}\">";
}
-
- $action = postVar('action');
- $isValid = doValidate();
- if ( $action == 'install' && $isValid && doInstall() ) // install process
- {
- showInstallCompleteForm();
- // Clearing the session
- $_SESSION = array();
- }
- elseif ( $_SESSION['mode'] == 'simple' ) // simple install mode
+ else
{
- if ( !$action || ( $action == 'next' && count($errors['db_setting']) > 0 ) )
- {
- if ( !$action )
- {
- $errors = array();
- }
- showDBSettingForm();
- }
- else
- {
- if ( $action == 'next' )
- {
- $errors = array();
- }
- showBlogSettingForm();
- }
+ echo "<option value=\"{$locale}\" selected=\"selected\">";
}
- else // advanced install mode
+
+ $checkfile = "./locales/{$locale}." . i18n::get_current_charset() . '.php';
+ if ( !file_exists($checkfile) )
{
- if ( !$action )
- {
- $errors = array();
- }
- showDetailSettingForm();
+ echo '* ';
}
- }
-
- showFooter();
-}
-/**
- * Display the form for language select
- */
-function showSelectLocaleForm()
-{
- // Get the browser language that can be displayed
- // TODO: not used
- $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
- foreach ($languages as $language)
+ $label = '_LOCALE_' . strtoupper($locale);
+ if ( !defined($label) )
{
- if (strpos($language, ';') === FALSE)
- {
- break;
+ echo $locale;
}
else
{
- $language = preg_replace('#([^;]+).*#', '$1', $language);
- break;
+ echo constant($label);
}
+ echo "</option>\n";
}
-
?>
- <div id="header">
- <div id="navigation">
- <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
- </div>
- </div>
- <div id="container">
- <p style="font-size:152%;font-weight:bold;">
- Select your locale:
- </p>
- <form method="post" action="./index.php">
-
- <div class="prt">
- <select name="locale">
- <option value="en_Latn_US">English - United States</option>
- <option value="ja_Jpan_JP">Japanese - Japan</option>
</select>
+ <p><?php echo _LOCALE_DESC1; ?></p>
+ <p><?php echo _LOCALE_DESC2; ?></p>
+ <p><?php echo _LOCALE_NEED_HELP;?></p>
<p class="sbt">
- <button type="submit" name="mode" value="simple" class="sbt_arw">START</button>
+ <button type="submit" name="action" value="locale" class="sbt_arw">START</button>
</p>
</div>
</form>
/**
* Display the form to set up a database
+ * @param bool $isPostback
*/
-function showDBSettingForm()
+function show_database_setting_form($isPostback)
{
- global $errors;
- getMySqlVersion(); // error is stored in $errors['mysql'].
+ global $param, $minimum_mysql_version;
+
+ $config_writable = canConfigFileWritable();
+ $mysql_version = getMySqlVersion();
?>
- <div id="header">
- <div id="navigation">
- <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
- <ul>
- <li><?php echo _STEP1; ?></li>
- <li class="gry"> > <?php echo _STEP2; ?></li>
- <li class="gry"> > <?php echo _STEP3; ?></li>
- <li class="rightbox">
- <a href="./?mode=details"><?php echo _MODE2; ?></a>
- </li>
- </ul>
- </div>
- </div>
<div id="container">
<p class="msg">
- <?php echo _SIMPLE_NAVI1;
- if ( !canConfigFileWritable() ) echo '<span class="err">', $errors['config'], '</span>';
- if ( $errors['mysql'] ) echo '<span class="err">', $errors['mysql'], '</span>';
- if ( is_array($errors['install']) )
- {
- foreach ( $errors['install'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ echo _SIMPLE_NAVI1;
+ if ( $config_writable != '' )
+ {
+ echo '<span class="err">', $config_writable, '</span>';
+ }
+ if ( $mysql_version == '0.0.0' )
+ {
+ echo '<span class="err">', _DBVERSION_UNKOWN, '</span>';
+ }
+ elseif ( version_compare($mysql_version, $minimum_mysql_version, '<') )
+ {
+ echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';
+ }
+?>
</p>
<form method="post" action="./index.php">
<div class="prt">
<h2><?php echo _DB_HEADER; ?></h2>
<p class="msg">
- <?php
- if ( is_array($errors['db_setting']) )
- {
- foreach ( $errors['db_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ if ( $isPostback )
+ {
+ $errors = $param->check_mysql_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
</p>
<table>
<tr>
<th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
- <td><input type="text" name="mysql_host" value="<?php echo $_SESSION['mysql_host']; ?>" /></td>
+ <td><input type="text" name="mysql_host" value="<?php echo $param->mysql_host; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _DB_FIELD2; ?></span><span class="sub"><?php echo _DB_FIELD2_DESC; ?></span></th>
- <td><input type="text" name="mysql_user" value="<?php echo $_SESSION['mysql_user']; ?>" /></td>
+ <td><input type="text" name="mysql_user" value="<?php echo $param->mysql_user; ?>" /></td>
</tr>
<tr>
- <th><span class="nam"><?php echo _DB_FIELD3; ?></span><span class="sub"><?php echo _DB_FIELD3_DESC; ?></span></th>
- <td><input type="text" name="mysql_password" value="<?php echo $_SESSION['mysql_password']; ?>" /></td>
+ <th><span class="nam"><?php echo _DB_FIELD3; ?></span></th>
+ <td><input type="text" name="mysql_password" value="<?php echo $param->mysql_password; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _DB_FIELD4; ?></span><span class="sub"><?php echo _DB_FIELD4_DESC; ?></span></th>
- <td><input type="text" name="mysql_database" value="<?php echo $_SESSION['mysql_database']; ?>" /></td>
+ <td><input type="text" name="mysql_database" value="<?php echo $param->mysql_database; ?>" /></td>
</tr>
</table>
<p class="sbt">
<button type="submit" name="mode" value="detail" class="sbt_sqr"><?php echo _MODE2; ?></button>
- <button type="submit" name="action" value="next" class="sbt_arw"><?php echo _NEXT; ?></button>
+ <button type="submit" name="action" value="mysql" class="sbt_arw"><?php echo _NEXT; ?></button>
</p>
<p class="msg">
<?php echo _DB_TEXT1; ?>
/**
* Displays a form to the blog settings
+ * @param bool $isPostback
*/
-function showBlogSettingForm()
+function show_blog_setting_form($isPostback)
{
- global $errors;
+ global $param;
?>
- <div id="header">
- <div id="navigation">
- <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
- <ul>
- <li><?php echo _STEP1; ?></li>
- <li> > <?php echo _STEP2; ?></li>
- <li class="gry"> > <?php echo _STEP3; ?></li>
- <li class="rightbox">
- <a href="./?mode=details"><?php echo _MODE2; ?></a>
- </li>
- </ul>
- </div>
- </div>
<div id="container">
<p class="msg">
<?php echo _SIMPLE_NAVI2; ?>
<div class="prt">
<h2><?php echo _BLOG_HEADER; ?></h2>
<p class="msg">
- <?php
- if ( is_array($errors['blog_setting']) )
- {
- foreach ( $errors['blog_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ if ( $isPostback )
+ {
+ $errors = $param->check_weblog_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
</p>
<table>
<tr>
<th><span class="nam"><?php echo _BLOG_FIELD1; ?></span></th>
- <td><input type="text" name="blog_name" value="<?php echo $_SESSION['blog_name'] ? $_SESSION['blog_name'] : 'My Nucleus CMS'; ?>" /></td>
+ <td><input type="text" name="blog_name" value="<?php echo $param->blog_name; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _BLOG_FIELD2; ?></span><span class="sub"><?php echo _BLOG_FIELD2_DESC; ?></span></th>
- <td><input type="text" name="blog_shortname" value="<?php echo $_SESSION['blog_shortname'] ? $_SESSION['blog_shortname'] : 'mynucleuscms'; ?>" /></td>
+ <td><input type="text" name="blog_shortname" value="<?php echo $param->blog_shortname; ?>" /></td>
</tr>
</table>
</div>
<div class="prt">
<h2><?php echo _ADMIN_HEADER; ?></h2>
<p class="msg">
- <?php
- if ( is_array($errors['user_setting']) )
- {
- foreach ( $errors['user_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ if ( $isPostback )
+ {
+ $errors = $param->check_user_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
</p>
<table>
<tr>
<th><span class="nam"><?php echo _ADMIN_FIELD1; ?></span></th>
- <td><input type="text" name="user_realname" value="<?php echo $_SESSION['user_name']; ?>" /></td>
+ <td><input type="text" name="user_realname" value="<?php echo $param->user_realname; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _ADMIN_FIELD2; ?></span><span class="sub"><?php echo _ADMIN_FIELD2_DESC; ?></span></th>
- <td><input type="text" name="user_name" value="<?php echo $_SESSION['user_realname']; ?>" /></td>
+ <td><input type="text" name="user_name" value="<?php echo $param->user_name; ?>" /></td>
</tr>
<tr>
- <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span><span class="sub"><?php echo _ADMIN_FIELD3_DESC; ?></span></th>
+ <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span></th>
<td><input type="password" name="user_password" /></td>
</tr>
<tr>
- <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span><span class="sub"><?php echo _ADMIN_FIELD4_DESC; ?></span></th>
+ <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span></th>
<td><input type="password" name="user_password2" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _ADMIN_FIELD5; ?></span></th>
- <td><input type="text" name="user_email" value="<?php echo $_SESSION['user_email']; ?>" /></td>
+ <td><input type="text" name="user_email" value="<?php echo $param->user_email; ?>" /></td>
</tr>
</table>
<p class="sbt">
- <button type="submit" name="action" value="install" class="sbt_arw"><?php echo _INSTALL; ?></button>
+ <button type="submit" name="action" value="weblog" class="sbt_arw" onclick="OnceSubmit()"><?php echo _INSTALL; ?></button>
</p>
</div>
</form>
/**
* Displays a form to the detail settings
+ * @param bool $isPostback
*/
-function showDetailSettingForm()
+function show_detail_setting_form($isPostback)
{
- global $errors;
+ global $param, $minimum_mysql_version;
+
+ $mysql_version = getMySqlVersion();
?>
- <div id="header">
- <div id="navigation">
- <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
- <ul>
- <li class="rightbox">
- <a href="./?mode=simple"><?php echo _MODE1; ?></a>
- </li>
- </ul>
- </div>
- </div>
<div id="container_detailed">
<p class="msg">
<?php echo _DETAIL_NAVI1; ?>
+<?php
+ if ( $isPostback && !$param->check_all_parameters() )
+ {
+ echo '<span class="err">', _VALID_ERROR, "</span>\n";
+ }
+?>
</p>
<ul class="msg">
<li>PHP: <?php echo phpversion(); ?></li>
- <li>MySQL: <?php echo getMySqlVersion();
- if (array_key_exists('mysql', $errors)) echo '<span class="err">', $errors['mysql'], '</span>'; ?></li>
+ <li>MySQL:
+<?php
+ echo ($mysql_version == '0.0.0') ? _DBVERSION_UNKOWN : $mysql_version;
+ if ( version_compare($mysql_version, $minimum_mysql_version, '<') )
+ {
+ echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';
+ }
+?></li>
</ul>
- <?php
- if ( is_array($errors['install']) )
- {
- echo '<p class="msg">';
- foreach ( $errors['install'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- echo '</p>';
- }
- ?>
-
<form method="post" action="">
-
+
<div class="prt">
<h2><?php echo _DETAIL_HEADER1; ?></h2>
<p class="msg">
- <?php echo _DETAIL_TEXT1;
- if ( is_array($errors['db_setting']) )
- {
- foreach ( $errors['db_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
- </p>
- <table>
- <tr>
- <th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
- <td><input type="text" name="mysql_host" value="<?php echo $_SESSION['mysql_host']; ?>" /></td>
- </tr>
- <tr>
+<?php
+ if ( $isPostback )
+ {
+ $errors = $param->check_mysql_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
+ </p>
+ <table>
+ <tr>
+ <th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
+ <td><input type="text" name="mysql_host" value="<?php echo $param->mysql_host; ?>" /></td>
+ </tr>
+ <tr>
<th><span class="nam"><?php echo _DB_FIELD2; ?></span><span class="sub"><?php echo _DB_FIELD2_DESC; ?></span></th>
- <td><input type="text" name="mysql_user" value="<?php echo $_SESSION['mysql_user']; ?>" /></td>
+ <td><input type="text" name="mysql_user" value="<?php echo $param->mysql_user; ?>" /></td>
</tr>
<tr>
- <th><span class="nam"><?php echo _DB_FIELD3; ?></span><span class="sub"><?php echo _DB_FIELD3_DESC; ?></span></th>
- <td><input type="text" name="mysql_password" value="<?php echo $_SESSION['mysql_password']; ?>" /></td>
+ <th><span class="nam"><?php echo _DB_FIELD3; ?></span></th>
+ <td><input type="text" name="mysql_password" value="<?php echo $param->mysql_password; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _DB_FIELD4; ?></span><span class="sub"><?php echo _DB_FIELD4_DESC; ?></span></th>
- <td><input type="text" name="mysql_database" value="<?php echo $_SESSION['mysql_database']; ?>" /></td>
+ <td><input type="text" name="mysql_database" value="<?php echo $param->mysql_database; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _DB_FIELD5; ?></span><span class="sub"><?php echo _DB_FIELD5_DESC; ?></span></th>
- <td><input type="text" name="mysql_tablePrefix" value="<?php echo $_SESSION['mysql_tablePrefix']; ?>" /></td>
+ <td><input type="text" name="mysql_tablePrefix" value="<?php echo $param->mysql_tablePrefix; ?>" /></td>
</tr>
</table>
-
+
<h2><?php echo _DETAIL_HEADER2; ?></h2>
<p class="msg">
- <?php echo _DETAIL_TEXT2;
- if ( is_array($errors['path_setting']) )
- {
- foreach ( $errors['path_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ if ( $isPostback )
+ {
+ $errors = $param->check_uri_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ $errors = $param->check_path_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
</p>
<table>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD1; ?></span></th>
- <td><input type="text" name="IndexURL" value="<?php echo $_SESSION['IndexURL']; ?>" /></td>
+ <td><input type="text" name="IndexURL" value="<?php echo $param->IndexURL; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD2; ?></span></th>
- <td><input type="text" name="AdminURL" value="<?php echo $_SESSION['AdminURL']; ?>" /></td>
+ <td><input type="text" name="AdminURL" value="<?php echo $param->AdminURL; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD3; ?></span></th>
- <td><input type="text" name="AdminPath" value="<?php echo $_SESSION['AdminPath']; ?>" /></td>
+ <td><input type="text" name="AdminPath" value="<?php echo $param->AdminPath; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD4; ?></span></th>
- <td><input type="text" name="MediaURL" value="<?php echo $_SESSION['MediaURL']; ?>" /></td>
+ <td><input type="text" name="MediaURL" value="<?php echo $param->MediaURL; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD5; ?></span></th>
- <td><input type="text" name="MediaPath" value="<?php echo $_SESSION['MediaPath']; ?>" /></td>
+ <td><input type="text" name="MediaPath" value="<?php echo $param->MediaPath; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD6; ?></span></th>
- <td><input type="text" name="SkinsURL" value="<?php echo $_SESSION['SkinsURL']; ?>" /></td>
+ <td><input type="text" name="SkinsURL" value="<?php echo $param->SkinsURL; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD7; ?></span></th>
- <td><input type="text" name="SkinsPath" value="<?php echo $_SESSION['SkinsPath']; ?>" /></td>
+ <td><input type="text" name="SkinsPath" value="<?php echo $param->SkinsPath; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD8; ?></span></th>
- <td><input type="text" name="PluginURL" value="<?php echo $_SESSION['PluginURL']; ?>" /></td>
+ <td><input type="text" name="PluginURL" value="<?php echo $param->PluginURL; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _PATH_FIELD9; ?></span></th>
- <td><input type="text" name="ActionURL" value="<?php echo $_SESSION['ActionURL']; ?>" /></td>
+ <td><input type="text" name="ActionURL" value="<?php echo $param->ActionURL; ?>" /></td>
</tr>
</table>
<p class="msg">
<?php echo _DETAIL_TEXT3; ?>
</p>
-
+
<h2><?php echo _DETAIL_HEADER3; ?></h2>
<p class="msg">
- <?php echo _DETAIL_TEXT4;
- if ( is_array($errors['user_setting']) )
- {
- foreach ( $errors['user_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ echo _DETAIL_TEXT4;
+ if ( $isPostback )
+ {
+ $errors = $param->check_user_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
</p>
<table>
<tr>
<th><span class="nam"><?php echo _ADMIN_FIELD1; ?></span></th>
- <td><input type="text" name="user_realname" value="<?php echo $_SESSION['user_realname']; ?>" /></td>
+ <td><input type="text" name="user_realname" value="<?php echo $param->user_realname; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _ADMIN_FIELD2; ?></span><span class="sub"><?php echo _ADMIN_FIELD2_DESC; ?></span></th>
- <td><input type="text" name="user_name" value="<?php echo $_SESSION['user_name']; ?>" /></td>
+ <td><input type="text" name="user_name" value="<?php echo $param->user_name; ?>" /></td>
</tr>
<tr>
- <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span><span class="sub"><?php echo _ADMIN_FIELD3_DESC; ?></span></th>
+ <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span></th>
<td><input type="password" name="user_password" /></td>
</tr>
<tr>
- <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span><span class="sub"><?php echo _ADMIN_FIELD4_DESC; ?></span></th>
+ <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span></th>
<td><input type="password" name="user_password2" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _ADMIN_FIELD5; ?></span></th>
- <td><input type="text" name="user_email" value="<?php echo $_SESSION['user_email']; ?>" /></td>
+ <td><input type="text" name="user_email" value="<?php echo $param->user_email; ?>" /></td>
</tr>
</table>
-
+
<h2><?php echo _DETAIL_HEADER4; ?></h2>
<p class="msg">
- <?php echo _DETAIL_TEXT5;
- if ( is_array($errors['blog_setting']) )
- {
- foreach ( $errors['blog_setting'] as $error )
- {
- echo '<span class="err">', $error, "</span>\n";
- }
- }
- ?>
+<?php
+ echo _DETAIL_TEXT5;
+ if ( $isPostback )
+ {
+ $errors = $param->check_weblog_parameters();
+ if ( is_array($errors) )
+ {
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ }
+?>
</p>
<table>
<tr>
<th><span class="nam"><?php echo _BLOG_FIELD1; ?></span></th>
- <td><input type="text" name="blog_name" value="<?php echo $_SESSION['blog_name']; ?>" /></td>
+ <td><input type="text" name="blog_name" value="<?php echo $param->blog_name; ?>" /></td>
</tr>
<tr>
<th><span class="nam"><?php echo _BLOG_FIELD2; ?></span><span class="sub"><?php echo _BLOG_FIELD2_DESC; ?></span></th>
- <td><input type="text" name="blog_shortname" value="<?php echo $_SESSION['blog_shortname']; ?>" /></td>
+ <td><input type="text" name="blog_shortname" value="<?php echo $param->blog_shortname; ?>" /></td>
</tr>
</table>
-
+
<p class="msg">
<?php echo _DETAIL_TEXT6; ?>
</p>
-
+
<p class="sbt">
- <button type="submit" name="action" value="install" class="sbt_arw"><?php echo _INSTALL; ?></button>
+ <button type="submit" name="action" value="detail" class="sbt_arw" onclick="OnceSubmit()"><?php echo _INSTALL; ?></button>
</p>
</div>
-
</form>
-
</div>
<?php
}
/**
* Displays a screen to signal the completion of the installation
*/
-function showInstallCompleteForm()
+function show_install_complete_form()
{
- global $errors;
+ global $MYSQL_HANDLER, $param;
+ $errors = do_install();
?>
- <div id="header">
- <div id="navigation">
- <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
- <ul>
- <li><?php echo _STEP1; ?></li>
- <li> > <?php echo _STEP2; ?></li>
- <li> > <?php echo _STEP3; ?></li>
- </ul>
- </div>
- </div>
<div id="container">
<p class="msg">
- <?php echo _INST_TEXT;
- if ( $errors['config_data'] )
- {
- echo '<span class="err">', _INST_TEXT4, '</span>';
- ?><pre><code><?php
-// mySQL connection information
-$MYSQL_HOST = '<b><?php echo $_SESSION['mysql_host']; ?></b>';
-$MYSQL_USER = '<b><?php echo $_SESSION['mysql_user']; ?></b>';
-$MYSQL_PASSWORD = '<i><b><?php echo $_SESSION['mysql_password']; ?></b></i>';
-$MYSQL_DATABASE = '<b><?php echo $_SESSION['mysql_database']; ?></b>';
-$MYSQL_PREFIX = '<b><?php echo $_SESSION['mysql_tablePrefix']; ?></b>';
-
-// new in 3.50. first element is db handler, the second is the db driver used by the handler
-// default is $MYSQL_HANDLER = array('mysql','mysql');
-//$MYSQL_HANDLER = array('mysql','mysql');
-//$MYSQL_HANDLER = array('pdo','mysql');
-$MYSQL_HANDLER = array('mysql','');
-
-// main nucleus directory
-$DIR_NUCLEUS = '<b><?php echo $_SESSION['AdminPath']; ?></b>';
-
-// path to media dir
-$DIR_MEDIA = '<b><?php echo $_SESSION['MediaPath']; ?></b>';
-
-// extra skin files for imported skins
-$DIR_SKINS = '<b><?php echo $_SESSION['SkinsPath']; ?></b>';
-
-// these dirs are normally sub dirs of the nucleus dir, but
-// you can redefine them if you wish
-$DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
-$DIR_LOCALES = $DIR_NUCLEUS . 'locales/';
-$DIR_LIBS = $DIR_NUCLEUS . 'libs/';
-
-// include libs
-include($DIR_LIBS.'globalfunctions.php');
-?></code></pre>
- <?php
- }
- else
- {
- echo '<span class="err">', _INST_TEXT5, '</span>';
- }
- ?>
+<?php
+ if ( is_array($errors) && count($errors) > 0 )
+ {
+ echo _INST_ERROR;
+ foreach ( $errors as $error )
+ {
+ echo '<span class="err">', $error, "</span>\n";
+ }
+ }
+ else
+ {
+ echo _INST_TEXT;
+ if ( array_key_exists('config_data', $_SESSION) )
+ {
+ echo '<span class="err">', _INST_TEXT4, '</span>';
+?>
+<textarea id="config_text" readonly="readonly" onfocus="SelectText(this);"><?php echo htmlentities($_SESSION['config_data'], null, i18n::get_current_charset()) ?></textarea>
+<?php
+ }
+ else
+ {
+ echo '<span class="err">', _INST_TEXT5, '</span>';
+ }
+?>
</p>
<form method="post" action="./index.php">
<div class="prt">
<h2><?php echo _INST_HEADER1; ?></h2>
<p class="msg">
- <?php echo sprintf(_INST_TEXT1, $_SESSION['blog_name']); ?>
+ <?php echo sprintf(_INST_TEXT1, $param->blog_name); ?>
</p>
<p class="sbt">
- <button type="button" name="toBlog" onclick="location.href='<?php echo $_SESSION['IndexURL']; ?>';" class="sbt_arw"><?php echo _INST_BUTTON1; ?></button>
+ <button type="button" name="toBlog" onclick="location.href='<?php echo $param->IndexURL; ?>';" class="sbt_arw"><?php echo _INST_BUTTON1; ?></button>
</p>
</div>
<?php echo _INST_TEXT2; ?>
</p>
<p class="sbt">
- <button type="button" name="toMng" onclick="location.href='<?php echo $_SESSION['AdminURL']; ?>';" class="sbt_arw"><?php echo _INST_BUTTON2; ?></button>
+ <button type="button" name="toMng" onclick="location.href='<?php echo $param->AdminURL; ?>';" class="sbt_arw"><?php echo _INST_BUTTON2; ?></button>
</p>
</div>
<?php echo _INST_TEXT3; ?>
</p>
<p class="sbt">
- <button type="button" name="toAddBlog" onclick="location.href='<?php echo $_SESSION['AdminURL']; ?>index.php?action=createnewlog';" class="sbt_arw"><?php echo _INST_BUTTON3; ?></button>
+ <button type="button" name="toAddBlog" onclick="location.href='<?php echo $param->AdminURL; ?>index.php?action=createnewlog';" class="sbt_arw"><?php echo _INST_BUTTON3; ?></button>
</p>
</div>
</form>
- </div>
<?php
-}
-
-/**
- *
- */
-function doValidate()
-{
- global $errors;
- $errors = array();
-
- // 0. put all POST-vars into sessions
- if (postVar('mysql_host')) $_SESSION['mysql_host'] = postVar('mysql_host');
- if (postVar('mysql_user')) $_SESSION['mysql_user'] = postVar('mysql_user');
- if (postVar('mysql_password')) $_SESSION['mysql_password'] = postVar('mysql_password');
- if (postVar('mysql_database')) $_SESSION['mysql_database'] = postVar('mysql_database');
- if (postVar('mysql_tablePrefix')) $_SESSION['mysql_tablePrefix'] = postVar('mysql_tablePrefix');
-
- if (postVar('blog_name')) $_SESSION['blog_name'] = postVar('blog_name');
- if (postVar('blog_shortname')) $_SESSION['blog_shortname'] = postVar('blog_shortname');
-
- if (postVar('user_name'))
- {
- $_SESSION['user_name'] = postVar('user_name');
- $_SESSION['user_password'] = postVar('user_password');
- $_SESSION['user_password2'] = postVar('user_password2');
- }
- if (postVar('user_realname')) $_SESSION['user_realname'] = postVar('user_realname');
- if (postVar('user_email')) $_SESSION['user_email'] = postVar('user_email');
-
- if (postVar('IndexURL')) $_SESSION['IndexURL'] = postVar('IndexURL');
- if (postVar('AdminURL')) $_SESSION['AdminURL'] = postVar('AdminURL');
- if (postVar('AdminPath')) $_SESSION['AdminPath'] = postVar('AdminPath');
- if (postVar('MediaURL')) $_SESSION['MediaURL'] = postVar('MediaURL');
- if (postVar('SkinsURL')) $_SESSION['SkinsURL'] = postVar('SkinsURL');
- if (postVar('PluginURL')) $_SESSION['PluginURL'] = postVar('PluginURL');
- if (postVar('ActionURL')) $_SESSION['ActionURL'] = postVar('ActionURL');
- if (postVar('MediaPath')) $_SESSION['MediaPath'] = postVar('MediaPath');
- if (postVar('SkinsPath')) $_SESSION['SkinsPath'] = postVar('SkinsPath');
-
- // TODO: I do not know why this is necessary
- $_SESSION['IndexURL'] = replace_double_backslash($_SESSION['IndexURL']);
- $_SESSION['AdminURL'] = replace_double_backslash($_SESSION['AdminURL']);
- $_SESSION['AdminPath'] = replace_double_backslash($_SESSION['AdminPath']);
- $_SESSION['MediaURL'] = replace_double_backslash($_SESSION['MediaURL']);
- $_SESSION['SkinsURL'] = replace_double_backslash($_SESSION['SkinsURL']);
- $_SESSION['PluginURL'] = replace_double_backslash($_SESSION['PluginURL']);
- $_SESSION['ActionURL'] = replace_double_backslash($_SESSION['ActionURL']);
- $_SESSION['MediaPath'] = replace_double_backslash($_SESSION['MediaPath']);
- $_SESSION['SkinsPath'] = replace_double_backslash($_SESSION['SkinsPath']);
-
-
- // 1. check the database connection
- $errors['db_setting'] = array();
- if ( !$_SESSION['mysql_host'] )
- {
- $errors['db_setting'][] = sprintf(_ERROR1, _DB_FIELD1);
- }
-
- if ( !$_SESSION['mysql_user'] )
- {
- $errors['db_setting'][] = sprintf(_ERROR1, _DB_FIELD2);
- }
-
- if ( !$_SESSION['mysql_database'] )
- {
- $errors['db_setting'][] = sprintf(_ERROR1, _DB_FIELD4);
- }
-
- if ( $_SESSION['mysql_tablePrefix'] && (!preg_match('/^[a-zA-Z0-9_]+$/i', $_SESSION['mysql_tablePrefix']) ) )
- {
- $errors['db_setting'][] = sprintf(_ERROR2, _DB_FIELD5);
- }
-
- if ( count($errors['db_setting']) == 0 )
- {
- // try to log in to mySQL
- global $MYSQL_CONN;
-
- // this will need to be changed if we ever allow
- $MYSQL_CONN = @sql_connect_args($_SESSION['mysql_host'], $_SESSION['mysql_user'], $_SESSION['mysql_password']);
-
- if ( $MYSQL_CONN == FALSE )
- {
- $errors['db_setting'][] = _ERROR3;
- }
- else
- {
- sql_close($MYSQL_CONN);
- }
- }
-
- if (count($errors['db_setting']) > 0)
- {
- return false;
- }
-
- // 2. check the blog settings
- $errors['blog_setting'] = array();
- $errors['user_setting'] = array();
- if ( !$_SESSION['blog_name'] )
- {
- $errors['blog_setting'][] = sprintf(_ERROR1, _BLOG_FIELD1);
- }
-
- if ( !$_SESSION['blog_shortname'] )
- {
- $errors['blog_setting'][] = sprintf(_ERROR1, _BLOG_FIELD2);
- }
- elseif ( !_isValidShortName($_SESSION['blog_shortname']) )
- {
- $errors['blog_setting'][] = _ERROR4;
- }
-
- if ( !$_SESSION['user_name'] )
- {
- $errors['user_setting'][] = sprintf(_ERROR1, _ADMIN_FIELD2);
}
- elseif ( !_isValidDisplayName($_SESSION['user_name']) )
- {
- $errors['user_setting'][] = _ERROR5;
- }
-
- if ( !$_SESSION['user_password'] || !$_SESSION['user_password2'] )
- {
- $errors['user_setting'][] = sprintf(_ERROR1, _ADMIN_FIELD3);
- }
-
- if ( $_SESSION['user_password'] != $_SESSION['user_password2'] )
- {
- $errors['user_setting'][] = _ERROR6;
- }
-
- if ( !$_SESSION['user_email'] )
- {
- $errors['user_setting'][] = sprintf(_ERROR1, _ADMIN_FIELD5);
- }
- elseif ( !_isValidMailAddress($_SESSION['user_email']) )
- {
- $errors['user_setting'][] = _ERROR7;
- }
-
- if (count($errors['blog_setting']) > 0 || count($errors['user_setting']) > 0)
- {
- return false;
- }
-
-
- // 3. check the path/url
- $errors['path_setting'] = array();
- // TODO: add action.php check
- if ( !ends_with_slash($_SESSION['IndexURL'])
- || !ends_with_slash($_SESSION['AdminURL'])
- || !ends_with_slash($_SESSION['MediaURL'])
- || !ends_with_slash($_SESSION['SkinsURL'])
- || !ends_with_slash($_SESSION['PluginURL']) )
- {
- $errors['path_setting'][] = _ERROR8;
- }
-
- if ( !ends_with_slash($_SESSION['AdminPath']) )
- {
- $errors['path_setting'][] = sprintf(_ERROR9, _PATH_FIELD3);
- }
-
- if ( !ends_with_slash($_SESSION['MediaPath']) )
- {
- $errors['path_setting'][] = sprintf(_ERROR9, _PATH_FIELD5);
- }
-
- if ( !ends_with_slash($_SESSION['SkinsPath']) )
- {
- $errors['path_setting'][] = sprintf(_ERROR9, _PATH_FIELD7);
- }
-
- if ( !is_dir($_SESSION['AdminPath']) )
- {
- $errors['path_setting'][] = _ERROR10;
- }
-
- if (count($errors['path_setting']) > 0)
- {
- return false;
- }
-
- return true;
+?>
+ </div>
+<?php
+ unset($param);
}
/**
* The installation process itself
+ * @return array error messages
*/
-function doInstall()
+function do_install()
{
- global $errors;
- global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX, $MYSQL_CONN;
-
+ global $param;
+ global $MYSQL_HANDLER, $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX, $MYSQL_CONN;
+ global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
$errors = array();
- $errors['install'] = array();
-
- // 1. put all SESSION-vars into vars
- $MYSQL_HOST = $_SESSION['mysql_host'];
- $MYSQL_USER = $_SESSION['mysql_user'];
- $MYSQL_PASSWORD = $_SESSION['mysql_password'];
- $MYSQL_DATABASE = $_SESSION['mysql_database'];
- $MYSQL_PREFIX = $_SESSION['mysql_tablePrefix'];
-
- $blog_name = $_SESSION['blog_name'];
- $blog_shortname = $_SESSION['blog_shortname'];
-
- $user_name = $_SESSION['user_name'];
- $user_realname = $_SESSION['user_realname'];
- $user_password = $_SESSION['user_password'];
- $user_email = $_SESSION['user_email'];
-
- $config_indexurl = $_SESSION['IndexURL'];
- $config_adminurl = $_SESSION['AdminURL'];
- $config_mediaurl = $_SESSION['MediaURL'];
- $config_skinsurl = $_SESSION['SkinsURL'];
- $config_pluginurl = $_SESSION['PluginURL'];
- $config_actionurl = $_SESSION['ActionURL'];
- $config_adminpath = $_SESSION['AdminPath'];
- $config_mediapath = $_SESSION['MediaPath'];
- $config_skinspath = $_SESSION['SkinsPath'];
-
- $config_adminemail = $user_email;
- $config_sitename = $blog_name;
-
- // 2.open mySQL connection
- // this will need to be changed if we ever allow
- $MYSQL_CONN = @sql_connect_args($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
+ /*
+ * 1. put all param-vars into vars
+ */
+ $MYSQL_HOST = $param->mysql_host;
+ $MYSQL_USER = $param->mysql_user;
+ $MYSQL_PASSWORD = $param->mysql_password;
+ $MYSQL_DATABASE = $param->mysql_database;
+ $MYSQL_PREFIX = $param->mysql_tablePrefix;
+
+ $DIR_NUCLEUS = $param->AdminPath;
+ $DIR_MEDIA = $param->MediaPath;
+ $DIR_SKINS = $param->SkinsPath;
+ $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
+ $DIR_LOCALES = $DIR_NUCLEUS . 'locales/';
+ $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
+ /*
+ * 2.open mySQL connection
+ */
+ $MYSQL_CONN = @DB::setConnectionInfo($MYSQL_HANDLER[1], $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
if ( $MYSQL_CONN == FALSE )
{
- $errors['install'][] = _ERROR3;
- return false;
- }
-
- // 3. try to create database
- if ( !sql_query('CREATE DATABASE IF NOT EXISTS ' . $MYSQL_DATABASE) )
- {
- $errors['install'][] = _ERROR11 . ': ' . sql_error();
+ $errors[] = _DBCONNECT_ERROR;
+ return $errors;
}
- // 4. try to select database
- if ( !sql_select_db($MYSQL_DATABASE) )
+ /*
+ * 3. try to create database if needed
+ */
+ if ( DB::execute("CREATE DATABASE IF NOT EXISTS {$MYSQL_DATABASE}") === FALSE )
{
- $errors['install'][] = _ERROR12;
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR1 . ': ' . $errinfo[2];
}
- sql_set_charset('utf8');
- // 4a. drop table that have already been created
- $result = sql_query('SHOW TABLES');
- while ($row = mysql_fetch_array($result, MYSQL_NUM))
+ /*
+ * 4. try to select database
+ */
+ $MYSQL_CONN = @DB::setConnectionInfo($MYSQL_HANDLER[1], $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE);
+ if ( !$MYSQL_CONN )
{
- if ( !sql_query('DROP TABLE ' . $row[0]) )
- {
- $errors['install'][] = _ERROR13 . ': ' . sql_error();
- }
+ $errors[] = _INST_ERROR2;
}
- if ( count($errors['install']) > 0 )
+ if ( count($errors) > 0 )
{
- return false;
+ return $errors;
}
- // 5. execute queries
- $filename = 'install.sql';
- $fd = fopen($filename, 'r');
- $queries = fread($fd, filesize($filename) );
- fclose($fd);
-
- $queries = preg_split('#(;\n|;\r)#', $queries);
-
- $aTableNames = array(
+ /*
+ * 5. execute queries
+ */
+ $table_names = array(
'nucleus_actionlog',
'nucleus_ban',
'nucleus_blog',
'nucleus_tickets'
);
- // these are unneeded (one of the replacements above takes care of them)
- // 'nucleus_plugin_event',
- // 'nucleus_plugin_option',
- // 'nucleus_plugin_option_desc',
- // 'nucleus_skin_desc',
- // 'nucleus_template_desc',
-
- $aTableNamesPrefixed = array(
- $MYSQL_PREFIX . 'nucleus_actionlog',
- $MYSQL_PREFIX . 'nucleus_ban',
- $MYSQL_PREFIX . 'nucleus_blog',
- $MYSQL_PREFIX . 'nucleus_category',
- $MYSQL_PREFIX . 'nucleus_comment',
- $MYSQL_PREFIX . 'nucleus_config',
- $MYSQL_PREFIX . 'nucleus_item',
- $MYSQL_PREFIX . 'nucleus_karma',
- $MYSQL_PREFIX . 'nucleus_member',
- $MYSQL_PREFIX . 'nucleus_plugin',
- $MYSQL_PREFIX . 'nucleus_skin',
- $MYSQL_PREFIX . 'nucleus_template',
- $MYSQL_PREFIX . 'nucleus_team',
- $MYSQL_PREFIX . 'nucleus_activation',
- $MYSQL_PREFIX . 'nucleus_tickets'
- );
+ $prefixed_table_names = array();
+ foreach ( $table_names as $table_name )
+ {
+ $prefixed_table_names[] = $MYSQL_PREFIX . $table_name;
+ }
- // these are unneeded (one of the replacements above takes care of them)
- // $MYSQL_PREFIX . 'nucleus_plugin_event',
- // $MYSQL_PREFIX . 'nucleus_plugin_option',
- // $MYSQL_PREFIX . 'nucleus_plugin_option_desc',
- // $MYSQL_PREFIX . 'nucleus_skin_desc',
- // $MYSQL_PREFIX . 'nucleus_template_desc',
+ // table exists check
+ $result = DB::getResult('SHOW TABLES');
+ foreach ( $result as $row )
+ {
+ if ( in_array($row[0], $prefixed_table_names) )
+ {
+ $errors[] = _INST_ERROR3;
+ break;
+ }
+ }
+ if ( count($errors) > 0 )
+ {
+ return $errors;
+ }
+
+ $filename = 'install.sql';
+ $fd = fopen($filename, 'r');
+ $queries = fread($fd, filesize($filename));
+ fclose($fd);
- $count = count($queries);
+ $queries = preg_split('#(;\n|;\r)#', $queries);
- for ( $idx = 0; $idx < $count; $idx++ )
+ foreach ( $queries as $query )
{
- $query = trim($queries[$idx]);
- // echo "QUERY = <small>" . _hsc($query) . "</small><p>";
-
- if ( $query )
+ if ( preg_match('/\w+/', $query) )
{
-
if ( $MYSQL_PREFIX )
{
- $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
- } // end if
+ $query = str_replace($table_names, $prefixed_table_names, $query);
+ }
- if ( !sql_query($query) )
+ if ( DB::execute($query) === FALSE )
{
- $errors['install'][] = _ERROR13 . ' (<small>' . _hsc($query) . '</small>): ' . sql_error();
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR4 . ' (<small>' . $query . '</small>): ' . $errinfo[2];
}
-
- } // end if
-
- } // end loop
-
- // 5a. make first post
- $newpost = "INSERT INTO ". tableName('nucleus_item')
- . " VALUES (1, '" . _1ST_POST_TITLE . "', '" . _1ST_POST . "', '" . _1ST_POST2 . "', 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1)";
- if ( !sql_query($newpost) )
- {
- $errors['install'][] = _ERROR13 . ' (<small>' . _hsc($newpost) . '</small>): ' . sql_error();
+ }
}
- // 6. update global settings
- updateConfig('IndexURL', $config_indexurl);
- updateConfig('AdminURL', $config_adminurl);
- updateConfig('MediaURL', $config_mediaurl);
- updateConfig('SkinsURL', $config_skinsurl);
- updateConfig('PluginURL', $config_pluginurl);
- updateConfig('ActionURL', $config_actionurl);
- updateConfig('AdminEmail', $config_adminemail);
- updateConfig('SiteName', $config_sitename);
- updateConfig('Locale', i18n::get_current_locale());
-
- // 7. update GOD member
- $query = 'UPDATE ' . tableName('nucleus_member')
- . " SET mname = '" . sql_real_escape_string($user_name) . "',"
- . " mrealname = '" . sql_real_escape_string($user_realname) . "',"
- . " mpassword = '" . md5(sql_real_escape_string($user_password) ) . "',"
- . " murl = '" . sql_real_escape_string($config_indexurl) . "',"
- . " memail = '" . sql_real_escape_string($user_email) . "',"
- . " madmin = 1, mcanlogin = 1"
- . " WHERE mnumber = 1";
-
- if ( !sql_query($query) )
+ /*
+ * 6. put needed records
+ */
+ /* push first post */
+ $query = "INSERT INTO %s VALUES (1, %s, %s, %s, 1, 1, %s, 0, 0, 0, 1, 0, 1)";
+ $query = sprintf($query,
+ tableName('nucleus_item'),
+ DB::quoteValue(_1ST_POST_TITLE),
+ DB::quoteValue(_1ST_POST),
+ DB::quoteValue(_1ST_POST2),
+ DB::formatDateTime()
+ );
+ if ( DB::execute($query) === FALSE )
{
- $errors['install'][] = _ERROR14 . ': ' . sql_error();
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR4 . ' (<small>' . $query . '</small>): ' . $errinfo[2];
}
- // 8. update weblog settings
- $query = 'UPDATE ' . tableName('nucleus_blog')
- . " SET bname = '" . sql_real_escape_string($blog_name) . "',"
- . " bshortname = '" . sql_real_escape_string($blog_shortname) . "',"
- . " burl = '" . sql_real_escape_string($config_indexurl) . "'"
- . " WHERE bnumber = 1";
-
- if ( !sql_query($query) )
+ /* push configurations */
+ array_merge($errors, updateConfig('IndexURL', $param->IndexURL));
+ array_merge($errors, updateConfig('AdminURL', $param->AdminURL));
+ array_merge($errors, updateConfig('MediaURL', $param->MediaURL));
+ array_merge($errors, updateConfig('SkinsURL', $param->SkinsURL));
+ array_merge($errors, updateConfig('PluginURL', $param->PluginURL));
+ array_merge($errors, updateConfig('ActionURL', $param->ActionURL));
+ array_merge($errors, updateConfig('AdminEmail', $param->user_email));
+ array_merge($errors, updateConfig('SiteName', $param->blog_name));
+ array_merge($errors, updateConfig('Locale', i18n::get_current_locale()));
+
+ /* push super admin */
+ $query = "UPDATE %s SET mname = %s, mrealname = %s, mpassword = %s, memail = %s, murl = %s, madmin = 1, mcanlogin = 1 WHERE mnumber = 1";
+ $query = sprintf($query,
+ tableName('nucleus_member'),
+ DB::quoteValue($param->user_name),
+ DB::quoteValue($param->user_realname),
+ DB::quoteValue(md5($param->user_password)),
+ DB::quoteValue($param->user_email),
+ DB::quoteValue($param->IndexURL)
+ );
+ if ( DB::execute($query) === FALSE )
{
- $errors['install'][] = _ERROR15 . ': ' . sql_error();
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR5 . ': ' . $errinfo[2];
}
- // 8-2. update category settings
- $query = 'UPDATE ' . tableName('nucleus_category')
- . " SET cname = '" . _GENERALCAT_NAME . "',"
- . " cdesc = '" . _GENERALCAT_DESC . "'"
- . " WHERE catid = 1";
-
- if ( !sql_query($query) )
+ /* push new weblog */
+ $query = "UPDATE %s SET bname = %s, bshortname = %s, burl = %s WHERE bnumber = 1";
+ $query = sprintf($query,
+ tableName('nucleus_blog'),
+ DB::quoteValue($param->blog_name),
+ DB::quoteValue($param->blog_shortname),
+ DB::quoteValue($param->IndexURL)
+ );
+ if ( DB::execute($query) === FALSE )
{
- $errors['install'][] = _ERROR15 . ': ' . sql_error();
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR6 . ': ' . $errinfo[2];
}
- // 9. update item date
- $query = 'UPDATE ' . tableName('nucleus_item')
- . " SET itime = '" . date('Y-m-d H:i:s', time() ) ."'"
- . " WHERE inumber = 1";
-
- if ( !sql_query($query) )
+ /* push default category */
+ $query = "UPDATE %s SET cname = %s, cdesc = %s WHERE catid = 1";
+ $query = sprintf($query,
+ tableName('nucleus_category'),
+ DB::quoteValue(_GENERALCAT_NAME),
+ DB::quoteValue(_GENERALCAT_DESC)
+ );
+ if ( DB::execute($query) === FALSE )
{
- $errors['install'][] = _ERROR16 . ': ' . sql_error();
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR6 . ': ' . $errinfo[2];
}
- sql_close();
-
+ /*
+ * 7. install default plugins and skins
+ */
global $aConfPlugsToInstall, $aConfSkinsToImport;
$aSkinErrors = array();
$aPlugErrors = array();
if ( (count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) )
{
- // 10. set global variables
- global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LOCALES, $DIR_LIBS;
- $DIR_NUCLEUS = $config_adminpath;
- $DIR_MEDIA = $config_mediapath;
- $DIR_SKINS = $config_skinspath;
- $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
- $DIR_LOCALES = $DIR_NUCLEUS . 'locales/';
- $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
-
- // Are utilized in the installCustomPlugs and installCustomSkins functions.
include_once($DIR_LIBS . 'globalfunctions.php');
global $manager;
if ( !isset($manager) )
{
- $manager = new MANAGER;
+ $manager = new Manager();
}
- // 11. install custom skins
+ include_once($DIR_LIBS . 'skinie.php');
+
$aSkinErrors = installCustomSkins();
if ( count($aSkinErrors) > 0 )
{
- array_push($errors['install'], $aSkinErrors);
+ array_merge($errors, $aSkinErrors);
}
- $defskinQue = 'SELECT sdnumber FROM ' . tableName('nucleus_skin_desc') . " WHERE sdname='default'";
- $res = sql_query($defskinQue);
- $obj = sql_fetch_assoc($res);
- $defSkinID = $obj['sdnumber'];
- $updateQuery = 'UPDATE ' . tableName('nucleus_blog') . ' SET bdefskin=' . intval($defSkinID) . ' WHERE bnumber=1';
- sql_query($updateQuery);
- $updateQuery = 'UPDATE ' . tableName('nucleus_config') . ' SET value=' . intval($defSkinID). " WHERE name='BaseSkin'";
- sql_query($updateQuery);
- // 12. install custom plugins
- $aPlugErrors = installCustomPlugs($manager);
+ $query = "SELECT sdnumber FROM %s WHERE sdname='admin/default'";
+ $query = sprintf($query, tableName('nucleus_skin_desc'));
+ $res = intval(DB::getValue($query));
+ array_merge($errors, updateConfig('AdminSkin', $res));
+
+ $query = "SELECT sdnumber FROM %s WHERE sdname='admin/bookmarklet'";
+ $query = sprintf($query, tableName('nucleus_skin_desc'));
+ $res = intval(DB::getValue($query));
+ array_merge($errors, updateConfig('BookmarkletSkin', $res));
+
+ $query = "SELECT sdnumber FROM %s WHERE sdname='default'";
+ $query = sprintf($query, tableName('nucleus_skin_desc'));
+ $defSkinID = intval(DB::getValue($query));
+
+ $query = "UPDATE %s SET bdefskin=%d WHERE bnumber=1";
+ $query = sprintf($query, tableName('nucleus_blog'), $defSkinID);
+ DB::execute($query);
+ $query = "UPDATE %s SET value=%d WHERE name='BaseSkin'";
+ $query = sprintf($query, tableName('nucleus_config'), $defSkinID);
+ DB::execute($query);
+
+ $aPlugErrors = installCustomPlugs();
if ( count($aPlugErrors) > 0 )
{
- array_push($errors['install'], $aPlugErrors);
+ array_merge($errors, $aPlugErrors);
}
}
- // 13. Write config file ourselves (if possible)
- $config_data = '<' . '?php' . "\n\n";
+ /*
+ * 8. Write config file ourselves (if possible)
+ */
+ $config_data = '<' . '?php' . "\n";
$config_data .= "// mySQL connection information\n";
$config_data .= "\$MYSQL_HOST = '" . $MYSQL_HOST . "';\n";
$config_data .= "\$MYSQL_USER = '" . $MYSQL_USER . "';\n";
$config_data .= "// default is \$MYSQL_HANDLER = array('mysql','mysql');\n";
$config_data .= "//\$MYSQL_HANDLER = array('mysql','mysql');\n";
$config_data .= "//\$MYSQL_HANDLER = array('pdo','mysql');\n";
- $config_data .= "\$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";
+ $config_data .= "\$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n";
$config_data .= "\n";
$config_data .= "// main nucleus directory\n";
- $config_data .= "\$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
+ $config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n";
$config_data .= "\n";
$config_data .= "// path to media dir\n";
- $config_data .= "\$DIR_MEDIA = '" . $config_mediapath . "';\n";
+ $config_data .= "\$DIR_MEDIA = '" . $DIR_MEDIA . "';\n";
$config_data .= "\n";
$config_data .= "// extra skin files for imported skins\n";
- $config_data .= "\$DIR_SKINS = '" . $config_skinspath . "';\n";
+ $config_data .= "\$DIR_SKINS = '" . $DIR_SKINS . "';\n";
$config_data .= "\n";
$config_data .= "// these dirs are normally sub dirs of the nucleus dir, but \n";
$config_data .= "// you can redefine them if you wish\n";
$config_data .= "include(\$DIR_LIBS.'globalfunctions.php');\n";
$config_data .= "?" . ">";
- $errors['config_data'] = $config_data;
-
- if ( @!file_exists('../config.php')
- || (@file_exists('../config.php') && is_writable('../config.php')) )
+ $result = false;
+ if ( @!file_exists('../config.php') || is_writable('../config.php') )
{
if ( $fp = @fopen('../config.php', 'w') )
{
- $result = @fwrite($fp, $config_data, i18n::strlen($config_data) );
+ $result = @fwrite($fp, $config_data, i18n::strlen($config_data));
fclose($fp);
-
- if ( $result )
- {
- unset($errors['config_data']);
- if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
- {
- @chmod('../config.php', 0444);
- }
- } // end if
}
- } // end if
+ }
- if ( count($errors['install']) > 0 )
+ if ( $result )
{
- return false;
+ // try to change the read-only permission.
+ if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
+ {
+ @chmod('../config.php', 0444);
+ }
}
- return true;
-} // end function doInstall()
+ else
+ {
+ $_SESSION['config_data'] = $config_data;
+ }
+
+ return $errors;
+}
/**
- * Verifying that you can write to the configuration file
+ * Confirm that you can write to the configuration file
+ * @return string error message
*/
function canConfigFileWritable()
{
- global $errors;
-
- // tell people how they can have their config file filled out automatically
if ( @file_exists('../config.php') && @!is_writable('../config.php') )
{
- // try to change the permissions.
- if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
+ // try to change the read-write permission.
+ if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
{
- @chmod('../config.php', 0666);
+ @chmod('../config.php', 0666);
}
if ( @!is_writable('../config.php') )
{
- $errors['config'] = _ERROR17;
- return false;
+ return _INST_ERROR8;
}
- } // end if
-
- return true;
+ }
+ return '';
}
/**
* To obtain the version of MySQL
- *
* @return string
*/
function getMySqlVersion()
{
- global $minimum_mysql_version, $errors;
+ global $MYSQL_HANDLER, $minimum_mysql_version, $errors;
// Turn on output buffer
// Needed to repress the output of the sql function that are
// not part of php (in this case the @ operator doesn't work)
ob_start();
// note: this piece of code is taken from phpMyAdmin
- $conn = sql_connect_args('localhost', '', '');
- $result = @sql_query('SELECT VERSION() AS version', $conn);
+ $conn = @DB::setConnectionInfo($MYSQL_HANDLER[1], 'localhost', '', '');
- if ( $result != FALSE && sql_num_rows($result) > 0 )
+ if ( $conn )
{
- $row = sql_fetch_array($result);
- $match = i18n::explode('.', $row['version']);
+ $row = DB::getAttribute(PDO::ATTR_SERVER_VERSION);
+ $match = preg_split('#\.#', $row);
}
else
{
- $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
+ $row = @DB::getRow('SHOW VARIABLES LIKE \'version\'');
- if ( $result != FALSE && @sql_num_rows($result) > 0 )
+ if ( $row )
{
- $row = sql_fetch_row($result);
- $match = i18n::explode('.', $row[1]);
+ $match = preg_split('#\.#', $row[1]);
}
else
{
- //$output = shell_exec('mysql -V');
- $output = ( function_exists('shell_exec') ) ? @shell_exec('mysql -V') : '0.0.0';
+ $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
- $match = i18n::explode('.', $version[0]);
+ $match = preg_split('#\.#', $version[0]);
if ( $match[0] == '' )
{
$match = array('0', '0', '0');
- } // end if
-
- } // end if
-
- } // end if
+ }
+ }
+ }
- @sql_disconnect($conn);
+ @DB::disConnect();
//End and clean output buffer
ob_end_clean();
- $mysqlVersion = implode($match, '.');
-
- if ( $mysqlVersion < $minimum_mysql_version )
- {
- $errors['mysql'] = sprintf(_ERROR18 , $minimum_mysql_version);
- }
-
- if ( $mysqlVersion == '0.0.0' )
- {
- return _ERROR19;
- }
- else
- {
- return $mysqlVersion;
- }
-}
-
-
-/**
- * To obtain information of the directory and path where you want to install the Nucleus.
- */
-function getURLAndPath()
-{
- // no need to this all! dirname(__FILE__) is all we need -- moraes
- /*
- // discover full path
- $fullPath = serverVar('PATH_TRANSLATED');
-
- if ($fullPath == '') {
- $fullPath = serverVar('SCRIPT_FILENAME');
- }
-
- $base_path = str_replace('./index.php', '', $fullPath);
- $base_path = replace_double_backslash($base_path);
- $base_path = replace_double_backslash($base_path);
-
- // add slash at end if necessary
- if (!ends_with_slash($base_path) ) {
- $base_path .= '/';
- }
- */
-
- /**
- * In the code below, there used to be if conditions within the form's HTML that conditionally echoed the URLs.
- *
- * For example:
- * if ($base_path) . . .
- * Or:
- * if ($url) . . .
- *
- * I removed this and simplified below, because PHP's type casting will make these always evaluate to TRUE.
- * At least currently, $base_path will always be non-empty, since the trailing slash is appended to it.
- * Similarly, $index_url will always be non-empty, since the 'http://' is prepended to it.
- * Non-empty, non-zero strings evaluated in if conditions are always cast to boolean TRUE.
- * The if conditions were accomplishing nothing (currently) and we should avoid using such comparisons, anyway.
- * If we need to check for a blank/empty string, use empty().
- *
- * I was initially replacing those if conditions with ternary operators for empty(), but then I realized
- * they will never be empty.
- *
- * In addition, I decided to remove the PHP logic from within the form and set up separate variables (they were
- * all just $url before), so the form just echos the values as needed.
- * - gregorlove 7/13/2011 5:56 PM
- */
-
- /* base path */
- $this_dir = implode('/', i18n::explode(DIRECTORY_SEPARATOR, dirname(__FILE__)));
- $base_path = realpath($this_dir . '/..');
- $pwd = preg_replace("#$base_path/#", '', $this_dir);
-
- # Index URL
- $index_url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
- $index_url = preg_replace("#$pwd/index.php#", '', $index_url);
- $index_url = replace_double_backslash($index_url);
-
- // add slash at end if necessary
- if ( !ends_with_slash($base_path) )
- {
- $base_path .= '/';
- }
- if ( !ends_with_slash($index_url) )
- {
- $index_url .= '/';
- }
-
- # Admin URL and path
- $admin_url = $index_url . 'nucleus/';
- $admin_path = $base_path . 'nucleus/';
-
- # Media URL and path
- $media_url = $index_url . 'media/';
- $media_path = $base_path . 'media/';
-
- # Skins URL and path
- $skins_url = $index_url . 'skins/';
- $skins_path = $base_path . 'skins/';
-
- # Plugins URL
- $plugins_url = $admin_url . 'plugins/';
-
- # Action URL
- $action_url = $index_url . 'action.php';
-
- $_SESSION['IndexURL'] = $index_url;
- $_SESSION['AdminURL'] = $admin_url;
- $_SESSION['AdminPath'] = $admin_path;
- $_SESSION['MediaURL'] = $media_url;
- $_SESSION['MediaPath'] = $media_path;
- $_SESSION['SkinsURL'] = $skins_url;
- $_SESSION['SkinsPath'] = $skins_path;
- $_SESSION['PluginURL'] = $plugins_url;
- $_SESSION['ActionURL'] = $action_url;
-
+ return implode($match, '.');
}
/**
*/
function tableName($input)
{
- if ( $_SESSION['mysql_tablePrefix'] )
+ global $MYSQL_PREFIX;
+ if ( $MYSQL_PREFIX )
{
- return $_SESSION['mysql_tablePrefix'] . $input;
+ return $MYSQL_PREFIX . $input;
}
else
{
return $input;
- } // end if
-
+ }
}
-
-
/**
* Install custom plugins
- *
- * @param object $manager MANAGER class instance
*/
-function installCustomPlugs($manager)
+function installCustomPlugs()
{
- global $aConfPlugsToInstall, $DIR_LIBS;
+ global $aConfPlugsToInstall, $DIR_LIBS, $manager;
$aErrors = array();
-
if ( count($aConfPlugsToInstall) == 0 )
{
return $aErrors;
}
- $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin') );
- $numCurrent = sql_num_rows($res);
+ $query = sprintf('SELECT * FROM %s', tableName('nucleus_plugin'));
+ $res = DB::getResult($query);
+ $numCurrent = $res->rowCount();
foreach ( $aConfPlugsToInstall as $plugName )
{
- // do this before calling getPlugin (in case the plugin id is used there)
- $query = 'INSERT INTO ' . tableName('nucleus_plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ", '" . sql_real_escape_string($plugName) . "')";
- sql_query($query);
+ $query = sprintf('INSERT INTO %s (porder, pfile) VALUES (%d, %s)',
+ tableName('nucleus_plugin'),
+ (++$numCurrent),
+ DB::quoteValue($plugName));
+ DB::execute($query);
- // get and install the plugin
$manager->clearCachedInfo('installedPlugins');
$plugin =& $manager->getPlugin($plugName);
$plugin->setID($numCurrent);
if ( !$plugin )
{
- sql_query('DELETE FROM ' . tableName('nucleus_plugin') . " WHERE pfile = '" . sql_real_escape_string($plugName) . "'");
+ $query = sprintf('DELETE FROM %s WHERE pfile = %s',
+ tableName('nucleus_plugin'),
+ DB::quoteValue($plugName));
+ DB::execute($query);
$numCurrent--;
- array_push($aErrors, sprintf(_ERROR20 ,$plugName));
+ array_push($aErrors, sprintf(_INST_ERROR9, $plugName));
continue;
- } // end if
-
+ }
$plugin->install();
- } // end loop
-
- // SYNC PLUGIN EVENT LIST
- sql_query('DELETE FROM ' . tableName('nucleus_plugin_event') );
+ }
- // loop over all installed plugins
- $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin') );
+ $query = sprintf('DELETE FROM %s', tableName('nucleus_plugin_event'));
+ DB::execute($query);
+ $query = sprintf('SELECT pid, pfile FROM %s', tableName('nucleus_plugin'));
+ $res = DB::getResult($query);
- while ( $o = sql_fetch_object($res) )
+ foreach ( $res as $row )
{
- $pid = $o->pid;
- $plug =& $manager->getPlugin($o->pfile);
+ $plug =& $manager->getPlugin($row['pfile']);
if ( $plug )
{
$eventList = $plug->getEventList();
-
foreach ( $eventList as $eventName )
{
- sql_query('INSERT INTO ' . tableName('nucleus_plugin_event') . ' (pid, event) VALUES (' . $pid . ", '" . $eventName . "')");
- } // end loop
-
- } // end if
-
- } // end loop
-
+ $query = sprintf('INSERT INTO %s (pid, event) VALUES (%d, %s)',
+ tableName('nucleus_plugin_event'),
+ intval($row['pid']),
+ DB::quoteValue($eventName));
+ DB::execute($query);
+ }
+ }
+ }
return $aErrors;
-} // end function installCustomPlugs()
-
+}
/**
* Install custom skins
global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
$aErrors = array();
-
if ( count($aConfSkinsToImport) == 0 )
{
return $aErrors;
}
- // load skinie class
- include_once($DIR_LIBS . 'skinie.php');
-
- $importer = new SKINIMPORT();
+ $importer = new SkinImport();
foreach ( $aConfSkinsToImport as $skinName )
{
if ( !@file_exists($skinFile) )
{
- array_push($aErrors, sprintf(_ERROR21, $skinFile));
+ array_push($aErrors, sprintf(_INST_ERROR10, $skinFile));
continue;
- } // end if
+ }
$error = $importer->readFile($skinFile);
if ( $error )
{
- array_push($aErrors, sprintf(_ERROR22, $skinName) . ' : ' . $error);
+ array_push($aErrors, sprintf(_INST_ERROR11, $skinName) . ' : ' . $error);
continue;
- } // end if
+ }
$error = $importer->writeToDatabase(1);
if ( $error )
{
- array_push($aErrors, sprintf(_ERROR22, $skinName) . ' : ' . $error);
+ array_push($aErrors, sprintf(_INST_ERROR12, $skinName) . ' : ' . $error);
continue;
- } // end if
-
- } // end loop
-
+ }
+ }
return $aErrors;
-} // end function installCustomSkins()
-
+}
/**
* Check if some important files of the Nucleus CMS installation are available
* Give an error if one or more files are not accessible
*/
-function doCheckFiles()
+function do_check_files()
{
$missingfiles = array();
$files = array(
'../index.php',
'../action.php',
'../nucleus/index.php',
- '../nucleus/media.php',
- '../nucleus/libs/globalfunctions.php',
+ '../nucleus/libs/ACTION.php',
+ '../nucleus/libs/ACTIONLOG.php',
+ '../nucleus/libs/ACTIONS.php',
'../nucleus/libs/ADMIN.php',
+ '../nucleus/libs/BaseActions.php',
'../nucleus/libs/BLOG.php',
+ '../nucleus/libs/BODYACTIONS.php',
'../nucleus/libs/COMMENT.php',
+ '../nucleus/libs/COMMENTACTIONS.php',
'../nucleus/libs/COMMENTS.php',
+ '../nucleus/libs/ENTITY.php',
+ '../nucleus/libs/globalfunctions.php',
+ '../nucleus/libs/i18n.php',
'../nucleus/libs/ITEM.php',
+ '../nucleus/libs/ITEMACTIONS.php',
+ '../nucleus/libs/LINK.php',
+ '../nucleus/libs/MANAGER.php',
+ '../nucleus/libs/MEDIA.php',
'../nucleus/libs/MEMBER.php',
+ '../nucleus/libs/NOTIFICATION.php',
+ '../nucleus/libs/PARSER.php',
+ '../nucleus/libs/PLUGIN.php',
+ '../nucleus/libs/PLUGINADMIN.php',
+ '../nucleus/libs/SEARCH.php',
+ '../nucleus/libs/showlist.php',
'../nucleus/libs/SKIN.php',
'../nucleus/libs/TEMPLATE.php',
- '../nucleus/libs/MEDIA.php',
- '../nucleus/libs/ACTIONLOG.php',
'../nucleus/libs/vars4.1.0.php',
- '../nucleus/libs/i18n.php',
- '../nucleus/libs/mysql.php',
- '../nucleus/libs/sql/mysql.php'
+ '../nucleus/libs/xmlrpc.inc.php',
+ '../nucleus/libs/xmlrpcs.inc.php',
+ '../nucleus/libs/sql/DB.php',
+ '../nucleus/libs/sql/MYSQLPDO.php'
);
-
- $count = count($files);
+ $count = count($files);
for ( $i = 0; $i < $count; $i++ )
{
-
if ( !is_readable($files[$i]) )
{
- array_push( $missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');
- } // end if
-
- } // end loop
+ array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');
+ }
+ }
if ( count($missingfiles) > 0 )
{
- exit(implode( "\n", $missingfiles));
- } // end if
-
-} // end function doCheckFiles()
-
+ exit(implode("\n", $missingfiles));
+ }
+}
/**
* Updates the configuration in the database
*
* @param string $name name of the config var
* @param string $value new value of the config var
- * @return int
+ * @return array
*/
function updateConfig($name, $value)
{
- global $errors;
- $name = addslashes($name);
- $value = trim(addslashes($value) );
+ $errors = array();
- $query = 'UPDATE ' . tableName('nucleus_config')
- . " SET `value` = '$value'"
- . " WHERE `name` = '$name'";
+ $query = "UPDATE %s SET value = %s WHERE name = %s";
+ $query = sprintf($query, tableName('nucleus_config'), DB::quoteValue(trim($value)), DB::quoteValue($name));
- if ( !sql_query($query) )
+ if ( DB::execute($query) === FALSE )
{
- $errors['install'][] = _ERROR13 . ': ' . sql_error();
+ $errinfo = DB::getError();
+ $errors[] = _INST_ERROR4 . ': ' . $errinfo[2];
}
- return sql_insert_id();
+ return $errors;
}
-
-/**
- * Replaces double backslashs
- *
- * @param string $input string that could have double backslashs
- * @return string
- */
-function replace_double_backslash($input)
+class ParamManager
{
- return str_replace('\\', '/', $input);
-}
+ /* process parameter */
+ public $state;
+ public $locale;
+
+ /* mysql connection parameters */
+ public $mysql_host;
+ public $mysql_user;
+ public $mysql_password;
+ public $mysql_database;
+ public $mysql_tablePrefix;
+
+ /* weblog configuration parameters */
+ public $blog_name;
+ public $blog_shortname;
+
+ /* member configuration parameters */
+ public $user_name;
+ public $user_realname;
+ public $user_password;
+ private $user_password2;
+ public $user_email;
+
+ /* URI parameters */
+ private $root_url;
+ public $IndexURL;
+ public $AdminURL;
+ public $MediaURL;
+ public $SkinsURL;
+ public $PluginURL;
+ public $ActionURL;
+
+ /* path parameters */
+ private $root_path;
+ public $AdminPath;
+ public $MediaPath;
+ public $SkinsPath;
+ /**
+ * constructor
+ */
+ public function __construct()
+ {
+ $this->init();
+ }
-/**
- * Checks if a string ends with a slash
- *
- * @param string $input
- * @return string
- */
-function ends_with_slash($input)
-{
- return ( i18n::strrpos($input, '/') == i18n::strlen($input) - 1);
-}
+ public function init()
+ {
+ // set default values
+ $this->state = 'locale';
+ $this->install_mode = 'simple';
+ $this->locale = '';
+ $this->mysql_host = @ini_get('mysql.default_host');
+ $this->blog_name = 'My Nucleus CMS';
+ $this->blog_shortname = 'mynucleuscms';
+ /* root path */
+ $directory_separator = preg_quote(DIRECTORY_SEPARATOR, '|');
+ $this->root_path = implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__) . '/..')));
+ if ( substr($this->root_path, -1, 1) !== '/' )
+ {
+ $this->root_path .= '/';
+ }
+ $base_path_pcre = preg_quote($this->root_path, '|');
+
+ /* current directry name */
+ $directory_name = preg_replace("#{$base_path_pcre}#", '', implode('/', preg_split("#{$directory_separator}#", realpath(dirname(__FILE__)))));
+ $directory_name_pcre = preg_quote($directory_name, '|');
+
+ /* root uri */
+ $root_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
+ $this->root_url = preg_replace("|$directory_name_pcre(.*)$|", '', $root_url);
+
+ $this->AdminPath = $this->root_path . 'nucleus/';
+ $this->MediaPath = $this->root_path . 'media/';
+ $this->SkinsPath = $this->root_path . 'skins/';
+
+ $this->IndexURL = $this->root_url;
+ $this->AdminURL = $this->root_url . 'nucleus/';
+ $this->MediaURL = $this->root_url . 'media/';
+ $this->SkinsURL = $this->root_url . 'skins/';
+ $this->PluginURL = $this->root_url . 'nucleus/plugins/';
+ $this->ActionURL = $this->root_url . 'action.php';
+ }
-/**
- * Checks if email address is valid
- *
- * @param string $address address which should be tested
- * @return bool
- */
-function _isValidMailAddress($address)
-{
+ private function read_parameter($parameter)
+ {
+ foreach ( $parameter as $element )
+ {
+ if ( array_key_exists($element, $_POST) )
+ {
+ $this->$element = $_POST[$element];
+ }
+ }
+ }
- if ( preg_match("/^[a-zA-Z0-9\._-]+@[A-Za-z0-9\._-]+\.[A-Za-z]{2,6}$/", $address) )
+ public function set_state($state)
{
- return TRUE;
+ $states = array('locale', 'mysql', 'weblog', 'detail', 'install');
+ if ( in_array($state, $states) )
+ {
+ $this->state = $state;
+ }
}
- else
+
+ public function set_locale()
{
- return FALSE;
- } // end if
+ $this->read_parameter(array('locale'));
-}
+ if ( !$this->locale )
+ {
+ /**
+ * default locale select simple implementation
+ *
+ * NOTE:
+ * RFC2616: Hypertext Transfer Protocol -- HTTP/1.1
+ * http://www.ietf.org/rfc/rfc2616.txt
+ *
+ * 14.4 Accept-Language
+ *
+ * The Accept-Language request-header field is similar to Accept, but
+ * restricts the set of natural languages that are preferred as a
+ * response to the request. Language tags are defined in section 3.10.
+ *
+ * Accept-Language = "Accept-Language" ":"
+ * 1#( language-range [ ";" "q" "=" qvalue ] )
+ * language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" )
+ *
+ * Each language-range MAY be given an associated quality value which
+ * represents an estimate of the user's preference for the languages
+ * specified by that range. The quality value defaults to "q=1". For
+ * example,
+ *
+ * Accept-Language: da, en-gb;q=0.8, en;q=0.7
+ *
+ * would mean: "I prefer Danish, but will accept British English and
+ * other types of English." A language-range matches a language-tag if
+ * it exactly equals the tag, or if it exactly equals a prefix of the
+ * tag such that the first tag character following the prefix is "-".
+ * The special range "*", if present in the Accept-Language field,
+ * matches every tag not matched by any other range present in the
+ * Accept-Language field.
+ *
+ * TODO: this is appropriate implement or not
+ */
+ $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
+
+ /* retrieve language token of language tag from first token */
+ $language = '';
+ if ( is_array($languages) && count($languages) > 0 )
+ {
+ $language = preg_replace('#^([\w]+).*$#', '$1', $languages[0]);
+ }
+
+ $locales = i18n::get_available_locale_list();
+ foreach ( $locales as $locale )
+ {
+ if ( i18n::strpos($locale, $language) === 0 )
+ {
+ $this->locale = $locale;
+ break;
+ }
+ }
+ }
+
+ /* include installer translation messages */
+ $translation_file = "./locales/{$this->locale}." . i18n::get_current_charset() . '.php';
+ if ( !file_exists($translation_file) )
+ {
+ $translation_file = './locales/en_Latn_US.UTF-8.php';
+ }
+ include($translation_file);
+
+ /* include global translation messages */
+ $translation_file = "../nucleus/locales/{$this->locale}." . i18n::get_current_charset() . '.php';
+ if ( !file_exists($translation_file) )
+ {
+ $translation_file = './locales/en_Latn_US.UTF-8.php';
+ }
+ include($translation_file);
+
+ i18n::set_current_locale($this->locale);
+
+ return;
+ }
+ public function check_mysql_parameters()
+ {
+ global $MYSQL_HANDLER;
+
+ $parameters = array('mysql_host', 'mysql_user', 'mysql_password', 'mysql_database', 'mysql_tablePrefix');
+ $this->read_parameter($parameters);
-/*
- * Check if short blog names and nicknames are allowed
- * Returns true if the given string is a valid shortname
- * logic: only letters and numbers are allowed, no spaces allowed
- *
- * FIX: function eregi is deprecated since PHP 5.3.0
- *
- * @param string $name name which should be tested
- * @return bool
- */
-function _isValidShortName($name)
-{
+ $errors = array();
+ if ( $this->mysql_host == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD1);
+ }
+
+ if ( $this->mysql_user == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD2);
+ }
+
+ if ( $this->mysql_user != ''
+ && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_user) )
+ {
+ $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD2);
+ }
+
+ if ( $this->mysql_database == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD4);
+ }
+
+ if ( $this->mysql_database != ''
+ && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_database) )
+ {
+ $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD4);
+ }
- if ( preg_match("/^[a-z0-9]+$/i", $name) )
+ if ( $this->mysql_tablePrefix != ''
+ && !preg_match('/^[a-z0-9_]+$/i', $this->mysql_tablePrefix) )
+ {
+ $errors[] = sprintf(_VALID_ERROR3, _DB_FIELD5);
+ }
+
+ if ( count($errors) == 0 )
+ {
+ $mysql_conn = @DB::setConnectionInfo($MYSQL_HANDLER[1], $this->mysql_host, $this->mysql_user, $this->mysql_password);
+ if ( $mysql_conn == false )
+ {
+ $errors[] = _DBCONNECT_ERROR;
+ }
+ else
+ {
+ @DB::disConnect();
+ }
+ }
+
+ return $errors;
+ }
+
+ public function check_user_parameters()
{
- return TRUE;
+ $parameters = array('user_name', 'user_realname', 'user_password', 'user_password2', 'user_email');
+ $this->read_parameter($parameters);
+
+ $errors = array();
+ if ( $this->user_realname == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD1);
+ }
+
+ if ( $this->user_name == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD2);
+ }
+ elseif ( !preg_match("/^[a-z0-9]+([ a-z0-9]*[a-z0-9]+)?$/i", $this->user_name) )
+ {
+ $errors[] = _VALID_ERROR5;
+ }
+
+ if ( $this->user_password == '' || $this->user_password2 == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD3);
+ $this->user_password = '';
+ }
+ elseif ( $this->user_password != $this->user_password2 )
+ {
+ $errors[] = _VALID_ERROR6;
+ $this->user_password = '';
+ }
+
+ if ( !preg_match("/^[a-z0-9\._+\-]+@[a-z0-9\._\-]+\.[a-z]{2,6}$/i", $this->user_email) )
+ {
+ $errors[] = _VALID_ERROR7;
+ }
+
+ return $errors;
}
- else
+
+ public function check_weblog_parameters()
{
- return FALSE;
- } // end if
+ $parameters = array('blog_name', 'blog_shortname');
+ $this->read_parameter($parameters);
-}
+ $errors = array();
+ if ( $this->blog_name == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD1);
+ }
+ if ( $this->blog_shortname == '' )
+ {
+ $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD2);
+ }
-/*
- * Check if a display name is allowed
- * Returns true if the given string is a valid display name
- *
- * FIX: function eregi is deprecated since PHP 5.3.0
- *
- * @param string $name name which should be tested
- * @return bool
- */
-function _isValidDisplayName($name)
-{
+ if ( !preg_match("/^[a-z0-9]+$/i", $this->blog_shortname) )
+ {
+ $errors[] = _VALID_ERROR4;
+ }
- if ( preg_match("/^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$/i", $name) )
+ return $errors;
+ }
+
+ public function check_uri_parameters()
{
- return TRUE;
+ $parameters = array('IndexURL', 'AdminURL', 'MediaURL', 'SkinsURL', 'PluginURL', 'ActionURL');
+ $this->read_parameter($parameters);
+
+ $errors = array();
+ if ( substr($this->IndexURL, -1, 1) !== '/' )
+ {
+ $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD1);
+ }
+
+ if ( substr($this->AdminURL, -1, 1) !== '/' )
+ {
+ $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD2);
+ }
+
+ if ( substr($this->MediaURL, -1, 1) !== '/' )
+ {
+ $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD4);
+ }
+
+ if ( substr($this->SkinsURL, -1, 1) !== '/' )
+ {
+ $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD6);
+ }
+
+ if ( substr($this->PluginURL, -1, 1) !== '/' )
+ {
+ $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD8);
+ }
+
+ if ( strrchr($this->ActionURL, '/') != '/action.php' )
+ {
+ $errors[] = sprintf(_VALID_ERROR9, _PATH_FIELD9);
+ }
+
+ return $errors;
}
- else
+
+ public function check_path_parameters()
{
- return FALSE;
- } // end if
+ $parameters = array('AdminPath', 'MediaPath', 'SkinsPath');
+ $this->read_parameter($parameters);
-}
+ $separators = array('/', DIRECTORY_SEPARATOR);
+ $errors = array();
+ if ( !in_array(substr($this->AdminPath, -1, 1), $separators) )
+ {
+ $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD3);
+ }
+ elseif ( !file_exists($this->AdminPath) )
+ {
+ $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD3);
+ }
-/**
- * _hsc
- * htmlspecialchars wrapper
- *
- * NOTE: htmlspecialchars_decode() is ASCII-to-ACII conversion
- * and its target string consists of several letters.
- * There are no problems.
- *
- * @static
- * @access public
- * @param string $string target string
- * @param string $quotation quotation mode. please refer to the argument of PHP built-in htmlspecialchars
- * @return string escaped string
- *
- */
-function _hsc($string, $quotation=ENT_QUOTES)
-{
- /*
- * we can use 'double_encode' flag instead of this when dropping supports for PHP 5.2.2 or lower
+ if ( !in_array(substr($this->MediaPath, -1, 1), $separators) )
+ {
+ $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD5);
+ }
+ elseif ( !file_exists($this->MediaPath) )
+ {
+ $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD5);
+ }
+
+ if ( !in_array(substr($this->SkinsPath, -1, 1), $separators) )
+ {
+ $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD7);
+ }
+ elseif ( !file_exists($this->SkinsPath) )
+ {
+ $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD7);
+ }
+
+ return $errors;
+ }
+
+ /**
+ * check all parameters
+ * @return bool
*/
- $string = htmlspecialchars_decode($string, $quotation);
- return (string) htmlspecialchars($string, $quotation, i18n::get_current_charset());
-}
+ public function check_all_parameters()
+ {
+ $this->set_locale();
-/* for the non-php systems that decide to show the contents:
-?></div>
-<?php
-*/
+ $isValid = true;
+ $isValid &= (count($this->check_mysql_parameters()) == 0);
+ $isValid &= (count($this->check_user_parameters()) == 0);
+ $isValid &= (count($this->check_weblog_parameters()) == 0);
+ $isValid &= (count($this->check_uri_parameters()) == 0);
+ $isValid &= (count($this->check_path_parameters()) == 0);
+
+ return $isValid;
+ }
+}