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