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 $
\r
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');
\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
67 // added for 3.5 sql_* wrapper
\r
68 global $MYSQL_HANDLER;
\r
70 if ( !isset($MYSQL_HANDLER) )
\r
72 $MYSQL_HANDLER = array('mysql', '');
\r
74 include_once('../nucleus/libs/sql/sql.php');
\r
77 if ( count($_GET) == 0 && count($_POST) == 0 )
\r
79 unset($_SESSION['param_manager']);
\r
82 // restore the $param from the session
\r
83 if ( array_key_exists('param_manager', $_SESSION) )
\r
85 $param = $_SESSION['param_manager'];
\r
89 $param = new ParamManager();
\r
92 // include translation file
\r
93 if ( array_key_exists('locale', $_POST) ) $param->set_locale();
\r
94 i18n::set_current_locale($param->locale);
\r
95 $translation_file = './locales/' . i18n::get_current_locale() . '.' . i18n::get_current_charset() . '.php';
\r
96 if ( !file_exists($translation_file) )
\r
98 $translation_file = './locales/en_Latn_US.UTF-8.php';
\r
100 include($translation_file);
\r
104 // $param is saved to the session
\r
105 if ( isset($param) )
\r
107 $_SESSION['param_manager'] = $param;
\r
111 unset($_SESSION['param_manager']);
\r
118 function do_action()
\r
122 if ( array_key_exists('action', $_POST) )
\r
124 $isPostback = true;
\r
128 $isPostback = false;
\r
132 if ( array_key_exists('mode', $_REQUEST) )
\r
134 if ( $_REQUEST['mode'] == 'detail' )
\r
136 $param->set_state('detail');
\r
138 elseif ( $_REQUEST['mode'] == 'simple' )
\r
140 $param->set_state('mysql');
\r
144 // input parameter check
\r
147 switch ( $param->state )
\r
150 $param->set_locale();
\r
151 $param->set_state('mysql');
\r
152 $isPostback = false;
\r
155 if ( count($param->check_mysql_parameters()) == 0 )
\r
157 $param->set_state('weblog');
\r
158 $isPostback = false;
\r
162 if ( count($param->check_user_parameters()) == 0
\r
163 && count($param->check_weblog_parameters()) == 0 )
\r
165 $param->set_state('install');
\r
166 $isPostback = false;
\r
170 if ( $param->check_all_parameters() )
\r
172 $param->set_state('install');
\r
173 $isPostback = false;
\r
181 switch ( $param->state )
\r
184 show_select_locale_form();
\r
187 show_database_setting_form($isPostback);
\r
190 show_blog_setting_form($isPostback);
\r
193 show_detail_setting_form($isPostback);
\r
196 show_install_complete_form();
\r
203 * header tag of the installation screens
\r
205 function show_header()
\r
209 /* HTTP 1.1 application for no caching */
\r
210 header("Cache-Control: no-cache, must-revalidate");
\r
211 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
\r
212 header('Content-Type: text/html; charset=' . i18n::get_current_charset());
\r
214 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
215 <html xmlns="http://www.w3.org/1999/xhtml">
\r
217 <title><?php echo _TITLE; ?></title>
\r
218 <link rel="stylesheet" type="text/css" href="./styles/inst.css" />
\r
219 <style type="text/css">
\r
221 <?php echo _BODYFONTSTYLE; ?>
\r
224 <script type="text/javascript">
\r
225 function SelectText( element ) {
\r
226 window.setTimeout( function() { element.select() }, 0 );
\r
228 var isSubmit = false;
\r
229 function OnceSubmit() {
\r
232 window.setTimeout( function() { isSubmit = false; }, 10000 );
\r
241 <div id="navigation">
\r
242 <h1><img src="./styles/nucleus_rogo.png" alt="NucleusCMS" /></h1>
\r
245 if ( in_array($param->state, array('mysql', 'weblog', 'install')) )
\r
247 echo '<li>', _STEP1, '</li><li';
\r
248 if ( $param->state == 'mysql' )
\r
250 echo ' class="gry"';
\r
252 echo '> > ', _STEP2, '</li><li';
\r
253 if ( in_array($param->state, array('mysql', 'weblog')) )
\r
255 echo ' class="gry"';
\r
257 echo '> > ', _STEP3, "</li>\n";
\r
259 if ( in_array($param->state, array('mysql', 'weblog', 'detail')) )
\r
261 echo '<li class="rightbox">';
\r
262 if ( in_array($param->state, array('mysql', 'weblog')) )
\r
264 echo '<a href="./?mode=detail">', _MODE2, '</a>';
\r
268 echo '<a href="./?mode=simple">', _MODE1, '</a>';
\r
280 * footer tag of the installation screens
\r
282 function show_footer()
\r
284 global $page_footer_copyright;
\r
287 <?php echo $page_footer_copyright; ?>
\r
295 * Display the form for language select
\r
297 function show_select_locale_form()
\r
299 // Get the browser language that can be displayed
\r
300 // TODO: default locale select simple implementation
\r
301 $languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
\r
302 foreach ( $languages as $language )
\r
304 $language = preg_replace('#([\w]+).*#', '$1', $language);
\r
309 array('en_Latn_US', 'English - United States'),
\r
310 array('ja_Jpan_JP', 'Japanese - Japan')
\r
313 <div id="container">
\r
314 <p style="font-size:152%;font-weight:bold;">
\r
315 Select your locale:
\r
317 <form method="post" action="./index.php">
\r
320 <select name="locale">
\r
322 foreach ( $locales as $locale )
\r
324 echo "<option value=\"$locale[0]\"";
\r
325 if ( i18n::strpos($locale[0], $language) === 0 )
\r
329 echo ">$locale[1]</option>\n";
\r
334 <button type="submit" name="action" value="locale" class="sbt_arw">START</button>
\r
343 * Display the form to set up a database
\r
344 * @param bool $isPostback
\r
346 function show_database_setting_form($isPostback)
\r
348 global $param, $minimum_mysql_version;
\r
350 $config_writable = canConfigFileWritable();
\r
351 $mysql_version = getMySqlVersion();
\r
353 <div id="container">
\r
356 echo _SIMPLE_NAVI1;
\r
357 if ( $config_writable != '' )
\r
359 echo '<span class="err">', $config_writable, '</span>';
\r
361 if ( $mysql_version == '0.0.0' )
\r
363 echo '<span class="err">', _DBVERSION_UNKOWN, '</span>';
\r
365 elseif ( version_compare($mysql_version, $minimum_mysql_version, '<') )
\r
367 echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';
\r
371 <form method="post" action="./index.php">
\r
373 <h2><?php echo _DB_HEADER; ?></h2>
\r
378 $errors = $param->check_mysql_parameters();
\r
379 if ( is_array($errors) )
\r
381 foreach ( $errors as $error )
\r
383 echo '<span class="err">', $error, "</span>\n";
\r
391 <th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
\r
392 <td><input type="text" name="mysql_host" value="<?php echo $param->mysql_host; ?>" /></td>
\r
395 <th><span class="nam"><?php echo _DB_FIELD2; ?></span><span class="sub"><?php echo _DB_FIELD2_DESC; ?></span></th>
\r
396 <td><input type="text" name="mysql_user" value="<?php echo $param->mysql_user; ?>" /></td>
\r
399 <th><span class="nam"><?php echo _DB_FIELD3; ?></span></th>
\r
400 <td><input type="text" name="mysql_password" value="<?php echo $param->mysql_password; ?>" /></td>
\r
403 <th><span class="nam"><?php echo _DB_FIELD4; ?></span><span class="sub"><?php echo _DB_FIELD4_DESC; ?></span></th>
\r
404 <td><input type="text" name="mysql_database" value="<?php echo $param->mysql_database; ?>" /></td>
\r
408 <button type="submit" name="mode" value="detail" class="sbt_sqr"><?php echo _MODE2; ?></button>
\r
409 <button type="submit" name="action" value="mysql" class="sbt_arw"><?php echo _NEXT; ?></button>
\r
412 <?php echo _DB_TEXT1; ?>
\r
421 * Displays a form to the blog settings
\r
422 * @param bool $isPostback
\r
424 function show_blog_setting_form($isPostback)
\r
428 <div id="container">
\r
430 <?php echo _SIMPLE_NAVI2; ?>
\r
432 <form method="post" action="./index.php">
\r
434 <h2><?php echo _BLOG_HEADER; ?></h2>
\r
439 $errors = $param->check_weblog_parameters();
\r
440 if ( is_array($errors) )
\r
442 foreach ( $errors as $error )
\r
444 echo '<span class="err">', $error, "</span>\n";
\r
452 <th><span class="nam"><?php echo _BLOG_FIELD1; ?></span></th>
\r
453 <td><input type="text" name="blog_name" value="<?php echo $param->blog_name; ?>" /></td>
\r
456 <th><span class="nam"><?php echo _BLOG_FIELD2; ?></span><span class="sub"><?php echo _BLOG_FIELD2_DESC; ?></span></th>
\r
457 <td><input type="text" name="blog_shortname" value="<?php echo $param->blog_shortname; ?>" /></td>
\r
463 <h2><?php echo _ADMIN_HEADER; ?></h2>
\r
468 $errors = $param->check_user_parameters();
\r
469 if ( is_array($errors) )
\r
471 foreach ( $errors as $error )
\r
473 echo '<span class="err">', $error, "</span>\n";
\r
481 <th><span class="nam"><?php echo _ADMIN_FIELD1; ?></span></th>
\r
482 <td><input type="text" name="user_realname" value="<?php echo $param->user_realname; ?>" /></td>
\r
485 <th><span class="nam"><?php echo _ADMIN_FIELD2; ?></span><span class="sub"><?php echo _ADMIN_FIELD2_DESC; ?></span></th>
\r
486 <td><input type="text" name="user_name" value="<?php echo $param->user_name; ?>" /></td>
\r
489 <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span></th>
\r
490 <td><input type="password" name="user_password" /></td>
\r
493 <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span></th>
\r
494 <td><input type="password" name="user_password2" /></td>
\r
497 <th><span class="nam"><?php echo _ADMIN_FIELD5; ?></span></th>
\r
498 <td><input type="text" name="user_email" value="<?php echo $param->user_email; ?>" /></td>
\r
502 <button type="submit" name="action" value="weblog" class="sbt_arw" onclick="OnceSubmit()"><?php echo _INSTALL; ?></button>
\r
511 * Displays a form to the detail settings
\r
512 * @param bool $isPostback
\r
514 function show_detail_setting_form($isPostback)
\r
516 global $param, $minimum_mysql_version;
\r
518 $mysql_version = getMySqlVersion();
\r
520 <div id="container_detailed">
\r
522 <?php echo _DETAIL_NAVI1; ?>
\r
524 if ( $isPostback && !$param->check_all_parameters() )
\r
526 echo '<span class="err">', _VALID_ERROR, "</span>\n";
\r
531 <li>PHP: <?php echo phpversion(); ?></li>
\r
534 echo ($mysql_version == '0.0.0') ? _DBVERSION_UNKOWN : $mysql_version;
\r
535 if ( version_compare($mysql_version, $minimum_mysql_version, '<') )
\r
537 echo '<span class="err">', sprintf(_DBVERSION_TOOLOW, $minimum_mysql_version), '</span>';
\r
541 <form method="post" action="">
\r
544 <h2><?php echo _DETAIL_HEADER1; ?></h2>
\r
549 $errors = $param->check_mysql_parameters();
\r
550 if ( is_array($errors) )
\r
552 foreach ( $errors as $error )
\r
554 echo '<span class="err">', $error, "</span>\n";
\r
562 <th><span class="nam"><?php echo _DB_FIELD1; ?></span><span class="sub"><?php echo _DB_FIELD1_DESC; ?></span></th>
\r
563 <td><input type="text" name="mysql_host" value="<?php echo $param->mysql_host; ?>" /></td>
\r
566 <th><span class="nam"><?php echo _DB_FIELD2; ?></span><span class="sub"><?php echo _DB_FIELD2_DESC; ?></span></th>
\r
567 <td><input type="text" name="mysql_user" value="<?php echo $param->mysql_user; ?>" /></td>
\r
570 <th><span class="nam"><?php echo _DB_FIELD3; ?></span></th>
\r
571 <td><input type="text" name="mysql_password" value="<?php echo $param->mysql_password; ?>" /></td>
\r
574 <th><span class="nam"><?php echo _DB_FIELD4; ?></span><span class="sub"><?php echo _DB_FIELD4_DESC; ?></span></th>
\r
575 <td><input type="text" name="mysql_database" value="<?php echo $param->mysql_database; ?>" /></td>
\r
578 <th><span class="nam"><?php echo _DB_FIELD5; ?></span><span class="sub"><?php echo _DB_FIELD5_DESC; ?></span></th>
\r
579 <td><input type="text" name="mysql_tablePrefix" value="<?php echo $param->mysql_tablePrefix; ?>" /></td>
\r
583 <h2><?php echo _DETAIL_HEADER2; ?></h2>
\r
588 $errors = $param->check_uri_parameters();
\r
589 if ( is_array($errors) )
\r
591 foreach ( $errors as $error )
\r
593 echo '<span class="err">', $error, "</span>\n";
\r
596 $errors = $param->check_path_parameters();
\r
597 if ( is_array($errors) )
\r
599 foreach ( $errors as $error )
\r
601 echo '<span class="err">', $error, "</span>\n";
\r
609 <th><span class="nam"><?php echo _PATH_FIELD1; ?></span></th>
\r
610 <td><input type="text" name="IndexURL" value="<?php echo $param->IndexURL; ?>" /></td>
\r
613 <th><span class="nam"><?php echo _PATH_FIELD2; ?></span></th>
\r
614 <td><input type="text" name="AdminURL" value="<?php echo $param->AdminURL; ?>" /></td>
\r
617 <th><span class="nam"><?php echo _PATH_FIELD3; ?></span></th>
\r
618 <td><input type="text" name="AdminPath" value="<?php echo $param->AdminPath; ?>" /></td>
\r
621 <th><span class="nam"><?php echo _PATH_FIELD4; ?></span></th>
\r
622 <td><input type="text" name="MediaURL" value="<?php echo $param->MediaURL; ?>" /></td>
\r
625 <th><span class="nam"><?php echo _PATH_FIELD5; ?></span></th>
\r
626 <td><input type="text" name="MediaPath" value="<?php echo $param->MediaPath; ?>" /></td>
\r
629 <th><span class="nam"><?php echo _PATH_FIELD6; ?></span></th>
\r
630 <td><input type="text" name="SkinsURL" value="<?php echo $param->SkinsURL; ?>" /></td>
\r
633 <th><span class="nam"><?php echo _PATH_FIELD7; ?></span></th>
\r
634 <td><input type="text" name="SkinsPath" value="<?php echo $param->SkinsPath; ?>" /></td>
\r
637 <th><span class="nam"><?php echo _PATH_FIELD8; ?></span></th>
\r
638 <td><input type="text" name="PluginURL" value="<?php echo $param->PluginURL; ?>" /></td>
\r
641 <th><span class="nam"><?php echo _PATH_FIELD9; ?></span></th>
\r
642 <td><input type="text" name="ActionURL" value="<?php echo $param->ActionURL; ?>" /></td>
\r
646 <?php echo _DETAIL_TEXT3; ?>
\r
649 <h2><?php echo _DETAIL_HEADER3; ?></h2>
\r
652 echo _DETAIL_TEXT4;
\r
655 $errors = $param->check_user_parameters();
\r
656 if ( is_array($errors) )
\r
658 foreach ( $errors as $error )
\r
660 echo '<span class="err">', $error, "</span>\n";
\r
668 <th><span class="nam"><?php echo _ADMIN_FIELD1; ?></span></th>
\r
669 <td><input type="text" name="user_realname" value="<?php echo $param->user_realname; ?>" /></td>
\r
672 <th><span class="nam"><?php echo _ADMIN_FIELD2; ?></span><span class="sub"><?php echo _ADMIN_FIELD2_DESC; ?></span></th>
\r
673 <td><input type="text" name="user_name" value="<?php echo $param->user_name; ?>" /></td>
\r
676 <th><span class="nam"><?php echo _ADMIN_FIELD3; ?></span></th>
\r
677 <td><input type="password" name="user_password" /></td>
\r
680 <th><span class="nam"><?php echo _ADMIN_FIELD4; ?></span></th>
\r
681 <td><input type="password" name="user_password2" /></td>
\r
684 <th><span class="nam"><?php echo _ADMIN_FIELD5; ?></span></th>
\r
685 <td><input type="text" name="user_email" value="<?php echo $param->user_email; ?>" /></td>
\r
689 <h2><?php echo _DETAIL_HEADER4; ?></h2>
\r
692 echo _DETAIL_TEXT5;
\r
695 $errors = $param->check_weblog_parameters();
\r
696 if ( is_array($errors) )
\r
698 foreach ( $errors as $error )
\r
700 echo '<span class="err">', $error, "</span>\n";
\r
708 <th><span class="nam"><?php echo _BLOG_FIELD1; ?></span></th>
\r
709 <td><input type="text" name="blog_name" value="<?php echo $param->blog_name; ?>" /></td>
\r
712 <th><span class="nam"><?php echo _BLOG_FIELD2; ?></span><span class="sub"><?php echo _BLOG_FIELD2_DESC; ?></span></th>
\r
713 <td><input type="text" name="blog_shortname" value="<?php echo $param->blog_shortname; ?>" /></td>
\r
718 <?php echo _DETAIL_TEXT6; ?>
\r
722 <button type="submit" name="action" value="detail" class="sbt_arw" onclick="OnceSubmit()"><?php echo _INSTALL; ?></button>
\r
731 * Displays a screen to signal the completion of the installation
\r
733 function show_install_complete_form()
\r
735 global $MYSQL_HANDLER, $param;
\r
736 $errors = do_install();
\r
738 <div id="container">
\r
741 if ( is_array($errors) && count($errors) > 0 )
\r
744 foreach ( $errors as $error )
\r
746 echo '<span class="err">', $error, "</span>\n";
\r
752 if ( array_key_exists('config_data', $_SESSION) )
\r
754 echo '<span class="err">', _INST_TEXT4, '</span>';
\r
756 <textarea id="config_text" readonly="readonly" onfocus="SelectText(this);"><?php echo htmlentities($_SESSION['config_data'], null, i18n::get_current_charset()) ?></textarea>
\r
761 echo '<span class="err">', _INST_TEXT5, '</span>';
\r
765 <form method="post" action="./index.php">
\r
767 <h2><?php echo _INST_HEADER1; ?></h2>
\r
769 <?php echo sprintf(_INST_TEXT1, $param->blog_name); ?>
\r
772 <button type="button" name="toBlog" onclick="location.href='<?php echo $param->IndexURL; ?>';" class="sbt_arw"><?php echo _INST_BUTTON1; ?></button>
\r
777 <h2><?php echo _INST_HEADER2; ?></h2>
\r
779 <?php echo _INST_TEXT2; ?>
\r
782 <button type="button" name="toMng" onclick="location.href='<?php echo $param->AdminURL; ?>';" class="sbt_arw"><?php echo _INST_BUTTON2; ?></button>
\r
787 <h2><?php echo _INST_HEADER3; ?></h2>
\r
789 <?php echo _INST_TEXT3; ?>
\r
792 <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
805 * The installation process itself
\r
806 * @return array error messages
\r
808 function do_install()
\r
811 global $MYSQL_HANDLER, $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX, $MYSQL_CONN;
\r
812 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
816 * 1. put all param-vars into vars
\r
818 $MYSQL_HOST = $param->mysql_host;
\r
819 $MYSQL_USER = $param->mysql_user;
\r
820 $MYSQL_PASSWORD = $param->mysql_password;
\r
821 $MYSQL_DATABASE = $param->mysql_database;
\r
822 $MYSQL_PREFIX = $param->mysql_tablePrefix;
\r
824 $DIR_NUCLEUS = $param->AdminPath;
\r
825 $DIR_MEDIA = $param->MediaPath;
\r
826 $DIR_SKINS = $param->SkinsPath;
\r
827 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
828 $DIR_LOCALES = $DIR_NUCLEUS . 'locales/';
\r
829 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
832 * 2.open mySQL connection
\r
834 $MYSQL_CONN = @DB::setConnectionInfo($MYSQL_HANDLER[1], $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD);
\r
835 if ( $MYSQL_CONN == FALSE )
\r
837 $errors[] = _DBCONNECT_ERROR;
\r
842 * 3. try to create database if needed
\r
844 if ( DB::execute("CREATE DATABASE IF NOT EXISTS {$MYSQL_DATABASE}") === FALSE )
\r
846 $errinfo = DB::getError();
\r
847 $errors[] = _INST_ERROR1 . ': ' . $errinfo[2];
\r
851 * 4. try to select database
\r
853 $MYSQL_CONN = @DB::setConnectionInfo($MYSQL_HANDLER[1], $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE);
\r
854 if ( !$MYSQL_CONN )
\r
856 $errors[] = _INST_ERROR2;
\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 = DB::getResult('SHOW TABLES');
\r
893 foreach ( $result as $row )
\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 ( DB::execute($query) === FALSE )
\r
924 $errinfo = DB::getError();
\r
925 $errors[] = _INST_ERROR4 . ' (<small>' . $query . '</small>): ' . $errinfo[2];
\r
931 * 6. put needed records
\r
933 /* push first post */
\r
934 $query = "INSERT INTO %s VALUES (1, %s, %s, %s, 1, 1, '%s', 0, 0, 0, 1, 0, 1)";
\r
935 $query = sprintf($query,
\r
936 tableName('nucleus_item'),
\r
937 DB::quoteValue(_1ST_POST_TITLE),
\r
938 DB::quoteValue(_1ST_POST),
\r
939 DB::quoteValue(_1ST_POST2),
\r
940 DB::formatDateTime(time())
\r
942 if ( DB::execute($query) === FALSE )
\r
944 $errinfo = DB::getError();
\r
945 $errors[] = _INST_ERROR4 . ' (<small>' . $newpost . '</small>): ' . $errinfo[2];
\r
948 /* push configurations */
\r
949 array_merge($errors, updateConfig('IndexURL', $param->IndexURL));
\r
950 array_merge($errors, updateConfig('AdminURL', $param->AdminURL));
\r
951 array_merge($errors, updateConfig('MediaURL', $param->MediaURL));
\r
952 array_merge($errors, updateConfig('SkinsURL', $param->SkinsURL));
\r
953 array_merge($errors, updateConfig('PluginURL', $param->PluginURL));
\r
954 array_merge($errors, updateConfig('ActionURL', $param->ActionURL));
\r
955 array_merge($errors, updateConfig('AdminEmail', $param->user_email));
\r
956 array_merge($errors, updateConfig('SiteName', $param->blog_name));
\r
957 array_merge($errors, updateConfig('Locale', i18n::get_current_locale()));
\r
959 /* push super admin */
\r
960 $query = "UPDATE %s SET mname = %s, mrealname = %s, mpassword = %s, memail = %s, murl = %s, madmin = 1, mcanlogin = 1 WHERE mnumber = 1";
\r
961 $query = sprintf($query,
\r
962 tableName('nucleus_member'),
\r
963 DB::quoteValue($param->user_name),
\r
964 DB::quoteValue($param->user_realname),
\r
965 DB::quoteValue(md5($param->user_password)),
\r
966 DB::quoteValue($param->user_email),
\r
967 DB::quoteValue($param->IndexURL)
\r
969 if ( DB::execute($query) === FALSE )
\r
971 $errinfo = DB::getError();
\r
972 $errors[] = _INST_ERROR5 . ': ' . $errinfo[2];
\r
975 /* push new weblog */
\r
976 $query = "UPDATE %s SET bname = %s, bshortname = %s, burl = %s WHERE bnumber = 1";
\r
977 $query = sprintf($query,
\r
978 tableName('nucleus_blog'),
\r
979 DB::quoteValue($param->blog_name),
\r
980 DB::quoteValue($param->blog_shortname),
\r
981 DB::quoteValue($param->IndexURL)
\r
983 if ( DB::execute($query) === FALSE )
\r
985 $errinfo = DB::getError();
\r
986 $errors[] = _INST_ERROR6 . ': ' . $errinfo[2];
\r
989 /* push default category */
\r
990 $query = "UPDATE %s SET cname = '%s', cdesc = '%s' WHERE catid = 1";
\r
991 $query = sprintf($query,
\r
992 tableName('nucleus_category'),
\r
993 DB::quoteValue(_GENERALCAT_NAME),
\r
994 DB::quoteValue(_GENERALCAT_DESC)
\r
996 if ( DB::execute($query) === FALSE )
\r
998 $errinfo = DB::getError();
\r
999 $errors[] = _INST_ERROR6 . ': ' . $errinfo[2];
\r
1003 * 7. install default plugins and skins
\r
1005 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
1006 $aSkinErrors = array();
\r
1007 $aPlugErrors = array();
\r
1009 if ( (count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) )
\r
1011 include_once($DIR_LIBS . 'globalfunctions.php');
\r
1013 if ( !isset($manager) )
\r
1015 $manager = new Manager();
\r
1018 include_once($DIR_LIBS . 'skinie.php');
\r
1020 $aSkinErrors = installCustomSkins();
\r
1021 if ( count($aSkinErrors) > 0 )
\r
1023 array_merge($errors, $aSkinErrors);
\r
1026 $query = "SELECT sdnumber FROM %s WHERE sdname='default'";
\r
1027 $query = sprintf($query, tableName('nucleus_skin_desc'));
\r
1028 $defSkinID = intval(DB::getValue($query));
\r
1030 $query = "UPDATE %s SET bdefskin=%d WHERE bnumber=1";
\r
1031 $query = sprintf($query, tableName('nucleus_blog'), $defSkinID);
\r
1032 DB::execute($query);
\r
1033 $query = "UPDATE %s SET value=%d WHERE name='BaseSkin'";
\r
1034 $query = sprintf($query, tableName('nucleus_config'), $defSkinID);
\r
1035 DB::execute($query);
\r
1037 $aPlugErrors = installCustomPlugs();
\r
1038 if ( count($aPlugErrors) > 0 )
\r
1040 array_merge($errors, $aPlugErrors);
\r
1045 * 8. Write config file ourselves (if possible)
\r
1047 $config_data = '<' . '?php' . "\n";
\r
1048 $config_data .= "// mySQL connection information\n";
\r
1049 $config_data .= "\$MYSQL_HOST = '" . $MYSQL_HOST . "';\n";
\r
1050 $config_data .= "\$MYSQL_USER = '" . $MYSQL_USER . "';\n";
\r
1051 $config_data .= "\$MYSQL_PASSWORD = '" . $MYSQL_PASSWORD . "';\n";
\r
1052 $config_data .= "\$MYSQL_DATABASE = '" . $MYSQL_DATABASE . "';\n";
\r
1053 $config_data .= "\$MYSQL_PREFIX = '" . $MYSQL_PREFIX . "';\n";
\r
1054 $config_data .= "// new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
\r
1055 $config_data .= "// default is \$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
1056 $config_data .= "//\$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
1057 $config_data .= "//\$MYSQL_HANDLER = array('pdo','mysql');\n";
\r
1058 $config_data .= "\$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n";
\r
1059 $config_data .= "\n";
\r
1060 $config_data .= "// main nucleus directory\n";
\r
1061 $config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n";
\r
1062 $config_data .= "\n";
\r
1063 $config_data .= "// path to media dir\n";
\r
1064 $config_data .= "\$DIR_MEDIA = '" . $DIR_MEDIA . "';\n";
\r
1065 $config_data .= "\n";
\r
1066 $config_data .= "// extra skin files for imported skins\n";
\r
1067 $config_data .= "\$DIR_SKINS = '" . $DIR_SKINS . "';\n";
\r
1068 $config_data .= "\n";
\r
1069 $config_data .= "// these dirs are normally sub dirs of the nucleus dir, but \n";
\r
1070 $config_data .= "// you can redefine them if you wish\n";
\r
1071 $config_data .= "\$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
1072 $config_data .= "\$DIR_LOCALES = \$DIR_NUCLEUS . 'locales/';\n";
\r
1073 $config_data .= "\$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
1074 $config_data .= "\n";
\r
1075 $config_data .= "// include libs\n";
\r
1076 $config_data .= "include(\$DIR_LIBS.'globalfunctions.php');\n";
\r
1077 $config_data .= "?" . ">";
\r
1080 if ( @!file_exists('../config.php') || is_writable('../config.php') )
\r
1082 if ( $fp = @fopen('../config.php', 'w') )
\r
1084 $result = @fwrite($fp, $config_data, i18n::strlen($config_data));
\r
1091 // try to change the read-only permission.
\r
1092 if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
\r
1094 @chmod('../config.php', 0444);
\r
1099 $_SESSION['config_data'] = $config_data;
\r
1106 * Confirm that you can write to the configuration file
\r
1107 * @return string error message
\r
1109 function canConfigFileWritable()
\r
1111 if ( @file_exists('../config.php') && @!is_writable('../config.php') )
\r
1113 // try to change the read-write permission.
\r
1114 if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
\r
1116 @chmod('../config.php', 0666);
\r
1119 if ( @!is_writable('../config.php') )
\r
1121 return _INST_ERROR8;
\r
1128 * To obtain the version of MySQL
\r
1131 function getMySqlVersion()
\r
1133 global $MYSQL_HANDLER, $minimum_mysql_version, $errors;
\r
1134 // Turn on output buffer
\r
1135 // Needed to repress the output of the sql function that are
\r
1136 // not part of php (in this case the @ operator doesn't work)
\r
1139 // note: this piece of code is taken from phpMyAdmin
\r
1140 $conn = @DB::setConnectionInfo($MYSQL_HANDLER[1], 'localhost', '', '');
\r
1144 $row = DB::getAttribute(PDO::ATTR_SERVER_VERSION);
\r
1145 $match = preg_split('#\.#', $row);
\r
1149 $row = @DB::getRow('SHOW VARIABLES LIKE \'version\'');
\r
1153 $match = preg_split('#\.#', $row[1]);
\r
1157 $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
\r
1158 preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
\r
1159 $match = preg_split('#\.#', $version[0]);
\r
1161 if ( $match[0] == '' )
\r
1163 $match = array('0', '0', '0');
\r
1168 @DB::disConnect();
\r
1170 //End and clean output buffer
\r
1173 return implode($match, '.');
\r
1177 * Add a table prefix if it is used
\r
1179 * @param string $input table name with prefix
\r
1182 function tableName($input)
\r
1184 global $MYSQL_PREFIX;
\r
1185 if ( $MYSQL_PREFIX )
\r
1187 return $MYSQL_PREFIX . $input;
\r
1196 * Install custom plugins
\r
1198 function installCustomPlugs()
\r
1200 global $aConfPlugsToInstall, $DIR_LIBS, $manager;
\r
1202 $aErrors = array();
\r
1203 if ( count($aConfPlugsToInstall) == 0 )
\r
1208 $query = sprintf('SELECT * FROM %s', tableName('nucleus_plugin'));
\r
1209 $res = DB::getResult($query);
\r
1210 $numCurrent = $res->rowCount();
\r
1212 foreach ( $aConfPlugsToInstall as $plugName )
\r
1214 $query = sprintf('INSERT INTO %s (porder, pfile) VALUES (%d, %s)',
\r
1215 tableName('nucleus_plugin'),
\r
1217 DB::quoteValue($plugName));
\r
1218 DB::execute($query);
\r
1220 $manager->clearCachedInfo('installedPlugins');
\r
1221 $plugin =& $manager->getPlugin($plugName);
\r
1222 $plugin->setID($numCurrent);
\r
1226 $query = sprintf('DELETE FROM %s WHERE pfile = %s',
\r
1227 tableName('nucleus_plugin'),
\r
1228 DB::quoteValue($plugName));
\r
1229 DB::execute($query);
\r
1231 array_push($aErrors, sprintf(_INST_ERROR9, $plugName));
\r
1234 $plugin->install();
\r
1237 $query = sprintf('DELETE FROM %s', tableName('nucleus_plugin_event'));
\r
1238 DB::execute($query);
\r
1239 $query = sprintf('SELECT pid, pfile FROM %s', tableName('nucleus_plugin'));
\r
1240 $res = DB::getResult($query);
\r
1242 foreach ( $res as $row )
\r
1244 $plug =& $manager->getPlugin($row['pfile']);
\r
1248 $eventList = $plug->getEventList();
\r
1249 foreach ( $eventList as $eventName )
\r
1251 $query = sprintf('INSERT INTO %s (pid, event) VALUES (%d, %s)',
\r
1252 tableName('nucleus_plugin_event'),
\r
1253 intval($row['pid']),
\r
1254 DB::quoteValue($eventName));
\r
1255 DB::execute($query);
\r
1263 * Install custom skins
\r
1264 * Prepares the installation of custom skins
\r
1266 function installCustomSkins()
\r
1268 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1270 $aErrors = array();
\r
1271 if ( count($aConfSkinsToImport) == 0 )
\r
1276 $importer = new SkinImport();
\r
1278 foreach ( $aConfSkinsToImport as $skinName )
\r
1280 $importer->reset();
\r
1281 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1283 if ( !@file_exists($skinFile) )
\r
1285 array_push($aErrors, sprintf(_INST_ERROR10, $skinFile));
\r
1289 $error = $importer->readFile($skinFile);
\r
1293 array_push($aErrors, sprintf(_INST_ERROR11, $skinName) . ' : ' . $error);
\r
1297 $error = $importer->writeToDatabase(1);
\r
1301 array_push($aErrors, sprintf(_INST_ERROR12, $skinName) . ' : ' . $error);
\r
1309 * Check if some important files of the Nucleus CMS installation are available
\r
1310 * Give an error if one or more files are not accessible
\r
1312 function do_check_files()
\r
1314 $missingfiles = array();
\r
1319 '../nucleus/index.php',
\r
1320 '../nucleus/media.php',
\r
1321 '../nucleus/libs/ACTION.php',
\r
1322 '../nucleus/libs/ACTIONLOG.php',
\r
1323 '../nucleus/libs/ACTIONS.php',
\r
1324 '../nucleus/libs/ADMIN.php',
\r
1325 '../nucleus/libs/BaseActions.php',
\r
1326 '../nucleus/libs/BLOG.php',
\r
1327 '../nucleus/libs/BODYACTIONS.php',
\r
1328 '../nucleus/libs/COMMENT.php',
\r
1329 '../nucleus/libs/COMMENTACTIONS.php',
\r
1330 '../nucleus/libs/COMMENTS.php',
\r
1331 '../nucleus/libs/ENCAPSULATE.php',
\r
1332 '../nucleus/libs/ENTITY.php',
\r
1333 '../nucleus/libs/globalfunctions.php',
\r
1334 '../nucleus/libs/i18n.php',
\r
1335 '../nucleus/libs/ITEM.php',
\r
1336 '../nucleus/libs/ITEMACTIONS.php',
\r
1337 '../nucleus/libs/LINK.php',
\r
1338 '../nucleus/libs/MANAGER.php',
\r
1339 '../nucleus/libs/MEDIA.php',
\r
1340 '../nucleus/libs/MEMBER.php',
\r
1341 '../nucleus/libs/NOTIFICATION.php',
\r
1342 '../nucleus/libs/PAGEFACTORY.php',
\r
1343 '../nucleus/libs/PARSER.php',
\r
1344 '../nucleus/libs/PLUGIN.php',
\r
1345 '../nucleus/libs/PLUGINADMIN.php',
\r
1346 '../nucleus/libs/SEARCH.php',
\r
1347 '../nucleus/libs/showlist.php',
\r
1348 '../nucleus/libs/SKIN.php',
\r
1349 '../nucleus/libs/TEMPLATE.php',
\r
1350 '../nucleus/libs/vars4.1.0.php',
\r
1351 '../nucleus/libs/xmlrpc.inc.php',
\r
1352 '../nucleus/libs/xmlrpcs.inc.php',
\r
1353 '../nucleus/libs/data/DB.php',
\r
1354 '../nucleus/libs/data/MYSQLPDO.php'
\r
1357 $count = count($files);
\r
1358 for ( $i = 0; $i < $count; $i++ )
\r
1360 if ( !is_readable($files[$i]) )
\r
1362 array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');
\r
1366 if ( count($missingfiles) > 0 )
\r
1368 exit(implode("\n", $missingfiles));
\r
1373 * Updates the configuration in the database
\r
1375 * @param string $name name of the config var
\r
1376 * @param string $value new value of the config var
\r
1379 function updateConfig($name, $value)
\r
1381 $errors = array();
\r
1383 $query = "UPDATE %s SET value = %s WHERE name = %s";
\r
1384 $query = sprintf($query, tableName('nucleus_config'), DB::quoteValue(trim($value)), DB::quoteValue($name));
\r
1386 if ( DB::execute($query) === FALSE )
\r
1388 $errinfo = DB::getError();
\r
1389 $errors[] = _INST_ERROR4 . ': ' . $errinfo[2];
\r
1394 class ParamManager
\r
1396 /* process parameter */
\r
1400 /* mysql connection parameters */
\r
1401 public $mysql_host;
\r
1402 public $mysql_user;
\r
1403 public $mysql_password;
\r
1404 public $mysql_database;
\r
1405 public $mysql_tablePrefix;
\r
1407 /* weblog configuration parameters */
\r
1408 public $blog_name;
\r
1409 public $blog_shortname;
\r
1411 /* member configuration parameters */
\r
1412 public $user_name;
\r
1413 public $user_realname;
\r
1414 public $user_password;
\r
1415 private $user_password2;
\r
1416 public $user_email;
\r
1418 /* URI parameters */
\r
1419 private $root_url;
\r
1424 public $PluginURL;
\r
1425 public $ActionURL;
\r
1427 /* path parameters */
\r
1428 private $root_path;
\r
1429 public $AdminPath;
\r
1430 public $MediaPath;
\r
1431 public $SkinsPath;
\r
1436 public function __construct()
\r
1441 public function init()
\r
1443 // set default values
\r
1444 $this->state = 'locale';
\r
1445 $this->install_mode = 'simple';
\r
1446 $this->locale = 'en_Latn_US';
\r
1447 $this->mysql_host = @ini_get('mysql.default_host');
\r
1448 $this->blog_name = 'My Nucleus CMS';
\r
1449 $this->blog_shortname = 'mynucleuscms';
\r
1452 $directory_separator = preg_quote(DIRECTORY_SEPARATOR, '|');
\r
1453 $this->root_path = implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__) . '/..')));
\r
1454 if ( substr($this->root_path, -1, 1) !== '/' )
\r
1456 $this->root_path .= '/';
\r
1458 $base_path_pcre = preg_quote($this->root_path, '|');
\r
1460 /* current directry name */
\r
1461 $directory_name = preg_replace("#{$base_path_pcre}#", '', implode('/', preg_split("#{$directory_separator}#", realpath(dirname(__FILE__)))));
\r
1462 $directory_name_pcre = preg_quote($directory_name, '|');
\r
1465 $root_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
\r
1466 $this->root_url = preg_replace("|$directory_name_pcre(.*)$|", '', $root_url);
\r
1468 $this->AdminPath = $this->root_path . 'nucleus/';
\r
1469 $this->MediaPath = $this->root_path . 'media/';
\r
1470 $this->SkinsPath = $this->root_path . 'skins/';
\r
1472 $this->IndexURL = $this->root_url;
\r
1473 $this->AdminURL = $this->root_url . 'nucleus/';
\r
1474 $this->MediaURL = $this->root_url . 'media/';
\r
1475 $this->SkinsURL = $this->root_url . 'skins/';
\r
1476 $this->PluginURL = $this->root_url . 'nucleus/plugins/';
\r
1477 $this->ActionURL = $this->root_url . 'action.php';
\r
1480 private function read_parameter($parameter)
\r
1482 foreach ( $parameter as $element )
\r
1484 if ( array_key_exists($element, $_POST) )
\r
1486 $this->$element = $_POST[$element];
\r
1491 public function set_state($state)
\r
1493 $states = array('locale', 'mysql', 'weblog', 'detail', 'install');
\r
1494 if ( in_array($state, $states) )
\r
1496 $this->state = $state;
\r
1500 public function set_locale()
\r
1502 $this->read_parameter(array('locale'));
\r
1504 if ( !in_array($this->locale, i18n::get_available_locale_list()) )
\r
1506 $this->locale = 'en_Latn_US';
\r
1510 public function check_mysql_parameters()
\r
1512 global $MYSQL_HANDLER;
\r
1514 $parameters = array('mysql_host', 'mysql_user', 'mysql_password', 'mysql_database', 'mysql_tablePrefix');
\r
1515 $this->read_parameter($parameters);
\r
1517 $errors = array();
\r
1518 if ( $this->mysql_host == '' )
\r
1520 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD1);
\r
1523 if ( $this->mysql_user == '' )
\r
1525 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD2);
\r
1528 if ( $this->mysql_user != ''
\r
1529 && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_user) )
\r
1531 $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD2);
\r
1534 if ( $this->mysql_database == '' )
\r
1536 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD4);
\r
1539 if ( $this->mysql_database != ''
\r
1540 && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_database) )
\r
1542 $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD4);
\r
1545 if ( $this->mysql_tablePrefix != ''
\r
1546 && !preg_match('/^[a-z0-9_]+$/i', $this->mysql_tablePrefix) )
\r
1548 $errors[] = sprintf(_VALID_ERROR3, _DB_FIELD5);
\r
1551 if ( count($errors) == 0 )
\r
1553 $mysql_conn = @DB::setConnectionInfo($MYSQL_HANDLER[1], $this->mysql_host, $this->mysql_user, $this->mysql_password);
\r
1554 if ( $mysql_conn == false )
\r
1556 $errors[] = _DBCONNECT_ERROR;
\r
1560 @DB::disConnect();
\r
1567 public function check_user_parameters()
\r
1569 $parameters = array('user_name', 'user_realname', 'user_password', 'user_password2', 'user_email');
\r
1570 $this->read_parameter($parameters);
\r
1572 $errors = array();
\r
1573 if ( $this->user_realname == '' )
\r
1575 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD1);
\r
1578 if ( $this->user_name == '' )
\r
1580 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD2);
\r
1582 elseif ( !preg_match("/^[a-z0-9]+([ a-z0-9]*[a-z0-9]+)?$/i", $this->user_name) )
\r
1584 $errors[] = _VALID_ERROR5;
\r
1587 if ( $this->user_password == '' || $this->user_password2 == '' )
\r
1589 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD3);
\r
1590 $this->user_password = '';
\r
1592 elseif ( $this->user_password != $this->user_password2 )
\r
1594 $errors[] = _VALID_ERROR6;
\r
1595 $this->user_password = '';
\r
1598 if ( !preg_match("/^[a-z0-9\._+\-]+@[a-z0-9\._\-]+\.[a-z]{2,6}$/i", $this->user_email) )
\r
1600 $errors[] = _VALID_ERROR7;
\r
1606 public function check_weblog_parameters()
\r
1608 $parameters = array('blog_name', 'blog_shortname');
\r
1609 $this->read_parameter($parameters);
\r
1611 $errors = array();
\r
1612 if ( $this->blog_name == '' )
\r
1614 $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD1);
\r
1617 if ( $this->blog_shortname == '' )
\r
1619 $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD2);
\r
1622 if ( !preg_match("/^[a-z0-9]+$/i", $this->blog_shortname) )
\r
1624 $errors[] = _VALID_ERROR4;
\r
1630 public function check_uri_parameters()
\r
1632 $parameters = array('IndexURL', 'AdminURL', 'MediaURL', 'SkinsURL', 'PluginURL', 'ActionURL');
\r
1633 $this->read_parameter($parameters);
\r
1635 $errors = array();
\r
1636 if ( substr($this->IndexURL, -1, 1) !== '/' )
\r
1638 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD1);
\r
1641 if ( substr($this->AdminURL, -1, 1) !== '/' )
\r
1643 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD2);
\r
1646 if ( substr($this->MediaURL, -1, 1) !== '/' )
\r
1648 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD4);
\r
1651 if ( substr($this->SkinsURL, -1, 1) !== '/' )
\r
1653 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD6);
\r
1656 if ( substr($this->PluginURL, -1, 1) !== '/' )
\r
1658 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD8);
\r
1661 if ( strrchr($this->ActionURL, '/') != '/action.php' )
\r
1663 $errors[] = sprintf(_VALID_ERROR9, _PATH_FIELD9);
\r
1669 public function check_path_parameters()
\r
1671 $parameters = array('AdminPath', 'MediaPath', 'SkinsPath');
\r
1672 $this->read_parameter($parameters);
\r
1674 $separators = array('/', DIRECTORY_SEPARATOR);
\r
1675 $errors = array();
\r
1676 if ( !in_array(substr($this->AdminPath, -1, 1), $separators) )
\r
1678 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD3);
\r
1680 elseif ( !file_exists($this->AdminPath) )
\r
1682 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD3);
\r
1685 if ( !in_array(substr($this->MediaPath, -1, 1), $separators) )
\r
1687 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD5);
\r
1689 elseif ( !file_exists($this->MediaPath) )
\r
1691 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD5);
\r
1694 if ( !in_array(substr($this->SkinsPath, -1, 1), $separators) )
\r
1696 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD7);
\r
1698 elseif ( !file_exists($this->SkinsPath) )
\r
1700 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD7);
\r
1707 * check all parameters
\r
1710 public function check_all_parameters()
\r
1712 $this->set_locale();
\r
1715 $isValid &= (count($this->check_mysql_parameters()) == 0);
\r
1716 $isValid &= (count($this->check_user_parameters()) == 0);
\r
1717 $isValid &= (count($this->check_weblog_parameters()) == 0);
\r
1718 $isValid &= (count($this->check_uri_parameters()) == 0);
\r
1719 $isValid &= (count($this->check_path_parameters()) == 0);
\r