Guest User

Error

a guest
Sep 5th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.56 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['domain'])&&$_POST['domain']!=''
  3.     &&isset($_POST['db_host'])&&$_POST['db_host']!=''
  4.     &&isset($_POST['db_name'])&&$_POST['db_name']!=''
  5.     &&isset($_POST['db_user'])&&$_POST['db_user']!=''
  6.     &&isset($_POST['db_pass']))
  7.     {
  8.         function write_to_file($filename, $data){
  9.             $fp = fopen($filename, 'w');
  10.                 fwrite($fp, $data);
  11.                 fclose($fp);
  12.         }
  13.         function IMPORT_TABLES($host,$user,$pass,$dbname, $sql_file_OR_content){
  14.             set_time_limit(3000);
  15.             $SQL_CONTENT = (strlen($sql_file_OR_content) > 300 ?  $sql_file_OR_content : file_get_contents($sql_file_OR_content)  );  
  16.             $allLines = explode("\n",$SQL_CONTENT);
  17.             $mysqli = new mysqli($host, $user, $pass, $dbname); if (mysqli_connect_errno()){echo "Failed to connect to MySQL: " . mysqli_connect_error();}
  18.                     $zzzzzz = $mysqli->query('SET foreign_key_checks = 0');         preg_match_all("/\nCREATE TABLE(.*?)\`(.*?)\`/si", "\n". $SQL_CONTENT, $target_tables); foreach ($target_tables[2] as $table){$mysqli->query('DROP TABLE IF EXISTS '.$table);}         $zzzzzz = $mysqli->query('SET foreign_key_checks = 1');    $mysqli->query("SET NAMES 'utf8'");  
  19.             $templine = ''; // Temporary variable, used to store current query
  20.             foreach ($allLines as $line)    {                                           // Loop through each line
  21.                     if (substr($line, 0, 2) != '--' && $line != '') {$templine .= $line;    // (if it is not a comment..) Add this line to the current segment
  22.                             if (substr(trim($line), -1, 1) == ';') {        // If it has a semicolon at the end, it's the end of the query
  23.                                     if(!$mysqli->query($templine)){ print('Error performing query \'<strong>' . $templine . '\': ' . $mysqli->error . '<br /><br />');  }  $templine = ''; // set variable to empty, to start picking up the lines after ";"
  24.                             }
  25.                     }
  26.             }   return;
  27.         }
  28.         $filename = 'database.sql';
  29.         $mysql_host = $_POST['db_host'];
  30.         $mysql_username = $_POST['db_user'];
  31.         $mysql_password = $_POST['db_pass'];
  32.         $mysql_database = $_POST['db_name'];
  33.         mysqli_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error()."<a style='color: red; font-weight: bold; font-size: 20px;' href='install.php'>go back and try again.</a> If you have no ideas why it happening email me - support@deep64.com");
  34.         mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error()."<a style='color: red; font-weight: bold; font-size: 20px;' href='install.php'>go back and try again.</a> If you have no ideas why it happening email me - support@deep64.com");
  35.         IMPORT_TABLES($mysql_host, $mysql_username, $mysql_password, $mysql_database, 'database.sql');
  36.         $text="<?php
  37.                ".'$'."db['default']['hostname']= '$mysql_host';                         // HOSTNAME HERE
  38.                ".'$'."db['default']['username']=  '$mysql_username';                      // USERNAME HERE
  39.                ".'$'."db['default']['password']=  '$mysql_password';                     // PASSWORD HERE
  40.                ".'$'."db['default']['database']=  '$mysql_database';                     // DB NAME HERE
  41.                ".'$'."db['default']['dbdriver']=  'mysqli';
  42.        ";
  43.         write_to_file('application/config/db.php', $text);
  44.         $text="<?php
  45.        ".'$'."config['base_url'] = '".$_POST['domain']."';
  46.        ";
  47.         write_to_file('application/config/siteurl.php', $text);
  48.         $text="RewriteEngine on
  49. RewriteCond $1 !^(index\.php|resources|robots\.txt)
  50. RewriteCond %{REQUEST_FILENAME} !-f
  51. RewriteCond %{REQUEST_FILENAME} !-d
  52. RewriteCond %{REQUEST_URI} !/assets
  53. RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
  54. RewriteRule page/assets/img/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/$1 [R=301,L,NC]
  55. RewriteRule page/assets/img/uploads/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/uploads/$1 [R=301,L,NC]
  56. RewriteRule admin/assets/img/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/$1 [R=301,L,NC]
  57. RewriteRule admin/assets/img/uploads/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/uploads/$1 [R=301,L,NC]
  58.        ";
  59.         write_to_file('.htaccess', $text);
  60.         header("Location: ".$_POST['domain']);
  61.     }else{
  62.         echo "You missed something, <a style='color: red; font-weight: bold; font-size: 20px;' href='install.php'>go back and try again.</a> If you have no ideas why it happening email me - support@deep64.com";
  63.     }
Add Comment
Please, Sign In to add comment