Run PHP Through Pawn [v2] -
i514x - 03.10.2010
v2
This little include allows you to run php scripts through pawn
Note: this include requires one .php file which needs to be run through web server
Functions:
• RunPHP(scriptid, code[]);
• FromFile(filename[]);
Callbacks:
• OnScriptResponse(scriptid, contents[])
Example:
php.txt
Код:
echo('Goodbye World!');
Some Pawn Script
pawn Код:
public OnFilterScriptInit()
{
RunPHP(0, "echo('Hello World!');");
return 1;
}
public OnFilterScriptExit()
{
RunPHP(1, FromFile('php.txt'));
return 1;
}
public OnScriptResponse(scriptid, contents[])
{
if(scriptid == 0) printf("OnFilterScriptInit: %s", contents);
if(scriptid == 1) printf("OnFilterScriptExit: %s", contents);
return 1;
}
php.inc
php.php
Upload php.php on your web server, upload php.inc to your pawno/include directory
And to use it at the top of your pawn script add:
pawn Код:
#define PHP_FILE_LOCATION "CHANGEME" //the web addreess to php.php file
#define SECURITY_CODE "YOUR_SECURITY_CODE" //here goes your security code
#include <php>
also set your security code in php.php
PS: Sorry for my bad english or if i didn't explain something
Re: Run PHP Through Pawn -
willsuckformoney - 03.10.2010
Cool, so PHP is for websites? Never knew.
Re: Run PHP Through Pawn -
i514x - 03.10.2010
Quote:
Originally Posted by willsuckformoney
Cool, so PHP is for websites? Never knew.
|
yes, you can make websites with PHP
but the purpose of this release is so you can make cool functions using PHP
no more plugins to functions like sha1() or md5() because it can be easily made with this except you just have to know PHP functions and stuff like that
Re: Run PHP Through Pawn -
Bumbis - 03.10.2010
So i guess it might be usefull. Nice idea.
Re: Run PHP Through Pawn -
Remis - 03.10.2010
But isn't this insecure? I would only allow it if it runs locally.
And why didn't you just use eval?
Re: Run PHP Through Pawn -
i514x - 03.10.2010
Quote:
Originally Posted by Remis
But isn't this insecure? I would only allow it if it runs locally.
|
it is 100% secure because if you upload it on your web server, only you control over PHP code that is in your map
Quote:
Originally Posted by Remis
And why didn't you just use eval?
|
what do you mean? sorry don't understand you
Re: Run PHP Through Pawn -
Remis - 03.10.2010
Quote:
Originally Posted by i514x_
only you control over PHP code that is in your map
|
Sorry, but what do you mean with this.
If I upload it to the webserver everyone can run post requests to it running any code. It will be in a public folder, otherwise this script won't work because it can't access the address.
So the only way is by only allowing local connections in the php script. (if the sa-mp server and the webserver are on the same host)
Quote:
what do you mean? sorry don't understand you
|
I mean eval, the function:
http://de2.php.net/manual/en/function.eval.php
Then you wouldn't need to create a cache file and include it.
Re: Run PHP Through Pawn -
i514x - 03.10.2010
Quote:
Originally Posted by Remis
Sorry, but what do you mean with this.
If I upload it to the webserver everyone can run post requests to it running any code. It will be in a public folder, otherwise this script won't work because it can't access the address.
So the only way is by only allowing local connections in the php script. (if the sa-mp server and the webserver are on the same host)
I mean eval, the function: http://de2.php.net/manual/en/function.eval.php
Then you wouldn't need to create a cache file and include it.
|
i didnt even knew that function existed but thx
to what you said before you're right but you can create free web hosting where you don't have anything else than that file php.php and it will be alright
PS: there are plenty of free web hostings
Re: Run PHP Through Pawn -
GaGlets(R) - 03.10.2010
Hmm .. i think this is un-useful.
There are nothing special that you could add through php only the same pawno functions...
its just my main, if i`m wrong say it to me and give some reason for that.
So you made this inc. so i could add immages to sa-mp like MTA? - answr is no.
so nothing cool .. only you can somehow script this with donators to automaticly give something...
Re: Run PHP Through Pawn -
JernejL - 04.10.2010
Quote:
Originally Posted by i514x_
yes, you can make websites with PHP
but the purpose of this release is so you can make cool functions using PHP
no more plugins to functions like sha1() or md5() because it can be easily made with this except you just have to know PHP functions and stuff like that
|
This idea is SO bad it's impossible to describe. Why is a plugin sha1 function bad? it's lightning fast, i dare you do a benchmark to see if your php sha1 is faster than a plugin sha1 variant.
Your script will never run at playable speed with > 10 players if done in php.