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