43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
// Check user agent and assign userID
|
|
if ($_SERVER['HTTP_USER_AGENT'] != "Graphictoria3") exit;
|
|
if (!isset($_GET['userID'])) exit;
|
|
if (is_array($_GET['userID'])) exit;
|
|
if (strlen($_GET['userID']) == 0) exit;
|
|
if (!is_numeric($_GET['userID'])) exit;
|
|
$uid = $_GET['userID'];
|
|
|
|
// Check if key exists and validate it
|
|
if (!isset($_GET['key'])) exit;
|
|
if (is_array($_GET['key'])) exit;
|
|
$key = $_GET['key'];
|
|
|
|
//Check if gameID exists and validate it
|
|
if (!isset($_GET['gameID'])) exit;
|
|
if (strlen($_GET['gameID']) == 0) exit;
|
|
if (is_array($_GET['gameID'])) exit;
|
|
if (!is_numeric($_GET['gameID'])) exit;
|
|
$gameId = $_GET['gameID'];
|
|
|
|
// Assign random string function
|
|
function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
|
{
|
|
$str = '';
|
|
$max = mb_strlen($keyspace, '8bit') - 1;
|
|
for ($i = 0; $i < $length; ++$i) {
|
|
$str .= $keyspace[random_int(0, $max)];
|
|
}
|
|
return $str;
|
|
}
|
|
|
|
$script = file_get_contents('http://api.xdiscuss.net/user/game/getScript.php?userID='.$uid.'&gameID='.$gameId.'&key=9cBOle3VIeU0wBfZmkL92qNU63xk8Y90&pkey='.$key);
|
|
$filename = "script" . time() . random_str(8);
|
|
$linuxDirectory = "/usr/bin/luac/scripts/" . $filename;
|
|
$wineDirectory = "Z://usr//bin//luac//scripts//" . $filename;
|
|
file_put_contents($linuxDirectory . ".lua", $script);
|
|
shell_exec("sudo -S wine /usr/bin/luac/luac5.1.exe -s -o ".$wineDirectory.".luac ".$wineDirectory.".lua 2>&1");
|
|
echo file_get_contents($linuxDirectory . ".luac");
|
|
|
|
@unlink($linuxDirectory . ".luac");
|
|
@unlink($linuxDirectory . ".lua");
|
|
?>
|