Skip to content

Commit

Permalink
plum's 2.2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Marsden committed Aug 27, 2019
1 parent f89b19c commit e7684a8
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 94 deletions.
8 changes: 4 additions & 4 deletions dump_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
$db = $_GET['db'];
$file_date = date("m_d_Y");
$file_name = $db . "_$file_date.sql";
$mysqlver = mysql_get_server_info();
$mysqlver = $pdo->getattribute(PDO::ATTR_SERVER_VERSION);
$date = date('F j, Y, g:i a');
$all_tables = array();
$get_tables = mysql_fetch_object(mysql_query("SELECT COUNT(TABLE_NAME) as num_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '$db'"));
$get_tables2 = mysql_query("SHOW TABLES FROM $db");
$get_tables = $pdo->query("SELECT COUNT(TABLE_NAME) as num_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '$db'")->fetch(PDO::FETCH_OBJ);
$get_tables2 = $pdo->query("SHOW TABLES FROM $db");
$rows = $get_tables->num_rows;
$dbheader = "-- MySQL Database Dump
-- Host: $host Database: $db
Expand Down Expand Up @@ -46,7 +46,7 @@
echo "<script>window.location = '$gzfile';</script>";
}
} else {
while ($arr = mysql_fetch_array($get_tables2)) {
while ($arr = $get_tables2->fetch()) {
array_push($all_tables, $arr[0]);
}
$current_t = $all_tables[$current];
Expand Down
4 changes: 2 additions & 2 deletions dump_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$table = $_GET['table'];
$file_date = date("m_d_Y");
$file_name = $db . "_" . $table . "_" . $file_date . ".sql";
$mysqlver = mysql_get_server_info();
$mysqlver = $pdo->getattribute(PDO::ATTR_SERVER_VERSION);
$date = date('F j, Y, g:i a');
$dbtableheader = "-- MySQL Table Dump
-- Host: $host Database: $db Table: $table
Expand All @@ -14,7 +14,7 @@
//Write table header to file
file_put_contents($file_name, $dbtableheader);
//Dump table
dump_table($table, $db, $file_name);
dump_table($table, $db, $file_name, 0, 0);
//Compress dump and download
$fileg2 = file_get_contents($file_name);
$gzfile = "$file_name.gz";
Expand Down
12 changes: 6 additions & 6 deletions hash_dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
$database = $_POST['hash_db'];
$table = $_POST['hash_table'];
$date = date('F j, Y, g:i a');
$query = mysql_query("SELECT * FROM $database.$table");
$query = $pdo->query("SELECT * FROM $database.$table");
$header = "This dump was taken on: $date\nFrom database: $database in table: $table\n----------------------------------------------\n";
if ($format == "hs") {
$file_name = $database."_hash_salt.txt";
//Write header to file
file_put_contents($file_name, $header);
while ($row = mysql_fetch_array($query)) {
while ($row = $query->fetch()) {
$hash = $row['password'];
$salt = $row['salt'];
$form = "$hash:$salt\n";
Expand All @@ -36,7 +36,7 @@
$file_name = $database."_username_hash_salt.txt";
//Write header to file
file_put_contents($file_name, $header);
while ($row = mysql_fetch_array($query)) {
while ($row = $query->fetch()) {
$username = $row['username'];
$hash = $row['password'];
$salt = $row['salt'];
Expand All @@ -54,7 +54,7 @@
$file_name = $database."_username_email_hash_salt.txt";
//Write header to file
file_put_contents($file_name, $header);
while ($row = mysql_fetch_array($query)) {
while ($row = $query->fetch()) {
$email = $row['email'];
$username = $row['username'];
$hash = $row['password'];
Expand All @@ -73,7 +73,7 @@
$file_name = $database."_email_hash_salt.txt";
//Write header to file
file_put_contents($file_name, $header);
while ($row = mysql_fetch_array($query)) {
while ($row = $query->fetch()) {
$email = $row['email'];
$hash = $row['password'];
$salt = $row['salt'];
Expand All @@ -91,7 +91,7 @@
$file_name = $database."_user_information.txt";
//Write header to file
file_put_contents($file_name, $header);
while ($row = mysql_fetch_array($query)) {
while ($row = $query->fetch()) {
$username = $row['username'];
$userid = $row['userid'];
$email = $row['email'];
Expand Down
14 changes: 10 additions & 4 deletions includes/example_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
$port = '3306';
$username = 'root';
$password = 'root';
if(!mysql_connect("$host:$port", $username, $password)) {
die('Could not connect to MySQL: ' . mysql_error());
}
?>
try {
$pdo = new PDO('mysql:host='.$host.';port='.$port.';dbname=;charset=utf8',
$username,
$password,
array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
);
} catch(PDOException $e) {
die($e->getMessage());
}
?>
22 changes: 12 additions & 10 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@ function Download($file) {
exit;
}
function dump_table($d_table, $d_database, $name, $n, $r) {
global $pdo;
$dump_file = "";
$n2 = $n + 1;
$file_name = $name;
$table_dump = mysql_query("SELECT * FROM $d_database.$d_table");
$table_dump2 = mysql_query("SELECT COUNT(*) as num_rows FROM $d_database.$d_table");
$res = mysql_fetch_object($table_dump2);
$table_dump = $pdo->query("SELECT * FROM $d_database.$d_table");
$table_dump2 = $pdo->query("SELECT COUNT(*) as num_rows FROM $d_database.$d_table");
$res = $table_dump2->fetch(PDO::FETCH_OBJ);
$num_rows = $res->num_rows;
if ($num_rows > 50000) {
echo "<script>window.location = './split_table.php?current=$n&next=$n2&db=$d_database&lim=0&table=$d_table&nr=$num_rows&r=$r';</script>";
exit;
} else {
while ($table_data = mysql_fetch_assoc($table_dump)) {
while ($table_data = $table_dump->fetch(PDO::FETCH_ASSOC)) {
$avalues = array_values($table_data);
$akeys = array_keys($table_data);
$addslash = array_map('addSlashes', $avalues);
$fields = implode("`, `", $akeys);
$values = implode("', '", $addslash);
$dump_file.= "INSERT INTO `$d_table` (`$fields`) VALUES ('$values');\n";
}
$result2 = mysql_query("SHOW CREATE TABLE $d_database.$d_table");
$result2 = $pdo->query("SHOW CREATE TABLE $d_database.$d_table");
$data2 = array();
while ($create_table = mysql_fetch_row($result2)) {
while ($create_table = $result2->fetch(PDO::FETCH_NUM)) {
$ct = $create_table[1];
$ct2 = "$ct;\n";
array_push($data2, $ct2);
Expand All @@ -54,21 +55,22 @@ function dump_table($d_table, $d_database, $name, $n, $r) {
}
}
function dump_table2($d_table, $d_database, $name, $limit, $last) {
global $pdo;
$dump_file = "";
$limit2 = $limit * 10000;
$file_name = $name;
$table_dump = mysql_query("SELECT * FROM $d_database.$d_table LIMIT $limit2, 10000");
while ($table_data = mysql_fetch_assoc($table_dump)) {
$table_dump = $pdo->query("SELECT * FROM $d_database.$d_table LIMIT $limit2, 10000");
while ($table_data = $table_dump->fetch(PDO::FETCH_ASSOC)) {
$avalues = array_values($table_data);
$akeys = array_keys($table_data);
$addslash = array_map('addSlashes', $avalues);
$fields = implode("`, `", $akeys);
$values = implode("', '", $addslash);
$dump_file.= "INSERT INTO `$d_table` (`$fields`) VALUES ('$values');\n";
}
$result2 = mysql_query("SHOW CREATE TABLE $d_database.$d_table");
$result2 = $pdo->query("SHOW CREATE TABLE $d_database.$d_table");
$data2 = array();
while ($create_table = mysql_fetch_row($result2)) {
while ($create_table = $result2->fetch(PDO::FETCH_NUM)) {
$ct = $create_table[1];
$ct2 = "$ct;\n";
array_push($data2, $ct2);
Expand Down
1 change: 1 addition & 0 deletions includes/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading

0 comments on commit e7684a8

Please sign in to comment.