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
14 * 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.php</i>, your web server is not able to run PHP-scripts, and therefor Nucleus will not be able to run there. </div><div style="display: none"><?php */
\r
19 This part of the install.php code allows for customization of the install process.
\r
20 When distributing plugins or skins together with a Nucleus installation, the
\r
21 configuration below will instruct to install them
\r
23 -- Start Of Configurable Part --
\r
26 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
\r
30 // array('NP_TrackBack', 'NP_MemberGoodies')
\r
31 $aConfPlugsToInstall = array('NP_SkinFiles');
\r
34 // array with skins to install. skins must be present under the skins/ directory with
\r
35 // a subdirectory having the same name that contains a skinbackup.xml file
\r
38 // array('base','rsd')
\r
39 $aConfSkinsToImport = array('default');
\r
42 -- End Of Configurable Part --
\r
45 // don't give warnings for uninitialized vars
\r
46 error_reporting(E_ERROR | E_WARNING | E_PARSE);
\r
48 // make sure there's no unnecessary escaping:
\r
49 set_magic_quotes_runtime(0);
\r
51 // if there are some plugins or skins to import, do not include vars
\r
52 // in globalfunctions.php again... so set a flag
\r
53 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {
\r
55 $CONF['installscript']=1;
\r
57 if (phpversion() >= '4.1.0')
\r
58 include_once('nucleus/libs/vars4.1.0.php');
\r
60 include_once('nucleus/libs/vars4.0.6.php');
\r
62 // check if mysql support is installed
\r
63 if (!function_exists('mysql_query'))
\r
64 _doError('Your PHP version does not have support for MySQL :(');
\r
66 if (postVar('action') == 'go')
\r
72 function showInstallForm() {
\r
74 // 0. pre check if all necessary files exist
\r
79 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
80 <html xmlns="http://www.w3.org/1999/xhtml">
\r
82 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
\r
83 <title>Nucleusのインストール</title>
\r
84 <style type="text/css"><!--
\r
85 @import url('nucleus/documentation/styles/manual.css');
\r
87 <script type="text/javascript"><!--
\r
88 // function to make sure the submit button only gets pressed once
\r
90 function checkSubmit() {
\r
91 if (submitcount == 0) {
\r
102 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
104 <form method="post" action="install.php">
\r
106 <h1>Install Nucleus</h1>
\r
109 このスクリプトはNucleusのインストールを手助けします。MySQLテーブルのセットアップと、<i>config.php</i>に入力するための情報を表示します(config.phpのパーミッションを0666にしておけば、後者の作業は自動的に行われます)。これをなす為に、いくつかの情報を入力する必要があります。
\r
113 すべての欄の入力が必要です。オプション情報はインストールが完了したら、Nucleusの管理領域から設定可能です。
\r
116 <h1>PHP & MySQL Versions</h1>
\r
119 以下はあなたのウェブホストにおけるPHPインタープリターとMySQLサーバーのバージョンです。Nucleusのサポートフォーラムに問題を報告するときは、この情報を書き添えてください。
\r
123 <li>PHP: <?php echo phpversion();
\r
124 $minVersion = '4.0.6';
\r
126 if (phpversion() < $minVersion)
\r
127 echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
\r
130 // note: this piece of code is taken from phpMyAdmin
\r
132 $result = @mysql_query('SELECT VERSION() AS version');
\r
133 if ($result != FALSE && @mysql_num_rows($result) > 0) {
\r
134 $row = mysql_fetch_array($result);
\r
135 $match = explode('.', $row['version']);
\r
137 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
\r
138 if ($result != FALSE && @mysql_num_rows($result) > 0){
\r
139 $row = mysql_fetch_row($result);
\r
140 $match = explode('.', $row[1]);
\r
148 if (!isset($match) || !isset($match[0])) {
\r
151 if (!isset($match[1])) {
\r
154 if (!isset($match[2])) {
\r
158 if ($match[0] != '?') {
\r
159 $match[0] = intval($match[0]);
\r
160 $match[1] = intval($match[1]);
\r
163 $mysqlVersion = implode($match, '.');
\r
164 $minVersion = '3.23';
\r
166 echo $mysqlVersion;
\r
168 if ($mysqlVersion < $minVersion)
\r
169 echo ' <span class="warning">注意: Nucleusの動作には少なくともバージョン ',$minVersion,' が必要とされます</span>';
\r
174 // tell people how they can have their config file filled out automatically
\r
175 if (@file_exists('config.php') && @!is_writable('config.php')) {
\r
177 <h1><i>config.php</i>の自動アップデート</h1>
\r
180 もし<em>config.php</em>を自動的に更新するようにしたいなら、書き込み可能にする必要があります。<em>config.php</em>のパーミッションを<strong>666</strong>にしてください。Nucleusのインストール成功後に、パーミッションを<strong>444</strong>に戻さなければなりません(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。
\r
184 もしファイルに書き込まないという選択をした(あるいは行えない)場合:ご心配なく。インストールの過程で<em>config.php</em>の中身が提供されます。ですから、それをご自身でアップロードしてください。
\r
189 <h1>MySQLのログインデータ</h1>
\r
192 MySQLのデータを以下に入力してください。それらはデータベース・テーブルを作成し情報を入力するために必要なものです。後で、<i>config.php</i>にも記入する必要があります(上記の自動アップデートを利用する場合、その手順は省略されます)。
\r
196 もしこの情報がわからなければ、システム管理者かホスティング元に連絡をとってください。ほとんどの場合、ホスト名は'localhost'です。もしNucleusがあなたのサーバのPHP設定から'default MySQL host'を検知したなら、'ホスト名'に既に記入されているはずです。もっとも、この情報が正確であるという保証はありません。
\r
200 <legend>基本のデータベース設定</legend>
\r
203 <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host'))?>" /></td>
\r
206 <td><input name="mySQL_user" /></td>
\r
209 <td><input name="mySQL_password" type="password" /></td>
\r
212 <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />データベースを作成する必要がある</label>)</td>
\r
217 <legend>高等なデータベース設定</legend>
\r
219 <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />テーブル・プリフィックスを利用</label></td>
\r
220 <td><input name="mySQL_tablePrefix" value="" /></td>
\r
222 <p>一つのデータベースに複数のNucleusをインストールしており、自分が何をやっているのか理解されている場合を除いては、<strong>これを変更する必要はありません</strong>。</p>
\r
223 <p>Nucleusによって生成されたすべてのデータベーステーブルは、このプリフィックスが頭につきます。</p>
\r
226 <h1>ディレクトリとURL</h1>
\r
229 このインストールスクリプトはNucleusがインストールされているディレクトリとURLを見つけようとしました。下の値をチェックして必要なら訂正してください。ファイルへのパスとURLはスラッシュ'/'で終わらなくてはなりません。
\r
233 <legend>URLs and directories</legend>
\r
235 <td>Site <strong>URL</strong>:</td>
\r
237 <input name="IndexURL" size="60" value="<?php $url = "http://" . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
\r
238 $url = str_replace("install.php",'',$url);
\r
239 $url = str_replace("\\","/",$url);
\r
240 // add slash at end if necessary
\r
241 if (!endsWithSlash($url)) $url .= '/';
\r
246 <td>Admin-area <strong>URL</strong>:</td>
\r
247 <td><input name="AdminURL" size="60" value="<?php if ($url) echo $url . 'nucleus/';
\r
251 <td>Admin-area <strong>path</strong>:</td>
\r
252 <td><input name="AdminPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
\r
253 $path = str_replace("\\","/",$path);
\r
254 // add slash at end if necessary
\r
255 if (!endsWithSlash($path)) $path .= '/';
\r
256 if($path) echo $path . 'nucleus/';
\r
260 <td>Media files <strong>URL</strong>:</td>
\r
261 <td><input name="MediaURL" size="60" value="<?php if ($url) echo $url . 'media/';
\r
265 <td>Media directory <strong>path</strong>:</td>
\r
266 <td><input name="MediaPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
\r
267 $path = str_replace("\\","/",$path);
\r
268 // add slash at end if necessary
\r
269 if (!endsWithSlash($path)) $path .= '/';
\r
270 if ($path) echo $path . 'media/';
\r
274 <td>Extra skin files <strong>URL</strong>:</td>
\r
275 <td><input name="SkinsURL" size="60" value="<?php if ($url) echo $url . 'skins/';
\r
277 <br />(インポートされたスキンが使用)
\r
280 <td>Extra skin files directory <strong>path</strong>:</td>
\r
281 <td><input name="SkinsPath" size="60" value="<?php $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
\r
282 $path = str_replace("\\","/",$path);
\r
283 // add slash at end if necessary
\r
284 if (!endsWithSlash($path)) $path .= '/';
\r
285 if ($path) echo $path . 'skins/';
\r
287 <br />(インポートされたスキンのファイル類を置く場所)
\r
290 <td>Plugin files <strong>URL</strong>:</td>
\r
291 <td><input name="PluginURL" size="60" value="<?php if ($url) echo $url . 'nucleus/plugins/';
\r
295 <td>Action <strong>URL</strong>:</td>
\r
296 <td><input name="ActionURL" size="60" value="<?php if ($url) echo $url . 'action.php';
\r
298 <br />(<tt>action.php</tt>へのhttp://から始まるURL)
\r
304 <strong>付記:</strong> 相対パスではなく<strong>絶対パスを使ってください</strong>。通常、絶対パスは<tt>/home/username/public_html/</tt>のような形をとります。Unixシステム(ほとんどのサーバーがそうです)において、パスはスラッシュから始まります。もしこれらの情報入力に問題が生じたら、あなたのサーバ管理者にたずねるべきです。
\r
307 <h1>管理権限をもつユーザー</h1>
\r
309 <p>以下に、サイトの最初のユーザーを作成するためのいくつかの情報を入力してください。</p>
\r
312 <legend>管理権限を持つユーザー</legend>
\r
316 <input name="User_name" value="" />
\r
317 <small>(許可される文字:a-z と 0-9、最初と最後以外のスペース)</small>
\r
320 <td>本名(ハンドル名):</td>
\r
321 <td><input name="User_realname" value="" /></td>
\r
324 <td><input name="User_password" type="password" value="" /></td>
\r
327 <td><input name="User_password2" type="password" value="" /></td>
\r
331 <input name="User_email" value="" />
\r
332 <small>(利用可能なメールアドレスを入れてください)</small>
\r
339 <p>以下に、デフォルトのweblogを作成するためにいくつかの情報を入力してください。このweblogの名前は、サイト名としても利用されます。</p>
\r
342 <legend>ウェブログのデータ</legend>
\r
345 <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>
\r
349 <input name="Blog_shortname" value="mynucleuscms" />
\r
350 <small>(許可される文字:a-z と 0-9、スペースは不可)</small>
\r
358 上に書いてきたデータが正しいか確かめてください。よければデータベース・テーブルと最初のデータを設定するために下のボタンを押してください。少し時間がかかるかもしれませんがご辛抱を。<b>ボタンをクリックするのは一回だけにしてください。</b>
\r
362 <input name="action" value="go" type="hidden" />
\r
363 <input type="submit" value="Nucleus CMSのインストール" onclick="return checkSubmit();" />
\r
374 function tableName($unPrefixed)
\r
376 global $mysql_usePrefix, $mysql_prefix;
\r
377 if ($mysql_usePrefix == 1)
\r
378 return $mysql_prefix . $unPrefixed;
\r
380 return $unPrefixed;
\r
383 function doInstall() {
\r
384 global $mysql_usePrefix, $mysql_prefix;
\r
386 // 0. put all POST-vars into vars
\r
387 $mysql_host = postVar('mySQL_host');
\r
388 $mysql_user = postVar('mySQL_user');
\r
389 $mysql_password = postVar('mySQL_password');
\r
390 $mysql_database = postVar('mySQL_database');
\r
391 $mysql_create = postVar('mySQL_create');
\r
392 $mysql_usePrefix = postVar('mySQL_usePrefix');
\r
393 $mysql_prefix = postVar('mySQL_tablePrefix');
\r
394 $config_indexurl = postVar('IndexURL');
\r
395 $config_adminurl = postVar('AdminURL');
\r
396 $config_adminpath = postVar('AdminPath');
\r
397 $config_mediaurl = postVar('MediaURL');
\r
398 $config_skinsurl = postVar('SkinsURL');
\r
399 $config_pluginurl = postVar('PluginURL');
\r
400 $config_actionurl = postVar('ActionURL');
\r
401 $config_mediapath = postVar('MediaPath');
\r
402 $config_skinspath = postVar('SkinsPath');
\r
403 $user_name = postVar('User_name');
\r
404 $user_realname = postVar('User_realname');
\r
405 $user_password = postVar('User_password');
\r
406 $user_password2 = postVar('User_password2');
\r
407 $user_email = postVar('User_email');
\r
408 $blog_name = postVar('Blog_name');
\r
409 $blog_shortname = postVar('Blog_shortname');
\r
410 $config_adminemail = $user_email;
\r
411 $config_sitename = $blog_name;
\r
414 $config_indexurl = str_replace("\\","/",$config_indexurl);
\r
415 $config_adminurl = str_replace("\\","/",$config_adminurl);
\r
416 $config_mediaurl = str_replace("\\","/",$config_mediaurl);
\r
417 $config_skinsurl = str_replace("\\","/",$config_skinsurl);
\r
418 $config_pluginurl = str_replace("\\","/",$config_pluginurl);
\r
419 $config_actionurl = str_replace("\\","/",$config_actionurl);
\r
420 $config_adminpath = str_replace("\\","/",$config_adminpath);
\r
421 $config_skinspath = str_replace("\\","/",$config_skinspath);
\r
423 // 1. check all the data
\r
426 if (!$mysql_database)
\r
427 array_push($errors,"mySQL database name missing");
\r
428 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0))
\r
429 array_push($errors,"mySQL prefix was selected, but prefix is empty");
\r
430 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix)))
\r
431 array_push($errors,"mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores");
\r
432 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl)
\r
433 || !endsWithSlash($config_mediaurl)
\r
434 || !endsWithSlash($config_pluginurl)
\r
435 || !endsWithSlash($config_skinsurl)
\r
436 // TODO: add action.php check
\r
438 array_push($errors,"One of the URLs does not end with a slash, or action url does not end with 'action.php'");
\r
439 if (!endsWithSlash($config_adminpath))
\r
440 array_push($errors,"The path of the administration area does not end with a slash");
\r
441 if (!endsWithSlash($config_mediapath))
\r
442 array_push($errors,"The media path does not end with a slash");
\r
443 if (!endsWithSlash($config_skinspath))
\r
444 array_push($errors,"The skins path does not end with a slash");
\r
445 if (!is_dir($config_adminpath))
\r
446 array_push($errors,"The path of the administration area does not exist on your server");
\r
447 if (!_isValidMailAddress($user_email))
\r
448 array_push($errors,"Invalid e-mail address given for user");
\r
449 if (!_isValidDisplayName($user_name))
\r
450 array_push($errors,"User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)");
\r
451 if (!$user_password || !$user_password2)
\r
452 array_push($errors, "User password is empty");
\r
453 if ($user_password != $user_password2)
\r
454 array_push($errors, "User password do not match");
\r
455 if (!_isValidShortName($blog_shortname))
\r
456 array_push($errors, "Invalid short name given for blog (allowed chars: a-z0-9, no spaces)");
\r
457 if (sizeof($errors) > 0)
\r
458 showErrorMessages($errors);
\r
460 // 2. try to log in to mySQL
\r
461 $connection = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
\r
462 if ($connection == false)
\r
463 _doError("Could not connect to mySQL server: " . mysql_error());
\r
465 // 3. try to create database (if needed)
\r
466 if ($mysql_create == 1) {
\r
467 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
470 // 4. try to select database
\r
471 mysql_select_db($mysql_database) or _doError("Could not select database. Make sure it exists");
\r
473 // 5. execute queries
\r
474 $filename = "install.sql";
\r
475 $fd = fopen ($filename, "r");
\r
476 $queries = fread ($fd, filesize ($filename));
\r
479 $queries = split("(;\n|;\r)",$queries);
\r
481 $aTableNames = array(
\r
482 'nucleus_actionlog',
\r
485 'nucleus_category',
\r
493 'nucleus_template',
\r
495 // these are unneeded (one of the replacements above takes care of them)
\r
496 // 'nucleus_plugin_event',
\r
497 // 'nucleus_plugin_option',
\r
498 // 'nucleus_plugin_option_desc',
\r
499 // 'nucleus_skin_desc',
\r
500 // 'nucleus_template_desc',
\r
502 $aTableNamesPrefixed = array(
\r
503 $mysql_prefix . 'nucleus_actionlog',
\r
504 $mysql_prefix . 'nucleus_ban',
\r
505 $mysql_prefix . 'nucleus_blog',
\r
506 $mysql_prefix . 'nucleus_category',
\r
507 $mysql_prefix . 'nucleus_comment',
\r
508 $mysql_prefix . 'nucleus_config',
\r
509 $mysql_prefix . 'nucleus_item',
\r
510 $mysql_prefix . 'nucleus_karma',
\r
511 $mysql_prefix . 'nucleus_member',
\r
512 $mysql_prefix . 'nucleus_plugin',
\r
513 $mysql_prefix . 'nucleus_skin',
\r
514 $mysql_prefix . 'nucleus_template',
\r
515 $mysql_prefix . 'nucleus_team'
\r
516 // these are unneeded (one of the replacements above takes care of them)
\r
517 // $mysql_prefix . 'nucleus_plugin_event',
\r
518 // $mysql_prefix . 'nucleus_plugin_option',
\r
519 // $mysql_prefix . 'nucleus_plugin_option_desc',
\r
520 // $mysql_prefix . 'nucleus_skin_desc',
\r
521 // $mysql_prefix . 'nucleus_template_desc',
\r
524 for ($idx = 0;$idx<sizeof($queries);$idx++) {
\r
525 $query = trim($queries[$idx]);
\r
526 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
\r
528 if ($mysql_usePrefix == 1)
\r
529 $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
\r
530 mysql_query($query) or _doError("Error while executing query (<small>" . htmlspecialchars($query) . "</small>): " . mysql_error());
\r
535 // 6. update global settings
\r
536 updateConfig('IndexURL', $config_indexurl);
\r
537 updateConfig('AdminURL', $config_adminurl);
\r
538 updateConfig('MediaURL', $config_mediaurl);
\r
539 updateConfig('SkinsURL', $config_skinsurl);
\r
540 updateConfig('PluginURL', $config_pluginurl);
\r
541 updateConfig('ActionURL', $config_actionurl);
\r
542 updateConfig('AdminEmail', $config_adminemail);
\r
543 updateConfig('SiteName', $config_sitename);
\r
546 // 7. update GOD member
\r
547 $query = 'UPDATE ' . tableName('nucleus_member')
\r
548 . " SET mname='" . addslashes($user_name) . "',"
\r
549 . " mrealname='". addslashes($user_realname) . "',"
\r
550 . " mpassword='". md5(addslashes($user_password)) . "',"
\r
551 . " murl='" . addslashes($config_indexurl) . "',"
\r
552 . " memail='" . addslashes($user_email) . "',"
\r
555 . " WHERE mnumber=1";
\r
556 mysql_query($query) or _doError("Error while setting member settings: " . mysql_error());
\r
558 // 8. update weblog settings
\r
559 $query = 'UPDATE ' . tableName('nucleus_blog')
\r
560 . " SET bname='" . addslashes($blog_name) . "',"
\r
561 . " bshortname='". addslashes($blog_shortname) . "',"
\r
562 . " burl='" . addslashes($config_indexurl) . "'"
\r
563 . " WHERE bnumber=1";
\r
564 mysql_query($query) or _doError("Error while setting weblog settings: " . mysql_error());
\r
566 // 9. update item date
\r
567 $query = 'UPDATE ' . tableName('nucleus_item')
\r
568 . " SET itime='". date("Y-m-d H:i:s",time()) ."'"
\r
569 . " WHERE inumber=1";
\r
570 mysql_query($query) or _doError("Error with query: " . mysql_error());
\r
572 global $aConfPlugsToInstall, $aConfSkinsToImport;
\r
573 $aSkinErrors = array();
\r
574 $aPlugErrors = array();
\r
575 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {
\r
576 // 10. set global variables
\r
577 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
\r
578 $MYSQL_HOST = $mysql_host;
\r
579 $MYSQL_USER = $mysql_user;
\r
580 $MYSQL_PASSWORD = $mysql_password;
\r
581 $MYSQL_DATABASE = $mysql_database;
\r
582 $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
\r
583 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
\r
584 $DIR_NUCLEUS = $config_adminpath;
\r
585 $DIR_MEDIA = $config_mediapath;
\r
586 $DIR_SKINS = $config_skinspath;
\r
587 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
588 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
589 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
591 // close database connection (needs to be closed if we want to include globalfunctions.php)
\r
595 include_once($DIR_LIBS . 'globalfunctions.php');
\r
597 // 11. install custom skins
\r
598 $aSkinErrors = installCustomSkins($manager);
\r
600 // 12. install custom plugins
\r
601 $aPlugErrors = installCustomPlugs($manager);
\r
606 // 12. Write config file ourselves (if possible)
\r
607 $bConfigWritten = 0;
\r
608 if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w')) {
\r
609 $config_data = "<" . "?php \n";
\r
610 $config_data .= "\n";
\r
611 $config_data .= " // mySQL connection information\n";
\r
612 $config_data .= " \$MYSQL_HOST = '" . $mysql_host . "';\n";
\r
613 $config_data .= " \$MYSQL_USER = '" . $mysql_user . "';\n";
\r
614 $config_data .= " \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
\r
615 $config_data .= " \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
\r
616 $config_data .= " \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
\r
617 $config_data .= "\n";
\r
618 $config_data .= " // main nucleus directory\n";
\r
619 $config_data .= " \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
\r
620 $config_data .= "\n";
\r
621 $config_data .= " // path to media dir\n";
\r
622 $config_data .= " \$DIR_MEDIA = '" . $config_mediapath . "';\n";
\r
623 $config_data .= "\n";
\r
624 $config_data .= " // extra skin files for imported skins\n";
\r
625 $config_data .= " \$DIR_SKINS = '" . $config_skinspath . "';\n";
\r
626 $config_data .= "\n";
\r
627 $config_data .= " // these dirs are normally sub dirs of the nucleus dir, but \n";
\r
628 $config_data .= " // you can redefine them if you wish\n";
\r
629 $config_data .= " \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
\r
630 $config_data .= " \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
\r
631 $config_data .= " \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
\r
632 $config_data .= "\n";
\r
633 $config_data .= " // include libs\n";
\r
634 $config_data .= " include(\$DIR_LIBS.'globalfunctions.php');\n";
\r
635 $config_data .= " if (!extension_loaded('mbstring')) {\n";
\r
636 $config_data .= " include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
\r
637 $config_data .= " }\n";
\r
638 $config_data .= "?" . ">";
\r
640 $result = @fputs($fp, $config_data, strlen($config_data));
\r
644 $bConfigWritten = 1;
\r
648 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
649 <html xmlns="http://www.w3.org/1999/xhtml">
\r
651 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
652 <title>Nucleusのインストール</title>
\r
654 @import url('nucleus/styles/manual.css');
\r
658 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
660 $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
\r
661 if (count($aAllErrors) > 0) {
\r
662 echo '<h1>Skin/Plugin Install errors</h1>';
\r
663 echo '<ul><li>'.implode('</li><li>', $aAllErrors).'</li></ul>';
\r
666 if (!$bConfigWritten) { ?>
\r
667 <h1>インストールはほぼ完了しました!</h1>
\r
669 データベーステーブルの初期値入力が成功しました。後は<i>config.php</i>を書き換えるだけです。以下に書き換えるべき内容を表示します(mysqlのパスワードはマスクされています。ここは実際のものに書き換えてください)
\r
674 // mySQL connection information
\r
675 $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
\r
676 $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
\r
677 $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
\r
678 $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
\r
679 $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
\r
681 // main nucleus directory
\r
682 $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
\r
684 // path to media dir
\r
685 $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
\r
687 // extra skin files for imported skins
\r
688 $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
\r
690 // these dirs are normally sub dirs of the nucleus dir, but
\r
691 // you can redefine them if you wish
\r
692 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
\r
693 $DIR_LANG = $DIR_NUCLEUS . 'language/';
\r
694 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
\r
697 include($DIR_LIBS.'globalfunctions.php');
\r
698 if (!extension_loaded('mbstring')) {
\r
699 include($DIR_LIBS.'mb_emulator/mb-emulator.php');
\r
704 <p>あなたのコンピュータ上のファイルを書き換えたら、FTPを使ってウェブサーバにアップロードしてください。ASCIIモードで送信してファイルを上書きします。
\r
708 <b>付記:</b> <i>config.php</i>の最初や終わりにスペースを空けないようにしましょう。実行時にエラーを引き起こす原因となります。
\r
710 したがって、config.phpの最初の文字は "<"で最後の文字は">"としなければなりません。
\r
714 <h1>インストールは完了しました!</h1>
\r
716 <p>Nucleusはインストールされ、<code>config.php</code>はアップデートされました。</p>
\r
718 <p>セキュリティのため<code>config.php</code>のパーミッションを444に戻すことを忘れないでください(<a href="nucleus/documentation/tips.html#filepermissions">パーミッション変更の簡易ガイド</a>)。</p>
\r
720 <h1>インストールファイルの削除</h1>
\r
722 <p>ウェブサーバから次のファイルを削除してください:</p>
\r
725 <li><b>install.sql</b>:テーブルの構造を内包するファイル</li>
\r
726 <li><b>install.php</b>:このファイル</li>
\r
729 <p>もしこれらのファイルを削除していなければ、管理領域を開くことが出来ません。</p>
\r
735 <li><a href="<?php echo $config_adminurl?>">管理領域にログインしてサイトの設定を行う</a></li>
\r
736 <li><a href="<?php echo $config_indexurl?>">すぐにサイトへ行ってみる</a></li>
\r
746 function installCustomPlugs(&$manager) {
\r
747 global $aConfPlugsToInstall, $DIR_LIBS;
\r
749 $aErrors = array();
\r
751 if (count($aConfPlugsToInstall) == 0)
\r
754 $numCurrent = mysql_num_rows(sql_query('SELECT * FROM '.sql_table('plugin')));
\r
756 foreach ($aConfPlugsToInstall as $plugName) {
\r
757 // do this before calling getPlugin (in case the plugin id is used there)
\r
758 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.(++$numCurrent).',"'.addslashes($plugName).'")';
\r
761 // get and install the plugin
\r
762 $plugin =& $manager->getPlugin($plugName);
\r
764 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\''. addslashes($plugName).'\'');
\r
766 array_push($aErrors, 'Unable to install plugin ' . $plugName);
\r
769 $plugin->install();
\r
772 // SYNC PLUGIN EVENT LIST
\r
773 sql_query('DELETE FROM '.sql_table('plugin_event'));
\r
774 // loop over all installed plugins
\r
775 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
\r
776 while($o = mysql_fetch_object($res)) {
\r
778 $plug =& $manager->getPlugin($o->pfile);
\r
781 $eventList = $plug->getEventList();
\r
782 foreach ($eventList as $eventName)
\r
783 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.$eventName.'\')');
\r
790 function installCustomSkins(&$manager) {
\r
791 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
\r
793 $aErrors = array();
\r
795 if (count($aConfSkinsToImport) == 0)
\r
798 // load skinie class
\r
799 include_once($DIR_LIBS . 'skinie.php');
\r
801 $importer = new SKINIMPORT();
\r
803 foreach ($aConfSkinsToImport as $skinName) {
\r
804 $importer->reset();
\r
806 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
\r
807 if (!@file_exists($skinFile)) {
\r
808 array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
\r
811 $error = $importer->readFile($skinFile);
\r
813 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
\r
816 $error = $importer->writeToDatabase(1);
\r
818 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
\r
826 // give an error if one or more nucleus are not accessible
\r
827 function doCheckFiles() {
\r
828 $missingfiles = array();
\r
830 if (!is_readable('install.sql'))
\r
831 array_push($missingfiles, "File <b>install.sql</b> is missing or not readable");
\r
832 if (!is_readable('index.php'))
\r
833 array_push($missingfiles, "File <b>index.php</b> is missing or not readable");
\r
834 if (!is_readable('action.php'))
\r
835 array_push($missingfiles, "File <b>action.php</b> is missing or not readable");
\r
836 if (!is_readable('nucleus/index.php'))
\r
837 array_push($missingfiles, "File <b>nucleus/index.php</b> is missing or not readable");
\r
838 if (!is_readable('nucleus/libs/globalfunctions.php'))
\r
839 array_push($missingfiles, "File <b>nucleus/libs/globalfunctions.php</b> is missing or not readable");
\r
840 if (!is_readable('nucleus/libs/ADMIN.php'))
\r
841 array_push($missingfiles, "File <b>nucleus/libs/ADMIN.php</b> is missing or not readable");
\r
842 if (!is_readable('nucleus/libs/BLOG.php'))
\r
843 array_push($missingfiles, "File <b>nucleus/libs/BLOG.php</b> is missing or not readable");
\r
844 if (!is_readable('nucleus/libs/COMMENT.php'))
\r
845 array_push($missingfiles, "File <b>nucleus/libs/COMMENT.php</b> is missing or not readable");
\r
846 if (!is_readable('nucleus/libs/COMMENTS.php'))
\r
847 array_push($missingfiles, "File <b>nucleus/libs/COMMENTS.php</b> is missing or not readable");
\r
848 if (!is_readable('nucleus/libs/ITEM.php'))
\r
849 array_push($missingfiles, "File <b>nucleus/libs/ITEM.php</b> is missing or not readable");
\r
850 if (!is_readable('nucleus/libs/MEMBER.php'))
\r
851 array_push($missingfiles, "File <b>nucleus/libs/MEMBER.php</b> is missing or not readable");
\r
852 if (!is_readable('nucleus/libs/SKIN.php'))
\r
853 array_push($missingfiles, "File <b>nucleus/libs/SKIN.php</b> is missing or not readable");
\r
854 if (!is_readable('nucleus/libs/TEMPLATE.php'))
\r
855 array_push($missingfiles, "File <b>nucleus/libs/TEMPLATE.php</b> is missing or not readable");
\r
856 if (!is_readable('nucleus/libs/MEDIA.php'))
\r
857 array_push($missingfiles, "File <b>nucleus/libs/MEDIA.php</b> is missing or not readable");
\r
858 if (!is_readable('nucleus/libs/ACTIONLOG.php'))
\r
859 array_push($missingfiles, "File <b>nucleus/libs/ACTIONLOG.php</b> is missing or not readable");
\r
860 if (!is_readable('nucleus/media.php'))
\r
861 array_push($missingfiles, "File <b>nucleus/media.php</b> is missing or not readable");
\r
864 if (sizeof($missingfiles) > 0)
\r
865 showErrorMessages($missingfiles);
\r
870 function updateConfig($name, $val) {
\r
871 $name = addslashes($name);
\r
872 $val = trim(addslashes($val));
\r
874 $query = 'UPDATE ' . tableName('nucleus_config')
\r
875 . " SET value='$val'"
\r
876 . " WHERE name='$name'";
\r
878 mysql_query($query) or _doError("Query error while trying to update config: " . mysql_error());
\r
879 return mysql_insert_id();
\r
882 function endsWithSlash($s) {
\r
883 return (strrpos($s,'/') == strlen($s) - 1);
\r
887 * Checks if email address is valid
\r
889 function _isValidMailAddress($address) {
\r
890 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address))
\r
896 // returns true if the given string is a valid shortname
\r
897 // (to check short blog names and nicknames)
\r
898 // logic: starts and ends with a non space, can contain spaces in between
\r
900 function _isValidShortName($name) {
\r
901 if (eregi("^[a-z0-9]+$", $name))
\r
909 // returns true if the given string is a valid display name
\r
910 // (to check nicknames)
\r
911 function _isValidDisplayName($name) {
\r
912 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name))
\r
918 function _doError($msg) {
\r
920 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
921 <html xmlns="http://www.w3.org/1999/xhtml">
\r
923 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
924 <title>Nucleus Install</title>
\r
926 @import url('nucleus/styles/manual.css');
\r
930 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
933 Error message was: "<?php echo $msg?>";
\r
937 <a href="install.php" onclick="history.back();return false;">Go Back</a>
\r
944 function showErrorMessages($errors) {
\r
946 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
947 <html xmlns="http://www.w3.org/1999/xhtml">
\r
949 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
950 <title>Nucleus Install</title>
\r
952 @import url('nucleus/styles/manual.css');
\r
956 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
\r
963 <?php while($msg = array_shift($errors))
\r
964 echo "<li>$msg</li>";
\r
969 <a href="install.php" onclick="history.back();return false;">Go Back</a>
\r
977 /* for the non-php systems that decide to show the contents:
\r