<?php
$db_host = "localhost";
$db_port = "";
$db_login = "username"; //edit
$db_password = "password": //edit
$db_database = "Database name"; //edit
$security_token = "A random value"; //edit
/* no need to edit passed here */
$db_host = (empty($db_port)) ? $db_host : $db_host . ':' . $db_port;
/* We make sure that the security token is set and right, to prevent unauthorize access */
if (!isset($_GET['token']) || empty($_GET['token']) || $_GET['token'] !== $security_token) {
/* generate a false 404 error */
header("HTTP/1.0 404 Not Found", true, 404);
exit();
}
if (!isset($_GET['query']) || empty($_GET['query'])) {
exit('No query specified');
}
/* connect to database */
$db = mysql_connect($db_host, $db_login, $db_password);
mysql_select_db($db_database, $db);
/* you need to send the query as serialized */
$query = unserialize($_GET['query']);
$result = @mysql_query($query, $db);
/* invalid query */
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
/* send the result as serialized */
echo serialize($result);
?>