Sunday, May 22, 2011

My server Rack - update








My rack is nearly full now
From the top I have,
15" LCD screen
24port 10/100 level 2 switch dealing with the VLANs
16port 10/100/1000 level 1 switch 
1TB HDD 1.66 GHz Dual core custom NAS FTP/HTTP/VPN running windows server 2003
P4 1.6 GHz 1GB ram Pfsense Firewall router (not in use)
Wireless N AP and ADSL2+ modem
CD2 2.4 GHz 3GB RAM dual TV cards (turns itself on and records TV when needed)
CISCO 3640 Dual 10/100 NICs with serial (only used when I am testing stuff)
APC SMART 1000VA UPS and Compaq 2000VA UPS

Wednesday, February 2, 2011

Cleaning!

A few days of cleaning

This is about one days worth of cleaning plus 4 cubic meters of rubbish been taken away, as you can see i have started to move stuff in, starting with my 19" server rack, i will be adding side panels to is shortly to keep out dust.

Sunday, January 30, 2011

Moving!!!


Over the next few weeks I will be moving into my new place, I have lots to do as to be seen in the following pictures, this means I am unable to finish my write-up on the PC controlled relay light as of this time, sorry. 


The workshop

The workshop
 
As the house was pretty much a deceased estate there is a lot of mess to clean up.
1.300AMP arc welder
2.Metal lathe
3.Band saw
There is also a lot more I was unable to take pictures of as the room was in too much of a mess more images on their way tomorrow.

This was an interesting find, a Vietnam war night vision scope that seems to be in complete, all but one part.
Dat view

Monday, January 17, 2011

First post of the year.

Happy new year everyone.
This year i will be posting lots more stuff here on my blog.

The first thing i will be is an update on my PC controlled relay light i did back in 2008.
This is the video i did all the way back then, as you can see its not very informative, i hope to fix that now with a detailed writeup/howto and a new video.

Sunday, October 24, 2010

My Current Computer Quad Screen







AMD 955 clocked @ 4.0Ghz
6GB DDR3 1600Mhz
Dual 4890's + GT220
22", 22", 19" and 17" Monitors
 

Thursday, October 14, 2010

Source engine query with php part2

include 'query.php';
$Server = 'SERVERSIP+PORT';
if(isset($_GET['server'])){
 $Server = $_GET['server'];
}
//-----------------------------------------------------------------
//Query + Server data Out + filtering
$q = source_query($Server);
$Sv = explode(':', $Server);
$SvIp = $Sv[0];
$SvPo = $Sv[1];
$q['appid'] = str_replace(160, 'Garrysmod', $q['appid']);
$q['appid'] = str_replace(184, 'Team_Fortress_2', $q['appid']);
$q['appid'] = str_replace(240, 'Counter-Strike:_Source', $q['appid']);
$map = substr($q['map'],0,14);
print_r($q);
//------------------------------------------------------------------
// Template Image

$im = imagecreatefrompng ("banner.png");

//------------------------------------------------------------------
//Check to see if i have a pic of the map
$mappic = "maps/".$q['map'].".png";
$nomap = "none.png";
if (file_exists($mappic)) {
    echo "GOOD I HAVE A PIC OF THE MAP!   ";
 $insert = imagecreatefrompng($mappic); 
 
} else {
    echo "SAD FACE I DON'T HAVE PIC OF MAP   ";
 $insert = imagecreatefrompng($nomap);
}
print_r($mappic);
$insert_x = imagesx($insert); 
$insert_y = imagesy($insert);
//-----------------------------------------------------------------
//PICK SOME COLOURS!!!!! IN RGB PLEASE
$colour = imagecolorallocate($im, 255, 255, 255);
$red = imagecolorallocate($im, 255, 0, 0);
$green = imagecolorallocate($im, 34, 139, 34);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
//------------------------------------------------------------------
//FONTS!!!! ADD MORE IF YOU WANT
$font = 'pirulen.ttf';

//------------------------------------------------------------------
//SEE IF SERVER IS ONLINE????

