install.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:11k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: install.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.4 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Installation script for DeskPRO v2.0.0.
- // | *** READ THE INSTALLATION MANUAL BEFORE USING THIS FILE! ***
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- ignore_user_abort(1);
- @set_time_limit(0);
- install_check();
- ////////////////////////// mySQL connection //////////////////////////
- if ($_REQUEST['step'] == 1) {
- /*
- 1. Assume config.php is correct and try and do a connection
- 2. If database exists it works
- 3. If database does not exist try and create it
- 4. Any problems, tell them to edit config.php!
- */
- do_message("Checking your mySQL connection");
- echo "<br /><br />";
- $connection = check_mysql_connection();
- // we have an error
- if ($connection[1]) {
- // the problem is from creating the database
- if ($connection[2]) {
- $create = create_database(DATABASE_NAME);
- if ($create[1]) {
- $error = "Your mySQL connection failed because the database you specified in config.php does not exist. DeskPRO attempted to create the database specified in config.php for you but was unable to. <br /><br /><i>$create[1]</i><br /><br />";
- } else {
- // we should have create the database, lets check the connection
- $connection = check_mysql_connection();
- if ($connection[1]) {
- $error = "DeskPRO was unable to connect to your mySQL server with the settings listed in config.php. DeskPRO attempted to create the database listed in config.php and your mySQL server reported this database creation a success however access to this database is still not possible. <br /><br /><i>$connection[1]</i><br /><br />";
- } else {
- // we created the database
- $notice = "DeskPRO automatically created the database " . DATABASE_NAME . " for you.<br /><br />";
- }
- }
- } else {
- $error = "<span class="cp_temp_edit">DeskPRO was unable to connect to your mySQL server with the settings listed in config.php.</span><br /><br /><ul><li><i>$connection[1]</i></li></ul>";
- }
- }
- if ($error) {
- echo "$error";
- echo "To correct this error please ensure that the settings inside /includes/config.php are correct. Please note that DeskPRO staff can <b>not</b> help you find these settings, you will need to contact your webhost. Once you have updated your config.php file you should refresh this page.";
- exit();
- }
-
- echo "$notice";
- echo "<span class="cp_temp_orig">Your mySQL connection was a success. DeskPRO is now ready to be installed.</span>";
- }
- ////////////////////////// Load database tables //////////////////////////
- if ($_REQUEST['step'] == 2) {
- do_message("Creating DeskPRO Tables");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- require('./v2data/tables.php');
-
- execute($queries);
- do_message_yes();
- }
- ////////////////////////// Load installation data //////////////////////////
- if ($_REQUEST['step'] == 3) {
- do_message("Loading Installation Data");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- load_data('install.sql');
- do_message_yes();
- }
- ////////////////////////// Load general data //////////////////////////
- if ($_REQUEST['step'] == 4) {
- do_message("Loading Default Data");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- load_data('data.sql');
- do_message_yes();
- }
- ////////////////////////// Load basic web templates //////////////////////////
- if ($_REQUEST['step'] == 5) {
- do_message("Loading web templates");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- sort_web_templates();
- do_message_yes();
- }
- ////////////////////////// Load email templates //////////////////////////
- if ($_REQUEST['step'] == 6) {
- do_message("Loading email templates");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- sort_email_templates();
- do_message_yes();
- }
- ////////////////////////// Load words //////////////////////////
- if ($_REQUEST['step'] == 7) {
- do_message("Loading words");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- sort_words();
- do_message_yes();
- }
- ////////////////////////// Load basic data //////////////////////////
- if ($_REQUEST['step'] == 8) {
- do_message("Loading settings");
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- load_data('settings.sql');
- do_message_yes();
- }
- ////////////////////////// SETTINGS / ADMIN ACCOUNT //////////////////////////
- if ($_REQUEST['step'] == 9) {
- $db = new DB_Sql;
- $db->User=constant('DATABASE_USER');
- $db->Password=constant('DATABASE_PASSWORD');
- $db->Host=constant('DATABASE_HOST');
- $db->Database=constant('DATABASE_NAME');
- $db->connect();
- if ($_REQUEST['complete']) {
- if (!$_REQUEST['admin_password']) {
- $error .= '<li>You did not enter a password</li>';
- }
- if (!($_REQUEST['admin_password'] == $_REQUEST['admin_password2'])) {
- $error .= '<li>The two passwords do not match</li>';
- }
- if (!validate_email($_REQUEST['email'])) {
- $error .= '<li>You did not enter a valid email address</li>';
- }
- if (!$_REQUEST['username']) {
- $error .= '<li>You did not enter a username</li>';
- }
- if (!$error) {
- install_header('DeskPro v2.0 Installation Completed!');
-
- $adminpasscookie = substr(md5($_REQUEST['admin_password'].rand()), 0, 8);
- // create the tech
- $db->query("
- INSERT INTO tech SET
- username = '" . mysql_escape_string($_REQUEST['username']) . "',
- password = '" . mysql_escape_string($_REQUEST['admin_password']) . "',
- password_cookie = '" . mysql_escape_string($adminpasscookie) . "',
- email = '" . mysql_escape_string($_REQUEST['email']) . "',
- is_admin = 1,
- fielddisplay = 1,
- cats_user = '',
- cats_admin = '',
- p_close_ticket = 1,
- p_tech_view = 1,
- p_tech_edit = 1,
- p_add_k = 1,
- p_edit_k = 1,
- p_delete_k = 1,
- p_add_c_k = 1,
- p_delete_c_k = 1,
- p_edit_c_k = 1,
- p_edit_users = 1,
- p_delete_users = 1,
- p_add_announcements = 1,
- p_delete_announcements = 1,
- p_create_users = 1,
- p_edit_announcements = 1,
- p_delete_other = 1,
- p_delete_own = 1,
- p_approve_new_registrations = 1,
- p_user_expire = 1,
- p_quickedit = 1,
- p_global_note = 1,
- p_html_tech = 1,
- p_html_user = 1
- ");
- // pre fill any settings
- $settings['cookie_path'] = str_replace('/admin/install', '', strtolower(dirname($_SERVER['SCRIPT_NAME'])));
- foreach($settings AS $key => $val) {
- $db->query("
- UPDATE settings SET
- value = '" . mysql_escape_string($_REQUEST[$key]) . "'
- WHERE settings = '$key'
- ");
- }
- echo "<P><span class="cp_temp_orig">Congratulations! You've successfully completed the DeskPro v2.0 installation!</span><p>The installer script has finished preparing your DeskPro
- v2.0 installation. Before you can access the administration interface,
- you'll need to rename or delete the following file from the
- install/ directory on your server:
- <UL>
- <LI>/install/index.php</LI>
- </UL></P>";
- echo "<P>You should now start the DeskPRO configuration system. To continue, please <A HREF="./../admin/">Click Here</A>.</P>";
- _a();
- define('FINISHED', 1);
- exit();
- }
- }
- echo "<P>The final step is to create an administor account for use in DeskPRO. This will be the account that is used to control your DeskPRO setup. You will be able to create additional accounts from the admin interface at a later point.</P>";
- echo '<FORM METHOD="POST" ACTION="index.php" NAME="proceed">';
- echo '<INPUT TYPE="hidden" NAME="step" VALUE="9">';
- echo '<INPUT TYPE="hidden" NAME="complete" VALUE="1">';
- echo '<INPUT TYPE="hidden" NAME="do" VALUE="install">';
- if ($error) {
- echo "<P><B>One or more error(s) were found in the values you provided. Please adjust the highlighted fields and submit this form again.</B></P><ul>$error</ul>";
- }
- ?>
-
- <TABLE WIDTH="100%" CELLSPACING="0" CELLPADDING="2">
- <tr>
- <td>
- <b>Administrator Account Username</b><br />
- The username for this administrator.
- </td><td>
- <INPUT TYPE="input" value="<?php echo $_REQUEST['username']?>" NAME="username" SIZE="30" />
- </td></tr>
- <td>
- <b>Administrator Account Password</b><br />
- Specify the desired password for the default administrator account here.
- </td><td>
- <INPUT TYPE="password" NAME="admin_password" SIZE="30" />
- </td></tr><tr><td>
- <b>Administrator Account Password</b><br />
- Confirm the password you entered above.
- </td><td>
- <INPUT TYPE="password" NAME="admin_password2" SIZE="30" />
- </td></tr><tr><td>
- <b>Administrator Account E-mail Address.</b><br />
- </td><td>
- <INPUT TYPE="input" value="<?php echo $_REQUEST['email']?>" NAME="email" SIZE="30" />
- </td></tr></table>
-
- <?php
- echo '<br /><center><INPUT TYPE="submit" NAME="ready" VALUE=">> Complete Installation >>"></P>';
- echo '</FORM>';
- exit();
- }