3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2012 The Nucleus Group
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
12 * This script will install the Nucleus tables in your SQL-database,
\r
13 * and initialize the data in those tables.
\r
17 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
18 * @copyright Copyright (C) 2002-2012 The Nucleus Group
\r
19 * @version $Id: index.php 1745 2012-04-12 23:45:47Z sakamocchi $
22 /* global values initialize */
\r
25 /* reporting all errors for support */
\r
26 error_reporting(E_ALL);
\r
28 $minimum_php_version = '5.0.6';
\r
29 $minimum_mysql_version = '3.23';
\r
31 $page_footer_copyright = '© 2001-2012 The Nucleus Groupe . Running Nucleus CMS v4.00';
\r
33 // begin if: server's PHP version is below the minimum; halt installation
\r
34 if ( version_compare(PHP_VERSION, $minimum_php_version, '<') )
\r
36 exit('<div style="font-size: xx-large;"> Nucleus requires at least PHP version ' . $minimum_php_version . '</div>');
\r
39 // make sure there's no unnecessary escaping: # set_magic_quotes_runtime(0);
\r
40 if ( version_compare(PHP_VERSION, '5.3.0', '<') )
\r
42 ini_set('magic_quotes_runtime', '0');
\r
45 /* default installed plugins and skins */
\r
46 $aConfPlugsToInstall = array('NP_SecurityEnforcer', 'NP_SkinFiles', 'NP_Text');
\r
47 $aConfSkinsToImport = array('atom', 'rss2.0', 'rsd', 'default', 'admin/defaultadmin');
\r
49 // Check if some important files
\r
52 /* i18n class is needed for internationalization */
\r
53 include_once('../nucleus/libs/i18n.php');
\r
54 if ( !i18n::init('UTF-8', './locales') )
\r
56 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>');
\r
59 // check if mysql support is installed; this check may not make sense, as is, in a version past 3.5x
\r
60 if ( !function_exists('mysql_query') && !function_exists('mysqli_query') )
\r
62 exit('<div style="font-size: xx-large;"> Your PHP version does not have support for MySQL :( </div>');
\r
65 // include core classes that are needed for login & plugin handling
\r
66 include_once('../nucleus/libs/mysql.php');
\r
68 // added for 3.5 sql_* wrapper
\r
69 global $MYSQL_HANDLER;
\r
71 if ( !isset($MYSQL_HANDLER) )
\r
73 $MYSQL_HANDLER = array('mysql', '');
\r
75 include_once('../nucleus/libs/sql/' . $MYSQL_HANDLER[0] . '.php');
\r
78 if ( count($_GET) == 0 && count($_POST) == 0 )
\r
80 unset($_SESSION['param_manager']);
\r
83 // restore the $param from the session
\r
84 if ( array_key_exists('param_manager', $_SESSION) )
\r
86 $param = $_SESSION['param_manager'];
\r
90 $param = new ParamManager();
\r
93 // include translation file
\r
94 if ( array_key_exists('locale', $_POST) ) $param->set_locale();
\r
95 i18n::set_current_locale($param->locale);
\r
96 $translation_file = './locales/' . i18n::get_current_locale() . '.' . i18n::get_current_charset() . '.php';
\r
97 if ( !file_exists($translation_file) )
\r
99 $translation_file = './locales/en_Latn_US.UTF-8.php';
\r
101 include($translation_file);
\r
105 // $param is saved to the session
\r
106 if ( isset($param) )
\r
108 $_SESSION['param_manager'] = $param;
\r
112 unset($_SESSION['param_manager']);
\r
119 function do_action()
\r
123 if ( array_key_exists('action', $_POST) )
\r
125 $isPostback = true;
\r
129 $isPostback = false;
\r
133 if ( array_key_exists('mode', $_REQUEST) )
\r
135 if ( $_REQUEST['mode'] == 'detail' )
\r
137 $param->set_state('detail');
\r
139 elseif ( $_REQUEST['mode'] == 'simple' )
\r
141 $param->set_state('mysql');
\r
145 // input parameter check
\r
148 switch ( $param->state )
\r
151 $param->set_locale();
\r
152 $param->set_state('mysql');
\r
153 $isPostback = false;
\r
156 if ( count($param->check_mysql_parameters()) == 0 )
\r
158 $param->set_state('weblog');
\r
159 $isPostback = false;
\r
163 if ( count($param->check_user_parameters()) == 0
\r
164 && count($param->check_weblog_parameters()) == 0 )
\r
166 $param->set_state('install');
\r
167 $isPostback = false;
\r
171 if ( $param->check_all_parameters() )
\r
173 $param->set_state('install');
\r
174 $isPostback = false;
\r
182 switch ( $param->state )
\r
185 show_select_locale_form();
\r
188 show_database_setting_form($isPostback);
\r
191 show_blog_setting_form($isPostback);
\r
194 show_detail_setting_form($isPostback);
\r
197 show_install_complete_form();
\r
204 * header tag of the installation screens
\r
206 function show_header()
\r
210 /* HTTP 1.1 application for no caching */
\r
211 header("Cache-Control: no-cache, must-revalidate");
\r
212 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
\r
213 header('Content-Type: text/html; charset=' . i18n::get_current_charset());
\r
215 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
216 <html xmlns="http://www.w3.org/1999/xhtml">
\r
218 <title><?php echo _TITLE; ?></title>
\r
219 <link rel="stylesheet" type="text/css" href="./styles/inst.css" />
\r
220 <style type="text/css">
\r
222 <?php echo _BODYFONTSTYLE; ?>
\r
225 <script type="text/javascript">
\r
226 function SelectText( element ) {
\r
227 window.setTimeout( function() { element.select() }, 0 );
\r
229 var isSubmit = false;
\r
230 function OnceSubmit() {
\r
233 window.setTimeout( function() { isSubmit = false; }, 10000 );
\r
242 <div id="navigation">
\r
243 <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
\r
246 if ( in_array($param->state, array('mysql', 'weblog', 'install')) )
\r
248 echo '<li>', _STEP1, '</li><li';
\r
249 if ( $param->state == 'mysql' )
\r
251 echo ' class="gry"';
\r
253 echo '> > ', _STEP2, '</li><li';
\r
254 if ( in_array($param->state, array('mysql', 'weblog')) )
\r
256 echo ' class="gry"';
\r
258 echo '> > ', _STEP3, "</li>\n";
\r
260 if ( in_array($param->state, array('mysql', 'weblog', 'detail')) )
\r
262 echo '<li class="rightbox">';
\r
263 if ( in_array($param->state, array('mysql', 'weblog')) )
\r
265 echo '<a href="./?mode=detail">', _MODE2, '</a>';
\r
269 echo '<a href="./?mode=simple">', _MODE1, '</a>';
\r
281 * footer tag of the installation screens
\r
283 function show_footer()
\r
285 global $page_footer_copyright;
\r
288 <?php echo $page_footer_copyright; ?>
\r
296 * Display the form for language select
\r
298 function show_select_locale_form()
\r
300 // Get the browser language that can be displayed
\r
301 // TODO: default locale select simple implementation
\r
302 $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
\r
303 foreach ( $languages as $language )
\r
305 $language = preg_replace('#([\w]+).*#', '$1', $language);
\r
310 array('en_Latn_US', 'English - United States'),
\r
311 array('ja_Jpan_JP', 'Japanese - Japan')
\r
314 <div id="container">
\r
315 <p style="font-size:152%;font-weight:bold;">
\r
316 Select your locale:
\r
318 <form method="post" action="./index.php">
\r
321 <select name="locale">
\r
323 foreach ( $locales as $locale )
\r
325 echo "<option value=\"$locale[0]\"";
\r
326 if ( i18n::strpos($locale[0], $language) === 0 )
\r
330 echo ">$locale[1]</option>\n";
\r
335 <button type="submit" name="action" value="locale" class="sbt_arw">START</button>
\r
344 * Display the form to set up a database
\r
345 * @param bool $isPostback
\r
347 function show_database_setting_form($isPostback)
\r
349 global $param, $minimum_mysql_version;
\r
351 $config_writable = canConfigFileWritable();
\r
352 $mysql_version = getMySqlVersion();
\r
354 <div id="container">
\r
357 echo _SIMPLE_NAVI1;
\r
358 if ( $config_writable != '' )
\r
360 echo '<span class="err">', $config_writable, '</span>';
\r
362 if ( $mysql_version == '0.0.0' )
\r
364 echo '<span class="err">', _DBVERSION_UNKOWN, '</span>';
\r
366 elseif ( version_compare($mysql_version, $minimum_mysql_version, '<') )
\r
368 echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';
\r
372 <form method="post" action="./index.php">
\r
374 <h2><?php echo _DB_HEADER; ?></h2>
\r
379 $errors = $param->check_mysql_parameters();
\r
380 if ( is_array($errors) )
\r
382 foreach ( $errors as $error )
\r
384 echo '<span class="err">', $error, "</span>\n";
\r
392 <th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
\r
393 <td><input type="text" name="mysql_host" value="<?php echo $param->mysql_host; ?>" /></td>
\r
396 <th><span class="nam"><?php echo _DB_FIELD2; ?></span><span class="sub"><?php echo _DB_FIELD2_DESC; ?></span></th>
\r
397 <td><input type="text" name="mysql_user" value="<?php echo $param->mysql_user; ?>" /></td>
\r
400 <th><span class="nam"><?php echo _DB_FIELD3; ?></span></th>
\r
401 <td><input type="text" name="mysql_password" value="<?php echo $param->mysql_password; ?>" /></td>
\r
404 <th><span class="nam"><?php echo _DB_FIELD4; ?></span><span class="sub"><?php echo _DB_FIELD4_DESC; ?></span></th>
\r
405 <td><input type="text" name="mysql_database" value="<?php echo $param->mysql_database; ?>" /></td>
\r
409 <button type="submit" name="mode" value="detail" class="sbt_sqr"><?php echo _MODE2; ?></button>
\r
410 <button type="submit" name="action" value="mysql" class="sbt_arw"><?php echo _NEXT; ?></button>
\r
413 <?php echo _DB_TEXT1; ?>
\r
422 * Displays a form to the blog settings
\r
423 * @param bool $isPostback
\r
425 function show_blog_setting_form($isPostback)
\r
429 <div id="container">
\r
431 <?php echo _SIMPLE_NAVI2; ?>
\r
433 <form method="post" action="./index.php">
\r
435 <h2><?php echo _BLOG_HEADER; ?></h2>
\r
440 $errors = $param->check_weblog_parameters();
\r
441 if ( is_array($errors) )
\r
443 foreach ( $errors as $error )
\r
445 echo '<span class="err">', $error, "</span>\n";
\r
453 <th><span class="nam"><?php echo _BLOG_FIELD1; ?></span></th>
\r
454 <td><input type="text" name="blog_name" value="<?php echo $param->blog_name; ?>" /></td>
\r
457 <th><span class="nam"><?php echo _BLOG_FIELD2; ?></span><span class="sub"><?php echo _BLOG_FIELD2_DESC; ?></span></th>
\r
458 <td><input type="text" name="blog_shortname" value="<?php echo $param->blog_shortname; ?>" /></td>
\r
464 <h2><?php echo _ADMIN_HEADER; ?></h2>
\r
469 $errors = $param->check_user_parameters();
\r
470 if ( is_array($errors) )
\r
472 foreach ( $errors as $error )
\r
474 echo '<span class="err">', $error, "</span>\n";
\r
482 <th><span class="nam"><?php echo _ADMIN_FIELD1; ?></span></th>
\r
483 <td><input type="text" name="user_realname" value="<?php echo $param->user_realname; ?>" /></td>
\r
486 <th><span class="nam"><?php echo _ADMIN_FIELD2; ?></span><span class="sub"><?php echo _ADMIN_FIELD2_DESC; ?></span></th>
\r
487 <td><input type="text" name="user_name" value="<?php echo $param->user_name; ?>" /></td>
\r
490 <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span></th>
\r
491 <td><input type="password" name="user_password" /></td>
\r
494 <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span></th>
\r
495 <td><input type="password" name="user_password2" /></td>
\r
498 <th><span class="nam"><?php echo _ADMIN_FIELD5; ?></span></th>
\r
499 <td><input type="text" name="user_email" value="<?php echo $param->user_email; ?>" /></td>
\r
503 <button type="submit" name="action" value="weblog" class="sbt_arw" onclick="OnceSubmit()"><?php echo _INSTALL; ?></button>
\r
512 * Displays a form to the detail settings
\r
513 * @param bool $isPostback
\r
515 function show_detail_setting_form($isPostback)
\r
517 global $param, $minimum_mysql_version;
\r
519 $mysql_version = getMySqlVersion();
\r
521 <div id="container_detailed">
\r
523 <?php echo _DETAIL_NAVI1; ?>
\r
525 if ( $isPostback && !$param->check_all_parameters() )
\r
527 echo '<span class="err">', _VALID_ERROR, "</span>\n";
\r
532 <li>PHP: <?php echo phpversion(); ?></li>
\r
535 echo ($mysql_version == '0.0.0') ? _DBVERSION_UNKOWN : $mysql_version;
\r
536 if ( version_compare($mysql_version, $minimum_mysql_version, '<') )
\r
538 echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';
\r
542 <form method="post" action="">
\r
545 <h2><?php echo _DETAIL_HEADER1; ?></h2>
\r
550 $errors = $param->check_mysql_parameters();
\r
551 if ( is_array($errors) )
\r
553 foreach ( $errors as $error )
\r
555 echo '<span class="err">', $error, "</span>\n";
\r
563 <th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
\r
564 <td><input type="text" name="mysql_host" value="<?php echo $param->mysql_host; ?>" /></td>
\r
567 <th><span class="nam"><?php echo _DB_FIELD2; ?></span><span class="sub"><?php echo _DB_FIELD2_DESC; ?></span></th>
\r
568 <td><input type="text" name="mysql_user" value="<?php echo $param->mysql_user; ?>" /></td>
\r
571 <th><span class="nam"><?php echo _DB_FIELD3; ?></span></th>
\r
572 <td><input type="text" name="mysql_password" value="<?php echo $param->mysql_password; ?>" /></td>
\r
575 <th><span class="nam"><?php echo _DB_FIELD4; ?></span><span class="sub"><?php echo _DB_FIELD4_DESC; ?></span></th>
\r
576 <td><input type="text" name="mysql_database" value="<?php echo $param->mysql_database; ?>" /></td>
\r
579 <th><span class="nam"><?php echo _DB_FIELD5; ?></span><span class="sub"><?php echo _DB_FIELD5_DESC; ?></span></th>
\r
580 <td><input type="text" name="mysql_tablePrefix" value="<?php echo $param->mysql_tablePrefix; ?>" /></td>
\r
584 <h2><?php echo _DETAIL_HEADER2; ?></h2>
\r
589 $errors = $param->check_uri_parameters();
\r
590 if ( is_array($errors) )
\r
592 foreach ( $errors as $error )
\r
594 echo '<span class="err">', $error, "</span>\n";
\r
597 $errors = $param->check_path_parameters();
\r
598 if ( is_array($errors) )
\r
600 foreach ( $errors as $error )
\r
602 echo '<span class="err">', $error, "</span>\n";
\r
610 <th><span class="nam"><?php echo _PATH_FIELD1; ?></span></th>
\r
611 <td><input type="text" name="IndexURL" value="<?php echo $param->IndexURL; ?>" /></td>
\r
614 <th><span class="nam"><?php echo _PATH_FIELD2; ?></span></th>
\r
615 <td><input type="text" name="AdminURL" value="<?php echo $param->AdminURL; ?>" /></td>
\r
618 <th><span class="nam"><?php echo _PATH_FIELD3; ?></span></th>
\r
619 <td><input type="text" name="AdminPath" value="<?php echo $param->AdminPath; ?>" /></td>
\r
622 <th><span class="nam"><?php echo _PATH_FIELD4; ?></span></th>
\r
623 <td><input type="text" name="MediaURL" value="<?php echo $param->MediaURL; ?>" /></td>
\r
626 <th><span class="nam"><?php echo _PATH_FIELD5; ?></span></th>
\r
627 <td><input type="text" name="MediaPath" value="<?php echo $param->MediaPath; ?>" /></td>
\r
630 <th><span class="nam"><?php echo _PATH_FIELD6; ?></span></th>
\r
631 <td><input type="text" name="SkinsURL" value="<?php echo $param->SkinsURL; ?>" /></td>
\r
634 <th><span class="nam"><?php echo _PATH_FIELD7; ?></span></th>
\r
635 <td><input type="text" name="SkinsPath" value="<?php echo $param->SkinsPath; ?>" /></td>
\r
638 <th><span class="nam"><?php echo _PATH_FIELD8; ?></span></th>
\r
639 <td><input type="text" name="PluginURL" value="<?php echo $param->PluginURL; ?>" /></td>
\r
642 <th><span class="nam"><?php echo _PATH_FIELD9; ?></span></th>
\r
643 <td><input type="text" name="ActionURL" value="<?php echo $param->ActionURL; ?>" /></td>
\r
647 <?php echo _DETAIL_TEXT3; ?>
\r
650 <h2><?php echo _DETAIL_HEADER3; ?></h2>
\r
653 echo _DETAIL_TEXT4;
\r
656 $errors = $param->check_user_parameters();
\r
657 if ( is_array($errors) )
\r
659 foreach ( $errors as $error )
\r
661 echo '<span class="err">', $error, "</span>\n";
\r
669 <th><span class="nam"><?php echo _ADMIN_FIELD1; ?></span></th>
\r
670 <td><input type="text" name="user_realname" value="<?php echo $param->user_realname; ?>" /></td>
\r
673 <th><span class="nam"><?php echo _ADMIN_FIELD2; ?></span><span class="sub"><?php echo _ADMIN_FIELD2_DESC; ?></span></th>
\r
674 <td><input type="text" name="user_name" value="<?php echo $param->user_name; ?>" /></td>
\r
677 <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span></th>
\r
678 <td><input type="password" name="user_password" /></td>
\r
681 <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span></th>
\r
682 <td><input type="password" name="user_password2" /></td>
\r
685 <th><span class="nam"><?php echo _ADMIN_FIELD5; ?></span></th>
\r
686 <td><input type="text" name="user_email" value="<?php echo $param->user_email; ?>" /></td>
\r
690 <h2><?php echo _DETAIL_HEADER4; ?></h2>
\r
693 echo _DETAIL_TEXT5;
\r
696 $errors = $param->check_weblog_parameters();
\r
697 if ( is_array($errors) )
\r
699 foreach ( $errors as $error )
\r
701 echo '<span class="err">', $error, "</span>\n";
\r
709 <th><span class="nam"><?php echo _BLOG_FIELD1; ?></span></th>
\r
710 <td><input type="text" name="blog_name" value="<?php echo $param->blog_name; ?>" /></td>
\r
713 <th><span class="nam"><?php echo _BLOG_FIELD2; ?></span><span class="sub"><?php echo _BLOG_FIELD2_DESC; ?></span></th>
\r
714 <td><input type="text" name="blog_shortname" value="<?php echo $param->blog_shortname; ?>" /></td>
\r
719 <?php echo _DETAIL_TEXT6; ?>
\r
723 <button type="submit" name="action" value="detail" class="sbt_arw" onclick="OnceSubmit()"><?php echo _INSTALL; ?></button>
\r
732 * Displays a screen to signal the completion of the installation
\r
734 function show_install_complete_form()
\r
736 global $MYSQL_HANDLER, $param;
\r
737 $errors = do_install();
\r
739 <div id="container">
\r
742 if ( is_array($errors) && count($errors) > 0 )
\r
745 foreach ( $errors as $error )
\r
747 echo '<span class="err">', $error, "</span>\n";
\r
753 if ( array_key_exists('config_data', $_SESSION) )
\r
755 echo '<span class="err">', _INST_TEXT4, '</span>';
\r
757 <textarea id="config_text" readonly="readonly" onfocus="SelectText(this);"><?php echo htmlentities($_SESSION['config_data'], null, i18n::get_current_charset()) ?></textarea>
\r
762 echo '<span class="err">', _INST_TEXT5, '</span>';
\r
766 <form method="post" action="./index.php">
\r
768 <h2><?php echo _INST_HEADER1; ?></h2>
\r
770 <?php echo sprintf(_INST_TEXT1, $param->blog_name); ?>
\r
773 <button type="button" name="toBlog" onclick="location.href='<?php echo $param->IndexURL; ?>';" class="sbt_arw"><?php echo _INST_BUTTON1; ?></button>
\r
778 <h2><?php echo _INST_HEADER2; ?></h2>
\r
780 <?php echo _INST_TEXT2; ?>
\r
783 <button type="button" name="toMng" onclick="location.href='<?php echo $param->AdminURL; ?>';" class="sbt_arw"><?php echo _INST_BUTTON2; ?></button>
\r
788 <h2><?php echo _INST_HEADER3; ?></h2>
\r
790 <?php echo _INST_TEXT3; ?>
\r
793 <button type="button" name="toAddBlog" onclick="location.href='<?php echo $param->AdminURL; ?>index.php?action=createnewlog';" class="sbt_arw"><?php echo _INST_BUTTON3; ?></button>
\r
806 * The installation process itself
\r
807 * @return array error messages
\r
809 function do_install()
\r
812 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX, $MYSQL_CONN;
\r
813 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
817 * 1. put all param-vars into vars
\r
819 $MYSQL_HOST = $param->mysql_host;
\r
820 $MYSQL_USER = $param->mysql_user;
\r
821 $MYSQL_PASSWORD = $param->mysql_password;
\r
822 $MYSQL_DATABASE = $param->mysql_database;
\r
823 $MYSQL_PREFIX = $param->mysql_tablePrefix;
\r
825 $DIR_NUCLEUS = $param->AdminPath;
\r
826 $DIR_MEDIA = $param->MediaPath;
\r
827 $DIR_SKINS = $param->SkinsPath;
\r
828 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
829 $DIR_LOCALES = $DIR_NUCLEUS . 'locales/';
\r
830 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
833 * 2.open mySQL connection
\r
835 $MYSQL_CONN = @sql_connect_args($MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
\r
836 if ( $MYSQL_CONN == false )
\r
838 $errors[] = _DBCONNECT_ERROR;
\r
843 * 3. try to create database if needed
\r
845 if ( !sql_query("CREATE DATABASE IF NOT EXISTS {$MYSQL_DATABASE}") )
\r
847 $errors[] = _INST_ERROR1 . ': ' . sql_error();
\r
851 * 4. try to select database
\r
853 if ( !sql_select_db($MYSQL_DATABASE) )
\r
855 $errors[] = _INST_ERROR2;
\r
857 sql_set_charset('utf8');
\r
859 if ( count($errors) > 0 )
\r
865 * 5. execute queries
\r
867 $table_names = array(
\r
868 'nucleus_actionlog',
\r
871 'nucleus_category',
\r
879 'nucleus_template',
\r
881 'nucleus_activation',
\r
885 $prefixed_table_names = array();
\r
886 foreach ( $table_names as $table_name )
\r
888 $prefixed_table_names[] = $MYSQL_PREFIX . $table_name;
\r
891 // table exists check
\r
892 $result = sql_query('SHOW TABLES');
\r
893 while ( $row = mysql_fetch_array($result, MYSQL_NUM) )
\r
895 if ( in_array($row[0], $prefixed_table_names) )
\r
897 $errors[] = _INST_ERROR3;
\r
901 if ( count($errors) > 0 )
\r
906 $filename = 'install.sql';
\r
907 $fd = fopen($filename, 'r');
\r
908 $queries = fread($fd, filesize($filename));
\r
911 $queries = preg_split('#(;\n|;\r)#', $queries);
\r
913 foreach ( $queries as $query )
\r
915 if ( preg_match('/\w+/', $query) )
\r
917 if ( $MYSQL_PREFIX )
\r
919 $query = str_replace($table_names, $prefixed_table_names, $query);
\r
922 if ( !sql_query($query) )
\r
924 $errors[] = _INST_ERROR4 . ' (<small>' . $query . '</small>): ' . sql_error();
\r
930 * 6. put needed records
\r
932 /* push first post */
\r
933 $query = "INSERT INTO %s VALUES (1, '%s', '%s', '%s', 1, 1, '%s', 0, 0, 0, 1, 0, 1)";
\r
934 $query = sprintf($query, tableName('nucleus_item'), _1ST_POST_TITLE, _1ST_POST, _1ST_POST2, i18n::formatted_datetime('mysql', time()));
\r
935 if ( !sql_query($query) )
\r
937 $errors[] = _INST_ERROR4 . ' (<small>' . $newpost . '</small>): ' . sql_error();
\r
940 /* push configurations */
\r
941 array_merge($errors, updateConfig('IndexURL', $param->IndexURL));
\r
942 array_merge($errors, updateConfig('AdminURL', $param->AdminURL));
\r
943 array_merge($errors, updateConfig('MediaURL', $param->MediaURL));
\r
944 array_merge($errors, updateConfig('SkinsURL', $param->SkinsURL));
\r
945 array_merge($errors, updateConfig('PluginURL', $param->PluginURL));
\r
946 array_merge($errors, updateConfig('ActionURL', $param->ActionURL));
\r
947 array_merge($errors, updateConfig('AdminEmail', $param->user_email));
\r
948 array_merge($errors, updateConfig('SiteName', $param->blog_name));
\r
949 array_merge($errors, updateConfig('Locale', i18n::get_current_locale()));
\r
951 /* escape strings for SQL */
\r
952 $user_name = sql_real_escape_string($param->user_name);
\r
953 $user_realname = sql_real_escape_string($param->user_realname);
\r
954 $user_password = sql_real_escape_string(md5($param->user_password));
\r
955 $user_email = sql_real_escape_string($param->user_email);
\r
956 $blog_name = sql_real_escape_string($param->blog_name);
\r
957 $blog_shortname = sql_real_escape_string($param->blog_shortname);
\r
958 $config_indexurl = sql_real_escape_string($param->IndexURL);
\r
960 /* push super admin */
\r
961 $query = "UPDATE %s SET mname = '%s', mrealname = '%s', mpassword = '%s', memail = '%s', murl = '%s', madmin = 1, mcanlogin = 1 WHERE mnumber = 1";
\r
962 $query = sprintf($query, tableName('nucleus_member'), $user_name, $user_realname, $user_password, $user_email, $config_indexurl);
\r
963 if ( !sql_query($query) )
\r
965 $errors[] = _INST_ERROR5 . ': ' . sql_error();
\r
968 /* push new weblog */
\r
969 $query = "UPDATE %s SET bname = '%s', bshortname = '%s', burl = '%s' WHERE bnumber = 1";
\r
970 $query = sprintf($query, tableName('nucleus_blog'), $blog_name, $blog_shortname, $config_indexurl);
\r
971 if ( !sql_query($query) )
\r
973 $errors[] = _INST_ERROR6 . ': ' . sql_error();
\r
976 /* push default category */
\r
977 $query = "UPDATE %s SET cname = '%s', cdesc = '%s' WHERE catid = 1";
\r
978 $query = sprintf($query, tableName('nucleus_category'), _GENERALCAT_NAME, _GENERALCAT_DESC);
\r
979 if ( !sql_query($query) )
\r
981 $errors[] = _INST_ERROR6 . ': ' . sql_error();
\r
987 * 7. install default plugins and skins
\r
989 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
990 $aSkinErrors = array();
\r
991 $aPlugErrors = array();
\r
993 if ( (count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) )
\r
995 include_once($DIR_LIBS . 'globalfunctions.php');
\r
997 if ( !isset($manager) )
\r
999 $manager = new Manager();
\r
1002 include_once($DIR_LIBS . 'skinie.php');
\r
1004 $aSkinErrors = installCustomSkins();
\r
1005 if ( count($aSkinErrors) > 0 )
\r
1007 array_merge($errors, $aSkinErrors);
\r
1009 $query = 'SELECT MIN(sdnumber) as result FROM ' . tableName('nucleus_skin_desc') . ' WHERE sdincmode = "admin"';
\r
1010 $res = sql_query($query);
\r
1011 $obj = sql_fetch_object($res);
\r
1012 array_merge($errors, updateConfig('DefaultAdminSkin', $obj->result));
\r
1014 $query = "SELECT sdnumber FROM %s WHERE sdname='default'";
\r
1015 $query = sprintf($query, tableName('nucleus_skin_desc'));
\r
1016 $res = sql_query($query);
\r
1017 $obj = sql_fetch_assoc($res);
\r
1018 $defSkinID = (integer) $obj['sdnumber'];
\r
1020 $query = "UPDATE %s SET bdefskin=%d WHERE bnumber=1";
\r
1021 $query = sprintf($query, tableName('nucleus_blog'), $defSkinID);
\r
1022 sql_query($query);
\r
1023 $query = "UPDATE %s SET value=%d WHERE name='BaseSkin'";
\r
1024 $query = sprintf($query, tableName('nucleus_config'), $defSkinID);
\r
1025 sql_query($query);
\r
1027 $aPlugErrors = installCustomPlugs();
\r
1028 if ( count($aPlugErrors) > 0 )
\r
1030 array_merge($errors, $aPlugErrors);
\r
1035 * 8. Write config file ourselves (if possible)
\r
1037 $config_data = '<' . '?php' . "\n";
\r
1038 $config_data .= "// mySQL connection information\n";
\r
1039 $config_data .= "\$MYSQL_HOST = '" . $MYSQL_HOST . "';\n";
\r
1040 $config_data .= "\$MYSQL_USER = '" . $MYSQL_USER . "';\n";
\r
1041 $config_data .= "\$MYSQL_PASSWORD = '" . $MYSQL_PASSWORD . "';\n";
\r
1042 $config_data .= "\$MYSQL_DATABASE = '" . $MYSQL_DATABASE . "';\n";
\r
1043 $config_data .= "\$MYSQL_PREFIX = '" . $MYSQL_PREFIX . "';\n";
\r
1044 $config_data .= "// new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
\r
1045 $config_data .= "// default is \$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
1046 $config_data .= "//\$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
1047 $config_data .= "//\$MYSQL_HANDLER = array('pdo','mysql');\n";
\r
1048 $config_data .= "\$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n";
\r
1049 $config_data .= "\n";
\r
1050 $config_data .= "// main nucleus directory\n";
\r
1051 $config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n";
\r
1052 $config_data .= "\n";
\r
1053 $config_data .= "// path to media dir\n";
\r
1054 $config_data .= "\$DIR_MEDIA = '" . $DIR_MEDIA . "';\n";
\r
1055 $config_data .= "\n";
\r
1056 $config_data .= "// extra skin files for imported skins\n";
\r
1057 $config_data .= "\$DIR_SKINS = '" . $DIR_SKINS . "';\n";
\r
1058 $config_data .= "\n";
\r
1059 $config_data .= "// these dirs are normally sub dirs of the nucleus dir, but \n";
\r
1060 $config_data .= "// you can redefine them if you wish\n";
\r
1061 $config_data .= "\$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
1062 $config_data .= "\$DIR_LOCALES = \$DIR_NUCLEUS . 'locales/';\n";
\r
1063 $config_data .= "\$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
1064 $config_data .= "\n";
\r
1065 $config_data .= "// include libs\n";
\r
1066 $config_data .= "include(\$DIR_LIBS.'globalfunctions.php');\n";
\r
1067 $config_data .= "?" . ">";
\r
1070 if ( @!file_exists('../config.php') || is_writable('../config.php') )
\r
1072 if ( $fp = @fopen('../config.php', 'w') )
\r
1074 $result = @fwrite($fp, $config_data, i18n::strlen($config_data));
\r
1081 // try to change the read-only permission.
\r
1082 if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
\r
1084 @chmod('../config.php', 0444);
\r
1089 $_SESSION['config_data'] = $config_data;
\r
1096 * Confirm that you can write to the configuration file
\r
1097 * @return string error message
\r
1099 function canConfigFileWritable()
\r
1101 if ( @file_exists('../config.php') && @!is_writable('../config.php') )
\r
1103 // try to change the read-write permission.
\r
1104 if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
\r
1106 @chmod('../config.php', 0666);
\r
1109 if ( @!is_writable('../config.php') )
\r
1111 return _INST_ERROR8;
\r
1118 * To obtain the version of MySQL
\r
1121 function getMySqlVersion()
\r
1123 global $minimum_mysql_version, $errors;
\r
1124 // Turn on output buffer
\r
1125 // Needed to repress the output of the sql function that are
\r
1126 // not part of php (in this case the @ operator doesn't work)
\r
1129 // note: this piece of code is taken from phpMyAdmin
\r
1130 $conn = sql_connect_args('localhost', '', '');
\r
1131 $result = @sql_query('SELECT VERSION() AS version', $conn);
\r
1133 if ( $result != FALSE && sql_num_rows($result) > 0 )
\r
1135 $row = sql_fetch_array($result);
\r
1136 $match = preg_split('#\.#', $row['version']);
\r
1140 $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
\r
1142 if ( $result != FALSE && @sql_num_rows($result) > 0 )
\r
1144 $row = sql_fetch_row($result);
\r
1145 $match = preg_split('#\.#', $row[1]);
\r
1149 $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
\r
1150 preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
\r
1151 $match = preg_split('#\.#', $version[0]);
\r
1153 if ( $match[0] == '' )
\r
1155 $match = array('0', '0', '0');
\r
1160 @sql_disconnect($conn);
\r
1162 //End and clean output buffer
\r
1165 return implode($match, '.');
\r
1169 * Add a table prefix if it is used
\r
1171 * @param string $input table name with prefix
\r
1174 function tableName($input)
\r
1176 global $MYSQL_PREFIX;
\r
1177 if ( $MYSQL_PREFIX )
\r
1179 return $MYSQL_PREFIX . $input;
\r
1188 * Install custom plugins
\r
1190 function installCustomPlugs()
\r
1192 global $aConfPlugsToInstall, $DIR_LIBS, $manager;
\r
1194 $aErrors = array();
\r
1195 if ( count($aConfPlugsToInstall) == 0 )
\r
1200 $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin'));
\r
1201 $numCurrent = sql_num_rows($res);
\r
1203 foreach ( $aConfPlugsToInstall as $plugName )
\r
1205 $query = 'INSERT INTO ' . tableName('nucleus_plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ", '" . sql_real_escape_string($plugName) . "')";
\r
1206 sql_query($query);
\r
1208 $manager->clearCachedInfo('installedPlugins');
\r
1209 $plugin =& $manager->getPlugin($plugName);
\r
1210 $plugin->setID($numCurrent);
\r
1214 sql_query('DELETE FROM ' . tableName('nucleus_plugin') . " WHERE pfile = '" . sql_real_escape_string($plugName) . "'");
\r
1216 array_push($aErrors, sprintf(_INST_ERROR9, $plugName));
\r
1219 $plugin->install();
\r
1222 sql_query('DELETE FROM ' . tableName('nucleus_plugin_event'));
\r
1223 $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin'));
\r
1225 while ( $o = sql_fetch_object($res) )
\r
1228 $plug =& $manager->getPlugin($o->pfile);
\r
1232 $eventList = $plug->getEventList();
\r
1233 foreach ( $eventList as $eventName )
\r
1235 sql_query('INSERT INTO ' . tableName('nucleus_plugin_event') . ' (pid, event) VALUES (' . $pid . ", '" . $eventName . "')");
\r
1243 * Install custom skins
\r
1244 * Prepares the installation of custom skins
\r
1246 function installCustomSkins()
\r
1248 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1250 $aErrors = array();
\r
1251 if ( count($aConfSkinsToImport) == 0 )
\r
1256 $importer = new SkinImport();
\r
1258 foreach ( $aConfSkinsToImport as $skinName )
\r
1260 $importer->reset();
\r
1261 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1263 if ( !@file_exists($skinFile) )
\r
1265 array_push($aErrors, sprintf(_INST_ERROR10, $skinFile));
\r
1269 $error = $importer->readFile($skinFile);
\r
1273 array_push($aErrors, sprintf(_INST_ERROR11, $skinName) . ' : ' . $error);
\r
1277 $error = $importer->writeToDatabase(1);
\r
1281 array_push($aErrors, sprintf(_INST_ERROR12, $skinName) . ' : ' . $error);
\r
1289 * Check if some important files of the Nucleus CMS installation are available
\r
1290 * Give an error if one or more files are not accessible
\r
1292 function do_check_files()
\r
1294 $missingfiles = array();
\r
1299 '../nucleus/index.php',
\r
1300 '../nucleus/media.php',
\r
1301 '../nucleus/libs/ACTION.php',
\r
1302 '../nucleus/libs/ACTIONLOG.php',
\r
1303 '../nucleus/libs/ACTIONS.php',
\r
1304 '../nucleus/libs/ADMIN.php',
\r
1305 '../nucleus/libs/BaseActions.php',
\r
1306 '../nucleus/libs/BLOG.php',
\r
1307 '../nucleus/libs/BODYACTIONS.php',
\r
1308 '../nucleus/libs/COMMENT.php',
\r
1309 '../nucleus/libs/COMMENTACTIONS.php',
\r
1310 '../nucleus/libs/COMMENTS.php',
\r
1311 '../nucleus/libs/ENCAPSULATE.php',
\r
1312 '../nucleus/libs/ENTITY.php',
\r
1313 '../nucleus/libs/globalfunctions.php',
\r
1314 '../nucleus/libs/i18n.php',
\r
1315 '../nucleus/libs/ITEM.php',
\r
1316 '../nucleus/libs/ITEMACTIONS.php',
\r
1317 '../nucleus/libs/LINK.php',
\r
1318 '../nucleus/libs/MANAGER.php',
\r
1319 '../nucleus/libs/MEDIA.php',
\r
1320 '../nucleus/libs/MEMBER.php',
\r
1321 '../nucleus/libs/mysql.php',
\r
1322 '../nucleus/libs/NOTIFICATION.php',
\r
1323 '../nucleus/libs/PAGEFACTORY.php',
\r
1324 '../nucleus/libs/PARSER.php',
\r
1325 '../nucleus/libs/PLUGIN.php',
\r
1326 '../nucleus/libs/PLUGINADMIN.php',
\r
1327 '../nucleus/libs/SEARCH.php',
\r
1328 '../nucleus/libs/showlist.php',
\r
1329 '../nucleus/libs/SKIN.php',
\r
1330 '../nucleus/libs/TEMPLATE.php',
\r
1331 '../nucleus/libs/vars4.1.0.php',
\r
1332 '../nucleus/libs/xmlrpc.inc.php',
\r
1333 '../nucleus/libs/xmlrpcs.inc.php',
\r
1334 '../nucleus/libs/sql/mysql.php'
\r
1337 $count = count($files);
\r
1338 for ( $i = 0; $i < $count; $i++ )
\r
1340 if ( !is_readable($files[$i]) )
\r
1342 array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');
\r
1346 if ( count($missingfiles) > 0 )
\r
1348 exit(implode("\n", $missingfiles));
\r
1353 * Updates the configuration in the database
\r
1355 * @param string $name name of the config var
\r
1356 * @param string $value new value of the config var
\r
1359 function updateConfig($name, $value)
\r
1361 $errors = array();
\r
1362 $name = sql_real_escape_string($name);
\r
1363 $value = trim(sql_real_escape_string($value));
\r
1365 $query = "UPDATE %s SET value = '%s' WHERE name = '%s'";
\r
1366 $query = sprintf($query, tableName('nucleus_config'), $value, $name);
\r
1368 if ( !sql_query($query) )
\r
1370 $errors[] = _INST_ERROR4 . ': ' . sql_error();
\r
1375 class ParamManager
\r
1377 /* process parameter */
\r
1381 /* mysql connection parameters */
\r
1382 public $mysql_host;
\r
1383 public $mysql_user;
\r
1384 public $mysql_password;
\r
1385 public $mysql_database;
\r
1386 public $mysql_tablePrefix;
\r
1388 /* weblog configuration parameters */
\r
1389 public $blog_name;
\r
1390 public $blog_shortname;
\r
1392 /* member configuration parameters */
\r
1393 public $user_name;
\r
1394 public $user_realname;
\r
1395 public $user_password;
\r
1396 private $user_password2;
\r
1397 public $user_email;
\r
1399 /* URI parameters */
\r
1400 private $root_url;
\r
1405 public $PluginURL;
\r
1406 public $ActionURL;
\r
1408 /* path parameters */
\r
1409 private $root_path;
\r
1410 public $AdminPath;
\r
1411 public $MediaPath;
\r
1412 public $SkinsPath;
\r
1417 public function __construct()
\r
1422 public function init()
\r
1424 // set default values
\r
1425 $this->state = 'locale';
\r
1426 $this->install_mode = 'simple';
\r
1427 $this->locale = 'en_Latn_US';
\r
1428 $this->mysql_host = @ini_get('mysql.default_host');
\r
1429 $this->blog_name = 'My Nucleus CMS';
\r
1430 $this->blog_shortname = 'mynucleuscms';
\r
1433 $directory_separator = preg_quote(DIRECTORY_SEPARATOR, '|');
\r
1434 $this->root_path = implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__) . '/..')));
\r
1435 if ( substr($this->root_path, -1, 1) !== '/' )
\r
1437 $this->root_path .= '/';
\r
1439 $base_path_pcre = preg_quote($this->root_path, '|');
\r
1441 /* current directry name */
\r
1442 $directory_name = preg_replace("#{$base_path_pcre}#", '', implode('/', preg_split("#{$directory_separator}#", realpath(dirname(__FILE__)))));
\r
1443 $directory_name_pcre = preg_quote($directory_name, '|');
\r
1446 $root_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
\r
1447 $this->root_url = preg_replace("|$directory_name_pcre(.*)$|", '', $root_url);
\r
1449 $this->AdminPath = $this->root_path . 'nucleus/';
\r
1450 $this->MediaPath = $this->root_path . 'media/';
\r
1451 $this->SkinsPath = $this->root_path . 'skins/';
\r
1453 $this->IndexURL = $this->root_url;
\r
1454 $this->AdminURL = $this->root_url . 'nucleus/';
\r
1455 $this->MediaURL = $this->root_url . 'media/';
\r
1456 $this->SkinsURL = $this->root_url . 'skins/';
\r
1457 $this->PluginURL = $this->root_url . 'nucleus/plugins/';
\r
1458 $this->ActionURL = $this->root_url . 'action.php';
\r
1461 private function read_parameter($parameter)
\r
1463 foreach ( $parameter as $element )
\r
1465 if ( array_key_exists($element, $_POST) )
\r
1467 $this->$element = $_POST[$element];
\r
1472 public function set_state($state)
\r
1474 $states = array('locale', 'mysql', 'weblog', 'detail', 'install');
\r
1475 if ( in_array($state, $states) )
\r
1477 $this->state = $state;
\r
1481 public function set_locale()
\r
1483 $this->read_parameter(array('locale'));
\r
1485 if ( !in_array($this->locale, i18n::get_available_locale_list()) )
\r
1487 $this->locale = 'en_Latn_US';
\r
1491 public function check_mysql_parameters()
\r
1493 $parameters = array('mysql_host', 'mysql_user', 'mysql_password', 'mysql_database', 'mysql_tablePrefix');
\r
1494 $this->read_parameter($parameters);
\r
1496 $errors = array();
\r
1497 if ( $this->mysql_host == '' )
\r
1499 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD1);
\r
1502 if ( $this->mysql_user == '' )
\r
1504 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD2);
\r
1507 if ( $this->mysql_user != ''
\r
1508 && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_user) )
\r
1510 $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD2);
\r
1513 if ( $this->mysql_database == '' )
\r
1515 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD4);
\r
1518 if ( $this->mysql_database != ''
\r
1519 && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_database) )
\r
1521 $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD4);
\r
1524 if ( $this->mysql_tablePrefix != ''
\r
1525 && !preg_match('/^[a-z0-9_]+$/i', $this->mysql_tablePrefix) )
\r
1527 $errors[] = sprintf(_VALID_ERROR3, _DB_FIELD5);
\r
1530 if ( count($errors) == 0 )
\r
1532 $mysql_conn = @sql_connect_args($this->mysql_host, $this->mysql_user, $this->mysql_password);
\r
1533 if ( $mysql_conn == false )
\r
1535 $errors[] = _DBCONNECT_ERROR;
\r
1539 @sql_disconnect($mysql_conn);
\r
1546 public function check_user_parameters()
\r
1548 $parameters = array('user_name', 'user_realname', 'user_password', 'user_password2', 'user_email');
\r
1549 $this->read_parameter($parameters);
\r
1551 $errors = array();
\r
1552 if ( $this->user_realname == '' )
\r
1554 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD1);
\r
1557 if ( $this->user_name == '' )
\r
1559 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD2);
\r
1561 elseif ( !preg_match("/^[a-z0-9]+([ a-z0-9]*[a-z0-9]+)?$/i", $this->user_name) )
\r
1563 $errors[] = _VALID_ERROR5;
\r
1566 if ( $this->user_password == '' || $this->user_password2 == '' )
\r
1568 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD3);
\r
1569 $this->user_password = '';
\r
1571 elseif ( $this->user_password != $this->user_password2 )
\r
1573 $errors[] = _VALID_ERROR6;
\r
1574 $this->user_password = '';
\r
1577 if ( !preg_match("/^[a-z0-9\._+\-]+@[a-z0-9\._\-]+\.[a-z]{2,6}$/i", $this->user_email) )
\r
1579 $errors[] = _VALID_ERROR7;
\r
1585 public function check_weblog_parameters()
\r
1587 $parameters = array('blog_name', 'blog_shortname');
\r
1588 $this->read_parameter($parameters);
\r
1590 $errors = array();
\r
1591 if ( $this->blog_name == '' )
\r
1593 $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD1);
\r
1596 if ( $this->blog_shortname == '' )
\r
1598 $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD2);
\r
1601 if ( !preg_match("/^[a-z0-9]+$/i", $this->blog_shortname) )
\r
1603 $errors[] = _VALID_ERROR4;
\r
1609 public function check_uri_parameters()
\r
1611 $parameters = array('IndexURL', 'AdminURL', 'MediaURL', 'SkinsURL', 'PluginURL', 'ActionURL');
\r
1612 $this->read_parameter($parameters);
\r
1614 $errors = array();
\r
1615 if ( substr($this->IndexURL, -1, 1) !== '/' )
\r
1617 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD1);
\r
1620 if ( substr($this->AdminURL, -1, 1) !== '/' )
\r
1622 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD2);
\r
1625 if ( substr($this->MediaURL, -1, 1) !== '/' )
\r
1627 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD4);
\r
1630 if ( substr($this->SkinsURL, -1, 1) !== '/' )
\r
1632 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD6);
\r
1635 if ( substr($this->PluginURL, -1, 1) !== '/' )
\r
1637 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD8);
\r
1640 if ( strrchr($this->ActionURL, '/') != '/action.php' )
\r
1642 $errors[] = sprintf(_VALID_ERROR9, _PATH_FIELD9);
\r
1648 public function check_path_parameters()
\r
1650 $parameters = array('AdminPath', 'MediaPath', 'SkinsPath');
\r
1651 $this->read_parameter($parameters);
\r
1653 $separators = array('/', DIRECTORY_SEPARATOR);
\r
1654 $errors = array();
\r
1655 if ( !in_array(substr($this->AdminPath, -1, 1), $separators) )
\r
1657 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD3);
\r
1659 elseif ( !file_exists($this->AdminPath) )
\r
1661 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD3);
\r
1664 if ( !in_array(substr($this->MediaPath, -1, 1), $separators) )
\r
1666 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD5);
\r
1668 elseif ( !file_exists($this->MediaPath) )
\r
1670 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD5);
\r
1673 if ( !in_array(substr($this->SkinsPath, -1, 1), $separators) )
\r
1675 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD7);
\r
1677 elseif ( !file_exists($this->SkinsPath) )
\r
1679 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD7);
\r
1686 * check all parameters
\r
1689 public function check_all_parameters()
\r
1691 $this->set_locale();
\r
1694 $isValid &= (count($this->check_mysql_parameters()) == 0);
\r
1695 $isValid &= (count($this->check_user_parameters()) == 0);
\r
1696 $isValid &= (count($this->check_weblog_parameters()) == 0);
\r
1697 $isValid &= (count($this->check_uri_parameters()) == 0);
\r
1698 $isValid &= (count($this->check_path_parameters()) == 0);
\r