if ($q['name'] != ''){
 
 $name = substr($q['name'],0,26);
 $namecolour = $green;
 
}
else 
{
 $name = "OFFLINE";
 $namecolour = $red;
}
//--------------------------------------------------------------------
//OUTPUT FILTERED SERVER DATA TO PIC
$maxplayers = $q['max'];
$player = $q['players'];
$ip = $SvIp;
$map = $map;
$port = $SvPo;
$players = $player."/".$maxplayers;
// PUT TEXT ON IMAGE (SIZE,ROTATE,X,Y,COLOUR,FONT,DATA)
imagettftext($im, 10, 0, 120, 32, $namecolour, $font, $name);
imagettftext($im, 10, 0, 120, 60, $colour, $font, $ip);
imagettftext($im, 10, 0, 120, 86, $colour, $font, $map);
imagettftext($im, 10, 0, 295, 60, $colour, $font, $port);
imagettftext($im, 10, 0, 350, 86, $colour, $font, $players);

//make the pic + put map pic ontop
imagecopymerge($im,$insert,455,20,0,0,$insert_x,$insert_y,100); 
imagepng($im,'serverbanner.png');
imagedestroy($im);
This php code will create a image file much like game trackers output.
This is the input file.

 This is the output of the file, if i had i pic of the map it would display in the map box.

Source engine query with php

?php
function source_query($ip)
{
    //set timeout in ms
    $timeout = "1";
    $cut = explode(":", $ip);
    $HL2_address = $cut[0];
    $HL2_port = $cut[1];

    $HL2_command = "\377\377\377\377TSource Engine Query\0";

    $HL2_socket = fsockopen("udp://" . $HL2_address, $HL2_port, $errno, $errstr, 3);
    fwrite($HL2_socket, $HL2_command);
 socket_set_timeout($HL2_socket,$timeout);
    $JunkHead = fread($HL2_socket, 4);
    $CheckStatus = socket_get_status($HL2_socket);
 //print_r($CheckStatus);
 
    if ($CheckStatus["unread_bytes"] == 0)
        return 0;
 if ($CheckStatus['timed_out'] == 1) {
  return 0;
 }
    $do = 1;
    while ($do) {
        $str = fread($HL2_socket, 1);
        $HL2_stats .= $str;
        $status = socket_get_status($HL2_socket);
        if ($status["unread_bytes"] == 0) {
            $do = 0;
        }
    }
    fclose($HL2_socket);

    $x = 0;
    while ($x <= strlen($HL2_stats)) {
        $x++;
        $result .= substr($HL2_stats, $x, 1);
    }

    // ord ( string $string );
    $result = str_split($result);
    $info['network'] = ord($result[0]);
    $char = 1;
    while (ord($result[$char]) != "") {
        $info['name'] .= $result[$char];
        $char++;
    }
    $char++;
    while (ord($result[$char]) != "") {
        $info['map'] .= $result[$char];
        $char++;
    }
    $char++;
    while (ord($result[$char]) != "") {
        $info['dir'] .= $result[$char];
        $char++;
    }
    $char++;
    while (ord($result[$char]) != "") {
        $info['description'] .= $result[$char];
        $char++;
    }
    $char++;
    $info['appid'] = ord($result[$char] . $result[($char + 1)]);
    $char += 2;
    $info['players'] = ord($result[$char]);
    $char++;
    $info['max'] = ord($result[$char]);
    $char++;
    $info['bots'] = ord($result[$char]);
    $char++;
    $info['dedicated'] = ord($result[$char]);
    $char++;
    $info['os'] = chr(ord($result[$char]));
    $char++;
    $info['password'] = ord($result[$char]);
    $char++;
    $info['secure'] = ord($result[$char]);
    $char++;
    while (ord($result[$char]) != "") {
        $info['version'] .= $result[$char];
        $char++;
    }

    return $info;
}
?

This will allow you to query any source game server like CSS TF2 and GarrysMod for it's information like players, map, OS and many more from a webpage.