Location: PHPKode > scripts > Random Text > admin/install.php
<?
/**
*
* @Script Random Text
* @version 1.0.0
* @copyright (c) Agrizlive.com
* @license You are allowed to modify this script. But you must provide a link of agrizlive.com in your footer (bottom of the page)
*
* Tested : PHP 5.2.11
*/

/**
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Install</title>
<link rel="stylesheet" type="text/css" href="css/theme.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="css/ie-sucks.css" />
<![endif]-->
<style>
#loginbox{
	position: relative;
	margin: 0 auto;
	margin-top: 200px;
	width: 400px;
}
fieldset{
	border: 0;
}
</style>
</head>
<?
	if(isset($_REQUEST['submit'])){
		$db_name = $_REQUEST['db'];
		$host = $_REQUEST['host'];
		$password = $_REQUEST['password'];
		$name = $_REQUEST['name'];
		$status = '';
		$link = mysql_connect($host,$name,$password);
		if(!$link){
			$status = "Can't cannot to mysql. Check the fields again";
		}
		else{
			$db = mysql_select_db($db_name);
			if(!$db){
				$status = "Can't cannot to database. Check the fields again";
			}
			else{
				$fp = fopen("text_config.php","r");
				$content = fread($fp,filesize('text_config.php'));
				fclose($fp);
				
				//Create config file
				
				$content = str_replace("{HOST_NAME}","$host",$content);
				$content = str_replace("{DB_USER}","$name",$content);
				$content = str_replace("{DB_PASS}","$password",$content);
				$content = str_replace("{DB_NAME}","$db_name",$content);
				
				$fp = fopen("text_config.php","w");
				fwrite($fp,$content);
				fclose($fp);
				
				//Install Query
				$query = "CREATE TABLE `agriz_text` (
`id` INT( 5 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`url` VARCHAR( 200 ) NOT NULL ,
`rtext` VARCHAR( 250 ) NOT NULL
) ENGINE = MYISAM ;";
				
				$query_user = "CREATE TABLE .`agriz_admin_text` (
`id` INT( 3 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`user_name` VARCHAR( 50 ) NOT NULL ,
`password` VARCHAR( 50 ) NOT NULL
) ENGINE = MYISAM ;";
				
				
				
				$result_user = mysql_query($query_user);
				
				$result = mysql_query($query);
				$query_insert = mysql_query("INSERT INTO `agriz_admin_text` (`id` ,`user_name` ,`password`)VALUES (NULL , 'admin', MD5( 'admin' ))");
				if($result && $result_user){
					$status = 'Installation is success. Delete install.php in admin. Admin login details admin / admin';
				}
				else{
					$status = 'There is a problem. Contact at http://www.agrizlive.com/contact.php';
				}
			}
		}
		
	}
?>
<body>
	<div id="container">
    	<div id="header">
        	<h2 style='color: black'>Install : Free Random Text BY agrizlive.com</h2>
			<div id="topmenu">
            </div>
		</div>
        
		<div id="wrapper">      
			<div id="loginbox">
				<form method="post" class="form">
					<fieldset>
					<legend>Install</legend>
						<p>
							<label>Host : </label>
							<input type="text" name="host" />
						</p>
						<p>
							<label>DB Name : </label>
							<input type="text" name="db" />
						</p>
						<p>
							<label>DB User : </label>
							<input type="text" name="name" />
						</p>
						<p>
							<label>DB Pass : </label>
							<input type="text" name="password" />
						</p>
						<?
							if(isset($_REQUEST['submit'])){
						?>
						<p>
							<?=$status;?>
						</p>
						<?	
							}
						?>
						<p>
							<input type="submit" name="submit" value="Install" />
						</p>
					</fieldset>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
Return current item: Random Text