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

Trash this one


Post New Thread Reply   
 
Thread Tools Display Modes
8088
Veteran Member
Join Date: Jan 2008
Old 04-28-2012 , 01:02   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #41

1777

Nice, riddles again instead of straight answers/questions. The http user (www-data for example) needs permission to write to the temporary directory. If it can't write to /tmp for whatever reason, just change /tmp in the script to a directory that the http user can write to (the script's current directory, or its parent if that's easier/safer). But as long as you don't let your host solve your UDP socket creation problem, the script will be of no use to you.
__________________
steamID converter with OpenSearch browser plugin

Last edited by 8088; 04-28-2012 at 01:03.
8088 is offline
matrixmark
Senior Member
Join Date: Jun 2010
Old 04-28-2012 , 15:56   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #42

Quote:
Originally Posted by rx1983 View Post
this my model server status:
http://www.csro.com.br/servidores/index.php
NIce is that a custom one you made? or a publicly available one?
matrixmark is offline
8088
Veteran Member
Join Date: Jan 2008
Old 04-28-2012 , 19:14   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #43

matrixmark, try this:
PHP Code:
<?php
require_once('JG_Cache.php');
require_once(
'SourceQuery.class.php');

$servers = array(
// add servers like this:
//'server_01' => array ('name' => 'My shitty server', 'ip' => 'abc.example.com', 'port' => '27015'),
//'server_02' => array ('name' => 'My crap server', 'ip' => '1.2.3.4', 'port' => '27015'),
  
'server_03' => array('name' => 'My awesome server''ip' => 'dks.servehalflife.com''port' => '27016')
);


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['status'] = $query->GetInfo();
      
$info['players'] = $query->GetPlayers();
    } catch (
SourceQueryException $e)
    {
      
$info $e->getMessage();
    }
    
$cache->set($server['name'], $info);
  }
  
?>
  <table style="width:500px;">
  <?php if (is_array($info)): ?>
    <caption style="color:#000;">
        <?php echo htmlspecialchars($info['status']['HostName']); ?><br>
        <?php echo $server['ip'] . ':' $server['port']; ?> | map: <?php echo htmlspecialchars($info['status']['Map']); ?> | players: <?php echo $info['status']['Players']; ?>/<?php echo $info['status']['MaxPlayers']; ?>
    </caption>
    <?php if (is_array($info['players'])): ?>
        <thead>
          <tr><th>player</th><th>score</th><th>play time</th></tr>
        </thead>
        <?php foreach ($info['players'] as $player): ?>
          <tr><td><?php echo htmlspecialchars($player['Name']); ?></td><td><?php echo $player['Frags']; ?></td><td><?php echo $player['TimeF']; ?></td></tr>
        <?php endforeach; ?>
    <?php endif; ?>
  <?php else: ?>
    <caption style="color:#ff0000;"><?php echo $server['ip']; ?>:<?php echo $server['port']; ?> (offline)</caption>
  <?php endif; ?>
</table>
  <?php
}
?>
__________________
steamID converter with OpenSearch browser plugin

Last edited by 8088; 04-28-2012 at 20:25.
8088 is offline
matrixmark
Senior Member
Join Date: Jun 2010
Old 04-30-2012 , 10:25   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #44

Quote:
Originally Posted by 8088 View Post
matrixmark, try this:
Dude ur awesome thanks seems to be working good.

for you
matrixmark is offline
jonnzus
Epic Member
Join Date: Oct 2010
Location: Finland
Old 04-30-2012 , 13:00   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #45

Any idea why it says it's offline?
http://user430.web.gamehost.ee/status.php

in php-file:

$servers = array(
// add servers like this:
'server_01' => array('name' => 'B-Elit public', 'ip' => '188.92.161.36', 'port' => '27010')//'
//'server_02' => array ('name' => 'My crap server', 'ip' => '1.2.3.4', 'port' => '27015'),
//'server_03' => array('name' => 'B-Elit public', 'ip' => '188.92.161.36', 'port' => '27010')
);
__________________
Quote:
367. Everyone's copyright will be broken. No exceptions.

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

Make your servers Steam-only.
__________________
steamID converter with OpenSearch browser plugin
8088 is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 04-30-2012 , 17:52   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #47

Quote:
Originally Posted by jonnzus View Post
Any idea why it says it's offline?
http://user430.web.gamehost.ee/status.php

in php-file:

$servers = array(
// add servers like this:
'server_01' => array('name' => 'B-Elit public', 'ip' => '188.92.161.36', 'port' => '27010')//'
//'server_02' => array ('name' => 'My crap server', 'ip' => '1.2.3.4', 'port' => '27015'),
//'server_03' => array('name' => 'B-Elit public', 'ip' => '188.92.161.36', 'port' => '27010')
);
I think your have the same problem with me.
__________________
kramesa is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-01-2012 , 09:06   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #48

Quote:
Originally Posted by kramesa View Post
I think your have the same problem with me.
His problem is non-steam.
__________________
xPaw is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-01-2012 , 10:53   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #49

Quote:
Originally Posted by xPaw View Post
His problem is non-steam.
My servers are non-steam now? Look in my signature, with HLSW.
__________________

Last edited by kramesa; 05-01-2012 at 10:58.
kramesa is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-01-2012 , 10:53   Re: Want an simple PHP script for website with div id="serverstatus"
Reply With Quote #50

Quote:
Originally Posted by kramesa View Post
My servers is non-steam now? Look in my signature, with HLSW.
I said HIS servers.
__________________
xPaw 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 01:18.


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