The online racing simulator
http code support
script.php

<?php

$allowed_list = array(

"TechEdison" => "yes",
"Androphp" => "no"

);

$username = $_GET["u"];

if($allowed_list[$username] == "yes")
{

echo '$allowed = 1;';

}
else
{

echo '$allowed = 0;';

}

?>

LFSLapper.lpr



Sub verify($userName)

http("http://localhost/script.php?u=".$userName);

IF($allowed == 0)
THEN

cmdLFS("/kick ".$userName);
GlobalMsg("Kicked: ".$userName.". Reason: Not Alowed");

ELSE

GlobalMsg("Welcome Back: ".$userName);

ENDIF

EndSub




CASE "!test":
verify($userName);
BREAK;


Hello developers, I had the opportunity to try these codes today and I tried them. But I am encountering a problem here, let me state the problem right away. First of all, I don't get any errors, but I think I did something wrong somewhere, but I couldn't figure it out. I'm starting to explain, I ran the codes on my localhost, I have a script.php file, but I couldn't print the values ​​coming from there to the lapper with if. To elaborate, let's assume that I did not define $allowed in the if else values ​​in PHP, and I added 2 GlobalMsgs to the if and else parts where $allowed is written. If the value is yes, it sends me a Value: 1 msg. If the value is no, I set the value: 0 to a GlobalMsg via PHP. In this case, I get the correct value, but when I put $allowed value in php and want to send GlobalMsg to the lapper with if, the $allowed value from php always sends the same message whether it is 1 or 0. I think I have a problem with the if writing in the lapper section, I couldn't solve it. It would be nice if people with knowledge on this subject could help me. Good work to everyone.
What if you try to rename the sub.
Because the http() function has the same name as the sub.
Quote from Bass-Driver :What if you try to rename the sub.
Because the http() function has the same name as the sub.

Actually, something different is written in that section in my own code. I changed it while writing the code in a hurry. Normally, it was called Sub verify, which means I don't have any problems redirecting to the sub, but for some reason, there is a problem with the if value.

Sub SendWebRequest($userName)
privmsg("Send webrequest");



$allowed = http("http://localhost/testscript.php?u=".$userName);

IF($allowed == 0)
THEN
cmdLFS("/kick ".$userName);
GlobalMsg("Kicked: ".$userName.". Reason: Not Alowed");
ELSE
GlobalMsg("Welcome Back: ".$userName);
ENDIF



EndSub

I tried it this way too, but I only get one result from the if, when I change the value the result is always the same.
Never used the http feature before, but i think you have to give the $allowed variable a value. Also you need to be sure, that the http function returns a value.


$allowed = http("http://localhost/script.php?u=".$userName);
IF($allowed == 0)
THEN
cmdLFS("/kick ".$userName);
GlobalMsg("Kicked: ".$userName.". Reason: Not Alowed");
ELSE
GlobalMsg("Welcome Back: ".$userName);
ENDIF

EDIT: nvm too late with this post lel

