Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   requesthttp & PHP help (https://forums.graalonline.com/forums/showthread.php?t=74240)

Tigairius 05-27-2007 07:09 PM

requesthttp & PHP help
 
I am trying to do a "Live Stats" section on Ol' Wests new site.
under actionPlayeronline on the Control-NPC I wrote:
requesthttp("olwest.awardspace.com", 80, "index.php?do=stats&pcount=" @ allplayerscount);

and on the stats page I wrote:

<?PHP
if($_GET['pcount'] > 0){
$content = $_GET['pcount'];
$fp = fopen("./stats.txt","wb");
fwrite($fp,$content);
fclose($fp);
}
$display = fopen("./stats.txt","r");
$line = fgets($display);
echo"There are currently ". $line ." people online.";
?>

For some reason the request HTTP isn't working on my server, is it disabled? I spoke with Björn about how he did it on his Graal Kingdoms Lib site, and he said it doesn't work anymore but he's not sure why. Any input on this?

godofwarares 05-27-2007 07:41 PM

Quote:

Originally Posted by Tigairius (Post 1312476)
I am trying to do a "Live Stats" section on Ol' Wests new site.
under actionPlayeronline on the Control-NPC I wrote:
requesthttp("olwest.awardspace.com", 80, "index.php?do=stats&pcount=" @ allplayerscount);

and on the stats page I wrote:

<?PHP
if($_GET['pcount'] > 0){
$content = $_GET['pcount'];
$fp = fopen("./stats.txt","wb");
fwrite($fp,$content);
fclose($fp);
}
$display = fopen("./stats.txt","r");
$line = fgets($display);
echo"There are currently ". $line ." people online.";
?>

For some reason the request HTTP isn't working on my server, is it disabled? I spoke with Björn about how he did it on his Graal Kingdoms Lib site, and he said it doesn't work anymore but he's not sure why. Any input on this?

Try using requesturl:

PHP Code:

temp.link "http://www.server.com/path/to/script.php?whatever=foo";
requesturl(temp.link); 

Thats how I get live stats on my webserver.


Also, For the PHP file, Try this:

PHP Code:

<?php
if (isset($_GET['playersonline']))
{
    
$data fopen("serverdata.txt""w+") or die("");
    
    
fputs($data$_GET['playersonline']);
}
?>


Tigairius 05-27-2007 07:52 PM

requesturl worked very well, thanks :)

Skyld 05-27-2007 08:22 PM

1 Attachment(s)
Just so you know, you should really put some sort of security or IP checking or something in your PHP script to confirm that the data is actually coming from the gserver.

You can probably find the IP of the server from the Graal Stats, and then check $_SERVER['REMOTE_ADDR'] against that IP or something, I guess.

Admins 05-27-2007 08:34 PM

Eventually also remember the requesturl object, e.g. this.request = requesturl(...), otherwise the request might be cancelled/deleted before the connection is established

dNeonb 05-27-2007 09:08 PM

Quote:

Originally Posted by Stefan (Post 1312492)
Eventually also remember the requesturl object, e.g. this.request = requesturl(...), otherwise the request might be cancelled/deleted before the connection is established

But it's weird. After you moved servers somehow the live stats for gk on my page stopped working.

Rapidwolve 05-27-2007 11:17 PM

Quote:

Originally Posted by Skyld (Post 1312490)
Just so you know, you should really put some sort of security or IP checking or something in your PHP script to confirm that the data is actually coming from the gserver.

You can probably find the IP of the server from the Graal Stats, and then check $_SERVER['REMOTE_ADDR'] against that IP or something, I guess.

I still don't understand how this Graal Stats site woks. How does it display information on the servers like that? Is that site made by someone who works on Graal?

JkWhoSaysNi 05-27-2007 11:44 PM

I don't know how it works unless it connects to graal as some sort of bot. I've no idea how it would do this though.

Tigairius 05-28-2007 12:08 AM

I think it's sent through the login server.


All times are GMT +2. The time now is 01:51 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.