Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-27-2007, 07:09 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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?
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #2  
Old 05-27-2007, 07:41 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by Tigairius View Post
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']);
}
?>
__________________
What signature? I see no signature?
Reply With Quote
  #3  
Old 05-27-2007, 07:52 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
requesturl worked very well, thanks
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #4  
Old 05-27-2007, 08:22 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
Attached Thumbnails
Click image for larger version

Name:	Picture 1.png
Views:	212
Size:	345.7 KB
ID:	41300  
__________________
Skyld
Reply With Quote
  #5  
Old 05-27-2007, 08:34 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Eventually also remember the requesturl object, e.g. this.request = requesturl(...), otherwise the request might be cancelled/deleted before the connection is established
Reply With Quote
  #6  
Old 05-27-2007, 09:08 PM
dNeonb dNeonb is offline
OOB
dNeonb's Avatar
Join Date: Feb 2003
Location: Germany
Posts: 1,240
dNeonb is on a distinguished road
Send a message via ICQ to dNeonb Send a message via AIM to dNeonb Send a message via Yahoo to dNeonb
Quote:
Originally Posted by Stefan View Post
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.
__________________

Forum PM
AIM GraalNeoN
ICQ 201894166
Reply With Quote
  #7  
Old 05-27-2007, 11:17 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Skyld View Post
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?
Reply With Quote
  #8  
Old 05-27-2007, 11:44 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
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.
__________________

Coming soon (Hopefully:P)
Reply With Quote
  #9  
Old 05-28-2007, 12:08 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
I think it's sent through the login server.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:00 PM.


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