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
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
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 && 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_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 = @sql_connect_args($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 ( !sql_query("CREATE DATABASE IF NOT EXISTS {$MYSQL_DATABASE}") )
\r
846 $errors[] = _INST_ERROR1 . ': ' . sql_error();
\r
850 * 4. try to select database
\r
852 if ( !sql_select_db($MYSQL_DATABASE) )
\r
854 $errors[] = _INST_ERROR2;
\r
856 sql_set_charset('utf8');
\r
858 if ( count($errors) > 0 )
\r
864 * 5. execute queries
\r
866 $table_names = array(
\r
867 'nucleus_actionlog',
\r
870 'nucleus_category',
\r
878 'nucleus_template',
\r
880 'nucleus_activation',
\r
884 $prefixed_table_names = array();
\r
885 foreach ( $table_names as $table_name )
\r
887 $prefixed_table_names[] = $MYSQL_PREFIX . $table_name;
\r
890 // table exists check
\r
891 $result = sql_query('SHOW TABLES');
\r
892 while ( $row = mysql_fetch_array($result, MYSQL_NUM) )
\r
894 if ( in_array($row[0], $prefixed_table_names) )
\r
896 $errors[] = _INST_ERROR3;
\r
900 if ( count($errors) > 0 )
\r
905 $filename = 'install.sql';
\r
906 $fd = fopen($filename, 'r');
\r
907 $queries = fread($fd, filesize($filename));
\r
910 $queries = preg_split('#(;\n|;\r)#', $queries);
\r
912 foreach ( $queries as $query )
\r
914 if ( preg_match('/\w+/', $query) )
\r
916 if ( $MYSQL_PREFIX )
\r
918 $query = str_replace($table_names, $prefixed_table_names, $query);
\r
921 if ( !sql_query($query) )
\r
923 $errors[] = _INST_ERROR4 . ' (<small>' . $query . '</small>): ' . sql_error();
\r
929 * 6. put needed records
\r
931 /* push first post */
\r
932 $query = "INSERT INTO %s VALUES (1, '%s', '%s', '%s', 1, 1, '%s', 0, 0, 0, 1, 0, 1)";
\r
933 $query = sprintf($query, tableName('nucleus_item'), _1ST_POST_TITLE, _1ST_POST, _1ST_POST2, i18n::formatted_datetime('mysql', time()));
\r
934 if ( !sql_query($query) )
\r
936 $errors[] = _INST_ERROR4 . ' (<small>' . $newpost . '</small>): ' . sql_error();
\r
939 /* push configurations */
\r
940 array_merge($errors, updateConfig('IndexURL', $param->IndexURL));
\r
941 array_merge($errors, updateConfig('AdminURL', $param->AdminURL));
\r
942 array_merge($errors, updateConfig('MediaURL', $param->MediaURL));
\r
943 array_merge($errors, updateConfig('SkinsURL', $param->SkinsURL));
\r
944 array_merge($errors, updateConfig('PluginURL', $param->PluginURL));
\r
945 array_merge($errors, updateConfig('ActionURL', $param->ActionURL));
\r
946 array_merge($errors, updateConfig('AdminEmail', $param->user_email));
\r
947 array_merge($errors, updateConfig('SiteName', $param->blog_name));
\r
948 array_merge($errors, updateConfig('Locale', i18n::get_current_locale()));
\r
950 /* escape strings for SQL */
\r
951 $user_name = sql_real_escape_string($param->user_name);
\r
952 $user_realname = sql_real_escape_string($param->user_realname);
\r
953 $user_password = sql_real_escape_string(md5($param->user_password));
\r
954 $user_email = sql_real_escape_string($param->user_email);
\r
955 $blog_name = sql_real_escape_string($param->blog_name);
\r
956 $blog_shortname = sql_real_escape_string($param->blog_shortname);
\r
957 $config_indexurl = sql_real_escape_string($param->IndexURL);
\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, tableName('nucleus_member'), $user_name, $user_realname, $user_password, $user_email, $config_indexurl);
\r
962 if ( !sql_query($query) )
\r
964 $errors[] = _INST_ERROR5 . ': ' . sql_error();
\r
967 /* push new weblog */
\r
968 $query = "UPDATE %s SET bname = '%s', bshortname = '%s', burl = '%s' WHERE bnumber = 1";
\r
969 $query = sprintf($query, tableName('nucleus_blog'), $blog_name, $blog_shortname, $config_indexurl);
\r
970 if ( !sql_query($query) )
\r
972 $errors[] = _INST_ERROR6 . ': ' . sql_error();
\r
975 /* push default category */
\r
976 $query = "UPDATE %s SET cname = '%s', cdesc = '%s' WHERE catid = 1";
\r
977 $query = sprintf($query, tableName('nucleus_category'), _GENERALCAT_NAME, _GENERALCAT_DESC);
\r
978 if ( !sql_query($query) )
\r
980 $errors[] = _INST_ERROR6 . ': ' . sql_error();
\r
986 * 7. install default plugins and skins
\r
988 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
989 $aSkinErrors = array();
\r
990 $aPlugErrors = array();
\r
992 if ( (count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) )
\r
994 include_once($DIR_LIBS . 'globalfunctions.php');
\r
996 if ( !isset($manager) )
\r
998 $manager = new Manager();
\r
1001 include_once($DIR_LIBS . 'skinie.php');
\r
1003 $aSkinErrors = installCustomSkins();
\r
1004 if ( count($aSkinErrors) > 0 )
\r
1006 array_merge($errors, $aSkinErrors);
\r
1009 $query = "SELECT sdnumber FROM %s WHERE sdname='default'";
\r
1010 $query = sprintf($query, tableName('nucleus_skin_desc'));
\r
1011 $res = sql_query($query);
\r
1012 $obj = sql_fetch_assoc($res);
\r
1013 $defSkinID = (integer) $obj['sdnumber'];
\r
1015 $query = "UPDATE %s SET bdefskin=%d WHERE bnumber=1";
\r
1016 $query = sprintf($query, tableName('nucleus_blog'), $defSkinID);
\r
1017 sql_query($query);
\r
1018 $query = "UPDATE %s SET value=%d WHERE name='BaseSkin'";
\r
1019 $query = sprintf($query, tableName('nucleus_config'), $defSkinID);
\r
1020 sql_query($query);
\r
1022 $aPlugErrors = installCustomPlugs();
\r
1023 if ( count($aPlugErrors) > 0 )
\r
1025 array_merge($errors, $aPlugErrors);
\r
1030 * 8. Write config file ourselves (if possible)
\r
1032 $config_data = '<' . '?php' . "\n";
\r
1033 $config_data .= "// mySQL connection information\n";
\r
1034 $config_data .= "\$MYSQL_HOST = '" . $MYSQL_HOST . "';\n";
\r
1035 $config_data .= "\$MYSQL_USER = '" . $MYSQL_USER . "';\n";
\r
1036 $config_data .= "\$MYSQL_PASSWORD = '" . $MYSQL_PASSWORD . "';\n";
\r
1037 $config_data .= "\$MYSQL_DATABASE = '" . $MYSQL_DATABASE . "';\n";
\r
1038 $config_data .= "\$MYSQL_PREFIX = '" . $MYSQL_PREFIX . "';\n";
\r
1039 $config_data .= "// new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
\r
1040 $config_data .= "// default is \$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
1041 $config_data .= "//\$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
1042 $config_data .= "//\$MYSQL_HANDLER = array('pdo','mysql');\n";
\r
1043 $config_data .= "\$MYSQL_HANDLER = array('" . $MYSQL_HANDLER[0] . "','" . $MYSQL_HANDLER[1] . "');\n";
\r
1044 $config_data .= "\n";
\r
1045 $config_data .= "// main nucleus directory\n";
\r
1046 $config_data .= "\$DIR_NUCLEUS = '" . $DIR_NUCLEUS . "';\n";
\r
1047 $config_data .= "\n";
\r
1048 $config_data .= "// path to media dir\n";
\r
1049 $config_data .= "\$DIR_MEDIA = '" . $DIR_MEDIA . "';\n";
\r
1050 $config_data .= "\n";
\r
1051 $config_data .= "// extra skin files for imported skins\n";
\r
1052 $config_data .= "\$DIR_SKINS = '" . $DIR_SKINS . "';\n";
\r
1053 $config_data .= "\n";
\r
1054 $config_data .= "// these dirs are normally sub dirs of the nucleus dir, but \n";
\r
1055 $config_data .= "// you can redefine them if you wish\n";
\r
1056 $config_data .= "\$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
1057 $config_data .= "\$DIR_LOCALES = \$DIR_NUCLEUS . 'locales/';\n";
\r
1058 $config_data .= "\$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
1059 $config_data .= "\n";
\r
1060 $config_data .= "// include libs\n";
\r
1061 $config_data .= "include(\$DIR_LIBS.'globalfunctions.php');\n";
\r
1062 $config_data .= "?" . ">";
\r
1065 if ( @!file_exists('../config.php') || is_writable('../config.php') )
\r
1067 if ( $fp = @fopen('../config.php', 'w') )
\r
1069 $result = @fwrite($fp, $config_data, i18n::strlen($config_data));
\r
1076 // try to change the read-only permission.
\r
1077 if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
\r
1079 @chmod('../config.php', 0444);
\r
1084 $_SESSION['config_data'] = $config_data;
\r
1091 * Confirm that you can write to the configuration file
\r
1092 * @return string error message
\r
1094 function canConfigFileWritable()
\r
1096 if ( @file_exists('../config.php') && @!is_writable('../config.php') )
\r
1098 // try to change the read-write permission.
\r
1099 if ( strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' )
\r
1101 @chmod('../config.php', 0666);
\r
1104 if ( @!is_writable('../config.php') )
\r
1106 return _INST_ERROR8;
\r
1113 * To obtain the version of MySQL
\r
1116 function getMySqlVersion()
\r
1118 global $minimum_mysql_version, $errors;
\r
1119 // Turn on output buffer
\r
1120 // Needed to repress the output of the sql function that are
\r
1121 // not part of php (in this case the @ operator doesn't work)
\r
1124 // note: this piece of code is taken from phpMyAdmin
\r
1125 $conn = sql_connect_args('localhost', '', '');
\r
1126 $result = @sql_query('SELECT VERSION() AS version', $conn);
\r
1128 if ( $result != FALSE && sql_num_rows($result) > 0 )
\r
1130 $row = sql_fetch_array($result);
\r
1131 $match = preg_split('#\.#', $row['version']);
\r
1135 $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
\r
1137 if ( $result != FALSE && @sql_num_rows($result) > 0 )
\r
1139 $row = sql_fetch_row($result);
\r
1140 $match = preg_split('#\.#', $row[1]);
\r
1144 //$output = shell_exec('mysql -V');
\r
1145 $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
\r
1146 preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
\r
1147 $match = preg_split('#\.#', $version[0]);
\r
1149 if ( $match[0] == '' )
\r
1151 $match = array('0', '0', '0');
\r
1156 @sql_disconnect($conn);
\r
1158 //End and clean output buffer
\r
1161 return implode($match, '.');
\r
1165 * Add a table prefix if it is used
\r
1167 * @param string $input table name with prefix
\r
1170 function tableName($input)
\r
1172 global $MYSQL_PREFIX;
\r
1173 if ( $MYSQL_PREFIX )
\r
1175 return $MYSQL_PREFIX . $input;
\r
1184 * Install custom plugins
\r
1186 function installCustomPlugs()
\r
1188 global $aConfPlugsToInstall, $DIR_LIBS, $manager;
\r
1190 $aErrors = array();
\r
1191 if ( count($aConfPlugsToInstall) == 0 )
\r
1196 $res = sql_query('SELECT * FROM ' . tableName('nucleus_plugin'));
\r
1197 $numCurrent = sql_num_rows($res);
\r
1199 foreach ( $aConfPlugsToInstall as $plugName )
\r
1201 $query = 'INSERT INTO ' . tableName('nucleus_plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ", '" . sql_real_escape_string($plugName) . "')";
\r
1202 sql_query($query);
\r
1204 $manager->clearCachedInfo('installedPlugins');
\r
1205 $plugin =& $manager->getPlugin($plugName);
\r
1206 $plugin->setID($numCurrent);
\r
1210 sql_query('DELETE FROM ' . tableName('nucleus_plugin') . " WHERE pfile = '" . sql_real_escape_string($plugName) . "'");
\r
1212 array_push($aErrors, sprintf(_INST_ERROR9, $plugName));
\r
1215 $plugin->install();
\r
1218 sql_query('DELETE FROM ' . tableName('nucleus_plugin_event'));
\r
1219 $res = sql_query('SELECT pid, pfile FROM ' . tableName('nucleus_plugin'));
\r
1221 while ( $o = sql_fetch_object($res) )
\r
1224 $plug =& $manager->getPlugin($o->pfile);
\r
1228 $eventList = $plug->getEventList();
\r
1229 foreach ( $eventList as $eventName )
\r
1231 sql_query('INSERT INTO ' . tableName('nucleus_plugin_event') . ' (pid, event) VALUES (' . $pid . ", '" . $eventName . "')");
\r
1239 * Install custom skins
\r
1240 * Prepares the installation of custom skins
\r
1242 function installCustomSkins()
\r
1244 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1246 $aErrors = array();
\r
1247 if ( count($aConfSkinsToImport) == 0 )
\r
1252 $importer = new SkinImport();
\r
1254 foreach ( $aConfSkinsToImport as $skinName )
\r
1256 $importer->reset();
\r
1257 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1259 if ( !@file_exists($skinFile) )
\r
1261 array_push($aErrors, sprintf(_INST_ERROR10, $skinFile));
\r
1265 $error = $importer->readFile($skinFile);
\r
1269 array_push($aErrors, sprintf(_INST_ERROR11, $skinName) . ' : ' . $error);
\r
1273 $error = $importer->writeToDatabase(1);
\r
1277 array_push($aErrors, sprintf(_INST_ERROR12, $skinName) . ' : ' . $error);
\r
1285 * Check if some important files of the Nucleus CMS installation are available
\r
1286 * Give an error if one or more files are not accessible
\r
1288 function do_check_files()
\r
1290 $missingfiles = array();
\r
1295 '../nucleus/index.php',
\r
1296 '../nucleus/media.php',
\r
1297 '../nucleus/libs/ACTION.php',
\r
1298 '../nucleus/libs/ACTIONLOG.php',
\r
1299 '../nucleus/libs/ACTIONS.php',
\r
1300 '../nucleus/libs/ADMIN.php',
\r
1301 '../nucleus/libs/BaseActions.php',
\r
1302 '../nucleus/libs/BLOG.php',
\r
1303 '../nucleus/libs/BODYACTIONS.php',
\r
1304 '../nucleus/libs/COMMENT.php',
\r
1305 '../nucleus/libs/COMMENTACTIONS.php',
\r
1306 '../nucleus/libs/COMMENTS.php',
\r
1307 '../nucleus/libs/ENCAPSULATE.php',
\r
1308 '../nucleus/libs/ENTITY.php',
\r
1309 '../nucleus/libs/globalfunctions.php',
\r
1310 '../nucleus/libs/i18n.php',
\r
1311 '../nucleus/libs/ITEM.php',
\r
1312 '../nucleus/libs/ITEMACTIONS.php',
\r
1313 '../nucleus/libs/LINK.php',
\r
1314 '../nucleus/libs/MANAGER.php',
\r
1315 '../nucleus/libs/MEDIA.php',
\r
1316 '../nucleus/libs/MEMBER.php',
\r
1317 '../nucleus/libs/mysql.php',
\r
1318 '../nucleus/libs/NOTIFICATION.php',
\r
1319 '../nucleus/libs/PAGEFACTORY.php',
\r
1320 '../nucleus/libs/PARSER.php',
\r
1321 '../nucleus/libs/PLUGIN.php',
\r
1322 '../nucleus/libs/PLUGINADMIN.php',
\r
1323 '../nucleus/libs/SEARCH.php',
\r
1324 '../nucleus/libs/showlist.php',
\r
1325 '../nucleus/libs/SKIN.php',
\r
1326 '../nucleus/libs/TEMPLATE.php',
\r
1327 '../nucleus/libs/vars4.1.0.php',
\r
1328 '../nucleus/libs/xmlrpc.inc.php',
\r
1329 '../nucleus/libs/xmlrpcs.inc.php',
\r
1330 '../nucleus/libs/sql/mysql.php'
\r
1333 $count = count($files);
\r
1334 for ( $i = 0; $i < $count; $i++ )
\r
1336 if ( !is_readable($files[$i]) )
\r
1338 array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.<br />');
\r
1342 if ( count($missingfiles) > 0 )
\r
1344 exit(implode("\n", $missingfiles));
\r
1349 * Updates the configuration in the database
\r
1351 * @param string $name name of the config var
\r
1352 * @param string $value new value of the config var
\r
1355 function updateConfig($name, $value)
\r
1357 $errors = array();
\r
1358 $name = sql_real_escape_string($name);
\r
1359 $value = trim(sql_real_escape_string($value));
\r
1361 $query = "UPDATE %s SET value = '%s' WHERE name = '%s'";
\r
1362 $query = sprintf($query, tableName('nucleus_config'), $value, $name);
\r
1364 if ( !sql_query($query) )
\r
1366 $errors[] = _INST_ERROR4 . ': ' . sql_error();
\r
1371 class ParamManager
\r
1373 /* process parameter */
\r
1377 /* mysql connection parameters */
\r
1378 public $mysql_host;
\r
1379 public $mysql_user;
\r
1380 public $mysql_password;
\r
1381 public $mysql_database;
\r
1382 public $mysql_tablePrefix;
\r
1384 /* weblog configuration parameters */
\r
1385 public $blog_name;
\r
1386 public $blog_shortname;
\r
1388 /* member configuration parameters */
\r
1389 public $user_name;
\r
1390 public $user_realname;
\r
1391 public $user_password;
\r
1392 private $user_password2;
\r
1393 public $user_email;
\r
1395 /* URI parameters */
\r
1396 private $root_url;
\r
1401 public $PluginURL;
\r
1402 public $ActionURL;
\r
1404 /* path parameters */
\r
1405 private $root_path;
\r
1406 public $AdminPath;
\r
1407 public $MediaPath;
\r
1408 public $SkinsPath;
\r
1413 public function __construct()
\r
1418 public function init()
\r
1420 // set default values
\r
1421 $this->state = 'locale';
\r
1422 $this->install_mode = 'simple';
\r
1423 $this->locale = 'en_Latn_US';
\r
1424 $this->mysql_host = @ini_get('mysql.default_host');
\r
1425 $this->blog_name = 'My Nucleus CMS';
\r
1426 $this->blog_shortname = 'mynucleuscms';
\r
1429 // $this->root_path = realpath(dirname(__FILE__) . '/..');
\r
1430 $directory_separator = preg_quote(DIRECTORY_SEPARATOR, '|');
\r
1431 $this->root_path = implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__) . '/..')));
\r
1432 if ( substr($this->root_path, -1, 1) !== '/' )
\r
1434 $this->root_path .= '/';
\r
1436 $base_path_pcre = preg_quote($this->root_path, '|');
\r
1438 /* current directry name */
\r
1439 $directory_name = preg_replace("|$base_path_pcre|", '', implode('/', preg_split("|$directory_separator|", realpath(dirname(__FILE__)))));
\r
1440 $directory_name_pcre = preg_quote($directory_name, '|');
\r
1443 $root_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
\r
1444 $this->root_url = preg_replace("|$directory_name_pcre(.*)$|", '', $root_url);
\r
1446 $this->AdminPath = $this->root_path . 'nucleus/';
\r
1447 $this->MediaPath = $this->root_path . 'media/';
\r
1448 $this->SkinsPath = $this->root_path . 'skins/';
\r
1450 $this->IndexURL = $this->root_url;
\r
1451 $this->AdminURL = $this->root_url . 'nucleus/';
\r
1452 $this->MediaURL = $this->root_url . 'media/';
\r
1453 $this->SkinsURL = $this->root_url . 'skins/';
\r
1454 $this->PluginURL = $this->root_url . 'nucleus/plugins/';
\r
1455 $this->ActionURL = $this->root_url . 'action.php';
\r
1458 private function read_parameter($parameter)
\r
1460 foreach ( $parameter as $element )
\r
1462 if ( array_key_exists($element, $_POST) )
\r
1464 $this->$element = $_POST[$element];
\r
1469 public function set_state($state)
\r
1471 $states = array('locale', 'mysql', 'weblog', 'detail', 'install');
\r
1472 if ( in_array($state, $states) )
\r
1474 $this->state = $state;
\r
1478 public function set_locale()
\r
1480 $this->read_parameter(array('locale'));
\r
1482 if ( !in_array($this->locale, i18n::get_available_locale_list()) )
\r
1484 $this->locale = 'en_Latn_US';
\r
1488 public function check_mysql_parameters()
\r
1490 $parameters = array('mysql_host', 'mysql_user', 'mysql_password', 'mysql_database', 'mysql_tablePrefix');
\r
1491 $this->read_parameter($parameters);
\r
1493 $errors = array();
\r
1494 if ( $this->mysql_host == '' )
\r
1496 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD1);
\r
1499 if ( $this->mysql_user == '' )
\r
1501 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD2);
\r
1504 if ( $this->mysql_user != ''
\r
1505 && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_user) )
\r
1507 $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD2);
\r
1510 // if ( $this->mysql_password == '' )
\r
1512 // $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD3);
\r
1515 if ( $this->mysql_database == '' )
\r
1517 $errors[] = sprintf(_VALID_ERROR1, _DB_FIELD4);
\r
1520 if ( $this->mysql_database != ''
\r
1521 && !preg_match('/^[a-z0-9_\-]+$/i', $this->mysql_database) )
\r
1523 $errors[] = sprintf(_VALID_ERROR2, _DB_FIELD4);
\r
1526 if ( $this->mysql_tablePrefix != ''
\r
1527 && !preg_match('/^[a-z0-9_]+$/i', $this->mysql_tablePrefix) )
\r
1529 $errors[] = sprintf(_VALID_ERROR3, _DB_FIELD5);
\r
1532 if ( count($errors) == 0 )
\r
1534 $mysql_conn = @sql_connect_args($this->mysql_host, $this->mysql_user, $this->mysql_password);
\r
1535 if ( $mysql_conn == false )
\r
1537 $errors[] = _DBCONNECT_ERROR;
\r
1541 @sql_close($mysql_conn);
\r
1548 public function check_user_parameters()
\r
1550 $parameters = array('user_name', 'user_realname', 'user_password', 'user_password2', 'user_email');
\r
1551 $this->read_parameter($parameters);
\r
1553 $errors = array();
\r
1554 if ( $this->user_realname == '' )
\r
1556 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD1);
\r
1559 if ( $this->user_name == '' )
\r
1561 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD2);
\r
1563 elseif ( !preg_match("/^[a-z0-9]+([ a-z0-9]*[a-z0-9]+)?$/i", $this->user_name) )
\r
1565 $errors[] = _VALID_ERROR5;
\r
1568 if ( $this->user_password == '' || $this->user_password2 == '' )
\r
1570 $errors[] = sprintf(_VALID_ERROR1, _ADMIN_FIELD3);
\r
1571 $this->user_password = '';
\r
1573 elseif ( $this->user_password != $this->user_password2 )
\r
1575 $errors[] = _VALID_ERROR6;
\r
1576 $this->user_password = '';
\r
1579 if ( !preg_match("/^[a-z0-9\._+\-]+@[a-z0-9\._\-]+\.[a-z]{2,6}$/i", $this->user_email) )
\r
1581 $errors[] = _VALID_ERROR7;
\r
1587 public function check_weblog_parameters()
\r
1589 $parameters = array('blog_name', 'blog_shortname');
\r
1590 $this->read_parameter($parameters);
\r
1592 $errors = array();
\r
1593 if ( $this->blog_name == '' )
\r
1595 $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD1);
\r
1598 if ( $this->blog_shortname == '' )
\r
1600 $errors[] = sprintf(_VALID_ERROR1, _BLOG_FIELD2);
\r
1603 if ( !preg_match("/^[a-z0-9]+$/i", $this->blog_shortname) )
\r
1605 $errors[] = _VALID_ERROR4;
\r
1611 public function check_uri_parameters()
\r
1613 $parameters = array('IndexURL', 'AdminURL', 'MediaURL', 'SkinsURL', 'PluginURL', 'ActionURL');
\r
1614 $this->read_parameter($parameters);
\r
1616 $errors = array();
\r
1617 if ( substr($this->IndexURL, -1, 1) !== '/' )
\r
1619 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD1);
\r
1622 if ( substr($this->AdminURL, -1, 1) !== '/' )
\r
1624 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD2);
\r
1627 if ( substr($this->MediaURL, -1, 1) !== '/' )
\r
1629 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD4);
\r
1632 if ( substr($this->SkinsURL, -1, 1) !== '/' )
\r
1634 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD6);
\r
1637 if ( substr($this->PluginURL, -1, 1) !== '/' )
\r
1639 $errors[] = sprintf(_VALID_ERROR8, _PATH_FIELD8);
\r
1642 if ( strrchr($this->ActionURL, '/') != '/action.php' )
\r
1644 $errors[] = sprintf(_VALID_ERROR9, _PATH_FIELD9);
\r
1650 public function check_path_parameters()
\r
1652 $parameters = array('AdminPath', 'MediaPath', 'SkinsPath');
\r
1653 $this->read_parameter($parameters);
\r
1655 $separators = array('/', DIRECTORY_SEPARATOR);
\r
1656 $errors = array();
\r
1657 if ( !in_array(substr($this->AdminPath, -1, 1), $separators) )
\r
1659 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD3);
\r
1661 elseif ( !file_exists($this->AdminPath) )
\r
1663 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD3);
\r
1666 if ( !in_array(substr($this->MediaPath, -1, 1), $separators) )
\r
1668 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD5);
\r
1670 elseif ( !file_exists($this->MediaPath) )
\r
1672 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD5);
\r
1675 if ( !in_array(substr($this->SkinsPath, -1, 1), $separators) )
\r
1677 $errors[] = sprintf(_VALID_ERROR10, _PATH_FIELD7);
\r
1679 elseif ( !file_exists($this->SkinsPath) )
\r
1681 $errors[] = sprintf(_VALID_ERROR11, _PATH_FIELD7);
\r
1688 * check all parameters
\r
1691 public function check_all_parameters()
\r
1693 $this->set_locale();
\r
1696 $isValid &= (count($this->check_mysql_parameters()) == 0);
\r
1697 $isValid &= (count($this->check_user_parameters()) == 0);
\r
1698 $isValid &= (count($this->check_weblog_parameters()) == 0);
\r
1699 $isValid &= (count($this->check_uri_parameters()) == 0);
\r
1700 $isValid &= (count($this->check_path_parameters()) == 0);
\r