To test and help properly, i need to install a webserver on my pc and make a basic php script. Won't do that today tho. Any more guessing doesn't help.
The value of the $allowed variable returns a $allowed variable from PHP with the data sent to you from http, but I don't understand where the problem is. I'm waiting for your results when you test.
Quote from Yisc[NL :;2080328"]Have a look at this message: https://www.lfs.net/forum/thread/93714

I can successfully send data from the PHP section, send globalmsg etc., but when it comes to printing the request from http with if in the lapper, it fails.
I get it, the webpage should send a variable to Lapper, but I am not sure if that's possible.
You could try to add this to your PHP-script:

echo "0";

Or 1 if that is the outcome of the check.
But again, I am not sure if it's possible to start with.
If I am in de mood this weekend, I will give it a try and come back on it (no promises though).
** Best answer **
It took some time,headaches and cursing to windows to get a webserver and PHP working on my PC.
Do not ask me on how or what i did it to setup a webserver with .PHP file extensions.Big grin

But i finally got some results.Thumbs up

The http() function is to execute other functions like:

Sub BlahBlah($something,$something);
EndSub

I've started with creating a simple command named !http.
Within that command, i've executed the http() function with the link to my local website.


CASE "!http":
$user = $argv;
http("http://localhost/Test/LFSLapper_Test.php?u=".$user);
BREAK;

inside the folder of the website, i created a PHP file and took some code i've found on this LFSLapper sub forum .Later i've added more stuff just for testing.

<?php
$allowed_list = array(

"TechEdison" => "no",
"Androphp" => "yes",
"Bass-Driver" => "yes"
);

$username = $_GET["u"];

if (array_key_exists("".$username."",$allowed_list))
{
if($allowed_list[$username] == "yes")
{
echo 'WebReturn('.$username.',"Allowed");';
}
else
{
echo 'WebReturn('.$username.',"Not Allowed");';
}
}
else
{
echo 'WebReturn('.$username.',"Not Found");';
}
?>

The code will check, if the username exist within the array named: $allowed_list
After that it checks if the username is allowed or not.

The return value must be a function and not a single character,number or word.

Example
'privmsg('$username.',"something");';
'globalmsg("something");';
'YourOwnNamedFunction("Parameter");';

In the testcode above, it returns a string named WebReturn('.$username.',"Not Found");
The LFSLapper sourcecode will translate this into a function with their given parameters.

Back to my Lapperscript, i've created a sub function with the parameters.

Sub WebReturn($User,$Allowed)
globalmsg("Player: ".$User." = ".$Allowed);
EndSub

Output:
Player: TechEdison = Not Allowed
Player: Androphp = Allowed
Player: 0 = Allowed (i have no idea why it returns a 0 when i'm in the server, this could be old lapperbug)


Please correct me, if i did something wrong. I'm totally not into web stuff.
Quote from Bass-Driver :It took some time,headaches and cursing to windows to get a webserver and PHP working on my PC.
Do not ask me on how or what i did it to setup a webserver with .PHP file extensions.Big grin

But i finally got some results.Thumbs up

The http() function is to execute other functions like:

Sub BlahBlah($something,$something);
EndSub

I've started with creating a simple command named !http.
Within that command, i've executed the http() function with the link to my local website.


CASE "!http":
$user = $argv;
http("http://localhost/Test/LFSLapper_Test.php?u=".$user);
BREAK;

inside the folder of the website, i created a PHP file and took some code i've found on this LFSLapper sub forum .Later i've added more stuff just for testing.

<?php
$allowed_list = array(

"TechEdison" => "no",
"Androphp" => "yes",
"Bass-Driver" => "yes"
);

$username = $_GET["u"];

if (array_key_exists("".$username."",$allowed_list))
{
if($allowed_list[$username] == "yes")
{
echo 'WebReturn('.$username.',"Allowed");';
}
else
{
echo 'WebReturn('.$username.',"Not Allowed");';
}
}
else
{
echo 'WebReturn('.$username.',"Not Found");';
}
?>

The code will check, if the username exist within the array named: $allowed_list
After that it checks if the username is allowed or not.

The return value must be a function and not a single character,number or word.

Example
'privmsg('$username.',"something");';
'globalmsg("something");';
'YourOwnNamedFunction("Parameter");';

In the testcode above, it returns a string named WebReturn('.$username.',"Not Found");
The LFSLapper sourcecode will translate this into a function with their given parameters.

Back to my Lapperscript, i've created a sub function with the parameters.

Sub WebReturn($User,$Allowed)
globalmsg("Player: ".$User." = ".$Allowed);
EndSub

Output:
Player: TechEdison = Not Allowed
Player: Androphp = Allowed
Player: 0 = Allowed (i have no idea why it returns a 0 when i'm in the server, this could be old lapperbug)


Please correct me, if i did something wrong. I'm totally not into web stuff.

Thank you for your answer, this seems like something really useful, I will try this code because it will be easier to check the codes I have implemented in PHP on Lapper, thank you for your help.
IF you have other example codes. You could give it to me, so i can create a tutorial for it with example codes.
Like i did with the Discord feature.
Quote from Bass-Driver :IF you have other example codes. You could give it to me, so i can create a tutorial for it with example codes.
Like i did with the Discord feature.

It will be really difficult for you to explain how the http code works or to try to train people to run it or to try to provide a website training. Especially for someone who doesn't know anything, creating a website infrastructure, reading PHP codes and directing them to the game (I'm sure they will get many errors while doing these) because every new person experiences these problems. If you believe that you can explain it and deal with the problems arising here, I can share a few simple code examples.

FGED GREDG RDFGDR GSFDG