3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2009 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
11 * This script will install the Nucleus tables in your SQL-database, and initialize the data in
\r
14 * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
\r
15 * ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>install.php</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php
\r
19 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
20 * @copyright Copyright (C) 2002-2009 The Nucleus Group
\r
22 * $NucleusJP: install.php,v 1.7 2007/02/04 06:28:44 kimitake Exp $
\r
26 This part of the install.php code allows for customization of the install process.
\r
27 When distributing plugins or skins together with a Nucleus installation, the
\r
28 configuration below will instruct to install them
\r
30 -- Start Of Configurable Part --
\r
33 include('./install_lang_japanese.php');
\r
35 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
\r
39 // array('NP_TrackBack', 'NP_MemberGoodies')
\r
40 $aConfPlugsToInstall = array('NP_SkinFiles');
\r
43 // array with skins to install. skins must be present under the skins/ directory with
\r
44 // a subdirectory having the same name that contains a skinbackup.xml file
\r
47 // array('base','rsd')
\r
48 $aConfSkinsToImport = array('default');
\r
51 -- End Of Configurable Part --
\r
54 // don't give warnings for uninitialized vars
\r
55 error_reporting(E_ERROR | E_WARNING | E_PARSE);
\r
57 // make sure there's no unnecessary escaping:
\r
58 set_magic_quotes_runtime(0);
\r
60 // if there are some plugins or skins to import, do not include vars
\r
61 // in globalfunctions.php again... so set a flag
\r
62 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
64 $CONF['installscript'] = 1;
\r
67 if (phpversion() >= '4.1.0') {
\r
68 include_once('nucleus/libs/vars4.1.0.php');
\r
70 include_once('nucleus/libs/vars4.0.6.php');
\r
73 include_once('nucleus/libs/mysql.php');
\r
75 // check if mysql support is installed
\r
76 if (!function_exists('mysql_query') ) {
\r
80 if (postVar('action') == 'go') {
\r
88 function showInstallForm() {
\r
89 // 0. pre check if all necessary files exist
\r
93 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
94 <html xmlns="http://www.w3.org/1999/xhtml">
\r
96 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
\r
97 <title><?php echo _TITLE; ?></title>
\r
98 <style type="text/css"><!--
\r
99 @import url('nucleus/documentation/styles/manual.css');
\r
101 <script type="text/javascript"><!--
\r
102 var submitcount = 0;
\r
104 // function to make sure the submit button only gets pressed once
\r
105 function checkSubmit() {
\r
106 if (submitcount == 0) {
\r
116 <div style="text-align:center"><img src="./nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->
\r
117 <form method="post" action="install.php">
\r
119 <h1><?php echo _HEADER1; ?></h1>
\r
121 <?php echo _TEXT1; ?>
\r
123 <h1><?php echo _HEADER1_2 ?></h1>
\r
125 <?php echo _TEXT1_2; ?>
\r
128 <legend><?php echo _TEXT1_2_TAB_HEAD; ?></legend>
\r
131 <td><?php echo _TEXT1_2_TAB_FIELD1; ?></td>
\r
133 <select name="charset" tabindex="10000">
\r
134 <option value="utf8" selected="selected">UTF-8</option>
\r
135 <option value="ujis" >EUC-JP</option>
\r
142 <h1><?php echo _HEADER2; ?></h1>
\r
144 <?php echo _TEXT2; ?>
\r
151 $minVersion = '4.0.6';
\r
153 if (phpversion() < $minVersion) {
\r
154 echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN, $minVersion) . '</span>';
\r
155 } elseif (phpversion() < '5') {
\r
156 echo ' <span class="warning" style="display:block">' . _TEXT2_WARN3 . '</span>';
\r
164 // note: this piece of code is taken from phpMyAdmin
\r
165 $result = @mysql_query('SELECT VERSION() AS version');
\r
167 if ($result != FALSE && @mysql_num_rows($result) > 0) {
\r
168 $row = mysql_fetch_array($result);
\r
169 $match = explode('.', $row['version']);
\r
171 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
\r
173 if ($result != FALSE && @mysql_num_rows($result) > 0) {
\r
174 $row = mysql_fetch_row($result);
\r
175 $match = explode('.', $row[1]);
\r
177 $output = shell_exec('mysql -V');
\r
178 preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
\r
179 $match = explode('.', $version[0]);
\r
181 if ($match[0] == '') {
\r
189 $mysqlVersion = implode($match, '.');
\r
190 $minVersion = '3.23';
\r
192 if ($mysqlVersion == '0.0.0') {
\r
193 echo _NOTIFICATION1;
\r
196 echo $mysqlVersion;
\r
199 if ($mysqlVersion < $minVersion) {
\r
200 echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN2, $minVersion) . '</span>';
\r
208 // tell people how they can have their config file filled out automatically
\r
209 if (@file_exists('config.php') && @!is_writable('config.php')) {
\r
212 <h1><?php echo _HEADER3; ?></h1>
\r
218 <h1><?php echo _HEADER4; ?></h1>
\r
220 <?php echo _TEXT4; ?>
\r
223 <legend><?php echo _TEXT4_TAB_HEAD; ?></legend>
\r
226 <td><?php echo _TEXT4_TAB_FIELD1; ?></td>
\r
227 <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" tabindex="10010" /></td>
\r
230 <td><?php echo _TEXT4_TAB_FIELD2; ?></td>
\r
231 <td><input name="mySQL_user" /></td>
\r
234 <td><?php echo _TEXT4_TAB_FIELD3; ?></td>
\r
235 <td><input name="mySQL_password" type="password" tabindex="10030" /></td>
\r
238 <td><?php echo _TEXT4_TAB_FIELD4; ?></td>
\r
239 <td><input name="mySQL_database" tabindex="10040" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create" tabindex="10050" /><label for="mySQL_create"><?php echo _TEXT4_TAB_FIELD4_ADD; ?></label>)</td>
\r
245 <legend><?php echo _TEXT4_TAB2_HEAD; ?></legend>
\r
248 <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix" tabindex="10060" /><label for="mySQL_usePrefix"><?php echo _TEXT4_TAB2_FIELD; ?></label></td>
\r
249 <td><input name="mySQL_tablePrefix" value="" tabindex="10070" /></td>
\r
253 <?php echo _TEXT4_TAB2_ADD; ?>
\r
257 <h1><?php echo _HEADER5; ?></h1>
\r
259 <?php echo _TEXT5; ?>
\r
263 // no need to this all! dirname(__FILE__) is all we need -- moraes
\r
265 // discover full path
\r
266 $fullPath = serverVar('PATH_TRANSLATED');
\r
268 if ($fullPath == '') {
\r
269 $fullPath = serverVar('SCRIPT_FILENAME');
\r
272 $basePath = str_replace('install.php', '', $fullPath);
\r
273 $basePath = replaceDoubleBackslash($basePath);
\r
274 $basePath = replaceDoubleBackslash($basePath);
\r
276 // add slash at end if necessary
\r
277 if (!endsWithSlash($basePath) ) {
\r
282 $basePath = dirname(__FILE__) . '/';
\r
286 <legend><?php echo _TEXT5_TAB_HEAD; ?></legend>
\r
289 <td><?php echo _TEXT5_TAB_FIELD1; ?></td>
\r
290 <td><input name="IndexURL" size="60" value="<?php
\r
291 $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
\r
292 $url = str_replace('install.php', '', $url);
\r
293 $url = replaceDoubleBackslash($url);
\r
295 // add slash at end if necessary
\r
296 if (!endsWithSlash($url) ) {
\r
300 echo $url; ?>" tabindex="10080" /></td>
\r
303 <td><?php echo _TEXT5_TAB_FIELD2; ?></td>
\r
304 <td><input name="AdminURL" size="60" value="<?php
\r
306 echo $url . 'nucleus/';
\r
307 } ?>" tabindex="10090" /></td>
\r
310 <td><?php echo _TEXT5_TAB_FIELD3; ?></td>
\r
311 <td><input name="AdminPath" size="60" value="<?php
\r
313 echo $basePath . 'nucleus/';
\r
314 } ?>" tabindex="10100" /></td>
\r
317 <td><?php echo _TEXT5_TAB_FIELD4; ?></td>
\r
318 <td><input name="MediaURL" size="60" value="<?php
\r
320 echo $url . 'media/';
\r
321 } ?>" tabindex="10110" /></td>
\r
324 <td><?php echo _TEXT5_TAB_FIELD5; ?></td>
\r
325 <td><input name="MediaPath" size="60" value="<?php
\r
327 echo $basePath . 'media/';
\r
328 } ?>" tabindex="10120" /></td>
\r
331 <td><?php echo _TEXT5_TAB_FIELD6; ?></td>
\r
332 <td><input name="SkinsURL" size="60" value="<?php
\r
334 echo $url . 'skins/';
\r
335 } ?>" tabindex="10130" />
\r
336 <br />(<?php echo _TEXT5_TAB_FIELD7_2; ?>)
\r
340 <td><?php echo _TEXT5_TAB_FIELD7; ?></td>
\r
341 <td><input name="SkinsPath" size="60" value="<?php
\r
343 echo $basePath . 'skins/';
\r
344 } ?>" tabindex="10140" />
\r
345 <br />(<?php echo _TEXT5_TAB_FIELD7_2; ?>)
\r
349 <td><?php echo _TEXT5_TAB_FIELD8; ?></td>
\r
350 <td><input name="PluginURL" size="60" value="<?php
\r
352 echo $url . 'nucleus/plugins/';
\r
353 } ?>" tabindex="10150" /></td>
\r
356 <td><?php echo _TEXT5_TAB_FIELD9; ?></td>
\r
357 <td><input name="ActionURL" size="60" value="<?php
\r
359 echo $url . 'action.php';
\r
360 } ?>" tabindex="10160" />
\r
361 <br />(<?php echo _TEXT5_TAB_FIELD9_2;?>)
\r
367 <?php echo _TEXT5_2; ?>
\r
369 <h1><? echo _HEADER6; ?></h1>
\r
371 <?php echo _TEXT6; ?>
\r
374 <legend><?php echo _TEXT6_TAB_HEAD; ?></legend>
\r
377 <td><?php echo _TEXT6_TAB_FIELD1; ?></td>
\r
378 <td><input name="User_name" value="" tabindex="10170" /> <small>(<?php echo _TEXT6_TAB_FIELD1_2; ?>)</small></td>
\r
381 <td><?php echo _TEXT6_TAB_FIELD2; ?></td>
\r
382 <td><input name="User_realname" value="" tabindex="10180" /></td>
\r
385 <td><?php echo _TEXT6_TAB_FIELD3; ?></td>
\r
386 <td><input name="User_password" type="password" value="" tabindex="10190" /></td>
\r
389 <td><?php echo _TEXT6_TAB_FIELD4; ?></td>
\r
390 <td><input name="User_password2" type="password" value="" tabindex="10200" /></td>
\r
393 <td><?php echo _TEXT6_TAB_FIELD5; ?></td>
\r
394 <td><input name="User_email" value="" tabindex="10210" /> <small>(<?php echo _TEXT6_TAB_FIELD5_2; ?>)</small></td>
\r
399 <h1><?php echo _HEADER7; ?></h1>
\r
401 <?php echo _TEXT7; ?>
\r
404 <legend><?php echo _TEXT7_TAB_HEAD; ?></legend>
\r
407 <td><?php echo _TEXT7_TAB_FIELD1; ?></td>
\r
408 <td><input name="Blog_name" size="60" value="My Nucleus CMS" tabindex="10220" /></td>
\r
411 <td><?php echo _TEXT7_TAB_FIELD2; ?></td>
\r
412 <td><input name="Blog_shortname" value="mynucleuscms" tabindex="10230" /> <small>(<?php echo _TEXT7_TAB_FIELD2_2; ?>)</small></td>
\r
417 <h1><?php echo _HEADER8; ?></h1>
\r
420 <legend><?php echo _TEXT8_TAB_HEADER; ?></legend>
\r
423 <td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" tabindex="10240" /><?php echo _TEXT8_TAB_FIELD1; ?></td>
\r
428 <h1><?php echo _HEADER9; ?></h1>
\r
430 <?php echo _TEXT9; ?>
\r
432 <p><input name="action" value="go" type="hidden" /> <input type="submit" value="<?php echo _BUTTON1; ?>" onclick="return checkSubmit();" tabindex="10250" /></p>
\r
440 function tableName($unPrefixed) {
\r
441 global $mysql_usePrefix, $mysql_prefix;
\r
443 if ($mysql_usePrefix == 1) {
\r
444 return $mysql_prefix . $unPrefixed;
\r
446 return $unPrefixed;
\r
450 function doInstall() {
\r
451 global $mysql_usePrefix, $mysql_prefix, $weblog_ping;
\r
453 // 0. put all POST-vars into vars
\r
454 $mysql_host = postVar('mySQL_host');
\r
455 $mysql_user = postVar('mySQL_user');
\r
456 $mysql_password = postVar('mySQL_password');
\r
457 $mysql_database = postVar('mySQL_database');
\r
458 $mysql_create = postVar('mySQL_create');
\r
459 $mysql_usePrefix = postVar('mySQL_usePrefix');
\r
460 $mysql_prefix = postVar('mySQL_tablePrefix');
\r
461 $config_indexurl = postVar('IndexURL');
\r
462 $config_adminurl = postVar('AdminURL');
\r
463 $config_adminpath = postVar('AdminPath');
\r
464 $config_mediaurl = postVar('MediaURL');
\r
465 $config_skinsurl = postVar('SkinsURL');
\r
466 $config_pluginurl = postVar('PluginURL');
\r
467 $config_actionurl = postVar('ActionURL');
\r
468 $config_mediapath = postVar('MediaPath');
\r
469 $config_skinspath = postVar('SkinsPath');
\r
470 $user_name = postVar('User_name');
\r
471 $user_realname = postVar('User_realname');
\r
472 $user_password = postVar('User_password');
\r
473 $user_password2 = postVar('User_password2');
\r
474 $user_email = postVar('User_email');
\r
475 $blog_name = postVar('Blog_name');
\r
476 $blog_shortname = postVar('Blog_shortname');
\r
477 $charset = postVar('charset');
\r
478 $config_adminemail = $user_email;
\r
479 $config_sitename = $blog_name;
\r
480 $weblog_ping = postVar('Weblog_ping');
\r
483 if (!extension_loaded('mbstring')) {
\r
484 include('nucleus/libs/mb_emulator/mb-emulator.php');
\r
486 if ($charset == 'ujis') {
\r
487 define('_CHARSET', 'EUC-JP');
\r
488 $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');
\r
489 $user_realname = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');
\r
490 $blog_name = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');
\r
492 define('_CHARSET', 'UTF-8');
\r
495 $config_indexurl = replaceDoubleBackslash($config_indexurl);
\r
496 $config_adminurl = replaceDoubleBackslash($config_adminurl);
\r
497 $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
\r
498 $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
\r
499 $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
\r
500 $config_actionurl = replaceDoubleBackslash($config_actionurl);
\r
501 $config_adminpath = replaceDoubleBackslash($config_adminpath);
\r
502 $config_skinspath = replaceDoubleBackslash($config_skinspath);
\r
503 $config_mediapath = replaceDoubleBackslash($config_mediapath);
\r
505 // 1. check all the data
\r
508 if (!$mysql_database) {
\r
509 array_push($errors, _ERROR2);
\r
512 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
\r
513 array_push($errors, _ERROR3);
\r
516 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
\r
517 array_push($errors, _ERROR4);
\r
520 // TODO: add action.php check
\r
521 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
\r
522 array_push($errors, _ERROR5);
\r
525 if (!endsWithSlash($config_adminpath) ) {
\r
526 array_push($errors, _ERROR6);
\r
529 if (!endsWithSlash($config_mediapath) ) {
\r
530 array_push($errors, _ERROR7);
\r
533 if (!endsWithSlash($config_skinspath) ) {
\r
534 array_push($errors, _ERROR8);
\r
537 if (!is_dir($config_adminpath) ) {
\r
538 array_push($errors, _ERROR9);
\r
541 if (!_isValidMailAddress($user_email) ) {
\r
542 array_push($errors, _ERROR10);
\r
545 if (!_isValidDisplayName($user_name) ) {
\r
546 array_push($errors, _ERROR11);
\r
549 if (!$user_password || !$user_password2) {
\r
550 array_push($errors, _ERROR12);
\r
553 if ($user_password != $user_password2) {
\r
554 array_push($errors, _ERROR13);
\r
557 if (!_isValidShortName($blog_shortname) ) {
\r
558 array_push($errors, _ERROR14);
\r
561 if (sizeof($errors) > 0) {
\r
562 showErrorMessages($errors);
\r
565 // 2-1. try to log in to mySQL
\r
566 global $MYSQL_CONN;
\r
567 $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
\r
569 if ($MYSQL_CONN == false) {
\r
570 _doError(_ERROR15 . ': ' . mysql_error() );
\r
573 /*/ <add for garble measure>
\r
574 // 2-2. set DEFAULT CHARSET and COLLATE
\r
575 $mySqlVer = implode('.', array_map('intval', explode('.', mysql_get_server_info($MYSQL_CONN))));
\r
576 if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {
\r
577 mysql_set_charset($charset);
\r
579 mysql_query("SET NAMES " . $charset);
\r
581 $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci';
\r
582 // </add for garble measure>*/
\r
584 // 3. try to create database (if needed)
\r
585 if ($mysql_create == 1) {
\r
586 $sql = 'CREATE DATABASE '
\r
588 /*/ <add for garble measure>
\r
589 . ' DEFAULT CHARACTER SET '
\r
593 // </add for garble measure>*/
\r
595 mysql_query($sql) or _doError(_ERROR16 . ': ' . mysql_error());
\r
598 // 4. try to select database
\r
599 mysql_select_db($mysql_database) or _doError(_ERROR17);
\r
601 // 5. execute queries
\r
602 $filename = 'install.sql';
\r
603 $fd = fopen($filename, 'r');
\r
604 $queries = fread($fd, filesize($filename) );
\r
607 $queries = split("(;\n|;\r)", $queries);
\r
609 $aTableNames = array(
\r
610 'nucleus_actionlog',
\r
613 'nucleus_category',
\r
621 'nucleus_template',
\r
623 'nucleus_activation',
\r
626 // these are unneeded (one of the replacements above takes care of them)
\r
627 // 'nucleus_plugin_event',
\r
628 // 'nucleus_plugin_option',
\r
629 // 'nucleus_plugin_option_desc',
\r
630 // 'nucleus_skin_desc',
\r
631 // 'nucleus_template_desc',
\r
633 $aTableNamesPrefixed = array(
\r
634 $mysql_prefix . 'nucleus_actionlog',
\r
635 $mysql_prefix . 'nucleus_ban',
\r
636 $mysql_prefix . 'nucleus_blog',
\r
637 $mysql_prefix . 'nucleus_category',
\r
638 $mysql_prefix . 'nucleus_comment',
\r
639 $mysql_prefix . 'nucleus_config',
\r
640 $mysql_prefix . 'nucleus_item',
\r
641 $mysql_prefix . 'nucleus_karma',
\r
642 $mysql_prefix . 'nucleus_member',
\r
643 $mysql_prefix . 'nucleus_plugin',
\r
644 $mysql_prefix . 'nucleus_skin',
\r
645 $mysql_prefix . 'nucleus_template',
\r
646 $mysql_prefix . 'nucleus_team',
\r
647 $mysql_prefix . 'nucleus_activation',
\r
648 $mysql_prefix . 'nucleus_tickets'
\r
650 // these are unneeded (one of the replacements above takes care of them)
\r
651 // $mysql_prefix . 'nucleus_plugin_event',
\r
652 // $mysql_prefix . 'nucleus_plugin_option',
\r
653 // $mysql_prefix . 'nucleus_plugin_option_desc',
\r
654 // $mysql_prefix . 'nucleus_skin_desc',
\r
655 // $mysql_prefix . 'nucleus_template_desc',
\r
657 $count = count($queries);
\r
659 for ($idx = 0; $idx < $count; $idx++) {
\r
660 $query = trim($queries[$idx]);
\r
661 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
\r
665 if ($mysql_usePrefix == 1) {
\r
666 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
\r
668 /*/ <add for garble measure>
\r
669 if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0) {
\r
670 $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
\r
672 // </add for garble measure>*/
\r
674 mysql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
\r
678 // 5a make first post
\r
679 if ($charset == 'ujis') {
\r
680 $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8');
\r
681 $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8');
\r
682 $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8');
\r
684 $itm_title = _1ST_POST_TITLE;
\r
685 $itm_body = _1ST_POST;
\r
686 $itm_more = _1ST_POST2;
\r
688 $newpost = "INSERT INTO "
\r
689 . tableName('nucleus_item')
\r
692 . "'" . $itm_title . "',"
\r
693 . " '" . $itm_body . "',"
\r
694 . " '" . $itm_more . "',"
\r
695 . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";
\r
696 mysql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . mysql_error() );
\r
698 // 6. update global settings
\r
699 updateConfig('IndexURL', $config_indexurl);
\r
700 updateConfig('AdminURL', $config_adminurl);
\r
701 updateConfig('MediaURL', $config_mediaurl);
\r
702 updateConfig('SkinsURL', $config_skinsurl);
\r
703 updateConfig('PluginURL', $config_pluginurl);
\r
704 updateConfig('ActionURL', $config_actionurl);
\r
705 updateConfig('AdminEmail', $config_adminemail);
\r
706 updateConfig('SiteName', $config_sitename);
\r
707 if ($charset == 'ujis') {
\r
708 updateConfig('Language', 'japanese-euc');
\r
711 // 7. update GOD member
\r
712 $query = 'UPDATE ' . tableName('nucleus_member')
\r
713 . " SET mname = '" . addslashes($user_name) . "',"
\r
714 . " mrealname = '" . addslashes($user_realname) . "',"
\r
715 . " mpassword = '" . md5(addslashes($user_password) ) . "',"
\r
716 . " murl = '" . addslashes($config_indexurl) . "',"
\r
717 . " memail = '" . addslashes($user_email) . "',"
\r
723 mysql_query($query) or _doError(_ERROR19 . ': ' . mysql_error() );
\r
725 // 8. update weblog settings
\r
726 $query = 'UPDATE ' . tableName('nucleus_blog')
\r
727 . " SET bname = '" . addslashes($blog_name) . "',"
\r
728 . " bshortname = '" . addslashes($blog_shortname) . "',"
\r
729 . " burl = '" . addslashes($config_indexurl) . "'"
\r
733 mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );
\r
735 // 8-2. update category settings
\r
736 if ($charset == 'ujis') {
\r
737 $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8');
\r
738 $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8');
\r
740 $cat_name = _GENERALCAT_NAME;
\r
741 $cat_desc = _GENERALCAT_DESC;
\r
743 $query = 'UPDATE ' . tableName('nucleus_category')
\r
744 . " SET cname = '" . $cat_name . "',"
\r
745 . " cdesc = '" . $cat_desc . "'"
\r
749 mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );
\r
751 // 9. update item date
\r
752 $query = 'UPDATE ' . tableName('nucleus_item')
\r
753 . " SET itime = '" . date('Y-m-d H:i:s', time() ) ."'"
\r
754 . " WHERE inumber = 1";
\r
756 mysql_query($query) or _doError(_ERROR21 . ': ' . mysql_error() );
\r
758 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
759 $aSkinErrors = array();
\r
760 $aPlugErrors = array();
\r
762 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
763 // 10. set global variables
\r
764 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
\r
766 $MYSQL_HOST = $mysql_host;
\r
767 $MYSQL_USER = $mysql_user;
\r
768 $MYSQL_PASSWORD = $mysql_password;
\r
769 $MYSQL_DATABASE = $mysql_database;
\r
770 $MYSQL_PREFIX = ($mysql_usePrefix == 1) ? $mysql_prefix : '';
\r
772 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
774 $DIR_NUCLEUS = $config_adminpath;
\r
775 $DIR_MEDIA = $config_mediapath;
\r
776 $DIR_SKINS = $config_skinspath;
\r
777 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
778 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
779 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
781 // close database connection (needs to be closed if we want to include globalfunctions.php)
\r
785 include_once($DIR_LIBS . 'globalfunctions.php');
\r
787 // 11. install custom skins
\r
788 $aSkinErrors = installCustomSkins($manager);
\r
790 // 12. install NP_Ping, if decided
\r
791 if ($weblog_ping == 1) {
\r
792 global $aConfPlugsToInstall;
\r
793 array_push($aConfPlugsToInstall, "NP_Ping");
\r
796 // 13. install custom plugins
\r
797 $aPlugErrors = installCustomPlugs($manager);
\r
800 // 14. Write config file ourselves (if possible)
\r
801 $bConfigWritten = 0;
\r
803 if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {
\r
804 $config_data = '<' . '?php' . "\n\n";
\r
805 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
\r
806 $config_data .= " // mySQL connection information\n";
\r
807 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
\r
808 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
\r
809 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
\r
810 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
\r
811 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";
\r
812 $config_data .= "\n";
\r
813 $config_data .= " // main nucleus directory\n";
\r
814 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
\r
815 $config_data .= "\n";
\r
816 $config_data .= " // path to media dir\n";
\r
817 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
\r
818 $config_data .= "\n";
\r
819 $config_data .= " // extra skin files for imported skins\n";
\r
820 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
\r
821 $config_data .= "\n";
\r
822 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
\r
823 $config_data .= " // you can redefine them if you wish\n";
\r
824 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
825 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
\r
826 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
827 $config_data .= "\n";
\r
828 $config_data .= " // include libs\n";
\r
829 $config_data .= " include(\$DIR_LIBS . 'globalfunctions.php');\n";
\r
830 $config_data .= " if (!extension_loaded('mbstring')) {\n";
\r
831 $config_data .= " include(\$DIR_LIBS . 'mb_emulator/mb-emulator.php');\n";
\r
832 $config_data .= " }\n";
\r
833 $config_data .= "?" . ">";
\r
835 $result = @fputs($fp, $config_data, strlen($config_data) );
\r
839 $bConfigWritten = 1;
\r
844 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
845 <html xmlns="http://www.w3.org/1999/xhtml">
\r
847 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
848 <title><?php echo _TITLE; ?></title>
\r
849 <style>@import url('nucleus/styles/manual.css');</style>
\r
852 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
855 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
\r
857 if (count($aAllErrors) > 0) {
\r
858 echo '<h1>' . _TITLE2 . '</h1>';
\r
859 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
\r
862 if (!$bConfigWritten) { ?>
\r
863 <h1><?php echo _TITLE3; ?></h1>
\r
865 <? echo _TEXT10; ?>
\r
867 <pre><code><?php
\r
868 // mySQL connection information
\r
869 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
\r
870 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
\r
871 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
\r
872 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
\r
873 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
\r
875 // main nucleus directory
\r
876 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
\r
878 // path to media dir
\r
879 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
\r
881 // extra skin files for imported skins
\r
882 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
\r
884 // these dirs are normally sub dirs of the nucleus dir, but
\r
885 // you can redefine them if you wish
\r
886 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
887 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
888 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
891 include($DIR_LIBS . 'globalfunctions.php');
\r
892 if (!extension_loaded('mbstring')) {
\r
893 include($DIR_LIBS . 'mb_emulator/mb-emulator.php');
\r
897 <?php echo _TEXT11; ?>
\r
900 <?php echo _TEXT12; ?>
\r
905 <h1><?php echo _TITLE4; ?></h1>
\r
907 <?php echo _TEXT13; ?>
\r
911 <h1><?php echo _TITLE5; ?></h1>
\r
913 <?php echo _TEXT14; ?>
\r
916 <li><?php echo _TEXT14_L1; ?></li>
\r
917 <li><?php echo _TEXT14_L2; ?></li>
\r
920 <h1><?php echo _HEADER10; ?></h1>
\r
922 <?php echo _TEXT15; ?>
\r
925 <li><?php echo _TEXT15_L1; ?></li>
\r
926 <li><?php echo _TEXT15_L2; ?></li>
\r
929 <?php echo _TEXT15_EX; ?>
\r
931 <h1><?php echo _HEADER11; ?></h1>
\r
933 <p><?php echo _TEXT16; ?>
\r
935 <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>
\r
936 <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>
\r
946 function installCustomPlugs(&$manager) {
\r
947 global $aConfPlugsToInstall, $DIR_LIBS;
\r
949 $aErrors = array();
\r
951 if (count($aConfPlugsToInstall) == 0) {
\r
955 $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
\r
956 $numCurrent = mysql_num_rows($res);
\r
958 foreach ($aConfPlugsToInstall as $plugName) {
\r
959 // do this before calling getPlugin (in case the plugin id is used there)
\r
960 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
\r
963 // get and install the plugin
\r
964 $manager->clearCachedInfo('installedPlugins');
\r
965 $plugin =& $manager->getPlugin($plugName);
\r
966 $plugin->plugid = $numCurrent;
\r
969 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
\r
971 array_push($aErrors, _ERROR22 . $plugName);
\r
975 $plugin->install();
\r
978 // SYNC PLUGIN EVENT LIST
\r
979 sql_query('DELETE FROM ' . sql_table('plugin_event') );
\r
981 // loop over all installed plugins
\r
982 $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
\r
984 while($o = mysql_fetch_object($res) ) {
\r
986 $plug =& $manager->getPlugin($o->pfile);
\r
989 $eventList = $plug->getEventList();
\r
991 foreach ($eventList as $eventName) {
\r
992 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
\r
1000 function installCustomSkins(&$manager) {
\r
1001 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1003 $aErrors = array();
\r
1005 if (count($aConfSkinsToImport) == 0) {
\r
1009 // load skinie class
\r
1010 include_once($DIR_LIBS . 'skinie.php');
\r
1012 $importer = new SKINIMPORT();
\r
1014 foreach ($aConfSkinsToImport as $skinName) {
\r
1015 $importer->reset();
\r
1016 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1018 if (!@file_exists($skinFile) ) {
\r
1019 array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2);
\r
1023 $error = $importer->readFile($skinFile);
\r
1026 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1030 $error = $importer->writeToDatabase(1);
\r
1033 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1041 // give an error if one or more nucleus are not accessible
\r
1042 function doCheckFiles() {
\r
1043 $missingfiles = array();
\r
1048 'nucleus/index.php',
\r
1049 'nucleus/libs/globalfunctions.php',
\r
1050 'nucleus/libs/ADMIN.php',
\r
1051 'nucleus/libs/BLOG.php',
\r
1052 'nucleus/libs/COMMENT.php',
\r
1053 'nucleus/libs/COMMENTS.php',
\r
1054 'nucleus/libs/ITEM.php',
\r
1055 'nucleus/libs/MEMBER.php',
\r
1056 'nucleus/libs/SKIN.php',
\r
1057 'nucleus/libs/TEMPLATE.php',
\r
1058 'nucleus/libs/MEDIA.php',
\r
1059 'nucleus/libs/ACTIONLOG.php',
\r
1060 'nucleus/media.php'
\r
1063 $count = count($files);
\r
1065 for ($i = 0; $i < $count; $i++) {
\r
1066 if (!is_readable($files[$i]) ) {
\r
1067 array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2);
\r
1071 // The above code replaces several if statements of the form:
\r
1073 // if (!is_readable('install.sql') ) {
\r
1074 // array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
\r
1077 if (count($missingfiles) > 0) {
\r
1078 showErrorMessages($missingfiles);
\r
1082 function updateConfig($name, $val) {
\r
1083 $name = addslashes($name);
\r
1084 $val = trim(addslashes($val) );
\r
1086 $query = 'UPDATE ' . tableName('nucleus_config')
\r
1087 . " SET value = '$val'"
\r
1088 . " WHERE name = '$name'";
\r
1090 mysql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );
\r
1091 return mysql_insert_id();
\r
1094 function replaceDoubleBackslash($input) {
\r
1095 return str_replace('\\', '/', $input);
\r
1098 function endsWithSlash($s) {
\r
1099 return (strrpos($s, '/') == strlen($s) - 1);
\r
1103 * Checks if email address is valid
\r
1105 function _isValidMailAddress($address) {
\r
1106 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
\r
1113 // returns true if the given string is a valid shortname
\r
1114 // (to check short blog names and nicknames)
\r
1115 // logic: starts and ends with a non space, can contain spaces in between
\r
1117 function _isValidShortName($name) {
\r
1118 if (eregi("^[a-z0-9]+$", $name) ) {
\r
1127 // returns true if the given string is a valid display name
\r
1128 // (to check nicknames)
\r
1129 function _isValidDisplayName($name) {
\r
1130 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
\r
1137 function _doError($msg) {
\r
1139 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1140 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1142 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
\r
1143 <title><?php echo _TITLE; ?></title>
\r
1144 <style>@import url('nucleus/styles/manual.css');</style>
\r
1147 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
1148 <h1><?php echo _ERROR27; ?></h1>
\r
1150 <p><?php echo _ERROR28; ?>: "<?php echo $msg?>";</p>
\r
1152 <p><a href="install.php" onclick="history.back();"><?php echo _TEXT17; ?></a></p>
\r
1160 function showErrorMessages($errors) {
\r
1162 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1163 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1165 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
\r
1166 <title><?php echo _TITLE; ?></title>
\r
1167 <style>@import url('nucleus/styles/manual.css');</style>
\r
1170 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
1171 <h1><?php echo _ERROR27; ?></h1>
\r
1173 <p><?php echo _ERROR29; ?>:</p>
\r
1178 while($msg = array_shift($errors) ) {
\r
1179 echo '<li>' . $msg . '</li>';
\r
1185 <p><a href="install.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>
\r
1193 /* for the non-php systems that decide to show the contents:
\r