3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2010 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-2010 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(
\r
45 // array with skins to install. skins must be present under the skins/ directory with
\r
46 // a subdirectory having the same name that contains a skinbackup.xml file
\r
49 // array('base','rsd')
\r
50 $aConfSkinsToImport = array(
\r
58 -- End Of Configurable Part --
\r
61 // don't give warnings for uninitialized vars
\r
62 error_reporting(E_ERROR | E_WARNING | E_PARSE);
\r
64 // make sure there's no unnecessary escaping:
\r
65 set_magic_quotes_runtime(0);
\r
67 // if there are some plugins or skins to import, do not include vars
\r
68 // in globalfunctions.php again... so set a flag
\r
69 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
71 $CONF['installscript'] = 1;
\r
74 if (phpversion() >= '4.1.0') {
\r
75 include_once('../nucleus/libs/vars4.1.0.php');
\r
77 include_once('../nucleus/libs/vars4.0.6.php');
\r
80 // include core classes that are needed for login & plugin handling
\r
81 // added for 3.5 sql_* wrapper
\r
82 global $MYSQL_HANDLER;
\r
83 //set the handler if different from mysql (or mysqli)
\r
84 //$MYSQL_HANDLER = array('pdo','mysql');
\r
85 if (!isset($MYSQL_HANDLER)) {
\r
86 $MYSQL_HANDLER = array('mysql','');
\r
89 include_once('../nucleus/libs/sql/'.$MYSQL_HANDLER[0].'.php');
\r
90 // end new for 3.5 sql_* wrapper
\r
91 include_once('../nucleus/libs/mysql.php');
\r
93 // check if mysql support is installed
\r
94 // this check may not make sense, as is, in a version past 3.5x
\r
95 if (!function_exists('mysql_query') ) {
\r
99 if (postVar('action') == 'go') {
\r
107 function showInstallForm() {
\r
108 // 0. pre check if all necessary files exist
\r
112 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
113 <html xmlns="http://www.w3.org/1999/xhtml">
\r
115 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
\r
116 <title><?php echo _TITLE; ?></title>
\r
117 <style type="text/css"><!--
\r
118 @import url('../nucleus/documentation/styles/manual.css');
\r
120 <script type="text/javascript"><!--
\r
121 var submitcount = 0;
\r
123 // function to make sure the submit button only gets pressed once
\r
124 function checkSubmit() {
\r
125 if (submitcount == 0) {
\r
135 <div style="text-align:center"><img src="../nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->
\r
136 <form method="post" action="index.php">
\r
138 <h1><?php echo _HEADER1; ?></h1>
\r
140 <?php echo _TEXT1; ?>
\r
142 <h1><?php echo _HEADER1_2 ?></h1>
\r
144 <?php echo _TEXT1_2; ?>
\r
147 <legend><?php echo _TEXT1_2_TAB_HEAD; ?></legend>
\r
150 <td><?php echo _TEXT1_2_TAB_FIELD1; ?></td>
\r
152 <select name="charset" tabindex="10000">
\r
153 <option value="utf8" selected="selected">UTF-8</option>
\r
154 <option value="ujis" >EUC-JP</option>
\r
161 <h1><?php echo _HEADER2; ?></h1>
\r
163 <?php echo _TEXT2; ?>
\r
170 $minVersion = '4.0.6';
\r
172 if (phpversion() < $minVersion) {
\r
173 echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN, $minVersion) . '</span>';
\r
174 } elseif (phpversion() < '5') {
\r
175 echo ' <span class="warning" style="display:block">' . _TEXT2_WARN3 . '</span>';
\r
183 // note: this piece of code is taken from phpMyAdmin
\r
184 $conn = sql_connect_args('localhost','','');
\r
185 $result = @sql_query('SELECT VERSION() AS version', $conn);
\r
187 if ($result != FALSE && sql_num_rows($result) > 0) {
\r
188 $row = sql_fetch_array($result);
\r
189 $match = explode('.', $row['version']);
\r
191 $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
\r
193 if ($result != FALSE && @sql_num_rows($result) > 0) {
\r
194 $row = sql_fetch_row($result);
\r
195 $match = explode('.', $row[1]);
\r
197 $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
\r
198 preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);
\r
199 $match = explode('.', $version[0]);
\r
201 if ($match[0] == '') {
\r
209 sql_disconnect($conn);
\r
210 $mysqlVersion = implode($match, '.');
\r
211 $minVersion = '3.23';
\r
213 if ($mysqlVersion == '0.0.0') {
\r
214 echo _NOTIFICATION1;
\r
217 echo $mysqlVersion;
\r
220 if ($mysqlVersion < $minVersion) {
\r
221 echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN2, $minVersion) . '</span>';
\r
229 // tell people how they can have their config file filled out automatically
\r
230 if (@file_exists('../config.php') && @!is_writable('../config.php')) {
\r
233 <h1><?php echo _HEADER3; ?></h1>
\r
239 <h1><?php echo _HEADER4; ?></h1>
\r
241 <?php echo _TEXT4; ?>
\r
244 <legend><?php echo _TEXT4_TAB_HEAD; ?></legend>
\r
247 <td><?php echo _TEXT4_TAB_FIELD1; ?></td>
\r
248 <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" tabindex="10010" /></td>
\r
251 <td><?php echo _TEXT4_TAB_FIELD2; ?></td>
\r
252 <td><input name="mySQL_user" tabindex="10020" /></td>
\r
255 <td><?php echo _TEXT4_TAB_FIELD3; ?></td>
\r
256 <td><input name="mySQL_password" type="password" tabindex="10030" /></td>
\r
259 <td><?php echo _TEXT4_TAB_FIELD4; ?></td>
\r
260 <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
266 <legend><?php echo _TEXT4_TAB2_HEAD; ?></legend>
\r
269 <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
270 <td><input name="mySQL_tablePrefix" value="" tabindex="10070" /></td>
\r
274 <?php echo _TEXT4_TAB2_ADD; ?>
\r
278 <h1><?php echo _HEADER5; ?></h1>
\r
280 <?php echo _TEXT5; ?>
\r
284 // no need to this all! dirname(__FILE__) is all we need -- moraes
\r
286 // discover full path
\r
287 $fullPath = serverVar('PATH_TRANSLATED');
\r
289 if ($fullPath == '') {
\r
290 $fullPath = serverVar('SCRIPT_FILENAME');
\r
293 $basePath = str_replace('install.php', '', $fullPath);
\r
294 $basePath = replaceDoubleBackslash($basePath);
\r
295 $basePath = replaceDoubleBackslash($basePath);
\r
297 // add slash at end if necessary
\r
298 if (!endsWithSlash($basePath) ) {
\r
303 $basePath = str_replace('install', '', dirname(__FILE__));
\r
307 <legend><?php echo _TEXT5_TAB_HEAD; ?></legend>
\r
310 <td><?php echo _TEXT5_TAB_FIELD1; ?></td>
\r
311 <td><input name="IndexURL" size="60" value="<?php
\r
312 $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
\r
313 $url = str_replace('install/index.php', '', $url);
\r
314 $url = replaceDoubleBackslash($url);
\r
316 // add slash at end if necessary
\r
317 if (!endsWithSlash($url) ) {
\r
321 echo $url; ?>" tabindex="10080" /></td>
\r
324 <td><?php echo _TEXT5_TAB_FIELD2; ?></td>
\r
325 <td><input name="AdminURL" size="60" value="<?php
\r
327 echo $url . 'nucleus/';
\r
328 } ?>" tabindex="10090" /></td>
\r
331 <td><?php echo _TEXT5_TAB_FIELD3; ?></td>
\r
332 <td><input name="AdminPath" size="60" value="<?php
\r
334 echo $basePath . 'nucleus/';
\r
335 } ?>" tabindex="10100" /></td>
\r
338 <td><?php echo _TEXT5_TAB_FIELD4; ?></td>
\r
339 <td><input name="MediaURL" size="60" value="<?php
\r
341 echo $url . 'media/';
\r
342 } ?>" tabindex="10110" /></td>
\r
345 <td><?php echo _TEXT5_TAB_FIELD5; ?></td>
\r
346 <td><input name="MediaPath" size="60" value="<?php
\r
348 echo $basePath . 'media/';
\r
349 } ?>" tabindex="10120" /></td>
\r
352 <td><?php echo _TEXT5_TAB_FIELD6; ?></td>
\r
353 <td><input name="SkinsURL" size="60" value="<?php
\r
355 echo $url . 'skins/';
\r
356 } ?>" tabindex="10130" />
\r
357 <br />(<?php echo _TEXT5_TAB_FIELD7_2; ?>)
\r
361 <td><?php echo _TEXT5_TAB_FIELD7; ?></td>
\r
362 <td><input name="SkinsPath" size="60" value="<?php
\r
364 echo $basePath . 'skins/';
\r
365 } ?>" tabindex="10140" />
\r
366 <br />(<?php echo _TEXT5_TAB_FIELD7_2; ?>)
\r
370 <td><?php echo _TEXT5_TAB_FIELD8; ?></td>
\r
371 <td><input name="PluginURL" size="60" value="<?php
\r
373 echo $url . 'nucleus/plugins/';
\r
374 } ?>" tabindex="10150" /></td>
\r
377 <td><?php echo _TEXT5_TAB_FIELD9; ?></td>
\r
378 <td><input name="ActionURL" size="60" value="<?php
\r
380 echo $url . 'action.php';
\r
381 } ?>" tabindex="10160" />
\r
382 <br />(<?php echo _TEXT5_TAB_FIELD9_2;?>)
\r
388 <?php echo _TEXT5_2; ?>
\r
390 <h1><? echo _HEADER6; ?></h1>
\r
392 <?php echo _TEXT6; ?>
\r
395 <legend><?php echo _TEXT6_TAB_HEAD; ?></legend>
\r
398 <td><?php echo _TEXT6_TAB_FIELD1; ?></td>
\r
399 <td><input name="User_name" value="" tabindex="10170" /> (<?php echo _TEXT6_TAB_FIELD1_2; ?>)</td>
\r
402 <td><?php echo _TEXT6_TAB_FIELD2; ?></td>
\r
403 <td><input name="User_realname" value="" tabindex="10180" /></td>
\r
406 <td><?php echo _TEXT6_TAB_FIELD3; ?></td>
\r
407 <td><input name="User_password" type="password" value="" tabindex="10190" /></td>
\r
410 <td><?php echo _TEXT6_TAB_FIELD4; ?></td>
\r
411 <td><input name="User_password2" type="password" value="" tabindex="10200" /></td>
\r
414 <td><?php echo _TEXT6_TAB_FIELD5; ?></td>
\r
415 <td><input name="User_email" value="" tabindex="10210" /> (<?php echo _TEXT6_TAB_FIELD5_2; ?>)</td>
\r
420 <h1><?php echo _HEADER7; ?></h1>
\r
422 <?php echo _TEXT7; ?>
\r
425 <legend><?php echo _TEXT7_TAB_HEAD; ?></legend>
\r
428 <td><?php echo _TEXT7_TAB_FIELD1; ?></td>
\r
429 <td><input name="Blog_name" size="60" value="My Nucleus CMS" tabindex="10220" /></td>
\r
432 <td><?php echo _TEXT7_TAB_FIELD2; ?></td>
\r
433 <td><input name="Blog_shortname" value="mynucleuscms" tabindex="10230" /> (<?php echo _TEXT7_TAB_FIELD2_2; ?>)</td>
\r
438 <h1><?php echo _HEADER8; ?></h1>
\r
441 <legend><?php echo _TEXT8_TAB_HEADER; ?></legend>
\r
444 <td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" tabindex="10240" /><?php echo _TEXT8_TAB_FIELD1; ?></td>
\r
449 <h1><?php echo _HEADER9; ?></h1>
\r
451 <?php echo _TEXT9; ?>
\r
454 <input name="action" value="go" type="hidden" />
\r
455 <input type="submit" value="<?php echo _BUTTON1; ?>" onclick="return checkSubmit();" tabindex="10250" />
\r
464 function tableName($unPrefixed) {
\r
465 global $mysql_usePrefix, $mysql_prefix;
\r
467 if ($mysql_usePrefix == 1) {
\r
468 return $mysql_prefix . $unPrefixed;
\r
470 return $unPrefixed;
\r
474 function doInstall() {
\r
475 global $mysql_usePrefix, $mysql_prefix, $weblog_ping;
\r
477 // 0. put all POST-vars into vars
\r
478 $mysql_host = postVar('mySQL_host');
\r
479 $mysql_user = postVar('mySQL_user');
\r
480 $mysql_password = postVar('mySQL_password');
\r
481 $mysql_database = postVar('mySQL_database');
\r
482 $mysql_create = postVar('mySQL_create');
\r
483 $mysql_usePrefix = postVar('mySQL_usePrefix');
\r
484 $mysql_prefix = postVar('mySQL_tablePrefix');
\r
485 $config_indexurl = postVar('IndexURL');
\r
486 $config_adminurl = postVar('AdminURL');
\r
487 $config_adminpath = postVar('AdminPath');
\r
488 $config_mediaurl = postVar('MediaURL');
\r
489 $config_skinsurl = postVar('SkinsURL');
\r
490 $config_pluginurl = postVar('PluginURL');
\r
491 $config_actionurl = postVar('ActionURL');
\r
492 $config_mediapath = postVar('MediaPath');
\r
493 $config_skinspath = postVar('SkinsPath');
\r
494 $user_name = postVar('User_name');
\r
495 $user_realname = postVar('User_realname');
\r
496 $user_password = postVar('User_password');
\r
497 $user_password2 = postVar('User_password2');
\r
498 $user_email = postVar('User_email');
\r
499 $blog_name = postVar('Blog_name');
\r
500 $blog_shortname = postVar('Blog_shortname');
\r
501 $charset = postVar('charset');
\r
502 $config_adminemail = $user_email;
\r
503 $config_sitename = $blog_name;
\r
504 $weblog_ping = postVar('Weblog_ping');
\r
507 if (!extension_loaded('mbstring')) {
\r
508 include('../nucleus/libs/mb_emulator/mb-emulator.php');
\r
510 if ($charset == 'ujis') {
\r
511 define('_CHARSET', 'EUC-JP');
\r
512 $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');
\r
513 $user_realname = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');
\r
514 $blog_name = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');
\r
516 define('_CHARSET', 'UTF-8');
\r
519 $config_indexurl = replaceDoubleBackslash($config_indexurl);
\r
520 $config_adminurl = replaceDoubleBackslash($config_adminurl);
\r
521 $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
\r
522 $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
\r
523 $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
\r
524 $config_actionurl = replaceDoubleBackslash($config_actionurl);
\r
525 $config_adminpath = replaceDoubleBackslash($config_adminpath);
\r
526 $config_skinspath = replaceDoubleBackslash($config_skinspath);
\r
527 $config_mediapath = replaceDoubleBackslash($config_mediapath);
\r
529 // 1. check all the data
\r
532 if (!$mysql_database) {
\r
533 array_push($errors, _ERROR2);
\r
536 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
\r
537 array_push($errors, _ERROR3);
\r
540 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
\r
541 array_push($errors, _ERROR4);
\r
544 // TODO: add action.php check
\r
545 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
\r
546 array_push($errors, _ERROR5);
\r
549 if (!endsWithSlash($config_adminpath) ) {
\r
550 array_push($errors, _ERROR6);
\r
553 if (!endsWithSlash($config_mediapath) ) {
\r
554 array_push($errors, _ERROR7);
\r
557 if (!endsWithSlash($config_skinspath) ) {
\r
558 array_push($errors, _ERROR8);
\r
561 if (!is_dir($config_adminpath) ) {
\r
562 array_push($errors, _ERROR9);
\r
565 if (!_isValidMailAddress($user_email) ) {
\r
566 array_push($errors, _ERROR10);
\r
569 if (!_isValidDisplayName($user_name) ) {
\r
570 array_push($errors, _ERROR11);
\r
573 if (!$user_password || !$user_password2) {
\r
574 array_push($errors, _ERROR12);
\r
577 if ($user_password != $user_password2) {
\r
578 array_push($errors, _ERROR13);
\r
581 if (!_isValidShortName($blog_shortname) ) {
\r
582 array_push($errors, _ERROR14);
\r
585 if (sizeof($errors) > 0) {
\r
586 showErrorMessages($errors);
\r
589 // 2-1. try to log in to mySQL
\r
591 global $MYSQL_CONN;
\r
592 // this will need to be changed if we ever allow
\r
593 $MYSQL_CONN = @sql_connect_args($mysql_host, $mysql_user, $mysql_password);
\r
595 if ($MYSQL_CONN == false) {
\r
596 _doError(_ERROR15 . ': ' . sql_error() );
\r
599 // <add for garble measure>
\r
600 // 2-2. set DEFAULT CHARSET and COLLATE
\r
601 $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info($MYSQL_CONN))));
\r
602 if ($mySqlVer >= '5.0.7' && phpversion() >= '5.2.3') {
\r
603 mysql_set_charset($charset);
\r
604 } elseif ($mySqlVer >= '4.1.0') {
\r
605 sql_query("SET NAMES " . $charset);
\r
607 $collation = ($charset == 'utf8') ? 'utf8_unicode_ci' : 'ujis_japanese_ci';
\r
608 // </add for garble measure>*/
\r
610 // 3. try to create database (if needed)
\r
611 if ($mysql_create == 1) {
\r
612 $sql = 'CREATE DATABASE '
\r
614 // <add for garble measure>
\r
615 if ($mySqlVer >= '4.1.0') {
\r
616 $sql .= ' DEFAULT CHARACTER SET '
\r
621 // </add for garble measure>*/
\r
622 sql_query($sql,$MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN));
\r
625 // 4. try to select database
\r
626 sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17);
\r
628 // 5. execute queries
\r
629 $filename = 'install.sql';
\r
630 $fd = fopen($filename, 'r');
\r
631 $queries = fread($fd, filesize($filename) );
\r
634 $queries = split("(;\n|;\r)", $queries);
\r
636 $aTableNames = array(
\r
637 'nucleus_actionlog',
\r
640 'nucleus_category',
\r
648 'nucleus_template',
\r
650 'nucleus_activation',
\r
653 // these are unneeded (one of the replacements above takes care of them)
\r
654 // 'nucleus_plugin_event',
\r
655 // 'nucleus_plugin_option',
\r
656 // 'nucleus_plugin_option_desc',
\r
657 // 'nucleus_skin_desc',
\r
658 // 'nucleus_template_desc',
\r
660 $aTableNamesPrefixed = array(
\r
661 $mysql_prefix . 'nucleus_actionlog',
\r
662 $mysql_prefix . 'nucleus_ban',
\r
663 $mysql_prefix . 'nucleus_blog',
\r
664 $mysql_prefix . 'nucleus_category',
\r
665 $mysql_prefix . 'nucleus_comment',
\r
666 $mysql_prefix . 'nucleus_config',
\r
667 $mysql_prefix . 'nucleus_item',
\r
668 $mysql_prefix . 'nucleus_karma',
\r
669 $mysql_prefix . 'nucleus_member',
\r
670 $mysql_prefix . 'nucleus_plugin',
\r
671 $mysql_prefix . 'nucleus_skin',
\r
672 $mysql_prefix . 'nucleus_template',
\r
673 $mysql_prefix . 'nucleus_team',
\r
674 $mysql_prefix . 'nucleus_activation',
\r
675 $mysql_prefix . 'nucleus_tickets'
\r
677 // these are unneeded (one of the replacements above takes care of them)
\r
678 // $mysql_prefix . 'nucleus_plugin_event',
\r
679 // $mysql_prefix . 'nucleus_plugin_option',
\r
680 // $mysql_prefix . 'nucleus_plugin_option_desc',
\r
681 // $mysql_prefix . 'nucleus_skin_desc',
\r
682 // $mysql_prefix . 'nucleus_template_desc',
\r
684 $count = count($queries);
\r
686 for ($idx = 0; $idx < $count; $idx++) {
\r
687 $query = trim($queries[$idx]);
\r
688 // echo "QUERY = " . htmlspecialchars($query) . "<p>";
\r
692 if ($mysql_usePrefix == 1) {
\r
693 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
\r
695 // <add for garble measure>
\r
696 if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0 && $mySqlVer >= '4.1.0') {
\r
697 $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
\r
699 // </add for garble measure>*/
\r
701 sql_query($query,$MYSQL_CONN) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . sql_error($MYSQL_CONN) );
\r
705 // 5a make first post
\r
706 if ($charset == 'ujis') {
\r
707 $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8');
\r
708 $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8');
\r
709 $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8');
\r
711 $itm_title = _1ST_POST_TITLE;
\r
712 $itm_body = _1ST_POST;
\r
713 $itm_more = _1ST_POST2;
\r
715 $newpost = "INSERT INTO "
\r
716 . tableName('nucleus_item')
\r
719 . "'" . $itm_title . "',"
\r
720 . " '" . $itm_body . "',"
\r
721 . " '" . $itm_more . "',"
\r
722 . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";
\r
723 sql_query($newpost,$MYSQL_CONN) or _doError(_ERROR18 . ' (' . htmlspecialchars($newpost) . '): ' . sql_error($MYSQL_CONN) );
\r
725 // 6. update global settings
\r
726 updateConfig('IndexURL', $config_indexurl);
\r
727 updateConfig('AdminURL', $config_adminurl);
\r
728 updateConfig('MediaURL', $config_mediaurl);
\r
729 updateConfig('SkinsURL', $config_skinsurl);
\r
730 updateConfig('PluginURL', $config_pluginurl);
\r
731 updateConfig('ActionURL', $config_actionurl);
\r
732 updateConfig('AdminEmail', $config_adminemail);
\r
733 updateConfig('SiteName', $config_sitename);
\r
734 if ($charset == 'ujis') {
\r
735 updateConfig('Language', 'japanese-euc');
\r
738 // 7. update GOD member
\r
739 $query = 'UPDATE ' . tableName('nucleus_member')
\r
740 . " SET mname = '" . addslashes($user_name) . "',"
\r
741 . " mrealname = '" . addslashes($user_realname) . "',"
\r
742 . " mpassword = '" . md5(addslashes($user_password) ) . "',"
\r
743 . " murl = '" . addslashes($config_indexurl) . "',"
\r
744 . " memail = '" . addslashes($user_email) . "',"
\r
750 sql_query($query,$MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN) );
\r
752 // 8. update weblog settings
\r
753 $query = 'UPDATE ' . tableName('nucleus_blog')
\r
754 . " SET bname = '" . addslashes($blog_name) . "',"
\r
755 . " bshortname = '" . addslashes($blog_shortname) . "',"
\r
756 . " burl = '" . addslashes($config_indexurl) . "'"
\r
760 sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );
\r
762 // 8-2. update category settings
\r
763 if ($charset == 'ujis') {
\r
764 $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8');
\r
765 $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8');
\r
767 $cat_name = _GENERALCAT_NAME;
\r
768 $cat_desc = _GENERALCAT_DESC;
\r
770 $query = 'UPDATE ' . tableName('nucleus_category')
\r
771 . " SET cname = '" . $cat_name . "',"
\r
772 . " cdesc = '" . $cat_desc . "'"
\r
776 sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );
\r
778 // 9. update item date
\r
779 $query = 'UPDATE ' . tableName('nucleus_item')
\r
780 . " SET itime = '" . date('Y-m-d H:i:s', time() ) ."'"
\r
781 . " WHERE inumber = 1";
\r
783 sql_query($query,$MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN) );
\r
785 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
786 $aSkinErrors = array();
\r
787 $aPlugErrors = array();
\r
789 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
790 // 10. set global variables
\r
791 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
\r
793 $MYSQL_HOST = $mysql_host;
\r
794 $MYSQL_USER = $mysql_user;
\r
795 $MYSQL_PASSWORD = $mysql_password;
\r
796 $MYSQL_DATABASE = $mysql_database;
\r
797 $MYSQL_PREFIX = ($mysql_usePrefix == 1) ? $mysql_prefix : '';
\r
799 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
801 $DIR_NUCLEUS = $config_adminpath;
\r
802 $DIR_MEDIA = $config_mediapath;
\r
803 $DIR_SKINS = $config_skinspath;
\r
804 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
805 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
806 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
808 // close database connection (needs to be closed if we want to include globalfunctions.php)
\r
809 sql_close($MYSQL_CONN);
\r
812 include_once($DIR_LIBS . 'globalfunctions.php');
\r
814 // 11. install custom skins
\r
815 $aSkinErrors = installCustomSkins($manager);
\r
816 $defskinQue = 'SELECT `sdnumber` as result FROM ' . sql_table('skin_desc') . ' WHERE `sdname` = "default"';
\r
817 $defSkinID = quickQuery($defskinQue);
\r
818 $updateQuery = 'UPDATE ' . sql_table('blog') . ' SET `bdefskin` = ' . intval($defSkinID) . ' WHERE `bnumber` = 1';
\r
819 sql_query($updateQuery);
\r
820 $updateQuery = 'UPDATE ' . sql_table('config') . ' SET `value` = ' . intval($defSkinID). ' WHERE `name` = "BaseSkin"';
\r
821 sql_query($updateQuery);
\r
823 // 12. install NP_Ping, if decided
\r
824 if ($weblog_ping == 1) {
\r
825 global $aConfPlugsToInstall;
\r
826 array_push($aConfPlugsToInstall, "NP_Ping");
\r
829 // 13. install custom plugins
\r
830 $aPlugErrors = installCustomPlugs($manager);
\r
833 // 14. Write config file ourselves (if possible)
\r
834 $bConfigWritten = 0;
\r
836 if (@file_exists('../config.php') && is_writable('../config.php') && $fp = @fopen('../config.php', 'w') ) {
\r
837 $config_data = '<' . '?php' . "\n\n";
\r
838 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
\r
839 $config_data .= " // mySQL connection information\n";
\r
840 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
\r
841 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
\r
842 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
\r
843 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
\r
844 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";
\r
845 $config_data .= " // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
\r
846 $config_data .= " // default is \$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
847 $config_data .= " //\$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
848 $config_data .= " //\$MYSQL_HANDLER = array('pdo','mysql');\n";
\r
849 $config_data .= " \$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";
\r
850 $config_data .= "\n";
\r
851 $config_data .= " // main nucleus directory\n";
\r
852 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
\r
853 $config_data .= "\n";
\r
854 $config_data .= " // path to media dir\n";
\r
855 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
\r
856 $config_data .= "\n";
\r
857 $config_data .= " // extra skin files for imported skins\n";
\r
858 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
\r
859 $config_data .= "\n";
\r
860 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
\r
861 $config_data .= " // you can redefine them if you wish\n";
\r
862 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
863 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
\r
864 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
865 $config_data .= "\n";
\r
866 $config_data .= " // include libs\n";
\r
867 $config_data .= " include(\$DIR_LIBS . 'globalfunctions.php');\n";
\r
868 $config_data .= " if (!extension_loaded('mbstring')) {\n";
\r
869 $config_data .= " include(\$DIR_LIBS . 'mb_emulator/mb-emulator.php');\n";
\r
870 $config_data .= " }\n";
\r
871 $config_data .= "?" . ">";
\r
873 $result = @fputs($fp, $config_data, strlen($config_data) );
\r
877 $bConfigWritten = 1;
\r
882 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
883 <html xmlns="http://www.w3.org/1999/xhtml">
\r
885 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
886 <title><?php echo _TITLE; ?></title>
\r
887 <style>@import url('../nucleus/styles/manual.css');</style>
\r
890 <div style='text-align:center'><img src='../nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
893 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
\r
895 if (count($aAllErrors) > 0) {
\r
896 echo '<h1>' . _TITLE2 . '</h1>';
\r
897 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
\r
900 if (!$bConfigWritten) { ?>
\r
901 <h1><?php echo _TITLE3; ?></h1>
\r
903 <? echo _TEXT10; ?>
\r
905 <pre><code><?php
\r
906 // mySQL connection information
\r
907 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
\r
908 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
\r
909 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
\r
910 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
\r
911 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
\r
913 // main nucleus directory
\r
914 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
\r
916 // path to media dir
\r
917 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
\r
919 // extra skin files for imported skins
\r
920 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
\r
922 // these dirs are normally sub dirs of the nucleus dir, but
\r
923 // you can redefine them if you wish
\r
924 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
925 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
926 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
929 include($DIR_LIBS . 'globalfunctions.php');
\r
930 if (!extension_loaded('mbstring')) {
\r
931 include($DIR_LIBS . 'mb_emulator/mb-emulator.php');
\r
935 <?php echo _TEXT11; ?>
\r
938 <?php echo _TEXT12; ?>
\r
943 <h1><?php echo _TITLE4; ?></h1>
\r
945 <?php echo _TEXT13; ?>
\r
949 <h1><?php echo _TITLE5; ?></h1>
\r
951 <?php echo _TEXT14; ?>
\r
954 <li><?php echo _TEXT14_L1; ?></li>
\r
955 <li><?php echo _TEXT14_L2; ?></li>
\r
958 <h1><?php echo _HEADER10; ?></h1>
\r
960 <?php echo _TEXT15; ?>
\r
963 <li><?php echo _TEXT15_L1; ?></li>
\r
964 <li><?php echo _TEXT15_L2; ?></li>
\r
965 <li><?php echo _TEXT15_L3; ?></li>
\r
968 <?php echo _TEXT16; ?>
\r
970 <h1><?php echo _HEADER11; ?></h1>
\r
972 <p><?php echo _TEXT16_H; ?>
\r
974 <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>
\r
975 <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>
\r
985 function installCustomPlugs(&$manager) {
\r
986 global $aConfPlugsToInstall, $DIR_LIBS;
\r
988 $aErrors = array();
\r
990 if (count($aConfPlugsToInstall) == 0) {
\r
994 $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
\r
995 $numCurrent = sql_num_rows($res);
\r
997 foreach ($aConfPlugsToInstall as $plugName) {
\r
998 // do this before calling getPlugin (in case the plugin id is used there)
\r
999 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
\r
1000 sql_query($query);
\r
1002 // get and install the plugin
\r
1003 $manager->clearCachedInfo('installedPlugins');
\r
1004 $plugin =& $manager->getPlugin($plugName);
\r
1005 $plugin->plugid = $numCurrent;
\r
1008 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
\r
1010 array_push($aErrors, _ERROR22 . $plugName);
\r
1014 $plugin->install();
\r
1017 // SYNC PLUGIN EVENT LIST
\r
1018 sql_query('DELETE FROM ' . sql_table('plugin_event') );
\r
1020 // loop over all installed plugins
\r
1021 $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
\r
1023 while($o = sql_fetch_object($res) ) {
\r
1025 $plug =& $manager->getPlugin($o->pfile);
\r
1028 $eventList = $plug->getEventList();
\r
1030 foreach ($eventList as $eventName) {
\r
1031 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
\r
1039 function installCustomSkins(&$manager) {
\r
1040 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1042 $aErrors = array();
\r
1044 if (empty($manager)) {
\r
1045 $manager = new MANAGER;
\r
1048 if (count($aConfSkinsToImport) == 0) {
\r
1052 // load skinie class
\r
1053 include_once($DIR_LIBS . 'skinie.php');
\r
1055 $importer = new SKINIMPORT();
\r
1057 foreach ($aConfSkinsToImport as $skinName) {
\r
1058 $importer->reset();
\r
1059 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1061 if (!@file_exists($skinFile) ) {
\r
1062 array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2);
\r
1066 $error = $importer->readFile($skinFile);
\r
1069 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1073 $error = $importer->writeToDatabase(1);
\r
1076 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1084 // give an error if one or more nucleus are not accessible
\r
1085 function doCheckFiles() {
\r
1086 $missingfiles = array();
\r
1091 '../nucleus/index.php',
\r
1092 '../nucleus/libs/globalfunctions.php',
\r
1093 '../nucleus/libs/ADMIN.php',
\r
1094 '../nucleus/libs/BLOG.php',
\r
1095 '../nucleus/libs/COMMENT.php',
\r
1096 '../nucleus/libs/COMMENTS.php',
\r
1097 '../nucleus/libs/ITEM.php',
\r
1098 '../nucleus/libs/MEMBER.php',
\r
1099 '../nucleus/libs/SKIN.php',
\r
1100 '../nucleus/libs/TEMPLATE.php',
\r
1101 '../nucleus/libs/MEDIA.php',
\r
1102 '../nucleus/libs/ACTIONLOG.php',
\r
1103 '../nucleus/media.php'
\r
1106 $count = count($files);
\r
1108 for ($i = 0; $i < $count; $i++) {
\r
1109 if (!is_readable($files[$i]) ) {
\r
1110 array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2);
\r
1114 // The above code replaces several if statements of the form:
\r
1116 // if (!is_readable('install.sql') ) {
\r
1117 // array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
\r
1120 if (count($missingfiles) > 0) {
\r
1121 showErrorMessages($missingfiles);
\r
1125 function updateConfig($name, $val) {
\r
1126 global $MYSQL_CONN;
\r
1127 $name = addslashes($name);
\r
1128 $val = trim(addslashes($val) );
\r
1130 $query = 'UPDATE ' . tableName('nucleus_config')
\r
1131 . " SET value = '$val'"
\r
1132 . " WHERE name = '$name'";
\r
1134 sql_query($query,$MYSQL_CONN) or _doError(_ERROR26 . ': ' . sql_error($MYSQL_CONN) );
\r
1135 return sql_insert_id($MYSQL_CONN);
\r
1138 function replaceDoubleBackslash($input) {
\r
1139 return str_replace('\\', '/', $input);
\r
1142 function endsWithSlash($s) {
\r
1143 return (strrpos($s, '/') == strlen($s) - 1);
\r
1147 * Checks if email address is valid
\r
1149 function _isValidMailAddress($address) {
\r
1150 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
\r
1157 // returns true if the given string is a valid shortname
\r
1158 // (to check short blog names and nicknames)
\r
1159 // logic: starts and ends with a non space, can contain spaces in between
\r
1161 function _isValidShortName($name) {
\r
1162 if (eregi("^[a-z0-9]+$", $name) ) {
\r
1171 // returns true if the given string is a valid display name
\r
1172 // (to check nicknames)
\r
1173 function _isValidDisplayName($name) {
\r
1174 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
\r
1181 function _doError($msg) {
\r
1183 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1184 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1186 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
1187 <title><?php echo _TITLE; ?></title>
\r
1188 <style>@import url('../nucleus/styles/manual.css');</style>
\r
1191 <div style='text-align:center'><img src='../nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
1192 <h1><?php echo _ERROR27; ?></h1>
\r
1194 <p><?php echo _ERROR28; ?> "<?php echo $msg; ?>";</p>
\r
1196 <p><a href="index.php" onclick="history.back();"><?php echo _TEXT17; ?></a></p>
\r
1204 function showErrorMessages($errors) {
\r
1206 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1207 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1209 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
1210 <title><?php echo _TITLE; ?></title>
\r
1211 <style>@import url('../nucleus/styles/manual.css');</style>
\r
1214 <div style='text-align:center'><img src='../nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
1215 <h1><?php echo _ERROR27; ?></h1>
\r
1217 <p><?php echo _ERROR29; ?>:</p>
\r
1222 while($msg = array_shift($errors) ) {
\r
1223 echo '<li>' . $msg . '</li>';
\r
1229 <p><a href="index.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>
\r
1237 /* for the non-php systems that decide to show the contents:
\r