OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk/utf8@906...
[nucleus-jp/nucleus-jp-ancient.git] / install.php
1 <?php\r
2 /*\r
3  * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
4  * Copyright (C) 2002-2009 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  * ?><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
16  */\r
17 \r
18 /**\r
19  * @license http://nucleuscms.org/license.txt GNU General Public License\r
20  * @copyright Copyright (C) 2002-2009 The Nucleus Group\r
21  * @version $Id: install.php,v 1.8 2007-04-25 06:34:29 kimitake Exp $\r
22  * $NucleusJP: install.php,v 1.7 2007/02/04 06:28:44 kimitake Exp $\r
23  */\r
24 \r
25 /*\r
26         This part of the install.php code allows for customization of the install process.\r
27         When distributing plugins or skins together with a Nucleus installation, the\r
28         configuration below will instruct to install them\r
29 \r
30         -- Start Of Configurable Part --\r
31 */\r
32 \r
33 include('./install_lang_japanese.php');\r
34 \r
35 // array with names of plugins to install. Plugin files must be present in the nucleus/plugin/\r
36 // directory.\r
37 //\r
38 // example:\r
39 //     array('NP_TrackBack', 'NP_MemberGoodies')\r
40 $aConfPlugsToInstall = array('NP_SkinFiles');\r
41 \r
42 \r
43 // array with skins to install. skins must be present under the skins/ directory with\r
44 // a subdirectory having the same name that contains a skinbackup.xml file\r
45 //\r
46 // example:\r
47 //     array('base','rsd')\r
48 $aConfSkinsToImport = array('default');\r
49 \r
50 /*\r
51         -- End Of Configurable Part --\r
52 */\r
53 \r
54 // don't give warnings for uninitialized vars\r
55 error_reporting(E_ERROR | E_WARNING | E_PARSE);\r
56 \r
57 // make sure there's no unnecessary escaping:\r
58 set_magic_quotes_runtime(0);\r
59 \r
60 // if there are some plugins or skins to import, do not include vars\r
61 // in globalfunctions.php again... so set a flag\r
62 if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {\r
63         global $CONF;\r
64         $CONF['installscript'] = 1;\r
65 }\r
66 \r
67 if (phpversion() >= '4.1.0') {\r
68         include_once('nucleus/libs/vars4.1.0.php');\r
69 } else {\r
70         include_once('nucleus/libs/vars4.0.6.php');\r
71 }\r
72 \r
73 include_once('nucleus/libs/mysql.php');\r
74 \r
75 // check if mysql support is installed\r
76         if (!function_exists('mysql_query') ) {\r
77                 _doError(_ERROR1);\r
78         }\r
79 \r
80         if (postVar('action') == 'go') {\r
81                 doInstall();\r
82         } else {\r
83                 showInstallForm();\r
84         }\r
85 \r
86         exit;\r
87 \r
88 function showInstallForm() {\r
89         // 0. pre check if all necessary files exist\r
90         doCheckFiles();\r
91 \r
92         ?>\r
93         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
94         <html xmlns="http://www.w3.org/1999/xhtml">\r
95         <head>\r
96                 <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />\r
97                 <title><?php echo _TITLE; ?></title>\r
98                 <style type="text/css"><!--\r
99                         @import url('nucleus/documentation/styles/manual.css');\r
100                 --></style>\r
101                 <script type="text/javascript"><!--\r
102                         var submitcount = 0;\r
103 \r
104                         // function to make sure the submit button only gets pressed once\r
105                         function checkSubmit() {\r
106                                 if (submitcount == 0) {\r
107                                         submitcount++;\r
108                                         return true;\r
109                                 } else {\r
110                                         return false;\r
111                                 }\r
112                         }\r
113                 --></script>\r
114         </head>\r
115         <body>\r
116                 <div style="text-align:center"><img src="./nucleus/styles/logo.gif" /></div> <!-- Nucleus logo -->\r
117                 <form method="post" action="install.php">\r
118 \r
119                 <h1><?php echo _HEADER1; ?></h1>\r
120 \r
121                 <?php echo _TEXT1; ?>\r
122 \r
123                 <h1><?php echo _HEADER2; ?></h1>\r
124 \r
125                 <?php echo _TEXT2; ?>\r
126 \r
127                 <ul>\r
128                         <li>PHP:\r
129 \r
130 <?php\r
131         echo phpversion();\r
132         $minVersion = '4.0.6';\r
133 \r
134         if (phpversion() < $minVersion) {\r
135                 echo ' <span class="warning">', _TEXT2_WARN , $minVersion, '</span>';\r
136         } elseif (phpversion() < '5') {\r
137                 echo ' <span class="warning">' . _TEXT2_WARN3 . '</span>';\r
138         }\r
139 ?>\r
140 \r
141                         </li>\r
142                         <li>MySQL:\r
143 \r
144 <?php\r
145         // note: this piece of code is taken from phpMyAdmin\r
146         $result = @mysql_query('SELECT VERSION() AS version');\r
147 \r
148         if ($result != FALSE && @mysql_num_rows($result) > 0) {\r
149                 $row = mysql_fetch_array($result);\r
150                 $match = explode('.', $row['version']);\r
151         } else {\r
152                 $result = @mysql_query('SHOW VARIABLES LIKE \'version\'');\r
153 \r
154                 if ($result != FALSE && @mysql_num_rows($result) > 0) {\r
155                         $row = mysql_fetch_row($result);\r
156                         $match = explode('.', $row[1]);\r
157                 } else {\r
158                         $output = shell_exec('mysql -V');\r
159                         preg_match('@[0-9]+\.[0-9]+\.[0-9]+@', $output, $version);\r
160                         $match = explode('.', $version[0]);\r
161 \r
162                         if ($match[0] == '') {\r
163                                 $match[0] = '0';\r
164                                 $match[1] = '0';\r
165                                 $match[2] = '0';\r
166                         }\r
167                 }\r
168         }\r
169 \r
170         $mysqlVersion = implode($match, '.');\r
171         $minVersion = '3.23';\r
172 \r
173         if ($mysqlVersion == '0.0.0') {\r
174                 echo _NOTIFICATION1;\r
175         }\r
176         else {\r
177                 echo $mysqlVersion;\r
178         }\r
179 \r
180         if ($mysqlVersion < $minVersion) {\r
181                 echo ' <span class="warning">'._TEXT2_WARN2 , $minVersion.'</span>';\r
182         }\r
183 ?>\r
184 \r
185                         </li>\r
186                 </ul>\r
187 \r
188 <?php\r
189         // tell people how they can have their config file filled out automatically\r
190         if (@file_exists('config.php') && @!is_writable('config.php') ) {\r
191 ?>\r
192 \r
193                 <h1><?php echo _HEADER3; ?></h1>\r
194 \r
195                 <?php echo _TEXT3;\r
196 \r
197 } ?>\r
198 \r
199                 <h1><?php echo _HEADER4; ?></h1>\r
200 \r
201                 <?php echo _TEXT4; ?>\r
202 \r
203                 <fieldset>\r
204                         <legend><?php echo _TEXT4_TAB_HEAD; ?></legend>\r
205                         <table>\r
206                                 <tr>\r
207                                         <td><?php echo _TEXT4_TAB_FIELD1; ?>:</td>\r
208                                         <td><input name="mySQL_host" value="<?php echo htmlspecialchars(@ini_get('mysql.default_host') )?>" /></td>\r
209                                 </tr>\r
210                                 <tr>\r
211                                         <td><?php echo _TEXT4_TAB_FIELD2; ?>:</td>\r
212                                         <td><input name="mySQL_user" /></td>\r
213                                 </tr>\r
214                                 <tr>\r
215                                         <td><?php echo _TEXT4_TAB_FIELD3; ?>:</td>\r
216                                         <td><input name="mySQL_password" type="password" /></td>\r
217                                 </tr>\r
218                                 <tr>\r
219                                         <td><?php echo _TEXT4_TAB_FIELD4; ?>:</td>\r
220                                         <td><input name="mySQL_database" /> (<input name="mySQL_create" value="1" type="checkbox" id="mySQL_create"><label for="mySQL_create" /><?php echo _TEXT4_TAB_FIELD4_ADD; ?></label>)</td>\r
221                                 </tr>\r
222                         </table>\r
223                 </fieldset>\r
224 \r
225                 <fieldset>\r
226                         <legend><?php echo _TEXT4_TAB2_HEAD; ?></legend>\r
227                         <table>\r
228                                 <tr>\r
229                                         <td><input name="mySQL_usePrefix" value="1" type="checkbox" id="mySQL_usePrefix"><label for="mySQL_usePrefix" /><?php echo _TEXT4_TAB2_FIELD; ?>:</label></td>\r
230                                         <td><input name="mySQL_tablePrefix" value="" /></td>\r
231                                 </tr>\r
232                         </table>\r
233 \r
234                         <?php echo _TEXT4_TAB2_ADD; ?>\r
235 \r
236                 </fieldset>\r
237 \r
238         <h1><?php echo _HEADER5; ?></h1>\r
239 \r
240         <?php echo _TEXT5; ?>\r
241 \r
242 <?php\r
243 \r
244         // no need to this all! dirname(__FILE__) is all we need -- moraes\r
245         /*\r
246         // discover full path\r
247         $fullPath = serverVar('PATH_TRANSLATED');\r
248 \r
249         if ($fullPath == '') {\r
250                 $fullPath = serverVar('SCRIPT_FILENAME');\r
251         }\r
252 \r
253         $basePath = str_replace('install.php', '', $fullPath);\r
254         $basePath = replaceDoubleBackslash($basePath);\r
255         $basePath = replaceDoubleBackslash($basePath);\r
256 \r
257         // add slash at end if necessary\r
258         if (!endsWithSlash($basePath) ) {\r
259                 $basePath .= '/';\r
260         }\r
261         */\r
262 \r
263         $basePath = dirname(__FILE__) . '/';\r
264 ?>\r
265 \r
266                 <fieldset>\r
267                         <legend><?php echo _TEXT5_TAB_HEAD; ?></legend>\r
268                         <table>\r
269                                 <tr>\r
270                                         <td><?php echo _TEXT5_TAB_FIELD1;?>:</td>\r
271                                         <td><input name="IndexURL" size="60" value="<?php\r
272                                                 $url = 'http://' . serverVar('HTTP_HOST') . serverVar('PHP_SELF');\r
273                                                 $url = str_replace('install.php', '', $url);\r
274                                                 $url = replaceDoubleBackslash($url);\r
275 \r
276                                                 // add slash at end if necessary\r
277                                                 if (!endsWithSlash($url) ) {\r
278                                                         $url .= '/';\r
279                                                 }\r
280 \r
281                                                 echo $url; ?>" /></td>\r
282                                 </tr>\r
283                                 <tr>\r
284                                         <td><?php echo _TEXT5_TAB_FIELD2;?>:</td>\r
285                                         <td><input name="AdminURL" size="60" value="<?php\r
286                                                 if ($url) {\r
287                                                         echo $url, 'nucleus/';\r
288                                                 } ?>" /></td>\r
289                                 </tr>\r
290                                 <tr>\r
291                                         <td><?php echo _TEXT5_TAB_FIELD3;?>:</td>\r
292                                         <td><input name="AdminPath" size="60" value="<?php\r
293                                                 if($basePath) {\r
294                                                         echo $basePath, 'nucleus/';\r
295                                                 } ?>" /></td>\r
296                                 </tr>\r
297                                 <tr>\r
298                                         <td><?php echo _TEXT5_TAB_FIELD4;?>:</td>\r
299                                         <td><input name="MediaURL" size="60" value="<?php\r
300                                                 if ($url) {\r
301                                                         echo $url, 'media/';\r
302                                                 } ?>" /></td>\r
303                                 </tr>\r
304                                 <tr>\r
305                                         <td><?php echo _TEXT5_TAB_FIELD5;?>:</td>\r
306                                         <td><input name="MediaPath" size="60" value="<?php\r
307                                                 if ($basePath) {\r
308                                                         echo $basePath, 'media/';\r
309                                                 } ?>" /></td>\r
310                                 </tr>\r
311                                 <tr>\r
312                                         <td><?php echo _TEXT5_TAB_FIELD6;?>:</td>\r
313                                         <td><input name="SkinsURL" size="60" value="<?php\r
314                                                 if ($url) {\r
315                                                         echo $url, 'skins/';\r
316                                                 } ?>" />\r
317                                                 <br />(used by imported skins)\r
318                                         </td>\r
319                                 </tr>\r
320                                 <tr>\r
321                                         <td><?php echo _TEXT5_TAB_FIELD7;?>:</td>\r
322                                         <td><input name="SkinsPath" size="60" value="<?php\r
323                                                 if ($basePath) {\r
324                                                         echo $basePath, 'skins/';\r
325                                                 } ?>" />\r
326                                                 <br />(<?php echo _TEXT5_TAB_FIELD7_2;?>)\r
327                                         </td>\r
328                                 </tr>\r
329                                 <tr>\r
330                                         <td><?php echo _TEXT5_TAB_FIELD8;?>:</td>\r
331                                         <td><input name="PluginURL" size="60" value="<?php\r
332                                                 if ($url) {\r
333                                                         echo $url, 'nucleus/plugins/';\r
334                                                 } ?>" /></td>\r
335                                 </tr>\r
336                                 <tr>\r
337                                         <td><?php echo _TEXT5_TAB_FIELD9;?>:</td>\r
338                                         <td><input name="ActionURL" size="60" value="<?php\r
339                                                 if ($url) {\r
340                                                         echo $url, 'action.php';\r
341                                                 } ?>" />\r
342                                                 <br />(<?php echo _TEXT5_TAB_FIELD9_2;?>)\r
343                                         </td>\r
344                                 </tr>\r
345                         </table>\r
346                 </fieldset>\r
347 \r
348                 <?php echo _TEXT5_2; ?>\r
349 \r
350                 <h1><? echo _HEADER6; ?></h1>\r
351 \r
352                 <?php echo _TEXT6; ?>\r
353 \r
354                 <fieldset>\r
355                         <legend><?php echo _TEXT6_TAB_HEAD; ?></legend>\r
356                         <table>\r
357                                 <tr>\r
358                                         <td><?php echo _TEXT6_TAB_FIELD1; ?>:</td>\r
359                                         <td><input name="User_name" value="" /> <small>(<?php echo _TEXT6_TAB_FIELD1_2; ?>)</small></td>\r
360                                 </tr>\r
361                                 <tr>\r
362                                         <td><?php echo _TEXT6_TAB_FIELD2; ?>:</td>\r
363                                         <td><input name="User_realname" value="" /></td>\r
364                                 </tr>\r
365                                 <tr>\r
366                                         <td><?php echo _TEXT6_TAB_FIELD3; ?>:</td>\r
367                                         <td><input name="User_password" type="password" value="" /></td>\r
368                                 </tr>\r
369                                 <tr>\r
370                                         <td><?php echo _TEXT6_TAB_FIELD4; ?>:</td>\r
371                                         <td><input name="User_password2" type="password" value="" /></td>\r
372                                 </tr>\r
373                                 <tr>\r
374                                         <td><?php echo _TEXT6_TAB_FIELD5; ?>:</td>\r
375                                         <td><input name="User_email" value="" /> <small>(<?php echo _TEXT6_TAB_FIELD5_2; ?>)</small></td>\r
376                                 </tr>\r
377                         </table>\r
378                 </fieldset>\r
379 \r
380                 <h1><?php echo _HEADER7; ?></h1>\r
381 \r
382                 <?php echo _TEXT7; ?>\r
383 \r
384                 <fieldset>\r
385                         <legend><?php echo _TEXT7_TAB_HEAD; ?></legend>\r
386                         <table>\r
387                                 <tr>\r
388                                         <td><?php echo _TEXT7_TAB_FIELD1; ?>:</td>\r
389                                         <td><input name="Blog_name" size="60" value="My Nucleus CMS" /></td>\r
390                                 </tr>\r
391                                 <tr>\r
392                                         <td><?php echo _TEXT7_TAB_FIELD2; ?>:</td>\r
393                                         <td><input name="Blog_shortname" value="mynucleuscms" /> <small>(<?php echo _TEXT7_TAB_FIELD2_2; ?>)</small></td>\r
394                                 </tr>\r
395                         </table>\r
396                 </fieldset>\r
397 \r
398                 <h1><?php echo _HEADER8; ?></h1>\r
399 \r
400                 <fieldset>\r
401                         <legend><?php echo _TEXT8_TAB_HEADER; ?></legend>\r
402                         <table>\r
403                                 <tr>\r
404                                         <td><input name="Weblog_ping" value="1" type="checkbox" id="Weblog_ping" /><?php echo _TEXT8_TAB_FIELD1; ?></td>\r
405                                 </tr>\r
406                         </table>\r
407                 </fieldset>\r
408 \r
409                 <h1><?php echo _HEADER9; ?></h1>\r
410 \r
411                 <?php echo _TEXT9; ?>\r
412 \r
413                 <p><input name="action" value="go" type="hidden" /> <input type="submit" value="<?php echo _BUTTON1; ?>" onclick="return checkSubmit();" /></p>\r
414 \r
415                 </form>\r
416         </body>\r
417 </html>\r
418 \r
419 <?php }\r
420 \r
421 function tableName($unPrefixed) {\r
422         global $mysql_usePrefix, $mysql_prefix;\r
423 \r
424         if ($mysql_usePrefix == 1) {\r
425                 return $mysql_prefix . $unPrefixed;\r
426         } else {\r
427                 return $unPrefixed;\r
428         }\r
429 }\r
430 \r
431 function doInstall() {\r
432         global $mysql_usePrefix, $mysql_prefix, $weblog_ping;\r
433 \r
434         // 0. put all POST-vars into vars\r
435         $mysql_host = postVar('mySQL_host');\r
436         $mysql_user = postVar('mySQL_user');\r
437         $mysql_password = postVar('mySQL_password');\r
438         $mysql_database = postVar('mySQL_database');\r
439         $mysql_create = postVar('mySQL_create');\r
440         $mysql_usePrefix = postVar('mySQL_usePrefix');\r
441         $mysql_prefix = postVar('mySQL_tablePrefix');\r
442         $config_indexurl = postVar('IndexURL');\r
443         $config_adminurl = postVar('AdminURL');\r
444         $config_adminpath = postVar('AdminPath');\r
445         $config_mediaurl = postVar('MediaURL');\r
446         $config_skinsurl = postVar('SkinsURL');\r
447         $config_pluginurl = postVar('PluginURL');\r
448         $config_actionurl = postVar('ActionURL');\r
449         $config_mediapath = postVar('MediaPath');\r
450         $config_skinspath = postVar('SkinsPath');\r
451         $user_name = postVar('User_name');\r
452         $user_realname = postVar('User_realname');\r
453         $user_password = postVar('User_password');\r
454         $user_password2 = postVar('User_password2');\r
455         $user_email = postVar('User_email');\r
456         $blog_name = postVar('Blog_name');\r
457         $blog_shortname = postVar('Blog_shortname');\r
458         $config_adminemail = $user_email;\r
459         $config_sitename = $blog_name;\r
460         $weblog_ping = postVar('Weblog_ping');\r
461 \r
462         $config_indexurl = replaceDoubleBackslash($config_indexurl);\r
463         $config_adminurl = replaceDoubleBackslash($config_adminurl);\r
464         $config_mediaurl = replaceDoubleBackslash($config_mediaurl);\r
465         $config_skinsurl = replaceDoubleBackslash($config_skinsurl);\r
466         $config_pluginurl = replaceDoubleBackslash($config_pluginurl);\r
467         $config_actionurl = replaceDoubleBackslash($config_actionurl);\r
468         $config_adminpath = replaceDoubleBackslash($config_adminpath);\r
469         $config_skinspath = replaceDoubleBackslash($config_skinspath);\r
470         $config_mediapath = replaceDoubleBackslash($config_mediapath);\r
471 \r
472         // 1. check all the data\r
473         $errors = array();\r
474 \r
475         if (!$mysql_database) {\r
476                 array_push($errors, _ERROR2);\r
477         }\r
478 \r
479         if (($mysql_usePrefix == 1) && (strlen($mysql_prefix) == 0) ) {\r
480                 array_push($errors, _ERROR3);\r
481         }\r
482 \r
483         if (($mysql_usePrefix == 1) && (!eregi('^[a-zA-Z0-9_]+$', $mysql_prefix) ) ) {\r
484                 array_push($errors, _ERROR4);\r
485         }\r
486 \r
487         // TODO: add action.php check\r
488         if (!endsWithSlash($config_indexurl) || !endsWithSlash($config_adminurl) || !endsWithSlash($config_mediaurl) || !endsWithSlash($config_pluginurl) || !endsWithSlash($config_skinsurl) ) {\r
489                 array_push($errors, _ERROR5);\r
490         }\r
491 \r
492         if (!endsWithSlash($config_adminpath) ) {\r
493                 array_push($errors, _ERROR6);\r
494         }\r
495 \r
496         if (!endsWithSlash($config_mediapath) ) {\r
497                 array_push($errors, _ERROR7);\r
498         }\r
499 \r
500         if (!endsWithSlash($config_skinspath) ) {\r
501                 array_push($errors, _ERROR8);\r
502         }\r
503 \r
504         if (!is_dir($config_adminpath) ) {\r
505                 array_push($errors, _ERROR9);\r
506         }\r
507 \r
508         if (!_isValidMailAddress($user_email) ) {\r
509                 array_push($errors, _ERROR10);\r
510         }\r
511 \r
512         if (!_isValidDisplayName($user_name) ) {\r
513                 array_push($errors, _ERROR11);\r
514         }\r
515 \r
516         if (!$user_password || !$user_password2) {\r
517                 array_push($errors, _ERROR12);\r
518         }\r
519 \r
520         if ($user_password != $user_password2) {\r
521                 array_push($errors, _ERROR13);\r
522         }\r
523 \r
524         if (!_isValidShortName($blog_shortname) ) {\r
525                 array_push($errors, _ERROR14);\r
526         }\r
527 \r
528         if (sizeof($errors) > 0) {\r
529                 showErrorMessages($errors);\r
530         }\r
531 \r
532         // 2. try to log in to mySQL\r
533         global $MYSQL_CONN;\r
534         $MYSQL_CONN = @mysql_connect($mysql_host, $mysql_user, $mysql_password);\r
535 \r
536         if ($MYSQL_CONN == false) {\r
537                 _doError(_ERROR15 . ': ' . mysql_error() );\r
538         }\r
539 \r
540         // 3. try to create database (if needed)\r
541         if ($mysql_create == 1) {\r
542                 mysql_query('CREATE DATABASE ' . $mysql_database) or _doError(_ERROR16 . ': ' . mysql_error() );\r
543         }\r
544 \r
545         // 4. try to select database\r
546         mysql_select_db($mysql_database) or _doError(_ERROR17);\r
547 \r
548         // 5. execute queries\r
549         $filename = 'install.sql';\r
550         $fd = fopen($filename, 'r');\r
551         $queries = fread($fd, filesize($filename) );\r
552         fclose($fd);\r
553 \r
554         $queries = split("(;\n|;\r)", $queries);\r
555 \r
556         $aTableNames = array(\r
557                 'nucleus_actionlog',\r
558                 'nucleus_ban',\r
559                 'nucleus_blog',\r
560                 'nucleus_category',\r
561                 'nucleus_comment',\r
562                 'nucleus_config',\r
563                 'nucleus_item',\r
564                 'nucleus_karma',\r
565                 'nucleus_member',\r
566                 'nucleus_plugin',\r
567                 'nucleus_skin',\r
568                 'nucleus_template',\r
569                 'nucleus_team',\r
570                 'nucleus_activation',\r
571                 'nucleus_tickets'\r
572                 );\r
573 // these are unneeded (one of the replacements above takes care of them)\r
574 //                      'nucleus_plugin_event',\r
575 //                      'nucleus_plugin_option',\r
576 //                      'nucleus_plugin_option_desc',\r
577 //                      'nucleus_skin_desc',\r
578 //                      'nucleus_template_desc',\r
579 \r
580         $aTableNamesPrefixed = array(\r
581                 $mysql_prefix . 'nucleus_actionlog',\r
582                 $mysql_prefix . 'nucleus_ban',\r
583                 $mysql_prefix . 'nucleus_blog',\r
584                 $mysql_prefix . 'nucleus_category',\r
585                 $mysql_prefix . 'nucleus_comment',\r
586                 $mysql_prefix . 'nucleus_config',\r
587                 $mysql_prefix . 'nucleus_item',\r
588                 $mysql_prefix . 'nucleus_karma',\r
589                 $mysql_prefix . 'nucleus_member',\r
590                 $mysql_prefix . 'nucleus_plugin',\r
591                 $mysql_prefix . 'nucleus_skin',\r
592                 $mysql_prefix . 'nucleus_template',\r
593                 $mysql_prefix . 'nucleus_team',\r
594                 $mysql_prefix . 'nucleus_activation',\r
595                 $mysql_prefix . 'nucleus_tickets'\r
596                 );\r
597 // these are unneeded (one of the replacements above takes care of them)\r
598 //                      $mysql_prefix . 'nucleus_plugin_event',\r
599 //                      $mysql_prefix . 'nucleus_plugin_option',\r
600 //                      $mysql_prefix . 'nucleus_plugin_option_desc',\r
601 //                      $mysql_prefix . 'nucleus_skin_desc',\r
602 //                      $mysql_prefix . 'nucleus_template_desc',\r
603 \r
604         $count = count($queries);\r
605 \r
606         for ($idx = 0; $idx < $count; $idx++) {\r
607                 $query = trim($queries[$idx]);\r
608                 // echo "QUERY = <small>" . htmlspecialchars($query) . "</small><p>";\r
609 \r
610                 if ($query) {\r
611 \r
612                         if ($mysql_usePrefix == 1) {\r
613                                         $query = str_replace($aTableNames, $aTableNamesPrefixed, $query);\r
614                         }\r
615 \r
616                         mysql_query($query) or _doError(_ERROR30 . ' (<small>' . htmlspecialchars($query) . '</small>): ' . mysql_error() );\r
617                 }\r
618         }\r
619 \r
620         // 5a make first post\r
621         $newpost = "INSERT INTO `nucleus_item` VALUES (1, '" . _1ST_POST_TITLE . "', '" . _1ST_POST . "', '" . _1ST_POST2 . "', 1, 1, '2005-08-15 11:04:26', 0, 0, 0, 1, 0, 1);";\r
622         mysql_query($newpost) or _doError(_ERROR18 . ' (<small>' . htmlspecialchars($newpost) . '</small>): ' . mysql_error() );\r
623 \r
624         // 6. update global settings\r
625         updateConfig('IndexURL', $config_indexurl);\r
626         updateConfig('AdminURL', $config_adminurl);\r
627         updateConfig('MediaURL', $config_mediaurl);\r
628         updateConfig('SkinsURL', $config_skinsurl);\r
629         updateConfig('PluginURL', $config_pluginurl);\r
630         updateConfig('ActionURL', $config_actionurl);\r
631         updateConfig('AdminEmail', $config_adminemail);\r
632         updateConfig('SiteName', $config_sitename);\r
633 \r
634         // 7. update GOD member\r
635         $query = 'UPDATE ' . tableName('nucleus_member')\r
636                         . " SET mname='" . addslashes($user_name) . "',"\r
637                         . " mrealname='" . addslashes($user_realname) . "',"\r
638                         . " mpassword='" . md5(addslashes($user_password) ) . "',"\r
639                         . " murl='" . addslashes($config_indexurl) . "',"\r
640                         . " memail='" . addslashes($user_email) . "',"\r
641                         . " madmin=1, mcanlogin=1"\r
642                         . " WHERE mnumber=1";\r
643 \r
644         mysql_query($query) or _doError(_ERROR19 . ': ' . mysql_error() );\r
645 \r
646         // 8. update weblog settings\r
647         $query = 'UPDATE ' . tableName('nucleus_blog')\r
648                         . " SET bname='" . addslashes($blog_name) . "',"\r
649                         . " bshortname='" . addslashes($blog_shortname) . "',"\r
650                         . " burl='" . addslashes($config_indexurl) . "'"\r
651                         . " WHERE bnumber=1";\r
652 \r
653         mysql_query($query) or _doError(_ERROR20 . ': ' . mysql_error() );\r
654 \r
655         // 9. update item date\r
656         $query = 'UPDATE ' . tableName('nucleus_item')\r
657                         . " SET itime='" . date('Y-m-d H:i:s', time() ) ."'"\r
658                         . " WHERE inumber=1";\r
659 \r
660         mysql_query($query) or _doError(_ERROR21 . ': ' . mysql_error() );\r
661 \r
662         global $aConfPlugsToInstall, $aConfSkinsToImport;\r
663         $aSkinErrors = array();\r
664         $aPlugErrors = array();\r
665 \r
666         if ((count($aConfPlugsToInstall) > 0) || (count($aConfSkinsToImport) > 0) ) {\r
667                 // 10. set global variables\r
668                 global $MYSQL_HOST, $MYSQL_USER, $MYSQL_PASSWORD, $MYSQL_DATABASE, $MYSQL_PREFIX;\r
669 \r
670                 $MYSQL_HOST = $mysql_host;\r
671                 $MYSQL_USER = $mysql_user;\r
672                 $MYSQL_PASSWORD = $mysql_password;\r
673                 $MYSQL_DATABASE = $mysql_database;\r
674                 $MYSQL_PREFIX = ($mysql_usePrefix == 1)?$mysql_prefix:'';\r
675 \r
676                 global $DIR_NUCLEUS, $DIR_MEDIA, $DIR_SKINS, $DIR_PLUGINS, $DIR_LANG, $DIR_LIBS;\r
677 \r
678                 $DIR_NUCLEUS = $config_adminpath;\r
679                 $DIR_MEDIA = $config_mediapath;\r
680                 $DIR_SKINS = $config_skinspath;\r
681                 $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';\r
682                 $DIR_LANG = $DIR_NUCLEUS . 'language/';\r
683                 $DIR_LIBS = $DIR_NUCLEUS . 'libs/';\r
684 \r
685                 // close database connection (needs to be closed if we want to include globalfunctions.php)\r
686                 mysql_close();\r
687 \r
688                 $manager = '';\r
689                 include_once($DIR_LIBS . 'globalfunctions.php');\r
690 \r
691                 // 11. install custom skins\r
692                 $aSkinErrors = installCustomSkins($manager);\r
693 \r
694                 // 12. install NP_Ping, if decided\r
695                 if ($weblog_ping == 1) {\r
696                         global $aConfPlugsToInstall;\r
697                         array_push($aConfPlugsToInstall, "NP_Ping");\r
698                 }\r
699 \r
700                 // 13. install custom plugins\r
701                 $aPlugErrors = installCustomPlugs($manager);\r
702         }\r
703 \r
704         // 14. Write config file ourselves (if possible)\r
705         $bConfigWritten = 0;\r
706 \r
707         if (@file_exists('config.php') && is_writable('config.php') && $fp = @fopen('config.php', 'w') ) {\r
708                 $config_data = '<' . '?php' . "\n\n";\r
709                 //$config_data .= "\n"; (extraneous, just added extra \n to previous line\r
710                 $config_data .= "       // mySQL connection information\n";\r
711                 $config_data .= "       \$MYSQL_HOST = '" . $mysql_host . "';\n";\r
712                 $config_data .= "       \$MYSQL_USER = '" . $mysql_user . "';\n";\r
713                 $config_data .= "       \$MYSQL_PASSWORD = '" . $mysql_password . "';\n";\r
714                 $config_data .= "       \$MYSQL_DATABASE = '" . $mysql_database . "';\n";\r
715                 $config_data .= "       \$MYSQL_PREFIX = '" . (($mysql_usePrefix == 1)?$mysql_prefix:'') . "';\n";\r
716                 $config_data .= "\n";\r
717                 $config_data .= "       // main nucleus directory\n";\r
718                 $config_data .= "       \$DIR_NUCLEUS = '" . $config_adminpath . "';\n";\r
719                 $config_data .= "\n";\r
720                 $config_data .= "       // path to media dir\n";\r
721                 $config_data .= "       \$DIR_MEDIA = '" . $config_mediapath . "';\n";\r
722                 $config_data .= "\n";\r
723                 $config_data .= "       // extra skin files for imported skins\n";\r
724                 $config_data .= "       \$DIR_SKINS = '" . $config_skinspath . "';\n";\r
725                 $config_data .= "\n";\r
726                 $config_data .= "       // these dirs are normally sub dirs of the nucleus dir, but \n";\r
727                 $config_data .= "       // you can redefine them if you wish\n";\r
728                 $config_data .= "       \$DIR_PLUGINS = \$DIR_NUCLEUS . 'plugins/';\n";\r
729                 $config_data .= "       \$DIR_LANG = \$DIR_NUCLEUS . 'language/';\n";\r
730                 $config_data .= "       \$DIR_LIBS = \$DIR_NUCLEUS . 'libs/';\n";\r
731                 $config_data .= "\n";\r
732                 $config_data .= "       // include libs\n";\r
733                 $config_data .= "       include(\$DIR_LIBS.'globalfunctions.php');\n";\r
734                 $config_data .= "       if (!extension_loaded('mbstring')) {\n";\r
735                 $config_data .= "       include(\$DIR_LIBS.'mb_emulator/mb-emulator.php');\n";\r
736                 $config_data .= "       }\n";\r
737                 $config_data .= "?" . ">";\r
738 \r
739                 $result = @fputs($fp, $config_data, strlen($config_data) );\r
740                 fclose($fp);\r
741 \r
742                 if ($result) {\r
743                         $bConfigWritten = 1;\r
744                 }\r
745         }\r
746 \r
747 ?>\r
748 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
749 <html xmlns="http://www.w3.org/1999/xhtml">\r
750 <head>\r
751         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
752         <title><?php echo _TITLE; ?></title>\r
753         <style>@import url('nucleus/styles/manual.css');</style>\r
754 </head>\r
755 <body>\r
756         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
757 \r
758 <?php\r
759         $aAllErrors = array_merge($aSkinErrors, $aPlugErrors);\r
760 \r
761         if (count($aAllErrors) > 0) {\r
762                 echo '<h1>' . _TITLE2 . '</h1>';\r
763                 echo '<ul><li>' . implode('</li><li>', $aAllErrors) . '</li></ul>';\r
764         }\r
765 \r
766         if (!$bConfigWritten) { ?>\r
767                 <h1><?php echo _TITLE3; ?></h1>\r
768 \r
769                 <? echo _TEXT10; ?>\r
770 \r
771                 <pre><code>&lt;?php\r
772         // mySQL connection information\r
773         $MYSQL_HOST = '<b><?php echo $mysql_host?></b>';\r
774         $MYSQL_USER = '<b><?php echo $mysql_user?></b>';\r
775         $MYSQL_PASSWORD = '<i><b>xxxxxxxxxxx</b></i>';\r
776         $MYSQL_DATABASE = '<b><?php echo $mysql_database?></b>';\r
777         $MYSQL_PREFIX = '<b><?php echo ($mysql_usePrefix == 1)?$mysql_prefix:''?></b>';\r
778 \r
779         // main nucleus directory\r
780         $DIR_NUCLEUS = '<b><?php echo $config_adminpath?></b>';\r
781 \r
782         // path to media dir\r
783         $DIR_MEDIA = '<b><?php echo $config_mediapath?></b>';\r
784 \r
785         // extra skin files for imported skins\r
786         $DIR_SKINS = '<b><?php echo $config_skinspath?></b>';\r
787 \r
788         // these dirs are normally sub dirs of the nucleus dir, but\r
789         // you can redefine them if you wish\r
790         $DIR_PLUGINS = $DIR_NUCLEUS . 'plugins/';\r
791         $DIR_LANG = $DIR_NUCLEUS . 'language/';\r
792         $DIR_LIBS = $DIR_NUCLEUS . 'libs/';\r
793 \r
794         // include libs\r
795         include($DIR_LIBS.'globalfunctions.php');\r
796         if (!extension_loaded('mbstring')) {\r
797                 include($DIR_LIBS.'mb_emulator/mb-emulator.php');\r
798         }\r
799 ?&gt;</code></pre>\r
800 \r
801         <?php echo _TEXT11; ?>\r
802 \r
803         <div class="note">\r
804         <?php echo _TEXT12; ?>\r
805         </div>\r
806 \r
807 <?php } else { ?>\r
808 \r
809         <h1><?php echo _TITLE4; ?></h1>\r
810 \r
811         <?php echo _TEXT13; ?>\r
812 \r
813 <?php } ?>\r
814 \r
815         <h1><?php echo _TITLE5; ?></h1>\r
816         \r
817         <?php echo _TEXT14; ?>\r
818 \r
819         <ul>\r
820                 <li><?php echo _TEXT14_L1; ?></li>\r
821                 <li><?php echo _TEXT14_L2; ?></li>\r
822         </ul>\r
823 \r
824         <p>もしこれらのファイルを削除していなければ、管理領域を開くことが出来ません。</p>\r
825 \r
826         <h1><?php echo _HEADER10; ?></h1>\r
827 \r
828         <?php echo _TEXT15; ?>\r
829                 <ul>\r
830                 <li><?php echo _TEXT15_L1; ?></li>\r
831                 <li><?php echo _TEXT15_L2; ?></li>\r
832                 </ul>\r
833 \r
834         <?php echo _TEXT16; ?>\r
835 \r
836         <h1><?php echo _HEADER11; ?></h1>\r
837 \r
838         <p><?php echo _TEXT16; ?>\r
839                 <ul>\r
840                         <li><a href="<?php echo $config_adminurl?>"><?php echo _TEXT16_L1; ?></a></li>\r
841                         <li><a href="<?php echo $config_indexurl?>"><?php echo _TEXT16_L2; ?></a></li>\r
842                 </ul>\r
843         </p>\r
844 \r
845 </body>\r
846 </html>\r
847 \r
848 <?php\r
849 }\r
850 \r
851 function installCustomPlugs(&$manager) {\r
852         global $aConfPlugsToInstall, $DIR_LIBS;\r
853 \r
854         $aErrors = array();\r
855 \r
856         if (count($aConfPlugsToInstall) == 0) {\r
857                 return $aErrors;\r
858         }\r
859 \r
860         $res = sql_query('SELECT * FROM ' . sql_table('plugin') );\r
861         $numCurrent = mysql_num_rows($res);\r
862 \r
863         foreach ($aConfPlugsToInstall as $plugName) {\r
864                 // do this before calling getPlugin (in case the plugin id is used there)\r
865                 $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . (++$numCurrent) . ', "' . addslashes($plugName) . '")';\r
866                 sql_query($query);\r
867 \r
868                 // get and install the plugin\r
869                 $manager->clearCachedInfo('installedPlugins');\r
870                 $plugin =& $manager->getPlugin($plugName);\r
871                 $plugin->plugid = $numCurrent;\r
872 \r
873                 if (!$plugin) {\r
874                         sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\'');\r
875                         $numCurrent--;\r
876                         array_push($aErrors, _ERROR22 . $plugName);\r
877                         continue;\r
878                 }\r
879 \r
880                 $plugin->install();\r
881         }\r
882 \r
883         // SYNC PLUGIN EVENT LIST\r
884         sql_query('DELETE FROM ' . sql_table('plugin_event') );\r
885 \r
886         // loop over all installed plugins\r
887         $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin') );\r
888 \r
889         while($o = mysql_fetch_object($res) ) {\r
890                 $pid = $o->pid;\r
891                 $plug =& $manager->getPlugin($o->pfile);\r
892 \r
893                 if ($plug) {\r
894                         $eventList = $plug->getEventList();\r
895 \r
896                         foreach ($eventList as $eventName) {\r
897                                 sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')');\r
898                         }\r
899                 }\r
900         }\r
901 \r
902         return $aErrors;\r
903 }\r
904 \r
905 function installCustomSkins(&$manager) {\r
906         global $aConfSkinsToImport, $DIR_LIBS, $DIR_SKINS;\r
907 \r
908         $aErrors = array();\r
909 \r
910         if (count($aConfSkinsToImport) == 0) {\r
911                 return $aErrors;\r
912         }\r
913 \r
914         // load skinie class\r
915         include_once($DIR_LIBS . 'skinie.php');\r
916 \r
917         $importer = new SKINIMPORT();\r
918 \r
919         foreach ($aConfSkinsToImport as $skinName) {\r
920                 $importer->reset();\r
921                 $skinFile = $DIR_SKINS . $skinName . '/skinbackup.xml';\r
922 \r
923                 if (!@file_exists($skinFile) ) {\r
924                         array_push($aErrors, _ERROR23_1 . $skinFile . ' : ' . _ERROR23_2);\r
925                         continue;\r
926                 }\r
927 \r
928                 $error = $importer->readFile($skinFile);\r
929 \r
930                 if ($error) {\r
931                         array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);\r
932                         continue;\r
933                 }\r
934 \r
935                 $error = $importer->writeToDatabase(1);\r
936 \r
937                 if ($error) {\r
938                         array_push($aErrors, _ERROR24 . $skinName . ' : ' . $error);\r
939                         continue;\r
940                 }\r
941         }\r
942 \r
943         return $aErrors;\r
944 }\r
945 \r
946 // give an error if one or more nucleus are not accessible\r
947 function doCheckFiles() {\r
948         $missingfiles = array();\r
949         $files = array(\r
950                 'install.sql',\r
951                 'index.php',\r
952                 'action.php',\r
953                 'nucleus/index.php',\r
954                 'nucleus/libs/globalfunctions.php',\r
955                 'nucleus/libs/ADMIN.php',\r
956                 'nucleus/libs/BLOG.php',\r
957                 'nucleus/libs/COMMENT.php',\r
958                 'nucleus/libs/COMMENTS.php',\r
959                 'nucleus/libs/ITEM.php',\r
960                 'nucleus/libs/MEMBER.php',\r
961                 'nucleus/libs/SKIN.php',\r
962                 'nucleus/libs/TEMPLATE.php',\r
963                 'nucleus/libs/MEDIA.php',\r
964                 'nucleus/libs/ACTIONLOG.php',\r
965                 'nucleus/media.php'\r
966                 );\r
967 \r
968         $count = count($files);\r
969 \r
970         for ($i = 0; $i < $count; $i++) {\r
971                 if (!is_readable($files[$i]) ) {\r
972                         array_push($missingfiles, _ERROR25_1 . $files[$i] . _ERROR25_2);\r
973                 }\r
974         }\r
975 \r
976 // The above code replaces several if statements of the form:\r
977 \r
978 //      if (!is_readable('install.sql') ) {\r
979 //              array_push($missingfiles, 'File <b>install.sql</b> is missing or not readable');\r
980 //      }\r
981 \r
982         if (count($missingfiles) > 0) {\r
983                 showErrorMessages($missingfiles);\r
984         }\r
985 }\r
986 \r
987 function updateConfig($name, $val) {\r
988         $name = addslashes($name);\r
989         $val = trim(addslashes($val) );\r
990 \r
991         $query = 'UPDATE ' . tableName('nucleus_config')\r
992                         . " SET value='$val'"\r
993                         . " WHERE name='$name'";\r
994 \r
995         mysql_query($query) or _doError(_ERROR26 . ': ' . mysql_error() );\r
996         return mysql_insert_id();\r
997 }\r
998 \r
999 function replaceDoubleBackslash($input) {\r
1000         return str_replace('\\', '/', $input);\r
1001 }\r
1002 \r
1003 function endsWithSlash($s) {\r
1004         return (strrpos($s, '/') == strlen($s) - 1);\r
1005 }\r
1006 \r
1007 /**\r
1008  * Checks if email address is valid\r
1009  */\r
1010 function _isValidMailAddress($address) {\r
1011         if (preg_match("/^[a-zA-Z0-9\._-]+@+[A-Za-z0-9\._-]+\.+[A-Za-z]{2,4}$/", $address) ) {\r
1012                 return 1;\r
1013         } else {\r
1014                 return 0;\r
1015         }\r
1016 }\r
1017 \r
1018 // returns true if the given string is a valid shortname\r
1019 // (to check short blog names and nicknames)\r
1020 // logic: starts and ends with a non space, can contain spaces in between\r
1021 //        min 2 chars\r
1022 function _isValidShortName($name) {\r
1023         if (eregi("^[a-z0-9]+$", $name) ) {\r
1024                 return 1;\r
1025         } else {\r
1026                 return 0;\r
1027         }\r
1028 }\r
1029 \r
1030 \r
1031 \r
1032 // returns true if the given string is a valid display name\r
1033 // (to check nicknames)\r
1034 function _isValidDisplayName($name) {\r
1035         if (eregi("^[a-z0-9]+[a-z0-9 ]*[a-z0-9]+$", $name) ) {\r
1036                 return 1;\r
1037         } else {\r
1038                 return 0;\r
1039         }\r
1040 }\r
1041 \r
1042 function _doError($msg) {\r
1043         ?>\r
1044 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
1045 <html xmlns="http://www.w3.org/1999/xhtml">\r
1046 <head>\r
1047         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
1048         <title><?php echo _TITLE; ?></title>\r
1049         <style>@import url('nucleus/styles/manual.css');</style>\r
1050 </head>\r
1051 <body>\r
1052         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
1053         <h1><?php echo _ERROR27; ?></h1>\r
1054 \r
1055         <p><?php echo _ERROR28; ?>: "<?php echo $msg?>";</p>\r
1056 \r
1057         <p><a href="install.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>\r
1058 </body>\r
1059 </html>\r
1060 \r
1061 <?php\r
1062         exit;\r
1063 }\r
1064 \r
1065 function showErrorMessages($errors) {\r
1066         ?>\r
1067 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
1068 <html xmlns="http://www.w3.org/1999/xhtml">\r
1069 <head>\r
1070         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
1071         <title><?php echo _TITLE; ?></title>\r
1072         <style>@import url('nucleus/styles/manual.css');</style>\r
1073 </head>\r
1074 <body>\r
1075         <div style='text-align:center'><img src='./nucleus/styles/logo.gif' /></div> <!-- Nucleus logo -->\r
1076         <h1><?php echo _ERROR27; ?></h1>\r
1077 \r
1078         <p><?php echo _ERROR29; ?>:</p>\r
1079 \r
1080         <ul>\r
1081 \r
1082 <?php\r
1083         while($msg = array_shift($errors) ) {\r
1084                 echo '<li>', $msg, '</li>';\r
1085         }\r
1086 ?>\r
1087 \r
1088         </ul>\r
1089 \r
1090         <p><a href="install.php" onclick="history.back();return false;"><?php echo _TEXT17; ?></a></p>\r
1091 </body>\r
1092 </html>\r
1093 \r
1094 <?php\r
1095         exit;\r
1096 }\r
1097 \r
1098 /* for the non-php systems that decide to show the contents:\r
1099 ?></div><?php   */\r
1100 \r
1101 ?>\r