Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['domain'])&&$_POST['domain']!=''
- &&isset($_POST['db_host'])&&$_POST['db_host']!=''
- &&isset($_POST['db_name'])&&$_POST['db_name']!=''
- &&isset($_POST['db_user'])&&$_POST['db_user']!=''
- &&isset($_POST['db_pass']))
- {
- function write_to_file($filename, $data){
- $fp = fopen($filename, 'w');
- fwrite($fp, $data);
- fclose($fp);
- }
- function IMPORT_TABLES($host,$user,$pass,$dbname, $sql_file_OR_content){
- set_time_limit(3000);
- $SQL_CONTENT = (strlen($sql_file_OR_content) > 300 ? $sql_file_OR_content : file_get_contents($sql_file_OR_content) );
- $allLines = explode("\n",$SQL_CONTENT);
- $mysqli = new mysqli($host, $user, $pass, $dbname); if (mysqli_connect_errno()){echo "Failed to connect to MySQL: " . mysqli_connect_error();}
- $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'");
- $templine = ''; // Temporary variable, used to store current query
- foreach ($allLines as $line) { // Loop through each line
- if (substr($line, 0, 2) != '--' && $line != '') {$templine .= $line; // (if it is not a comment..) Add this line to the current segment
- if (substr(trim($line), -1, 1) == ';') { // If it has a semicolon at the end, it's the end of the query
- 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 ";"
- }
- }
- } return;
- }
- $filename = 'database.sql';
- $mysql_host = $_POST['db_host'];
- $mysql_username = $_POST['db_user'];
- $mysql_password = $_POST['db_pass'];
- $mysql_database = $_POST['db_name'];
- 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");
- 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");
- IMPORT_TABLES($mysql_host, $mysql_username, $mysql_password, $mysql_database, 'database.sql');
- $text="<?php
- ".'$'."db['default']['hostname']= '$mysql_host'; // HOSTNAME HERE
- ".'$'."db['default']['username']= '$mysql_username'; // USERNAME HERE
- ".'$'."db['default']['password']= '$mysql_password'; // PASSWORD HERE
- ".'$'."db['default']['database']= '$mysql_database'; // DB NAME HERE
- ".'$'."db['default']['dbdriver']= 'mysqli';
- ";
- write_to_file('application/config/db.php', $text);
- $text="<?php
- ".'$'."config['base_url'] = '".$_POST['domain']."';
- ";
- write_to_file('application/config/siteurl.php', $text);
- $text="RewriteEngine on
- RewriteCond $1 !^(index\.php|resources|robots\.txt)
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_URI} !/assets
- RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
- RewriteRule page/assets/img/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/$1 [R=301,L,NC]
- RewriteRule page/assets/img/uploads/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/uploads/$1 [R=301,L,NC]
- RewriteRule admin/assets/img/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/$1 [R=301,L,NC]
- RewriteRule admin/assets/img/uploads/([^.]+\.(jpe?g|gif|bmp|png))$ /assets/img/uploads/$1 [R=301,L,NC]
- ";
- write_to_file('.htaccess', $text);
- header("Location: ".$_POST['domain']);
- }else{
- 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";
- }
Add Comment
Please, Sign In to add comment