View file install.php

File size: 9.88Kb
<?php
error_reporting(0);
$install = $_GET['install'];
switch ($install) {
    case 'tables':
$title = "Checking Database";
include('includes/connect.php');
include('includes/header.php');
echo '<div class="title">Installing Tables</div>';

//Table creation
        mysql_query("DROP TABLE IF EXISTS `file_cat`;");
        mysql_query("
        	CREATE TABLE IF NOT EXISTS `file_cat` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) COLLATE latin1_general_ci NOT NULL,
  `ext` text COLLATE latin1_general_ci NOT NULL,
  `img` text COLLATE latin1_general_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
        ");
		mysql_query("DROP TABLE IF EXISTS `files`;");
        mysql_query("
			CREATE TABLE IF NOT EXISTS `files` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `catid` bigint(20) NOT NULL,
  `type` text NOT NULL,
  `description` text NOT NULL,
  `password` varchar(255) NOT NULL,
  `size` varchar(255) NOT NULL,
  `time` bigint(20) NOT NULL,
  `downloaded` bigint(20) NOT NULL,
  `views` bigint(20) NOT NULL,
  `userid` bigint(20) NOT NULL,
  `report` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
        ");
		mysql_query("DROP TABLE IF EXISTS `users`;");
        mysql_query("
			CREATE TABLE IF NOT EXISTS `users` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `username` varchar(30) NOT NULL,
  `mail` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `rights` int(1) NOT NULL DEFAULT '0',
  `files` bigint(20) NOT NULL,
  `disk` double NOT NULL,
  `regtime` bigint(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
        ");
		mysql_query("DROP TABLE IF EXISTS `settings`;");
        mysql_query("
			CREATE TABLE IF NOT EXISTS `settings` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
        ");
        mysql_query("INSERT INTO `settings` VALUES ('1','title','Free File Sharing')");
        mysql_query("INSERT INTO `settings` VALUES ('2','news','User registration is open.')");
        mysql_query("INSERT INTO `settings` VALUES ('6','file_ext','gif, jpg, png, bmp, mp3, mp4, 3gp, wav, jar, jad, sis, sisx, apk, 3gp, avi, mid, jpeg, zip, tar, 7z, txt, pdf, doc, cab, exe, rar')");
        mysql_query("INSERT INTO `settings` VALUES ('3','upmax','100')");
        mysql_query("INSERT INTO `settings` VALUES ('4','filemax','10')");
        mysql_query("INSERT INTO `settings` VALUES ('5','registration','1')");
        mysql_query("INSERT INTO `settings` VALUES ('7','terms','1. Terms one\n2. Terms two\n3. Terms three')");
        mysql_query("INSERT INTO `settings` VALUES ('8','about','We offer free mobile file sharing site for everyone. We provide some
features such as:

&bull; Free user registration
&bull; Free 100MB space per user and will be increased soon
&bull; Ability to add a password in your download page
&bull; Ability to plant your own ads in your download pages
&bull; Multi language support (<a href=\"doc.php?read=translating\">wanna translate?</a>)
&bull; Etc.

<b>Howto</b>:
&bull; <a href=\"http://youtube.com/?watch=c3dAAsX\">How to using this site?</a>
&bull; <a href=\"doc.php?read=translating\">How to translate this site into my language?</a>
')");
		mysql_query("DROP TABLE IF EXISTS `guide`;");
        mysql_query("
			CREATE TABLE IF NOT EXISTS `guide` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
        ");
        mysql_query("INSERT INTO `guide` VALUES ('1','registration','Registration howto')");
        mysql_query("INSERT INTO `guide` VALUES ('2','login','Login howto')");
        mysql_query("INSERT INTO `guide` VALUES ('3','uploading','Uploading files howto')");
        mysql_query("INSERT INTO `guide` VALUES ('4','importing','Importing files howto')");
		mysql_query("INSERT INTO `guide` VALUES ('5','plant-ads','Planting an ads files howto')");
        mysql_query("INSERT INTO `guide` VALUES ('6','commenting-file','Comenting files files howto')");
        mysql_query("INSERT INTO `guide` VALUES ('7','reporting-file','Reporting files howto')");
        mysql_query("INSERT INTO `guide` VALUES ('8','translating','Translating howto')");
        mysql_query("INSERT INTO `guide` VALUES ('9','contacting-admin','Contacting admin howto')");
		
	mysql_query("DROP TABLE IF EXISTS `contributors`;");
        mysql_query("
			CREATE TABLE IF NOT EXISTS `contributors` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `link` varchar(255) NULL,
  `desc` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
        ");
        mysql_query("INSERT INTO `contributors` VALUES ('1','Suyadi','http://mobile3.us', 'Coder and Founder')");
        mysql_query("INSERT INTO `contributors` VALUES ('2','Mihai Ionut Vilcu','http://master-land.net','Translator: Romana, Espanol')");
        mysql_query("INSERT INTO `contributors` VALUES ('3','Vijay33','http://vijay33.in', 'Translator: Hindi')");
        mysql_query("INSERT INTO `contributors` VALUES ('4','Aleksej','http://wapdiz.ru', 'CSS and Translator: Russian')");	

//End of table creation
		
header("location:?install=final");
break;

case 'final' :
$title = "Installation";
include('includes/connect.php');
include('includes/header.php');
echo '<div class="title">Installation</div>';
 if ( $_GET['act'] == "admin" )
{ $password = md5( addslashes( $_POST['password'] ) );
$username = addslashes( $_POST['username'] );
$email = addslashes( $_POST['email'] );
$code = addslashes(input($_POST['code']));
if (strlen($_POST['username'])<3 || strlen($_POST['username'])>20 ) {
echo '<div class="news">Error! Username must be between 4 - 15 characters<br/><a href="javascript:history.go(-1)">Go back</a></div>'; }
elseif ( mysql_num_rows(mysql_query("SELECT id FROM users WHERE username='$username'"))>0)
{ echo '<div class="news">This Username already Exist! <br/>
<a href="javascript:history.go(-1)">Go back</a></div>'; }
elseif(!preg_match("^[A-Za-z0-9]+$^", "$username"))
{ echo '<div class="news">Username contain invalid characters! <br/>
<a href="javascript:history.go(-1)">Go back</a></div>'; }
elseif (!check_email($email))
{ echo '<div class="news">Invalid Email! <br/>
<a href="javascript:history.go(-1)">Go back</a></div>';
}
elseif ( ! $_POST['username'] || ! $_POST['password'] || ! $email)
{
echo '<div class="news">Error! you have not entered all fields! <br/>
<a href="javascript:history.go(-1)">Go back</a></div>';
}
elseif ( mysql_num_rows(mysql_query("SELECT id FROM users WHERE mail='$email'"))>0)
{ echo '<div class="news">This email is already in use, Please choose another email! <br/>
<a href="javascript:history.go(-1)">Go back</a></div>';
}
elseif (strlen($_POST['password'])<5 || strlen($_POST['password'])>15 )
{ echo '<div class="news">Password must be between 6 - 15 characters! <br/>
<a href="javascript:history.go(-1)">Go back</a></div>';
}
elseif($code ==''|| $code != $_SESSION['security_code']){
echo '<div class="news">Please insert correct code!<br/>
<a href="javascript:history.go(-1)">Go back</a></div>';
}
else{
$pw = $_POST['password'];
$user = insert('users');
mkdir('data/user'.$user);
@$a=mysql_query("INSERT INTO users (id,username,mail, password,rights,disk,files,regtime) VALUES ('$user', '$username', '{$email}', '{$password}', '2', '0', '0', '$time')");
if ($a) print "<div class=\"box\">Installation completed!<br/>User ID: $user<br/>Login: $username<br/>Password: $pw<br/><a href=\"login.php\">Click here to LogIn</a></div><div class=\"news\"><font color=\"red\"><i>Do not forget to <b>delete</b> the file <b>install.php</b> for security reasons</i></font></div>";
else
print '<div class="news">There was an error in the registration process, please contact the site administrator</div>';
}
}

//Admin account creation form
else {
echo '<div class="list">
<form action="?install=final&act=admin" method="post"><br>
<b>Username:</b><br><input size="17" type="text" name="username" value="" class="name"><br>
<b>E-mail:</b><br><input size="17" type="text" name="email" value="" class="email"><br>
<b>Password:</b> (6 - 20 char)<br>
<input size="17" type="password" name="password" value="" class="pass"><br>
Security Code:<br/>
<img src="captcha.php?width=100&height=40&characters=5" alt="security code"><br>
<input type="text" name="code" value="" size="5">
<input type="submit" name="submit" value="Sign Up"></form></div>';
}
 break;

 //First page
    default:
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">';
echo '<html xmlns="http://www.w3.org/1999/xhtml">';
echo "<head><title>Installation</title><link rel=\"stylesheet\" href=\"/style.css\" type=\"text/css\" media=\"all,handheld\"/> </head>";
echo '<body><div class="head"><img src="'.$url.'/images/logo.jpg"/></div><div class="content">';
echo '<div class="list"><img src="/images/home.png" height="15" width="15" alt="*" style="border:0px;vertical-align:middle;"/></img> <a href="'.$url.'" title="home">Home</a> | '; if($userid) { echo '<a href="'.$url.'/user">Panel</a>'; if($rights>1) { echo ' | <a href="'.$url.'/admin">admin</a>'; } echo ' | <a href="'.$url.'/logout.php">Logout</a>'; } else { echo '<a href="'.$url.'/login.php">LogIn</a> | <a href="'.$url.'/registration.php">Registration</a>'; } echo '</div><br/>';
echo '<div class="title">Installation</div>
	  <div class="list"><i>
	  1. Unzip the file to your server<br />
	  2. Create a MySQL Database<br />
	  3. Setup Database Details in "</i><b><font color="#326ca7">includes/connect.php</b></font>"</div>
	  <div class="news">Click "<font color="#326ca7">continue</font>" if you\'ve completed the procedures above!<br><b><a href="?install=tables">C0NTINUE</a></b></div>';
}
 require ('includes/footer.php'); 
?>