Файл: ADLT.BIZ Clone/install/index.php
Строк: 87
<?
error_reporting(0);
$message = "";
$error = "";
if(isset($_GET['action']) && $_GET['action'] == "install"){
$db_h = strip_tags($_POST['db_h']);
$database = strip_tags($_POST['database']);
$db_u = strip_tags($_POST['db_u']);
$db_p = strip_tags($_POST['db_p']);
$url = strip_tags($_POST['url']);
$title = strip_tags($_POST['title']);
if(mysql_connect($db_h,$db_u,$db_p)){
if(mysql_select_db($database)){
$config = '<?php
$dbhost = "'.$db_h.'";
$database = "'.$database.'";
$dbuname = "'.$db_u.'";
$dbpass = "'.$db_p.'";
$domain = "'.$url.'";
$website_title = "'.$title.'";
$connect = mysql_connect("$dbhost","$dbuname","$dbpass");
$select = mysql_select_db("$database");
?>';
$fp = fopen("../config.php", "w");
fwrite($fp, $config);
fclose($fp);
if(mysql_query("CREATE TABLE urls(id int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), url varchar(1000), short varchar(1000), hits int(255) NOT NULL DEFAULT '0')")){
$message = 'Successfully installed! Please delete "install" folder!';
}else{
$error = 'Could not create tables.';
}
}else{
$error = 'Could not select database.';
}
}else{
$error = 'Could not connect to database.';
}
}
?>
<!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><title>Install</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="container">
<a href="#"><div id="logo"></div></a>
<?
if(strlen($error) > 0){
echo"<div id="error">$error</div>";
}
if(strlen($message) > 0){
echo"<div id="correct">$message</div>";
}
?>
<div style="background:#fff;border:1px #efefef solid;padding:5px;border-radius:3px">
<form action="?action=install" method="post" class="mnform">
<fieldset>
<legend>Database Config</legend>
<div class="type-text">
<label for="db_h">Database Host</label><br />
<input type="text" name="db_h" id="db_h" value="localhost" style="height:28px;width:360px;margin-bottom:3px;" />
</div>
<div class="type-text">
<label for="database">Database Name</label><br />
<input type="text" name="database" id="database" value="" style="height:28px;width:360px;margin-bottom:3px;" />
</div>
<div class="type-text">
<label for="db_u">Database User</label><br />
<input type="text" name="db_u" id="db_u" value="" style="height:28px;width:360px;margin-bottom:3px;" />
</div>
<div class="type-text">
<label for="db_p">Database Password</label><br />
<input type="text" name="db_p" id="db_p" value="" style="height:28px;width:360px;margin-bottom:3px;" />
</div>
</fieldset>
<fieldset>
<legend>Website Info</legend>
<div class="type-text">
<label for="title">Website Title</label><br />
<input type="text" name="title" id="title" value="Website title" onclick="if(this.value=='Website title')this.value='';" onblur="if(this.value=='')this.value='Website title';" style="height:28px;width:360px;margin-bottom:3px;" />
</div>
<div class="type-text">
<label for="url">Website URL</label><br />
<input type="text" name="url" id="url" value="Website URL (no trailing slash)" onclick="if(this.value=='Website URL (no trailing slash)')this.value='';" onblur="if(this.value=='')this.value='Website URL (no trailing slash)';" style="height:28px;width:360px;margin-bottom:3px;" />
</div>
</fieldset>
<div style="text-align:right"><input id="shorten" type="submit" name="submit" value="Install" /></div>
</form>
</div>
</div>
</body>
</html>