3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2012 The Nucleus Group
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
12 * This script will install the Nucleus tables in your SQL-database,
\r
13 * and initialize the data in those tables.
\r
15 * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
\r
16 * ?><div style="font-size: xx-large;">If you see this text in your browser when you open <i>/install/</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
20 This part of the index.php code allows for customization of the install process.
\r
21 When distributing plugins or skins together with a Nucleus installation, the
\r
22 configuration below will instruct to install them
\r
24 -- Start Of Configurable Part --
\r
27 include('./install_lang_japanese.php');
\r
29 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
\r
33 // array('NP_TrackBack', 'NP_MemberGoodies')
\r
34 $aConfPlugsToInstall = array(
\r
39 // array with skins to install. skins must be present under the skins/ directory with
\r
40 // a subdirectory having the same name that contains a skinbackup.xml file
\r
43 // array('base','rsd')
\r
44 $aConfSkinsToImport = array(
\r
52 -- End Of Configurable Part --
\r
55 // don't give warnings for uninitialized vars
\r
56 error_reporting(E_ERROR | E_WARNING | E_PARSE);
\r
58 // make sure there's no unnecessary escaping:
\r
59 set_magic_quotes_runtime(0);
\r
61 // if there are some plugins or skins to import, do not include vars
\r
62 // in globalfunctions.php again... so set a flag
\r
63 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
65 $CONF['installscript'] = 1;
\r
68 // compatibility script for php < 4.1.0
\r
69 // ToDo: remove this here and from the core
\r
70 if (phpversion() >= '4.1.0') {
\r
71 include_once('../nucleus/libs/vars4.1.0.php');
\r
73 include_once('../nucleus/libs/vars4.0.6.php');
\r
76 // include core classes that are needed for login & plugin handling
\r
77 include_once('../nucleus/libs/mysql.php');
\r
78 // added for 3.5 sql_* wrapper
\r
79 global $MYSQL_HANDLER;
\r
80 //set the handler if different from mysql (or mysqli)
\r
81 //$MYSQL_HANDLER = array('pdo','mysql');
\r
82 if (!isset($MYSQL_HANDLER)) {
\r
83 $MYSQL_HANDLER = array('mysql','');
\r
85 include_once('../nucleus/libs/sql/'.$MYSQL_HANDLER[0].'.php');
\r
86 // end new for 3.5 sql_* wrapper
\r
88 // check if mysql support is installed
\r
89 // this check may not make sense, as is, in a version past 3.5x
\r
90 if (!function_exists('mysql_query') ) {
\r
94 if (postVar('action') == 'go') {
\r
103 * Show the form for the installation settings
\r
105 function showInstallForm() {
\r
106 // 0. pre check if all necessary files exist
\r
110 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
111 <html xmlns="http://www.w3.org/1999/xhtml">
\r
113 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
\r
114 <title><?php echo _TITLE; ?></title>
\r
115 <style type="text/css"><!--
\r
116 @import url('../nucleus/documentation/styles/manual.css');
\r
118 <script type="text/javascript"><!--
\r
119 var submitcount = 0;
\r
121 // function to make sure the submit button only gets pressed once
\r
122 function checkSubmit() {
\r
123 if (submitcount == 0) {
\r
133 <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->
\r
134 <form method="post" action="index.php">
\r
136 <h1><?php echo _HEADER1; ?></h1>
\r
138 <?php echo _TEXT1; ?>
\r
140 <h1><?php echo _HEADER1_2 ?></h1>
\r
142 <?php echo _TEXT1_2; ?>
\r
145 <legend><?php echo _TEXT1_2_TAB_HEAD; ?></legend>
\r
148 <td><?php echo _TEXT1_2_TAB_FIELD1; ?></td>
\r
150 <select name="charset" tabindex="10000">
\r
151 <option value="utf8" selected="selected">UTF-8</option>
\r
152 <option value="ujis" >EUC-JP</option>
\r
159 <h1><?php echo _HEADER2; ?></h1>
\r
161 <?php echo _TEXT2; ?>
\r
171 // Turn on output buffer
\r
172 // Needed to repress the output of the sql function that are
\r
173 // not part of php (in this case the @ operator doesn't work)
\r
175 // note: this piece of code is taken from phpMyAdmin
\r
176 $conn = sql_connect_args('localhost','','');
\r
177 $result = @sql_query('SELECT VERSION() AS version', $conn);
\r
178 if ($result != FALSE && sql_num_rows($result) > 0) {
\r
179 $row = sql_fetch_array($result);
\r
180 $match = explode('.', $row['version']);
\r
182 $result = @sql_query('SHOW VARIABLES LIKE \'version\'', $conn);
\r
183 if ($result != FALSE && @sql_num_rows($result) > 0) {
\r
184 $row = sql_fetch_row($result);
\r
185 $match = explode('.', $row[1]);
\r
187 $output = (function_exists('shell_exec')) ? @shell_exec('mysql -V') : '0.0.0';
\r
188 preg_match('#[0-9]+\.[0-9]+\.[0-9]+#', $output, $version);
\r
189 $match = explode('.', $version[0]);
\r
191 if ($match[0] == '') {
\r
198 @sql_disconnect($conn);
\r
199 //End and clean output buffer
\r
201 $mySqlVersion = implode($match, '.');
\r
202 $minVersion = '3.23';
\r
204 if (version_compare($mySqlVersion, '0.0.0', '==')) {
\r
205 echo _NOTIFICATION1;
\r
208 echo $mySqlVersion;
\r
211 if (version_compare($mySqlVersion, $minVersion, '<')) {
\r
212 echo ' <span class="warning" style="display:block">' . sprintf(_TEXT2_WARN1, $minVersion) . '</span>';
\r
218 if (phpversion() < '5.0.0') {
\r
219 echo ' <p class="deprecated">' . _TEXT2_WARN2 . '</p>';
\r
228 // tell people how they can have their config file filled out automatically
\r
229 if (@file_exists('../config.php') && @!is_writable('../config.php')) {
\r
232 <h1><?php echo _HEADER3; ?></h1>
\r
238 <h1><?php echo _HEADER4; ?></h1>
\r
240 <?php echo _TEXT4; ?>
\r
243 <legend><?php echo _TEXT4_TAB_HEAD; ?></legend>
\r
246 <td><label for="if_mySQL_host"><?php echo _TEXT4_TAB_FIELD1; ?>:</label></td>
\r
247 <td><input id="if_mySQL_host" name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" tabindex="10010" /></td>
\r
250 <td><label for="if_mySQL_user"><?php echo _TEXT4_TAB_FIELD2; ?>:</label></td>
\r
251 <td><input id="if_mySQL_user" name="mySQL_user" tabindex="10020" /></td>
\r
254 <td><label for="if_mySQL_password"><?php echo _TEXT4_TAB_FIELD3; ?>:</label></td>
\r
255 <td><input id="if_mySQL_password" name="mySQL_password" type="password" tabindex="10030" /></td>
\r
258 <td><label for="if_mySQL_database"><?php echo _TEXT4_TAB_FIELD4; ?>:</label></td>
\r
259 <td><input id="if_mySQL_database" 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
265 <legend><?php echo _TEXT4_TAB2_HEAD; ?></legend>
\r
268 <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
269 <td><input name="mySQL_tablePrefix" value="" tabindex="10070" /></td>
\r
273 <?php echo _TEXT4_TAB2_ADD; ?>
\r
277 <h1><?php echo _HEADER5; ?></h1>
\r
279 <?php echo _TEXT5; ?>
\r
283 // no need to this all! dirname(__FILE__) is all we need -- moraes
\r
285 // discover full path
\r
286 $fullPath = serverVar('PATH_TRANSLATED');
\r
288 if ($fullPath == '') {
\r
289 $fullPath = serverVar('SCRIPT_FILENAME');
\r
292 $basePath = str_replace('install.php', '', $fullPath);
\r
293 $basePath = replaceDoubleBackslash($basePath);
\r
294 $basePath = replaceDoubleBackslash($basePath);
\r
296 // add slash at end if necessary
\r
297 if (!endsWithSlash($basePath) ) {
\r
302 $basePath = str_replace('install', '', dirname(__FILE__));
\r
306 <legend><?php echo _TEXT5_TAB_HEAD; ?></legend>
\r
309 <td><label for="if_IndexURL"><?php echo _TEXT5_TAB_FIELD1;?>:</label></td>
\r
310 <td><input id="if_IndexURL" name="IndexURL" size="60" value="<?php
\r
311 $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
\r
312 $url = str_replace('install/index.php', '', $url);
\r
313 $url = replaceDoubleBackslash($url);
\r
315 // add slash at end if necessary
\r
316 if (!endsWithSlash($url) ) {
\r
320 echo $url; ?>" tabindex="10080" /></td>
\r
323 <td><label for="if_AdminURL"><?php echo _TEXT5_TAB_FIELD2;?>:</label></td>
\r
324 <td><input id="if_AdminURL" name="AdminURL" size="60" value="<?php
\r
326 echo $url . 'nucleus/';
\r
327 } ?>" tabindex="10090" /></td>
\r
330 <td><label for="if_AdminPath"><?php echo _TEXT5_TAB_FIELD3;?>:</label></td>
\r
331 <td><input id="if_AdminPath" name="AdminPath" size="60" value="<?php
\r
333 echo $basePath . 'nucleus/';
\r
334 } ?>" tabindex="10100" /></td>
\r
337 <td><label for="if_MediaURL"><?php echo _TEXT5_TAB_FIELD4;?>:</label></td>
\r
338 <td><input id="if_MediaURL" name="MediaURL" size="60" value="<?php
\r
340 echo $url . 'media/';
\r
341 } ?>" tabindex="10110" /></td>
\r
344 <td><label for="if_MediaPath"><?php echo _TEXT5_TAB_FIELD5;?>:</label></td>
\r
345 <td><input id="if_MediaPath" name="MediaPath" size="60" value="<?php
\r
347 echo $basePath . 'media/';
\r
348 } ?>" tabindex="10120" /></td>
\r
351 <td><label for="if_SkinsURL"><?php echo _TEXT5_TAB_FIELD6;?>:</label></td>
\r
352 <td><input id="if_SkinsURL" name="SkinsURL" size="60" value="<?php
\r
354 echo $url . 'skins/';
\r
355 } ?>" tabindex="10130" />
\r
356 <br />(<?php echo _TEXT5_TAB_FIELD7_2; ?>)
\r
360 <td><label for="if_SkinsPath"><?php echo _TEXT5_TAB_FIELD7;?>:</label></td>
\r
361 <td><input id="if_SkinsPath" name="SkinsPath" size="60" value="<?php
\r
363 echo $basePath . 'skins/';
\r
364 } ?>" tabindex="10140" />
\r
365 <br />(<?php echo _TEXT5_TAB_FIELD7_2; ?>)
\r
369 <td><label for="if_PluginURL"><?php echo _TEXT5_TAB_FIELD8;?>:</label></td>
\r
370 <td><input id="if_PluginURL" name="PluginURL" size="60" value="<?php
\r
372 echo $url . 'nucleus/plugins/';
\r
373 } ?>" tabindex="10150" /></td>
\r
376 <td><label for="if_ActionURL"><?php echo _TEXT5_TAB_FIELD9;?>:</label></td>
\r
377 <td><input id="if_ActionURL" name="ActionURL" size="60" value="<?php
\r
379 echo $url . 'action.php';
\r
380 } ?>" tabindex="10160" />
\r
381 <br />(<?php echo _TEXT5_TAB_FIELD9_2;?>)
\r
387 <?php echo _TEXT5_2; ?>
\r
389 <h1><?php echo _HEADER6; ?></h1>
\r
391 <?php echo _TEXT6; ?>
\r
394 <legend><?php echo _TEXT6_TAB_HEAD; ?></legend>
\r
397 <td><label for="if_User_name"><?php echo _TEXT6_TAB_FIELD1; ?>:</label></td>
\r
398 <td><input id="if_User_name" name="User_name" value="" tabindex="10170" /> <small>(<?php echo _TEXT6_TAB_FIELD1_2; ?>)</small></td>
\r
401 <td><label for="if_User_realname"><?php echo _TEXT6_TAB_FIELD2; ?>:</label></td>
\r
402 <td><input id="if_User_realname" name="User_realname" value="" tabindex="10180" /></td>
\r
405 <td><label for="if_User_password"><?php echo _TEXT6_TAB_FIELD3; ?>:</label></td>
\r
406 <td><input id="if_User_password" name="User_password" type="password" value="" tabindex="10190" /></td>
\r
409 <td><label for="if_User_password2"><?php echo _TEXT6_TAB_FIELD4; ?>:</label></td>
\r
410 <td><input id="if_User_password2" name="User_password2" type="password" value="" tabindex="10200" /></td>
\r
413 <td><label for="if_User_email"><?php echo _TEXT6_TAB_FIELD5; ?>:</label></td>
\r
414 <td><input id="if_User_email" name="User_email" value="" tabindex="10210" /> <small>(<?php echo _TEXT6_TAB_FIELD5_2; ?>)</small></td>
\r
419 <h1><?php echo _HEADER7; ?></h1>
\r
421 <?php echo _TEXT7; ?>
\r
424 <legend><?php echo _TEXT7_TAB_HEAD; ?></legend>
\r
427 <td><label for="if_Blog_name"><?php echo _TEXT7_TAB_FIELD1; ?>:</label></td>
\r
428 <td><input id="if_Blog_name" name="Blog_name" size="60" value="My Nucleus CMS" tabindex="10220" /></td>
\r
431 <td><label for="if_Blog_shortname"><?php echo _TEXT7_TAB_FIELD2; ?>:</label></td>
\r
432 <td><input id="if_Blog_shortname" name="Blog_shortname" value="mynucleuscms" tabindex="10230" /> <small>(<?php echo _TEXT7_TAB_FIELD2_2; ?>)</small></td>
\r
437 <h1><?php echo _HEADER8; ?></h1>
\r
440 <legend><?php echo _TEXT8_TAB_HEADER; ?></legend>
\r
443 <td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" tabindex="10240" /><label for="Weblog_ping"><?php echo _TEXT8_TAB_FIELD1; ?></label></td>
\r
448 <h1><?php echo _HEADER9; ?></h1>
\r
450 <?php echo _TEXT9; ?>
\r
453 <input name="action" value="go" type="hidden" />
\r
454 <input type="submit" value="<?php echo _BUTTON1; ?>" onclick="return checkSubmit();" tabindex="10250" />
\r
464 * Add a table prefix if it is used
\r
466 * @param $unPrefixed
\r
467 * table name with prefix
\r
469 function tableName($unPrefixed) {
\r
470 global $mysql_usePrefix, $mysql_prefix;
\r
472 if ($mysql_usePrefix == 1) {
\r
473 return $mysql_prefix . $unPrefixed;
\r
475 return $unPrefixed;
\r
480 * The installation process itself
\r
482 function doInstall() {
\r
483 global $mysql_usePrefix, $mysql_prefix, $weblog_ping;
\r
485 // 0. put all POST-vars into vars
\r
486 $mysql_host = postVar('mySQL_host');
\r
487 $mysql_user = postVar('mySQL_user');
\r
488 $mysql_password = postVar('mySQL_password');
\r
489 $mysql_database = postVar('mySQL_database');
\r
490 $mysql_create = postVar('mySQL_create');
\r
491 $mysql_usePrefix = postVar('mySQL_usePrefix');
\r
492 $mysql_prefix = postVar('mySQL_tablePrefix');
\r
493 $config_indexurl = postVar('IndexURL');
\r
494 $config_adminurl = postVar('AdminURL');
\r
495 $config_adminpath = postVar('AdminPath');
\r
496 $config_mediaurl = postVar('MediaURL');
\r
497 $config_skinsurl = postVar('SkinsURL');
\r
498 $config_pluginurl = postVar('PluginURL');
\r
499 $config_actionurl = postVar('ActionURL');
\r
500 $config_mediapath = postVar('MediaPath');
\r
501 $config_skinspath = postVar('SkinsPath');
\r
502 $user_name = postVar('User_name');
\r
503 $user_realname = postVar('User_realname');
\r
504 $user_password = postVar('User_password');
\r
505 $user_password2 = postVar('User_password2');
\r
506 $user_email = postVar('User_email');
\r
507 $blog_name = postVar('Blog_name');
\r
508 $blog_shortname = postVar('Blog_shortname');
\r
509 $charset = postVar('charset');
\r
510 $config_adminemail = $user_email;
\r
511 $config_sitename = $blog_name;
\r
512 $weblog_ping = postVar('Weblog_ping');
\r
516 $config_indexurl = replaceDoubleBackslash($config_indexurl);
\r
517 $config_adminurl = replaceDoubleBackslash($config_adminurl);
\r
518 $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
\r
519 $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
\r
520 $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
\r
521 $config_actionurl = replaceDoubleBackslash($config_actionurl);
\r
522 $config_adminpath = replaceDoubleBackslash($config_adminpath);
\r
523 $config_skinspath = replaceDoubleBackslash($config_skinspath);
\r
524 $config_mediapath = replaceDoubleBackslash($config_mediapath);
\r
527 * Include and initialize multibyte functions as a replacement for mbstring extension
\r
528 * if mbstring extension is not loaded.
\r
529 * Jan.28, 2011. Japanese Package Release Team
\r
531 if (!function_exists('mb_convert_encoding')){
\r
532 global $mbemu_internals;
\r
533 include_once($config_adminpath.'libs/mb_emulator/mb-emulator.php');
\r
535 if (function_exists('date_default_timezone_set')){
\r
536 @date_default_timezone_set((function_exists('date_default_timezone_get')) ? @date_default_timezone_get() : 'UTC');
\r
539 if ($charset == 'ujis') {
\r
540 define('_CHARSET', 'EUC-JP');
\r
541 $config_sitename = mb_convert_encoding($config_sitename, _CHARSET, 'UTF-8');
\r
542 $user_realname = mb_convert_encoding($user_realname, _CHARSET, 'UTF-8');
\r
543 $blog_name = mb_convert_encoding($blog_name, _CHARSET, 'UTF-8');
\r
545 define('_CHARSET', 'UTF-8');
\r
549 // 1. check all the data
\r
552 if (!$mysql_database) {
\r
553 array_push($errors, _ERROR2);
\r
556 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
\r
557 array_push($errors, _ERROR3);
\r
560 if (($mysql_usePrefix == 1) && (!preg_match('#^[a-zA-Z0-9_]+$#', $mysql_prefix) ) ) {
\r
561 array_push($errors, _ERROR4);
\r
564 // TODO: add action.php check
\r
565 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
\r
566 array_push($errors, _ERROR5);
\r
569 if (!endsWithSlash($config_adminpath) ) {
\r
570 array_push($errors, _ERROR6);
\r
573 if (!endsWithSlash($config_mediapath) ) {
\r
574 array_push($errors, _ERROR7);
\r
577 if (!endsWithSlash($config_skinspath) ) {
\r
578 array_push($errors, _ERROR8);
\r
581 if (!is_dir($config_adminpath) ) {
\r
582 array_push($errors, _ERROR9);
\r
585 if (!_isValidMailAddress($user_email) ) {
\r
586 array_push($errors, _ERROR10);
\r
589 if (!_isValidDisplayName($user_name) ) {
\r
590 array_push($errors, _ERROR11);
\r
593 if (!$user_password || !$user_password2) {
\r
594 array_push($errors, _ERROR12);
\r
597 if ($user_password != $user_password2) {
\r
598 array_push($errors, _ERROR13);
\r
601 if (!_isValidShortName($blog_shortname) ) {
\r
602 array_push($errors, _ERROR14);
\r
605 if (sizeof($errors) > 0) {
\r
606 showErrorMessages($errors);
\r
609 // 2. try to log in to mySQL
\r
611 global $MYSQL_CONN;
\r
612 // this will need to be changed if we ever allow
\r
613 $MYSQL_CONN = @sql_connect_args($mysql_host, $mysql_user, $mysql_password);
\r
615 if ($MYSQL_CONN == false) {
\r
616 _doError(_ERROR15 . ': ' . sql_error() );
\r
619 // 3. try to create database (if needed)
\r
620 $mySqlVer = implode('.', array_map('intval', explode('.', sql_get_server_info())));
\r
621 $collation = ($charset == 'utf8') ? 'utf8_general_ci' : 'ujis_japanese_ci';
\r
622 if ($mysql_create == 1) {
\r
623 $sql = 'CREATE DATABASE '
\r
625 // <add for garble measure>
\r
626 if (version_compare($mySqlVer, '4.1.0', '>=')) {
\r
627 $sql .= ' DEFAULT CHARACTER SET '
\r
632 // </add for garble measure>*/
\r
633 sql_query($sql,$MYSQL_CONN) or _doError(_ERROR16 . ': ' . sql_error($MYSQL_CONN));
\r
636 // 4. try to select database
\r
637 sql_select_db($mysql_database,$MYSQL_CONN) or _doError(_ERROR17);
\r
640 * 4.5. set character set to this database in MySQL server
\r
641 * This processing is added by Nucleus CMS Japanese Package Release Team as of Mar.30, 2011
\r
643 sql_set_charset_jp($charset);
\r
646 // 5. execute queries
\r
647 $filename = 'install.sql';
\r
648 $fd = fopen($filename, 'r');
\r
649 $queries = fread($fd, filesize($filename) );
\r
652 $queries = split("(;\n|;\r)", $queries);
\r
654 $aTableNames = array(
\r
655 'nucleus_actionlog',
\r
658 'nucleus_category',
\r
666 'nucleus_template',
\r
668 'nucleus_activation',
\r
671 // these are unneeded (one of the replacements above takes care of them)
\r
672 // 'nucleus_plugin_event',
\r
673 // 'nucleus_plugin_option',
\r
674 // 'nucleus_plugin_option_desc',
\r
675 // 'nucleus_skin_desc',
\r
676 // 'nucleus_template_desc',
\r
678 $aTableNamesPrefixed = array(
\r
679 $mysql_prefix . 'nucleus_actionlog',
\r
680 $mysql_prefix . 'nucleus_ban',
\r
681 $mysql_prefix . 'nucleus_blog',
\r
682 $mysql_prefix . 'nucleus_category',
\r
683 $mysql_prefix . 'nucleus_comment',
\r
684 $mysql_prefix . 'nucleus_config',
\r
685 $mysql_prefix . 'nucleus_item',
\r
686 $mysql_prefix . 'nucleus_karma',
\r
687 $mysql_prefix . 'nucleus_member',
\r
688 $mysql_prefix . 'nucleus_plugin',
\r
689 $mysql_prefix . 'nucleus_skin',
\r
690 $mysql_prefix . 'nucleus_template',
\r
691 $mysql_prefix . 'nucleus_team',
\r
692 $mysql_prefix . 'nucleus_activation',
\r
693 $mysql_prefix . 'nucleus_tickets'
\r
695 // these are unneeded (one of the replacements above takes care of them)
\r
696 // $mysql_prefix . 'nucleus_plugin_event',
\r
697 // $mysql_prefix . 'nucleus_plugin_option',
\r
698 // $mysql_prefix . 'nucleus_plugin_option_desc',
\r
699 // $mysql_prefix . 'nucleus_skin_desc',
\r
700 // $mysql_prefix . 'nucleus_template_desc',
\r
702 $count = count($queries);
\r
704 for ($idx = 0; $idx < $count; $idx++) {
\r
705 $query = trim($queries[$idx]);
\r
706 // echo "QUERY = " . htmlspecialchars($query) . "<p>";
\r
710 if ($mysql_usePrefix == 1) {
\r
711 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
\r
713 // <add for garble measure>
\r
714 if ($mysql_create != 1 && strpos($query, 'CREATE TABLE') === 0 && version_compare($mySqlVer, '4.1.0', '>=')) {
\r
715 $query .= ' DEFAULT CHARACTER SET ' . $charset . ' COLLATE ' . $collation;
\r
717 // </add for garble measure>*/
\r
719 sql_query($query,$MYSQL_CONN) or _doError(_ERROR30 . ' (' . htmlspecialchars($query) . '): ' . sql_error($MYSQL_CONN) );
\r
723 // 5a make first post
\r
724 if (strtoupper(_CHARSET) != 'UTF-8') {
\r
725 $itm_title = mb_convert_encoding(_1ST_POST_TITLE, _CHARSET, 'UTF-8');
\r
726 $itm_body = mb_convert_encoding(_1ST_POST, _CHARSET, 'UTF-8');
\r
727 $itm_more = mb_convert_encoding(_1ST_POST2, _CHARSET, 'UTF-8');
\r
729 $itm_title = _1ST_POST_TITLE;
\r
730 $itm_body = _1ST_POST;
\r
731 $itm_more = _1ST_POST2;
\r
733 $newpost = "INSERT INTO "
\r
734 . tableName('nucleus_item')
\r
737 . "'" . $itm_title . "',"
\r
738 . " '" . $itm_body . "',"
\r
739 . " '" . $itm_more . "',"
\r
740 . " 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";
\r
741 sql_query($newpost,$MYSQL_CONN) or _doError(_ERROR18 . ' (' . htmlspecialchars($newpost) . '): ' . sql_error($MYSQL_CONN) );
\r
743 // 6. update global settings
\r
744 updateConfig('IndexURL', $config_indexurl);
\r
745 updateConfig('AdminURL', $config_adminurl);
\r
746 updateConfig('MediaURL', $config_mediaurl);
\r
747 updateConfig('SkinsURL', $config_skinsurl);
\r
748 updateConfig('PluginURL', $config_pluginurl);
\r
749 updateConfig('ActionURL', $config_actionurl);
\r
750 updateConfig('AdminEmail', $config_adminemail);
\r
751 updateConfig('SiteName', $config_sitename);
\r
752 if ($charset == 'ujis') {
\r
753 updateConfig('Language', 'japanese-euc');
\r
756 // 7. update GOD member
\r
757 $query = 'UPDATE ' . tableName('nucleus_member')
\r
758 . " SET mname = '" . addslashes($user_name) . "',"
\r
759 . " mrealname = '" . addslashes($user_realname) . "',"
\r
760 . " mpassword = '" . md5(addslashes($user_password) ) . "',"
\r
761 . " murl = '" . addslashes($config_indexurl) . "',"
\r
762 . " memail = '" . addslashes($user_email) . "',"
\r
768 sql_query($query,$MYSQL_CONN) or _doError(_ERROR19 . ': ' . sql_error($MYSQL_CONN) );
\r
770 // 8. update weblog settings
\r
771 $query = 'UPDATE ' . tableName('nucleus_blog')
\r
772 . " SET bname = '" . addslashes($blog_name) . "',"
\r
773 . " bshortname = '" . addslashes($blog_shortname) . "',"
\r
774 . " burl = '" . addslashes($config_indexurl) . "'"
\r
778 sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );
\r
780 // 8-2. update category settings
\r
781 if (strtoupper(_CHARSET) != 'UTF-8') {
\r
782 $cat_name = mb_convert_encoding(_GENERALCAT_NAME, _CHARSET, 'UTF-8');
\r
783 $cat_desc = mb_convert_encoding(_GENERALCAT_DESC, _CHARSET, 'UTF-8');
\r
785 $cat_name = _GENERALCAT_NAME;
\r
786 $cat_desc = _GENERALCAT_DESC;
\r
788 $query = 'UPDATE ' . tableName('nucleus_category')
\r
789 . " SET cname = '" . $cat_name . "',"
\r
790 . " cdesc = '" . $cat_desc . "'"
\r
794 sql_query($query,$MYSQL_CONN) or _doError(_ERROR20 . ': ' . sql_error($MYSQL_CONN) );
\r
796 // 9. update item date
\r
797 $query = 'UPDATE ' . tableName('nucleus_item')
\r
798 . " SET itime = '" . date('Y-m-d H:i:s', time() ) ."'"
\r
799 . " WHERE inumber = 1";
\r
801 sql_query($query,$MYSQL_CONN) or _doError(_ERROR21 . ': ' . sql_error($MYSQL_CONN) );
\r
803 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
804 $aSkinErrors = array();
\r
805 $aPlugErrors = array();
\r
807 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
\r
808 // 10. set global variables
\r
809 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
\r
811 $MYSQL_HOST = $mysql_host;
\r
812 $MYSQL_USER = $mysql_user;
\r
813 $MYSQL_PASSWORD = $mysql_password;
\r
814 $MYSQL_DATABASE = $mysql_database;
\r
815 $MYSQL_PREFIX = ($mysql_usePrefix == 1) ? $mysql_prefix : '';
\r
817 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
819 $DIR_NUCLEUS = $config_adminpath;
\r
820 $DIR_MEDIA = $config_mediapath;
\r
821 $DIR_SKINS = $config_skinspath;
\r
822 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
823 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
824 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
826 // close database connection (needs to be closed if we want to include globalfunctions.php)
\r
827 sql_close($MYSQL_CONN);
\r
830 include_once($DIR_LIBS . 'globalfunctions.php');
\r
832 // 11. install custom skins
\r
833 $aSkinErrors = installCustomSkins($manager);
\r
834 $defskinQue = 'SELECT `sdnumber` as result FROM ' . sql_table('skin_desc') . ' WHERE `sdname` = "default"';
\r
835 $defSkinID = quickQuery($defskinQue);
\r
836 $updateQuery = 'UPDATE ' . sql_table('blog') . ' SET `bdefskin` = ' . intval($defSkinID) . ' WHERE `bnumber` = 1';
\r
837 sql_query($updateQuery);
\r
838 $updateQuery = 'UPDATE ' . sql_table('config') . ' SET `value` = ' . intval($defSkinID). ' WHERE `name` = "BaseSkin"';
\r
839 sql_query($updateQuery);
\r
841 // 12. install NP_Ping, if decided
\r
842 if ($weblog_ping == 1) {
\r
843 global $aConfPlugsToInstall;
\r
844 array_push($aConfPlugsToInstall, "NP_Ping");
\r
847 // 13. install custom plugins
\r
848 $aPlugErrors = installCustomPlugs($manager);
\r
851 // 14. Write config file ourselves (if possible)
\r
852 $bConfigWritten = 0;
\r
854 if (@file_exists('../config.php') && is_writable('../config.php') && $fp = @fopen('../config.php', 'w') ) {
\r
855 $config_data = '<' . '?php' . "\n\n";
\r
856 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
\r
857 $config_data .= " // mySQL connection information\n";
\r
858 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
\r
859 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
\r
860 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
\r
861 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
\r
862 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1) ? $mysql_prefix : '') . "';\n";
\r
863 $config_data .= " // new in 3.50. first element is db handler, the second is the db driver used by the handler\n";
\r
864 $config_data .= " // default is \$MYSQL_HANDLER = array('mysql','');\n";
\r
865 $config_data .= " //\$MYSQL_HANDLER = array('mysql','mysql');\n";
\r
866 $config_data .= " //\$MYSQL_HANDLER = array('pdo','mysql');\n";
\r
867 $config_data .= " \$MYSQL_HANDLER = array('".$MYSQL_HANDLER[0]."','".$MYSQL_HANDLER[1]."');\n";
\r
868 $config_data .= "\n";
\r
869 $config_data .= " // main nucleus directory\n";
\r
870 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
\r
871 $config_data .= "\n";
\r
872 $config_data .= " // path to media dir\n";
\r
873 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
\r
874 $config_data .= "\n";
\r
875 $config_data .= " // extra skin files for imported skins\n";
\r
876 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
\r
877 $config_data .= "\n";
\r
878 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
\r
879 $config_data .= " // you can redefine them if you wish\n";
\r
880 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
881 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
\r
882 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
883 $config_data .= "\n";
\r
884 $config_data .= " // include libs\n";
\r
885 $config_data .= " include(\$DIR_LIBS . 'globalfunctions.php');\n";
\r
886 $config_data .= "?" . ">";
\r
888 $result = @fputs($fp, $config_data, strlen($config_data) );
\r
892 $bConfigWritten = 1;
\r
897 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
898 <html xmlns="http://www.w3.org/1999/xhtml">
\r
900 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
901 <title><?php echo _TITLE; ?></title>
\r
902 <style>@import url('../nucleus/styles/manual.css');</style>
\r
905 <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->
\r
908 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
\r
910 if (count($aAllErrors) > 0) {
\r
911 echo '<h1>' . _TITLE2 . '</h1>';
\r
912 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
\r
915 if (!$bConfigWritten) { ?>
\r
916 <h1><?php echo _TITLE3; ?></h1>
\r
918 <?php echo _TEXT10; ?>
\r
920 <pre><code><?php
\r
921 // mySQL connection information
\r
922 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
\r
923 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
\r
924 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
\r
925 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
\r
926 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
\r
928 // new in 3.50. first element is db handler, the second is the db driver used by the handler
\r
929 // default is $MYSQL_HANDLER = array('mysql','');
\r
930 $MYSQL_HANDLER = array('<?php echo $MYSQL_HANDLER[0];?>','<?php echo $MYSQL_HANDLER[1];?>');
\r
932 // main nucleus directory
\r
933 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
\r
935 // path to media dir
\r
936 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
\r
938 // extra skin files for imported skins
\r
939 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
\r
941 // these dirs are normally sub dirs of the nucleus dir, but
\r
942 // you can redefine them if you wish
\r
943 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
944 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
945 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
948 include($DIR_LIBS . 'globalfunctions.php');
\r
951 <?php echo _TEXT11; ?>
\r
954 <?php echo _TEXT12; ?>
\r
959 <h1><?php echo _TITLE4; ?></h1>
\r
961 <?php echo _TEXT13; ?>
\r
965 <h1><?php echo _TITLE5; ?></h1>
\r
967 <?php echo _TEXT14; ?>
\r
970 <li><?php echo _TEXT14_L1; ?></li>
\r
971 <li><?php echo _TEXT14_L2; ?></li>
\r
974 <h1><?php echo _HEADER10; ?></h1>
\r
976 <?php echo _TEXT15; ?>
\r
979 <li><?php echo _TEXT15_L1; ?></li>
\r
980 <li><?php echo _TEXT15_L2; ?></li>
\r
981 <li><?php echo _TEXT15_L3; ?></li>
\r
984 <?php echo _TEXT16; ?>
\r
986 <h1><?php echo _HEADER11; ?></h1>
\r
988 <p><?php echo _TEXT16_H; ?>
\r
990 <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>
\r
991 <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>
\r
1002 * Install custom plugins
\r
1004 function installCustomPlugs(&$manager) {
\r
1005 global $aConfPlugsToInstall, $DIR_LIBS;
\r
1007 $aErrors = array();
\r
1009 if (count($aConfPlugsToInstall) == 0) {
\r
1013 $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
\r
1014 $numCurrent = sql_num_rows($res);
\r
1016 foreach ($aConfPlugsToInstall as $plugName) {
\r
1017 // do this before calling getPlugin (in case the plugin id is used there)
\r
1018 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
\r
1019 sql_query($query);
\r
1021 // get and install the plugin
\r
1022 $manager->clearCachedInfo('installedPlugins');
\r
1023 $plugin =& $manager->getPlugin($plugName);
\r
1024 $plugin->plugid = $numCurrent;
\r
1027 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
\r
1029 array_push($aErrors, _ERROR22 . $plugName);
\r
1033 $plugin->install();
\r
1036 // SYNC PLUGIN EVENT LIST
\r
1037 sql_query('DELETE FROM ' . sql_table('plugin_event') );
\r
1039 // loop over all installed plugins
\r
1040 $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
\r
1042 while($o = sql_fetch_object($res) ) {
\r
1044 $plug =& $manager->getPlugin($o->pfile);
\r
1047 $eventList = $plug->getEventList();
\r
1049 foreach ($eventList as $eventName) {
\r
1050 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
\r
1059 * Install custom skins
\r
1060 * Prepares the installation of custom skins
\r
1062 function installCustomSkins(&$manager) {
\r
1063 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
1065 $aErrors = array();
\r
1067 if (empty($manager)) {
\r
1068 $manager = new MANAGER;
\r
1071 if (count($aConfSkinsToImport) == 0) {
\r
1075 // load skinie class
\r
1076 include_once($DIR_LIBS . 'skinie.php');
\r
1078 $importer = new SKINIMPORT();
\r
1080 foreach ($aConfSkinsToImport as $skinName) {
\r
1081 $importer->reset();
\r
1082 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
1084 if (!@file_exists($skinFile) ) {
\r
1085 array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2);
\r
1089 $error = $importer->readFile($skinFile);
\r
1092 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1096 $error = $importer->writeToDatabase(1);
\r
1099 array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);
\r
1108 * Check if some important files of the Nucleus CMS installation are available
\r
1109 * Give an error if one or more files are not accessible
\r
1111 function doCheckFiles() {
\r
1112 $missingfiles = array();
\r
1117 '../nucleus/index.php',
\r
1118 '../nucleus/libs/globalfunctions.php',
\r
1119 '../nucleus/libs/ADMIN.php',
\r
1120 '../nucleus/libs/BLOG.php',
\r
1121 '../nucleus/libs/COMMENT.php',
\r
1122 '../nucleus/libs/COMMENTS.php',
\r
1123 '../nucleus/libs/ITEM.php',
\r
1124 '../nucleus/libs/MEMBER.php',
\r
1125 '../nucleus/libs/SKIN.php',
\r
1126 '../nucleus/libs/TEMPLATE.php',
\r
1127 '../nucleus/libs/MEDIA.php',
\r
1128 '../nucleus/libs/ACTIONLOG.php',
\r
1129 '../nucleus/media.php'
\r
1132 $count = count($files);
\r
1134 for ($i = 0; $i < $count; $i++) {
\r
1135 if (!is_readable($files[$i]) ) {
\r
1136 array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2);
\r
1140 if (count($missingfiles) > 0) {
\r
1141 showErrorMessages($missingfiles);
\r
1146 * Updates the configuration in the database
\r
1149 * name of the config var
\r
1151 * new value of the config var
\r
1153 function updateConfig($name, $val) {
\r
1154 global $MYSQL_CONN;
\r
1155 $name = addslashes($name);
\r
1156 $val = trim(addslashes($val) );
\r
1158 $query = 'UPDATE ' . tableName('nucleus_config')
\r
1159 . " SET value = '$val'"
\r
1160 . " WHERE name = '$name'";
\r
1162 sql_query($query,$MYSQL_CONN) or _doError(_ERROR26 . ': ' . sql_error($MYSQL_CONN) );
\r
1163 return sql_insert_id($MYSQL_CONN);
\r
1167 * Replaces doubled backslashs
\r
1170 * string that could have double backslashs
\r
1172 function replaceDoubleBackslash($input) {
\r
1173 return str_replace('\\', '/', $input);
\r
1177 * Checks if a string ends with a slash
\r
1182 function endsWithSlash($s) {
\r
1183 return (strrpos($s, '/') == strlen($s) - 1);
\r
1187 * Checks if email address is valid
\r
1190 * address which should be tested
\r
1192 function _isValidMailAddress($address) {
\r
1193 if (preg_match("#^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$#", $address) ) {
\r
1201 * Check if short blog names and nicknames are allowed
\r
1202 * Returns true if the given string is a valid shortname
\r
1203 * logic: only letters and numbers are allowed, no spaces allowed
\r
1205 * FIX: function eregi is deprecated since PHP 5.3.0
\r
1208 * name which should be tested
\r
1210 function _isValidShortName($name) {
\r
1211 if (preg_match("#^[a-zA-Z0-9]+$#", $name) ) {
\r
1219 * Check if a display name is allowed
\r
1220 * Returns true if the given string is a valid display name
\r
1222 * FIX: function eregi is deprecated since PHP 5.3.0
\r
1225 * name which should be tested
\r
1227 function _isValidDisplayName($name) {
\r
1228 if (preg_match("#^[a-zA-Z0-9]+[a-zA-Z0-9 ]*[a-zA-Z0-9]+$#", $name) ) {
\r
1236 * Shows error message
\r
1241 function _doError($msg) {
\r
1243 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1244 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1246 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
1247 <title><?php echo _TITLE; ?></title>
\r
1248 <style>@import url('../nucleus/styles/manual.css');</style>
\r
1251 <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->
\r
1252 <h1><?php echo _ERROR27; ?></h1>
\r
1254 <p><?php echo _ERROR28; ?> "<?php echo $msg; ?>";</p>
\r
1256 <p><a href="index.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>
\r
1265 * Shows error messages
\r
1268 * array with error messages
\r
1270 function showErrorMessages($errors) {
\r
1272 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
1273 <html xmlns="http://www.w3.org/1999/xhtml">
\r
1275 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
1276 <title><?php echo _TITLE; ?></title>
\r
1277 <style>@import url('../nucleus/styles/manual.css');</style>
\r
1280 <div style="text-align:center"><img src="../nucleus/styles/logo.gif" alt="<?php echo _ALT_NUCLEUS_CMS_LOGO; ?>" /></div> <!-- Nucleus logo -->
\r
1281 <h1><?php echo _ERROR27; ?></h1>
\r
1283 <p><?php echo _ERROR29; ?>:</p>
\r
1288 while($msg = array_shift($errors) ) {
\r
1289 echo '<li>' . $msg . '</li>';
\r
1295 <p><a href="index.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>
\r
1303 /* for the non-php systems that decide to show the contents:
\r