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 ($charset == 'ujis') {
\r
484 define('_CHARSET', 'EUC-JP');
\r
485 $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');
\r
486 $user_realname = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');
\r
487 $blog_name = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');
\r
489 define('_CHARSET', 'UTF-8');
\r
492 $config_indexurl = replaceDoubleBackslash($config_indexurl);
\r
493 $config_adminurl = replaceDoubleBackslash($config_adminurl);
\r
494 $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
\r
495 $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
\r
496 $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
\r
497 $config_actionurl = replaceDoubleBackslash($config_actionurl);
\r
498 $config_adminpath = replaceDoubleBackslash($config_adminpath);
\r
499 $config_skinspath = replaceDoubleBackslash($config_skinspath);
\r
500 $config_mediapath = replaceDoubleBackslash($config_mediapath);
\r
502 // 1. check all the data
\r
505 if (!$mysql_database) {
\r
506 array_push($errors, _ERROR2);
\r
509 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
\r
510 array_push($errors, _ERROR3);
\r
513 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
\r
514 array_push($errors, _ERROR4);
\r
517 // TODO: add action.php check
\r
518 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
\r
519 array_push($errors, _ERROR5);
\r
522 if (!endsWithSlash($config_adminpath) ) {
\r
523 array_push($errors, _ERROR6);
\r
526 if (!endsWithSlash($config_mediapath) ) {
\r
527 array_push($errors, _ERROR7);
\r
530 if (!endsWithSlash($config_skinspath) ) {
\r
531 array_push($errors, _ERROR8);
\r
534 if (!is_dir($config_adminpath) ) {
\r
535 array_push($errors, _ERROR9);
\r
538 if (!_isValidMailAddress($user_email) ) {
\r
539 array_push($errors, _ERROR10);
\r
542 if (!_isValidDisplayName($user_name) ) {
\r
543 array_push($errors, _ERROR11);
\r
546 if (!$user_password || !$user_password2) {
\r
547 array_push($errors, _ERROR12);
\r
550 if ($user_password != $user_password2) {
\r
551 array_push($errors, _ERROR13);
\r
554 if (!_isValidShortName($blog_shortname) ) {
\r
555 array_push($errors, _ERROR14);
\r
558 if (sizeof($errors) > 0) {
\r
559 showErrorMessages($errors);
\r
562 // 2-1. try to log in to mySQL
\r
563 global $MYSQL_CONN;
\r
564 $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
\r
566 if ($MYSQL_CONN == false) {
\r
567 _doError(_ERROR15 . ': ' . mysql_error() );
\r
570 /*/ <add for garble measure>
\r
571 // 2-2. set DEFAULT CHARSET and COLLATE
\r
572 $mySqlVer = implode('.', array_map('intval', explode('.', mysql_get_server_info($MYSQL_CONN))));
\r
573 if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {
\r
574 mysql_set_charset($charset);
\r
576 mysql_query("SET NAMES " . $charset);
\r
578 $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci';
\r
579 // </add for garble measure>*/
\r
581 // 3. try to create database (if needed)
\r
582 if ($mysql_create == 1) {
\r
583 $sql = 'CREATE DATABASE '
\r
585 /*/ <add for garble measure>
\r
586 . ' DEFAULT CHARACTER SET '
\r
590 // </add for garble measure>*/
\r
592 mysql_query($sql) or _doError(_ERROR16 . ': ' . mysql_error());
\r
595 // 4. try to select database
\r
596 mysql_select_db($mysql_database) or _doError(_ERROR17);
\r
598 // 5. execute queries
\r
599 $filename = 'install.sql';
\r
600 $fd = fopen($filename, 'r');
\r
601 $queries = fread($fd, filesize($filename) );
\r
604 $queries = split("(;\n|;\r)", $queries);
\r
606 $aTableNames = array(
\r
607 'nucleus_actionlog',
\r
610 'nucleus_category',
\r
618 'nucleus_template',
\r
620 'nucleus_activation',
\r
623 // these are unneeded (one of the replacements above takes care of them)
\r
624 // 'nucleus_plugin_event',
\r
625 // 'nucleus_plugin_option',
\r
626 // 'nucleus_plugin_option_desc',
\r
627 // 'nucleus_skin_desc',
\r
628 // 'nucleus_template_desc',
\r
630 $aTableNamesPrefixed = array(
\r
631 $mysql_prefix . 'nucleus_actionlog',
\r
632 $mysql_prefix . 'nucleus_ban',
\r
633 $mysql_prefix . 'nucleus_blog',
\r
634 $mysql_prefix . 'nucleus_category',
\r
635 $mysql_prefix . 'nucleus_comment',
\r
636 $mysql_prefix . 'nucleus_config',
\r
637 $mysql_prefix . 'nucleus_item',
\r
638 $mysql_prefix . 'nucleus_karma',
\r
639 $mysql_prefix . 'nucleus_member',
\r
640 $mysql_prefix . 'nucleus_plugin',
\r
641 $mysql_prefix . 'nucleus_skin',
\r
642 $mysql_prefix . 'nucleus_template',
\r
643 $mysql_prefix . 'nucleus_team',
\r
644 $mysql_prefix . 'nucleus_activation',
\r
645 $mysql_prefix . 'nucleus_tickets'
\r
647 // these are unneeded (one of the replacements above takes care of them)
\r
648 // $mysql_prefix . 'nucleus_plugin_event',
\r
649 // $mysql_prefix . 'nucleus_plugin_option',
\r
650 // $mysql_prefix . 'nucleus_plugin_option_desc',
\r
651 // $mysql_prefix . 'nucleus_skin_desc',
\r
652 // $mysql_prefix . 'nucleus_template_desc',
\r
654 $count = count($queries);
\r
656 for ($idx = 0; $idx < $count; $idx++) {
\r
657 $query = trim($queries[$idx]);
\r
658 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
\r
662 if ($mysql_usePrefix == 1) {
\r
663 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
\r
665 /*/ <add for garble measure>
\r
666 if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0) {
\r
667 $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
\r
669 // </add for garble measure>*/
\r
671 mysql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
\r
675 // 5a make first post
\r
676 if ($charset == 'ujis') {
\r
677 $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8');
\r
678 $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8');
\r
679 $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8');
\r
681 $itm_title = _1ST_POST_TITLE;
\r
682 $itm_body = _1ST_POST;
\r
683 $itm_more = _1ST_POST2;
\r
685 $newpost = "INSERT INTO "
\r
686 . tableName('nucleus_item')
\r
689 . "'" . $itm_title . "',"
\r
690 . " '" . $itm_body . "',"
\r
691 . " '" . $itm_more . "',"
\r
692 . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";
\r
693 mysql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . mysql_error() );
\r
695 // 6. update global settings
\r
696 updateConfig('IndexURL', $config_indexurl);
\r
697 updateConfig('AdminURL', $config_adminurl);
\r
698 updateConfig('MediaURL', $config_mediaurl);
\r
699 updateConfig('SkinsURL', $config_skinsurl);
\r
700 updateConfig('PluginURL', $config_pluginurl);
\r
701 updateConfig('ActionURL', $config_actionurl);
\r
702 updateConfig('AdminEmail', $config_adminemail);
\r
703 updateConfig('SiteName', $config_sitename);
\r
704 if ($charset == 'ujis') {
\r
705 updateConfig('Language', 'japanese-euc');
\r
708 // 7. update GOD member
\r
709 $query = 'UPDATE ' . tableName('nucleus_member')
\r
710 . " SET mname = '" . addslashes($user_name) . "',"
\r
711 . " mrealname = '" . addslashes($user_realname) . "',"
\r
712 . " mpassword = '" . md5(addslashes($user_password) ) . "',"
\r
713 . " murl = '" . addslashes($config_indexurl) . "',"
\r
714 . " memail = '" . addslashes($user_email) . "',"
\r
720 mysql_query($query) or _doError(_ERROR19 . ': ' . mysql_error() );
\r
722 // 8. update weblog settings
\r
723 $query = 'UPDATE ' . tableName('nucleus_blog')
\r
724 . " SET bname = '" . addslashes($blog_name) . "',"
\r
725 . " bshortname = '" . addslashes($blog_shortname) . "',"
\r
726 . " burl = '" . addslashes($config_indexurl) . "'"
\r
730 mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );
\r
732 // 8-2. update category settings
\r
733 if ($charset == 'ujis') {
\r
734 $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8');
\r
735 $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8');
\r
737 $cat_name = _GENERALCAT_NAME;
\r
738 $cat_desc = _GENERALCAT_DESC;
\r
740 $query = 'UPDATE ' . tableName('nucleus_category')
\r
741 . " SET cname = '" . $cat_name . "',"
\r
742 . " cdesc = '" . $cat_desc . "'"
\r
746 mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );
\r
748 // 9. update item date
\r
749 $query = 'UPDATE ' . tableName('nucleus_item')
\r
750 . " SET itime = '" . date('Y-m-d H:i:s', time() ) ."'"
\r
751 . " WHERE inumber = 1";
\r
753 mysql_query($query) or _doError(_ERROR21 . ': ' . mysql_error() );
\r
755 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
756 $aSkinErrors = array();
\r
757 $aPlugErrors = array();
\r
759 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
760 // 10. set global variables
\r
761 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
\r
763 $MYSQL_HOST = $mysql_host;
\r
764 $MYSQL_USER = $mysql_user;
\r
765 $MYSQL_PASSWORD = $mysql_password;
\r
766 $MYSQL_DATABASE = $mysql_database;
\r
767 $MYSQL_PREFIX = ($mysql_usePrefix == 1) ? $mysql_prefix : '';
\r
769 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
771 $DIR_NUCLEUS = $config_adminpath;
\r
772 $DIR_MEDIA = $config_mediapath;
\r
773 $DIR_SKINS = $config_skinspath;
\r
774 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
775 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
776 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
778 // close database connection (needs to be closed if we want to include globalfunctions.php)
\r
782 include_once($DIR_LIBS . 'globalfunctions.php');
\r
784 // 11. install custom skins
\r
785 $aSkinErrors = installCustomSkins($manager);
\r
787 // 12. install NP_Ping, if decided
\r
788 if ($weblog_ping == 1) {
\r
789 global $aConfPlugsToInstall;
\r
790 array_push($aConfPlugsToInstall, "NP_Ping");
\r
793 // 13. install custom plugins
\r
794 $aPlugErrors = installCustomPlugs($manager);
\r
797 // 14. Write config file ourselves (if possible)
\r
798 $bConfigWritten = 0;
\r
800 if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {
\r
801 $config_data = '<' . '?php' . "\n\n";
\r
802 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
\r
803 $config_data .= " // mySQL connection information\n";
\r
804 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
\r
805 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
\r
806 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
\r
807 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
\r
808 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";
\r
809 $config_data .= "\n";
\r
810 $config_data .= " // main nucleus directory\n";
\r
811 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
\r
812 $config_data .= "\n";
\r
813 $config_data .= " // path to media dir\n";
\r
814 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
\r
815 $config_data .= "\n";
\r
816 $config_data .= " // extra skin files for imported skins\n";
\r
817 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
\r
818 $config_data .= "\n";
\r
819 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
\r
820 $config_data .= " // you can redefine them if you wish\n";
\r
821 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
822 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
\r
823 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
824 $config_data .= "\n";
\r
825 $config_data .= " // include libs\n";
\r
826 $config_data .= " include(\$DIR_LIBS . 'globalfunctions.php');\n";
\r
827 $config_data .= " if (!extension_loaded('mbstring')) {\n";
\r
828 $config_data .= " include(\$DIR_LIBS . 'mb_emulator/mb-emulator.php');\n";
\r
829 $config_data .= " }\n";
\r
830 $config_data .= "?" . ">";
\r
832 $result = @fputs($fp, $config_data, strlen($config_data) );
\r
836 $bConfigWritten = 1;
\r
841 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
842 <html xmlns="http://www.w3.org/1999/xhtml">
\r
844 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
845 <title><?php echo _TITLE; ?></title>
\r
846 <style>@import url('nucleus/styles/manual.css');</style>
\r
849 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
852 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
\r
854 if (count($aAllErrors) > 0) {
\r
855 echo '<h1>' . _TITLE2 . '</h1>';
\r
856 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
\r
859 if (!$bConfigWritten) { ?>
\r
860 <h1><?php echo _TITLE3; ?></h1>
\r
862 <? echo _TEXT10; ?>
\r
864 <pre><code><?php
\r
865 // mySQL connection information
\r
866 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
\r
867 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
\r
868 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
\r
869 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
\r
870 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
\r
872 // main nucleus directory
\r
873 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
\r
875 // path to media dir
\r
876 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
\r
878 // extra skin files for imported skins
\r
879 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
\r
881 // these dirs are normally sub dirs of the nucleus dir, but
\r
882 // you can redefine them if you wish
\r
883 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
884 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
885 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
888 include($DIR_LIBS . 'globalfunctions.php');
\r
889 if (!extension_loaded('mbstring')) {
\r
890 include($DIR_LIBS . 'mb_emulator/mb-emulator.php');
\r
894 <?php echo _TEXT11; ?>
\r
897 <?php echo _TEXT12; ?>
\r
902 <h1><?php echo _TITLE4; ?></h1>
\r
904 <?php echo _TEXT13; ?>
\r
908 <h1><?php echo _TITLE5; ?></h1>
\r
910 <?php echo _TEXT14; ?>
\r
913 <li><?php echo _TEXT14_L1; ?></li>
\r
914 <li><?php echo _TEXT14_L2; ?></li>
\r
917 <h1><?php echo _HEADER10; ?></h1>
\r
919 <?php echo _TEXT15; ?>
\r
922 <li><?php echo _TEXT15_L1; ?></li>
\r
923 <li><?php echo _TEXT15_L2; ?></li>
\r
926 <?php echo _TEXT15_EX; ?>
\r
928 <h1><?php echo _HEADER11; ?></h1>
\r
930 <p><?php echo _TEXT16; ?>
\r
932 <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>
\r
933 <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>
\r
943 function installCustomPlugs(&$manager) {
\r
944 global $aConfPlugsToInstall, $DIR_LIBS;
\r
946 $aErrors = array();
\r
948 if (count($aConfPlugsToInstall) == 0) {
\r
952 $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
\r
953 $numCurrent = mysql_num_rows($res);
\r
955 foreach ($aConfPlugsToInstall as $plugName) {
\r
956 // do this before calling getPlugin (in case the plugin id is used there)
\r
957 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
\r
960 // get and install the plugin
\r
961 $manager->clearCachedInfo('installedPlugins');
\r
962 $plugin =& $manager->getPlugin($plugName);
\r
963 $plugin->plugid = $numCurrent;
\r
966 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
\r
968 array_push($aErrors, _ERROR22 . $plugName);
\r
972 $plugin->install();
\r
975 // SYNC PLUGIN EVENT LIST
\r
976 sql_query('DELETE FROM ' . sql_table('plugin_event') );
\r
978 // loop over all installed plugins
\r
979 $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
\r
981 while($o = mysql_fetch_object($res) ) {
\r
983 $plug =& $manager->getPlugin($o->pfile);
\r
986 $eventList = $plug->getEventList();
\r
988 foreach ($eventList as $eventName) {
\r
989 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
\r
997 function installCustomSkins(&$manager) {
\r
998 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1000 $aErrors = array();
\r
1002 if (count($aConfSkinsToImport) == 0) {
\r
1006 // load skinie class
\r
1007 include_once($DIR_LIBS . 'skinie.php');
\r
1009 $importer = new SKINIMPORT();
\r
1011 foreach ($aConfSkinsToImport as $skinName) {
\r
1012 $importer->reset();
\r
1013 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1015 if (!@file_exists($skinFile) ) {
\r
1016 array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2);
\r
1020 $error = $importer->readFile($skinFile);
\r
1023 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1027 $error = $importer->writeToDatabase(1);
\r
1030 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1038 // give an error if one or more nucleus are not accessible
\r
1039 function doCheckFiles() {
\r
1040 $missingfiles = array();
\r
1045 'nucleus/index.php',
\r
1046 'nucleus/libs/globalfunctions.php',
\r
1047 'nucleus/libs/ADMIN.php',
\r
1048 'nucleus/libs/BLOG.php',
\r
1049 'nucleus/libs/COMMENT.php',
\r
1050 'nucleus/libs/COMMENTS.php',
\r
1051 'nucleus/libs/ITEM.php',
\r
1052 'nucleus/libs/MEMBER.php',
\r
1053 'nucleus/libs/SKIN.php',
\r
1054 'nucleus/libs/TEMPLATE.php',
\r
1055 'nucleus/libs/MEDIA.php',
\r
1056 'nucleus/libs/ACTIONLOG.php',
\r
1057 'nucleus/media.php'
\r
1060 $count = count($files);
\r
1062 for ($i = 0; $i < $count; $i++) {
\r
1063 if (!is_readable($files[$i]) ) {
\r
1064 array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2);
\r
1068 // The above code replaces several if statements of the form:
\r
1070 // if (!is_readable('install.sql') ) {
\r
1071 // array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
\r
1074 if (count($missingfiles) > 0) {
\r
1075 showErrorMessages($missingfiles);
\r
1079 function updateConfig($name, $val) {
\r
1080 $name = addslashes($name);
\r
1081 $val = trim(addslashes($val) );
\r
1083 $query = 'UPDATE ' . tableName('nucleus_config')
\r
1084 . " SET value = '$val'"
\r
1085 . " WHERE name = '$name'";
\r
1087 mysql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );
\r
1088 return mysql_insert_id();
\r
1091 function replaceDoubleBackslash($input) {
\r
1092 return str_replace('\\', '/', $input);
\r
1095 function endsWithSlash($s) {
\r
1096 return (strrpos($s, '/') == strlen($s) - 1);
\r
1100 * Checks if email address is valid
\r
1102 function _isValidMailAddress($address) {
\r
1103 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
\r
1110 // returns true if the given string is a valid shortname
\r
1111 // (to check short blog names and nicknames)
\r
1112 // logic: starts and ends with a non space, can contain spaces in between
\r
1114 function _isValidShortName($name) {
\r
1115 if (eregi("^[a-z0-9]+$", $name) ) {
\r
1124 // returns true if the given string is a valid display name
\r
1125 // (to check nicknames)
\r
1126 function _isValidDisplayName($name) {
\r
1127 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
\r
1134 function _doError($msg) {
\r
1136 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1137 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1139 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
\r
1140 <title><?php echo _TITLE; ?></title>
\r
1141 <style>@import url('nucleus/styles/manual.css');</style>
\r
1144 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
1145 <h1><?php echo _ERROR27; ?></h1>
\r
1147 <p><?php echo _ERROR28; ?>: "<?php echo $msg?>";</p>
\r
1149 <p><a href="install.php" onclick="history.back();"><?php echo _TEXT17; ?></a></p>
\r
1157 function showErrorMessages($errors) {
\r
1159 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1160 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1162 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
\r
1163 <title><?php echo _TITLE; ?></title>
\r
1164 <style>@import url('nucleus/styles/manual.css');</style>
\r
1167 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
1168 <h1><?php echo _ERROR27; ?></h1>
\r
1170 <p><?php echo _ERROR29; ?>:</p>
\r
1175 while($msg = array_shift($errors) ) {
\r
1176 echo '<li>' . $msg . '</li>';
\r
1182 <p><a href="install.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>
\r
1190 /* for the non-php systems that decide to show the contents:
\r