[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.6 4 * Copyright 2010 MyBB Group, All Rights Reserved 5 * 6 * Website: http://mybb.com 7 * License: http://mybb.com/about/license 8 * 9 * $Id$ 10 */ 11 12 @set_time_limit(0); 13 14 define('MYBB_ROOT', dirname(dirname(__FILE__))."/"); 15 define("INSTALL_ROOT", dirname(__FILE__)."/"); 16 define("TIME_NOW", time()); 17 define("IN_MYBB", 1); 18 define("IN_INSTALL", 1); 19 20 if(function_exists('date_default_timezone_set') && !ini_get('date.timezone')) 21 { 22 date_default_timezone_set('GMT'); 23 } 24 25 require_once MYBB_ROOT.'inc/class_error.php'; 26 $error_handler = new errorHandler(); 27 28 require_once MYBB_ROOT.'inc/class_core.php'; 29 $mybb = new MyBB; 30 31 // Include the files necessary for installation 32 require_once MYBB_ROOT.'inc/class_timers.php'; 33 require_once MYBB_ROOT.'inc/functions.php'; 34 35 $admin_dir = "admin"; 36 37 // Perform a check if MyBB is already installed or not 38 $installed = false; 39 if(file_exists(MYBB_ROOT."/inc/config.php")) 40 { 41 require MYBB_ROOT."/inc/config.php"; 42 if(is_array($config)) 43 { 44 $installed = true; 45 if(isset($config['admindir'])) 46 { 47 $admin_dir = $config['admindir']; 48 } 49 else if(isset($config['admin_dir'])) 50 { 51 $admin_dir = $config['admin_dir']; 52 } 53 } 54 } 55 56 require_once MYBB_ROOT.'inc/class_xml.php'; 57 require_once MYBB_ROOT.'inc/functions_user.php'; 58 require_once MYBB_ROOT.'inc/class_language.php'; 59 $lang = new MyLanguage(); 60 $lang->set_path(MYBB_ROOT.'install/resources'); 61 $lang->load('language'); 62 63 // Prevent any shut down functions from running 64 $done_shutdown = 1; 65 66 // Include the necessary contants for installation 67 $grouppermignore = array('gid', 'type', 'title', 'description', 'namestyle', 'usertitle', 'stars', 'starimage', 'image'); 68 $groupzerogreater = array('pmquota', 'maxreputationsday', 'attachquota'); 69 $displaygroupfields = array('title', 'description', 'namestyle', 'usertitle', 'stars', 'starimage', 'image'); 70 $fpermfields = array('canview', 'candlattachments', 'canpostthreads', 'canpostreplys', 'canpostattachments', 'canratethreads', 'caneditposts', 'candeleteposts', 'candeletethreads', 'caneditattachments', 'canpostpolls', 'canvotepolls', 'cansearch'); 71 72 // Include the installation resources 73 require_once INSTALL_ROOT.'resources/output.php'; 74 $output = new installerOutput; 75 76 $dboptions = array(); 77 78 if(function_exists('mysqli_connect')) 79 { 80 $dboptions['mysqli'] = array( 81 'class' => 'DB_MySQLi', 82 'title' => 'MySQL Improved', 83 'short_title' => 'MySQLi', 84 'structure_file' => 'mysql_db_tables.php', 85 'population_file' => 'mysql_db_inserts.php' 86 ); 87 } 88 89 if(function_exists('mysql_connect')) 90 { 91 $dboptions['mysql'] = array( 92 'class' => 'DB_MySQL', 93 'title' => 'MySQL', 94 'short_title' => 'MySQL', 95 'structure_file' => 'mysql_db_tables.php', 96 'population_file' => 'mysql_db_inserts.php' 97 ); 98 } 99 100 if(function_exists('pg_connect')) 101 { 102 $dboptions['pgsql'] = array( 103 'class' => 'DB_PgSQL', 104 'title' => 'PostgreSQL', 105 'short_title' => 'PostgreSQL', 106 'structure_file' => 'pgsql_db_tables.php', 107 'population_file' => 'mysql_db_inserts.php' 108 ); 109 } 110 111 if(class_exists('PDO')) 112 { 113 $supported_dbs = PDO::getAvailableDrivers(); 114 if(in_array('sqlite', $supported_dbs)) 115 { 116 $dboptions['sqlite'] = array( 117 'class' => 'DB_SQLite', 118 'title' => 'SQLite 3', 119 'short_title' => 'SQLite', 120 'structure_file' => 'sqlite_db_tables.php', 121 'population_file' => 'mysql_db_inserts.php' 122 ); 123 } 124 } 125 126 if(file_exists('lock')) 127 { 128 $output->print_error($lang->locked); 129 } 130 else if($installed == true && !$mybb->input['action']) 131 { 132 $output->print_header($lang->already_installed, "errormsg", 0); 133 echo $lang->sprintf($lang->mybb_already_installed, $mybb->version); 134 $output->print_footer(); 135 } 136 else 137 { 138 $output->steps = array( 139 'intro' => $lang->welcome, 140 'license' => $lang->license_agreement, 141 'requirements_check' => $lang->req_check, 142 'database_info' => $lang->db_config, 143 'create_tables' => $lang->table_creation, 144 'populate_tables' => $lang->data_insertion, 145 'templates' => $lang->theme_install, 146 'configuration' => $lang->board_config, 147 'adminuser' => $lang->admin_user, 148 'final' => $lang->finish_setup, 149 ); 150 151 if(!isset($mybb->input['action'])) 152 { 153 $mybb->input['action'] = 'intro'; 154 } 155 156 switch($mybb->input['action']) 157 { 158 case 'license': 159 license_agreement(); 160 break; 161 case 'requirements_check': 162 requirements_check(); 163 break; 164 case 'database_info': 165 database_info(); 166 break; 167 case 'create_tables': 168 create_tables(); 169 break; 170 case 'populate_tables': 171 populate_tables(); 172 break; 173 case 'templates': 174 insert_templates(); 175 break; 176 case 'configuration': 177 configure(); 178 break; 179 case 'adminuser'; 180 create_admin_user(); 181 break; 182 case 'final': 183 install_done(); 184 break; 185 default: 186 intro(); 187 break; 188 } 189 } 190 191 function intro() 192 { 193 global $output, $mybb, $lang; 194 195 $output->print_header($lang->welcome, 'welcome'); 196 if(strpos(strtolower($_SERVER['PHP_SELF']), "upload/") !== false) 197 { 198 echo $lang->sprintf($lang->mybb_incorrect_folder); 199 } 200 echo $lang->sprintf($lang->welcome_step, $mybb->version); 201 $output->print_footer('license'); 202 } 203 204 function license_agreement() 205 { 206 global $output, $lang, $mybb; 207 208 ob_start(); 209 $output->print_header($lang->license_agreement, 'license'); 210 211 if($mybb->input['allow_anonymous_info'] == 1) 212 { 213 require_once MYBB_ROOT."inc/functions_serverstats.php"; 214 $build_server_stats = build_server_stats(1, '', $mybb->version_code, $mybb->config['database']['encoding']); 215 216 if($build_server_stats['info_sent_success'] == false) 217 { 218 echo $build_server_stats['info_image']; 219 } 220 } 221 ob_end_flush(); 222 223 $license = <<<EOF 224 <pre> 225 GNU LESSER GENERAL PUBLIC LICENSE 226 Version 3, 29 June 2007 227 228 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> 229 Everyone is permitted to copy and distribute verbatim copies 230 of this license document, but changing it is not allowed. 231 232 233 This version of the GNU Lesser General Public License incorporates 234 the terms and conditions of version 3 of the GNU General Public 235 License, supplemented by the additional permissions listed below. 236 237 0. Additional Definitions. 238 239 As used herein, "this License" refers to version 3 of the GNU Lesser 240 General Public License, and the "GNU GPL" refers to version 3 of the GNU 241 General Public License. 242 243 "The Library" refers to a covered work governed by this License, 244 other than an Application or a Combined Work as defined below. 245 246 An "Application" is any work that makes use of an interface provided 247 by the Library, but which is not otherwise based on the Library. 248 Defining a subclass of a class defined by the Library is deemed a mode 249 of using an interface provided by the Library. 250 251 A "Combined Work" is a work produced by combining or linking an 252 Application with the Library. The particular version of the Library 253 with which the Combined Work was made is also called the "Linked 254 Version". 255 256 The "Minimal Corresponding Source" for a Combined Work means the 257 Corresponding Source for the Combined Work, excluding any source code 258 for portions of the Combined Work that, considered in isolation, are 259 based on the Application, and not on the Linked Version. 260 261 The "Corresponding Application Code" for a Combined Work means the 262 object code and/or source code for the Application, including any data 263 and utility programs needed for reproducing the Combined Work from the 264 Application, but excluding the System Libraries of the Combined Work. 265 266 1. Exception to Section 3 of the GNU GPL. 267 268 You may convey a covered work under sections 3 and 4 of this License 269 without being bound by section 3 of the GNU GPL. 270 271 2. Conveying Modified Versions. 272 273 If you modify a copy of the Library, and, in your modifications, a 274 facility refers to a function or data to be supplied by an Application 275 that uses the facility (other than as an argument passed when the 276 facility is invoked), then you may convey a copy of the modified 277 version: 278 279 a) under this License, provided that you make a good faith effort to 280 ensure that, in the event an Application does not supply the 281 function or data, the facility still operates, and performs 282 whatever part of its purpose remains meaningful, or 283 284 b) under the GNU GPL, with none of the additional permissions of 285 this License applicable to that copy. 286 287 3. Object Code Incorporating Material from Library Header Files. 288 289 The object code form of an Application may incorporate material from 290 a header file that is part of the Library. You may convey such object 291 code under terms of your choice, provided that, if the incorporated 292 material is not limited to numerical parameters, data structure 293 layouts and accessors, or small macros, inline functions and templates 294 (ten or fewer lines in length), you do both of the following: 295 296 a) Give prominent notice with each copy of the object code that the 297 Library is used in it and that the Library and its use are 298 covered by this License. 299 300 b) Accompany the object code with a copy of the GNU GPL and this license 301 document. 302 303 4. Combined Works. 304 305 You may convey a Combined Work under terms of your choice that, 306 taken together, effectively do not restrict modification of the 307 portions of the Library contained in the Combined Work and reverse 308 engineering for debugging such modifications, if you also do each of 309 the following: 310 311 a) Give prominent notice with each copy of the Combined Work that 312 the Library is used in it and that the Library and its use are 313 covered by this License. 314 315 b) Accompany the Combined Work with a copy of the GNU GPL and this license 316 document. 317 318 c) For a Combined Work that displays copyright notices during 319 execution, include the copyright notice for the Library among 320 these notices, as well as a reference directing the user to the 321 copies of the GNU GPL and this license document. 322 323 d) Do one of the following: 324 325 0) Convey the Minimal Corresponding Source under the terms of this 326 License, and the Corresponding Application Code in a form 327 suitable for, and under terms that permit, the user to 328 recombine or relink the Application with a modified version of 329 the Linked Version to produce a modified Combined Work, in the 330 manner specified by section 6 of the GNU GPL for conveying 331 Corresponding Source. 332 333 1) Use a suitable shared library mechanism for linking with the 334 Library. A suitable mechanism is one that (a) uses at run time 335 a copy of the Library already present on the user's computer 336 system, and (b) will operate properly with a modified version 337 of the Library that is interface-compatible with the Linked 338 Version. 339 340 e) Provide Installation Information, but only if you would otherwise 341 be required to provide such information under section 6 of the 342 GNU GPL, and only to the extent that such information is 343 necessary to install and execute a modified version of the 344 Combined Work produced by recombining or relinking the 345 Application with a modified version of the Linked Version. (If 346 you use option 4d0, the Installation Information must accompany 347 the Minimal Corresponding Source and Corresponding Application 348 Code. If you use option 4d1, you must provide the Installation 349 Information in the manner specified by section 6 of the GNU GPL 350 for conveying Corresponding Source.) 351 352 5. Combined Libraries. 353 354 You may place library facilities that are a work based on the 355 Library side by side in a single library together with other library 356 facilities that are not Applications and are not covered by this 357 License, and convey such a combined library under terms of your 358 choice, if you do both of the following: 359 360 a) Accompany the combined library with a copy of the same work based 361 on the Library, uncombined with any other library facilities, 362 conveyed under the terms of this License. 363 364 b) Give prominent notice with the combined library that part of it 365 is a work based on the Library, and explaining where to find the 366 accompanying uncombined form of the same work. 367 368 6. Revised Versions of the GNU Lesser General Public License. 369 370 The Free Software Foundation may publish revised and/or new versions 371 of the GNU Lesser General Public License from time to time. Such new 372 versions will be similar in spirit to the present version, but may 373 differ in detail to address new problems or concerns. 374 375 Each version is given a distinguishing version number. If the 376 Library as you received it specifies that a certain numbered version 377 of the GNU Lesser General Public License "or any later version" 378 applies to it, you have the option of following the terms and 379 conditions either of that published version or of any later version 380 published by the Free Software Foundation. If the Library as you 381 received it does not specify a version number of the GNU Lesser 382 General Public License, you may choose any version of the GNU Lesser 383 General Public License ever published by the Free Software Foundation. 384 385 If the Library as you received it specifies that a proxy can decide 386 whether future versions of the GNU Lesser General Public License shall 387 apply, that proxy's public statement of acceptance of any version is 388 permanent authorization for you to choose that version for the 389 Library. 390 391 GNU GENERAL PUBLIC LICENSE 392 Version 3, 29 June 2007 393 394 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> 395 Everyone is permitted to copy and distribute verbatim copies 396 of this license document, but changing it is not allowed. 397 398 Preamble 399 400 The GNU General Public License is a free, copyleft license for 401 software and other kinds of works. 402 403 The licenses for most software and other practical works are designed 404 to take away your freedom to share and change the works. By contrast, 405 the GNU General Public License is intended to guarantee your freedom to 406 share and change all versions of a program--to make sure it remains free 407 software for all its users. We, the Free Software Foundation, use the 408 GNU General Public License for most of our software; it applies also to 409 any other work released this way by its authors. You can apply it to 410 your programs, too. 411 412 When we speak of free software, we are referring to freedom, not 413 price. Our General Public Licenses are designed to make sure that you 414 have the freedom to distribute copies of free software (and charge for 415 them if you wish), that you receive source code or can get it if you 416 want it, that you can change the software or use pieces of it in new 417 free programs, and that you know you can do these things. 418 419 To protect your rights, we need to prevent others from denying you 420 these rights or asking you to surrender the rights. Therefore, you have 421 certain responsibilities if you distribute copies of the software, or if 422 you modify it: responsibilities to respect the freedom of others. 423 424 For example, if you distribute copies of such a program, whether 425 gratis or for a fee, you must pass on to the recipients the same 426 freedoms that you received. You must make sure that they, too, receive 427 or can get the source code. And you must show them these terms so they 428 know their rights. 429 430 Developers that use the GNU GPL protect your rights with two steps: 431 (1) assert copyright on the software, and (2) offer you this License 432 giving you legal permission to copy, distribute and/or modify it. 433 434 For the developers' and authors' protection, the GPL clearly explains 435 that there is no warranty for this free software. For both users' and 436 authors' sake, the GPL requires that modified versions be marked as 437 changed, so that their problems will not be attributed erroneously to 438 authors of previous versions. 439 440 Some devices are designed to deny users access to install or run 441 modified versions of the software inside them, although the manufacturer 442 can do so. This is fundamentally incompatible with the aim of 443 protecting users' freedom to change the software. The systematic 444 pattern of such abuse occurs in the area of products for individuals to 445 use, which is precisely where it is most unacceptable. Therefore, we 446 have designed this version of the GPL to prohibit the practice for those 447 products. If such problems arise substantially in other domains, we 448 stand ready to extend this provision to those domains in future versions 449 of the GPL, as needed to protect the freedom of users. 450 451 Finally, every program is threatened constantly by software patents. 452 States should not allow patents to restrict development and use of 453 software on general-purpose computers, but in those that do, we wish to 454 avoid the special danger that patents applied to a free program could 455 make it effectively proprietary. To prevent this, the GPL assures that 456 patents cannot be used to render the program non-free. 457 458 The precise terms and conditions for copying, distribution and 459 modification follow. 460 461 TERMS AND CONDITIONS 462 463 0. Definitions. 464 465 "This License" refers to version 3 of the GNU General Public License. 466 467 "Copyright" also means copyright-like laws that apply to other kinds of 468 works, such as semiconductor masks. 469 470 "The Program" refers to any copyrightable work licensed under this 471 License. Each licensee is addressed as "you". "Licensees" and 472 "recipients" may be individuals or organizations. 473 474 To "modify" a work means to copy from or adapt all or part of the work 475 in a fashion requiring copyright permission, other than the making of an 476 exact copy. The resulting work is called a "modified version" of the 477 earlier work or a work "based on" the earlier work. 478 479 A "covered work" means either the unmodified Program or a work based 480 on the Program. 481 482 To "propagate" a work means to do anything with it that, without 483 permission, would make you directly or secondarily liable for 484 infringement under applicable copyright law, except executing it on a 485 computer or modifying a private copy. Propagation includes copying, 486 distribution (with or without modification), making available to the 487 public, and in some countries other activities as well. 488 489 To "convey" a work means any kind of propagation that enables other 490 parties to make or receive copies. Mere interaction with a user through 491 a computer network, with no transfer of a copy, is not conveying. 492 493 An interactive user interface displays "Appropriate Legal Notices" 494 to the extent that it includes a convenient and prominently visible 495 feature that (1) displays an appropriate copyright notice, and (2) 496 tells the user that there is no warranty for the work (except to the 497 extent that warranties are provided), that licensees may convey the 498 work under this License, and how to view a copy of this License. If 499 the interface presents a list of user commands or options, such as a 500 menu, a prominent item in the list meets this criterion. 501 502 1. Source Code. 503 504 The "source code" for a work means the preferred form of the work 505 for making modifications to it. "Object code" means any non-source 506 form of a work. 507 508 A "Standard Interface" means an interface that either is an official 509 standard defined by a recognized standards body, or, in the case of 510 interfaces specified for a particular programming language, one that 511 is widely used among developers working in that language. 512 513 The "System Libraries" of an executable work include anything, other 514 than the work as a whole, that (a) is included in the normal form of 515 packaging a Major Component, but which is not part of that Major 516 Component, and (b) serves only to enable use of the work with that 517 Major Component, or to implement a Standard Interface for which an 518 implementation is available to the public in source code form. A 519 "Major Component", in this context, means a major essential component 520 (kernel, window system, and so on) of the specific operating system 521 (if any) on which the executable work runs, or a compiler used to 522 produce the work, or an object code interpreter used to run it. 523 524 The "Corresponding Source" for a work in object code form means all 525 the source code needed to generate, install, and (for an executable 526 work) run the object code and to modify the work, including scripts to 527 control those activities. However, it does not include the work's 528 System Libraries, or general-purpose tools or generally available free 529 programs which are used unmodified in performing those activities but 530 which are not part of the work. For example, Corresponding Source 531 includes interface definition files associated with source files for 532 the work, and the source code for shared libraries and dynamically 533 linked subprograms that the work is specifically designed to require, 534 such as by intimate data communication or control flow between those 535 subprograms and other parts of the work. 536 537 The Corresponding Source need not include anything that users 538 can regenerate automatically from other parts of the Corresponding 539 Source. 540 541 The Corresponding Source for a work in source code form is that 542 same work. 543 544 2. Basic Permissions. 545 546 All rights granted under this License are granted for the term of 547 copyright on the Program, and are irrevocable provided the stated 548 conditions are met. This License explicitly affirms your unlimited 549 permission to run the unmodified Program. The output from running a 550 covered work is covered by this License only if the output, given its 551 content, constitutes a covered work. This License acknowledges your 552 rights of fair use or other equivalent, as provided by copyright law. 553 554 You may make, run and propagate covered works that you do not 555 convey, without conditions so long as your license otherwise remains 556 in force. You may convey covered works to others for the sole purpose 557 of having them make modifications exclusively for you, or provide you 558 with facilities for running those works, provided that you comply with 559 the terms of this License in conveying all material for which you do 560 not control copyright. Those thus making or running the covered works 561 for you must do so exclusively on your behalf, under your direction 562 and control, on terms that prohibit them from making any copies of 563 your copyrighted material outside their relationship with you. 564 565 Conveying under any other circumstances is permitted solely under 566 the conditions stated below. Sublicensing is not allowed; section 10 567 makes it unnecessary. 568 569 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 570 571 No covered work shall be deemed part of an effective technological 572 measure under any applicable law fulfilling obligations under article 573 11 of the WIPO copyright treaty adopted on 20 December 1996, or 574 similar laws prohibiting or restricting circumvention of such 575 measures. 576 577 When you convey a covered work, you waive any legal power to forbid 578 circumvention of technological measures to the extent such circumvention 579 is effected by exercising rights under this License with respect to 580 the covered work, and you disclaim any intention to limit operation or 581 modification of the work as a means of enforcing, against the work's 582 users, your or third parties' legal rights to forbid circumvention of 583 technological measures. 584 585 4. Conveying Verbatim Copies. 586 587 You may convey verbatim copies of the Program's source code as you 588 receive it, in any medium, provided that you conspicuously and 589 appropriately publish on each copy an appropriate copyright notice; 590 keep intact all notices stating that this License and any 591 non-permissive terms added in accord with section 7 apply to the code; 592 keep intact all notices of the absence of any warranty; and give all 593 recipients a copy of this License along with the Program. 594 595 You may charge any price or no price for each copy that you convey, 596 and you may offer support or warranty protection for a fee. 597 598 5. Conveying Modified Source Versions. 599 600 You may convey a work based on the Program, or the modifications to 601 produce it from the Program, in the form of source code under the 602 terms of section 4, provided that you also meet all of these conditions: 603 604 a) The work must carry prominent notices stating that you modified 605 it, and giving a relevant date. 606 607 b) The work must carry prominent notices stating that it is 608 released under this License and any conditions added under section 609 7. This requirement modifies the requirement in section 4 to 610 "keep intact all notices". 611 612 c) You must license the entire work, as a whole, under this 613 License to anyone who comes into possession of a copy. This 614 License will therefore apply, along with any applicable section 7 615 additional terms, to the whole of the work, and all its parts, 616 regardless of how they are packaged. This License gives no 617 permission to license the work in any other way, but it does not 618 invalidate such permission if you have separately received it. 619 620 d) If the work has interactive user interfaces, each must display 621 Appropriate Legal Notices; however, if the Program has interactive 622 interfaces that do not display Appropriate Legal Notices, your 623 work need not make them do so. 624 625 A compilation of a covered work with other separate and independent 626 works, which are not by their nature extensions of the covered work, 627 and which are not combined with it such as to form a larger program, 628 in or on a volume of a storage or distribution medium, is called an 629 "aggregate" if the compilation and its resulting copyright are not 630 used to limit the access or legal rights of the compilation's users 631 beyond what the individual works permit. Inclusion of a covered work 632 in an aggregate does not cause this License to apply to the other 633 parts of the aggregate. 634 635 6. Conveying Non-Source Forms. 636 637 You may convey a covered work in object code form under the terms 638 of sections 4 and 5, provided that you also convey the 639 machine-readable Corresponding Source under the terms of this License, 640 in one of these ways: 641 642 a) Convey the object code in, or embodied in, a physical product 643 (including a physical distribution medium), accompanied by the 644 Corresponding Source fixed on a durable physical medium 645 customarily used for software interchange. 646 647 b) Convey the object code in, or embodied in, a physical product 648 (including a physical distribution medium), accompanied by a 649 written offer, valid for at least three years and valid for as 650 long as you offer spare parts or customer support for that product 651 model, to give anyone who possesses the object code either (1) a 652 copy of the Corresponding Source for all the software in the 653 product that is covered by this License, on a durable physical 654 medium customarily used for software interchange, for a price no 655 more than your reasonable cost of physically performing this 656 conveying of source, or (2) access to copy the 657 Corresponding Source from a network server at no charge. 658 659 c) Convey individual copies of the object code with a copy of the 660 written offer to provide the Corresponding Source. This 661 alternative is allowed only occasionally and noncommercially, and 662 only if you received the object code with such an offer, in accord 663 with subsection 6b. 664 665 d) Convey the object code by offering access from a designated 666 place (gratis or for a charge), and offer equivalent access to the 667 Corresponding Source in the same way through the same place at no 668 further charge. You need not require recipients to copy the 669 Corresponding Source along with the object code. If the place to 670 copy the object code is a network server, the Corresponding Source 671 may be on a different server (operated by you or a third party) 672 that supports equivalent copying facilities, provided you maintain 673 clear directions next to the object code saying where to find the 674 Corresponding Source. Regardless of what server hosts the 675 Corresponding Source, you remain obligated to ensure that it is 676 available for as long as needed to satisfy these requirements. 677 678 e) Convey the object code using peer-to-peer transmission, provided 679 you inform other peers where the object code and Corresponding 680 Source of the work are being offered to the general public at no 681 charge under subsection 6d. 682 683 A separable portion of the object code, whose source code is excluded 684 from the Corresponding Source as a System Library, need not be 685 included in conveying the object code work. 686 687 A "User Product" is either (1) a "consumer product", which means any 688 tangible personal property which is normally used for personal, family, 689 or household purposes, or (2) anything designed or sold for incorporation 690 into a dwelling. In determining whether a product is a consumer product, 691 doubtful cases shall be resolved in favor of coverage. For a particular 692 product received by a particular user, "normally used" refers to a 693 typical or common use of that class of product, regardless of the status 694 of the particular user or of the way in which the particular user 695 actually uses, or expects or is expected to use, the product. A product 696 is a consumer product regardless of whether the product has substantial 697 commercial, industrial or non-consumer uses, unless such uses represent 698 the only significant mode of use of the product. 699 700 "Installation Information" for a User Product means any methods, 701 procedures, authorization keys, or other information required to install 702 and execute modified versions of a covered work in that User Product from 703 a modified version of its Corresponding Source. The information must 704 suffice to ensure that the continued functioning of the modified object 705 code is in no case prevented or interfered with solely because 706 modification has been made. 707 708 If you convey an object code work under this section in, or with, or 709 specifically for use in, a User Product, and the conveying occurs as 710 part of a transaction in which the right of possession and use of the 711 User Product is transferred to the recipient in perpetuity or for a 712 fixed term (regardless of how the transaction is characterized), the 713 Corresponding Source conveyed under this section must be accompanied 714 by the Installation Information. But this requirement does not apply 715 if neither you nor any third party retains the ability to install 716 modified object code on the User Product (for example, the work has 717 been installed in ROM). 718 719 The requirement to provide Installation Information does not include a 720 requirement to continue to provide support service, warranty, or updates 721 for a work that has been modified or installed by the recipient, or for 722 the User Product in which it has been modified or installed. Access to a 723 network may be denied when the modification itself materially and 724 adversely affects the operation of the network or violates the rules and 725 protocols for communication across the network. 726 727 Corresponding Source conveyed, and Installation Information provided, 728 in accord with this section must be in a format that is publicly 729 documented (and with an implementation available to the public in 730 source code form), and must require no special password or key for 731 unpacking, reading or copying. 732 733 7. Additional Terms. 734 735 "Additional permissions" are terms that supplement the terms of this 736 License by making exceptions from one or more of its conditions. 737 Additional permissions that are applicable to the entire Program shall 738 be treated as though they were included in this License, to the extent 739 that they are valid under applicable law. If additional permissions 740 apply only to part of the Program, that part may be used separately 741 under those permissions, but the entire Program remains governed by 742 this License without regard to the additional permissions. 743 744 When you convey a copy of a covered work, you may at your option 745 remove any additional permissions from that copy, or from any part of 746 it. (Additional permissions may be written to require their own 747 removal in certain cases when you modify the work.) You may place 748 additional permissions on material, added by you to a covered work, 749 for which you have or can give appropriate copyright permission. 750 751 Notwithstanding any other provision of this License, for material you 752 add to a covered work, you may (if authorized by the copyright holders of 753 that material) supplement the terms of this License with terms: 754 755 a) Disclaiming warranty or limiting liability differently from the 756 terms of sections 15 and 16 of this License; or 757 758 b) Requiring preservation of specified reasonable legal notices or 759 author attributions in that material or in the Appropriate Legal 760 Notices displayed by works containing it; or 761 762 c) Prohibiting misrepresentation of the origin of that material, or 763 requiring that modified versions of such material be marked in 764 reasonable ways as different from the original version; or 765 766 d) Limiting the use for publicity purposes of names of licensors or 767 authors of the material; or 768 769 e) Declining to grant rights under trademark law for use of some 770 trade names, trademarks, or service marks; or 771 772 f) Requiring indemnification of licensors and authors of that 773 material by anyone who conveys the material (or modified versions of 774 it) with contractual assumptions of liability to the recipient, for 775 any liability that these contractual assumptions directly impose on 776 those licensors and authors. 777 778 All other non-permissive additional terms are considered "further 779 restrictions" within the meaning of section 10. If the Program as you 780 received it, or any part of it, contains a notice stating that it is 781 governed by this License along with a term that is a further 782 restriction, you may remove that term. If a license document contains 783 a further restriction but permits relicensing or conveying under this 784 License, you may add to a covered work material governed by the terms 785 of that license document, provided that the further restriction does 786 not survive such relicensing or conveying. 787 788 If you add terms to a covered work in accord with this section, you 789 must place, in the relevant source files, a statement of the 790 additional terms that apply to those files, or a notice indicating 791 where to find the applicable terms. 792 793 Additional terms, permissive or non-permissive, may be stated in the 794 form of a separately written license, or stated as exceptions; 795 the above requirements apply either way. 796 797 8. Termination. 798 799 You may not propagate or modify a covered work except as expressly 800 provided under this License. Any attempt otherwise to propagate or 801 modify it is void, and will automatically terminate your rights under 802 this License (including any patent licenses granted under the third 803 paragraph of section 11). 804 805 However, if you cease all violation of this License, then your 806 license from a particular copyright holder is reinstated (a) 807 provisionally, unless and until the copyright holder explicitly and 808 finally terminates your license, and (b) permanently, if the copyright 809 holder fails to notify you of the violation by some reasonable means 810 prior to 60 days after the cessation. 811 812 Moreover, your license from a particular copyright holder is 813 reinstated permanently if the copyright holder notifies you of the 814 violation by some reasonable means, this is the first time you have 815 received notice of violation of this License (for any work) from that 816 copyright holder, and you cure the violation prior to 30 days after 817 your receipt of the notice. 818 819 Termination of your rights under this section does not terminate the 820 licenses of parties who have received copies or rights from you under 821 this License. If your rights have been terminated and not permanently 822 reinstated, you do not qualify to receive new licenses for the same 823 material under section 10. 824 825 9. Acceptance Not Required for Having Copies. 826 827 You are not required to accept this License in order to receive or 828 run a copy of the Program. Ancillary propagation of a covered work 829 occurring solely as a consequence of using peer-to-peer transmission 830 to receive a copy likewise does not require acceptance. However, 831 nothing other than this License grants you permission to propagate or 832 modify any covered work. These actions infringe copyright if you do 833 not accept this License. Therefore, by modifying or propagating a 834 covered work, you indicate your acceptance of this License to do so. 835 836 10. Automatic Licensing of Downstream Recipients. 837 838 Each time you convey a covered work, the recipient automatically 839 receives a license from the original licensors, to run, modify and 840 propagate that work, subject to this License. You are not responsible 841 for enforcing compliance by third parties with this License. 842 843 An "entity transaction" is a transaction transferring control of an 844 organization, or substantially all assets of one, or subdividing an 845 organization, or merging organizations. If propagation of a covered 846 work results from an entity transaction, each party to that 847 transaction who receives a copy of the work also receives whatever 848 licenses to the work the party's predecessor in interest had or could 849 give under the previous paragraph, plus a right to possession of the 850 Corresponding Source of the work from the predecessor in interest, if 851 the predecessor has it or can get it with reasonable efforts. 852 853 You may not impose any further restrictions on the exercise of the 854 rights granted or affirmed under this License. For example, you may 855 not impose a license fee, royalty, or other charge for exercise of 856 rights granted under this License, and you may not initiate litigation 857 (including a cross-claim or counterclaim in a lawsuit) alleging that 858 any patent claim is infringed by making, using, selling, offering for 859 sale, or importing the Program or any portion of it. 860 861 11. Patents. 862 863 A "contributor" is a copyright holder who authorizes use under this 864 License of the Program or a work on which the Program is based. The 865 work thus licensed is called the contributor's "contributor version". 866 867 A contributor's "essential patent claims" are all patent claims 868 owned or controlled by the contributor, whether already acquired or 869 hereafter acquired, that would be infringed by some manner, permitted 870 by this License, of making, using, or selling its contributor version, 871 but do not include claims that would be infringed only as a 872 consequence of further modification of the contributor version. For 873 purposes of this definition, "control" includes the right to grant 874 patent sublicenses in a manner consistent with the requirements of 875 this License. 876 877 Each contributor grants you a non-exclusive, worldwide, royalty-free 878 patent license under the contributor's essential patent claims, to 879 make, use, sell, offer for sale, import and otherwise run, modify and 880 propagate the contents of its contributor version. 881 882 In the following three paragraphs, a "patent license" is any express 883 agreement or commitment, however denominated, not to enforce a patent 884 (such as an express permission to practice a patent or covenant not to 885 sue for patent infringement). To "grant" such a patent license to a 886 party means to make such an agreement or commitment not to enforce a 887 patent against the party. 888 889 If you convey a covered work, knowingly relying on a patent license, 890 and the Corresponding Source of the work is not available for anyone 891 to copy, free of charge and under the terms of this License, through a 892 publicly available network server or other readily accessible means, 893 then you must either (1) cause the Corresponding Source to be so 894 available, or (2) arrange to deprive yourself of the benefit of the 895 patent license for this particular work, or (3) arrange, in a manner 896 consistent with the requirements of this License, to extend the patent 897 license to downstream recipients. "Knowingly relying" means you have 898 actual knowledge that, but for the patent license, your conveying the 899 covered work in a country, or your recipient's use of the covered work 900 in a country, would infringe one or more identifiable patents in that 901 country that you have reason to believe are valid. 902 903 If, pursuant to or in connection with a single transaction or 904 arrangement, you convey, or propagate by procuring conveyance of, a 905 covered work, and grant a patent license to some of the parties 906 receiving the covered work authorizing them to use, propagate, modify 907 or convey a specific copy of the covered work, then the patent license 908 you grant is automatically extended to all recipients of the covered 909 work and works based on it. 910 911 A patent license is "discriminatory" if it does not include within 912 the scope of its coverage, prohibits the exercise of, or is 913 conditioned on the non-exercise of one or more of the rights that are 914 specifically granted under this License. You may not convey a covered 915 work if you are a party to an arrangement with a third party that is 916 in the business of distributing software, under which you make payment 917 to the third party based on the extent of your activity of conveying 918 the work, and under which the third party grants, to any of the 919 parties who would receive the covered work from you, a discriminatory 920 patent license (a) in connection with copies of the covered work 921 conveyed by you (or copies made from those copies), or (b) primarily 922 for and in connection with specific products or compilations that 923 contain the covered work, unless you entered into that arrangement, 924 or that patent license was granted, prior to 28 March 2007. 925 926 Nothing in this License shall be construed as excluding or limiting 927 any implied license or other defenses to infringement that may 928 otherwise be available to you under applicable patent law. 929 930 12. No Surrender of Others' Freedom. 931 932 If conditions are imposed on you (whether by court order, agreement or 933 otherwise) that contradict the conditions of this License, they do not 934 excuse you from the conditions of this License. If you cannot convey a 935 covered work so as to satisfy simultaneously your obligations under this 936 License and any other pertinent obligations, then as a consequence you may 937 not convey it at all. For example, if you agree to terms that obligate you 938 to collect a royalty for further conveying from those to whom you convey 939 the Program, the only way you could satisfy both those terms and this 940 License would be to refrain entirely from conveying the Program. 941 942 13. Use with the GNU Affero General Public License. 943 944 Notwithstanding any other provision of this License, you have 945 permission to link or combine any covered work with a work licensed 946 under version 3 of the GNU Affero General Public License into a single 947 combined work, and to convey the resulting work. The terms of this 948 License will continue to apply to the part which is the covered work, 949 but the special requirements of the GNU Affero General Public License, 950 section 13, concerning interaction through a network will apply to the 951 combination as such. 952 953 14. Revised Versions of this License. 954 955 The Free Software Foundation may publish revised and/or new versions of 956 the GNU General Public License from time to time. Such new versions will 957 be similar in spirit to the present version, but may differ in detail to 958 address new problems or concerns. 959 960 Each version is given a distinguishing version number. If the 961 Program specifies that a certain numbered version of the GNU General 962 Public License "or any later version" applies to it, you have the 963 option of following the terms and conditions either of that numbered 964 version or of any later version published by the Free Software 965 Foundation. If the Program does not specify a version number of the 966 GNU General Public License, you may choose any version ever published 967 by the Free Software Foundation. 968 969 If the Program specifies that a proxy can decide which future 970 versions of the GNU General Public License can be used, that proxy's 971 public statement of acceptance of a version permanently authorizes you 972 to choose that version for the Program. 973 974 Later license versions may give you additional or different 975 permissions. However, no additional obligations are imposed on any 976 author or copyright holder as a result of your choosing to follow a 977 later version. 978 979 15. Disclaimer of Warranty. 980 981 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 982 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 983 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 984 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 985 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 986 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 987 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 988 ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 989 990 16. Limitation of Liability. 991 992 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 993 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 994 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 995 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 996 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 997 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 998 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 999 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 1000 SUCH DAMAGES. 1001 1002 17. Interpretation of Sections 15 and 16. 1003 1004 If the disclaimer of warranty and limitation of liability provided 1005 above cannot be given local legal effect according to their terms, 1006 reviewing courts shall apply local law that most closely approximates 1007 an absolute waiver of all civil liability in connection with the 1008 Program, unless a warranty or assumption of liability accompanies a 1009 copy of the Program in return for a fee. 1010 1011 END OF TERMS AND CONDITIONS 1012 </pre> 1013 EOF; 1014 echo $lang->sprintf($lang->license_step, $license); 1015 $output->print_footer('requirements_check'); 1016 } 1017 1018 function requirements_check() 1019 { 1020 global $output, $mybb, $dboptions, $lang; 1021 1022 $mybb->input['action'] = "requirements_check"; 1023 $output->print_header($lang->req_check, 'requirements'); 1024 echo $lang->req_step_top; 1025 $errors = array(); 1026 $showerror = 0; 1027 1028 if(!file_exists(MYBB_ROOT."/inc/config.php")) 1029 { 1030 if(!@rename(MYBB_ROOT."/inc/config.default.php", MYBB_ROOT."/inc/config.php")) 1031 { 1032 if(!$configwritable) 1033 { 1034 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_configdefaultfile); 1035 $configstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable); 1036 $showerror = 1; 1037 } 1038 } 1039 } 1040 1041 // Check PHP Version 1042 if(version_compare(PHP_VERSION, '5.1.0', "<")) 1043 { 1044 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->sprintf($lang->req_step_error_phpversion, PHP_VERSION)); 1045 $phpversion = $lang->sprintf($lang->req_step_span_fail, PHP_VERSION); 1046 $showerror = 1; 1047 } 1048 else 1049 { 1050 $phpversion = $lang->sprintf($lang->req_step_span_pass, PHP_VERSION); 1051 } 1052 1053 if(function_exists('mb_detect_encoding')) 1054 { 1055 $mboptions[] = $lang->multi_byte; 1056 } 1057 1058 if(function_exists('iconv')) 1059 { 1060 $mboptions[] = 'iconv'; 1061 } 1062 1063 // Check Multibyte extensions 1064 if(count($mboptions) < 1) 1065 { 1066 $mbstatus = $lang->sprintf($lang->req_step_span_fail, $lang->none); 1067 } 1068 else 1069 { 1070 $mbstatus = implode(', ', $mboptions); 1071 } 1072 1073 // Check database engines 1074 if(count($dboptions) < 1) 1075 { 1076 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_dboptions); 1077 $dbsupportlist = $lang->sprintf($lang->req_step_span_fail, $lang->none); 1078 $showerror = 1; 1079 } 1080 else 1081 { 1082 foreach($dboptions as $dboption) 1083 { 1084 $dbsupportlist[] = $dboption['title']; 1085 } 1086 $dbsupportlist = implode(', ', $dbsupportlist); 1087 } 1088 1089 // Check XML parser is installed 1090 if(!function_exists('xml_parser_create')) 1091 { 1092 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_xmlsupport); 1093 $xmlstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_installed); 1094 $showerror = 1; 1095 } 1096 else 1097 { 1098 $xmlstatus = $lang->sprintf($lang->req_step_span_pass, $lang->installed); 1099 } 1100 1101 // Check config file is writable 1102 $configwritable = @fopen(MYBB_ROOT.'inc/config.php', 'w'); 1103 if(!$configwritable) 1104 { 1105 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_configfile); 1106 $configstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable); 1107 $showerror = 1; 1108 } 1109 else 1110 { 1111 $configstatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable); 1112 } 1113 @fclose($configwritable); 1114 1115 // Check settings file is writable 1116 $settingswritable = @fopen(MYBB_ROOT.'inc/settings.php', 'w'); 1117 if(!$settingswritable) 1118 { 1119 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_settingsfile); 1120 $settingsstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable); 1121 $showerror = 1; 1122 } 1123 else 1124 { 1125 $settingsstatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable); 1126 } 1127 @fclose($settingswritable); 1128 1129 // Check cache directory is writable 1130 $cachewritable = @fopen(MYBB_ROOT.'cache/test.write', 'w'); 1131 if(!$cachewritable) 1132 { 1133 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_cachedir); 1134 $cachestatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable); 1135 $showerror = 1; 1136 @fclose($cachewritable); 1137 } 1138 else 1139 { 1140 $cachestatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable); 1141 @fclose($cachewritable); 1142 @my_chmod(MYBB_ROOT.'cache', '0777'); 1143 @my_chmod(MYBB_ROOT.'cache/test.write', '0777'); 1144 @unlink(MYBB_ROOT.'cache/test.write'); 1145 } 1146 1147 // Check upload directory is writable 1148 $uploadswritable = @fopen(MYBB_ROOT.'uploads/test.write', 'w'); 1149 if(!$uploadswritable) 1150 { 1151 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_uploaddir); 1152 $uploadsstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable); 1153 $showerror = 1; 1154 @fclose($uploadswritable); 1155 } 1156 else 1157 { 1158 $uploadsstatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable); 1159 @fclose($uploadswritable); 1160 @my_chmod(MYBB_ROOT.'uploads', '0777'); 1161 @my_chmod(MYBB_ROOT.'uploads/test.write', '0777'); 1162 @unlink(MYBB_ROOT.'uploads/test.write'); 1163 } 1164 1165 // Check avatar directory is writable 1166 $avatarswritable = @fopen(MYBB_ROOT.'uploads/avatars/test.write', 'w'); 1167 if(!$avatarswritable) 1168 { 1169 $errors[] = $lang->sprintf($lang->req_step_error_box, $lang->req_step_error_avatardir); 1170 $avatarsstatus = $lang->sprintf($lang->req_step_span_fail, $lang->not_writable); 1171 $showerror = 1; 1172 @fclose($avatarswritable); 1173 } 1174 else 1175 { 1176 $avatarsstatus = $lang->sprintf($lang->req_step_span_pass, $lang->writable); 1177 @fclose($avatarswritable); 1178 @my_chmod(MYBB_ROOT.'uploads/avatars', '0777'); 1179 @my_chmod(MYBB_ROOT.'uploads/avatars/test.write', '0777'); 1180 @unlink(MYBB_ROOT.'uploads/avatars/test.write'); 1181 } 1182 1183 // Output requirements page 1184 echo $lang->sprintf($lang->req_step_reqtable, $phpversion, $dbsupportlist, $mbstatus, $xmlstatus, $configstatus, $settingsstatus, $cachestatus, $uploadsstatus, $avatarsstatus); 1185 1186 if($showerror == 1) 1187 { 1188 $error_list = error_list($errors); 1189 echo $lang->sprintf($lang->req_step_error_tablelist, $error_list); 1190 echo "\n <input type=\"hidden\" name=\"action\" value=\"{$mybb->input['action']}\" />"; 1191 echo "\n <div id=\"next_button\"><input type=\"submit\" class=\"submit_button\" value=\"{$lang->recheck} »\" /></div><br style=\"clear: both;\" />\n"; 1192 $output->print_footer(); 1193 } 1194 else 1195 { 1196 echo $lang->req_step_reqcomplete; 1197 $output->print_footer('database_info'); 1198 } 1199 } 1200 1201 function database_info() 1202 { 1203 global $output, $dbinfo, $errors, $mybb, $dboptions, $lang; 1204 1205 $mybb->input['action'] = 'database_info'; 1206 $output->print_header($lang->db_config, 'dbconfig'); 1207 1208 echo "<script type=\"text/javascript\"> 1209 function updateDBSettings() 1210 { 1211 dbengine = \$('dbengine').options[\$('dbengine').selectedIndex].value; 1212 $$('.db_settings').each(function(element) 1213 { 1214 element.className = 'db_settings'; 1215 if(dbengine+'_settings' == element.id) 1216 { 1217 Element.show(element); 1218 } 1219 else 1220 { 1221 Element.hide(element); 1222 } 1223 }); 1224 } 1225 Event.observe(window, 'load', updateDBSettings); 1226 </script>"; 1227 1228 // Check for errors from this stage 1229 if(is_array($errors)) 1230 { 1231 $error_list = error_list($errors); 1232 echo $lang->sprintf($lang->db_step_error_config, $error_list); 1233 } 1234 else 1235 { 1236 echo $lang->db_step_config_db; 1237 } 1238 1239 // Loop through database engines 1240 foreach($dboptions as $dbfile => $dbtype) 1241 { 1242 if($mybb->input['dbengine'] == $dbfile) 1243 { 1244 $dbengines .= "<option value=\"{$dbfile}\" selected=\"selected\">{$dbtype['title']}</option>"; 1245 } 1246 else 1247 { 1248 $dbengines .= "<option value=\"{$dbfile}\">{$dbtype['title']}</option>"; 1249 } 1250 } 1251 1252 foreach($dboptions as $dbfile => $dbtype) 1253 { 1254 require_once MYBB_ROOT."inc/db_{$dbfile}.php"; 1255 $db = new $dbtype['class']; 1256 $encodings = $db->fetch_db_charsets(); 1257 $encoding_select = ''; 1258 if(!$mybb->input['config'][$dbfile]['dbhost']) 1259 { 1260 $mybb->input['config'][$dbfile]['dbhost'] = "localhost"; 1261 } 1262 if(!$mybb->input['config'][$dbfile]['tableprefix']) 1263 { 1264 $mybb->input['config'][$dbfile]['tableprefix'] = "mybb_"; 1265 } 1266 if(!$mybb->input['config'][$dbfile]['encoding']) 1267 { 1268 $mybb->input['config'][$dbfile]['encoding'] = "utf8"; 1269 } 1270 1271 $class = ''; 1272 if(!$first && !$mybb->input['dbengine']) 1273 { 1274 $mybb->input['dbengine'] = $dbfile; 1275 $first = true; 1276 } 1277 if($dbfile == $mybb->input['dbengine']) 1278 { 1279 $class = "_selected"; 1280 } 1281 1282 $db_info[$dbfile] = " 1283 <tbody id=\"{$dbfile}_settings\" class=\"db_settings db_type{$class}\"> 1284 <tr> 1285 <th colspan=\"2\" class=\"first last\">{$dbtype['title']} {$lang->database_settings}</th> 1286 </tr>"; 1287 1288 // SQLite gets some special settings 1289 if($dbfile == 'sqlite') 1290 { 1291 $db_info[$dbfile] .= " 1292 <tr class=\"alt_row\"> 1293 <td class=\"first\"><label for=\"config_{$dbfile}_dbname\">{$lang->database_path}</label></td> 1294 <td class=\"last alt_col\"><input type=\"text\" class=\"text_input\" name=\"config[{$dbfile}][dbname]\" id=\"config_{$dbfile}_dbname\" value=\"".htmlspecialchars_uni($mybb->input['config'][$dbfile]['dbname'])."\" /></td> 1295 </tr>"; 1296 } 1297 // Others get db host, username, password etc 1298 else 1299 { 1300 $db_info[$dbfile] .= " 1301 <tr class=\"alt_row\"> 1302 <td class=\"first\"><label for=\"config_{$dbfile}_dbhost\">{$lang->database_host}</label></td> 1303 <td class=\"last alt_col\"><input type=\"text\" class=\"text_input\" name=\"config[{$dbfile}][dbhost]\" id=\"config_{$dbfile}_dbhost\" value=\"".htmlspecialchars_uni($mybb->input['config'][$dbfile]['dbhost'])."\" /></td> 1304 </tr> 1305 <tr> 1306 <td class=\"first\"><label for=\"config_{$dbfile}_dbuser\">{$lang->database_user}</label></td> 1307 <td class=\"last alt_col\"><input type=\"text\" class=\"text_input\" name=\"config[{$dbfile}][dbuser]\" id=\"config_{$dbfile}_dbuser\" value=\"".htmlspecialchars_uni($mybb->input['config'][$dbfile]['dbuser'])."\" /></td> 1308 </tr> 1309 <tr class=\"alt_row\"> 1310 <td class=\"first\"><label for=\"config_{$dbfile}_dbpass\">{$lang->database_pass}</label></td> 1311 <td class=\"last alt_col\"><input type=\"password\" class=\"text_input\" name=\"config[{$dbfile}][dbpass]\" id=\"config_{$dbfile}_dbpass\" value=\"".htmlspecialchars_uni($mybb->input['config'][$dbfile]['dbpass'])."\" /></td> 1312 </tr> 1313 <tr class=\"last\"> 1314 <td class=\"first\"><label for=\"config_{$dbfile}_dbname\">{$lang->database_name}</label></td> 1315 <td class=\"last alt_col\"><input type=\"text\" class=\"text_input\" name=\"config[{$dbfile}][dbname]\" id=\"config_{$dbfile}_dbname\" value=\"".htmlspecialchars_uni($mybb->input['config'][$dbfile]['dbname'])."\" /></td> 1316 </tr>"; 1317 } 1318 1319 // Now we're up to table settings 1320 $db_info[$dbfile] .= " 1321 <tr> 1322 <th colspan=\"2\" class=\"first last\">{$dbtype['title']} {$lang->table_settings}</th> 1323 </tr> 1324 <tr class=\"first\"> 1325 <td class=\"first\"><label for=\"config_{$dbfile}_tableprefix\">{$lang->table_prefix}</label></td> 1326 <td class=\"last alt_col\"><input type=\"text\" class=\"text_input\" name=\"config[{$dbfile}][tableprefix]\" id=\"config_{$dbfile}_tableprefix\" value=\"".htmlspecialchars_uni($mybb->input['config'][$dbfile]['tableprefix'])."\" /></td> 1327 </tr> 1328 "; 1329 1330 // Encoding selection only if supported 1331 if(is_array($encodings)) 1332 { 1333 $select_options = ""; 1334 foreach($encodings as $encoding => $title) 1335 { 1336 if($mybb->input['config'][$dbfile]['encoding'] == $encoding) 1337 { 1338 $select_options .= "<option value=\"{$encoding}\" selected=\"selected\">{$title}</option>"; 1339 } 1340 else 1341 { 1342 $select_options .= "<option value=\"{$encoding}\">{$title}</option>"; 1343 } 1344 } 1345 $db_info[$dbfile] .= " 1346 <tr class=\"last\"> 1347 <td class=\"first\"><label for=\"config_{$dbfile}_encoding\">{$lang->table_encoding}</label></td> 1348 <td class=\"last alt_col\"><select name=\"config[{$dbfile}][encoding]\" id=\"config_{$dbfile}_encoding\">{$select_options}</select></td> 1349 </tr> 1350 </tbody>"; 1351 } 1352 } 1353 $dbconfig = implode("", $db_info); 1354 1355 echo $lang->sprintf($lang->db_step_config_table, $dbengines, $dbconfig); 1356 $output->print_footer('create_tables'); 1357 } 1358 1359 function create_tables() 1360 { 1361 global $output, $dbinfo, $errors, $mybb, $dboptions, $lang; 1362 1363 if(!file_exists(MYBB_ROOT."inc/db_{$mybb->input['dbengine']}.php")) 1364 { 1365 $errors[] = $lang->db_step_error_invalidengine; 1366 database_info(); 1367 } 1368 1369 $config = $mybb->input['config'][$mybb->input['dbengine']]; 1370 1371 if(strstr($mybb->input['dbengine'], "sqlite") !== false) 1372 { 1373 if(strstr($config['dbname'], "./") !== false || strstr($config['dbname'], "../") !== false || empty($config['dbname'])) 1374 { 1375 $errors[] = $lang->db_step_error_sqlite_invalid_dbname; 1376 database_info(); 1377 } 1378 } 1379 1380 // Attempt to connect to the db 1381 require_once MYBB_ROOT."inc/db_{$mybb->input['dbengine']}.php"; 1382 switch($mybb->input['dbengine']) 1383 { 1384 case "sqlite": 1385 $db = new DB_SQLite; 1386 break; 1387 case "pgsql": 1388 $db = new DB_PgSQL; 1389 break; 1390 case "mysqli": 1391 $db = new DB_MySQLi; 1392 break; 1393 default: 1394 $db = new DB_MySQL; 1395 } 1396 $db->error_reporting = 0; 1397 1398 $connect_array = array( 1399 "hostname" => $config['dbhost'], 1400 "username" => $config['dbuser'], 1401 "password" => $config['dbpass'], 1402 "database" => $config['dbname'], 1403 "encoding" => $config['encoding'] 1404 ); 1405 1406 $connection = $db->connect($connect_array); 1407 if($connection === false) 1408 { 1409 $errors[] = $lang->sprintf($lang->db_step_error_noconnect, $config['dbhost']); 1410 } 1411 // double check if the DB exists for MySQL 1412 elseif(method_exists($db, 'select_db') && !$db->select_db($config['dbname'])) 1413 { 1414 $errors[] = $lang->sprintf($lang->db_step_error_nodbname, $config['dbname']); 1415 } 1416 1417 // Most DB engines only allow certain characters in the table name. Oracle requires an alphabetic character first. 1418 if((!preg_match("#^[A-Za-z][A-Za-z0-9_]*$#", $config['tableprefix'])) && $config['tableprefix'] != '') 1419 { 1420 $errors[] = $lang->db_step_error_invalid_tableprefix; 1421 } 1422 1423 // Needs to be smaller then 64 characters total (MySQL Limit). 1424 // This allows 24 characters for the actual table name, which should be sufficient. 1425 if(strlen($config['tableprefix']) > 40) 1426 { 1427 $errors[] = $lang->db_step_error_tableprefix_too_long; 1428 } 1429 1430 if(is_array($errors)) 1431 { 1432 database_info(); 1433 } 1434 1435 // Decide if we can use a database encoding or not 1436 if($db->fetch_db_charsets() != false) 1437 { 1438 $db_encoding = "\$config['database']['encoding'] = '{$config['encoding']}';"; 1439 } 1440 else 1441 { 1442 $db_encoding = "// \$config['database']['encoding'] = '{$config['encoding']}';"; 1443 } 1444 1445 $config['dbpass'] = addslashes($config['dbpass']); 1446 1447 // Write the configuration file 1448 $configdata = "<?php 1449 /** 1450 * Database configuration 1451 * 1452 * Please see the MyBB Docs for advanced 1453 * database configuration for larger installations 1454 * http://docs.mybb.com/ 1455 */ 1456 1457 \$config['database']['type'] = '{$mybb->input['dbengine']}'; 1458 \$config['database']['database'] = '{$config['dbname']}'; 1459 \$config['database']['table_prefix'] = '{$config['tableprefix']}'; 1460 1461 \$config['database']['hostname'] = '{$config['dbhost']}'; 1462 \$config['database']['username'] = '{$config['dbuser']}'; 1463 \$config['database']['password'] = '{$config['dbpass']}'; 1464 1465 /** 1466 * Admin CP directory 1467 * For security reasons, it is recommended you 1468 * rename your Admin CP directory. You then need 1469 * to adjust the value below to point to the 1470 * new directory. 1471 */ 1472 1473 \$config['admin_dir'] = 'admin'; 1474 1475 /** 1476 * Hide all Admin CP links 1477 * If you wish to hide all Admin CP links 1478 * on the front end of the board after 1479 * renaming your Admin CP directory, set this 1480 * to 1. 1481 */ 1482 1483 \$config['hide_admin_links'] = 0; 1484 1485 /** 1486 * Data-cache configuration 1487 * The data cache is a temporary cache 1488 * of the most commonly accessed data in MyBB. 1489 * By default, the database is used to store this data. 1490 * 1491 * If you wish to use the file system (cache/ directory), MemCache, xcache, or eAccelerator 1492 * you can change the value below to 'files', 'memcache', 'xcache' or 'eaccelerator' from 'db'. 1493 */ 1494 1495 \$config['cache_store'] = 'db'; 1496 1497 /** 1498 * Memcache configuration 1499 * If you are using memcache as your data-cache, 1500 * you need to configure the hostname and port 1501 * of your memcache server below. 1502 * 1503 * If not using memcache, ignore this section. 1504 */ 1505 1506 \$config['memcache']['host'] = 'localhost'; 1507 \$config['memcache']['port'] = 11211; 1508 1509 /** 1510 * Super Administrators 1511 * A comma separated list of user IDs who cannot 1512 * be edited, deleted or banned in the Admin CP. 1513 * The administrator permissions for these users 1514 * cannot be altered either. 1515 */ 1516 1517 \$config['super_admins'] = '1'; 1518 1519 /** 1520 * Database Encoding 1521 * If you wish to set an encoding for MyBB uncomment 1522 * the line below (if it isn't already) and change 1523 * the current value to the mysql charset: 1524 * http://dev.mysql.com/doc/refman/5.1/en/charset-mysql.html 1525 */ 1526 1527 {$db_encoding} 1528 1529 /** 1530 * Automatic Log Pruning 1531 * The MyBB task system can automatically prune 1532 * various log files created by MyBB. 1533 * To enable this functionality for the logs below, set the 1534 * the number of days before each log should be pruned. 1535 * If you set the value to 0, the logs will not be pruned. 1536 */ 1537 1538 \$config['log_pruning'] = array( 1539 'admin_logs' => 365, // Administrator logs 1540 'mod_logs' => 365, // Moderator logs 1541 'task_logs' => 30, // Scheduled task logs 1542 'mail_logs' => 180, // Mail error logs 1543 'user_mail_logs' => 180, // User mail logs 1544 'promotion_logs' => 180 // Promotion logs 1545 ); 1546 1547 ?>"; 1548 1549 $file = fopen(MYBB_ROOT.'inc/config.php', 'w'); 1550 fwrite($file, $configdata); 1551 fclose($file); 1552 1553 // Error reporting back on 1554 $db->error_reporting = 1; 1555 1556 $output->print_header($lang->table_creation, 'createtables'); 1557 echo $lang->sprintf($lang->tablecreate_step_connected, $dboptions[$mybb->input['dbengine']]['short_title'], $db->get_version()); 1558 1559 if($dboptions[$mybb->input['dbengine']]['structure_file']) 1560 { 1561 $structure_file = $dboptions[$mybb->input['dbengine']]['structure_file']; 1562 } 1563 else 1564 { 1565 $structure_file = 'mysql_db_tables.php'; 1566 } 1567 1568 require_once INSTALL_ROOT."resources/{$structure_file}"; 1569 foreach($tables as $val) 1570 { 1571 $val = preg_replace('#mybb_(\S+?)([\s\.,\(]|$)#', $config['tableprefix'].'\\1\\2', $val); 1572 $val = preg_replace('#;$#', $db->build_create_table_collation().";", $val); 1573 preg_match('#CREATE TABLE (\S+)(\s?|\(?)\(#i', $val, $match); 1574 if($match[1]) 1575 { 1576 $db->drop_table($match[1], false, false); 1577 echo $lang->sprintf($lang->tablecreate_step_created, $match[1]); 1578 } 1579 $db->query($val); 1580 if($match[1]) 1581 { 1582 echo $lang->done . "<br />\n"; 1583 } 1584 } 1585 echo $lang->tablecreate_step_done; 1586 $output->print_footer('populate_tables'); 1587 } 1588 1589 function populate_tables() 1590 { 1591 global $output, $lang; 1592 1593 require MYBB_ROOT.'inc/config.php'; 1594 $db = db_connection($config); 1595 1596 $output->print_header($lang->table_population, 'tablepopulate'); 1597 echo $lang->sprintf($lang->populate_step_insert); 1598 1599 if($dboptions[$db->type]['population_file']) 1600 { 1601 $population_file = $dboptions[$db->type]['population_file']; 1602 } 1603 else 1604 { 1605 $population_file = 'mysql_db_inserts.php'; 1606 } 1607 1608 require_once INSTALL_ROOT."resources/{$population_file}"; 1609 foreach($inserts as $val) 1610 { 1611 $val = preg_replace('#mybb_(\S+?)([\s\.,]|$)#', $config['database']['table_prefix'].'\\1\\2', $val); 1612 $db->query($val); 1613 } 1614 1615 // Update the sequences for PgSQL 1616 if($config['database']['type'] == "pgsql") 1617 { 1618 $db->query("SELECT setval('{$config['database']['table_prefix']}attachtypes_atid_seq', (SELECT max(atid) FROM {$config['database']['table_prefix']}attachtypes));"); 1619 $db->query("SELECT setval('{$config['database']['table_prefix']}forums_fid_seq', (SELECT max(fid) FROM {$config['database']['table_prefix']}forums));"); 1620 $db->query("SELECT setval('{$config['database']['table_prefix']}helpdocs_hid_seq', (SELECT max(hid) FROM {$config['database']['table_prefix']}helpdocs));"); 1621 $db->query("SELECT setval('{$config['database']['table_prefix']}helpsections_sid_seq', (SELECT max(sid) FROM {$config['database']['table_prefix']}helpsections));"); 1622 $db->query("SELECT setval('{$config['database']['table_prefix']}icons_iid_seq', (SELECT max(iid) FROM {$config['database']['table_prefix']}icons));"); 1623 $db->query("SELECT setval('{$config['database']['table_prefix']}profilefields_fid_seq', (SELECT max(fid) FROM {$config['database']['table_prefix']}profilefields));"); 1624 $db->query("SELECT setval('{$config['database']['table_prefix']}smilies_sid_seq', (SELECT max(sid) FROM {$config['database']['table_prefix']}smilies));"); 1625 $db->query("SELECT setval('{$config['database']['table_prefix']}spiders_sid_seq', (SELECT max(sid) FROM {$config['database']['table_prefix']}spiders));"); 1626 $db->query("SELECT setval('{$config['database']['table_prefix']}templategroups_gid_seq', (SELECT max(gid) FROM {$config['database']['table_prefix']}templategroups));"); 1627 } 1628 1629 echo $lang->populate_step_inserted; 1630 $output->print_footer('templates'); 1631 } 1632 1633 function insert_templates() 1634 { 1635 global $output, $cache, $db, $lang; 1636 1637 require MYBB_ROOT.'inc/config.php'; 1638 $db = db_connection($config); 1639 1640 require_once MYBB_ROOT.'inc/class_datacache.php'; 1641 $cache = new datacache; 1642 1643 $output->print_header($lang->theme_installation, 'theme'); 1644 1645 echo $lang->theme_step_importing; 1646 1647 $db->delete_query("themes"); 1648 $db->delete_query("templates"); 1649 $db->delete_query("themestylesheets"); 1650 my_rmdir_recursive(MYBB_ROOT."cache/themes", array(MYBB_ROOT."cache/themes/index.html")); 1651 1652 $insert_array = array( 1653 'title' => 'Default Templates' 1654 ); 1655 $templateset = $db->insert_query("templatesets", $insert_array); 1656 1657 $contents = @file_get_contents(INSTALL_ROOT.'resources/mybb_theme.xml'); 1658 if(file_exists(MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions_themes.php")) 1659 { 1660 require_once MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions.php"; 1661 require_once MYBB_ROOT.$mybb->config['admin_dir']."/inc/functions_themes.php"; 1662 } 1663 elseif(file_exists(MYBB_ROOT."admin/inc/functions_themes.php")) 1664 { 1665 require_once MYBB_ROOT."admin/inc/functions.php"; 1666 require_once MYBB_ROOT."admin/inc/functions_themes.php"; 1667 } 1668 else 1669 { 1670 $output->print_error("Please make sure your admin directory is uploaded correctly."); 1671 } 1672 $theme_id = import_theme_xml($contents, array("templateset" => -2, "version_compat" => 1)); 1673 $tid = build_new_theme("Default", null, $theme_id); 1674 1675 // Update our properties template set to the correct one 1676 $query = $db->simple_select("themes", "properties", "tid='{$tid}'", array('limit' => 1)); 1677 $properties = unserialize($db->fetch_field($query, "properties")); 1678 $properties['templateset'] = $templateset; 1679 unset($properties['inherited']['templateset']); 1680 1681 $db->update_query("themes", array("def" => 1, "properties" => $db->escape_string(serialize($properties))), "tid='{$tid}'"); 1682 1683 echo $lang->theme_step_imported; 1684 $output->print_footer('configuration'); 1685 } 1686 1687 function configure() 1688 { 1689 global $output, $mybb, $errors, $lang; 1690 1691 $output->print_header($lang->board_config, 'config'); 1692 1693 // If board configuration errors 1694 if(is_array($errors)) 1695 { 1696 $error_list = error_list($errors); 1697 echo $lang->sprintf($lang->config_step_error_config, $error_list); 1698 1699 $bbname = htmlspecialchars_uni($mybb->input['bbname']); 1700 $bburl = htmlspecialchars_uni($mybb->input['bburl']); 1701 $websitename = htmlspecialchars_uni($mybb->input['websitename']); 1702 $websiteurl = htmlspecialchars_uni($mybb->input['websiteurl']); 1703 $cookiedomain = htmlspecialchars_uni($mybb->input['cookiedomain']); 1704 $cookiepath = htmlspecialchars_uni($mybb->input['cookiepath']); 1705 $contactemail = htmlspecialchars_uni($mybb->input['contactemail']); 1706 } 1707 else 1708 { 1709 $bbname = 'Forums'; 1710 $cookiedomain = ''; 1711 $cookiepath = '/'; 1712 $websiteurl = $hostname.'/'; 1713 $websitename = 'Your Website'; 1714 $contactemail = ''; 1715 1716 $protocol = "http://"; 1717 if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") || substr($bburl, 0, 5) == "https") 1718 { 1719 $protocol = "https://"; 1720 } 1721 1722 // Attempt auto-detection 1723 if($_SERVER['HTTP_HOST']) 1724 { 1725 $hostname = $protocol.$_SERVER['HTTP_HOST']; 1726 $cookiedomain = '.'.$_SERVER['HTTP_HOST']; 1727 } 1728 elseif($_SERVER['SERVER_NAME']) 1729 { 1730 $hostname = $protocol.$_SERVER['SERVER_NAME']; 1731 $cookiedomain = '.'.$_SERVER['SERVER_NAME']; 1732 } 1733 1734 if(substr($cookiedomain, 0, 5) == ".www.") 1735 { 1736 $cookiedomain = my_substr($cookiedomain, 4); 1737 } 1738 1739 if($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['SERVER_NAME'] == 'localhost' || ip2long($_SERVER['SERVER_NAME']) != false) 1740 { 1741 $cookiedomain = ''; 1742 } 1743 1744 if($_SERVER['SERVER_PORT'] && $_SERVER['SERVER_PORT'] != 80 && !preg_match("#:[0-9]#i", $hostname)) 1745 { 1746 $hostname .= ':'.$_SERVER['SERVER_PORT']; 1747 } 1748 1749 $currentlocation = get_current_location(); 1750 if($currentlocation) 1751 { 1752 // TODO: Change this to find the last position of /install/ 1753 $pos = my_strpos($currentlocation, '/install/'); 1754 if($pos === 0) 1755 { 1756 $cookiepath = "/"; 1757 } 1758 else 1759 { 1760 $cookiepath = my_substr($currentlocation, 0, $pos).'/'; 1761 } 1762 } 1763 1764 $currentscript = $hostname.get_current_location(); 1765 1766 if($currentscript) 1767 { 1768 $bburl = my_substr($currentscript, 0, my_strpos($currentscript, '/install/')); 1769 } 1770 1771 if($_SERVER['SERVER_ADMIN']) 1772 { 1773 $contactemail = $_SERVER['SERVER_ADMIN']; 1774 } 1775 } 1776 1777 echo $lang->sprintf($lang->config_step_table, $bbname, $bburl, $websitename, $websiteurl, $cookiedomain, $cookiepath, $contactemail); 1778 $output->print_footer('adminuser'); 1779 } 1780 1781 function create_admin_user() 1782 { 1783 global $output, $mybb, $errors, $db, $lang; 1784 1785 $mybb->input['action'] = "adminuser"; 1786 // If no errors then check for errors from last step 1787 if(!is_array($errors)) 1788 { 1789 if(empty($mybb->input['bburl'])) 1790 { 1791 $errors[] = $lang->config_step_error_url; 1792 } 1793 if(empty($mybb->input['bbname'])) 1794 { 1795 $errors[] = $lang->config_step_error_name; 1796 } 1797 if(is_array($errors)) 1798 { 1799 configure(); 1800 } 1801 } 1802 $output->print_header($lang->create_admin, 'admin'); 1803 1804 if(is_array($errors)) 1805 { 1806 $error_list = error_list($errors); 1807 echo $lang->sprintf($lang->admin_step_error_config, $error_list); 1808 $adminuser = $mybb->input['adminuser']; 1809 $adminemail = $mybb->input['adminemail']; 1810 } 1811 else 1812 { 1813 require MYBB_ROOT.'inc/config.php'; 1814 $db = db_connection($config); 1815 1816 echo $lang->admin_step_setupsettings; 1817 1818 $settings = file_get_contents(INSTALL_ROOT.'resources/settings.xml'); 1819 $parser = new XMLParser($settings); 1820 $parser->collapse_dups = 0; 1821 $tree = $parser->get_tree(); 1822 1823 // Insert all the settings 1824 foreach($tree['settings'][0]['settinggroup'] as $settinggroup) 1825 { 1826 $groupdata = array( 1827 'name' => $db->escape_string($settinggroup['attributes']['name']), 1828 'title' => $db->escape_string($settinggroup['attributes']['title']), 1829 'description' => $db->escape_string($settinggroup['attributes']['description']), 1830 'disporder' => intval($settinggroup['attributes']['disporder']), 1831 'isdefault' => $settinggroup['attributes']['isdefault'], 1832 ); 1833 $gid = $db->insert_query('settinggroups', $groupdata); 1834 ++$groupcount; 1835 foreach($settinggroup['setting'] as $setting) 1836 { 1837 $settingdata = array( 1838 'name' => $db->escape_string($setting['attributes']['name']), 1839 'title' => $db->escape_string($setting['title'][0]['value']), 1840 'description' => $db->escape_string($setting['description'][0]['value']), 1841 'optionscode' => $db->escape_string($setting['optionscode'][0]['value']), 1842 'value' => $db->escape_string($setting['settingvalue'][0]['value']), 1843 'disporder' => intval($setting['disporder'][0]['value']), 1844 'gid' => $gid, 1845 'isdefault' => 1 1846 ); 1847 1848 $db->insert_query('settings', $settingdata); 1849 $settingcount++; 1850 } 1851 } 1852 1853 if(my_substr($mybb->input['bburl'], -1, 1) == '/') 1854 { 1855 $mybb->input['bburl'] = my_substr($mybb->input['bburl'], 0, -1); 1856 } 1857 1858 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['bbname'])), "name='bbname'"); 1859 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['bburl'])), "name='bburl'"); 1860 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['websitename'])), "name='homename'"); 1861 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['websiteurl'])), "name='homeurl'"); 1862 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiedomain'])), "name='cookiedomain'"); 1863 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['cookiepath'])), "name='cookiepath'"); 1864 $db->update_query("settings", array('value' => $db->escape_string($mybb->input['contactemail'])), "name='adminemail'"); 1865 $db->update_query("settings", array('value' => 'mailto:'.$db->escape_string($mybb->input['contactemail'])), "name='contactlink'"); 1866 1867 write_settings(); 1868 1869 echo $lang->sprintf($lang->admin_step_insertesettings, $settingcount, $groupcount); 1870 1871 include_once MYBB_ROOT."inc/functions_task.php"; 1872 $tasks = file_get_contents(INSTALL_ROOT.'resources/tasks.xml'); 1873 $parser = new XMLParser($tasks); 1874 $parser->collapse_dups = 0; 1875 $tree = $parser->get_tree(); 1876 1877 // Insert scheduled tasks 1878 foreach($tree['tasks'][0]['task'] as $task) 1879 { 1880 $new_task = array( 1881 'title' => $db->escape_string($task['title'][0]['value']), 1882 'description' => $db->escape_string($task['description'][0]['value']), 1883 'file' => $db->escape_string($task['file'][0]['value']), 1884 'minute' => $db->escape_string($task['minute'][0]['value']), 1885 'hour' => $db->escape_string($task['hour'][0]['value']), 1886 'day' => $db->escape_string($task['day'][0]['value']), 1887 'weekday' => $db->escape_string($task['weekday'][0]['value']), 1888 'month' => $db->escape_string($task['month'][0]['value']), 1889 'enabled' => $db->escape_string($task['enabled'][0]['value']), 1890 'logging' => $db->escape_string($task['logging'][0]['value']) 1891 ); 1892 1893 $new_task['nextrun'] = fetch_next_run($new_task); 1894 1895 $db->insert_query("tasks", $new_task); 1896 $taskcount++; 1897 } 1898 1899 echo $lang->sprintf($lang->admin_step_insertedtasks, $taskcount); 1900 1901 $views = file_get_contents(INSTALL_ROOT.'resources/adminviews.xml'); 1902 $parser = new XMLParser($views); 1903 $parser->collapse_dups = 0; 1904 $tree = $parser->get_tree(); 1905 1906 // Insert admin views 1907 foreach($tree['adminviews'][0]['view'] as $view) 1908 { 1909 $fields = array(); 1910 foreach($view['fields'][0]['field'] as $field) 1911 { 1912 $fields[] = $field['attributes']['name']; 1913 } 1914 1915 $conditions = array(); 1916 if(is_array($view['conditions'][0]['condition'])) 1917 { 1918 foreach($view['conditions'][0]['condition'] as $condition) 1919 { 1920 if(!$condition['value']) continue; 1921 if($condition['attributes']['is_serialized'] == 1) 1922 { 1923 $condition['value'] = unserialize($condition['value']); 1924 } 1925 $conditions[$condition['attributes']['name']] = $condition['value']; 1926 } 1927 } 1928 1929 $custom_profile_fields = array(); 1930 if(is_array($view['custom_profile_fields'][0]['field'])) 1931 { 1932 foreach($view['custom_profile_fields'][0]['field'] as $field) 1933 { 1934 $custom_profile_fields[] = $field['attributes']['name']; 1935 } 1936 } 1937 1938 $new_view = array( 1939 "uid" => 0, 1940 "type" => $db->escape_string($view['attributes']['type']), 1941 "visibility" => intval($view['attributes']['visibility']), 1942 "title" => $db->escape_string($view['title'][0]['value']), 1943 "fields" => $db->escape_string(serialize($fields)), 1944 "conditions" => $db->escape_string(serialize($conditions)), 1945 "custom_profile_fields" => $db->escape_string(serialize($custom_profile_fields)), 1946 "sortby" => $db->escape_string($view['sortby'][0]['value']), 1947 "sortorder" => $db->escape_string($view['sortorder'][0]['value']), 1948 "perpage" => intval($view['perpage'][0]['value']), 1949 "view_type" => $db->escape_string($view['view_type'][0]['value']) 1950 ); 1951 $db->insert_query("adminviews", $new_view); 1952 $view_count++; 1953 } 1954 1955 echo $lang->sprintf($lang->admin_step_insertedviews, $view_count); 1956 1957 echo $lang->admin_step_createadmin; 1958 } 1959 1960 echo $lang->sprintf($lang->admin_step_admintable, $adminuser, $adminemail); 1961 $output->print_footer('final'); 1962 } 1963 1964 function install_done() 1965 { 1966 global $output, $db, $mybb, $errors, $cache, $lang; 1967 1968 if(empty($mybb->input['adminuser'])) 1969 { 1970 $errors[] = $lang->admin_step_error_nouser; 1971 } 1972 if(empty($mybb->input['adminpass'])) 1973 { 1974 $errors[] = $lang->admin_step_error_nopassword; 1975 } 1976 if($mybb->input['adminpass'] != $mybb->input['adminpass2']) 1977 { 1978 $errors[] = $lang->admin_step_error_nomatch; 1979 } 1980 if(empty($mybb->input['adminemail'])) 1981 { 1982 $errors[] = $lang->admin_step_error_noemail; 1983 } 1984 if(is_array($errors)) 1985 { 1986 create_admin_user(); 1987 } 1988 1989 require MYBB_ROOT.'inc/config.php'; 1990 $db = db_connection($config); 1991 1992 require MYBB_ROOT.'inc/settings.php'; 1993 $mybb->settings = &$settings; 1994 1995 ob_start(); 1996 $output->print_header($lang->finish_setup, 'finish'); 1997 1998 echo $lang->done_step_usergroupsinserted; 1999 2000 // Insert all of our user groups from the XML file 2001 $usergroup_settings = file_get_contents(INSTALL_ROOT.'resources/usergroups.xml'); 2002 $parser = new XMLParser($usergroup_settings); 2003 $parser->collapse_dups = 0; 2004 $tree = $parser->get_tree(); 2005 2006 $admin_gid = ''; 2007 $group_count = 0; 2008 foreach($tree['usergroups'][0]['usergroup'] as $usergroup) 2009 { 2010 // usergroup[cancp][0][value] 2011 $new_group = array(); 2012 foreach($usergroup as $key => $value) 2013 { 2014 if(!is_array($value)) 2015 { 2016 continue; 2017 } 2018 2019 $new_group[$key] = $db->escape_string($value[0]['value']); 2020 } 2021 $db->insert_query("usergroups", $new_group, false); 2022 2023 // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs) 2024 if($new_group['cancp'] == 1 && !$admin_gid) 2025 { 2026 $admin_gid = $usergroup['gid'][0]['value']; 2027 } 2028 $group_count++; 2029 } 2030 2031 // Restart usergroup sequence with correct # of groups 2032 if($config['database']['type'] == "pgsql") 2033 { 2034 $db->query("SELECT setval('{$config['database']['table_prefix']}usergroups_gid_seq', (SELECT max(gid) FROM {$config['database']['table_prefix']}usergroups));"); 2035 } 2036 2037 echo $lang->done . '</p>'; 2038 2039 echo $lang->done_step_admincreated; 2040 $now = TIME_NOW; 2041 $salt = random_str(); 2042 $loginkey = generate_loginkey(); 2043 $saltedpw = md5(md5($salt).md5($mybb->input['adminpass'])); 2044 2045 $newuser = array( 2046 'username' => $db->escape_string($mybb->input['adminuser']), 2047 'password' => $saltedpw, 2048 'salt' => $salt, 2049 'loginkey' => $loginkey, 2050 'email' => $db->escape_string($mybb->input['adminemail']), 2051 'usergroup' => $admin_gid, // assigned above 2052 'regdate' => $now, 2053 'lastactive' => $now, 2054 'lastvisit' => $now, 2055 'website' => '', 2056 'icq' => '', 2057 'aim' => '', 2058 'yahoo' => '', 2059 'msn' =>'', 2060 'birthday' => '', 2061 'signature' => '', 2062 'allownotices' => 1, 2063 'hideemail' => 0, 2064 'subscriptionmethod' => '0', 2065 'receivepms' => 1, 2066 'pmnotice' => 1, 2067 'pmnotify' => 1, 2068 'showsigs' => 1, 2069 'showavatars' => 1, 2070 'showquickreply' => 1, 2071 'invisible' => 0, 2072 'style' => '0', 2073 'timezone' => 0, 2074 'dst' => 0, 2075 'threadmode' => '', 2076 'daysprune' => 0, 2077 'regip' => $db->escape_string(get_ip()), 2078 'longregip' => intval(my_ip2long(get_ip())), 2079 'language' => '', 2080 'showcodebuttons' => 1, 2081 'tpp' => 0, 2082 'ppp' => 0, 2083 'referrer' => 0, 2084 'buddylist' => '', 2085 'ignorelist' => '', 2086 'pmfolders' => '', 2087 'notepad' => '', 2088 'showredirect' => 1, 2089 'usernotes' => '' 2090 ); 2091 $db->insert_query('users', $newuser); 2092 echo $lang->done . '</p>'; 2093 2094 echo $lang->done_step_adminoptions; 2095 $adminoptions = file_get_contents(INSTALL_ROOT.'resources/adminoptions.xml'); 2096 $parser = new XMLParser($adminoptions); 2097 $parser->collapse_dups = 0; 2098 $tree = $parser->get_tree(); 2099 $insertmodule = array(); 2100 2101 $db->delete_query("adminoptions"); 2102 2103 // Insert all the admin permissions 2104 foreach($tree['adminoptions'][0]['user'] as $users) 2105 { 2106 $uid = $users['attributes']['uid']; 2107 2108 foreach($users['permissions'][0]['module'] as $module) 2109 { 2110 foreach($module['permission'] as $permission) 2111 { 2112 $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value']; 2113 } 2114 } 2115 2116 $defaultviews = array(); 2117 foreach($users['defaultviews'][0]['view'] as $view) 2118 { 2119 $defaultviews[$view['attributes']['type']] = $view['value']; 2120 } 2121 2122 $adminoptiondata = array( 2123 'uid' => intval($uid), 2124 'cpstyle' => '', 2125 'notes' => '', 2126 'permissions' => $db->escape_string(serialize($insertmodule)), 2127 'defaultviews' => $db->escape_string(serialize($defaultviews)) 2128 ); 2129 2130 $insertmodule = array(); 2131 2132 $db->insert_query('adminoptions', $adminoptiondata); 2133 } 2134 echo $lang->done . '</p>'; 2135 2136 // Automatic Login 2137 my_unsetcookie("sid"); 2138 my_unsetcookie("mybbuser"); 2139 my_setcookie('mybbuser', $uid.'_'.$loginkey, null, true); 2140 ob_end_flush(); 2141 2142 // Make fulltext columns if supported 2143 if($db->supports_fulltext('threads')) 2144 { 2145 $db->create_fulltext_index('threads', 'subject'); 2146 } 2147 if($db->supports_fulltext_boolean('posts')) 2148 { 2149 $db->create_fulltext_index('posts', 'message'); 2150 } 2151 2152 echo $lang->done_step_cachebuilding; 2153 require_once MYBB_ROOT.'inc/class_datacache.php'; 2154 $cache = new datacache; 2155 $cache->update_version(); 2156 $cache->update_attachtypes(); 2157 $cache->update_smilies(); 2158 $cache->update_badwords(); 2159 $cache->update_usergroups(); 2160 $cache->update_forumpermissions(); 2161 $cache->update_stats(); 2162 $cache->update_forums(); 2163 $cache->update_moderators(); 2164 $cache->update_usertitles(); 2165 $cache->update_reportedposts(); 2166 $cache->update_mycode(); 2167 $cache->update_posticons(); 2168 $cache->update_update_check(); 2169 $cache->update_tasks(); 2170 $cache->update_spiders(); 2171 $cache->update_bannedips(); 2172 $cache->update_banned(); 2173 $cache->update_bannedemails(); 2174 $cache->update_birthdays(); 2175 $cache->update_groupleaders(); 2176 $cache->update_threadprefixes(); 2177 $cache->update_forumsdisplay(); 2178 $cache->update("plugins", array()); 2179 $cache->update("internal_settings", array('encryption_key' => random_str(32))); 2180 2181 $version_history = array(); 2182 $dh = opendir(INSTALL_ROOT."resources"); 2183 while(($file = readdir($dh)) !== false) 2184 { 2185 if(preg_match("#upgrade([0-9]+).php$#i", $file, $match)) 2186 { 2187 $version_history[$match[1]] = $match[1]; 2188 } 2189 } 2190 sort($version_history, SORT_NUMERIC); 2191 $cache->update("version_history", $version_history); 2192 2193 echo $lang->done . '</p>'; 2194 2195 echo $lang->done_step_success; 2196 2197 $written = 0; 2198 if(is_writable('./')) 2199 { 2200 $lock = @fopen('./lock', 'w'); 2201 $written = @fwrite($lock, '1'); 2202 @fclose($lock); 2203 if($written) 2204 { 2205 echo $lang->done_step_locked; 2206 } 2207 } 2208 if(!$written) 2209 { 2210 echo $lang->done_step_dirdelete; 2211 } 2212 echo $lang->done_whats_next; 2213 $output->print_footer(''); 2214 } 2215 2216 function db_connection($config) 2217 { 2218 require_once MYBB_ROOT."inc/db_{$config['database']['type']}.php"; 2219 switch($config['database']['type']) 2220 { 2221 case "sqlite": 2222 $db = new DB_SQLite; 2223 break; 2224 case "pgsql": 2225 $db = new DB_PgSQL; 2226 break; 2227 case "mysqli": 2228 $db = new DB_MySQLi; 2229 break; 2230 default: 2231 $db = new DB_MySQL; 2232 } 2233 2234 // Connect to Database 2235 define('TABLE_PREFIX', $config['database']['table_prefix']); 2236 2237 $db->connect($config['database']); 2238 $db->set_table_prefix(TABLE_PREFIX); 2239 $db->type = $config['database']['type']; 2240 2241 return $db; 2242 } 2243 2244 function error_list($array) 2245 { 2246 $string = "<ul>\n"; 2247 foreach($array as $error) 2248 { 2249 $string .= "<li>{$error}</li>\n"; 2250 } 2251 $string .= "</ul>\n"; 2252 return $string; 2253 } 2254 2255 function write_settings() 2256 { 2257 global $db; 2258 2259 $query = $db->simple_select('settings', '*', '', array('order_by' => 'title')); 2260 while($setting = $db->fetch_array($query)) 2261 { 2262 $setting['value'] = str_replace("\"", "\\\"", $setting['value']); 2263 $settings .= "\$settings['{$setting['name']}'] = \"{$setting['value']}\";\n"; 2264 } 2265 if(!empty($settings)) 2266 { 2267 $settings = "<?php\n/*********************************\ \n DO NOT EDIT THIS FILE, PLEASE USE\n THE SETTINGS EDITOR\n\*********************************/\n\n{$settings}\n?>"; 2268 $file = fopen(MYBB_ROOT."inc/settings.php", "w"); 2269 fwrite($file, $settings); 2270 fclose($file); 2271 } 2272 } 2273 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |