3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2005 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
15 * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
\r
16 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
17 * @copyright Copyright (C) 2002-2005 The Nucleus Group
\r
18 * @version $Id: install.php,v 1.5 2005-04-20 06:53:20 kimitake Exp $
\r
20 ?><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
23 This part of the install.php code allows for customization of the install process.
\r
24 When distributing plugins or skins together with a Nucleus installation, the
\r
25 configuration below will instruct to install them
\r
27 -- Start Of Configurable Part --
\r
30 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
\r
34 // array('NP_TrackBack', 'NP_MemberGoodies')
\r
35 $aConfPlugsToInstall = array('NP_SkinFiles');
\r
38 // array with skins to install. skins must be present under the skins/ directory with
\r
39 // a subdirectory having the same name that contains a skinbackup.xml file
\r
42 // array('base','rsd')
\r
43 $aConfSkinsToImport = array('default');
\r
46 -- End Of Configurable Part --
\r
49 // don't give warnings for uninitialized vars
\r
50 error_reporting(E_ERROR | E_WARNING | E_PARSE);
\r
52 // make sure there's no unnecessary escaping:
\r
53 set_magic_quotes_runtime(0);
\r
55 // if there are some plugins or skins to import, do not include vars
\r
56 // in globalfunctions.php again... so set a flag
\r
57 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {
\r
59 $CONF['installscript']=1;
\r
61 if (phpversion() >= '4.1.0')
\r
62 include_once('nucleus/libs/vars4.1.0.php');
\r
64 include_once('nucleus/libs/vars4.0.6.php');
\r
66 // check if mysql support is installed
\r
67 if (!function_exists('mysql_query'))
\r
68 _doError('Your PHP version does not have support for MySQL :(');
\r
70 if (postVar('action') == 'go')
\r
76 function showInstallForm() {
\r
78 // 0. pre check if all necessary files exist
\r
83 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
84 <html xmlns="http://www.w3.org/1999/xhtml">
\r
86 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
\r
87 <title>Nucleusのインストール</title>
\r
88 <style type="text/css"><!--
\r
89 @import url('nucleus/documentation/styles/manual.css');
\r
91 <script type="text/javascript"><!--
\r
92 // function to make sure the submit button only gets pressed once
\r
94 function checkSubmit() {
\r
95 if (submitcount == 0) {
\r
106 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
108 <form method="post" action="install.php">
\r
110 <h1>Install Nucleus</h1>
\r
113 このスクリプトはNucleusのインストールを手助けします。MySQLテーブルのセットアップと、<i>config.php</i>に入力するための情報を表示します(config.phpのパーミッションを0666にしておけば、後者の作業は自動的に行われます)。これをなす為に、いくつかの情報を入力する必要があります。
\r
117 すべての欄の入力が必要です。オプション情報はインストールが完了したら、Nucleusの管理領域から設定可能です。
\r
120 <h1>PHP & MySQL Versions</h1>
\r
123 以下はあなたのウェブホストにおけるPHPインタープリターとMySQLサーバーのバージョンです。Nucleusのサポートフォーラムに問題を報告するときは、この情報を書き添えてください。
\r
127 <li>PHP: <?php echo phpversion();
\r
128 $minVersion = '4.0.6';
\r
130 if (phpversion() < $minVersion)
\r
131 echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
\r
134 // note: this piece of code is taken from phpMyAdmin
\r
136 $result = @mysql_query('SELECT VERSION() AS version');
\r
137 if ($result != FALSE && @mysql_num_rows($result) > 0) {
\r
138 $row = mysql_fetch_array($result);
\r
139 $match = explode('.', $row['version']);
\r
141 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
\r
142 if ($result != FALSE && @mysql_num_rows($result) > 0){
\r
143 $row = mysql_fetch_row($result);
\r
144 $match = explode('.', $row[1]);
\r
152 if (!isset($match) || !isset($match[0])) {
\r
155 if (!isset($match[1])) {
\r
158 if (!isset($match[2])) {
\r
162 if ($match[0] != '?') {
\r
163 $match[0] = intval($match[0]);
\r
164 $match[1] = intval($match[1]);
\r
167 $mysqlVersion = implode($match, '.');
\r
168 $minVersion = '3.23';
\r
170 echo $mysqlVersion;
\r
172 if ($mysqlVersion < $minVersion)
\r
173 echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
\r
178 // tell people how they can have their config file filled out automatically
\r
179 if (@file_exists('config.php') && @!is_writable('config.php')) {
\r
181 <h1><i>config.php</i>の自動アップデート</h1>
\r
184 もし<em>config.php</em>を自動的に更新するようにしたいなら、書き込み可能にする必要があります。<em>config.php</em>のパーミッションを<strong>666</strong>にしてください。Nucleusのインストール成功後に、パーミッションを<strong>444</strong>に戻さなければなりません(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。
\r
188 もしファイルに書き込まないという選択をした(あるいは行えない)場合:ご心配なく。インストールの過程で<em>config.php</em>の中身が提供されます。ですから、それをご自身でアップロードしてください。
\r
193 <h1>MySQLのログインデータ</h1>
\r
196 MySQLのデータを以下に入力してください。それらはデータベース・テーブルを作成し情報を入力するために必要なものです。後で、<i>config.php</i>にも記入する必要があります(上記の自動アップデートを利用する場合、その手順は省略されます)。
\r
200 もしこの情報がわからなければ、システム管理者かホスティング元に連絡をとってください。ほとんどの場合、ホスト名は'localhost'です。もしNucleusがあなたのサーバのPHP設定から'default MySQL host'を検知したなら、'ホスト名'に既に記入されているはずです。もっとも、この情報が正確であるという保証はありません。
\r
204 <legend>基本のデータベース設定</legend>
\r
207 <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host'))?>" /></td>
\r
210 <td><input name="mySQL_user" /></td>
\r
213 <td><input name="mySQL_password" type="password" /></td>
\r
216 <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />データベースを作成する必要がある</label>)</td>
\r
221 <legend>高等なデータベース設定</legend>
\r
223 <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />テーブル・プリフィックスを利用</label></td>
\r
224 <td><input name="mySQL_tablePrefix" value="" /></td>
\r
226 <p>一つのデータベースに複数のNucleusをインストールしており、自分が何をやっているのか理解されている場合を除いては、<strong>これを変更する必要はありません</strong>。</p>
\r
227 <p>Nucleusによって生成されたすべてのデータベーステーブルは、このプリフィックスが頭につきます。</p>
\r
230 <h1>ディレクトリとURL</h1>
\r
233 このインストールスクリプトはNucleusがインストールされているディレクトリとURLを見つけようとしました。下の値をチェックして必要なら訂正してください。ファイルへのパスとURLはスラッシュ'/'で終わらなくてはなりません。
\r
237 <legend>URLs and directories</legend>
\r
239 <td>Site <strong>URL</strong>:</td>
\r
241 <input name="IndexURL" size="60" value="<?php $url = "http://" . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
\r
242 $url = str_replace("install.php",'',$url);
\r
243 $url = str_replace("\\","/",$url);
\r
244 // add slash at end if necessary
\r
245 if (!endsWithSlash($url)) $url .= '/';
\r
250 <td>Admin-area <strong>URL</strong>:</td>
\r
251 <td><input name="AdminURL" size="60" value="<?php if ($url) echo $url . 'nucleus/';
\r
255 <td>Admin-area <strong>path</strong>:</td>
\r
256 <td><input name="AdminPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
\r
257 $path = str_replace("\\","/",$path);
\r
258 // add slash at end if necessary
\r
259 if (!endsWithSlash($path)) $path .= '/';
\r
260 if($path) echo $path . 'nucleus/';
\r
264 <td>Media files <strong>URL</strong>:</td>
\r
265 <td><input name="MediaURL" size="60" value="<?php if ($url) echo $url . 'media/';
\r
269 <td>Media directory <strong>path</strong>:</td>
\r
270 <td><input name="MediaPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
\r
271 $path = str_replace("\\","/",$path);
\r
272 // add slash at end if necessary
\r
273 if (!endsWithSlash($path)) $path .= '/';
\r
274 if ($path) echo $path . 'media/';
\r
278 <td>Extra skin files <strong>URL</strong>:</td>
\r
279 <td><input name="SkinsURL" size="60" value="<?php if ($url) echo $url . 'skins/';
\r
281 <br />(インポートされたスキンが使用)
\r
284 <td>Extra skin files directory <strong>path</strong>:</td>
\r
285 <td><input name="SkinsPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
\r
286 $path = str_replace("\\","/",$path);
\r
287 // add slash at end if necessary
\r
288 if (!endsWithSlash($path)) $path .= '/';
\r
289 if ($path) echo $path . 'skins/';
\r
291 <br />(インポートされたスキンのファイル類を置く場所)
\r
294 <td>Plugin files <strong>URL</strong>:</td>
\r
295 <td><input name="PluginURL" size="60" value="<?php if ($url) echo $url . 'nucleus/plugins/';
\r
299 <td>Action <strong>URL</strong>:</td>
\r
300 <td><input name="ActionURL" size="60" value="<?php if ($url) echo $url . 'action.php';
\r
302 <br />(<tt>action.php</tt>へのhttp://から始まるURL)
\r
308 <strong>付記:</strong> 相対パスではなく<strong>絶対パスを使ってください</strong>。通常、絶対パスは<tt>/home/username/public_html/</tt>のような形をとります。Unixシステム(ほとんどのサーバーがそうです)において、パスはスラッシュから始まります。もしこれらの情報入力に問題が生じたら、あなたのサーバ管理者にたずねるべきです。
\r
311 <h1>管理権限をもつユーザー</h1>
\r
313 <p>以下に、サイトの最初のユーザーを作成するためのいくつかの情報を入力してください。</p>
\r
316 <legend>管理権限を持つユーザー</legend>
\r
320 <input name="User_name" value="" />
\r
321 <small>(許可される文字:a-z と 0-9、最初と最後以外のスペース)</small>
\r
324 <td>本名(ハンドル名):</td>
\r
325 <td><input name="User_realname" value="" /></td>
\r
328 <td><input name="User_password" type="password" value="" /></td>
\r
331 <td><input name="User_password2" type="password" value="" /></td>
\r
335 <input name="User_email" value="" />
\r
336 <small>(利用可能なメールアドレスを入れてください)</small>
\r
343 <p>以下に、デフォルトのweblogを作成するためにいくつかの情報を入力してください。このweblogの名前は、サイト名としても利用されます。</p>
\r
346 <legend>ウェブログのデータ</legend>
\r
349 <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>
\r
353 <input name="Blog_shortname" value="mynucleuscms" />
\r
354 <small>(許可される文字:a-z と 0-9、スペースは不可)</small>
\r
362 上に書いてきたデータが正しいか確かめてください。よければデータベース・テーブルと最初のデータを設定するために下のボタンを押してください。少し時間がかかるかもしれませんがご辛抱を。<b>ボタンをクリックするのは一回だけにしてください。</b>
\r
366 <input name="action" value="go" type="hidden" />
\r
367 <input type="submit" value="Nucleus CMSのインストール" onclick="return checkSubmit();" />
\r
378 function tableName($unPrefixed)
\r
380 global $mysql_usePrefix, $mysql_prefix;
\r
381 if ($mysql_usePrefix == 1)
\r
382 return $mysql_prefix . $unPrefixed;
\r
384 return $unPrefixed;
\r
387 function doInstall() {
\r
388 global $mysql_usePrefix, $mysql_prefix;
\r
390 // 0. put all POST-vars into vars
\r
391 $mysql_host = postVar('mySQL_host');
\r
392 $mysql_user = postVar('mySQL_user');
\r
393 $mysql_password = postVar('mySQL_password');
\r
394 $mysql_database = postVar('mySQL_database');
\r
395 $mysql_create = postVar('mySQL_create');
\r
396 $mysql_usePrefix = postVar('mySQL_usePrefix');
\r
397 $mysql_prefix = postVar('mySQL_tablePrefix');
\r
398 $config_indexurl = postVar('IndexURL');
\r
399 $config_adminurl = postVar('AdminURL');
\r
400 $config_adminpath = postVar('AdminPath');
\r
401 $config_mediaurl = postVar('MediaURL');
\r
402 $config_skinsurl = postVar('SkinsURL');
\r
403 $config_pluginurl = postVar('PluginURL');
\r
404 $config_actionurl = postVar('ActionURL');
\r
405 $config_mediapath = postVar('MediaPath');
\r
406 $config_skinspath = postVar('SkinsPath');
\r
407 $user_name = postVar('User_name');
\r
408 $user_realname = postVar('User_realname');
\r
409 $user_password = postVar('User_password');
\r
410 $user_password2 = postVar('User_password2');
\r
411 $user_email = postVar('User_email');
\r
412 $blog_name = postVar('Blog_name');
\r
413 $blog_shortname = postVar('Blog_shortname');
\r
414 $config_adminemail = $user_email;
\r
415 $config_sitename = $blog_name;
\r
418 $config_indexurl = str_replace("\\","/",$config_indexurl);
\r
419 $config_adminurl = str_replace("\\","/",$config_adminurl);
\r
420 $config_mediaurl = str_replace("\\","/",$config_mediaurl);
\r
421 $config_skinsurl = str_replace("\\","/",$config_skinsurl);
\r
422 $config_pluginurl = str_replace("\\","/",$config_pluginurl);
\r
423 $config_actionurl = str_replace("\\","/",$config_actionurl);
\r
424 $config_adminpath = str_replace("\\","/",$config_adminpath);
\r
425 $config_skinspath = str_replace("\\","/",$config_skinspath);
\r
427 // 1. check all the data
\r
430 if (!$mysql_database)
\r
431 array_push($errors,"mySQL database name missing");
\r
432 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0))
\r
433 array_push($errors,"mySQL prefix was selected, but prefix is empty");
\r
434 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix)))
\r
435 array_push($errors,"mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores");
\r
436 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl)
\r
437 || !endsWithSlash($config_mediaurl)
\r
438 || !endsWithSlash($config_pluginurl)
\r
439 || !endsWithSlash($config_skinsurl)
\r
440 // TODO: add action.php check
\r
442 array_push($errors,"One of the URLs does not end with a slash, or action url does not end with 'action.php'");
\r
443 if (!endsWithSlash($config_adminpath))
\r
444 array_push($errors,"The path of the administration area does not end with a slash");
\r
445 if (!endsWithSlash($config_mediapath))
\r
446 array_push($errors,"The media path does not end with a slash");
\r
447 if (!endsWithSlash($config_skinspath))
\r
448 array_push($errors,"The skins path does not end with a slash");
\r
449 if (!is_dir($config_adminpath))
\r
450 array_push($errors,"The path of the administration area does not exist on your server");
\r
451 if (!_isValidMailAddress($user_email))
\r
452 array_push($errors,"Invalid e-mail address given for user");
\r
453 if (!_isValidDisplayName($user_name))
\r
454 array_push($errors,"User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)");
\r
455 if (!$user_password || !$user_password2)
\r
456 array_push($errors, "User password is empty");
\r
457 if ($user_password != $user_password2)
\r
458 array_push($errors, "User password do not match");
\r
459 if (!_isValidShortName($blog_shortname))
\r
460 array_push($errors, "Invalid short name given for blog (allowed chars: a-z0-9, no spaces)");
\r
461 if (sizeof($errors) > 0)
\r
462 showErrorMessages($errors);
\r
464 // 2. try to log in to mySQL
\r
465 $connection = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
\r
466 if ($connection == false)
\r
467 _doError("Could not connect to mySQL server: " . mysql_error());
\r
469 // 3. try to create database (if needed)
\r
470 if ($mysql_create == 1) {
\r
471 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());
\r
474 // 4. try to select database
\r
475 mysql_select_db($mysql_database) or _doError("Could not select database. Make sure it exists");
\r
477 // 5. execute queries
\r
478 $filename = "install.sql";
\r
479 $fd = fopen ($filename, "r");
\r
480 $queries = fread ($fd, filesize ($filename));
\r
483 $queries = split("(;\n|;\r)",$queries);
\r
485 $aTableNames = array(
\r
486 'nucleus_actionlog',
\r
489 'nucleus_category',
\r
497 'nucleus_template',
\r
499 'nucleus_activation',
\r
501 // these are unneeded (one of the replacements above takes care of them)
\r
502 // 'nucleus_plugin_event',
\r
503 // 'nucleus_plugin_option',
\r
504 // 'nucleus_plugin_option_desc',
\r
505 // 'nucleus_skin_desc',
\r
506 // 'nucleus_template_desc',
\r
508 $aTableNamesPrefixed = array(
\r
509 $mysql_prefix . 'nucleus_actionlog',
\r
510 $mysql_prefix . 'nucleus_ban',
\r
511 $mysql_prefix . 'nucleus_blog',
\r
512 $mysql_prefix . 'nucleus_category',
\r
513 $mysql_prefix . 'nucleus_comment',
\r
514 $mysql_prefix . 'nucleus_config',
\r
515 $mysql_prefix . 'nucleus_item',
\r
516 $mysql_prefix . 'nucleus_karma',
\r
517 $mysql_prefix . 'nucleus_member',
\r
518 $mysql_prefix . 'nucleus_plugin',
\r
519 $mysql_prefix . 'nucleus_skin',
\r
520 $mysql_prefix . 'nucleus_template',
\r
521 $mysql_prefix . 'nucleus_team',
\r
522 $mysql_prefix . 'nucleus_activation',
\r
523 $mysql_prefix . 'nucleus_tickets'
\r
524 // these are unneeded (one of the replacements above takes care of them)
\r
525 // $mysql_prefix . 'nucleus_plugin_event',
\r
526 // $mysql_prefix . 'nucleus_plugin_option',
\r
527 // $mysql_prefix . 'nucleus_plugin_option_desc',
\r
528 // $mysql_prefix . 'nucleus_skin_desc',
\r
529 // $mysql_prefix . 'nucleus_template_desc',
\r
532 for ($idx = 0;$idx<sizeof($queries);$idx++) {
\r
533 $query = trim($queries[$idx]);
\r
534 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
\r
536 if ($mysql_usePrefix == 1)
\r
537 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
\r
538 mysql_query($query) or _doError("Error while executing query (<small>" . htmlspecialchars($query) . "</small>): " . mysql_error());
\r
543 // 6. update global settings
\r
544 updateConfig('IndexURL', $config_indexurl);
\r
545 updateConfig('AdminURL', $config_adminurl);
\r
546 updateConfig('MediaURL', $config_mediaurl);
\r
547 updateConfig('SkinsURL', $config_skinsurl);
\r
548 updateConfig('PluginURL', $config_pluginurl);
\r
549 updateConfig('ActionURL', $config_actionurl);
\r
550 updateConfig('AdminEmail', $config_adminemail);
\r
551 updateConfig('SiteName', $config_sitename);
\r
554 // 7. update GOD member
\r
555 $query = 'UPDATE ' . tableName('nucleus_member')
\r
556 . " SET mname='" . addslashes($user_name) . "',"
\r
557 . " mrealname='". addslashes($user_realname) . "',"
\r
558 . " mpassword='". md5(addslashes($user_password)) . "',"
\r
559 . " murl='" . addslashes($config_indexurl) . "',"
\r
560 . " memail='" . addslashes($user_email) . "',"
\r
563 . " WHERE mnumber=1";
\r
564 mysql_query($query) or _doError("Error while setting member settings: " . mysql_error());
\r
566 // 8. update weblog settings
\r
567 $query = 'UPDATE ' . tableName('nucleus_blog')
\r
568 . " SET bname='" . addslashes($blog_name) . "',"
\r
569 . " bshortname='". addslashes($blog_shortname) . "',"
\r
570 . " burl='" . addslashes($config_indexurl) . "'"
\r
571 . " WHERE bnumber=1";
\r
572 mysql_query($query) or _doError("Error while setting weblog settings: " . mysql_error());
\r
574 // 9. update item date
\r
575 $query = 'UPDATE ' . tableName('nucleus_item')
\r
576 . " SET itime='". date("Y-m-d H:i:s",time()) ."'"
\r
577 . " WHERE inumber=1";
\r
578 mysql_query($query) or _doError("Error with query: " . mysql_error());
\r
580 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
581 $aSkinErrors = array();
\r
582 $aPlugErrors = array();
\r
583 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {
\r
584 // 10. set global variables
\r
585 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
\r
586 $MYSQL_HOST = $mysql_host;
\r
587 $MYSQL_USER = $mysql_user;
\r
588 $MYSQL_PASSWORD = $mysql_password;
\r
589 $MYSQL_DATABASE = $mysql_database;
\r
590 $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
\r
591 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
592 $DIR_NUCLEUS = $config_adminpath;
\r
593 $DIR_MEDIA = $config_mediapath;
\r
594 $DIR_SKINS = $config_skinspath;
\r
595 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
596 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
597 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
599 // close database connection (needs to be closed if we want to include globalfunctions.php)
\r
603 include_once($DIR_LIBS . 'globalfunctions.php');
\r
605 // 11. install custom skins
\r
606 $aSkinErrors = installCustomSkins($manager);
\r
608 // 12. install custom plugins
\r
609 $aPlugErrors = installCustomPlugs($manager);
\r
614 // 12. Write config file ourselves (if possible)
\r
615 $bConfigWritten = 0;
\r
616 if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w')) {
\r
617 $config_data = "<" . "?php \n";
\r
618 $config_data .= "\n";
\r
619 $config_data .= " // mySQL connection information\n";
\r
620 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
\r
621 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
\r
622 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
\r
623 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
\r
624 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
\r
625 $config_data .= "\n";
\r
626 $config_data .= " // main nucleus directory\n";
\r
627 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
\r
628 $config_data .= "\n";
\r
629 $config_data .= " // path to media dir\n";
\r
630 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
\r
631 $config_data .= "\n";
\r
632 $config_data .= " // extra skin files for imported skins\n";
\r
633 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
\r
634 $config_data .= "\n";
\r
635 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
\r
636 $config_data .= " // you can redefine them if you wish\n";
\r
637 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
638 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
\r
639 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
640 $config_data .= "\n";
\r
641 $config_data .= " // include libs\n";
\r
642 $config_data .= " include(\$DIR_LIBS.'globalfunctions.php');\n";
\r
643 $config_data .= " if (!extension_loaded('mbstring')) {\n";
\r
644 $config_data .= " include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
\r
645 $config_data .= " }\n";
\r
646 $config_data .= "?" . ">";
\r
648 $result = @fputs($fp, $config_data, strlen($config_data));
\r
652 $bConfigWritten = 1;
\r
656 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
657 <html xmlns="http://www.w3.org/1999/xhtml">
\r
659 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
660 <title>Nucleusのインストール</title>
\r
662 @import url('nucleus/styles/manual.css');
\r
666 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
668 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
\r
669 if (count($aAllErrors) > 0) {
\r
670 echo '<h1>Skin/Plugin Install errors</h1>';
\r
671 echo '<ul><li>'.implode('</li><li>', $aAllErrors).'</li></ul>';
\r
674 if (!$bConfigWritten) { ?>
\r
675 <h1>インストールはほぼ完了しました!</h1>
\r
677 データベーステーブルの初期値入力が成功しました。後は<i>config.php</i>を書き換えるだけです。以下に書き換えるべき内容を表示します(mysqlのパスワードはマスクされています。ここは実際のものに書き換えてください)
\r
682 // mySQL connection information
\r
683 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
\r
684 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
\r
685 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
\r
686 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
\r
687 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
\r
689 // main nucleus directory
\r
690 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
\r
692 // path to media dir
\r
693 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
\r
695 // extra skin files for imported skins
\r
696 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
\r
698 // these dirs are normally sub dirs of the nucleus dir, but
\r
699 // you can redefine them if you wish
\r
700 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
701 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
702 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
705 include($DIR_LIBS.'globalfunctions.php');
\r
706 if (!extension_loaded('mbstring')) {
\r
707 include($DIR_LIBS.'mb_emulator/mb-emulator.php');
\r
712 <p>あなたのコンピュータ上のファイルを書き換えたら、FTPを使ってウェブサーバにアップロードしてください。ASCIIモードで送信してファイルを上書きします。
\r
716 <b>付記:</b> <i>config.php</i>の最初や終わりにスペースを空けないようにしましょう。実行時にエラーを引き起こす原因となります。
\r
718 したがって、config.phpの最初の文字は "<"で最後の文字は">"としなければなりません。
\r
722 <h1>インストールは完了しました!</h1>
\r
724 <p>Nucleusはインストールされ、<code>config.php</code>はアップデートされました。</p>
\r
726 <p>セキュリティのため<code>config.php</code>のパーミッションを444に戻すことを忘れないでください(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>
\r
728 <h1>インストールファイルの削除</h1>
\r
730 <p>ウェブサーバから次のファイルを削除してください:</p>
\r
733 <li><b>install.sql</b>:テーブルの構造を内包するファイル</li>
\r
734 <li><b>install.php</b>:このファイル</li>
\r
737 <p>もしこれらのファイルを削除していなければ、管理領域を開くことが出来ません。</p>
\r
743 <li><a href="<?php echo $config_adminurl?>">管理領域にログインしてサイトの設定を行う</a></li>
\r
744 <li><a href="<?php echo $config_indexurl?>">すぐにサイトへ行ってみる</a></li>
\r
754 function installCustomPlugs(&$manager) {
\r
755 global $aConfPlugsToInstall, $DIR_LIBS;
\r
757 $aErrors = array();
\r
759 if (count($aConfPlugsToInstall) == 0)
\r
762 $numCurrent = mysql_num_rows(sql_query('SELECT * FROM '.sql_table('plugin')));
\r
764 foreach ($aConfPlugsToInstall as $plugName) {
\r
765 // do this before calling getPlugin (in case the plugin id is used there)
\r
766 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.(++$numCurrent).',"'.addslashes($plugName).'")';
\r
769 // get and install the plugin
\r
770 $plugin =& $manager->getPlugin($plugName);
\r
772 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\''. addslashes($plugName).'\'');
\r
774 array_push($aErrors, 'Unable to install plugin ' . $plugName);
\r
777 $plugin->install();
\r
780 // SYNC PLUGIN EVENT LIST
\r
781 sql_query('DELETE FROM '.sql_table('plugin_event'));
\r
782 // loop over all installed plugins
\r
783 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
\r
784 while($o = mysql_fetch_object($res)) {
\r
786 $plug =& $manager->getPlugin($o->pfile);
\r
789 $eventList = $plug->getEventList();
\r
790 foreach ($eventList as $eventName)
\r
791 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.$eventName.'\')');
\r
798 function installCustomSkins(&$manager) {
\r
799 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
801 $aErrors = array();
\r
803 if (count($aConfSkinsToImport) == 0)
\r
806 // load skinie class
\r
807 include_once($DIR_LIBS . 'skinie.php');
\r
809 $importer = new SKINIMPORT();
\r
811 foreach ($aConfSkinsToImport as $skinName) {
\r
812 $importer->reset();
\r
814 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
815 if (!@file_exists($skinFile)) {
\r
816 array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
\r
819 $error = $importer->readFile($skinFile);
\r
821 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
\r
824 $error = $importer->writeToDatabase(1);
\r
826 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
\r
834 // give an error if one or more nucleus are not accessible
\r
835 function doCheckFiles() {
\r
836 $missingfiles = array();
\r
838 if (!is_readable('install.sql'))
\r
839 array_push($missingfiles, "File <b>install.sql</b> is missing or not readable");
\r
840 if (!is_readable('index.php'))
\r
841 array_push($missingfiles, "File <b>index.php</b> is missing or not readable");
\r
842 if (!is_readable('action.php'))
\r
843 array_push($missingfiles, "File <b>action.php</b> is missing or not readable");
\r
844 if (!is_readable('nucleus/index.php'))
\r
845 array_push($missingfiles, "File <b>nucleus/index.php</b> is missing or not readable");
\r
846 if (!is_readable('nucleus/libs/globalfunctions.php'))
\r
847 array_push($missingfiles, "File <b>nucleus/libs/globalfunctions.php</b> is missing or not readable");
\r
848 if (!is_readable('nucleus/libs/ADMIN.php'))
\r
849 array_push($missingfiles, "File <b>nucleus/libs/ADMIN.php</b> is missing or not readable");
\r
850 if (!is_readable('nucleus/libs/BLOG.php'))
\r
851 array_push($missingfiles, "File <b>nucleus/libs/BLOG.php</b> is missing or not readable");
\r
852 if (!is_readable('nucleus/libs/COMMENT.php'))
\r
853 array_push($missingfiles, "File <b>nucleus/libs/COMMENT.php</b> is missing or not readable");
\r
854 if (!is_readable('nucleus/libs/COMMENTS.php'))
\r
855 array_push($missingfiles, "File <b>nucleus/libs/COMMENTS.php</b> is missing or not readable");
\r
856 if (!is_readable('nucleus/libs/ITEM.php'))
\r
857 array_push($missingfiles, "File <b>nucleus/libs/ITEM.php</b> is missing or not readable");
\r
858 if (!is_readable('nucleus/libs/MEMBER.php'))
\r
859 array_push($missingfiles, "File <b>nucleus/libs/MEMBER.php</b> is missing or not readable");
\r
860 if (!is_readable('nucleus/libs/SKIN.php'))
\r
861 array_push($missingfiles, "File <b>nucleus/libs/SKIN.php</b> is missing or not readable");
\r
862 if (!is_readable('nucleus/libs/TEMPLATE.php'))
\r
863 array_push($missingfiles, "File <b>nucleus/libs/TEMPLATE.php</b> is missing or not readable");
\r
864 if (!is_readable('nucleus/libs/MEDIA.php'))
\r
865 array_push($missingfiles, "File <b>nucleus/libs/MEDIA.php</b> is missing or not readable");
\r
866 if (!is_readable('nucleus/libs/ACTIONLOG.php'))
\r
867 array_push($missingfiles, "File <b>nucleus/libs/ACTIONLOG.php</b> is missing or not readable");
\r
868 if (!is_readable('nucleus/media.php'))
\r
869 array_push($missingfiles, "File <b>nucleus/media.php</b> is missing or not readable");
\r
872 if (sizeof($missingfiles) > 0)
\r
873 showErrorMessages($missingfiles);
\r
878 function updateConfig($name, $val) {
\r
879 $name = addslashes($name);
\r
880 $val = trim(addslashes($val));
\r
882 $query = 'UPDATE ' . tableName('nucleus_config')
\r
883 . " SET value='$val'"
\r
884 . " WHERE name='$name'";
\r
886 mysql_query($query) or _doError("Query error while trying to update config: " . mysql_error());
\r
887 return mysql_insert_id();
\r
890 function endsWithSlash($s) {
\r
891 return (strrpos($s,'/') == strlen($s) - 1);
\r
895 * Checks if email address is valid
\r
897 function _isValidMailAddress($address) {
\r
898 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address))
\r
904 // returns true if the given string is a valid shortname
\r
905 // (to check short blog names and nicknames)
\r
906 // logic: starts and ends with a non space, can contain spaces in between
\r
908 function _isValidShortName($name) {
\r
909 if (eregi("^[a-z0-9]+$", $name))
\r
917 // returns true if the given string is a valid display name
\r
918 // (to check nicknames)
\r
919 function _isValidDisplayName($name) {
\r
920 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name))
\r
926 function _doError($msg) {
\r
928 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
929 <html xmlns="http://www.w3.org/1999/xhtml">
\r
931 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
932 <title>Nucleus Install</title>
\r
934 @import url('nucleus/styles/manual.css');
\r
938 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
941 Error message was: "<?php echo $msg?>";
\r
945 <a href="install.php" onclick="history.back();return false;">Go Back</a>
\r
952 function showErrorMessages($errors) {
\r
954 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
955 <html xmlns="http://www.w3.org/1999/xhtml">
\r
957 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
958 <title>Nucleus Install</title>
\r
960 @import url('nucleus/styles/manual.css');
\r
964 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
971 <?php while($msg = array_shift($errors))
\r
972 echo "<li>$msg</li>";
\r
977 <a href="install.php" onclick="history.back();return false;">Go Back</a>
\r
985 /* for the non-php systems that decide to show the contents:
\r