OSDN Git Service

merged 3.2 code
[nucleus-jp/nucleus-jp-ancient.git] / euc / install.php
1 <?php\r
2         /**\r
3           * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
4           * Copyright (C) 2002-2005 The Nucleus Group\r
5           *\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
12           * those tables.\r
13           *\r
14           * Below is a friendly way of letting users on non-php systems know that Nucleus won't run there.\r
15           *\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
17 \r
18         /*\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
22 \r
23                 -- Start Of Configurable Part --\r
24         */\r
25 \r
26                 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/\r
27                 // directory.\r
28                 //\r
29                 // example:\r
30                 //     array('NP_TrackBack', 'NP_MemberGoodies')\r
31                 $aConfPlugsToInstall = array('NP_SkinFiles');\r
32 \r
33 \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
36                 //\r
37                 // example:\r
38                 //     array('base','rsd')\r
39                 $aConfSkinsToImport = array('default');\r
40 \r
41         /*\r
42                 -- End Of Configurable Part --\r
43         */\r
44 \r
45         // don't give warnings for uninitialized vars\r
46         error_reporting(E_ERROR | E_WARNING | E_PARSE);\r
47 \r
48         // make sure there's no unnecessary escaping:\r
49         set_magic_quotes_runtime(0);\r
50 \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
54           global $CONF;\r
55           $CONF['installscript']=1;\r
56         }\r
57   if (phpversion() >= '4.1.0')\r
58           include_once('nucleus/libs/vars4.1.0.php');\r
59   else\r
60           include_once('nucleus/libs/vars4.0.6.php');\r
61 \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
65 \r
66         if (postVar('action') == 'go')\r
67                 doInstall();\r
68         else\r
69                 showInstallForm();\r
70         exit;\r
71 \r
72         function showInstallForm() {\r
73 \r
74                 // 0. pre check if all necessary files exist\r
75                 doCheckFiles();\r
76 \r
77         ?>\r
78         <!DOCTYPE html\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
81         <head>\r
82                 <meta http-equiv="content-type" content="application/xhtml+xml; charset=EUC-JP" />\r
83                 <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>\r
84                 <style type="text/css"><!--\r
85                         @import url('nucleus/documentation/styles/manual.css');\r
86                 --></style>\r
87                 <script type="text/javascript"><!--\r
88                         // function to make sure the submit button only gets pressed once\r
89                         var submitcount=0;\r
90                         function checkSubmit() {\r
91                                 if (submitcount == 0) {\r
92                                         submitcount++;\r
93                                         return true;\r
94                                 } else {\r
95                                         return false;\r
96                                 }\r
97                         }\r
98                 --></script>\r
99         </head>\r
100         <body>\r
101 \r
102   <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
103 \r
104         <form method="post" action="install.php">\r
105 \r
106         <h1>Install Nucleus</h1>\r
107 \r
108         <p>\r
109         ¤³¤Î¥¹¥¯¥ê¥×¥È¤ÏNucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë¤ò¼ê½õ¤±¤·¤Þ¤¹¡£MySQL¥Æ¡¼¥Ö¥ë¤Î¥»¥Ã¥È¥¢¥Ã¥×¤È¡¢<i>config.php</i>¤ËÆþÎϤ¹¤ë¤¿¤á¤Î¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡Êconfig.php¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò0666¤Ë¤·¤Æ¤ª¤±¤Ð¡¢¸å¼Ô¤Îºî¶È¤Ï¼«Æ°Åª¤Ë¹Ô¤ï¤ì¤Þ¤¹¡Ë¡£¤³¤ì¤ò¤Ê¤¹°Ù¤Ë¡¢¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£\r
110         </p>\r
111 \r
112         <p>\r
113         ¤¹¤Ù¤Æ¤ÎÍó¤ÎÆþÎϤ¬É¬ÍפǤ¹¡£¥ª¥×¥·¥ç¥ó¾ðÊó¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤¬´°Î»¤·¤¿¤é¡¢Nucleus¤Î´ÉÍýÎΰ褫¤éÀßÄê²Äǽ¤Ç¤¹¡£\r
114         </p>\r
115 \r
116         <h1>PHP &amp; MySQL Versions</h1>\r
117 \r
118         <p>\r
119                 °Ê²¼¤Ï¤¢¤Ê¤¿¤Î¥¦¥§¥Ö¥Û¥¹¥È¤Ë¤ª¤±¤ëPHP¥¤¥ó¥¿¡¼¥×¥ê¥¿¡¼¤ÈMySQL¥µ¡¼¥Ð¡¼¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤¹¡£Nucleus¤Î¥µ¥Ý¡¼¥È¥Õ¥©¡¼¥é¥à¤ËÌäÂê¤òÊó¹ð¤¹¤ë¤È¤­¤Ï¡¢¤³¤Î¾ðÊó¤ò½ñ¤­Åº¤¨¤Æ¤¯¤À¤µ¤¤¡£\r
120         </p>\r
121 \r
122         <ul>\r
123                 <li>PHP: <?php                  echo phpversion();\r
124                         $minVersion = '4.0.6';\r
125 \r
126                         if (phpversion() < $minVersion)\r
127                                 echo ' <span class="warning">Ãí°Õ: Nucleus¤ÎÆ°ºî¤Ë¤Ï¾¯¤Ê¤¯¤È¤â¥Ð¡¼¥¸¥ç¥ó ',$minVersion,' ¤¬É¬ÍפȤµ¤ì¤Þ¤¹</span>';\r
128                 ?></li>\r
129                 <li>MySQL: <?php\r
130                         // note: this piece of code is taken from phpMyAdmin\r
131 \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
136                         } else {\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
141                                 } else {\r
142                                         $match[0] = '?';\r
143                                         $match[1] = '?';\r
144                                         $match[2] = '?';\r
145                                 }\r
146                         }\r
147 \r
148                         if (!isset($match) || !isset($match[0])) {\r
149                                 $match[0] = 3;\r
150                         }\r
151                         if (!isset($match[1])) {\r
152                                 $match[1] = 21;\r
153                         }\r
154                         if (!isset($match[2])) {\r
155                                 $match[2] = 0;\r
156                         }\r
157 \r
158                         if ($match[0] != '?') {\r
159                                 $match[0] = intval($match[0]);\r
160                                 $match[1] = intval($match[1]);\r
161                         }\r
162 \r
163                         $mysqlVersion = implode($match, '.');\r
164                         $minVersion = '3.23';\r
165 \r
166                         echo $mysqlVersion;\r
167 \r
168                         if ($mysqlVersion < $minVersion)\r
169                                 echo ' <span class="warning">Ãí°Õ: Nucleus¤ÎÆ°ºî¤Ë¤Ï¾¯¤Ê¤¯¤È¤â¥Ð¡¼¥¸¥ç¥ó ',$minVersion,' ¤¬É¬ÍפȤµ¤ì¤Þ¤¹</span>';\r
170                 ?></li>\r
171         </ul>\r
172 \r
173 <?php\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
176 ?>\r
177         <h1><i>config.php</i>¤Î¼«Æ°¥¢¥Ã¥×¥Ç¡¼¥È</h1>\r
178 \r
179         <p>\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
181         </p>\r
182 \r
183         <p>\r
184         ¤â¤·¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤Þ¤Ê¤¤¤È¤¤¤¦ÁªÂò¤ò¤·¤¿¡Ê¤¢¤ë¤¤¤Ï¹Ô¤¨¤Ê¤¤¡Ë¾ì¹ç¡§¤´¿´Çۤʤ¯¡£¥¤¥ó¥¹¥È¡¼¥ë¤Î²áÄø¤Ç<em>config.php</em>¤ÎÃæ¿È¤¬Ä󶡤µ¤ì¤Þ¤¹¡£¤Ç¤¹¤«¤é¡¢¤½¤ì¤ò¤´¼«¿È¤Ç¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£\r
185         </p>\r
186 \r
187 <?php } ?>\r
188 \r
189         <h1>MySQL¤Î¥í¥°¥¤¥ó¥Ç¡¼¥¿</h1>\r
190 \r
191         <p>\r
192         MySQL¤Î¥Ç¡¼¥¿¤ò°Ê²¼¤ËÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤½¤ì¤é¤Ï¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Æ¡¼¥Ö¥ë¤òºîÀ®¤·¾ðÊó¤òÆþÎϤ¹¤ë¤¿¤á¤ËɬÍפʤâ¤Î¤Ç¤¹¡£¸å¤Ç¡¢<i>config.php</i>¤Ë¤âµ­Æþ¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡Ê¾åµ­¤Î¼«Æ°¥¢¥Ã¥×¥Ç¡¼¥È¤òÍøÍѤ¹¤ë¾ì¹ç¡¢¤½¤Î¼ê½ç¤Ï¾Êά¤µ¤ì¤Þ¤¹¡Ë¡£\r
193         </p>\r
194 \r
195         <p>\r
196         ¤â¤·¤³¤Î¾ðÊ󤬤狼¤é¤Ê¤±¤ì¤Ð¡¢¥·¥¹¥Æ¥à´ÉÍý¼Ô¤«¥Û¥¹¥Æ¥£¥ó¥°¸µ¤ËÏ¢Íí¤ò¤È¤Ã¤Æ¤¯¤À¤µ¤¤¡£¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢¥Û¥¹¥È̾¤Ï'localhost'¤Ç¤¹¡£¤â¤·Nucleus¤¬¤¢¤Ê¤¿¤Î¥µ¡¼¥Ð¤ÎPHPÀßÄ꤫¤é'default MySQL host'¤ò¸¡ÃΤ·¤¿¤Ê¤é¡¢'¥Û¥¹¥È̾'¤Ë´û¤Ëµ­Æþ¤µ¤ì¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹¡£¤â¤Ã¤È¤â¡¢¤³¤Î¾ðÊó¤¬Àµ³Î¤Ç¤¢¤ë¤È¤¤¤¦ÊݾڤϤ¢¤ê¤Þ¤»¤ó¡£\r
197         </p>\r
198 \r
199         <fieldset>\r
200                 <legend>´ðËܤΥǡ¼¥¿¥Ù¡¼¥¹ÀßÄê</legend>\r
201                 <table><tr>\r
202                         <td>¥Û¥¹¥È̾¡§</td>\r
203                         <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host'))?>" /></td>\r
204                 </tr><tr>\r
205                         <td>¥æ¡¼¥¶¡¼Ì¾¡§</td>\r
206                         <td><input name="mySQL_user" /></td>\r
207                 </tr><tr>\r
208                         <td>¥Ñ¥¹¥ï¡¼¥É¡§</td>\r
209                         <td><input name="mySQL_password" type="password" /></td>\r
210                 </tr><tr>\r
211                         <td>¥Ç¡¼¥¿¥Ù¡¼¥¹Ì¾¡§</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
213                 </tr></table>\r
214         </fieldset>\r
215 \r
216         <fieldset>\r
217                 <legend>¹âÅù¤Ê¥Ç¡¼¥¿¥Ù¡¼¥¹ÀßÄê</legend>\r
218                 <table><tr>\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
221                 </tr></table>\r
222                 <p>°ì¤Ä¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÊ£¿ô¤ÎNucleus¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤Æ¤ª¤ê¡¢¼«Ê¬¤¬²¿¤ò¤ä¤Ã¤Æ¤¤¤ë¤Î¤«Íý²ò¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¤ò½ü¤¤¤Æ¤Ï¡¢<strong>¤³¤ì¤òÊѹ¹¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó</strong>¡£</p>\r
223                 <p>Nucleus¤Ë¤è¤Ã¤ÆÀ¸À®¤µ¤ì¤¿¤¹¤Ù¤Æ¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Ï¡¢¤³¤Î¥×¥ê¥Õ¥£¥Ã¥¯¥¹¤¬Æ¬¤Ë¤Ä¤­¤Þ¤¹¡£</p>\r
224         </fieldset>\r
225 \r
226         <h1>¥Ç¥£¥ì¥¯¥È¥ê¤ÈURL</h1>\r
227 \r
228         <p>\r
229         ¤³¤Î¥¤¥ó¥¹¥È¡¼¥ë¥¹¥¯¥ê¥×¥È¤ÏNucleus¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¥Ç¥£¥ì¥¯¥È¥ê¤ÈURL¤ò¸«¤Ä¤±¤è¤¦¤È¤·¤Þ¤·¤¿¡£²¼¤ÎÃͤò¥Á¥§¥Ã¥¯¤·¤ÆɬÍפʤéÄûÀµ¤·¤Æ¤¯¤À¤µ¤¤¡£¥Õ¥¡¥¤¥ë¤Ø¤Î¥Ñ¥¹¤ÈURL¤Ï¥¹¥é¥Ã¥·¥å'/'¤Ç½ª¤ï¤é¤Ê¤¯¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó¡£\r
230         </p>\r
231 \r
232         <fieldset>\r
233                 <legend>URLs and directories</legend>\r
234                 <table><tr>\r
235                         <td>Site <strong>URL</strong>:</td>\r
236                         <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
242                                         echo $url;\r
243                                 ?>" />\r
244                         </td>\r
245                 </tr><tr>\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
248                                 ?>" />\r
249                         </td>\r
250                 </tr><tr>\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
257                                 ?>" />\r
258                         </td>\r
259                 </tr><tr>\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
262                                 ?>" />\r
263                         </td>\r
264                 </tr><tr>\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
271                                 ?>" />\r
272                         </td>\r
273                 </tr><tr>\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
276                                 ?>" />\r
277                                 <br />(¥¤¥ó¥Ý¡¼¥È¤µ¤ì¤¿¥¹¥­¥ó¤¬»ÈÍÑ)\r
278                         </td>\r
279                 </tr><tr>\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
286                                 ?>" />\r
287                                 <br />(¥¤¥ó¥Ý¡¼¥È¤µ¤ì¤¿¥¹¥­¥ó¤Î¥Õ¥¡¥¤¥ëÎà¤òÃÖ¤¯¾ì½ê)\r
288                         </td>\r
289                 </tr><tr>\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
292                                 ?>" />\r
293                         </td>\r
294                 </tr><tr>\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
297                                 ?>" />\r
298                                 <br />(<tt>action.php</tt>¤Ø¤Îhttp://¤«¤é»Ï¤Þ¤ëURL)\r
299                         </td>\r
300                 </tr></table>\r
301         </fieldset>\r
302 \r
303         <p class="note">\r
304         <strong>ÉÕµ­:</strong> ÁêÂХѥ¹¤Ç¤Ï¤Ê¤¯<strong>ÀäÂХѥ¹¤ò»È¤Ã¤Æ¤¯¤À¤µ¤¤</strong>¡£Ä̾ÀäÂХѥ¹¤Ï<tt>/home/username/public_html/</tt>¤Î¤è¤¦¤Ê·Á¤ò¤È¤ê¤Þ¤¹¡£Unix¥·¥¹¥Æ¥à¡Ê¤Û¤È¤ó¤É¤Î¥µ¡¼¥Ð¡¼¤¬¤½¤¦¤Ç¤¹¡Ë¤Ë¤ª¤¤¤Æ¡¢¥Ñ¥¹¤Ï¥¹¥é¥Ã¥·¥å¤«¤é»Ï¤Þ¤ê¤Þ¤¹¡£¤â¤·¤³¤ì¤é¤Î¾ðÊóÆþÎϤËÌäÂ꤬À¸¤¸¤¿¤é¡¢¤¢¤Ê¤¿¤Î¥µ¡¼¥Ð´ÉÍý¼Ô¤Ë¤¿¤º¤Í¤ë¤Ù¤­¤Ç¤¹¡£\r
305         </p>\r
306 \r
307         <h1>´ÉÍý¸¢¸Â¤ò¤â¤Ä¥æ¡¼¥¶¡¼</h1>\r
308 \r
309         <p>°Ê²¼¤Ë¡¢¥µ¥¤¥È¤ÎºÇ½é¤Î¥æ¡¼¥¶¡¼¤òºîÀ®¤¹¤ë¤¿¤á¤Î¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£</p>\r
310 \r
311         <fieldset>\r
312                 <legend>´ÉÍý¸¢¸Â¤ò»ý¤Ä¥æ¡¼¥¶¡¼</legend>\r
313                 <table><tr>\r
314                         <td>ɽ¼¨¤µ¤ì¤ë̾Á°¡§</td>\r
315                         <td>\r
316                                 <input name="User_name" value="" />\r
317                                 <small>(µö²Ä¤µ¤ì¤ëʸ»ú¡§a-z ¤È 0-9¡¢ºÇ½é¤ÈºÇ¸å°Ê³°¤Î¥¹¥Ú¡¼¥¹)</small>\r
318                         </td>\r
319                 </tr><tr>\r
320                         <td>ËÜ̾¡Ê¥Ï¥ó¥É¥ë̾¡Ë¡§</td>\r
321                         <td><input name="User_realname" value="" /></td>\r
322                 </tr><tr>\r
323                         <td>¥Ñ¥¹¥ï¡¼¥É¡§</td>\r
324                         <td><input name="User_password" type="password" value="" /></td>\r
325                 </tr><tr>\r
326                         <td>¥Ñ¥¹¥ï¡¼¥É¤Î³Îǧ¡§</td>\r
327                         <td><input name="User_password2" type="password" value="" /></td>\r
328                 </tr><tr>\r
329                         <td>¥á¡¼¥ë¥¢¥É¥ì¥¹¡§</td>\r
330                         <td>\r
331                                 <input name="User_email" value="" />\r
332                                 <small>(ÍøÍѲÄǽ¤Ê¥á¡¼¥ë¥¢¥É¥ì¥¹¤òÆþ¤ì¤Æ¤¯¤À¤µ¤¤)</small>\r
333                         </td>\r
334                 </tr></table>\r
335         </fieldset>\r
336 \r
337         <h1>¥¦¥§¥Ö¥í¥°¤Î¥Ç¡¼¥¿</h1>\r
338 \r
339         <p>°Ê²¼¤Ë¡¢¥Ç¥Õ¥©¥ë¥È¤Îweblog¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¤¤¤¯¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£¤³¤Îweblog¤Î̾Á°¤Ï¡¢¥µ¥¤¥È̾¤È¤·¤Æ¤âÍøÍѤµ¤ì¤Þ¤¹¡£</p>\r
340 \r
341         <fieldset>\r
342                 <legend>¥¦¥§¥Ö¥í¥°¤Î¥Ç¡¼¥¿</legend>\r
343                 <table><tr>\r
344                         <td>Blog̾¡§</td>\r
345                         <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>\r
346                 </tr><tr>\r
347                         <td>Blog¤Îû½Ì̾¡§</td>\r
348                         <td>\r
349                                 <input name="Blog_shortname" value="mynucleuscms" />\r
350                                 <small>(µö²Ä¤µ¤ì¤ëʸ»ú¡§a-z ¤È 0-9¡¢¥¹¥Ú¡¼¥¹¤ÏÉÔ²Ä)</small>\r
351                         </td>\r
352                 </tr></table>\r
353         </fieldset>\r
354 \r
355         <h1>¥Ç¡¼¥¿¤ÎÁ÷¿®</h1>\r
356 \r
357         <p>\r
358         ¾å¤Ë½ñ¤¤¤Æ¤­¤¿¥Ç¡¼¥¿¤¬Àµ¤·¤¤¤«³Î¤«¤á¤Æ¤¯¤À¤µ¤¤¡£¤è¤±¤ì¤Ð¥Ç¡¼¥¿¥Ù¡¼¥¹¡¦¥Æ¡¼¥Ö¥ë¤ÈºÇ½é¤Î¥Ç¡¼¥¿¤òÀßÄꤹ¤ë¤¿¤á¤Ë²¼¤Î¥Ü¥¿¥ó¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤¡£¾¯¤·»þ´Ö¤¬¤«¤«¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¤¬¤´¿ÉÊú¤ò¡£<b>¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤Î¤Ï°ì²ó¤À¤±¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£</b>\r
359         </p>\r
360 \r
361         <p>\r
362                 <input name="action" value="go" type="hidden" />\r
363                 <input type="submit" value="Nucleus CMS¤Î¥¤¥ó¥¹¥È¡¼¥ë" onclick="return checkSubmit();" />\r
364         </p>\r
365 \r
366         </form>\r
367 \r
368         </body>\r
369         </html>\r
370 \r
371 \r
372         <?php   }\r
373 \r
374         function tableName($unPrefixed)\r
375         {\r
376                 global $mysql_usePrefix, $mysql_prefix;\r
377                 if ($mysql_usePrefix == 1)\r
378                         return $mysql_prefix . $unPrefixed;\r
379                 else\r
380                         return $unPrefixed;\r
381         }\r
382 \r
383         function doInstall() {\r
384                 global $mysql_usePrefix, $mysql_prefix;\r
385 \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
412 \r
413 \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
422 \r
423                 // 1. check all the data\r
424                 $errors = array();\r
425 \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
437                     )\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
459 \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
464 \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
468                 }\r
469 \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
472 \r
473                 // 5. execute queries\r
474                 $filename = "install.sql";\r
475                 $fd = fopen ($filename, "r");\r
476                 $queries = fread ($fd, filesize ($filename));\r
477                 fclose ($fd);\r
478 \r
479                 $queries = split("(;\n|;\r)",$queries);\r
480 \r
481                 $aTableNames = array(\r
482                         'nucleus_actionlog',\r
483                         'nucleus_ban',\r
484                         'nucleus_blog',\r
485                         'nucleus_category',\r
486                         'nucleus_comment',\r
487                         'nucleus_config',\r
488                         'nucleus_item',\r
489                         'nucleus_karma',\r
490                         'nucleus_member',\r
491                         'nucleus_plugin',\r
492                         'nucleus_skin',\r
493                         'nucleus_template',\r
494                         'nucleus_team'\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
501                 );\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
522                 );\r
523 \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
527                         if ($query) {\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
531                         }\r
532 \r
533                 }\r
534 \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
544 \r
545 \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
553                        . "     madmin=1,"\r
554                        . "     mcanlogin=1"\r
555                        . " WHERE mnumber=1";\r
556                 mysql_query($query) or _doError("Error while setting member settings: " . mysql_error());\r
557 \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
565 \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
571 \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
590 \r
591                         // close database connection (needs to be closed if we want to include globalfunctions.php)\r
592                         mysql_close();\r
593 \r
594                         $manager = '';\r
595                         include_once($DIR_LIBS . 'globalfunctions.php');\r
596 \r
597                         // 11. install custom skins\r
598                         $aSkinErrors = installCustomSkins($manager);\r
599 \r
600                         // 12. install custom plugins\r
601                         $aPlugErrors = installCustomPlugs($manager);\r
602 \r
603                 }\r
604 \r
605 \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
639 \r
640                         $result = @fputs($fp, $config_data, strlen($config_data));\r
641                         fclose($fp);\r
642 \r
643                         if ($result)\r
644                                 $bConfigWritten = 1;\r
645                 }\r
646 \r
647                 ?>\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
650                 <head>\r
651                         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />\r
652                         <title>Nucleus¤Î¥¤¥ó¥¹¥È¡¼¥ë</title>\r
653                         <style>\r
654                                 @import url('nucleus/styles/manual.css');\r
655                         </style>\r
656                 </head>\r
657                 <body>\r
658                 <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
659 <?php\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
664         }\r
665 \r
666         if (!$bConfigWritten) { ?>\r
667                         <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï¤Û¤Ü´°Î»¤·¤Þ¤·¤¿¡ª</h1>\r
668                         <p>\r
669                         ¥Ç¡¼¥¿¥Ù¡¼¥¹¥Æ¡¼¥Ö¥ë¤Î½é´üÃÍÆþÎϤ¬À®¸ù¤·¤Þ¤·¤¿¡£¸å¤Ï<i>config.php</i>¤ò½ñ¤­´¹¤¨¤ë¤À¤±¤Ç¤¹¡£°Ê²¼¤Ë½ñ¤­´¹¤¨¤ë¤Ù¤­ÆâÍƤòɽ¼¨¤·¤Þ¤¹¡Êmysql¤Î¥Ñ¥¹¥ï¡¼¥É¤Ï¥Þ¥¹¥¯¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¤³¤³¤Ï¼ÂºÝ¤Î¤â¤Î¤Ë½ñ¤­´¹¤¨¤Æ¤¯¤À¤µ¤¤¡Ë\r
670                         </p>\r
671 \r
672                         <pre>\r
673 &lt;?php\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
680 \r
681         // main nucleus directory\r
682         $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';\r
683 \r
684         // path to media dir\r
685         $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';\r
686 \r
687         // extra skin files for imported skins\r
688         $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';\r
689 \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
695 \r
696         // include 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
700         }\r
701 ?&gt;\r
702                         </pre>\r
703 \r
704                         <p>¤¢¤Ê¤¿¤Î¥³¥ó¥Ô¥å¡¼¥¿¾å¤Î¥Õ¥¡¥¤¥ë¤ò½ñ¤­´¹¤¨¤¿¤é¡¢FTP¤ò»È¤Ã¤Æ¥¦¥§¥Ö¥µ¡¼¥Ð¤Ë¥¢¥Ã¥×¥í¡¼¥É¤·¤Æ¤¯¤À¤µ¤¤¡£ASCII¥â¡¼¥É¤ÇÁ÷¿®¤·¤Æ¥Õ¥¡¥¤¥ë¤ò¾å½ñ¤­¤·¤Þ¤¹¡£\r
705                         </p>\r
706 \r
707                         <div class="note">\r
708                         <b>ÉÕµ­:</b> <i>config.php</i>¤ÎºÇ½é¤ä½ª¤ï¤ê¤Ë¥¹¥Ú¡¼¥¹¤ò¶õ¤±¤Ê¤¤¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£¼Â¹Ô»þ¤Ë¥¨¥é¡¼¤ò°ú¤­µ¯¤³¤¹¸¶°ø¤È¤Ê¤ê¤Þ¤¹¡£\r
709                         <br />\r
710                         ¤·¤¿¤¬¤Ã¤Æ¡¢config.php¤ÎºÇ½é¤Îʸ»ú¤Ï "&lt;"¤ÇºÇ¸å¤Îʸ»ú¤Ï"&gt;"¤È¤·¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£\r
711                         </div>\r
712 \r
713 <?php } else { ?>\r
714                         <h1>¥¤¥ó¥¹¥È¡¼¥ë¤Ï´°Î»¤·¤Þ¤·¤¿¡ª</h1>\r
715 \r
716                         <p>Nucleus¤Ï¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¡¢<code>config.php</code>¤Ï¥¢¥Ã¥×¥Ç¡¼¥È¤µ¤ì¤Þ¤·¤¿¡£</p>\r
717 \r
718                         <p>¥»¥­¥å¥ê¥Æ¥£¤Î¤¿¤á<code>config.php</code>¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤ò444¤ËÌ᤹¤³¤È¤ò˺¤ì¤Ê¤¤¤Ç¤¯¤À¤µ¤¤(<a href="nucleus/documentation/tips.html#filepermissions">¥Ñ¡¼¥ß¥Ã¥·¥ç¥óÊѹ¹¤Î´Ê°×¥¬¥¤¥É</a>)¡£</p>\r
719 <?php } ?>\r
720                         <h1>¥¤¥ó¥¹¥È¡¼¥ë¥Õ¥¡¥¤¥ë¤Îºï½ü</h1>\r
721 \r
722                         <p>¥¦¥§¥Ö¥µ¡¼¥Ð¤«¤é¼¡¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡§</p>\r
723 \r
724                         <ul>\r
725                                 <li><b>install.sql</b>¡§¥Æ¡¼¥Ö¥ë¤Î¹½Â¤¤òÆâÊñ¤¹¤ë¥Õ¥¡¥¤¥ë</li>\r
726                                 <li><b>install.php</b>¡§¤³¤Î¥Õ¥¡¥¤¥ë</li>\r
727                         </ul>\r
728 \r
729                         <p>¤â¤·¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¤òºï½ü¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢´ÉÍýÎΰè¤ò³«¤¯¤³¤È¤¬½ÐÍè¤Þ¤»¤ó¡£</p>\r
730 \r
731                         <h1>¥¦¥§¥Ö¥µ¥¤¥È¤Î³Îǧ</h1>\r
732                         <p>\r
733                         ¥¦¥§¥Ö¥µ¥¤¥È¤ò»È¤¦½àÈ÷¤¬À°¤¤¤Þ¤·¤¿¡£\r
734                         <ul>\r
735                                 <li><a href="<?php echo $config_adminurl?>">´ÉÍýÎΰè¤Ë¥í¥°¥¤¥ó¤·¤Æ¥µ¥¤¥È¤ÎÀßÄê¤ò¹Ô¤¦</a></li>\r
736                                 <li><a href="<?php echo $config_indexurl?>">¤¹¤°¤Ë¥µ¥¤¥È¤Ø¹Ô¤Ã¤Æ¤ß¤ë</a></li>\r
737                         </ul>\r
738                         </p>\r
739 \r
740                 </body>\r
741                 </html>\r
742                 <?php\r
743         }\r
744 \r
745 \r
746         function installCustomPlugs(&$manager) {\r
747                 global $aConfPlugsToInstall, $DIR_LIBS;\r
748 \r
749                 $aErrors = array();\r
750 \r
751                 if (count($aConfPlugsToInstall) == 0)\r
752                         return $aErrors;\r
753 \r
754                 $numCurrent = mysql_num_rows(sql_query('SELECT * FROM '.sql_table('plugin')));\r
755 \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
759                         sql_query($query);\r
760 \r
761                         // get and install the plugin\r
762                         $plugin =& $manager->getPlugin($plugName);\r
763                         if (!$plugin) {\r
764                                 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\''. addslashes($plugName).'\'');\r
765                                 $numCurrent--;\r
766                                 array_push($aErrors, 'Unable to install plugin ' . $plugName);\r
767                                 continue;\r
768                         }\r
769                         $plugin->install();\r
770                 }\r
771 \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
777                         $pid = $o->pid;\r
778                         $plug =& $manager->getPlugin($o->pfile);\r
779                         if ($plug)\r
780                         {\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
784                         }\r
785                 }\r
786 \r
787                 return $aErrors;\r
788         }\r
789 \r
790         function installCustomSkins(&$manager) {\r
791                 global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;\r
792 \r
793                 $aErrors = array();\r
794 \r
795                 if (count($aConfSkinsToImport) == 0)\r
796                         return $aErrors;\r
797 \r
798                 // load skinie class\r
799                 include_once($DIR_LIBS . 'skinie.php');\r
800 \r
801                 $importer = new SKINIMPORT();\r
802 \r
803                 foreach ($aConfSkinsToImport as $skinName) {\r
804                         $importer->reset();\r
805 \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
809                                 continue;\r
810                         }\r
811                         $error = $importer->readFile($skinFile);\r
812                         if ($error) {\r
813                                 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);\r
814                                 continue;\r
815                         }\r
816                         $error = $importer->writeToDatabase(1);\r
817                         if ($error) {\r
818                                 array_push($aErrors, 'Unable to import ' . $skinName . ' : ' . $error);\r
819                                 continue;\r
820                         }\r
821                 }\r
822 \r
823                 return $aErrors;\r
824         }\r
825 \r
826         // give an error if one or more nucleus are not accessible\r
827         function doCheckFiles() {\r
828                 $missingfiles = array();\r
829 \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
862 \r
863 \r
864                 if (sizeof($missingfiles) > 0)\r
865                         showErrorMessages($missingfiles);\r
866 \r
867 \r
868         }\r
869 \r
870         function updateConfig($name, $val) {\r
871                 $name = addslashes($name);\r
872                 $val = trim(addslashes($val));\r
873 \r
874                 $query = 'UPDATE ' . tableName('nucleus_config')\r
875                        . " SET value='$val'"\r
876                        . " WHERE name='$name'";\r
877 \r
878                 mysql_query($query) or _doError("Query error while trying to update config: " . mysql_error());\r
879                 return mysql_insert_id();\r
880         }\r
881 \r
882         function endsWithSlash($s) {\r
883                 return (strrpos($s,'/') == strlen($s) - 1);\r
884         }\r
885 \r
886         /**\r
887           * Checks if email address is valid\r
888           */\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
891                         return 1;\r
892                 else\r
893                         return 0;\r
894         }\r
895 \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
899         //        min 2 chars\r
900         function _isValidShortName($name) {\r
901                 if (eregi("^[a-z0-9]+$", $name))\r
902                         return 1;\r
903                 else\r
904                         return 0;\r
905         }\r
906 \r
907 \r
908 \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
913                         return 1;\r
914                 else\r
915                         return 0;\r
916         }\r
917 \r
918         function _doError($msg) {\r
919                 ?>\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
922                 <head>\r
923                         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />\r
924                         <title>Nucleus Install</title>\r
925                         <style>\r
926                                 @import url('nucleus/styles/manual.css');\r
927                         </style>\r
928                 </head>\r
929                 <body>\r
930                   <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
931                         <h1>Error!</h1>\r
932                         <p>\r
933                         Error message was: "<?php echo $msg?>";\r
934                         </p>\r
935 \r
936                         <p>\r
937                         <a href="install.php" onclick="history.back();return false;">Go Back</a>\r
938                         </p>\r
939                 </body>\r
940                 </html>\r
941                 <?php           exit;\r
942         }\r
943 \r
944         function showErrorMessages($errors) {\r
945                 ?>\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
948                 <head>\r
949                         <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" />\r
950                         <title>Nucleus Install</title>\r
951                         <style>\r
952                                 @import url('nucleus/styles/manual.css');\r
953                         </style>\r
954                 </head>\r
955                 <body>\r
956                   <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
957                         <h1>Errors!</h1>\r
958                         <p>\r
959                         Errors were found:\r
960                         </p>\r
961 \r
962                         <ul>\r
963                         <?php   while($msg = array_shift($errors))\r
964                                         echo "<li>$msg</li>";\r
965                         ?>\r
966                         </ul>\r
967 \r
968                         <p>\r
969                         <a href="install.php" onclick="history.back();return false;">Go Back</a>\r
970                         </p>\r
971                 </body>\r
972                 </html>\r
973                 <?php           exit;\r
974         }\r
975 \r
976 \r
977         /* for the non-php systems that decide to show the contents:\r
978            ?></div><?php        */\r
979 \r
980 ?>\r