<?php
error_reporting(E_ALL ^ E_DEPRECATED);
mysqli_report(MYSQLI_REPORT_OFF);
include "../include/variables.php";
include "../include/functions.php";
include "../include/errors.php";
include "../include/getip.php";
include "../include/sqlwrapper.php";
$PHP_SELF=$_SERVER['PHP_SELF'];
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
if (ob_get_length()) ob_end_clean();
ob_start("ob_gzhandler");
}
else ob_start();
if (!empty($_SERVER['HTTPS'])) {
$session_options = array(
"secure" => true,
"SameSite" => "None"
);
session_set_cookie_params($session_options);
}
session_start();
include "../include/lang.php";
include "../include/auth.php";
if ($admin) {
include "../include/db.php";
if ($db_link){
header('Content-Type: text/plain; charset=utf-8');
header("Content-Disposition: inline; filename=$db.sql");
mysqli_select_db($db_link,$db);
mysqli_query($db_link,"set names utf8mb4");
$query="show tables";
$result=mysqli_query($db_link,$query) or die(mysqli_error($db_link));
if (mysqli_num_rows($result) > 0){
while ($arr=mysqli_fetch_assoc($result)){
foreach ($arr as $table) {
$query="desc $table";
$result2=mysqli_query($db_link,$query) or die(mysqli_error($db_link));
echo "create table `$table` (";
$first=false;
while ($arr2=mysqli_fetch_assoc($result2)){
if (!$first) $first = true;
else echo ",";
echo "`".$arr2['Field']."` ";
switch($arr2['Type']) {
case "mediumtext": echo "text"; break;
case "int(11)": echo "int"; break;
default: echo $arr2['Type']; break;
}
echo ($arr2['Null'] == "NO"?" not null":"");
if ($arr2['Default'] !== NULL) {
$quotes=false;
$escape=true;
if (preg_match("/^varchar\([^\)]+\)\$/i",$arr2['Type'])) {
$quotes=true;
}
if (($arr2['Type'] == "mediumtext") || ($arr2['Type'] == "text")) {
$escape = false;
}
echo " default ";
if ($quotes) echo "'";
if ($escape)
echo mysqli_real_escape_string($db_link,$arr2['Default']);
else
echo $arr2['Default'];
if ($quotes) echo "'";
}
echo (!empty($arr2['Extra'])?(" ".$arr2['Extra']):"").($arr2['Key'] == "PRI"?" primary key":"");
}
echo ")";
$query="SELECT ENGINE,AUTO_INCREMENT,TABLE_COLLATION,CHARACTER_SET_NAME FROM information_schema.`TABLES` T,information_schema.COLLATION_CHARACTER_SET_APPLICABILITY CCSA where CCSA.collation_name = T.table_collation and T.TABLE_SCHEMA = '$db' and T.TABLE_NAME = '$table'";
$result2=mysqli_query($db_link,$query) or die(mysqli_error($db_link));
if (mysqli_num_rows($result) > 0){
echo " ";
while ($arr2=mysqli_fetch_assoc($result2)){
$first=false;
$query="show variables like 'default_storage_engine'";
$result3=mysqli_query($db_link,$query) or die(mysqli_error($db_link));
if (mysqli_num_rows($result3) == 0 || !($arr3=mysqli_fetch_assoc($result3)) || $arr3['Value'] != $arr2['ENGINE']) {
if (!empty($arr2['ENGINE'])) {
if (!$first) $first = true;
else echo " ";
echo "ENGINE=".$arr2['ENGINE'];
}
}
switch ($table) {
case "abuseipdb":
case "accesslog":
case "antiflood":
case "ipfilter_log":
break;
default:
if (!empty($arr2['AUTO_INCREMENT'])) {
if (!$first) $first = true;
else echo " ";
echo "AUTO_INCREMENT=".$arr2['AUTO_INCREMENT'];
}
break;
}
if (!empty($arr2['CHARACTER_SET_NAME'])) {
if (!$first) $first = true;
else echo " ";
echo "DEFAULT CHARSET=".$arr2['CHARACTER_SET_NAME'];
}
if (!empty($arr2['TABLE_COLLATION'])) {
if (!$first) $first = true;
else echo " ";
echo "COLLATE=".$arr2['TABLE_COLLATION'];
}
}
}
echo ";\n\n";
switch ($table) {
case "abuseipdb":
case "accesslog":
case "antiflood":
case "ipfilter_log":
break;
default:
$query="select * from $table";
$result2=mysqli_query($db_link,$query) or die(mysqli_error($db_link));
if (mysqli_num_rows($result2) > 0) {
while ($arr2=mysqli_fetch_assoc($result2)){
foreach ($arr2 as $name => $value){
$names[]="`".$name."`";
$values[]=(!is_numeric($value)?"'":"").mysqli_real_escape_string($db_link,$value).(!is_numeric($value)?"'":"");
}
echo "insert into `$table` (".implode(",",$names).") values (".implode(",",$values).");\n";
unset($names,$values);
}
echo "\n";
}
$query="SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = '$db' AND TABLE_NAME = '$table'";
$result2=mysqli_query($db_link,$query) or die(mysqli_error($db_link));
if (mysqli_num_rows($result) > 0){
if ($arr2=mysqli_fetch_assoc($result2)){
if($arr2['AUTO_INCREMENT'] !== NULL)
echo "alter table `$table` AUTO_INCREMENT=".$arr2['AUTO_INCREMENT'].";\n\n";
}
}
break;
}
}
}
//echo "</pre>";
}
mysqli_close($db_link);
} else {
$evt=503;
header ($_SERVER['SERVER_PROTOCOL']." 503 Service Unavailable");
echo "Database connection error.";
}
} else {
$evt=403;
header ($_SERVER['SERVER_PROTOCOL']." 403 Forbidden");
echo "You need to log in as admin to use this feature.";
}
include "../include/iplog.php";
saveTranslations();
?>
You can also check other includes below (some files are hidden as they are in exclusion list):
functions.php
errors.php
getip.php
sqlwrapper.php
lang.php
auth.php
iplog.php