⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?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: index.php,v $
// | $Date: 2004/02/12 21:16:57 $
// | $Revision: 1.10 $
// +-------------------------------------------------------------+
// | File Details:
// | - Basic Configuration
// +-------------------------------------------------------------+

error_reporting(E_ALL & ~E_NOTICE);

if (function_exists('set_time_limit') and get_cfg_var('safe_mode') == 0) {	
	@set_time_limit(1200);
}

define('DEVELOPERMODE', '1');
define('DONOT_LOGQUERIES', '1');
define('INSTALLER', 1);

@include_once('./../includes/config.php');
require_once('./../includes/global.php');
require_once('./../includes/functions/admin-tech_functions.php');
require_once('./../includes/functions/general_functions.php');
require_once('./../includes/functions/database/mysql.php');
require_once('./../includes/functions/conditional_functions.php');

install_header('DeskPRO Installation & Upgrade');

if (!in_string('index.php', $_SERVER['SCRIPT_NAME']) AND !in_string('index.php', $_SERVER['PHP_SELF'])) {
	echo "This file can only be run when the filename is <b>index.php</b>. Please rename it to run the file.";
	exit();
}

$latest_version = '2.0.1';

?>
<script language="javascript">
function visyes(id) {
	e=document.getElementById(id).style;
	e.display='';
}
</script>
<?php

######################################################################################################################
############################################ EMPTY DATABASE #################################################
######################################################################################################################

if ($_REQUEST['do'] == "delete_database") {

	echo "<center>Please <a href=\"index.php?do=delete_database2\">confirm</a> that you wish to empty the database " . DATABASE_NAME . ". This will delete <b>ALL</b> tables and is completly irreversible.</center>";
	exit();
}

if ($_REQUEST['do'] == "delete_database2") {

	$db = new DB_Sql;
	$db->Halt_On_Error = 'no';
	$db->User=constant('DATABASE_USER');
	$db->Password=constant('DATABASE_PASSWORD');
	$db->Host=constant('DATABASE_HOST');
	$db->Database=constant('DATABASE_NAME');
	$db->connect();
	$db->query("DROP database " . DATABASE_NAME);
	if (!$db->geterrno()) {
		$db->query("CREATE database " . DATABASE_NAME);
		if (!$errno = mysql_errno()) {
			alert('Your database has been emptied.');
		} else {
			alert('Your database was deleted but could not be recreated.');
		}
	} else {
		alert("Your database could not be deleted. Please check the database user has permission to perform this action. mySQL Error number: " . $db->geterrno() . " mySQL Error description: " . $db->geterrdesc());
	}
	unset($_REQUEST['do']);
}

if (!$_REQUEST['do']) {

######################################################################################################################
############################################ START INSTALL / UPGRADE #################################################
######################################################################################################################
	
	?>

	<b>Welcome to the DeskPRO Installer & Upgrader.<br />
	Nullified by WTN-WDYL Team `2004'<br /></b>
	<br />

	<?php

	$fail += check_config();
	$fail += check_thelicense();
	$fail += check_php_ver();
	$fail += check_mysql();
	$fail += check_pcre();
	$fail += check_graphs_perms();
	$fail += check_encoding();
	$warning += check_gd();
	$warning += check_sessions();
	echo "<br /><br />";

	if ($fail) {		
		echo "<P>Please correct the following problems, and reload this page. DeskPro v2.0 installation cannot continue until these are resolved:</P><UL>\n";
		echo $askhostto;
		echo "</UL>";
		exit();
	}

	$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->Halt_On_Error = 'no';
	$db->connect();
	$errno = mysql_errno();

	// we have connected to database, lets check for tables
	if (!$errno) {

		$send_to_deskpro .= "- We connected to the Database\n";

		$db->query("SHOW TABLES");
		if ($db->num_rows()) {

			$send_to_deskpro .= "- The database contained tables\n";
			
			// if we get here we have tables in this database. This is probably bad
			while ($result = $db->row_array()) {

				$send_to_deskpro .= "- Database table $result[0] found\n";

				// need to work out if this  *is* deskpro
				$table_array[] = $result[0];

				// pick unusal v2 table
				if ($result[0] == 'tech_internal_help_entry') {
					$send_to_deskpro .= "- We found the tech_internal_help_entry table suggesting a DeskPRO v2 install\n";
					$using_deskpro = 1;
				}
				// pick v1 table
				if ($result[0] == 'categories') {
					$send_to_deskpro .= "- We found the categories table suggesting a DeskPRO v1 install\n";
					$using_deskpro = 1;
					$deskpro_v1 = 1;
				}
			}

			$result = $db->query_return("SELECT * FROM settings WHERE settings = 'deskpro_version'");
			if (is_array($result)) {
				$send_to_deskpro .= "- We found the DeskPRO version row in the settings table\n";
				$deskpro_version = $result['value'];
				$send_to_deskpro .= "- We found the DeskPRO version, it is $result[value]\n";
			}

			// we now know if this is deskpro, what version of deskpro if it is and the table.

			if ($deskpro_version OR $using_deskpro) {

				$doupgrade = 1;

				echo "<span class=\"cp_temp_orig\">DeskPRO database found with v$deskpro_version</span><br /><br />";

				echo "The database <i><b>" . DATABASE_NAME . "</b></i> already contains an installation of DeskPRO";
				if ($deskpro_version) {
					echo " v$deskpro_version.";
				}

				if ($deskpro_version == $latest_version) {

					echo "<br /><br />You already have the latest version of DeskPRO installed. <br /><br /> If you wish to reinstall DeskPRO you must first delete your database. This is irreversible and results in complete loss of your current data. " . jprompt('Are you sure you wish to delete your database?', 'index.php?do=delete_database', ' delete your database');
					exit();
				}

				echo " You can now start the DeskPRO upgrade process. If you wish to perform a fresh installation of DeskPRO you will first have to " . jprompt('Are you sure you wish to delete your database?', 'index.php?do=delete_database', 'empty your database') . ", (this is irreversible) and start with a new database from scratch.";	

				?>
				<br /><br />
				Please verify that you have backed up your database. You can back up your database using the <I>mysqldump</I> utility
				(included with MySQL). Alternately, you can use a utility such as 
				phpMyAdmin. Please note that 
				we can not be held responsible for any problems with the upgrade process. It is essential you have made a backup and that you have checked your backup is complete.<br /><br />

				We are now going to upgrade your DeskPRO installation from v<?php echo "$deskpro_version to v$latest_version";?>. If this is not the version of DeskPRO you currently have installed, please contact DeskPRO Support.<br /><br />

				The upgrade system will upgrade your software to the latest version of
				DeskPRO.<br /><br />
				
				<center>
				<form action="index.php" method="post" name="upgrade">
				<?php
					if ($deskpro_v1) {
						echo "<input type=\"hidden\" name=\"do\" value=\"upgrade_v1\">";
					} else {
						echo "<input type=\"hidden\" name=\"do\" value=\"upgrade_v2\">";
					}
				?>

				<script language="JavaScript">
				function jprompt_2(message,url) {
					input_box=confirm(message);
					if (input_box==true) {
						document.upgrade.submit();
					}
				}

				document.write('<input type="button" name="upgrade" value="<?php echo "Upgrade v$deskpro_version to v$latest_version";?>" onclick="jprompt_2(\'This will immediately begin the upgrade process. Do NOT proceed until you have backed up your database! Without a backup, this process cannot be reversed!\')">');
				
				</script>
				<noscript>
				<input type="submit" name="upgrade" value="Perform Upgrade" />
				</noscript>
				</form>
				
				<?php
			
			} else {
				echo "The database you specified in config.php already has tables in it. It is not recommended that you install DeskPRO in a database that already has tables are there are likely to be conflicts. You can either " . jprompt('Are you sure you wish to delete your database?', 'index.php?do=delete_database', ' delete your database') . " which is irreverisble or continue with the <a href=\"index.php?fromindex=1\">install</a>";
			}
		} else {
		$send_to_deskpro .= "- The database contains no tables\n";
		}
	} else {
		$send_to_deskpro .= "- We could not connect to the database\n";
	}

	if (!$doupgrade) {
	
		// if we get here we either have no database found or an empty database.
		echo " <span class=\"cp_temp_orig\">No current installations where found.</span><br /><center><form method=\"post\" action=\"index.php\"><input type=\"hidden\" name=\"do\" value=\"install\"><input type=\"submit\" name=\"go\" value=\"Start Installation\"></form>";

	}

	echo "</center><hr>If this the result above is not what you where expecting, click <a href=\"javascript:visyes('report');\">here</a>.<br /><br />";

	echo "<div id=\"report\" name=\"report\" style=\"display:none\">Error.<br /><br />
		<textarea style=\"width:100%\" rows=\"15\">$send_to_deskpro</textarea></div>
	";

}

######################################################################################################################
############################################ INSTALL #################################################################
######################################################################################################################

if ($_REQUEST['do'] == 'install') {

	/*
		Lets install the latest version of DeskPRO
	*/

	give_default($_REQUEST['step'], 1);
	include('./install.php');

	if (!defined('FINISHED')) {

		$step = $_REQUEST['step'] + 1;
		echo "<BR><BR>To continue the installation, <A HREF=\"index.php?do=install&step=$step\">click here.</A>\n";
		exit();
	}
	exit();
}

######################################################################################################################
############################################ UPGRADE v1 -> v2 #################################################################
######################################################################################################################

if ($_REQUEST['do'] == 'upgrade_v1') {

	/*
		Upgrades the system from v1.1.x to v2.0.0
		Once we complete this we continue upgrading to v2.x.y
	*/

	$db = new DB_Sql;
	$db->Halt_On_Error = 'yes';
	$db->User=constant('DATABASE_USER');
	$db->Password=constant('DATABASE_PASSWORD');
	$db->Host=constant('DATABASE_HOST');
	$db->Database=constant('DATABASE_NAME');
	$db->connect();

	$db2 = new DB_Sql;
	$db2->Halt_On_Error = 'yes';
	$db2->User=constant('DATABASE_USER');
	$db2->Password=constant('DATABASE_PASSWORD');
	$db2->Host=constant('DATABASE_HOST');
	$db2->Database=constant('DATABASE_NAME');
	$db2->connect();

	$this_version = $db->query_return("SELECT value FROM settings WHERE settings = 'deskpro_version'");
	$this_version = $this_version['value'];

	give_default($_REQUEST['step'], 1);
	include('./upgrade_v1_v2/upgrade-110-197.php');

	if (!defined('FINISHED')) {

		if (defined('CUSTOMDIRECT')) {
			echo "<BR><BR>To continue the upgrade, <A HREF=\"index.php?do=upgrade_v1&step=$step&$extra_variables\">click here.</A>\n";
			exit();
		} else {
			$step = $_REQUEST['step'] + 1;
			echo "<BR><BR>To continue the upgrade, <A HREF=\"index.php?do=upgrade_v1&step=$step\">click here.</A>\n";
			exit();
		}
	} else {
		echo "<BR><BR>Upgrade to v2.0.0 now finished. We now need to upgrade to $latest_version, <A HREF=\"index.php?do=upgrade_v2\">click here.</A>\n";
	}

	exit();
}

######################################################################################################################
############################################ UPGRADE v2.x - v2.y #################################################################
######################################################################################################################

if ($_REQUEST['do'] == 'upgrade_v2') {

	$db = new DB_Sql;
	$db->Halt_On_Error = 'no';
	$db->User=constant('DATABASE_USER');
	$db->Password=constant('DATABASE_PASSWORD');
	$db->Host=constant('DATABASE_HOST');
	$db->Database=constant('DATABASE_NAME');

	$db2 = new DB_Sql;
	$db2->Halt_On_Error = 'yes';
	$db2->User=constant('DATABASE_USER');
	$db2->Password=constant('DATABASE_PASSWORD');
	$db2->Host=constant('DATABASE_HOST');
	$db2->Database=constant('DATABASE_NAME');
	$db2->connect();

	give_default($_REQUEST['step'], 1);

	/*
		The upgrade system. We will always upgrade to the latest version.
		Key is to find the the version of DeskPRO we are currently working on.
		At the end we run any standard queries
	*/

	$upgrades = array(
		'2.0.0' => 200,
		'2.0.1' => 201,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -