Advertisement
Guest User

Untitled

a guest
May 30th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <?
  2. /***********************
  3. / Offerscript installer
  4. /***********************
  5.  
  6. OfferScript version 1
  7. Offerscript.com
  8. Creator : Anthony
  9. */
  10.  
  11. //Report all errors
  12. error_reporting(E_ALL);
  13.  
  14. $install = 'installer.lock';
  15. if (file_exists($install))
  16.         {
  17.                 die("Please delete installer.lock to re-install.");
  18.         }
  19.  
  20. if (isset($_POST['subm']))
  21.         {
  22.                 //Check for empty fields
  23.                 if (empty($_POST['host']) || empty($_POST['username']) || empty($_POST['password']))
  24.                         {
  25.                                 print "Please fill in the necessary information";
  26.                                 exit;
  27.                         }
  28.                 //Make sure connects to MySQL
  29.                 $host     = $_POST['host'];
  30.                 $username = $_POST['username'];
  31.                 $password = $_POST['password'];
  32.                 $database = $_POST['db'];
  33.                
  34.                 $con = mysql_connect($host, $username, $password);
  35.                 if (!$con)
  36.                         {
  37.                                 die("MySQL connection Error : " . mysql_error());
  38.                         }
  39.                 $db_selected = mysql_select_db($database, $con);
  40.                 if (!$db_selected)
  41.                         {
  42.                                 die("Cant connect to database : " . mysql_error());
  43.                         }
  44.                 $filename = 'install.sql';
  45.                 $fd       = fopen($filename, 'r');
  46.                 $queries  = fread($fd, filesize($filename));
  47.                 fclose($fd);
  48.                 $queries = split(';', $queries);
  49.                
  50.                 $count = count($queries);
  51.                 for ($idx = 0; $idx < $count; $idx++)
  52.                         {
  53.                                 $query = $queries[$idx];
  54.                                 $sql   = mysql_query($query);
  55.                         }
  56.                 print "Installed successfully";
  57.                 $fh = fopen("installer.lock", "w+");
  58.                 if($fh==false)
  59.                 die("unable to create file");
  60.                 mysql_close($con);
  61.         }
  62. else
  63.         {
  64.                 //Actual Form
  65.                 print "
  66.    <form action='" . $_SERVER['PHP_SELF'] . "' method='post'>
  67.    Database Host<br><input type='text' name='host' /><br>
  68.    Database Name<br><input type='text' name='db' /><br>
  69.    Database Username<br><input type='text' name='username' /><br>
  70.    Database Password<br><input type='text' name='password' /><br>
  71.    <input type='submit' /><input type='hidden' name='subm' />
  72.    </form>
  73.    ";
  74.         }
  75. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement