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

📄 index.old

📁 不错的东西
💻 OLD
字号:
<?phpsession_start();error_reporting( E_ALL ^ E_NOTICE);if($_SERVER['REQUEST_METHOD'] == "POST" && $_SERVER['PHP_SELF']){	// Unset previous errors.	unset($_SESSION['error']);	// define var $conf_file.	$conf_file = "../conf/mysql.inc.php";	if($_GET['step'] == 2)	{		if(empty($_POST['company']))		{			$_SESSION['error']['company'] = TRUE;			$_SESSION['error']['msg'][] = "Company name is required!";		}		else		{			$_SESSION['install']['company'] = mysql_escape_string($_POST['company']);		}		if(empty($_POST['username']))		{			$_SESSION['error']['username'] = TRUE;			$_SESSION['error']['msg'][] = "Username is required!";		}		else		{			$_SESSION['install']['username'] = mysql_escape_string($_POST['username']);		}		if(strcmp($_POST['password']['0'], $_POST['password']['1']) != 0)		{			$_SESSION['error']['password'] = TRUE;			$_SESSION['error']['msg'][] = "Please verify that passwords match!";		}		else		{			if(empty($_POST['password']['0']))			{				$_SESSION['error']['password'] = TRUE;				$_SESSION['error']['msg'][] = "Password is required!";			}			else			{				$_SESSION['install']['password'] = sha1($_POST['password']['0']);			}		}		if(empty($_POST['http_path']))		{			$_SESSION['error']['http_path'] = TRUE;			$_SESSION['error']['msg'][] = "URL to script is required!";		}		else		{			$_SESSION['install']['http_path'] = mysql_escape_string($_POST['http_path']);		}	}	if($_GET['step'] == 1)	{		if(empty($_POST['hostname']))		{			$_SESSION['error']['hostname'] = TRUE;			$_SESSION['error']['msg'][] = "MySQL Database Hostname is required!";		}		else		{			$_SESSION['install']['mysql']['hostname'] = mysql_escape_string($_POST['hostname']);		}		if(empty($_POST['username']))		{			$_SESSION['error']['username'] = TRUE;			$_SESSION['error']['msg'][] = "MySQL Database Username is required!";		}		else		{			$_SESSION['install']['mysql']['username'] = mysql_escape_string($_POST['username']);		}		if(empty($_POST['password']))		{			$_SESSION['error']['password'] = TRUE;			$_SESSION['error']['msg'][] = "MySQL Database Password is required!";		}		else		{			$_SESSION['install']['mysql']['password'] = mysql_escape_string($_POST['password']);		}		if(empty($_POST['database']))		{			$_SESSION['error']['database'] = TRUE;			$_SESSION['error']['msg'][] = "MySQL Database Name is required!";		}		else		{			$_SESSION['install']['mysql']['database'] = mysql_escape_string($_POST['database']);		}		if(is_resource(mysql_connect($_SESSION['install']['mysql']['hostname'], $_SESSION['install']['mysql']['username'], $_SESSION['install']['mysql']['password'])))		{			if(mysql_select_db($_SESSION['install']['mysql']['database']))			{				if (is_writeable(dirname($conf_file)))				{					// create conf file and forward to next step.					$conf = "<?php\n\$conf = array\n(\n\t\"hostname\" => \"{$_SESSION['install']['mysql']['hostname']}\",\n\t\"username\" => \"{$_SESSION['install']['mysql']['username']}\",\n\t\"password\" => \"{$_SESSION['install']['mysql']['password']}\",\n\t\"database\" => \"{$_SESSION['install']['mysql']['database']}\"\n);\n\n\$link = mysql_connect(\$conf['hostname'], \$conf['username'], \$conf['password']) or die(\"Unable to connect to the MySQL Database: \" . mysql_error());\nmysql_select_db(\$conf['database']) or die(\"Unable to connect to the MySQL Database: \" . mysql_error());\n?>";					$pipe = fopen($conf_file, "w");					fwrite($pipe, $conf, strlen($conf));					fclose($pipe);					if(file_exists($conf_file))					{						require($conf_file);						/*						*	Modified: 09/14/05						*	Fixed sql insert problem - fix						*/						//$query_bits = explode(";\n", file_get_contents("mysql.sql"));						$query_bits = trim($query_bits);						$query_bits = preg_split ("/[;]+/", file_get_contents("mysql.sql"));						array_pop($query_bits);						$query = '';						foreach($query_bits as $key => $query_bit)						{							if ( $key >= 21 && $key < 46)							{								$query .= $query_bit;								continue;							}							if ( $key == 46 )							{								$query_bit = $query . $query_bit;								$query_bit = substr( $query_bit , 2 );							}							if(!empty($query_bit)) {								$query = mysql_query($query_bit) or die('' . __LINE__ . ': ' . mysql_error() . '<br /><br />' . $query_bit);							}						}					}					header("Location: ?step=2");				}				else				{					$_SESSION['error']['write'] = TRUE;					$_SESSION['error']['msg'][] = "Please chmod 0777 to the /conf dir.";				}			}			else			{				$_SESSION['error']['database'] = TRUE;				$_SESSION['error']['msg'][] = "Unable to select the Database: " . $_SESSION['install']['database'];			}		}		else		{			$_SESSION['error']['connection'] = TRUE;			$_SESSION['error']['msg'] = "Unable to connect to the MySQL Database.";		}	}	session_write_close();	if(!$_SESSION['error'])	{		if($_GET['step'] == 2)		{			if(file_exists($conf_file))			{				require($conf_file);				/*				*  Justin Osterholt				*  11/26/05				*  mysql connect/db select code moved from mysq.inc.php				*/				$link = mysql_connect($conf['hostname'], $conf['username'], $conf['password']) or die("Unable to connect to the MySQL Database: " . mysql_error());				mysql_select_db($conf['database']) or die("Unable to connect to the MySQL Database: " . mysql_error());				$query = mysql_query("INSERT INTO accounts (username, password, level, status, date) VALUES ('" . $_SESSION['install']['username'] . "', '" . $_SESSION['install']['password'] . "', 1, 2, NOW())");				$query = mysql_query("INSERT INTO settings (company, http_path) VALUES ('" . $_SESSION['install']['company'] . "', '" . $_SESSION['install']['http_path'] . "')");			}		}		header("Location: ?step=" . ($_GET['step'] + 1));	}	else	{		header("Location: ?step=" . $_GET['step']);	}}else{	$_GET['step'] = (isset($_GET['step'])) ? $_GET['step'] : 1;	if($_GET['step'] == 3)	{		echo "<p>Installation Complete!</p>";	}	if($_GET['step'] == 2)	{		if($_SESSION['error'])		{			echo "<ul style=\"list-style: none;\">";			foreach($_SESSION['error']['msg'] as $msg)			{				echo "<li>$msg</li>";			}			echo "</ul>";			// Unset previous errors.			unset($_SESSION['error']);		}		?>		<form method="post" action="<?=$_SERVER['PHP_SELF']?>?step=2">		<fieldset>		<label>Installation</label>		<table>		<tr>			<td colspan="2">Please fill out your original administration login information below:</td>		</tr>		<tr>			<td><label for="company">Company Name:</label></td>			<td><input type="text" name="company" id="company"<?=($_SESSION['install']['company']) ? " value=\"{$_SESSION['install']['company']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="username">Username:</label></td>			<td><input type="text" name="username" id="username"<?=($_SESSION['install']['username']) ? " value=\"{$_SESSION['install']['username']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="password1">Password:</label></td>			<td><input type="password" name="password[]" id="password1"<?=($_SESSION['install']['password']) ? " value=\"{$_SESSION['install']['password']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="password2">Verify Password:</label></td>			<td><input type="password" name="password[]" id="password2"<?=($_SESSION['install']['password']) ? " value=\"{$_SESSION['install']['password']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="http_path">URL to script:</label></td>			<td><input type="text" name="http_path" id="http_path"<?=($_SESSION['install']['http_path']) ? " value=\"{$_SESSION['install']['http_path']}\"" : NULL?> /></td>		</tr>		<tr>			<td colspan="2"><input type="submit" value="next" /></td>		</tr>		</table>		</fieldset		</form>		<?php	}	if($_GET['step'] == 1)	{		if($_SESSION['error'])		{			echo "<ul style=\"list-style: none;\">";			foreach($_SESSION['error']['msg'] as $msg)			{				echo "<li>$msg</li>";			}			echo "</ul>";			// Unset previous errors.			unset($_SESSION['error']);		}		/*		*	Modified: 09/14/05		*	Hostname default set to 'localhost'		*/		if(empty($_SESSION['install']['mysql']['hostname'])) {			$_SESSION['install']['mysql']['hostname'] = "localhost";		}		?>		<form method="post" action="<?=$_SERVER['PHP_SELF']?>?step=1">		<fieldset>		<label>Installation: </label>		<table>		<tr>			<td colspan="2">Please fill out your MySQL Database connection information below:</td>		</tr>		<tr>			<td><label for="hostname">MySQL Hostname:</label></td>			<td><input type="text" name="hostname" id="hostname"<?=($_SESSION['install']['mysql']['hostname']) ? " value=\"{$_SESSION['install']['mysql']['hostname']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="username">MySQL Username:</label></td>			<td><input type="text" name="username" id="username"<?=($_SESSION['install']['mysql']['username']) ? " value=\"{$_SESSION['install']['mysql']['username']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="password">MySQL Password:</label></td>			<td><input type="password" name="password" id="password"<?=($_SESSION['install']['mysql']['password']) ? " value=\"{$_SESSION['install']['mysql']['password']}\"" : NULL?> /></td>		</tr>		<tr>			<td><label for="database">MySQL Database Name:</label></td>			<td><input type="text" name="database" id="database"<?=($_SESSION['install']['mysql']['database']) ? " value=\"{$_SESSION['install']['mysql']['database']}\"" : NULL?> /></td>		</tr>		<tr>			<td colspan="2"><input type="submit" value="next" /></td>		</tr>		</table>		</fieldset>		</form>		<?php	}}?>

⌨️ 快捷键说明

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