Raised This Month: $32 Target: $400
 8% 

Trash this one


Post New Thread Reply   
 
Thread Tools Display Modes
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-25-2012 , 19:31   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #21

Don't works

Look:

Code:
<?php require_once('JG_Cache.php'); require_once('SourceQuery.class.php'); $servers = array( 'server_01' => array ('name' => 'Server #1', 'ip' => '189.38.58.98', 'port' => '27036') ); foreach ($servers as $server) {   $cache = new JG_Cache('/tmp');   $info = $cache->get($server['name'], 60); // second paramater = cache time in seconds   if ($info === false) {     $query = new SourceQuery();     try {       $query->Connect($server['ip'], $server['port']);       $info = $query->GetInfo();     } catch (SourceQueryException $e) {       $info = $e->getMessage();     }     //$cache->set($server['name'], $info);   }   if (is_array($info)) {     echo '<div style="color:#fff;">' . $server['ip'] . ':' . $server['port'] . ' | map: ' . $info['Map'] . ' | players: ' . $info['Players'] . '/' . $info['MaxPlayers'] . '</div>';   }   else {     echo '<div style="color:#ff0000;">' . $server['ip'] . ':' . $server['port'] . ' (offline)</div>';   } }
__________________
kramesa is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-25-2012 , 19:36   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #22

I can't help you if you keep ignoring my questions.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-25-2012 , 19:40   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #23

Quote:
Originally Posted by 8088 View Post
Is error reporting enabled at its absolute maximum? Can you write to /tmp?
I don't undestand. Can you explain?
__________________
kramesa is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-25-2012 , 20:03   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #24

Sure. Read this about error reporting: http://php.net/manual/en/errorfunc.configuration.php

Example:
PHP Code:
<?php

error_reporting
(E_ALL); // report all errors and notices
ini_set('display_errors''2'); // print the reports to the screen (as opposed to a log file)

// the rest of the script
As for /tmp, on Linux systems this is the default directory where temporary data is stored. The script I posted caches the queries, so it won't have to query your game servers every time the page is requested (so the page loads faster and it uses less resources). To find out where your system writes temporary data to, try this:
PHP Code:
<?php
echo sys_get_temp_dir();
?>
To test if you can write to /tmp, try this:
PHP Code:
<?php
$path 
'/tmp';
$file 'test.txt';
$handle fopen($path.'/'.$file'w') or die('can\'t write to '.$path);
fclose($handle);
?>
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-25-2012 , 20:12   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #25

Quote:
Originally Posted by 8088 View Post
Sure. Read this about error reporting: http://php.net/manual/en/errorfunc.configuration.php

Example:
PHP Code:
<?php

error_reporting
(E_ALL); // report all errors and notices
ini_set('display_errors''2'); // print the reports to the screen (as opposed to a log file)

// the rest of the script
As for /tmp, on Linux systems this is the default directory where temporary data is stored. The script I posted caches the queries, so it won't have to query your game servers every time the page is requested (so the page loads faster and it uses less resources). To find out where your system writes temporary data to, try this:
PHP Code:
<?php
echo sys_get_temp_dir();
?>
To test if you can write to /tmp, try this:
PHP Code:
<?php
$path 
'/tmp';
$file 'test.txt';
$handle fopen($path.'/'.$file'w') or die('can\'t write to '.$path);
fclose($handle);
?>
I have this:

Code:
Notice: fwrite() [function.fwrite]: send of 25 bytes failed with errno=1 Operation not permitted in /home/web/public_html/SourceQuery.class.php on line 400
My host is not allowed to run this?
__________________

Last edited by kramesa; 04-25-2012 at 20:13.
kramesa is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-25-2012 , 20:16   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #26

Looks like it.

https://www.google.com/search?q=Noti...+not+permitted ->
http://forums.interwavestudios.com/t...ror/#entry7398
http://forums.interwavestudios.com/t...ata/#entry5986
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-25-2012 , 20:30   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #27

My safe mod is off, I dont know what is happen.
__________________

Last edited by kramesa; 04-25-2012 at 20:34.
kramesa is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-25-2012 , 21:26   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #28

There are more ways than enabling safe_mode to disallow operations. Also, even if you are allowed to open and write to sockets it may still be blocked by a firewall (which is hard to tell in case of UDP - see the warning here). You'll have to contact your host.
__________________
steamID converter with OpenSearch browser plugin

Last edited by 8088; 04-25-2012 at 21:37.
8088 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-26-2012 , 14:04   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #29

Quote:
Originally Posted by 8088 View Post
There are more ways than enabling safe_mode to disallow operations. Also, even if you are allowed to open and write to sockets it may still be blocked by a firewall (which is hard to tell in case of UDP - see the warning here). You'll have to contact your host.
What's the port I need open?
__________________
kramesa is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-26-2012 , 16:17   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #30

As far as I know ports are randomly assigned when creating a socket (at least with fsockopen). Like I said, contact your host.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
Reply


Thread Tools
Display Modes

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 -4. The time now is 04:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode