OSDN Git Service

updated 0.37
[nucleus-jp/nucleus-jp-ancient.git] / euc / install.php
1 <?php
2         /**
3           * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4           * Copyright (C) 2002-2004 The Nucleus Group
5           *
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
12           * those tables.
13           *
14           * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.
15           *
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         */
17
18         /*
19                 This part of the install.php code allows for customization of the install process.
20                 When distributing plugins or skins together with a Nucleus installation, the
21                 configuration below will instruct to install them
22
23                 -- Start Of Configurable Part --
24         */
25
26                 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/
27                 // directory.
28                 //
29                 // example:
30                 //     array('NP_TrackBack', 'NP_MemberGoodies')
31                 $aConfPlugsToInstall = array();
32
33
34                 // array with skins to install. skins must be present under the skins/ directory with
35                 // a subdirectory having the same name that contains a skinbackup.xml file
36                 //
37                 // example:
38                 //     array('base','rsd')
39                 $aConfSkinsToImport = array();
40
41         /*
42                 -- End Of Configurable Part --
43         */
44
45         // don't give warnings for uninitialized vars
46         error_reporting(E_ERROR | E_WARNING | E_PARSE);
47
48         // make sure there's no unnecessary escaping:
49         set_magic_quotes_runtime(0);
50
51   // if there are some plugins or skins to import, do not include vars
52   // in globalfunctions.php again... so set a flag
53         if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {
54           global $CONF;
55           $CONF['installscript']=1;
56         }
57   if (phpversion() >= '4.1.0')
58           include_once('nucleus/libs/vars4.1.0.php');
59   else
60           include_once('nucleus/libs/vars4.0.6.php');
61
62         // check if mysql support is installed
63         if (!function_exists('mysql_query'))
64                 _doError('Your PHP version does not have support for MySQL :(');
65
66         if (postVar('action') == 'go')
67                 doInstall();
68         else
69                 showInstallForm();
70         exit;
71
72         function showInstallForm() {
73
74                 // 0. pre check if all necessary files exist
75                 doCheckFiles();
76
77         ?>
78         <!DOCTYPE html
79         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
80         <html xmlns="http://www.w3.org/1999/xhtml">
81         <head>
82                 <meta http-equiv="content-type" content="application/xhtml+xml; charset=EUC-JP" />
83                 <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>
84                 <style type="text/css"><!--
85                         @import url('nucleus/documentation/styles/manual.css');
86                 --></style>
87                 <script type="text/javascript"><!--
88                         // function to make sure the submit button only gets pressed once
89                         var submitcount=0;
90                         function checkSubmit() {
91                                 if (submitcount == 0) {
92                                         submitcount++;
93                                         return true;
94                                 } else {
95                                         return false;
96                                 }
97                         }
98                 --></script>
99         </head>
100         <body>
101
102   <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
103
104         <form method="post" action="install.php">
105
106         <h1>Install Nucleus</h1>
107
108         <p>
109         ¤³¤Î¥¹¥¯¥ê¥×¥È¤ÏNucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë¤ò¼ê½õ¤±¤·¤Þ¤¹¡£MySQL¥Æ¡¼¥Ö¥ë¤Î¥»¥Ã¥È¥¢¥Ã¥×¤È¡¢<i>config.php</i>¤ËÆþÎϤ¹¤ë¤¿¤á¤Î¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡Êconfig.php¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò0666¤Ë¤·¤Æ¤ª¤±¤Ð¡¢¸å¼Ô¤Îºî¶È¤Ï¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤Þ¤¹¡Ë¡£¤³¤ì¤ò¤Ê¤¹°Ù¤Ë¡¢¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
110         </p>
111
112         <p>
113         ¤¹¤Ù¤Æ¤ÎÍó¤ÎÆþÎϤ¬É¬ÍפǤ¹¡£¥ª¥×¥·¥ç¥ó¾ðÊó¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤¬´°Î»¤·¤¿¤é¡¢Nucleus¤Î´ÉÍýÎΰ褫¤éÀßÄê²Äǽ¤Ç¤¹¡£
114         </p>
115
116         <h1>PHP &amp; MySQL Versions</h1>
117
118         <p>
119                 °Ê²¼¤Ï¤¢¤Ê¤¿¤Î¥¦¥§¥Ö¥Û¥¹¥È¤Ë¤ª¤±¤ëPHP¥¤¥ó¥¿¡¼¥×¥ê¥¿¡¼¤ÈMySQL¥µ¡¼¥Ð¡¼¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤¹¡£Nucleus¤Î¥µ¥Ý¡¼¥È¥Õ¥©¡¼¥é¥à¤ËÌäÂê¤òÊó¹ð¤¹¤ë¤È¤­¤Ï¡¢¤³¤Î¾ðÊó¤ò½ñ¤­Åº¤¨¤Æ¤¯¤À¤µ¤¤¡£
120         </p>
121
122         <ul>
123                 <li>PHP: <?php                  echo phpversion();
124                         $minVersion = '4.0.6';
125
126                         if (phpversion() < $minVersion)
127                                 echo ' <span class="warning">Ãí°Õ: Nucleus¤ÎÆ°ºî¤Ë¤Ï¾¯¤Ê¤¯¤È¤â¥Ð¡¼¥¸¥ç¥ó ',$minVersion,' ¤¬É¬ÍפȤµ¤ì¤Þ¤¹</span>';
128                 ?></li>
129                 <li>MySQL: <?php
130                         // note: this piece of code is taken from phpMyAdmin
131
132                         $result = @mysql_query('SELECT VERSION() AS version');
133                         if ($result != FALSE && @mysql_num_rows($result) > 0) {
134                                 $row   = mysql_fetch_array($result);
135                                 $match = explode('.', $row['version']);
136                         } else {
137                                 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
138                                 if ($result != FALSE && @mysql_num_rows($result) > 0){
139                                         $row   = mysql_fetch_row($result);
140                                         $match = explode('.', $row[1]);
141                                 } else {
142                                         $match[0] = '?';
143                                         $match[1] = '?';
144                                         $match[2] = '?';
145                                 }
146                         }
147
148                         if (!isset($match) || !isset($match[0])) {
149                                 $match[0] = 3;
150                         }
151                         if (!isset($match[1])) {
152                                 $match[1] = 21;
153                         }
154                         if (!isset($match[2])) {
155                                 $match[2] = 0;
156                         }
157
158                         if ($match[0] != '?') {
159                                 $match[0] = intval($match[0]);
160                                 $match[1] = intval($match[1]);
161                         }
162
163                         $mysqlVersion = implode($match, '.');
164                         $minVersion = '3.23';
165
166                         echo $mysqlVersion;
167
168                         if ($mysqlVersion < $minVersion)
169                                 echo ' <span class="warning">Ãí°Õ: Nucleus¤ÎÆ°ºî¤Ë¤Ï¾¯¤Ê¤¯¤È¤â¥Ð¡¼¥¸¥ç¥ó ',$minVersion,' ¤¬É¬ÍפȤµ¤ì¤Þ¤¹</span>';
170                 ?></li>
171         </ul>
172
173 <?php
174         // tell people how they can have their config file filled out automatically
175         if (@file_exists('config.php') && @!is_writable('config.php')) {
176 ?>
177         <h1><i>config.php</i>¤Î¼«Æ°¥¢¥Ã¥×¥Ç¡¼¥È</h1>
178
179         <p>
180         ¤â¤·<em>config.php</em>¤ò¼«Æ°Åª¤Ë¹¹¿·¤¹¤ë¤è¤¦¤Ë¤·¤¿¤¤¤Ê¤é¡¢½ñ¤­¹þ¤ß²Äǽ¤Ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£<em>config.php</em>¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò<strong>666</strong>¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ëÀ®¸ù¸å¤Ë¡¢¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò<strong>444</strong>¤ËÌᤵ¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡Ê<a href="nucleus/documentation/tips.html#filepermissions">¥Ñ¡¼¥ß¥Ã¥·¥ç¥óÊѹ¹¤Î´Ê°×¥¬¥¤¥É</a>¡Ë¡£
181         </p>
182
183         <p>
184         ¤â¤·¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤Þ¤Ê¤¤¤È¤¤¤¦ÁªÂò¤ò¤·¤¿¡Ê¤¢¤ë¤¤¤Ï¹Ô¤¨¤Ê¤¤¡Ë¾ì¹ç¡§¤´¿´Çۤʤ¯¡£¥¤¥ó¥¹¥È¡¼¥ë¤Î²áÄø¤Ç<em>config.php</em>¤ÎÃæ¿È¤¬Ä󶡤µ¤ì¤Þ¤¹¡£¤Ç¤¹¤«¤é¡¢¤½¤ì¤ò¤´¼«¿È¤Ç¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£
185         </p>
186
187 <?php } ?>
188
189         <h1>MySQL¤Î¥í¥°¥¤¥ó¥Ç¡¼¥¿</h1>
190
191         <p>
192         MySQL¤Î¥Ç¡¼¥¿¤ò°Ê²¼¤ËÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤½¤ì¤é¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Æ¡¼¥Ö¥ë¤òºîÀ®¤·¾ðÊó¤òÆþÎϤ¹¤ë¤¿¤á¤ËɬÍפʤâ¤Î¤Ç¤¹¡£¸å¤Ç¡¢<i>config.php</i>¤Ë¤âµ­Æþ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡Ê¾åµ­¤Î¼«Æ°¥¢¥Ã¥×¥Ç¡¼¥È¤òÍøÍѤ¹¤ë¾ì¹ç¡¢¤½¤Î¼ê½ç¤Ï¾Êά¤µ¤ì¤Þ¤¹¡Ë¡£
193         </p>
194
195         <p>
196         ¤â¤·¤³¤Î¾ðÊ󤬤狼¤é¤Ê¤±¤ì¤Ð¡¢¥·¥¹¥Æ¥à´ÉÍý¼Ô¤«¥Û¥¹¥Æ¥£¥ó¥°¸µ¤ËÏ¢Íí¤ò¤È¤Ã¤Æ¤¯¤À¤µ¤¤¡£¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢¥Û¥¹¥È̾¤Ï'localhost'¤Ç¤¹¡£¤â¤·Nucleus¤¬¤¢¤Ê¤¿¤Î¥µ¡¼¥Ð¤ÎPHPÀßÄ꤫¤é'default MySQL host'¤ò¸¡ÃΤ·¤¿¤Ê¤é¡¢'¥Û¥¹¥È̾'¤Ë´û¤Ëµ­Æþ¤µ¤ì¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹¡£¤â¤Ã¤È¤â¡¢¤³¤Î¾ðÊó¤¬Àµ³Î¤Ç¤¢¤ë¤È¤¤¤¦ÊݾڤϤ¢¤ê¤Þ¤»¤ó¡£
197         </p>
198
199         <fieldset>
200                 <legend>´ðËܤΥǡ¼¥¿¥Ù¡¼¥¹ÀßÄê</legend>
201                 <table><tr>
202                         <td>¥Û¥¹¥È̾¡§</td>
203                         <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host'))?>" /></td>
204                 </tr><tr>
205                         <td>¥æ¡¼¥¶¡¼Ì¾¡§</td>
206                         <td><input name="mySQL_user" /></td>
207                 </tr><tr>
208                         <td>¥Ñ¥¹¥ï¡¼¥É¡§</td>
209                         <td><input name="mySQL_password" type="password" /></td>
210                 </tr><tr>
211                         <td>¥Ç¡¼¥¿¥Ù¡¼¥¹Ì¾¡§</td>
212                         <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" />¥Ç¡¼¥¿¥Ù¡¼¥¹¤òºîÀ®¤¹¤ëɬÍפ¬¤¢¤ë</label>)</td>
213                 </tr></table>
214         </fieldset>
215
216         <fieldset>
217                 <legend>¹âÅù¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹ÀßÄê</legend>
218                 <table><tr>
219                         <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" />¥Æ¡¼¥Ö¥ë¡¦¥×¥ê¥Õ¥£¥Ã¥¯¥¹¤òÍøÍÑ</label></td>
220                         <td><input name="mySQL_tablePrefix" value="" /></td>
221                 </tr></table>
222                 <p>°ì¤Ä¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÊ£¿ô¤ÎNucleus¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤Æ¤ª¤ê¡¢¼«Ê¬¤¬²¿¤ò¤ä¤Ã¤Æ¤¤¤ë¤Î¤«Íý²ò¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤ò½ü¤¤¤Æ¤Ï¡¢<strong>¤³¤ì¤òÊѹ¹¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó</strong>¡£</p>
223                 <p>Nucleus¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Ï¡¢¤³¤Î¥×¥ê¥Õ¥£¥Ã¥¯¥¹¤¬Æ¬¤Ë¤Ä¤­¤Þ¤¹¡£</p>
224         </fieldset>
225
226         <h1>¥Ç¥£¥ì¥¯¥È¥ê¤ÈURL</h1>
227
228         <p>
229         ¤³¤Î¥¤¥ó¥¹¥È¡¼¥ë¥¹¥¯¥ê¥×¥È¤ÏNucleus¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÈURL¤ò¸«¤Ä¤±¤è¤¦¤È¤·¤Þ¤·¤¿¡£²¼¤ÎÃͤò¥Á¥§¥Ã¥¯¤·¤ÆɬÍפʤéÄûÀµ¤·¤Æ¤¯¤À¤µ¤¤¡£¥Õ¥¡¥¤¥ë¤Ø¤Î¥Ñ¥¹¤ÈURL¤Ï¥¹¥é¥Ã¥·¥å'/'¤Ç½ª¤ï¤é¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£
230         </p>
231
232         <fieldset>
233                 <legend>URLs and directories</legend>
234                 <table><tr>
235                         <td>Site <strong>URL</strong>:</td>
236                         <td>
237                                         <input name="IndexURL" size="60" value="<?php                                   $url = "http://" . serverVar('HTTP_HOST') . serverVar('PHP_SELF');
238                                         $url = str_replace("install.php",'',$url);
239                                         $url = str_replace("\\","/",$url);
240                                         // add slash at end if necessary
241                                         if (!endsWithSlash($url)) $url .= '/';
242                                         echo $url;
243                                 ?>" />
244                         </td>
245                 </tr><tr>
246                         <td>Admin-area <strong>URL</strong>:</td>
247                         <td><input name="AdminURL" size="60" value="<?php                                       if ($url) echo $url . 'nucleus/';
248                                 ?>" />
249                         </td>
250                 </tr><tr>
251                         <td>Admin-area <strong>path</strong>:</td>
252                         <td><input name="AdminPath" size="60" value="<?php                                      $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
253                                         $path = str_replace("\\","/",$path);
254                                         // add slash at end if necessary
255                                         if (!endsWithSlash($path)) $path .= '/';
256                                         if($path) echo  $path . 'nucleus/';
257                                 ?>" />
258                         </td>
259                 </tr><tr>
260                         <td>Media files <strong>URL</strong>:</td>
261                         <td><input name="MediaURL" size="60" value="<?php                                       if ($url) echo $url . 'media/';
262                                 ?>" />
263                         </td>
264                 </tr><tr>
265                         <td>Media directory <strong>path</strong>:</td>
266                         <td><input name="MediaPath" size="60" value="<?php                                      $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
267                                         $path = str_replace("\\","/",$path);
268                                         // add slash at end if necessary
269                                         if (!endsWithSlash($path)) $path .= '/';
270                                         if ($path) echo $path . 'media/';
271                                 ?>" />
272                         </td>
273                 </tr><tr>
274                         <td>Extra skin files <strong>URL</strong>:</td>
275                         <td><input name="SkinsURL" size="60" value="<?php                                       if ($url) echo $url . 'skins/';
276                                 ?>" />
277                                 <br />(¥¤¥ó¥Ý¡¼¥È¤µ¤ì¤¿¥¹¥­¥ó¤¬»ÈÍÑ)
278                         </td>
279                 </tr><tr>
280                         <td>Extra skin files directory <strong>path</strong>:</td>
281                         <td><input name="SkinsPath" size="60" value="<?php                              $path = str_replace("install.php",'',serverVar('SCRIPT_FILENAME'));
282                                 $path = str_replace("\\","/",$path);
283                                 // add slash at end if necessary
284                                 if (!endsWithSlash($path)) $path .= '/';
285                                 if ($path) echo $path . 'skins/';
286                                 ?>" />
287                                 <br />(¥¤¥ó¥Ý¡¼¥È¤µ¤ì¤¿¥¹¥­¥ó¤Î¥Õ¥¡¥¤¥ëÎà¤òÃÖ¤¯¾ì½ê)
288                         </td>
289                 </tr><tr>
290                         <td>Plugin files <strong>URL</strong>:</td>
291                         <td><input name="PluginURL" size="60" value="<?php                                      if ($url) echo $url . 'nucleus/plugins/';
292                                 ?>" />
293                         </td>
294                 </tr><tr>
295                         <td>Action <strong>URL</strong>:</td>
296                         <td><input name="ActionURL" size="60" value="<?php                                      if ($url) echo $url . 'action.php';
297                                 ?>" />
298                                 <br />(<tt>action.php</tt>¤Ø¤Îhttp://¤«¤é»Ï¤Þ¤ëURL)
299                         </td>
300                 </tr></table>
301         </fieldset>
302
303         <p class="note">
304         <strong>ÉÕµ­:</strong> ÁêÂХѥ¹¤Ç¤Ï¤Ê¤¯<strong>ÀäÂХѥ¹¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤</strong>¡£Ä̾ÀäÂХѥ¹¤Ï<tt>/home/username/public_html/</tt>¤Î¤è¤¦¤Ê·Á¤ò¤È¤ê¤Þ¤¹¡£Unix¥·¥¹¥Æ¥à¡Ê¤Û¤È¤ó¤É¤Î¥µ¡¼¥Ð¡¼¤¬¤½¤¦¤Ç¤¹¡Ë¤Ë¤ª¤¤¤Æ¡¢¥Ñ¥¹¤Ï¥¹¥é¥Ã¥·¥å¤«¤é»Ï¤Þ¤ê¤Þ¤¹¡£¤â¤·¤³¤ì¤é¤Î¾ðÊóÆþÎϤËÌäÂ꤬À¸¤¸¤¿¤é¡¢¤¢¤Ê¤¿¤Î¥µ¡¼¥Ð´ÉÍý¼Ô¤Ë¤¿¤º¤Í¤ë¤Ù¤­¤Ç¤¹¡£
305         </p>
306
307         <h1>´ÉÍý¸¢¸Â¤ò¤â¤Ä¥æ¡¼¥¶¡¼</h1>
308
309         <p>°Ê²¼¤Ë¡¢¥µ¥¤¥È¤ÎºÇ½é¤Î¥æ¡¼¥¶¡¼¤òºîÀ®¤¹¤ë¤¿¤á¤Î¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£</p>
310
311         <fieldset>
312                 <legend>´ÉÍý¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¡¼</legend>
313                 <table><tr>
314                         <td>ɽ¼¨¤µ¤ì¤ë̾Á°¡§</td>
315                         <td>
316                                 <input name="User_name" value="" />
317                                 <small>(µö²Ä¤µ¤ì¤ëʸ»ú¡§a-z ¤È 0-9¡¢ºÇ½é¤ÈºÇ¸å°Ê³°¤Î¥¹¥Ú¡¼¥¹)</small>
318                         </td>
319                 </tr><tr>
320                         <td>ËÜ̾¡Ê¥Ï¥ó¥É¥ë̾¡Ë¡§</td>
321                         <td><input name="User_realname" value="" /></td>
322                 </tr><tr>
323                         <td>¥Ñ¥¹¥ï¡¼¥É¡§</td>
324                         <td><input name="User_password" type="password" value="" /></td>
325                 </tr><tr>
326                         <td>¥Ñ¥¹¥ï¡¼¥É¤Î³Îǧ¡§</td>
327                         <td><input name="User_password2" type="password" value="" /></td>
328                 </tr><tr>
329                         <td>¥á¡¼¥ë¥¢¥É¥ì¥¹¡§</td>
330                         <td>
331                                 <input name="User_email" value="" />
332                                 <small>(ÍøÍѲÄǽ¤Ê¥á¡¼¥ë¥¢¥É¥ì¥¹¤òÆþ¤ì¤Æ¤¯¤À¤µ¤¤)</small>
333                         </td>
334                 </tr></table>
335         </fieldset>
336
337         <h1>¥¦¥§¥Ö¥í¥°¤Î¥Ç¡¼¥¿</h1>
338
339         <p>°Ê²¼¤Ë¡¢¥Ç¥Õ¥©¥ë¥È¤Îweblog¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤³¤Îweblog¤Î̾Á°¤Ï¡¢¥µ¥¤¥È̾¤È¤·¤Æ¤âÍøÍѤµ¤ì¤Þ¤¹¡£</p>
340
341         <fieldset>
342                 <legend>¥¦¥§¥Ö¥í¥°¤Î¥Ç¡¼¥¿</legend>
343                 <table><tr>
344                         <td>Blog̾¡§</td>
345                         <td><input name="Blog_name" size="60" value="My Nucleus Weblog" /></td>
346                 </tr><tr>
347                         <td>Blog¤Îû½Ì̾¡§</td>
348                         <td>
349                                 <input name="Blog_shortname" value="myweblog" />
350                                 <small>(µö²Ä¤µ¤ì¤ëʸ»ú¡§a-z ¤È 0-9¡¢¥¹¥Ú¡¼¥¹¤ÏÉÔ²Ä)</small>
351                         </td>
352                 </tr></table>
353         </fieldset>
354
355         <h1>¥Ç¡¼¥¿¤ÎÁ÷¿®</h1>
356
357         <p>
358         ¾å¤Ë½ñ¤¤¤Æ¤­¤¿¥Ç¡¼¥¿¤¬Àµ¤·¤¤¤«³Î¤«¤á¤Æ¤¯¤À¤µ¤¤¡£¤è¤±¤ì¤Ð¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Æ¡¼¥Ö¥ë¤ÈºÇ½é¤Î¥Ç¡¼¥¿¤òÀßÄꤹ¤ë¤¿¤á¤Ë²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£¾¯¤·»þ´Ö¤¬¤«¤«¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¤´¿ÉÊú¤ò¡£<b>¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤Î¤Ï°ì²ó¤À¤±¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£</b>
359         </p>
360
361         <p>
362                 <input name="action" value="go" type="hidden" />
363                 <input type="submit" value="Install Nucleus" onclick="return checkSubmit();" />
364         </p>
365
366         </form>
367
368         </body>
369         </html>
370
371
372         <?php   }
373
374         function tableName($unPrefixed)
375         {
376                 global $mysql_usePrefix, $mysql_prefix;
377                 if ($mysql_usePrefix == 1)
378                         return $mysql_prefix . $unPrefixed;
379                 else
380                         return $unPrefixed;
381         }
382
383         function doInstall() {
384                 global $mysql_usePrefix, $mysql_prefix;
385
386                 // 0. put all POST-vars into vars
387                 $mysql_host             = postVar('mySQL_host');
388                 $mysql_user             = postVar('mySQL_user');
389                 $mysql_password         = postVar('mySQL_password');
390                 $mysql_database         = postVar('mySQL_database');
391                 $mysql_create           = postVar('mySQL_create');
392                 $mysql_usePrefix        = postVar('mySQL_usePrefix');
393                 $mysql_prefix           = postVar('mySQL_tablePrefix');
394                 $config_indexurl        = postVar('IndexURL');
395                 $config_adminurl        = postVar('AdminURL');
396                 $config_adminpath       = postVar('AdminPath');
397                 $config_mediaurl        = postVar('MediaURL');
398                 $config_skinsurl        = postVar('SkinsURL');
399                 $config_pluginurl       = postVar('PluginURL');
400                 $config_actionurl       = postVar('ActionURL');
401                 $config_mediapath       = postVar('MediaPath');
402                 $config_skinspath       = postVar('SkinsPath');
403                 $user_name                      = postVar('User_name');
404                 $user_realname          = postVar('User_realname');
405                 $user_password          = postVar('User_password');
406                 $user_password2         = postVar('User_password2');
407                 $user_email             = postVar('User_email');
408                 $blog_name                      = postVar('Blog_name');
409                 $blog_shortname         = postVar('Blog_shortname');
410                 $config_adminemail      = $user_email;
411                 $config_sitename        = $blog_name;
412
413
414                 $config_indexurl        = str_replace("\\","/",$config_indexurl);
415                 $config_adminurl        = str_replace("\\","/",$config_adminurl);
416                 $config_mediaurl        = str_replace("\\","/",$config_mediaurl);
417                 $config_skinsurl        = str_replace("\\","/",$config_skinsurl);
418                 $config_pluginurl       = str_replace("\\","/",$config_pluginurl);
419                 $config_actionurl       = str_replace("\\","/",$config_actionurl);
420                 $config_adminpath       = str_replace("\\","/",$config_adminpath);
421                 $config_skinspath       = str_replace("\\","/",$config_skinspath);
422
423                 // 1. check all the data
424                 $errors = array();
425
426                 if (!$mysql_database)
427                         array_push($errors,"mySQL database name missing");
428                 if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0))
429                         array_push($errors,"mySQL prefix was selected, but prefix is empty");
430                 if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix)))
431                         array_push($errors,"mySQL prefix should only contain characters from the ranges A-Z, a-z, 0-9 or underscores");
432                 if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl)
433                                                      || !endsWithSlash($config_mediaurl)
434                                                      || !endsWithSlash($config_pluginurl)
435                                                      || !endsWithSlash($config_skinsurl)
436                                                                 // TODO: add action.php check
437                     )
438                         array_push($errors,"One of the URLs does not end with a slash, or action url does not end with 'action.php'");
439                 if (!endsWithSlash($config_adminpath))
440                         array_push($errors,"The path of the administration area does not end with a slash");
441                 if (!endsWithSlash($config_mediapath))
442                         array_push($errors,"The media path does not end with a slash");
443                 if (!endsWithSlash($config_skinspath))
444                         array_push($errors,"The skins path does not end with a slash");
445                 if (!is_dir($config_adminpath))
446                         array_push($errors,"The path of the administration area does not exist on your server");
447                 if (!_isValidMailAddress($user_email))
448                         array_push($errors,"Invalid e-mail address given for user");
449                 if (!_isValidDisplayName($user_name))
450                         array_push($errors,"User name is not a valid display name (allowed chars: a-zA-Z0-9 and spaces)");
451                 if (!$user_password || !$user_password2)
452                         array_push($errors, "User password is empty");
453                 if ($user_password != $user_password2)
454                         array_push($errors, "User password do not match");
455                 if (!_isValidShortName($blog_shortname))
456                         array_push($errors, "Invalid short name given for blog (allowed chars: a-z0-9, no spaces)");
457                 if (sizeof($errors) > 0)
458                         showErrorMessages($errors);
459
460                 // 2. try to log in to mySQL
461                 $connection = @mysql_connect($mysql_host, $mysql_user, $mysql_password);
462                 if ($connection == false)
463                         _doError("Could not connect to mySQL server: " . mysql_error());
464
465                 // 3. try to create database (if needed)
466                 if ($mysql_create == 1) {
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());
468                 }
469
470                 // 4. try to select database
471                 mysql_select_db($mysql_database) or _doError("Could not select database. Make sure it exists");
472
473                 // 5. execute queries
474                 $filename = "install.sql";
475                 $fd = fopen ($filename, "r");
476                 $queries = fread ($fd, filesize ($filename));
477                 fclose ($fd);
478
479                 $queries = split("(;\n|;\r)",$queries);
480
481                 $aTableNames = array(
482                         'nucleus_actionlog',
483                         'nucleus_ban',
484                         'nucleus_blog',
485                         'nucleus_category',
486                         'nucleus_comment',
487                         'nucleus_config',
488                         'nucleus_item',
489                         'nucleus_karma',
490                         'nucleus_member',
491                         'nucleus_plugin',
492                         'nucleus_skin',
493                         'nucleus_template',
494                         'nucleus_team',
495                         'nucleus_activation',
496                         'nucleus_tickets'
497 // these are unneeded (one of the replacements above takes care of them)
498 //                      'nucleus_plugin_event',
499 //                      'nucleus_plugin_option',
500 //                      'nucleus_plugin_option_desc',
501 //                      'nucleus_skin_desc',
502 //                      'nucleus_template_desc',
503                 );
504                 $aTableNamesPrefixed = array(
505                         $mysql_prefix . 'nucleus_actionlog',
506                         $mysql_prefix . 'nucleus_ban',
507                         $mysql_prefix . 'nucleus_blog',
508                         $mysql_prefix . 'nucleus_category',
509                         $mysql_prefix . 'nucleus_comment',
510                         $mysql_prefix . 'nucleus_config',
511                         $mysql_prefix . 'nucleus_item',
512                         $mysql_prefix . 'nucleus_karma',
513                         $mysql_prefix . 'nucleus_member',
514                         $mysql_prefix . 'nucleus_plugin',
515                         $mysql_prefix . 'nucleus_skin',
516                         $mysql_prefix . 'nucleus_template',
517                         $mysql_prefix . 'nucleus_team',
518                         $mysql_prefix . 'nucleus_activation',
519                         $mysql_prefix . 'nucleus_tickets'
520 // these are unneeded (one of the replacements above takes care of them)
521 //                      $mysql_prefix . 'nucleus_plugin_event',
522 //                      $mysql_prefix . 'nucleus_plugin_option',
523 //                      $mysql_prefix . 'nucleus_plugin_option_desc',
524 //                      $mysql_prefix . 'nucleus_skin_desc',
525 //                      $mysql_prefix . 'nucleus_template_desc',
526                 );
527
528                 for ($idx = 0;$idx<sizeof($queries);$idx++) {
529                         $query = trim($queries[$idx]);
530                         // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";
531                         if ($query) {
532                                 if ($mysql_usePrefix == 1)
533                                         $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);
534                                 mysql_query($query) or _doError("Error while executing query (<small>" . htmlspecialchars($query) . "</small>): " . mysql_error());
535                         }
536
537                 }
538
539                 // 6. update global settings
540                 updateConfig('IndexURL',        $config_indexurl);
541                 updateConfig('AdminURL',        $config_adminurl);
542                 updateConfig('MediaURL',        $config_mediaurl);
543                 updateConfig('SkinsURL',        $config_skinsurl);
544                 updateConfig('PluginURL',       $config_pluginurl);
545                 updateConfig('ActionURL',       $config_actionurl);
546                 updateConfig('AdminEmail',      $config_adminemail);
547                 updateConfig('SiteName',        $config_sitename);
548
549
550                 // 7. update GOD member
551                 $query =  'UPDATE ' . tableName('nucleus_member')
552                        . " SET mname='" . addslashes($user_name) . "',"
553                        . "     mrealname='". addslashes($user_realname) . "',"
554                        . "     mpassword='". md5(addslashes($user_password)) . "',"
555                        . "     murl='" . addslashes($config_indexurl) . "',"
556                        . "     memail='" . addslashes($user_email) . "',"
557                        . "     madmin=1,"
558                        . "     mcanlogin=1"
559                        . " WHERE mnumber=1";
560                 mysql_query($query) or _doError("Error while setting member settings: " . mysql_error());
561
562                 // 8. update weblog settings
563                 $query =  'UPDATE ' . tableName('nucleus_blog')
564                        . " SET bname='" . addslashes($blog_name) . "',"
565                        . "     bshortname='". addslashes($blog_shortname) . "',"
566                        . "     burl='" . addslashes($config_indexurl) . "'"
567                        . " WHERE bnumber=1";
568                 mysql_query($query) or _doError("Error while setting weblog settings: " . mysql_error());
569
570                 // 9. update item date
571                 $query =  'UPDATE ' . tableName('nucleus_item')
572                         . " SET itime='". date("Y-m-d H:i:s",time()) ."'"
573                         . " WHERE inumber=1";
574                 mysql_query($query) or _doError("Error with query: " . mysql_error());
575
576                 global $aConfPlugsToInstall, $aConfSkinsToImport;
577                 $aSkinErrors = array();
578                 $aPlugErrors = array();
579                 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0)) {
580                         // 10. set global variables
581                         global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;
582                         $MYSQL_HOST = $mysql_host;
583                         $MYSQL_USER = $mysql_user;
584                         $MYSQL_PASSWORD = $mysql_password;
585                         $MYSQL_DATABASE = $mysql_database;
586                         $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';
587                         global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;
588                         $DIR_NUCLEUS = $config_adminpath;
589                         $DIR_MEDIA = $config_mediapath;
590                         $DIR_SKINS = $config_skinspath;
591                         $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
592                         $DIR_LANG = $DIR_NUCLEUS . 'language/';
593                         $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
594
595                         // close database connection (needs to be closed if we want to include globalfunctions.php)
596                         mysql_close();
597
598                         $manager = '';
599                         include_once($DIR_LIBS . 'globalfunctions.php');
600
601                         // 11. install custom skins
602                         $aSkinErrors = installCustomSkins($manager);
603
604                         // 12. install custom plugins
605                         $aPlugErrors = installCustomPlugs($manager);
606
607                 }
608
609
610                 // 12. Write config file ourselves (if possible)
611                 $bConfigWritten = 0;
612                 if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w')) {
613                         $config_data = "<" . "?php \n";
614                         $config_data .= "\n";
615                         $config_data .= "       // mySQL connection information\n";
616                         $config_data .= "       \$MYSQL_HOST = '" . $mysql_host . "';\n";
617                         $config_data .= "       \$MYSQL_USER = '" . $mysql_user . "';\n";
618                         $config_data .= "       \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";
619                         $config_data .= "       \$MYSQL_DATABASE = '" . $mysql_database . "';\n";
620                         $config_data .= "       \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";
621                         $config_data .= "\n";
622                         $config_data .= "       // main nucleus directory\n";
623                         $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";
624                         $config_data .= "\n";
625                         $config_data .= "       // path to media dir\n";
626                         $config_data .= "       \$DIR_MEDIA = '" . $config_mediapath . "';\n";
627                         $config_data .= "\n";
628                         $config_data .= "       // extra skin files for imported skins\n";
629                         $config_data .= "       \$DIR_SKINS = '" . $config_skinspath . "';\n";
630                         $config_data .= "\n";
631                         $config_data .= "       // these dirs are normally sub dirs of the nucleus dir, but \n";
632                         $config_data .= "       // you can redefine them if you wish\n";
633                         $config_data .= "       \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";
634                         $config_data .= "       \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";
635                         $config_data .= "       \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";
636                         $config_data .= "\n";
637                         $config_data .= "       // include libs\n";
638                         $config_data .= "       include(\$DIR_LIBS.'globalfunctions.php');\n";
639                         $config_data .= "       if (!extension_loaded('mbstring')) {\n";
640                         $config_data .= "       include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";
641                         $config_data .= "       }\n";
642                         $config_data .= "?" . ">";
643
644                         $result = @fputs($fp, $config_data, strlen($config_data));
645                         fclose($fp);
646
647                         if ($result)
648                                 $bConfigWritten = 1;
649                 }
650
651                 ?>
652 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
653                 <html xmlns="http://www.w3.org/1999/xhtml">
654                 <head>
655                         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
656                         <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>
657                         <style>
658                                 @import url('nucleus/styles/manual.css');
659                         </style>
660                 </head>
661                 <body>
662                 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
663 <?php
664         $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);
665         if (count($aAllErrors) > 0) {
666                 echo '<h1>Skin/Plugin Install errors</h1>';
667                 echo '<ul><li>'.implode('</li><li>', $aAllErrors).'</li></ul>';
668         }
669
670         if (!$bConfigWritten) { ?>
671                         <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï¤Û¤Ü´°Î»¤·¤Þ¤·¤¿¡ª</h1>
672                         <p>
673                         ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Î½é´üÃÍÆþÎϤ¬À®¸ù¤·¤Þ¤·¤¿¡£¸å¤Ï<i>config.php</i>¤ò½ñ¤­´¹¤¨¤ë¤À¤±¤Ç¤¹¡£°Ê²¼¤Ë½ñ¤­´¹¤¨¤ë¤Ù¤­ÆâÍƤòɽ¼¨¤·¤Þ¤¹¡Êmysql¤Î¥Ñ¥¹¥ï¡¼¥É¤Ï¥Þ¥¹¥¯¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤³¤Ï¼ÂºÝ¤Î¤â¤Î¤Ë½ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡Ë
674                         </p>
675
676                         <pre>
677 &lt;?php
678         // mySQL connection information
679         $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';
680         $MYSQL_USER = '<b><?php echo $mysql_user?></b>';
681         $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';
682         $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';
683         $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';
684
685         // main nucleus directory
686         $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';
687
688         // path to media dir
689         $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';
690
691         // extra skin files for imported skins
692         $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';
693
694         // these dirs are normally sub dirs of the nucleus dir, but
695         // you can redefine them if you wish
696         $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';
697         $DIR_LANG = $DIR_NUCLEUS . 'language/';
698         $DIR_LIBS = $DIR_NUCLEUS . 'libs/';
699
700         // include libs
701         include($DIR_LIBS.'globalfunctions.php');
702         if (!extension_loaded('mbstring')) {
703         include($DIR_LIBS.'mb_emulator/mb-emulator.php');
704         }
705
706 ?&gt;
707                         </pre>
708
709                         <p>¤¢¤Ê¤¿¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤Î¥Õ¥¡¥¤¥ë¤ò½ñ¤­´¹¤¨¤¿¤é¡¢FTP¤ò»È¤Ã¤Æ¥¦¥§¥Ö¥µ¡¼¥Ð¤Ë¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£ASCII¥â¡¼¥É¤ÇÁ÷¿®¤·¤Æ¥Õ¥¡¥¤¥ë¤ò¾å½ñ¤­¤·¤Þ¤¹¡£
710                         </p>
711
712                         <div class="note">
713                         <b>ÉÕµ­:</b> <i>config.php</i>¤ÎºÇ½é¤ä½ª¤ï¤ê¤Ë¥¹¥Ú¡¼¥¹¤ò¶õ¤±¤Ê¤¤¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£¼Â¹Ô»þ¤Ë¥¨¥é¡¼¤ò°ú¤­µ¯¤³¤¹¸¶°ø¤È¤Ê¤ê¤Þ¤¹¡£
714                         <br />
715                         ¤·¤¿¤¬¤Ã¤Æ¡¢config.php¤ÎºÇ½é¤Îʸ»ú¤Ï "&lt;"¤ÇºÇ¸å¤Îʸ»ú¤Ï"&gt;"¤È¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
716                         </div>
717
718 <?php } else { ?>
719                         <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï´°Î»¤·¤Þ¤·¤¿¡ª</h1>
720
721                         <p>Nucleus¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¡¢<code>config.php</code>¤Ï¥¢¥Ã¥×¥Ç¡¼¥È¤µ¤ì¤Þ¤·¤¿¡£</p>
722
723                         <p>¥»¥­¥å¥ê¥Æ¥£¤Î¤¿¤á<code>config.php</code>¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò444¤ËÌ᤹¤³¤È¤ò˺¤ì¤Ê¤¤¤Ç¤¯¤À¤µ¤¤(<a href="nucleus/documentation/tips.html#filepermissions">¥Ñ¡¼¥ß¥Ã¥·¥ç¥óÊѹ¹¤Î´Ê°×¥¬¥¤¥É</a>)¡£</p>
724 <?php } ?>
725                         <h1>¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤Îºï½ü</h1>
726
727                         <p>¥¦¥§¥Ö¥µ¡¼¥Ð¤«¤é¼¡¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡§</p>
728
729                         <ul>
730                                 <li><b>install.sql</b>¡§¥Æ¡¼¥Ö¥ë¤Î¹½Â¤¤òÆâÊñ¤¹¤ë¥Õ¥¡¥¤¥ë</li>
731                                 <li><b>install.php</b>¡§¤³¤Î¥Õ¥¡¥¤¥ë</li>
732                         </ul>
733
734                         <p>¤â¤·¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢´ÉÍýÎΰè¤ò³«¤¯¤³¤È¤¬½ÐÍè¤Þ¤»¤ó¡£</p>
735
736                         <h1>¥¦¥§¥Ö¥µ¥¤¥È¤Î³Îǧ</h1>
737                         <p>
738                         ¥¦¥§¥Ö¥µ¥¤¥È¤ò»È¤¦½àÈ÷¤¬À°¤¤¤Þ¤·¤¿¡£
739                         <ul>
740                                 <li><a href="<?php echo $config_adminurl?>">´ÉÍýÎΰè¤Ë¥í¥°¥¤¥ó¤·¤Æ¥µ¥¤¥È¤ÎÀßÄê¤ò¹Ô¤¦</a></li>
741                                 <li><a href="<?php echo $config_indexurl?>">¤¹¤°¤Ë¥µ¥¤¥È¤Ø¹Ô¤Ã¤Æ¤ß¤ë</a></li>
742                         </ul>
743                         </p>
744
745                 </body>
746                 </html>
747                 <?php
748         }
749
750
751         function installCustomPlugs(&$manager) {
752                 global $aConfPlugsToInstall, $DIR_LIBS;
753
754                 $aErrors = array();
755
756                 if (count($aConfPlugsToInstall) == 0)
757                         return $aErrors;
758
759                 $numCurrent = mysql_num_rows(sql_query('SELECT * FROM '.sql_table('plugin')));
760
761                 foreach ($aConfPlugsToInstall as $plugName) {
762                         // do this before calling getPlugin (in case the plugin id is used there)
763                         $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.(++$numCurrent).',"'.addslashes($plugName).'")';
764                         sql_query($query);
765
766                         // get and install the plugin
767                         $plugin =& $manager->getPlugin($plugName);
768                         if (!$plugin) {
769                                 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\''. addslashes($plugName).'\'');
770                                 $numCurrent--;
771                                 array_push($aErrors, 'Unable to install plugin ' . $plugName);
772                                 continue;
773                         }
774                         $plugin->install();
775                 }
776
777                 // SYNC PLUGIN EVENT LIST
778                 sql_query('DELETE FROM '.sql_table('plugin_event'));
779                 // loop over all installed plugins
780                 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
781                 while($o = mysql_fetch_object($res)) {
782                         $pid = $o->pid;
783                         $plug =& $manager->getPlugin($o->pfile);
784                         if ($plug)
785                         {
786                                 $eventList = $plug->getEventList();
787                                 foreach ($eventList as $eventName) 
788                                         sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.$eventName.'\')');
789                         }
790                 }
791
792                 return $aErrors;
793         }
794
795         function installCustomSkins(&$manager) {
796                 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;
797
798                 $aErrors = array();
799
800                 if (count($aConfSkinsToImport) == 0)
801                         return $aErrors;
802
803                 // load skinie class
804                 include_once($DIR_LIBS . 'skinie.php');
805
806                 $importer = new SKINIMPORT();
807
808                 foreach ($aConfSkinsToImport as $skinName) {
809                         $importer->reset();
810
811                         $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';
812                         if (!@file_exists($skinFile)) {
813                                 array_push($aErrors, 'Unable to import ' . $skinFile . ' : file does not exist');
814                                 continue;
815                         }
816                         $error = $importer->readFile($skinFile);
817                         if ($error) {
818                                 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
819                                 continue;
820                         }
821                         $error = $importer->writeToDatabase(1);
822                         if ($error) {
823                                 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);
824                                 continue;
825                         }
826                 }
827
828                 return $aErrors;
829         }
830
831         // give an error if one or more nucleus are not accessible
832         function doCheckFiles() {
833                 $missingfiles = array();
834
835                 if (!is_readable('install.sql'))
836                         array_push($missingfiles, "File <b>install.sql</b> is missing or not readable");
837                 if (!is_readable('index.php'))
838                         array_push($missingfiles, "File <b>index.php</b> is missing or not readable");
839                 if (!is_readable('action.php'))
840                         array_push($missingfiles, "File <b>action.php</b> is missing or not readable");
841                 if (!is_readable('nucleus/index.php'))
842                         array_push($missingfiles, "File <b>nucleus/index.php</b> is missing or not readable");
843                 if (!is_readable('nucleus/libs/globalfunctions.php'))
844                         array_push($missingfiles, "File <b>nucleus/libs/globalfunctions.php</b> is missing or not readable");
845                 if (!is_readable('nucleus/libs/ADMIN.php'))
846                         array_push($missingfiles, "File <b>nucleus/libs/ADMIN.php</b> is missing or not readable");
847                 if (!is_readable('nucleus/libs/BLOG.php'))
848                         array_push($missingfiles, "File <b>nucleus/libs/BLOG.php</b> is missing or not readable");
849                 if (!is_readable('nucleus/libs/COMMENT.php'))
850                         array_push($missingfiles, "File <b>nucleus/libs/COMMENT.php</b> is missing or not readable");
851                 if (!is_readable('nucleus/libs/COMMENTS.php'))
852                         array_push($missingfiles, "File <b>nucleus/libs/COMMENTS.php</b> is missing or not readable");
853                 if (!is_readable('nucleus/libs/ITEM.php'))
854                         array_push($missingfiles, "File <b>nucleus/libs/ITEM.php</b> is missing or not readable");
855                 if (!is_readable('nucleus/libs/MEMBER.php'))
856                         array_push($missingfiles, "File <b>nucleus/libs/MEMBER.php</b> is missing or not readable");
857                 if (!is_readable('nucleus/libs/SKIN.php'))
858                         array_push($missingfiles, "File <b>nucleus/libs/SKIN.php</b> is missing or not readable");
859                 if (!is_readable('nucleus/libs/TEMPLATE.php'))
860                         array_push($missingfiles, "File <b>nucleus/libs/TEMPLATE.php</b> is missing or not readable");
861                 if (!is_readable('nucleus/libs/MEDIA.php'))
862                         array_push($missingfiles, "File <b>nucleus/libs/MEDIA.php</b> is missing or not readable");
863                 if (!is_readable('nucleus/libs/ACTIONLOG.php'))
864                         array_push($missingfiles, "File <b>nucleus/libs/ACTIONLOG.php</b> is missing or not readable");
865                 if (!is_readable('nucleus/media.php'))
866                         array_push($missingfiles, "File <b>nucleus/media.php</b> is missing or not readable");
867
868
869                 if (sizeof($missingfiles) > 0)
870                         showErrorMessages($missingfiles);
871
872
873         }
874
875         function updateConfig($name, $val) {
876                 $name = addslashes($name);
877                 $val = trim(addslashes($val));
878
879                 $query = 'UPDATE ' . tableName('nucleus_config')
880                        . " SET value='$val'"
881                        . " WHERE name='$name'";
882
883                 mysql_query($query) or _doError("Query error while trying to update config: " . mysql_error());
884                 return mysql_insert_id();
885         }
886
887         function endsWithSlash($s) {
888                 return (strrpos($s,'/') == strlen($s) - 1);
889         }
890
891         /**
892           * Checks if email address is valid
893           */
894         function _isValidMailAddress($address) {
895                 if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address))
896                         return 1;
897                 else
898                         return 0;
899         }
900
901         // returns true if the given string is a valid shortname
902         // (to check short blog names and nicknames)
903         // logic: starts and ends with a non space, can contain spaces in between
904         //        min 2 chars
905         function _isValidShortName($name) {
906                 if (eregi("^[a-z0-9]+$", $name))
907                         return 1;
908                 else
909                         return 0;
910         }
911
912
913
914         // returns true if the given string is a valid display name
915         // (to check nicknames)
916         function _isValidDisplayName($name) {
917                 if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name))
918                         return 1;
919                 else
920                         return 0;
921         }
922
923         function _doError($msg) {
924                 ?>
925 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
926                 <html xmlns="http://www.w3.org/1999/xhtml">
927                 <head>
928                         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
929                         <title>Nucleus Install</title>
930                         <style>
931                                 @import url('nucleus/styles/manual.css');
932                         </style>
933                 </head>
934                 <body>
935                   <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
936                         <h1>Error!</h1>
937                         <p>
938                         Error message was: "<?php echo $msg?>";
939                         </p>
940
941                         <p>
942                         <a href="install.php" onclick="history.back();return false;">Go Back</a>
943                         </p>
944                 </body>
945                 </html>
946                 <?php           exit;
947         }
948
949         function showErrorMessages($errors) {
950                 ?>
951 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
952                 <html xmlns="http://www.w3.org/1999/xhtml">
953                 <head>
954                         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />
955                         <title>Nucleus Install</title>
956                         <style>
957                                 @import url('nucleus/styles/manual.css');
958                         </style>
959                 </head>
960                 <body>
961                   <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->
962                         <h1>Errors!</h1>
963                         <p>
964                         Errors were found:
965                         </p>
966
967                         <ul>
968                         <?php   while($msg = array_shift($errors))
969                                         echo "<li>$msg</li>";
970                         ?>
971                         </ul>
972
973                         <p>
974                         <a href="install.php" onclick="history.back();return false;">Go Back</a>
975                         </p>
976                 </body>
977                 </html>
978                 <?php           exit;
979         }
980
981
982         /* for the non-php systems that decide to show the contents:
983            ?></div><?php        */
984
985 ?>