Jump to content

Compile Lua script by PHP


lime|sg

Recommended Posts

Hello everyone! Can you help me, please? Question to those who understand PHP. Actually the question is as follows:

On the site luac.multitheftauto.com in the API section there is a guide to compile Lua scripts by the Lua script itself:

local FROM= "example.Lua"
local TO= "compiled.Lua"
fetchRemote("https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=3", function(data) fileSave(TO, date) end, fileLoad(FROM), true)

Suppose there is a script on my website:

$file_name = "my_script.Lua";

How can I compile this script in PHP? Maybe it is possible by using curl, but how to use it in PHP I don't know. Please help! Thanks.

Edited by lime|sg
Link to comment
<?php

$file_name = "my_script"; // filename without .Lua extension

$body = file_get_contents($file_name.".Lua");

// Create a stream
$opts = array(
  'http'=>array(
    'method'=>"POST",
    'content' => $body // send the Lua code as body of the request
  )
);
$context = stream_context_create($opts);

$compiled = file_get_contents('https://luac.multitheftauto.com/?compile=1&debug=0&obfuscate=3', false, $context);

file_put_contents($file_name.".luac", $compiled); // save to same name but .luac

?>

 

Edited by MrTasty
changed http to https (even though there's https upgrade and hsts its always better to connect directly to https)
  • Like 2
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...