[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * @package install 5 * @version $Id$ 6 * @copyright (c) 2005 phpBB Group 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License 8 * 9 */ 10 11 /** 12 */ 13 if (!defined('IN_INSTALL')) 14 { 15 // Someone has tried to access the file direct. This is not a good idea, so exit 16 exit; 17 } 18 19 if (!empty($setmodules)) 20 { 21 // If phpBB is already installed we do not include this module 22 if (@file_exists($phpbb_root_path . 'config.' . $phpEx) && !file_exists($phpbb_root_path . 'cache/install_lock')) 23 { 24 include_once($phpbb_root_path . 'config.' . $phpEx); 25 26 if (defined('PHPBB_INSTALLED')) 27 { 28 return; 29 } 30 } 31 32 $module[] = array( 33 'module_type' => 'install', 34 'module_title' => 'INSTALL', 35 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), 36 'module_order' => 10, 37 'module_subs' => '', 38 'module_stages' => array('INTRO', 'REQUIREMENTS', 'DATABASE', 'ADMINISTRATOR', 'CONFIG_FILE', 'ADVANCED', 'CREATE_TABLE', 'FINAL'), 39 'module_reqs' => '' 40 ); 41 } 42 43 /** 44 * Installation 45 * @package install 46 */ 47 class install_install extends module 48 { 49 function install_install(&$p_master) 50 { 51 $this->p_master = &$p_master; 52 } 53 54 function main($mode, $sub) 55 { 56 global $lang, $template, $language, $phpbb_root_path, $cache; 57 58 switch ($sub) 59 { 60 case 'intro': 61 $cache->purge(); 62 63 $this->page_title = $lang['SUB_INTRO']; 64 65 $template->assign_vars(array( 66 'TITLE' => $lang['INSTALL_INTRO'], 67 'BODY' => $lang['INSTALL_INTRO_BODY'], 68 'L_SUBMIT' => $lang['NEXT_STEP'], 69 'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>', 70 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language", 71 )); 72 73 break; 74 75 case 'requirements': 76 $this->check_server_requirements($mode, $sub); 77 78 break; 79 80 case 'database': 81 $this->obtain_database_settings($mode, $sub); 82 83 break; 84 85 case 'administrator': 86 $this->obtain_admin_settings($mode, $sub); 87 88 break; 89 90 case 'config_file': 91 $this->create_config_file($mode, $sub); 92 93 break; 94 95 case 'advanced': 96 $this->obtain_advanced_settings($mode, $sub); 97 98 break; 99 100 case 'create_table': 101 $this->load_schema($mode, $sub); 102 break; 103 104 case 'final': 105 $this->build_search_index($mode, $sub); 106 $this->add_modules($mode, $sub); 107 $this->add_language($mode, $sub); 108 $this->add_bots($mode, $sub); 109 $this->email_admin($mode, $sub); 110 $this->disable_avatars_if_unwritable(); 111 112 // Remove the lock file 113 @unlink($phpbb_root_path . 'cache/install_lock'); 114 115 break; 116 } 117 118 $this->tpl_name = 'install_install'; 119 } 120 121 /** 122 * Checks that the server we are installing on meets the requirements for running phpBB 123 */ 124 function check_server_requirements($mode, $sub) 125 { 126 global $lang, $template, $phpbb_root_path, $phpEx, $language; 127 128 $this->page_title = $lang['STAGE_REQUIREMENTS']; 129 130 $template->assign_vars(array( 131 'TITLE' => $lang['REQUIREMENTS_TITLE'], 132 'BODY' => $lang['REQUIREMENTS_EXPLAIN'], 133 )); 134 135 $passed = array('php' => false, 'db' => false, 'files' => false, 'pcre' => false, 'imagesize' => false,); 136 137 // Test for basic PHP settings 138 $template->assign_block_vars('checks', array( 139 'S_LEGEND' => true, 140 'LEGEND' => $lang['PHP_SETTINGS'], 141 'LEGEND_EXPLAIN' => $lang['PHP_SETTINGS_EXPLAIN'], 142 )); 143 144 // Test the minimum PHP version 145 $php_version = PHP_VERSION; 146 147 if (version_compare($php_version, '4.3.3') < 0) 148 { 149 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 150 } 151 else 152 { 153 $passed['php'] = true; 154 155 // We also give feedback on whether we're running in safe mode 156 $result = '<strong style="color:green">' . $lang['YES']; 157 if (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on') 158 { 159 $result .= ', ' . $lang['PHP_SAFE_MODE']; 160 } 161 $result .= '</strong>'; 162 } 163 164 $template->assign_block_vars('checks', array( 165 'TITLE' => $lang['PHP_VERSION_REQD'], 166 'RESULT' => $result, 167 168 'S_EXPLAIN' => false, 169 'S_LEGEND' => false, 170 )); 171 172 // Don't check for register_globals on 5.4+ 173 if (version_compare($php_version, '5.4.0-dev') < 0) 174 { 175 // Check for register_globals being enabled 176 if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on') 177 { 178 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 179 } 180 else 181 { 182 $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; 183 } 184 185 $template->assign_block_vars('checks', array( 186 'TITLE' => $lang['PHP_REGISTER_GLOBALS'], 187 'TITLE_EXPLAIN' => $lang['PHP_REGISTER_GLOBALS_EXPLAIN'], 188 'RESULT' => $result, 189 190 'S_EXPLAIN' => true, 191 'S_LEGEND' => false, 192 )); 193 } 194 195 // Check for url_fopen 196 if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on') 197 { 198 $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; 199 } 200 else 201 { 202 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 203 } 204 205 $template->assign_block_vars('checks', array( 206 'TITLE' => $lang['PHP_URL_FOPEN_SUPPORT'], 207 'TITLE_EXPLAIN' => $lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'], 208 'RESULT' => $result, 209 210 'S_EXPLAIN' => true, 211 'S_LEGEND' => false, 212 )); 213 214 215 // Check for getimagesize 216 if (@function_exists('getimagesize')) 217 { 218 $passed['imagesize'] = true; 219 $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; 220 } 221 else 222 { 223 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 224 } 225 226 $template->assign_block_vars('checks', array( 227 'TITLE' => $lang['PHP_GETIMAGESIZE_SUPPORT'], 228 'TITLE_EXPLAIN' => $lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'], 229 'RESULT' => $result, 230 231 'S_EXPLAIN' => true, 232 'S_LEGEND' => false, 233 )); 234 235 // Check for PCRE UTF-8 support 236 if (@preg_match('//u', '')) 237 { 238 $passed['pcre'] = true; 239 $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; 240 } 241 else 242 { 243 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 244 } 245 246 $template->assign_block_vars('checks', array( 247 'TITLE' => $lang['PCRE_UTF_SUPPORT'], 248 'TITLE_EXPLAIN' => $lang['PCRE_UTF_SUPPORT_EXPLAIN'], 249 'RESULT' => $result, 250 251 'S_EXPLAIN' => true, 252 'S_LEGEND' => false, 253 )); 254 255 /** 256 * Better not enabling and adding to the loaded extensions due to the specific requirements needed 257 if (!@extension_loaded('mbstring')) 258 { 259 can_load_dll('mbstring'); 260 } 261 */ 262 263 $passed['mbstring'] = true; 264 if (@extension_loaded('mbstring')) 265 { 266 // Test for available database modules 267 $template->assign_block_vars('checks', array( 268 'S_LEGEND' => true, 269 'LEGEND' => $lang['MBSTRING_CHECK'], 270 'LEGEND_EXPLAIN' => $lang['MBSTRING_CHECK_EXPLAIN'], 271 )); 272 273 $checks = array( 274 array('func_overload', '&', MB_OVERLOAD_MAIL|MB_OVERLOAD_STRING), 275 array('encoding_translation', '!=', 0), 276 array('http_input', '!=', 'pass'), 277 array('http_output', '!=', 'pass') 278 ); 279 280 foreach ($checks as $mb_checks) 281 { 282 $ini_val = @ini_get('mbstring.' . $mb_checks[0]); 283 switch ($mb_checks[1]) 284 { 285 case '&': 286 if (intval($ini_val) & $mb_checks[2]) 287 { 288 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 289 $passed['mbstring'] = false; 290 } 291 else 292 { 293 $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; 294 } 295 break; 296 297 case '!=': 298 if ($ini_val != $mb_checks[2]) 299 { 300 $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; 301 $passed['mbstring'] = false; 302 } 303 else 304 { 305 $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; 306 } 307 break; 308 } 309 $template->assign_block_vars('checks', array( 310 'TITLE' => $lang['MBSTRING_' . strtoupper($mb_checks[0])], 311 'TITLE_EXPLAIN' => $lang['MBSTRING_' . strtoupper($mb_checks[0]) . '_EXPLAIN'], 312 'RESULT' => $result, 313 314 'S_EXPLAIN' => true, 315 'S_LEGEND' => false, 316 )); 317 } 318 } 319 320 // Test for available database modules 321 $template->assign_block_vars('checks', array( 322 'S_LEGEND' => true, 323 'LEGEND' => $lang['PHP_SUPPORTED_DB'], 324 'LEGEND_EXPLAIN' => $lang['PHP_SUPPORTED_DB_EXPLAIN'], 325 )); 326 327 $available_dbms = get_available_dbms(false, true); 328 $passed['db'] = $available_dbms['ANY_DB_SUPPORT']; 329 unset($available_dbms['ANY_DB_SUPPORT']); 330 331 foreach ($available_dbms as $db_name => $db_ary) 332 { 333 if (!$db_ary['AVAILABLE']) 334 { 335 $template->assign_block_vars('checks', array( 336 'TITLE' => $lang['DLL_' . strtoupper($db_name)], 337 'RESULT' => '<span style="color:red">' . $lang['UNAVAILABLE'] . '</span>', 338 339 'S_EXPLAIN' => false, 340 'S_LEGEND' => false, 341 )); 342 } 343 else 344 { 345 $template->assign_block_vars('checks', array( 346 'TITLE' => $lang['DLL_' . strtoupper($db_name)], 347 'RESULT' => '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>', 348 349 'S_EXPLAIN' => false, 350 'S_LEGEND' => false, 351 )); 352 } 353 } 354 355 // Test for other modules 356 $template->assign_block_vars('checks', array( 357 'S_LEGEND' => true, 358 'LEGEND' => $lang['PHP_OPTIONAL_MODULE'], 359 'LEGEND_EXPLAIN' => $lang['PHP_OPTIONAL_MODULE_EXPLAIN'], 360 )); 361 362 foreach ($this->php_dlls_other as $dll) 363 { 364 if (!@extension_loaded($dll)) 365 { 366 if (!can_load_dll($dll)) 367 { 368 $template->assign_block_vars('checks', array( 369 'TITLE' => $lang['DLL_' . strtoupper($dll)], 370 'RESULT' => '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>', 371 372 'S_EXPLAIN' => false, 373 'S_LEGEND' => false, 374 )); 375 continue; 376 } 377 } 378 379 $template->assign_block_vars('checks', array( 380 'TITLE' => $lang['DLL_' . strtoupper($dll)], 381 'RESULT' => '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>', 382 383 'S_EXPLAIN' => false, 384 'S_LEGEND' => false, 385 )); 386 } 387 388 // Can we find Imagemagick anywhere on the system? 389 $exe = (DIRECTORY_SEPARATOR == '\\') ? '.exe' : ''; 390 391 $magic_home = getenv('MAGICK_HOME'); 392 $img_imagick = ''; 393 if (empty($magic_home)) 394 { 395 $locations = array('C:/WINDOWS/', 'C:/WINNT/', 'C:/WINDOWS/SYSTEM/', 'C:/WINNT/SYSTEM/', 'C:/WINDOWS/SYSTEM32/', 'C:/WINNT/SYSTEM32/', '/usr/bin/', '/usr/sbin/', '/usr/local/bin/', '/usr/local/sbin/', '/opt/', '/usr/imagemagick/', '/usr/bin/imagemagick/'); 396 $path_locations = str_replace('\\', '/', (explode(($exe) ? ';' : ':', getenv('PATH')))); 397 398 $locations = array_merge($path_locations, $locations); 399 foreach ($locations as $location) 400 { 401 // The path might not end properly, fudge it 402 if (substr($location, -1, 1) !== '/') 403 { 404 $location .= '/'; 405 } 406 407 if (@file_exists($location) && @is_readable($location . 'mogrify' . $exe) && @filesize($location . 'mogrify' . $exe) > 3000) 408 { 409 $img_imagick = str_replace('\\', '/', $location); 410 continue; 411 } 412 } 413 } 414 else 415 { 416 $img_imagick = str_replace('\\', '/', $magic_home); 417 } 418 419 $template->assign_block_vars('checks', array( 420 'TITLE' => $lang['APP_MAGICK'], 421 'RESULT' => ($img_imagick) ? '<strong style="color:green">' . $lang['AVAILABLE'] . ', ' . $img_imagick . '</strong>' : '<strong style="color:blue">' . $lang['NO_LOCATION'] . '</strong>', 422 423 'S_EXPLAIN' => false, 424 'S_LEGEND' => false, 425 )); 426 427 // Check permissions on files/directories we need access to 428 $template->assign_block_vars('checks', array( 429 'S_LEGEND' => true, 430 'LEGEND' => $lang['FILES_REQUIRED'], 431 'LEGEND_EXPLAIN' => $lang['FILES_REQUIRED_EXPLAIN'], 432 )); 433 434 $directories = array('cache/', 'files/', 'store/'); 435 436 umask(0); 437 438 $passed['files'] = true; 439 foreach ($directories as $dir) 440 { 441 $exists = $write = false; 442 443 // Try to create the directory if it does not exist 444 if (!file_exists($phpbb_root_path . $dir)) 445 { 446 @mkdir($phpbb_root_path . $dir, 0777); 447 phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE); 448 } 449 450 // Now really check 451 if (file_exists($phpbb_root_path . $dir) && is_dir($phpbb_root_path . $dir)) 452 { 453 phpbb_chmod($phpbb_root_path . $dir, CHMOD_READ | CHMOD_WRITE); 454 $exists = true; 455 } 456 457 // Now check if it is writable by storing a simple file 458 $fp = @fopen($phpbb_root_path . $dir . 'test_lock', 'wb'); 459 if ($fp !== false) 460 { 461 $write = true; 462 } 463 @fclose($fp); 464 465 @unlink($phpbb_root_path . $dir . 'test_lock'); 466 467 $passed['files'] = ($exists && $write && $passed['files']) ? true : false; 468 469 $exists = ($exists) ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>'; 470 $write = ($write) ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : ''); 471 472 $template->assign_block_vars('checks', array( 473 'TITLE' => $dir, 474 'RESULT' => $exists . $write, 475 476 'S_EXPLAIN' => false, 477 'S_LEGEND' => false, 478 )); 479 } 480 481 // Check permissions on files/directories it would be useful access to 482 $template->assign_block_vars('checks', array( 483 'S_LEGEND' => true, 484 'LEGEND' => $lang['FILES_OPTIONAL'], 485 'LEGEND_EXPLAIN' => $lang['FILES_OPTIONAL_EXPLAIN'], 486 )); 487 488 $directories = array('config.' . $phpEx, 'images/avatars/upload/'); 489 490 foreach ($directories as $dir) 491 { 492 $write = $exists = true; 493 if (file_exists($phpbb_root_path . $dir)) 494 { 495 if (!phpbb_is_writable($phpbb_root_path . $dir)) 496 { 497 $write = false; 498 } 499 } 500 else 501 { 502 $write = $exists = false; 503 } 504 505 $exists_str = ($exists) ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>'; 506 $write_str = ($write) ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : ''); 507 508 $template->assign_block_vars('checks', array( 509 'TITLE' => $dir, 510 'RESULT' => $exists_str . $write_str, 511 512 'S_EXPLAIN' => false, 513 'S_LEGEND' => false, 514 )); 515 } 516 517 // And finally where do we want to go next (well today is taken isn't it :P) 518 $s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : ''; 519 520 $url = (!in_array(false, $passed)) ? $this->p_master->module_url . "?mode=$mode&sub=database&language=$language" : $this->p_master->module_url . "?mode=$mode&sub=requirements&language=$language "; 521 $submit = (!in_array(false, $passed)) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST']; 522 523 524 $template->assign_vars(array( 525 'L_SUBMIT' => $submit, 526 'S_HIDDEN' => $s_hidden_fields, 527 'U_ACTION' => $url, 528 )); 529 } 530 531 /** 532 * Obtain the information required to connect to the database 533 */ 534 function obtain_database_settings($mode, $sub) 535 { 536 global $lang, $template, $phpEx; 537 538 $this->page_title = $lang['STAGE_DATABASE']; 539 540 // Obtain any submitted data 541 $data = $this->get_submitted_data(); 542 543 $connect_test = false; 544 $error = array(); 545 $available_dbms = get_available_dbms(false, true); 546 547 // Has the user opted to test the connection? 548 if (isset($_POST['testdb'])) 549 { 550 if (!isset($available_dbms[$data['dbms']]) || !$available_dbms[$data['dbms']]['AVAILABLE']) 551 { 552 $error[] = $lang['INST_ERR_NO_DB']; 553 $connect_test = false; 554 } 555 else if (!preg_match(get_preg_expression('table_prefix'), $data['table_prefix'])) 556 { 557 $error[] = $lang['INST_ERR_DB_INVALID_PREFIX']; 558 $connect_test = false; 559 } 560 else 561 { 562 $connect_test = connect_check_db(true, $error, $available_dbms[$data['dbms']], $data['table_prefix'], $data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport']); 563 } 564 565 $template->assign_block_vars('checks', array( 566 'S_LEGEND' => true, 567 'LEGEND' => $lang['DB_CONNECTION'], 568 'LEGEND_EXPLAIN' => false, 569 )); 570 571 if ($connect_test) 572 { 573 $template->assign_block_vars('checks', array( 574 'TITLE' => $lang['DB_TEST'], 575 'RESULT' => '<strong style="color:green">' . $lang['SUCCESSFUL_CONNECT'] . '</strong>', 576 577 'S_EXPLAIN' => false, 578 'S_LEGEND' => false, 579 )); 580 } 581 else 582 { 583 $template->assign_block_vars('checks', array( 584 'TITLE' => $lang['DB_TEST'], 585 'RESULT' => '<strong style="color:red">' . implode('<br />', $error) . '</strong>', 586 587 'S_EXPLAIN' => false, 588 'S_LEGEND' => false, 589 )); 590 } 591 } 592 593 if (!$connect_test) 594 { 595 // Update the list of available DBMS modules to only contain those which can be used 596 $available_dbms_temp = array(); 597 foreach ($available_dbms as $type => $dbms_ary) 598 { 599 if (!$dbms_ary['AVAILABLE']) 600 { 601 continue; 602 } 603 604 $available_dbms_temp[$type] = $dbms_ary; 605 } 606 607 $available_dbms = &$available_dbms_temp; 608 609 // And now for the main part of this page 610 $data['table_prefix'] = (!empty($data['table_prefix']) ? $data['table_prefix'] : 'phpbb_'); 611 612 foreach ($this->db_config_options as $config_key => $vars) 613 { 614 if (!is_array($vars) && strpos($config_key, 'legend') === false) 615 { 616 continue; 617 } 618 619 if (strpos($config_key, 'legend') !== false) 620 { 621 $template->assign_block_vars('options', array( 622 'S_LEGEND' => true, 623 'LEGEND' => $lang[$vars]) 624 ); 625 626 continue; 627 } 628 629 $options = isset($vars['options']) ? $vars['options'] : ''; 630 631 $template->assign_block_vars('options', array( 632 'KEY' => $config_key, 633 'TITLE' => $lang[$vars['lang']], 634 'S_EXPLAIN' => $vars['explain'], 635 'S_LEGEND' => false, 636 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '', 637 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options), 638 ) 639 ); 640 } 641 } 642 643 // And finally where do we want to go next (well today is taken isn't it :P) 644 $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; 645 $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />'; 646 if ($connect_test) 647 { 648 foreach ($this->db_config_options as $config_key => $vars) 649 { 650 if (!is_array($vars)) 651 { 652 continue; 653 } 654 $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />'; 655 } 656 } 657 658 $url = ($connect_test) ? $this->p_master->module_url . "?mode=$mode&sub=administrator" : $this->p_master->module_url . "?mode=$mode&sub=database"; 659 $s_hidden_fields .= ($connect_test) ? '' : '<input type="hidden" name="testdb" value="true" />'; 660 661 $submit = $lang['NEXT_STEP']; 662 663 $template->assign_vars(array( 664 'L_SUBMIT' => $submit, 665 'S_HIDDEN' => $s_hidden_fields, 666 'U_ACTION' => $url, 667 )); 668 } 669 670 /** 671 * Obtain the administrator's name, password and email address 672 */ 673 function obtain_admin_settings($mode, $sub) 674 { 675 global $lang, $template, $phpEx; 676 677 $this->page_title = $lang['STAGE_ADMINISTRATOR']; 678 679 // Obtain any submitted data 680 $data = $this->get_submitted_data(); 681 682 if ($data['dbms'] == '') 683 { 684 // Someone's been silly and tried calling this page direct 685 // So we send them back to the start to do it again properly 686 $this->p_master->redirect("index.$phpEx?mode=install"); 687 } 688 689 $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; 690 $passed = false; 691 692 $data['default_lang'] = ($data['default_lang'] !== '') ? $data['default_lang'] : $data['language']; 693 694 if (isset($_POST['check'])) 695 { 696 $error = array(); 697 698 // Check the entered email address and password 699 if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email1'] == '' || $data['board_email2'] == '') 700 { 701 $error[] = $lang['INST_ERR_MISSING_DATA']; 702 } 703 704 if ($data['admin_pass1'] != $data['admin_pass2'] && $data['admin_pass1'] != '') 705 { 706 $error[] = $lang['INST_ERR_PASSWORD_MISMATCH']; 707 } 708 709 // Test against the default username rules 710 if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) < 3) 711 { 712 $error[] = $lang['INST_ERR_USER_TOO_SHORT']; 713 } 714 715 if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) > 20) 716 { 717 $error[] = $lang['INST_ERR_USER_TOO_LONG']; 718 } 719 720 // Test against the default password rules 721 if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) < 6) 722 { 723 $error[] = $lang['INST_ERR_PASSWORD_TOO_SHORT']; 724 } 725 726 if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) > 30) 727 { 728 $error[] = $lang['INST_ERR_PASSWORD_TOO_LONG']; 729 } 730 731 if ($data['board_email1'] != $data['board_email2'] && $data['board_email1'] != '') 732 { 733 $error[] = $lang['INST_ERR_EMAIL_MISMATCH']; 734 } 735 736 if ($data['board_email1'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email1'])) 737 { 738 $error[] = $lang['INST_ERR_EMAIL_INVALID']; 739 } 740 741 $template->assign_block_vars('checks', array( 742 'S_LEGEND' => true, 743 'LEGEND' => $lang['STAGE_ADMINISTRATOR'], 744 'LEGEND_EXPLAIN' => false, 745 )); 746 747 if (!sizeof($error)) 748 { 749 $passed = true; 750 $template->assign_block_vars('checks', array( 751 'TITLE' => $lang['ADMIN_TEST'], 752 'RESULT' => '<strong style="color:green">' . $lang['TESTS_PASSED'] . '</strong>', 753 754 'S_EXPLAIN' => false, 755 'S_LEGEND' => false, 756 )); 757 } 758 else 759 { 760 $template->assign_block_vars('checks', array( 761 'TITLE' => $lang['ADMIN_TEST'], 762 'RESULT' => '<strong style="color:red">' . implode('<br />', $error) . '</strong>', 763 764 'S_EXPLAIN' => false, 765 'S_LEGEND' => false, 766 )); 767 } 768 } 769 770 if (!$passed) 771 { 772 foreach ($this->admin_config_options as $config_key => $vars) 773 { 774 if (!is_array($vars) && strpos($config_key, 'legend') === false) 775 { 776 continue; 777 } 778 779 if (strpos($config_key, 'legend') !== false) 780 { 781 $template->assign_block_vars('options', array( 782 'S_LEGEND' => true, 783 'LEGEND' => $lang[$vars]) 784 ); 785 786 continue; 787 } 788 789 $options = isset($vars['options']) ? $vars['options'] : ''; 790 791 $template->assign_block_vars('options', array( 792 'KEY' => $config_key, 793 'TITLE' => $lang[$vars['lang']], 794 'S_EXPLAIN' => $vars['explain'], 795 'S_LEGEND' => false, 796 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '', 797 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options), 798 ) 799 ); 800 } 801 } 802 else 803 { 804 foreach ($this->admin_config_options as $config_key => $vars) 805 { 806 if (!is_array($vars)) 807 { 808 continue; 809 } 810 $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />'; 811 } 812 } 813 814 $s_hidden_fields .= ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; 815 $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />'; 816 817 foreach ($this->db_config_options as $config_key => $vars) 818 { 819 if (!is_array($vars)) 820 { 821 continue; 822 } 823 $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />'; 824 } 825 826 $submit = $lang['NEXT_STEP']; 827 828 $url = ($passed) ? $this->p_master->module_url . "?mode=$mode&sub=config_file" : $this->p_master->module_url . "?mode=$mode&sub=administrator"; 829 $s_hidden_fields .= ($passed) ? '' : '<input type="hidden" name="check" value="true" />'; 830 831 $template->assign_vars(array( 832 'L_SUBMIT' => $submit, 833 'S_HIDDEN' => $s_hidden_fields, 834 'U_ACTION' => $url, 835 )); 836 } 837 838 /** 839 * Writes the config file to disk, or if unable to do so offers alternative methods 840 */ 841 function create_config_file($mode, $sub) 842 { 843 global $lang, $template, $phpbb_root_path, $phpEx; 844 845 $this->page_title = $lang['STAGE_CONFIG_FILE']; 846 847 // Obtain any submitted data 848 $data = $this->get_submitted_data(); 849 850 if ($data['dbms'] == '') 851 { 852 // Someone's been silly and tried calling this page direct 853 // So we send them back to the start to do it again properly 854 $this->p_master->redirect("index.$phpEx?mode=install"); 855 } 856 857 $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; 858 $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />'; 859 $written = false; 860 861 // Create a list of any PHP modules we wish to have loaded 862 $load_extensions = array(); 863 $available_dbms = get_available_dbms($data['dbms']); 864 $check_exts = array_merge(array($available_dbms[$data['dbms']]['MODULE']), $this->php_dlls_other); 865 866 foreach ($check_exts as $dll) 867 { 868 if (!@extension_loaded($dll)) 869 { 870 if (!can_load_dll($dll)) 871 { 872 continue; 873 } 874 875 $load_extensions[] = $dll . '.' . PHP_SHLIB_SUFFIX; 876 } 877 } 878 879 // Create a lock file to indicate that there is an install in progress 880 $fp = @fopen($phpbb_root_path . 'cache/install_lock', 'wb'); 881 if ($fp === false) 882 { 883 // We were unable to create the lock file - abort 884 $this->p_master->error($lang['UNABLE_WRITE_LOCK'], __LINE__, __FILE__); 885 } 886 @fclose($fp); 887 888 @chmod($phpbb_root_path . 'cache/install_lock', 0777); 889 890 // Time to convert the data provided into a config file 891 $config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER'], $load_extensions); 892 893 // Attempt to write out the config file directly. If it works, this is the easiest way to do it ... 894 if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path)) 895 { 896 // Assume it will work ... if nothing goes wrong below 897 $written = true; 898 899 if (!($fp = @fopen($phpbb_root_path . 'config.' . $phpEx, 'w'))) 900 { 901 // Something went wrong ... so let's try another method 902 $written = false; 903 } 904 905 if (!(@fwrite($fp, $config_data))) 906 { 907 // Something went wrong ... so let's try another method 908 $written = false; 909 } 910 911 @fclose($fp); 912 913 if ($written) 914 { 915 // We may revert back to chmod() if we see problems with users not able to change their config.php file directly 916 phpbb_chmod($phpbb_root_path . 'config.' . $phpEx, CHMOD_READ); 917 } 918 } 919 920 if (isset($_POST['dldone'])) 921 { 922 // Do a basic check to make sure that the file has been uploaded 923 // Note that all we check is that the file has _something_ in it 924 // We don't compare the contents exactly - if they can't upload 925 // a single file correctly, it's likely they will have other problems.... 926 if (filesize($phpbb_root_path . 'config.' . $phpEx) > 10) 927 { 928 $written = true; 929 } 930 } 931 932 $config_options = array_merge($this->db_config_options, $this->admin_config_options); 933 934 foreach ($config_options as $config_key => $vars) 935 { 936 if (!is_array($vars)) 937 { 938 continue; 939 } 940 $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />'; 941 } 942 943 if (!$written) 944 { 945 // OK, so it didn't work let's try the alternatives 946 947 if (isset($_POST['dlconfig'])) 948 { 949 // They want a copy of the file to download, so send the relevant headers and dump out the data 950 header("Content-Type: text/x-delimtext; name=\"config.$phpEx\""); 951 header("Content-disposition: attachment; filename=config.$phpEx"); 952 echo $config_data; 953 exit; 954 } 955 956 // The option to download the config file is always available, so output it here 957 $template->assign_vars(array( 958 'BODY' => $lang['CONFIG_FILE_UNABLE_WRITE'], 959 'L_DL_CONFIG' => $lang['DL_CONFIG'], 960 'L_DL_CONFIG_EXPLAIN' => $lang['DL_CONFIG_EXPLAIN'], 961 'L_DL_DONE' => $lang['DONE'], 962 'L_DL_DOWNLOAD' => $lang['DL_DOWNLOAD'], 963 'S_HIDDEN' => $s_hidden_fields, 964 'S_SHOW_DOWNLOAD' => true, 965 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&sub=config_file", 966 )); 967 return; 968 } 969 else 970 { 971 $template->assign_vars(array( 972 'BODY' => $lang['CONFIG_FILE_WRITTEN'], 973 'L_SUBMIT' => $lang['NEXT_STEP'], 974 'S_HIDDEN' => $s_hidden_fields, 975 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&sub=advanced", 976 )); 977 return; 978 } 979 } 980 981 /** 982 * Provide an opportunity to customise some advanced settings during the install 983 * in case it is necessary for them to be set to access later 984 */ 985 function obtain_advanced_settings($mode, $sub) 986 { 987 global $lang, $template, $phpEx; 988 989 $this->page_title = $lang['STAGE_ADVANCED']; 990 991 // Obtain any submitted data 992 $data = $this->get_submitted_data(); 993 994 if ($data['dbms'] == '') 995 { 996 // Someone's been silly and tried calling this page direct 997 // So we send them back to the start to do it again properly 998 $this->p_master->redirect("index.$phpEx?mode=install"); 999 } 1000 1001 $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : ''; 1002 $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />'; 1003 1004 // HTTP_HOST is having the correct browser url in most cases... 1005 $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); 1006 1007 // HTTP HOST can carry a port number... 1008 if (strpos($server_name, ':') !== false) 1009 { 1010 $server_name = substr($server_name, 0, strpos($server_name, ':')); 1011 } 1012 1013 $data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true; 1014 $data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name; 1015 $data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT')); 1016 $data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'); 1017 $data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false); 1018 1019 if ($data['script_path'] === '') 1020 { 1021 $name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF'); 1022 if (!$name) 1023 { 1024 $name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI'); 1025 } 1026 1027 // Replace backslashes and doubled slashes (could happen on some proxy setups) 1028 $name = str_replace(array('\\', '//'), '/', $name); 1029 $data['script_path'] = trim(dirname(dirname($name))); 1030 } 1031 1032 foreach ($this->advanced_config_options as $config_key => $vars) 1033 { 1034 if (!is_array($vars) && strpos($config_key, 'legend') === false) 1035 { 1036 continue; 1037 } 1038 1039 if (strpos($config_key, 'legend') !== false) 1040 { 1041 $template->assign_block_vars('options', array( 1042 'S_LEGEND' => true, 1043 'LEGEND' => $lang[$vars]) 1044 ); 1045 1046 continue; 1047 } 1048 1049 $options = isset($vars['options']) ? $vars['options'] : ''; 1050 1051 $template->assign_block_vars('options', array( 1052 'KEY' => $config_key, 1053 'TITLE' => $lang[$vars['lang']], 1054 'S_EXPLAIN' => $vars['explain'], 1055 'S_LEGEND' => false, 1056 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '', 1057 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options), 1058 ) 1059 ); 1060 } 1061 1062 $config_options = array_merge($this->db_config_options, $this->admin_config_options); 1063 foreach ($config_options as $config_key => $vars) 1064 { 1065 if (!is_array($vars)) 1066 { 1067 continue; 1068 } 1069 $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />'; 1070 } 1071 1072 $submit = $lang['NEXT_STEP']; 1073 1074 $url = $this->p_master->module_url . "?mode=$mode&sub=create_table"; 1075 1076 $template->assign_vars(array( 1077 'BODY' => $lang['STAGE_ADVANCED_EXPLAIN'], 1078 'L_SUBMIT' => $submit, 1079 'S_HIDDEN' => $s_hidden_fields, 1080 'U_ACTION' => $url, 1081 )); 1082 } 1083 1084 /** 1085 * Load the contents of the schema into the database and then alter it based on what has been input during the installation 1086 */ 1087 function load_schema($mode, $sub) 1088 { 1089 global $db, $lang, $template, $phpbb_root_path, $phpEx; 1090 1091 $this->page_title = $lang['STAGE_CREATE_TABLE']; 1092 $s_hidden_fields = ''; 1093 1094 // Obtain any submitted data 1095 $data = $this->get_submitted_data(); 1096 1097 if ($data['dbms'] == '') 1098 { 1099 // Someone's been silly and tried calling this page direct 1100 // So we send them back to the start to do it again properly 1101 $this->p_master->redirect("index.$phpEx?mode=install"); 1102 } 1103 1104 // HTTP_HOST is having the correct browser url in most cases... 1105 $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); 1106 $referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER'); 1107 1108 // HTTP HOST can carry a port number... 1109 if (strpos($server_name, ':') !== false) 1110 { 1111 $server_name = substr($server_name, 0, strpos($server_name, ':')); 1112 } 1113 1114 $cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name; 1115 1116 // Try to come up with the best solution for cookie domain... 1117 if (strpos($cookie_domain, 'www.') === 0) 1118 { 1119 $cookie_domain = str_replace('www.', '.', $cookie_domain); 1120 } 1121 1122 // If we get here and the extension isn't loaded it should be safe to just go ahead and load it 1123 $available_dbms = get_available_dbms($data['dbms']); 1124 1125 if (!isset($available_dbms[$data['dbms']])) 1126 { 1127 // Someone's been silly and tried providing a non-existant dbms 1128 $this->p_master->redirect("index.$phpEx?mode=install"); 1129 } 1130 1131 $dbms = $available_dbms[$data['dbms']]['DRIVER']; 1132 1133 // Load the appropriate database class if not already loaded 1134 include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); 1135 1136 // Instantiate the database 1137 $db = new $sql_db(); 1138 $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); 1139 1140 // NOTE: trigger_error does not work here. 1141 $db->sql_return_on_error(true); 1142 1143 // If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;) 1144 if ($data['dbms'] == 'mysql') 1145 { 1146 if (version_compare($db->sql_server_info(true), '4.1.3', '>=')) 1147 { 1148 $available_dbms[$data['dbms']]['SCHEMA'] .= '_41'; 1149 } 1150 else 1151 { 1152 $available_dbms[$data['dbms']]['SCHEMA'] .= '_40'; 1153 } 1154 } 1155 1156 // Ok we have the db info go ahead and read in the relevant schema 1157 // and work on building the table 1158 $dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql'; 1159 1160 // How should we treat this schema? 1161 $delimiter = $available_dbms[$data['dbms']]['DELIM']; 1162 1163 $sql_query = @file_get_contents($dbms_schema); 1164 1165 $sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query); 1166 1167 $sql_query = phpbb_remove_comments($sql_query); 1168 1169 $sql_query = split_sql_file($sql_query, $delimiter); 1170 1171 foreach ($sql_query as $sql) 1172 { 1173 //$sql = trim(str_replace('|', ';', $sql)); 1174 if (!$db->sql_query($sql)) 1175 { 1176 $error = $db->sql_error(); 1177 $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); 1178 } 1179 } 1180 unset($sql_query); 1181 1182 // Ok tables have been built, let's fill in the basic information 1183 $sql_query = file_get_contents('schemas/schema_data.sql'); 1184 1185 // Deal with any special comments 1186 switch ($data['dbms']) 1187 { 1188 case 'mssql': 1189 case 'mssql_odbc': 1190 case 'mssqlnative': 1191 $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query); 1192 break; 1193 1194 case 'postgres': 1195 $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query); 1196 break; 1197 } 1198 1199 // Change prefix 1200 $sql_query = preg_replace('# phpbb_([^\s]*) #i', ' ' . $data['table_prefix'] . '\1 ', $sql_query); 1201 1202 // Change language strings... 1203 $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query); 1204 1205 $sql_query = phpbb_remove_comments($sql_query); 1206 $sql_query = split_sql_file($sql_query, ';'); 1207 1208 foreach ($sql_query as $sql) 1209 { 1210 //$sql = trim(str_replace('|', ';', $sql)); 1211 if (!$db->sql_query($sql)) 1212 { 1213 $error = $db->sql_error(); 1214 $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); 1215 } 1216 } 1217 unset($sql_query); 1218 1219 $current_time = time(); 1220 1221 $user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; 1222 $user_ip = (stripos($user_ip, '::ffff:') === 0) ? substr($user_ip, 7) : $user_ip; 1223 1224 if ($data['script_path'] !== '/') 1225 { 1226 // Adjust destination path (no trailing slash) 1227 if (substr($data['script_path'], -1) == '/') 1228 { 1229 $data['script_path'] = substr($data['script_path'], 0, -1); 1230 } 1231 1232 $data['script_path'] = str_replace(array('../', './'), '', $data['script_path']); 1233 1234 if ($data['script_path'][0] != '/') 1235 { 1236 $data['script_path'] = '/' . $data['script_path']; 1237 } 1238 } 1239 1240 // Set default config and post data, this applies to all DB's 1241 $sql_ary = array( 1242 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value) 1243 VALUES ('board_startdate', '$current_time')", 1244 1245 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value) 1246 VALUES ('default_lang', '" . $db->sql_escape($data['default_lang']) . "')", 1247 1248 'UPDATE ' . $data['table_prefix'] . "config 1249 SET config_value = '" . $db->sql_escape($data['img_imagick']) . "' 1250 WHERE config_name = 'img_imagick'", 1251 1252 'UPDATE ' . $data['table_prefix'] . "config 1253 SET config_value = '" . $db->sql_escape($data['server_name']) . "' 1254 WHERE config_name = 'server_name'", 1255 1256 'UPDATE ' . $data['table_prefix'] . "config 1257 SET config_value = '" . $db->sql_escape($data['server_port']) . "' 1258 WHERE config_name = 'server_port'", 1259 1260 'UPDATE ' . $data['table_prefix'] . "config 1261 SET config_value = '" . $db->sql_escape($data['board_email1']) . "' 1262 WHERE config_name = 'board_email'", 1263 1264 'UPDATE ' . $data['table_prefix'] . "config 1265 SET config_value = '" . $db->sql_escape($data['board_email1']) . "' 1266 WHERE config_name = 'board_contact'", 1267 1268 'UPDATE ' . $data['table_prefix'] . "config 1269 SET config_value = '" . $db->sql_escape($cookie_domain) . "' 1270 WHERE config_name = 'cookie_domain'", 1271 1272 'UPDATE ' . $data['table_prefix'] . "config 1273 SET config_value = '" . $db->sql_escape($lang['default_dateformat']) . "' 1274 WHERE config_name = 'default_dateformat'", 1275 1276 'UPDATE ' . $data['table_prefix'] . "config 1277 SET config_value = '" . $db->sql_escape($data['email_enable']) . "' 1278 WHERE config_name = 'email_enable'", 1279 1280 'UPDATE ' . $data['table_prefix'] . "config 1281 SET config_value = '" . $db->sql_escape($data['smtp_delivery']) . "' 1282 WHERE config_name = 'smtp_delivery'", 1283 1284 'UPDATE ' . $data['table_prefix'] . "config 1285 SET config_value = '" . $db->sql_escape($data['smtp_host']) . "' 1286 WHERE config_name = 'smtp_host'", 1287 1288 'UPDATE ' . $data['table_prefix'] . "config 1289 SET config_value = '" . $db->sql_escape($data['smtp_auth']) . "' 1290 WHERE config_name = 'smtp_auth_method'", 1291 1292 'UPDATE ' . $data['table_prefix'] . "config 1293 SET config_value = '" . $db->sql_escape($data['smtp_user']) . "' 1294 WHERE config_name = 'smtp_username'", 1295 1296 'UPDATE ' . $data['table_prefix'] . "config 1297 SET config_value = '" . $db->sql_escape($data['smtp_pass']) . "' 1298 WHERE config_name = 'smtp_password'", 1299 1300 'UPDATE ' . $data['table_prefix'] . "config 1301 SET config_value = '" . $db->sql_escape($data['cookie_secure']) . "' 1302 WHERE config_name = 'cookie_secure'", 1303 1304 'UPDATE ' . $data['table_prefix'] . "config 1305 SET config_value = '" . $db->sql_escape($data['force_server_vars']) . "' 1306 WHERE config_name = 'force_server_vars'", 1307 1308 'UPDATE ' . $data['table_prefix'] . "config 1309 SET config_value = '" . $db->sql_escape($data['script_path']) . "' 1310 WHERE config_name = 'script_path'", 1311 1312 'UPDATE ' . $data['table_prefix'] . "config 1313 SET config_value = '" . $db->sql_escape($data['server_protocol']) . "' 1314 WHERE config_name = 'server_protocol'", 1315 1316 'UPDATE ' . $data['table_prefix'] . "config 1317 SET config_value = '" . $db->sql_escape($data['admin_name']) . "' 1318 WHERE config_name = 'newest_username'", 1319 1320 'UPDATE ' . $data['table_prefix'] . "config 1321 SET config_value = '" . md5(mt_rand()) . "' 1322 WHERE config_name = 'avatar_salt'", 1323 1324 'UPDATE ' . $data['table_prefix'] . "users 1325 SET username = '" . $db->sql_escape($data['admin_name']) . "', user_password='" . $db->sql_escape(md5($data['admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . $db->sql_escape(phpbb_email_hash($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "' 1326 WHERE username = 'Admin'", 1327 1328 'UPDATE ' . $data['table_prefix'] . "moderator_cache 1329 SET username = '" . $db->sql_escape($data['admin_name']) . "' 1330 WHERE username = 'Admin'", 1331 1332 'UPDATE ' . $data['table_prefix'] . "forums 1333 SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "' 1334 WHERE forum_last_poster_name = 'Admin'", 1335 1336 'UPDATE ' . $data['table_prefix'] . "topics 1337 SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "' 1338 WHERE topic_first_poster_name = 'Admin' 1339 OR topic_last_poster_name = 'Admin'", 1340 1341 'UPDATE ' . $data['table_prefix'] . "users 1342 SET user_regdate = $current_time", 1343 1344 'UPDATE ' . $data['table_prefix'] . "posts 1345 SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'", 1346 1347 'UPDATE ' . $data['table_prefix'] . "topics 1348 SET topic_time = $current_time, topic_last_post_time = $current_time", 1349 1350 'UPDATE ' . $data['table_prefix'] . "forums 1351 SET forum_last_post_time = $current_time", 1352 1353 'UPDATE ' . $data['table_prefix'] . "config 1354 SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "' 1355 WHERE config_name = 'dbms_version'", 1356 ); 1357 1358 if (@extension_loaded('gd') || can_load_dll('gd')) 1359 { 1360 $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config 1361 SET config_value = 'phpbb_captcha_gd' 1362 WHERE config_name = 'captcha_plugin'"; 1363 1364 $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config 1365 SET config_value = '1' 1366 WHERE config_name = 'captcha_gd'"; 1367 } 1368 1369 $ref = substr($referer, strpos($referer, '://') + 3); 1370 1371 if (!(stripos($ref, $server_name) === 0)) 1372 { 1373 $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config 1374 SET config_value = '0' 1375 WHERE config_name = 'referer_validation'"; 1376 } 1377 1378 // We set a (semi-)unique cookie name to bypass login issues related to the cookie name. 1379 $cookie_name = 'phpbb3_'; 1380 $rand_str = md5(mt_rand()); 1381 $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35)); 1382 $rand_str = substr($rand_str, 0, 5); 1383 $cookie_name .= strtolower($rand_str); 1384 1385 $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config 1386 SET config_value = '" . $db->sql_escape($cookie_name) . "' 1387 WHERE config_name = 'cookie_name'"; 1388 1389 foreach ($sql_ary as $sql) 1390 { 1391 //$sql = trim(str_replace('|', ';', $sql)); 1392 1393 if (!$db->sql_query($sql)) 1394 { 1395 $error = $db->sql_error(); 1396 $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__); 1397 } 1398 } 1399 1400 $submit = $lang['NEXT_STEP']; 1401 1402 $url = $this->p_master->module_url . "?mode=$mode&sub=final"; 1403 1404 $template->assign_vars(array( 1405 'BODY' => $lang['STAGE_CREATE_TABLE_EXPLAIN'], 1406 'L_SUBMIT' => $submit, 1407 'S_HIDDEN' => build_hidden_fields($data), 1408 'U_ACTION' => $url, 1409 )); 1410 } 1411 1412 /** 1413 * Build the search index... 1414 */ 1415 function build_search_index($mode, $sub) 1416 { 1417 global $db, $lang, $phpbb_root_path, $phpEx, $config; 1418 1419 // Obtain any submitted data 1420 $data = $this->get_submitted_data(); 1421 $table_prefix = $data['table_prefix']; 1422 1423 // If we get here and the extension isn't loaded it should be safe to just go ahead and load it 1424 $available_dbms = get_available_dbms($data['dbms']); 1425 1426 if (!isset($available_dbms[$data['dbms']])) 1427 { 1428 // Someone's been silly and tried providing a non-existant dbms 1429 $this->p_master->redirect("index.$phpEx?mode=install"); 1430 } 1431 1432 $dbms = $available_dbms[$data['dbms']]['DRIVER']; 1433 1434 // Load the appropriate database class if not already loaded 1435 include($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); 1436 1437 // Instantiate the database 1438 $db = new $sql_db(); 1439 $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false); 1440 1441 // NOTE: trigger_error does not work here. 1442 $db->sql_return_on_error(true); 1443 1444 include_once($phpbb_root_path . 'includes/constants.' . $phpEx); 1445 include_once($phpbb_root_path . 'includes/search/fulltext_native.' . $phpEx); 1446 1447 // Fill the config array - it is needed by those functions we call 1448 $sql = 'SELECT * 1449 FROM ' . CONFIG_TABLE; 1450 $result = $db->sql_query($sql); 1451 1452 $config = array(); 1453 while ($row = $db->sql_fetchrow($result)) 1454 { 1455 $config[$row['config_name']] = $row['config_value']; 1456 } 1457 $db->sql_freeresult($result); 1458 1459 $error = false; 1460 $search = new fulltext_native($error); 1461 1462 $sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id 1463 FROM ' . POSTS_TABLE; 1464 $result = $db->sql_query($sql); 1465 1466 while ($row = $db->sql_fetchrow($result)) 1467 { 1468 $search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']); 1469 } 1470 $db->sql_freeresult($result); 1471 } 1472 1473 /** 1474 * Populate the module tables 1475 */ 1476 function add_modules($mode, $sub) 1477 { 1478 global $db, $lang, $phpbb_root_path, $phpEx; 1479 1480 include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx); 1481 1482 $_module = new acp_modules(); 1483 $module_classes = array('acp', 'mcp', 'ucp'); 1484 1485 // Add categories 1486 foreach ($module_classes as $module_class) 1487 { 1488 $categories = array(); 1489 1490 // Set the module class 1491 $_module->module_class = $module_class; 1492 1493 foreach ($this->module_categories[$module_class] as $cat_name => $subs) 1494 { 1495 $module_data = array( 1496 'module_basename' => '', 1497 'module_enabled' => 1, 1498 'module_display' => 1, 1499 'parent_id' => 0, 1500 'module_class' => $module_class, 1501 'module_langname' => $cat_name, 1502 'module_mode' => '', 1503 'module_auth' => '', 1504 ); 1505 1506 // Add category 1507 $_module->update_module_data($module_data, true); 1508 1509 // Check for last sql error happened 1510 if ($db->sql_error_triggered) 1511 { 1512 $error = $db->sql_error($db->sql_error_sql); 1513 $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); 1514 } 1515 1516 $categories[$cat_name]['id'] = (int) $module_data['module_id']; 1517 $categories[$cat_name]['parent_id'] = 0; 1518 1519 // Create sub-categories... 1520 if (is_array($subs)) 1521 { 1522 foreach ($subs as $level2_name) 1523 { 1524 $module_data = array( 1525 'module_basename' => '', 1526 'module_enabled' => 1, 1527 'module_display' => 1, 1528 'parent_id' => (int) $categories[$cat_name]['id'], 1529 'module_class' => $module_class, 1530 'module_langname' => $level2_name, 1531 'module_mode' => '', 1532 'module_auth' => '', 1533 ); 1534 1535 $_module->update_module_data($module_data, true); 1536 1537 // Check for last sql error happened 1538 if ($db->sql_error_triggered) 1539 { 1540 $error = $db->sql_error($db->sql_error_sql); 1541 $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); 1542 } 1543 1544 $categories[$level2_name]['id'] = (int) $module_data['module_id']; 1545 $categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id']; 1546 } 1547 } 1548 } 1549 1550 // Get the modules we want to add... returned sorted by name 1551 $module_info = $_module->get_module_infos('', $module_class); 1552 1553 foreach ($module_info as $module_basename => $fileinfo) 1554 { 1555 foreach ($fileinfo['modes'] as $module_mode => $row) 1556 { 1557 foreach ($row['cat'] as $cat_name) 1558 { 1559 if (!isset($categories[$cat_name])) 1560 { 1561 continue; 1562 } 1563 1564 $module_data = array( 1565 'module_basename' => $module_basename, 1566 'module_enabled' => 1, 1567 'module_display' => (isset($row['display'])) ? (int) $row['display'] : 1, 1568 'parent_id' => (int) $categories[$cat_name]['id'], 1569 'module_class' => $module_class, 1570 'module_langname' => $row['title'], 1571 'module_mode' => $module_mode, 1572 'module_auth' => $row['auth'], 1573 ); 1574 1575 $_module->update_module_data($module_data, true); 1576 1577 // Check for last sql error happened 1578 if ($db->sql_error_triggered) 1579 { 1580 $error = $db->sql_error($db->sql_error_sql); 1581 $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); 1582 } 1583 } 1584 } 1585 } 1586 1587 // Move some of the modules around since the code above will put them in the wrong place 1588 if ($module_class == 'acp') 1589 { 1590 // Move main module 4 up... 1591 $sql = 'SELECT * 1592 FROM ' . MODULES_TABLE . " 1593 WHERE module_basename = 'main' 1594 AND module_class = 'acp' 1595 AND module_mode = 'main'"; 1596 $result = $db->sql_query($sql); 1597 $row = $db->sql_fetchrow($result); 1598 $db->sql_freeresult($result); 1599 1600 $_module->move_module_by($row, 'move_up', 4); 1601 1602 // Move permissions intro screen module 4 up... 1603 $sql = 'SELECT * 1604 FROM ' . MODULES_TABLE . " 1605 WHERE module_basename = 'permissions' 1606 AND module_class = 'acp' 1607 AND module_mode = 'intro'"; 1608 $result = $db->sql_query($sql); 1609 $row = $db->sql_fetchrow($result); 1610 $db->sql_freeresult($result); 1611 1612 $_module->move_module_by($row, 'move_up', 4); 1613 1614 // Move manage users screen module 5 up... 1615 $sql = 'SELECT * 1616 FROM ' . MODULES_TABLE . " 1617 WHERE module_basename = 'users' 1618 AND module_class = 'acp' 1619 AND module_mode = 'overview'"; 1620 $result = $db->sql_query($sql); 1621 $row = $db->sql_fetchrow($result); 1622 $db->sql_freeresult($result); 1623 1624 $_module->move_module_by($row, 'move_up', 5); 1625 } 1626 1627 if ($module_class == 'ucp') 1628 { 1629 // Move attachment module 4 down... 1630 $sql = 'SELECT * 1631 FROM ' . MODULES_TABLE . " 1632 WHERE module_basename = 'attachments' 1633 AND module_class = 'ucp' 1634 AND module_mode = 'attachments'"; 1635 $result = $db->sql_query($sql); 1636 $row = $db->sql_fetchrow($result); 1637 $db->sql_freeresult($result); 1638 1639 $_module->move_module_by($row, 'move_down', 4); 1640 } 1641 1642 // And now for the special ones 1643 // (these are modules which appear in multiple categories and thus get added manually to some for more control) 1644 if (isset($this->module_extras[$module_class])) 1645 { 1646 foreach ($this->module_extras[$module_class] as $cat_name => $mods) 1647 { 1648 $sql = 'SELECT module_id, left_id, right_id 1649 FROM ' . MODULES_TABLE . " 1650 WHERE module_langname = '" . $db->sql_escape($cat_name) . "' 1651 AND module_class = '" . $db->sql_escape($module_class) . "'"; 1652 $result = $db->sql_query_limit($sql, 1); 1653 $row2 = $db->sql_fetchrow($result); 1654 $db->sql_freeresult($result); 1655 1656 foreach ($mods as $mod_name) 1657 { 1658 $sql = 'SELECT * 1659 FROM ' . MODULES_TABLE . " 1660 WHERE module_langname = '" . $db->sql_escape($mod_name) . "' 1661 AND module_class = '" . $db->sql_escape($module_class) . "' 1662 AND module_basename <> ''"; 1663 $result = $db->sql_query_limit($sql, 1); 1664 $row = $db->sql_fetchrow($result); 1665 $db->sql_freeresult($result); 1666 1667 $module_data = array( 1668 'module_basename' => $row['module_basename'], 1669 'module_enabled' => (int) $row['module_enabled'], 1670 'module_display' => (int) $row['module_display'], 1671 'parent_id' => (int) $row2['module_id'], 1672 'module_class' => $row['module_class'], 1673 'module_langname' => $row['module_langname'], 1674 'module_mode' => $row['module_mode'], 1675 'module_auth' => $row['module_auth'], 1676 ); 1677 1678 $_module->update_module_data($module_data, true); 1679 1680 // Check for last sql error happened 1681 if ($db->sql_error_triggered) 1682 { 1683 $error = $db->sql_error($db->sql_error_sql); 1684 $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); 1685 } 1686 } 1687 } 1688 } 1689 1690 $_module->remove_cache_file(); 1691 } 1692 } 1693 1694 /** 1695 * Populate the language tables 1696 */ 1697 function add_language($mode, $sub) 1698 { 1699 global $db, $lang, $phpbb_root_path, $phpEx; 1700 1701 $dir = @opendir($phpbb_root_path . 'language'); 1702 1703 if (!$dir) 1704 { 1705 $this->error('Unable to access the language directory', __LINE__, __FILE__); 1706 } 1707 1708 while (($file = readdir($dir)) !== false) 1709 { 1710 $path = $phpbb_root_path . 'language/' . $file; 1711 1712 if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS') 1713 { 1714 continue; 1715 } 1716 1717 if (is_dir($path) && file_exists($path . '/iso.txt')) 1718 { 1719 $lang_file = file("$path/iso.txt"); 1720 1721 $lang_pack = array( 1722 'lang_iso' => basename($path), 1723 'lang_dir' => basename($path), 1724 'lang_english_name' => trim(htmlspecialchars($lang_file[0])), 1725 'lang_local_name' => trim(htmlspecialchars($lang_file[1], ENT_COMPAT, 'UTF-8')), 1726 'lang_author' => trim(htmlspecialchars($lang_file[2], ENT_COMPAT, 'UTF-8')), 1727 ); 1728 1729 $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack)); 1730 1731 if ($db->sql_error_triggered) 1732 { 1733 $error = $db->sql_error($db->sql_error_sql); 1734 $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); 1735 } 1736 1737 $valid_localized = array( 1738 'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply', 1739 ); 1740 1741 $sql_ary = array(); 1742 1743 $sql = 'SELECT * 1744 FROM ' . STYLES_IMAGESET_TABLE; 1745 $result = $db->sql_query($sql); 1746 1747 while ($imageset_row = $db->sql_fetchrow($result)) 1748 { 1749 if (@file_exists("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg")) 1750 { 1751 $cfg_data_imageset_data = parse_cfg_file("{$phpbb_root_path}styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg"); 1752 foreach ($cfg_data_imageset_data as $image_name => $value) 1753 { 1754 if (strpos($value, '*') !== false) 1755 { 1756 if (substr($value, -1, 1) === '*') 1757 { 1758 list($image_filename, $image_height) = explode('*', $value); 1759 $image_width = 0; 1760 } 1761 else 1762 { 1763 list($image_filename, $image_height, $image_width) = explode('*', $value); 1764 } 1765 } 1766 else 1767 { 1768 $image_filename = $value; 1769 $image_height = $image_width = 0; 1770 } 1771 1772 if (strpos($image_name, 'img_') === 0 && $image_filename) 1773 { 1774 $image_name = substr($image_name, 4); 1775 if (in_array($image_name, $valid_localized)) 1776 { 1777 $sql_ary[] = array( 1778 'image_name' => (string) $image_name, 1779 'image_filename' => (string) $image_filename, 1780 'image_height' => (int) $image_height, 1781 'image_width' => (int) $image_width, 1782 'imageset_id' => (int) $imageset_row['imageset_id'], 1783 'image_lang' => (string) $lang_pack['lang_iso'], 1784 ); 1785 } 1786 } 1787 } 1788 } 1789 } 1790 $db->sql_freeresult($result); 1791 1792 if (sizeof($sql_ary)) 1793 { 1794 $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary); 1795 1796 if ($db->sql_error_triggered) 1797 { 1798 $error = $db->sql_error($db->sql_error_sql); 1799 $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__); 1800 } 1801 } 1802 } 1803 } 1804 closedir($dir); 1805 } 1806 1807 /** 1808 * Add search robots to the database 1809 */ 1810 function add_bots($mode, $sub) 1811 { 1812 global $db, $lang, $phpbb_root_path, $phpEx, $config; 1813 1814 // Obtain any submitted data 1815 $data = $this->get_submitted_data(); 1816 1817 // Fill the config array - it is needed by those functions we call 1818 $sql = 'SELECT * 1819 FROM ' . CONFIG_TABLE; 1820 $result = $db->sql_query($sql); 1821 1822 $config = array(); 1823 while ($row = $db->sql_fetchrow($result)) 1824 { 1825 $config[$row['config_name']] = $row['config_value']; 1826 } 1827 $db->sql_freeresult($result); 1828 1829 $sql = 'SELECT group_id 1830 FROM ' . GROUPS_TABLE . " 1831 WHERE group_name = 'BOTS'"; 1832 $result = $db->sql_query($sql); 1833 $group_id = (int) $db->sql_fetchfield('group_id'); 1834 $db->sql_freeresult($result); 1835 1836 if (!$group_id) 1837 { 1838 // If we reach this point then something has gone very wrong 1839 $this->p_master->error($lang['NO_GROUP'], __LINE__, __FILE__); 1840 } 1841 1842 if (!function_exists('user_add')) 1843 { 1844 include($phpbb_root_path . 'includes/functions_user.' . $phpEx); 1845 } 1846 1847 foreach ($this->bot_list as $bot_name => $bot_ary) 1848 { 1849 $user_row = array( 1850 'user_type' => USER_IGNORE, 1851 'group_id' => $group_id, 1852 'username' => $bot_name, 1853 'user_regdate' => time(), 1854 'user_password' => '', 1855 'user_colour' => '9E8DA7', 1856 'user_email' => '', 1857 'user_lang' => $data['default_lang'], 1858 'user_style' => 1, 1859 'user_timezone' => 0, 1860 'user_dateformat' => $lang['default_dateformat'], 1861 'user_allow_massemail' => 0, 1862 'user_allow_pm' => 0, 1863 ); 1864 1865 $user_id = user_add($user_row); 1866 1867 if (!$user_id) 1868 { 1869 // If we can't insert this user then continue to the next one to avoid inconsistent data 1870 $this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true); 1871 continue; 1872 } 1873 1874 $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( 1875 'bot_active' => 1, 1876 'bot_name' => (string) $bot_name, 1877 'user_id' => (int) $user_id, 1878 'bot_agent' => (string) $bot_ary[0], 1879 'bot_ip' => (string) $bot_ary[1], 1880 )); 1881 1882 $result = $db->sql_query($sql); 1883 } 1884 } 1885 1886 /** 1887 * Sends an email to the board administrator with their password and some useful links 1888 */ 1889 function email_admin($mode, $sub) 1890 { 1891 global $auth, $config, $db, $lang, $template, $user, $phpbb_root_path, $phpEx; 1892 1893 $this->page_title = $lang['STAGE_FINAL']; 1894 1895 // Obtain any submitted data 1896 $data = $this->get_submitted_data(); 1897 1898 $sql = 'SELECT * 1899 FROM ' . CONFIG_TABLE; 1900 $result = $db->sql_query($sql); 1901 1902 $config = array(); 1903 while ($row = $db->sql_fetchrow($result)) 1904 { 1905 $config[$row['config_name']] = $row['config_value']; 1906 } 1907 $db->sql_freeresult($result); 1908 1909 $user->session_begin(); 1910 $auth->login($data['admin_name'], $data['admin_pass1'], false, true, true); 1911 1912 // OK, Now that we've reached this point we can be confident that everything 1913 // is installed and working......I hope :) 1914 // So it's time to send an email to the administrator confirming the details 1915 // they entered 1916 1917 if ($config['email_enable']) 1918 { 1919 include_once($phpbb_root_path . 'includes/functions_messenger.' . $phpEx); 1920 1921 $messenger = new messenger(false); 1922 1923 $messenger->template('installed', $data['language']); 1924 1925 $messenger->to($data['board_email1'], $data['admin_name']); 1926 1927 $messenger->anti_abuse_headers($config, $user); 1928 1929 $messenger->assign_vars(array( 1930 'USERNAME' => htmlspecialchars_decode($data['admin_name']), 1931 'PASSWORD' => htmlspecialchars_decode($data['admin_pass1'])) 1932 ); 1933 1934 $messenger->send(NOTIFY_EMAIL); 1935 } 1936 1937 // And finally, add a note to the log 1938 add_log('admin', 'LOG_INSTALL_INSTALLED', $config['version']); 1939 1940 $template->assign_vars(array( 1941 'TITLE' => $lang['INSTALL_CONGRATS'], 1942 'BODY' => sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], $config['version'], append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=convert&language=' . $data['language']), '../docs/README.html'), 1943 'L_SUBMIT' => $lang['INSTALL_LOGIN'], 1944 'U_ACTION' => append_sid($phpbb_root_path . 'adm/index.' . $phpEx, 'i=send_statistics&mode=send_statistics'), 1945 )); 1946 } 1947 1948 /** 1949 * Check if the avatar directory is writable and disable avatars 1950 * if it isn't writable. 1951 */ 1952 function disable_avatars_if_unwritable() 1953 { 1954 global $phpbb_root_path; 1955 1956 if (!phpbb_is_writable($phpbb_root_path . 'images/avatars/upload/')) 1957 { 1958 set_config('allow_avatar', 0); 1959 set_config('allow_avatar_upload', 0); 1960 } 1961 } 1962 1963 /** 1964 * Generate a list of available mail server authentication methods 1965 */ 1966 function mail_auth_select($selected_method) 1967 { 1968 global $lang; 1969 1970 $auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP'); 1971 $s_smtp_auth_options = ''; 1972 1973 foreach ($auth_methods as $method) 1974 { 1975 $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $lang['SMTP_' . str_replace('-', '_', $method)] . '</option>'; 1976 } 1977 1978 return $s_smtp_auth_options; 1979 } 1980 1981 /** 1982 * Get submitted data 1983 */ 1984 function get_submitted_data() 1985 { 1986 return array( 1987 'language' => basename(request_var('language', '')), 1988 'dbms' => request_var('dbms', ''), 1989 'dbhost' => request_var('dbhost', ''), 1990 'dbport' => request_var('dbport', ''), 1991 'dbuser' => request_var('dbuser', ''), 1992 'dbpasswd' => request_var('dbpasswd', '', true), 1993 'dbname' => request_var('dbname', ''), 1994 'table_prefix' => request_var('table_prefix', ''), 1995 'default_lang' => basename(request_var('default_lang', '')), 1996 'admin_name' => utf8_normalize_nfc(request_var('admin_name', '', true)), 1997 'admin_pass1' => request_var('admin_pass1', '', true), 1998 'admin_pass2' => request_var('admin_pass2', '', true), 1999 'board_email1' => strtolower(request_var('board_email1', '')), 2000 'board_email2' => strtolower(request_var('board_email2', '')), 2001 'img_imagick' => request_var('img_imagick', ''), 2002 'ftp_path' => request_var('ftp_path', ''), 2003 'ftp_user' => request_var('ftp_user', ''), 2004 'ftp_pass' => request_var('ftp_pass', ''), 2005 'email_enable' => request_var('email_enable', ''), 2006 'smtp_delivery' => request_var('smtp_delivery', ''), 2007 'smtp_host' => request_var('smtp_host', ''), 2008 'smtp_auth' => request_var('smtp_auth', ''), 2009 'smtp_user' => request_var('smtp_user', ''), 2010 'smtp_pass' => request_var('smtp_pass', ''), 2011 'cookie_secure' => request_var('cookie_secure', ''), 2012 'force_server_vars' => request_var('force_server_vars', ''), 2013 'server_protocol' => request_var('server_protocol', ''), 2014 'server_name' => request_var('server_name', ''), 2015 'server_port' => request_var('server_port', ''), 2016 'script_path' => request_var('script_path', ''), 2017 ); 2018 } 2019 2020 /** 2021 * The information below will be used to build the input fields presented to the user 2022 */ 2023 var $db_config_options = array( 2024 'legend1' => 'DB_CONFIG', 2025 'dbms' => array('lang' => 'DBMS', 'type' => 'select', 'options' => 'dbms_select(\'{VALUE}\')', 'explain' => false), 2026 'dbhost' => array('lang' => 'DB_HOST', 'type' => 'text:25:100', 'explain' => true), 2027 'dbport' => array('lang' => 'DB_PORT', 'type' => 'text:25:100', 'explain' => true), 2028 'dbname' => array('lang' => 'DB_NAME', 'type' => 'text:25:100', 'explain' => false), 2029 'dbuser' => array('lang' => 'DB_USERNAME', 'type' => 'text:25:100', 'explain' => false), 2030 'dbpasswd' => array('lang' => 'DB_PASSWORD', 'type' => 'password:25:100', 'explain' => false), 2031 'table_prefix' => array('lang' => 'TABLE_PREFIX', 'type' => 'text:25:100', 'explain' => true), 2032 ); 2033 var $admin_config_options = array( 2034 'legend1' => 'ADMIN_CONFIG', 2035 'default_lang' => array('lang' => 'DEFAULT_LANG', 'type' => 'select', 'options' => '$this->module->inst_language_select(\'{VALUE}\')', 'explain' => false), 2036 'admin_name' => array('lang' => 'ADMIN_USERNAME', 'type' => 'text:25:100', 'explain' => true), 2037 'admin_pass1' => array('lang' => 'ADMIN_PASSWORD', 'type' => 'password:25:100', 'explain' => true), 2038 'admin_pass2' => array('lang' => 'ADMIN_PASSWORD_CONFIRM', 'type' => 'password:25:100', 'explain' => false), 2039 'board_email1' => array('lang' => 'CONTACT_EMAIL', 'type' => 'text:25:100', 'explain' => false), 2040 'board_email2' => array('lang' => 'CONTACT_EMAIL_CONFIRM', 'type' => 'text:25:100', 'explain' => false), 2041 ); 2042 var $advanced_config_options = array( 2043 'legend1' => 'ACP_EMAIL_SETTINGS', 2044 'email_enable' => array('lang' => 'ENABLE_EMAIL', 'type' => 'radio:enabled_disabled', 'explain' => true), 2045 'smtp_delivery' => array('lang' => 'USE_SMTP', 'type' => 'radio:yes_no', 'explain' => true), 2046 'smtp_host' => array('lang' => 'SMTP_SERVER', 'type' => 'text:25:50', 'explain' => false), 2047 'smtp_auth' => array('lang' => 'SMTP_AUTH_METHOD', 'type' => 'select', 'options' => '$this->module->mail_auth_select(\'{VALUE}\')', 'explain' => true), 2048 'smtp_user' => array('lang' => 'SMTP_USERNAME', 'type' => 'text:25:255', 'explain' => true), 2049 'smtp_pass' => array('lang' => 'SMTP_PASSWORD', 'type' => 'password:25:255', 'explain' => true), 2050 2051 'legend2' => 'SERVER_URL_SETTINGS', 2052 'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'type' => 'radio:enabled_disabled', 'explain' => true), 2053 'force_server_vars' => array('lang' => 'FORCE_SERVER_VARS', 'type' => 'radio:yes_no', 'explain' => true), 2054 'server_protocol' => array('lang' => 'SERVER_PROTOCOL', 'type' => 'text:10:10', 'explain' => true), 2055 'server_name' => array('lang' => 'SERVER_NAME', 'type' => 'text:40:255', 'explain' => true), 2056 'server_port' => array('lang' => 'SERVER_PORT', 'type' => 'text:5:5', 'explain' => true), 2057 'script_path' => array('lang' => 'SCRIPT_PATH', 'type' => 'text::255', 'explain' => true), 2058 ); 2059 2060 /** 2061 * Specific PHP modules we may require for certain optional or extended features 2062 */ 2063 var $php_dlls_other = array('zlib', 'ftp', 'gd', 'xml'); 2064 2065 /** 2066 * A list of the web-crawlers/bots we recognise by default 2067 * 2068 * Candidates but not included: 2069 * 'Accoona [Bot]' 'Accoona-AI-Agent/' 2070 * 'ASPseek [Crawler]' 'ASPseek/' 2071 * 'Boitho [Crawler]' 'boitho.com-dc/' 2072 * 'Bunnybot [Bot]' 'powered by www.buncat.de' 2073 * 'Cosmix [Bot]' 'cfetch/' 2074 * 'Crawler Search [Crawler]' '.Crawler-Search.de' 2075 * 'Findexa [Crawler]' 'Findexa Crawler (' 2076 * 'GBSpider [Spider]' 'GBSpider v' 2077 * 'genie [Bot]' 'genieBot (' 2078 * 'Hogsearch [Bot]' 'oegp v. 1.3.0' 2079 * 'Insuranco [Bot]' 'InsurancoBot' 2080 * 'IRLbot [Bot]' 'http://irl.cs.tamu.edu/crawler' 2081 * 'ISC Systems [Bot]' 'ISC Systems iRc Search' 2082 * 'Jyxobot [Bot]' 'Jyxobot/' 2083 * 'Kraehe [Metasuche]' '-DIE-KRAEHE- META-SEARCH-ENGINE/' 2084 * 'LinkWalker' 'LinkWalker' 2085 * 'MMSBot [Bot]' 'http://www.mmsweb.at/bot.html' 2086 * 'Naver [Bot]' 'nhnbot@naver.com)' 2087 * 'NetResearchServer' 'NetResearchServer/' 2088 * 'Nimble [Crawler]' 'NimbleCrawler' 2089 * 'Ocelli [Bot]' 'Ocelli/' 2090 * 'Onsearch [Bot]' 'onCHECK-Robot' 2091 * 'Orange [Spider]' 'OrangeSpider' 2092 * 'Sproose [Bot]' 'http://www.sproose.com/bot' 2093 * 'Susie [Sync]' '!Susie (http://www.sync2it.com/susie)' 2094 * 'Tbot [Bot]' 'Tbot/' 2095 * 'Thumbshots [Capture]' 'thumbshots-de-Bot' 2096 * 'Vagabondo [Crawler]' 'http://webagent.wise-guys.nl/' 2097 * 'Walhello [Bot]' 'appie 1.1 (www.walhello.com)' 2098 * 'WissenOnline [Bot]' 'WissenOnline-Bot' 2099 * 'WWWeasel [Bot]' 'WWWeasel Robot v' 2100 * 'Xaldon [Spider]' 'Xaldon WebSpider' 2101 */ 2102 var $bot_list = array( 2103 'AdsBot [Google]' => array('AdsBot-Google', ''), 2104 'Alexa [Bot]' => array('ia_archiver', ''), 2105 'Alta Vista [Bot]' => array('Scooter/', ''), 2106 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), 2107 'Baidu [Spider]' => array('Baiduspider', ''), 2108 'Bing [Bot]' => array('bingbot/', ''), 2109 'Exabot [Bot]' => array('Exabot', ''), 2110 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), 2111 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), 2112 'Francis [Bot]' => array('http://www.neomo.de/', ''), 2113 'Gigabot [Bot]' => array('Gigabot/', ''), 2114 'Google Adsense [Bot]' => array('Mediapartners-Google', ''), 2115 'Google Desktop' => array('Google Desktop', ''), 2116 'Google Feedfetcher' => array('Feedfetcher-Google', ''), 2117 'Google [Bot]' => array('Googlebot', ''), 2118 'Heise IT-Markt [Crawler]' => array('heise-IT-Markt-Crawler', ''), 2119 'Heritrix [Crawler]' => array('heritrix/1.', ''), 2120 'IBM Research [Bot]' => array('ibm.com/cs/crawler', ''), 2121 'ICCrawler - ICjobs' => array('ICCrawler - ICjobs', ''), 2122 'ichiro [Crawler]' => array('ichiro/', ''), 2123 'Majestic-12 [Bot]' => array('MJ12bot/', ''), 2124 'Metager [Bot]' => array('MetagerBot/', ''), 2125 'MSN NewsBlogs' => array('msnbot-NewsBlogs/', ''), 2126 'MSN [Bot]' => array('msnbot/', ''), 2127 'MSNbot Media' => array('msnbot-media/', ''), 2128 'Nutch [Bot]' => array('http://lucene.apache.org/nutch/', ''), 2129 'Online link [Validator]' => array('online link validator', ''), 2130 'psbot [Picsearch]' => array('psbot/0', ''), 2131 'Sensis [Crawler]' => array('Sensis Web Crawler', ''), 2132 'SEO Crawler' => array('SEO search Crawler/', ''), 2133 'Seoma [Crawler]' => array('Seoma [SEO Crawler]', ''), 2134 'SEOSearch [Crawler]' => array('SEOsearch/', ''), 2135 'Snappy [Bot]' => array('Snappy/1.1 ( http://www.urltrends.com/ )', ''), 2136 'Steeler [Crawler]' => array('http://www.tkl.iis.u-tokyo.ac.jp/~crawler/', ''), 2137 'Telekom [Bot]' => array('crawleradmin.t-info@telekom.de', ''), 2138 'TurnitinBot [Bot]' => array('TurnitinBot/', ''), 2139 'Voyager [Bot]' => array('voyager/', ''), 2140 'W3 [Sitesearch]' => array('W3 SiteSearch Crawler', ''), 2141 'W3C [Linkcheck]' => array('W3C-checklink/', ''), 2142 'W3C [Validator]' => array('W3C_Validator', ''), 2143 'YaCy [Bot]' => array('yacybot', ''), 2144 'Yahoo MMCrawler [Bot]' => array('Yahoo-MMCrawler/', ''), 2145 'Yahoo Slurp [Bot]' => array('Yahoo! DE Slurp', ''), 2146 'Yahoo [Bot]' => array('Yahoo! Slurp', ''), 2147 'YahooSeeker [Bot]' => array('YahooSeeker/', ''), 2148 ); 2149 2150 /** 2151 * Define the module structure so that we can populate the database without 2152 * needing to hard-code module_id values 2153 */ 2154 var $module_categories = array( 2155 'acp' => array( 2156 'ACP_CAT_GENERAL' => array( 2157 'ACP_QUICK_ACCESS', 2158 'ACP_BOARD_CONFIGURATION', 2159 'ACP_CLIENT_COMMUNICATION', 2160 'ACP_SERVER_CONFIGURATION', 2161 ), 2162 'ACP_CAT_FORUMS' => array( 2163 'ACP_MANAGE_FORUMS', 2164 'ACP_FORUM_BASED_PERMISSIONS', 2165 ), 2166 'ACP_CAT_POSTING' => array( 2167 'ACP_MESSAGES', 2168 'ACP_ATTACHMENTS', 2169 ), 2170 'ACP_CAT_USERGROUP' => array( 2171 'ACP_CAT_USERS', 2172 'ACP_GROUPS', 2173 'ACP_USER_SECURITY', 2174 ), 2175 'ACP_CAT_PERMISSIONS' => array( 2176 'ACP_GLOBAL_PERMISSIONS', 2177 'ACP_FORUM_BASED_PERMISSIONS', 2178 'ACP_PERMISSION_ROLES', 2179 'ACP_PERMISSION_MASKS', 2180 ), 2181 'ACP_CAT_STYLES' => array( 2182 'ACP_STYLE_MANAGEMENT', 2183 'ACP_STYLE_COMPONENTS', 2184 ), 2185 'ACP_CAT_MAINTENANCE' => array( 2186 'ACP_FORUM_LOGS', 2187 'ACP_CAT_DATABASE', 2188 ), 2189 'ACP_CAT_SYSTEM' => array( 2190 'ACP_AUTOMATION', 2191 'ACP_GENERAL_TASKS', 2192 'ACP_MODULE_MANAGEMENT', 2193 ), 2194 'ACP_CAT_DOT_MODS' => null, 2195 ), 2196 'mcp' => array( 2197 'MCP_MAIN' => null, 2198 'MCP_QUEUE' => null, 2199 'MCP_REPORTS' => null, 2200 'MCP_NOTES' => null, 2201 'MCP_WARN' => null, 2202 'MCP_LOGS' => null, 2203 'MCP_BAN' => null, 2204 ), 2205 'ucp' => array( 2206 'UCP_MAIN' => null, 2207 'UCP_PROFILE' => null, 2208 'UCP_PREFS' => null, 2209 'UCP_PM' => null, 2210 'UCP_USERGROUPS' => null, 2211 'UCP_ZEBRA' => null, 2212 ), 2213 ); 2214 2215 var $module_extras = array( 2216 'acp' => array( 2217 'ACP_QUICK_ACCESS' => array( 2218 'ACP_MANAGE_USERS', 2219 'ACP_GROUPS_MANAGE', 2220 'ACP_MANAGE_FORUMS', 2221 'ACP_MOD_LOGS', 2222 'ACP_BOTS', 2223 'ACP_PHP_INFO', 2224 ), 2225 'ACP_FORUM_BASED_PERMISSIONS' => array( 2226 'ACP_FORUM_PERMISSIONS', 2227 'ACP_FORUM_PERMISSIONS_COPY', 2228 'ACP_FORUM_MODERATORS', 2229 'ACP_USERS_FORUM_PERMISSIONS', 2230 'ACP_GROUPS_FORUM_PERMISSIONS', 2231 ), 2232 ), 2233 ); 2234 } 2235 2236 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Oct 2 15:03:47 2013 | Cross-referenced by PHPXref 0.7.1 |