Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /***********************
- / Offerscript installer
- /***********************
- OfferScript version 1
- Offerscript.com
- Creator : Anthony
- */
- //Report all errors
- error_reporting(E_ALL);
- $install = 'installer.lock';
- if (file_exists($install))
- {
- die("Please delete installer.lock to re-install.");
- }
- if (isset($_POST['subm']))
- {
- //Check for empty fields
- if (empty($_POST['host']) || empty($_POST['username']) || empty($_POST['password']))
- {
- print "Please fill in the necessary information";
- exit;
- }
- //Make sure connects to MySQL
- $host = $_POST['host'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $database = $_POST['db'];
- $con = mysql_connect($host, $username, $password);
- if (!$con)
- {
- die("MySQL connection Error : " . mysql_error());
- }
- $db_selected = mysql_select_db($database, $con);
- if (!$db_selected)
- {
- die("Cant connect to database : " . mysql_error());
- }
- $filename = 'install.sql';
- $fd = fopen($filename, 'r');
- $queries = fread($fd, filesize($filename));
- fclose($fd);
- $queries = split(';', $queries);
- $count = count($queries);
- for ($idx = 0; $idx < $count; $idx++)
- {
- $query = $queries[$idx];
- $sql = mysql_query($query);
- }
- print "Installed successfully";
- $fh = fopen("installer.lock", "w+");
- if($fh==false)
- die("unable to create file");
- mysql_close($con);
- }
- else
- {
- //Actual Form
- print "
- <form action='" . $_SERVER['PHP_SELF'] . "' method='post'>
- Database Host<br><input type='text' name='host' /><br>
- Database Name<br><input type='text' name='db' /><br>
- Database Username<br><input type='text' name='username' /><br>
- Database Password<br><input type='text' name='password' /><br>
- <input type='submit' /><input type='hidden' name='subm' />
- </form>
- ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement