3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2007 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
11 * This script will install the Nucleus tables in your SQL-database, and initialize the data in
14 * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
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
19 * @license http://nucleuscms.org/license.txt GNU General Public License
20 * @copyright Copyright (C) 2002-2007 The Nucleus Group
21 * @version $Id: install.php,v 1.7 2007-02-04 06:28:44 kimitake Exp $
22 * $NucleusJP: install.php,v 1.6 2006/07/17 19:59:46 kimitake Exp $
26 This part of the install.php code allows for customization of the install process.
27 When distributing plugins or skins together with a Nucleus installation, the
28 configuration below will instruct to install them
30 -- Start Of Configurable Part --
33 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
37 // array('NP_TrackBack', 'NP_MemberGoodies')
38 $aConfPlugsToInstall = array('NP_SkinFiles');
41 // array with skins to install. skins must be present under the skins/ directory with
42 // a subdirectory having the same name that contains a skinbackup.xml file
45 // array('base','rsd')
46 $aConfSkinsToImport = array('default');
49 -- End Of Configurable Part --
52 // don't give warnings for uninitialized vars
53 error_reporting(E_ERROR | E_WARNING | E_PARSE);
55 // make sure there's no unnecessary escaping:
56 set_magic_quotes_runtime(0);
58 // if there are some plugins or skins to import, do not include vars
59 // in globalfunctions.php again... so set a flag
60 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
62 $CONF['installscript'] = 1;
65 if (phpversion() >= '4.1.0') {
66 include_once('nucleus/libs/vars4.1.0.php');
68 include_once('nucleus/libs/vars4.0.6.php');
71 include_once('nucleus/libs/mysql.php');
73 // check if mysql support is installed
74 if (!function_exists('mysql_query') ) {
75 _doError('Your PHP version does not have support for MySQL :(');
78 if (postVar('action') == 'go') {
86 function showInstallForm() {
87 // 0. pre check if all necessary files exist
91 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
92 <html xmlns="http://www.w3.org/1999/xhtml">
94 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
95 <title>Nucleusのインストール</title>
96 <style type="text/css"><!--
97 @import url('nucleus/documentation/styles/manual.css');
99 <script type="text/javascript"><!--
102 // function to make sure the submit button only gets pressed once
103 function checkSubmit() {
104 if (submitcount == 0) {
114 <div style="text-align:center"><img src="./nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->
115 <form method="post" action="install.php">
117 <h1>Install Nucleus</h1>
119 <p>このスクリプトはNucleusのインストールを手助けします。MySQLテーブルのセットアップと、<i>config.php</i>に入力するための情報を表示します(config.phpのパーミッションを0666にしておけば、後者の作業は自動的に行われます)。これをなす為に、いくつかの情報を入力する必要があります。</p>
121 <p>すべての欄の入力が必要です。オプション情報はインストールが完了したら、Nucleusの管理領域から設定可能です。</p>
123 <h1>PHP & MySQL Versions</h1>
125 <p>以下はあなたのウェブホストにおけるPHPインタープリターとMySQLサーバーのバージョンです。Nucleusのサポートフォーラムに問題を報告するときは、この情報を書き添えてください。</p>
132 $minVersion = '4.0.6';
134 if (phpversion() < $minVersion) {
135 echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
143 // note: this piece of code is taken from phpMyAdmin
144 $result = @mysql_query('SELECT VERSION() AS version');
146 if ($result != FALSE && @mysql_num_rows($result) > 0) {
147 $row = mysql_fetch_array($result);
148 $match = explode('.', $row['version']);
150 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
152 if ($result != FALSE && @mysql_num_rows($result) > 0) {
153 $row = mysql_fetch_row($result);
154 $match = explode('.', $row[1]);
162 if (!isset($match) || !isset($match[0]) ) {
166 if (!isset($match[1]) ) {
170 if (!isset($match[2]) ) {
174 if ($match[0] != '?') {
175 $match[0] = intval($match[0]);
176 $match[1] = intval($match[1]);
179 $mysqlVersion = implode($match, '.');
180 $minVersion = '3.23';
184 if ($mysqlVersion < $minVersion) {
185 echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
193 // tell people how they can have their config file filled out automatically
194 if (@file_exists('config.php') && @!is_writable('config.php') ) {
197 <h1><i>config.php</i>の自動アップデート</h1>
199 <p>もし<em>config.php</em>を自動的に更新するようにしたいなら、書き込み可能にする必要があります。<em>config.php</em>のパーミッションを<strong>666</strong>にしてください。Nucleusのインストール成功後に、パーミッションを<strong>444</strong>に戻さなければなりません(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>
201 <p>もしファイルに書き込まないという選択をした(あるいは行えない)場合:ご心配なく。インストールの過程で<em>config.php</em>の中身が提供されます。ですから、それをご自身でアップロードしてください。</p>
205 <h1>MySQLのログインデータ</h1>
207 <p>MySQLのデータを以下に入力してください。それらはデータベース・テーブルを作成し情報を入力するために必要なものです。後で、<i>config.php</i>にも記入する必要があります(上記の自動アップデートを利用する場合、その手順は省略されます)。</p>
209 <p>もしこの情報がわからなければ、システム管理者かホスティング元に連絡をとってください。ほとんどの場合、ホスト名は'localhost'です。もしNucleusがあなたのサーバのPHP設定から'default MySQL host'を検知したなら、'ホスト名'に既に記入されているはずです。もっとも、この情報が正確であるという保証はありません。</p>
212 <legend>基本のデータベース設定</legend>
216 <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" /></td>
220 <td><input name="mySQL_user" /></td>
224 <td><input name="mySQL_password" type="password" /></td>
228 <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />データベースを作成する必要がある</label>)</td>
234 <legend>高等なデータベース設定</legend>
237 <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />テーブル・プリフィックスを利用</label></td>
238 <td><input name="mySQL_tablePrefix" value="" /></td>
242 <p>一つのデータベースに複数のNucleusをインストールしており、自分が何をやっているのか理解されている場合を除いては、<strong>これを変更する必要はありません</strong>。</p>
243 <p>Nucleusによって生成されたすべてのデータベーステーブルは、このプリフィックスが頭につきます。</p>
248 <p>このインストールスクリプトはNucleusがインストールされているディレクトリとURLを見つけようとしました。下の値をチェックして必要なら訂正してください。ファイルへのパスとURLはスラッシュ'/'で終わらなくてはなりません。</p>
252 // no need to this all! dirname(__FILE__) is all we need -- moraes
254 // discover full path
255 $fullPath = serverVar('PATH_TRANSLATED');
257 if ($fullPath == '') {
258 $fullPath = serverVar('SCRIPT_FILENAME');
261 $basePath = str_replace('install.php', '', $fullPath);
262 $basePath = replaceDoubleBackslash($basePath);
263 $basePath = replaceDoubleBackslash($basePath);
265 // add slash at end if necessary
266 if (!endsWithSlash($basePath) ) {
271 $basePath = dirname(__FILE__) . '/';
275 <legend>URLs and directories</legend>
278 <td>Site <strong>URL</strong>:</td>
279 <td><input name="IndexURL" size="60" value="<?php
280 $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
281 $url = str_replace('install.php', '', $url);
282 $url = replaceDoubleBackslash($url);
284 // add slash at end if necessary
285 if (!endsWithSlash($url) ) {
289 echo $url; ?>" /></td>
292 <td>Admin-area <strong>URL</strong>:</td>
293 <td><input name="AdminURL" size="60" value="<?php
295 echo $url, 'nucleus/';
299 <td>Admin-area <strong>path</strong>:</td>
300 <td><input name="AdminPath" size="60" value="<?php
302 echo $basePath, 'nucleus/';
306 <td>Media files <strong>URL</strong>:</td>
307 <td><input name="MediaURL" size="60" value="<?php
313 <td>Media directory <strong>path</strong>:</td>
314 <td><input name="MediaPath" size="60" value="<?php
316 echo $basePath, 'media/';
320 <td>Extra skin files <strong>URL</strong>:</td>
321 <td><input name="SkinsURL" size="60" value="<?php
325 <br />(インポートされたスキンが使用)
329 <td>Extra skin files directory <strong>path</strong>:</td>
330 <td><input name="SkinsPath" size="60" value="<?php
332 echo $basePath, 'skins/';
334 <br />(インポートされたスキンのファイル類を置く場所)
338 <td>Plugin files <strong>URL</strong>:</td>
339 <td><input name="PluginURL" size="60" value="<?php
341 echo $url, 'nucleus/plugins/';
345 <td>Action <strong>URL</strong>:</td>
346 <td><input name="ActionURL" size="60" value="<?php
348 echo $url, 'action.php';
350 <br />(<tt>action.php</tt>へのhttp://から始まるURL)
356 <p class="note"><strong>付記:</strong> 相対パスではなく<strong>絶対パスを使ってください</strong>。通常、絶対パスは<tt>/home/username/public_html/</tt>のような形をとります。Unixシステム(ほとんどのサーバーがそうです)において、パスはスラッシュから始まります。もしこれらの情報入力に問題が生じたら、あなたのサーバ管理者にたずねるべきです。</p>
360 <p>以下に、サイトの最初のユーザーを作成するためのいくつかの情報を入力してください。</p>
363 <legend>管理権限を持つユーザー</legend>
367 <td><input name="User_name" value="" /> <small>(許可される文字:a-z と 0-9、最初と最後以外のスペース)</small></td>
371 <td><input name="User_realname" value="" /></td>
375 <td><input name="User_password" type="password" value="" /></td>
379 <td><input name="User_password2" type="password" value="" /></td>
383 <td><input name="User_email" value="" /> <small>(利用可能なメールアドレスを入れてください)</small></td>
390 <p>以下に、デフォルトのweblogを作成するためにいくつかの情報を入力してください。このweblogの名前は、サイト名としても利用されます。</p>
393 <legend>ウェブログのデータ</legend>
397 <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>
401 <td><input name="Blog_shortname" value="mynucleuscms" /> <small>(許可される文字:a-z と 0-9、スペースは不可)</small></td>
408 <p>上に書いてきたデータが正しいか確かめてください。よければデータベース・テーブルと最初のデータを設定するために下のボタンを押してください。少し時間がかかるかもしれませんがご辛抱を。<b>ボタンをクリックするのは一回だけにしてください。</b></p>
410 <p><input name="action" value="go" type="hidden" /> <input type="submit" value="Nucleus CMSのインストール" onclick="return checkSubmit();" /></p>
418 function tableName($unPrefixed) {
419 global $mysql_usePrefix, $mysql_prefix;
421 if ($mysql_usePrefix == 1) {
422 return $mysql_prefix . $unPrefixed;
428 function doInstall() {
429 global $mysql_usePrefix, $mysql_prefix;
431 // 0. put all POST-vars into vars
432 $mysql_host = postVar('mySQL_host');
433 $mysql_user = postVar('mySQL_user');
434 $mysql_password = postVar('mySQL_password');
435 $mysql_database = postVar('mySQL_database');
436 $mysql_create = postVar('mySQL_create');
437 $mysql_usePrefix = postVar('mySQL_usePrefix');
438 $mysql_prefix = postVar('mySQL_tablePrefix');
439 $config_indexurl = postVar('IndexURL');
440 $config_adminurl = postVar('AdminURL');
441 $config_adminpath = postVar('AdminPath');
442 $config_mediaurl = postVar('MediaURL');
443 $config_skinsurl = postVar('SkinsURL');
444 $config_pluginurl = postVar('PluginURL');
445 $config_actionurl = postVar('ActionURL');
446 $config_mediapath = postVar('MediaPath');
447 $config_skinspath = postVar('SkinsPath');
448 $user_name = postVar('User_name');
449 $user_realname = postVar('User_realname');
450 $user_password = postVar('User_password');
451 $user_password2 = postVar('User_password2');
452 $user_email = postVar('User_email');
453 $blog_name = postVar('Blog_name');
454 $blog_shortname = postVar('Blog_shortname');
455 $config_adminemail = $user_email;
456 $config_sitename = $blog_name;
458 $config_indexurl = replaceDoubleBackslash($config_indexurl);
459 $config_adminurl = replaceDoubleBackslash($config_adminurl);
460 $config_mediaurl = replaceDoubleBackslash($config_mediaurl);
461 $config_skinsurl = replaceDoubleBackslash($config_skinsurl);
462 $config_pluginurl = replaceDoubleBackslash($config_pluginurl);
463 $config_actionurl = replaceDoubleBackslash($config_actionurl);
464 $config_adminpath = replaceDoubleBackslash($config_adminpath);
465 $config_skinspath = replaceDoubleBackslash($config_skinspath);
467 // 1. check all the data
470 if (!$mysql_database) {
471 array_push($errors, 'mySQL database name missing');
474 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {
475 array_push($errors, 'mySQL prefix was selected, but prefix is empty');
478 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {
479 array_push($errors, 'mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores');
482 // TODO: add action.php check
483 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {
484 array_push($errors, 'One of the URLs does not end with a slash, or action url does not end with \'action.php\'');
487 if (!endsWithSlash($config_adminpath) ) {
488 array_push($errors, 'The path of the administration area does not end with a slash');
491 if (!endsWithSlash($config_mediapath) ) {
492 array_push($errors, 'The media path does not end with a slash');
495 if (!endsWithSlash($config_skinspath) ) {
496 array_push($errors, 'The skins path does not end with a slash');
499 if (!is_dir($config_adminpath) ) {
500 array_push($errors, 'The path of the administration area does not exist on your server');
503 if (!_isValidMailAddress($user_email) ) {
504 array_push($errors, 'Invalid e-mail address given for user');
507 if (!_isValidDisplayName($user_name) ) {
508 array_push($errors, 'User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)');
511 if (!$user_password || !$user_password2) {
512 array_push($errors, 'User password is empty');
515 if ($user_password != $user_password2) {
516 array_push($errors, 'User password do not match');
519 if (!_isValidShortName($blog_shortname) ) {
520 array_push($errors, 'Invalid short name given for blog (allowed chars: a-z0-9, no spaces)');
523 if (sizeof($errors) > 0) {
524 showErrorMessages($errors);
527 // 2. try to log in to mySQL
529 $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
531 if ($MYSQL_CONN == false) {
532 _doError('Could not connect to mySQL server: ' . mysql_error() );
535 // 3. try to create database (if needed)
536 if ($mysql_create == 1) {
537 mysql_query('CREATE DATABASE ' . $mysql_database) or _doError('Could not create database. Make sure you have the rights to do so. SQL error was: ' . mysql_error() );
540 // 4. try to select database
541 mysql_select_db($mysql_database) or _doError('Could not select database. Make sure it exists');
543 // 5. execute queries
544 $filename = 'install.sql';
545 $fd = fopen($filename, 'r');
546 $queries = fread($fd, filesize($filename) );
549 $queries = split("(;\n|;\r)", $queries);
551 $aTableNames = array(
565 'nucleus_activation',
568 // these are unneeded (one of the replacements above takes care of them)
569 // 'nucleus_plugin_event',
570 // 'nucleus_plugin_option',
571 // 'nucleus_plugin_option_desc',
572 // 'nucleus_skin_desc',
573 // 'nucleus_template_desc',
575 $aTableNamesPrefixed = array(
576 $mysql_prefix . 'nucleus_actionlog',
577 $mysql_prefix . 'nucleus_ban',
578 $mysql_prefix . 'nucleus_blog',
579 $mysql_prefix . 'nucleus_category',
580 $mysql_prefix . 'nucleus_comment',
581 $mysql_prefix . 'nucleus_config',
582 $mysql_prefix . 'nucleus_item',
583 $mysql_prefix . 'nucleus_karma',
584 $mysql_prefix . 'nucleus_member',
585 $mysql_prefix . 'nucleus_plugin',
586 $mysql_prefix . 'nucleus_skin',
587 $mysql_prefix . 'nucleus_template',
588 $mysql_prefix . 'nucleus_team',
589 $mysql_prefix . 'nucleus_activation',
590 $mysql_prefix . 'nucleus_tickets'
592 // these are unneeded (one of the replacements above takes care of them)
593 // $mysql_prefix . 'nucleus_plugin_event',
594 // $mysql_prefix . 'nucleus_plugin_option',
595 // $mysql_prefix . 'nucleus_plugin_option_desc',
596 // $mysql_prefix . 'nucleus_skin_desc',
597 // $mysql_prefix . 'nucleus_template_desc',
599 $count = count($queries);
601 for ($idx = 0; $idx < $count; $idx++) {
602 $query = trim($queries[$idx]);
603 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
607 if ($mysql_usePrefix == 1) {
608 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
611 mysql_query($query) or _doError('Error while executing query (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );
615 // 6. update global settings
616 updateConfig('IndexURL', $config_indexurl);
617 updateConfig('AdminURL', $config_adminurl);
618 updateConfig('MediaURL', $config_mediaurl);
619 updateConfig('SkinsURL', $config_skinsurl);
620 updateConfig('PluginURL', $config_pluginurl);
621 updateConfig('ActionURL', $config_actionurl);
622 updateConfig('AdminEmail', $config_adminemail);
623 updateConfig('SiteName', $config_sitename);
625 // 7. update GOD member
626 $query = 'UPDATE ' . tableName('nucleus_member')
627 . " SET mname='" . addslashes($user_name) . "',"
628 . " mrealname='" . addslashes($user_realname) . "',"
629 . " mpassword='" . md5(addslashes($user_password) ) . "',"
630 . " murl='" . addslashes($config_indexurl) . "',"
631 . " memail='" . addslashes($user_email) . "',"
632 . " madmin=1, mcanlogin=1"
633 . " WHERE mnumber=1";
635 mysql_query($query) or _doError('Error while setting member settings: ' . mysql_error() );
637 // 8. update weblog settings
638 $query = 'UPDATE ' . tableName('nucleus_blog')
639 . " SET bname='" . addslashes($blog_name) . "',"
640 . " bshortname='" . addslashes($blog_shortname) . "',"
641 . " burl='" . addslashes($config_indexurl) . "'"
642 . " WHERE bnumber=1";
644 mysql_query($query) or _doError('Error while setting weblog settings: ' . mysql_error() );
646 // 9. update item date
647 $query = 'UPDATE ' . tableName('nucleus_item')
648 . " SET itime='" . date('Y-m-d H:i:s', time() ) ."'"
649 . " WHERE inumber=1";
651 mysql_query($query) or _doError('Error with query: ' . mysql_error() );
653 global $aConfPlugsToInstall, $aConfSkinsToImport;
654 $aSkinErrors = array();
655 $aPlugErrors = array();
657 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {
658 // 10. set global variables
659 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
661 $MYSQL_HOST = $mysql_host;
662 $MYSQL_USER = $mysql_user;
663 $MYSQL_PASSWORD = $mysql_password;
664 $MYSQL_DATABASE = $mysql_database;
665 $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
667 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
669 $DIR_NUCLEUS = $config_adminpath;
670 $DIR_MEDIA = $config_mediapath;
671 $DIR_SKINS = $config_skinspath;
672 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
673 $DIR_LANG = $DIR_NUCLEUS . 'language/';
674 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
676 // close database connection (needs to be closed if we want to include globalfunctions.php)
680 include_once($DIR_LIBS . 'globalfunctions.php');
682 // 11. install custom skins
683 $aSkinErrors = installCustomSkins($manager);
685 // 12. install custom plugins
686 $aPlugErrors = installCustomPlugs($manager);
689 // 12. Write config file ourselves (if possible)
692 if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {
693 $config_data = '<' . '?php' . "\n\n";
694 //$config_data .= "\n"; (extraneous, just added extra \n to previous line
695 $config_data .= " // mySQL connection information\n";
696 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
697 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
698 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
699 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
700 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
701 $config_data .= "\n";
702 $config_data .= " // main nucleus directory\n";
703 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
704 $config_data .= "\n";
705 $config_data .= " // path to media dir\n";
706 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
707 $config_data .= "\n";
708 $config_data .= " // extra skin files for imported skins\n";
709 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
710 $config_data .= "\n";
711 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
712 $config_data .= " // you can redefine them if you wish\n";
713 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
714 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
715 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
716 $config_data .= "\n";
717 $config_data .= " // include libs\n";
718 $config_data .= " include(\$DIR_LIBS.'globalfunctions.php');\n";
719 $config_data .= " if (!extension_loaded('mbstring')) {\n";
720 $config_data .= " include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
721 $config_data .= " }\n";
722 $config_data .= "?" . ">";
724 $result = @fputs($fp, $config_data, strlen($config_data) );
733 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
734 <html xmlns="http://www.w3.org/1999/xhtml">
736 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
737 <title>Nucleusのインストール</title>
738 <style>@import url('nucleus/styles/manual.css');</style>
741 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
744 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
746 if (count($aAllErrors) > 0) {
747 echo '<h1>Skin/Plugin Install errors</h1>';
748 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';
751 if (!$bConfigWritten) { ?>
752 <h1>インストールはほぼ完了しました!</h1>
754 <p>データベーステーブルの初期値入力が成功しました。後は<i>config.php</i>を書き換えるだけです。以下に書き換えるべき内容を表示します(mysqlのパスワードはマスクされています。ここは実際のものに書き換えてください)</p>
757 // mySQL connection information
758 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
759 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
760 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
761 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
762 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
764 // main nucleus directory
765 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
768 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
770 // extra skin files for imported skins
771 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
773 // these dirs are normally sub dirs of the nucleus dir, but
774 // you can redefine them if you wish
775 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
776 $DIR_LANG = $DIR_NUCLEUS . 'language/';
777 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
780 include($DIR_LIBS.'globalfunctions.php');
781 if (!extension_loaded('mbstring')) {
782 include($DIR_LIBS.'mb_emulator/mb-emulator.php');
786 <p>あなたのコンピュータ上のファイルを書き換えたら、FTPを使ってウェブサーバにアップロードしてください。ASCIIモードで送信してファイルを上書きします。</p>
789 <b>付記:</b> <i>config.php</i>の最初や終わりにスペースを空けないようにしましょう。実行時にエラーを引き起こす原因となります。<br />
790 したがって、config.phpの最初の文字は "<"で最後の文字は">"としなければなりません。
795 <h1>インストールは完了しました!</h1>
797 <p>Nucleusはインストールされ、<code>config.php</code>はアップデートされました。</p>
799 <p>セキュリティのため<code>config.php</code>のパーミッションを444に戻すことを忘れないでください(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>
803 <h1>インストールファイルの削除</h1>
805 <p>ウェブサーバから次のファイルを削除してください:</p>
808 <li><b>install.sql</b>:テーブルの構造を内包するファイル</li>
809 <li><b>install.php</b>:このファイル</li>
812 <p>もしこれらのファイルを削除していなければ、管理領域を開くことが出来ません。</p>
816 <p>ウェブサイトを使う準備が整いました。
818 <li><a href="<?php echo $config_adminurl?>">管理領域にログインしてサイトの設定を行う</a></li>
819 <li><a href="<?php echo $config_indexurl?>">すぐにサイトへ行ってみる</a></li>
829 function installCustomPlugs(&$manager) {
830 global $aConfPlugsToInstall, $DIR_LIBS;
834 if (count($aConfPlugsToInstall) == 0) {
838 $res = sql_query('SELECT * FROM ' . sql_table('plugin') );
839 $numCurrent = mysql_num_rows($res);
841 foreach ($aConfPlugsToInstall as $plugName) {
842 // do this before calling getPlugin (in case the plugin id is used there)
843 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';
846 // get and install the plugin
847 $plugin =& $manager->getPlugin($plugName);
850 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');
852 array_push($aErrors, 'Unable to install plugin ' . $plugName);
859 // SYNC PLUGIN EVENT LIST
860 sql_query('DELETE FROM ' . sql_table('plugin_event') );
862 // loop over all installed plugins
863 $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );
865 while($o = mysql_fetch_object($res) ) {
867 $plug =& $manager->getPlugin($o->pfile);
870 $eventList = $plug->getEventList();
872 foreach ($eventList as $eventName) {
873 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');
881 function installCustomSkins(&$manager) {
882 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
886 if (count($aConfSkinsToImport) == 0) {
891 include_once($DIR_LIBS . 'skinie.php');
893 $importer = new SKINIMPORT();
895 foreach ($aConfSkinsToImport as $skinName) {
897 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
899 if (!@file_exists($skinFile) ) {
900 array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
904 $error = $importer->readFile($skinFile);
907 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
911 $error = $importer->writeToDatabase(1);
914 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
922 // give an error if one or more nucleus are not accessible
923 function doCheckFiles() {
924 $missingfiles = array();
930 'nucleus/libs/globalfunctions.php',
931 'nucleus/libs/ADMIN.php',
932 'nucleus/libs/BLOG.php',
933 'nucleus/libs/COMMENT.php',
934 'nucleus/libs/COMMENTS.php',
935 'nucleus/libs/ITEM.php',
936 'nucleus/libs/MEMBER.php',
937 'nucleus/libs/SKIN.php',
938 'nucleus/libs/TEMPLATE.php',
939 'nucleus/libs/MEDIA.php',
940 'nucleus/libs/ACTIONLOG.php',
944 $count = count($files);
946 for ($i = 0; $i < $count; $i++) {
947 if (!is_readable($files[$i]) ) {
948 array_push($missingfiles, 'File <b>' . $files[$i] . '</b> is missing or not readable.');
952 // The above code replaces several if statements of the form:
954 // if (!is_readable('install.sql') ) {
955 // array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');
958 if (count($missingfiles) > 0) {
959 showErrorMessages($missingfiles);
963 function updateConfig($name, $val) {
964 $name = addslashes($name);
965 $val = trim(addslashes($val) );
967 $query = 'UPDATE ' . tableName('nucleus_config')
968 . " SET value='$val'"
969 . " WHERE name='$name'";
971 mysql_query($query) or _doError('Query error while trying to update config: ' . mysql_error() );
972 return mysql_insert_id();
975 function replaceDoubleBackslash($input) {
976 return str_replace('\\', '/', $input);
979 function endsWithSlash($s) {
980 return (strrpos($s, '/') == strlen($s) - 1);
984 * Checks if email address is valid
986 function _isValidMailAddress($address) {
987 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {
994 // returns true if the given string is a valid shortname
995 // (to check short blog names and nicknames)
996 // logic: starts and ends with a non space, can contain spaces in between
998 function _isValidShortName($name) {
999 if (eregi("^[a-z0-9]+$", $name) ) {
1008 // returns true if the given string is a valid display name
1009 // (to check nicknames)
1010 function _isValidDisplayName($name) {
1011 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {
1018 function _doError($msg) {
1020 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1021 <html xmlns="http://www.w3.org/1999/xhtml">
1023 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1024 <title>Nucleus Install</title>
1025 <style>@import url('nucleus/styles/manual.css');</style>
1028 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
1031 <p>Error message was: "<?php echo $msg?>";</p>
1033 <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
1041 function showErrorMessages($errors) {
1043 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
1044 <html xmlns="http://www.w3.org/1999/xhtml">
1046 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
1047 <title>Nucleus Install</title>
1048 <style>@import url('nucleus/styles/manual.css');</style>
1051 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
1054 <p>Errors were found:</p>
1059 while($msg = array_shift($errors) ) {
1060 echo '<li>', $msg, '</li>';
1066 <p><a href="install.php" onclick="history.back();return false;">Go Back</a></p>
1074 /* for the non-php systems that decide to show the contents: