Guest User

Untitled

a guest
Oct 17th, 2010
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.89 KB | None | 0 0
  1. /*
  2.  
  3. Pawn Library
  4. Run PHP through Pawn
  5. by i514x_
  6.  
  7. */
  8.  
  9. #include <a_http>
  10.  
  11. #define MAX_PHP_LENGTH 256
  12.  
  13. forward OnServerTryingToRunPHP(index, response_code, data[]);
  14. forward OnScriptResponse(scriptid, contents[]);
  15.  
  16. stock RunPHP(scriptid, code[MAX_PHP_LENGTH])
  17. {
  18.     new string[MAX_PHP_LENGTH+5];
  19.     format(string, sizeof(string), "code=%s&security="SECURITY_CODE, code);
  20.     HTTP(scriptid, HTTP_POST, PHP_FILE_LOCATION, string, "OnServerTryingToRunPHP");
  21. }
  22.  
  23. stock FromFile(filename[])
  24. {
  25.     new string[MAX_PHP_LENGTH];
  26.     new File:f = fopen(filename, io_read);
  27.     if(f)
  28.     {
  29.         fread(f, string);
  30.     }
  31.     fclose(f);
  32.     return string;
  33. }
  34.  
  35. public OnServerTryingToRunPHP(index, response_code, data[])
  36. {
  37.     if(response_code != 200)
  38.     {
  39.         printf("Error: %d, trying to compile PHP on external server.", response_code);
  40.         return 0;
  41.     }
  42.     CallLocalFunction("OnScriptResponse", "ds", index, data);
  43.     return 1;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment