Trix -
Joined: 03 Apr 2003 Posts: 33
|
Posted: Sun Feb 08, 2004 4:17 pm Post subject: PHP GD Script HELP!!! |
|
|
i have a php gd sig. what it does is conntect to my CoolMon data and display it in a image, it also pulls a random quote from a mySQL database and displays that but it doest work for some reson :( it used to give an error 200 before but now it does nothing. this is the code.:
Code: |
<?php
include( 'soap/class.soap_client.php' );
function bytes2megs ( $bytes ) {
$megs = round( $bytes / ( 1024 * 1024 ) );
return $megs;
}
header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
header( 'Last-Modified: ' . gmdate( "D, d M Y H:i:s" ) . ' GMT' );
header( 'Cache-Control: no-store, no-cache, must-revalidate' );
header( 'Cache-Control: post-check=0, pre-check=0', false );
header( 'Pragma: no-cache' );
header( 'Content-type: image/png' );
$client = @new soapclient( 'http://home.p9r.com:61300/wsdl/ICoolMonWS', 'wsdl', 'ICoolMonWSPort' );
$im = ImageCreateTrueColor( 466, 132 );
ImageAlphaBlending( $im, true );
$other = ImageColorAllocate($im, 120,220,0);
$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 0,0,0);
$grey = ImageColorAllocate($im, 100,100,100);
$blue = ImageColorAllocate($im, 34,132,235);
ImageFill($im,0,0,$white);
$backim = ImageCreateFromPNG( "window.png" );
ImageCopy( $im, $backim, 0, 0, 0, 0, 466, 132 );
ImageDestroy( $backim );
/*
ImageTTFText($im, 10, 0, 370, 40, $black, 'C:/windows/fonts/lucida~2.ttf', 'Webcam: ');
$camim = ImageCreateFromJPEG( "D:\Webpages\webcam\archive\camimage.jpg" );
ImageCopyResampled( $im, $camim, 368, 45, 0, 0, 68, 50, 320, 240 );
ImageDestroy( $camim );
*/
if( @$client->call('GetUptime', array(), 'urn:CoolMonIntf-ICoolMonWS' ) == -1 )
{
ImageTTFText($im, 12, 0, 30, 45, $black, 'C:/windows/fonts/lucida~2.ttf', 'Stat gatherer not running' );
ImageTTFText($im, 12, 0, 30, 65, $black, 'C:/windows/fonts/lucida~2.ttf', '(Probably playing a game)');
ImagePNG( $im );
ImageDestroy( $im );
exit;
}
$uptime = @$client->call( 'GetUptime', array(), 'urn:CoolMonIntf-ICoolMonWS' );
$RAMfree = @$client->call( 'GetRAM', array( 'SubItem' => 'siFree' ), 'urn:CoolMonIntf-ICoolMonWS' );
$RAMtotal = @$client->call( 'GetRAM', array( 'SubItem' => 'siTotal' ), 'urn:CoolMonIntf-ICoolMonWS' );
$RAMused = @$client->call( 'GetRAM', array( 'SubItem' => 'siUsed' ), 'urn:CoolMonIntf-ICoolMonWS' );
$NETup = @$client->call( 'GetNetWrite', array( 'Selection' => '1024' ), 'urn:CoolMonIntf-ICoolMonWS' );
$NETdown = @$client->call( 'GetNetRead', array( 'Selection' => '1024' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Cused = @$client->call( 'GetDriveSpace', array( 'Selection' => 'C', 'SubItem' => 'siFree' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Ctotal = @$client->call( 'GetDriveSpace', array( 'Selection' => 'C', 'SubItem' => 'siTotal' ), 'urn:CoolMonIntf-ICoolMonWS' );
/*
$Dused = @$client->call( 'GetDriveSpace', array( 'Selection' => 'D', 'SubItem' => 'siFree' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Dtotal = @$client->call( 'GetDriveSpace', array( 'Selection' => 'D', 'SubItem' => 'siTotal' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Eused = @$client->call( 'GetDriveSpace', array( 'Selection' => 'G', 'SubItem' => 'siFree' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Etotal = @$client->call( 'GetDriveSpace', array( 'Selection' => 'G', 'SubItem' => 'siTotal' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Hused = @$client->call( 'GetDriveSpace', array( 'Selection' => 'H', 'SubItem' => 'siFree' ), 'urn:CoolMonIntf-ICoolMonWS' );
$Htotal = @$client->call( 'GetDriveSpace', array( 'Selection' => 'H', 'SubItem' => 'siTotal' ), 'urn:CoolMonIntf-ICoolMonWS' );
*/
$RAMperc = round( ( $RAMfree / $RAMtotal )* 100 );
$RAMfree = bytes2megs( $RAMfree );
$RAMtotal = bytes2megs( $RAMtotal );
$RAMused = bytes2megs( $RAMused );
$days = floor( $uptime / 60 / 60 / 24 );
$hours = ( floor( ( $uptime / 60 / 60 ) % 24 ) >= 10 ) ? floor( ( $uptime / 60 / 60 ) % 24 ) : "0" . floor( ( $uptime / 60 / 60 ) % 24 );
$minutes = ( floor( ( $uptime / 60 ) % 60 ) >= 10 ) ? floor( ( $uptime / 60 ) % 60 ) : "0" . floor( ( $uptime / 60 ) % 60 );
$seconds = ( round( $uptime % 60 ) >= 10 ) ? floor( $uptime % 60 ) : "0" . floor( $uptime % 60 );
$time = $hours . ":" . $minutes . ":" . $seconds;
if ($days != 0) {
ImageTTFText($im, 10, 0, 31, 43, $black, 'C:/windows/fonts/lucida~1.ttf', 'Uptime: '.$days. ':'.$time );
} else {
ImageTTFText($im, 10, 0, 31, 43, $black, 'C:/windows/fonts/lucida~1.ttf', 'Uptime: '.$time);
}
ImageTTFText( $im, 10, 0, 157, 43, $black, 'C:/windows/fonts/lucida~1.ttf', 'Net: '.round( $NETup, 2 ).'KB/s Up '.round( $NETdown,2 ).'KB/s Down');
ImageTTFText( $im, 10, 0, 31, 60, $black, 'C:/windows/fonts/lucida~1.ttf', 'RAM Free: '.$RAMperc.'% HD Space: '.round( ( $Cused + $Dused + $Eused + $Hused ) / 1024, 2 ).' / '.round( ( $Ctotal + $Dtotal + $Etotal + $Htotal ) / 1024, 2 ).'GB' );
/*
$logoim = ImageCreateFromPNG( "D:\Webpages\\root\scripts\sig\logo.png" );
ImageCopy( $im, $logoim, 29, 64, 0, 00, 198, 35 );
ImageTTFText( $im, 10, 0, 240, 78, $grey, 'C:/windows/fonts/lucida~2.ttf', 'Current Version:' );
ImageTTFText( $im, 10, 0, 240, 91, $grey, 'C:/windows/fonts/lucida~2.ttf', 'Public Preview 2' );
ImageTTFText( $im, 10, 0, 239, 77, $blue, 'C:/windows/fonts/lucida~2.ttf', 'Current Version:' );
ImageTTFText( $im, 10, 0, 239, 90, $blue, 'C:/windows/fonts/lucida~2.ttf', 'Public Preview 2' );
*/
mysql_connect( 'localhost', '', '' ) or die( "Oh crud! MySQL died!!" );
mysql_select_db( 'sig' ) or die( 'WTF? Sig Data not found :D' );
$id = mysql_query( "SELECT m.msg AS sg FROM current c LEFT JOIN messages m ON c.msg = m.id WHERE m.approved = 1" );
$m = mysql_fetch_array( $id );
ImageTTFText( $im, 10, 0, 31, 80, $black, 'C:/windows/fonts/lucida~2.ttf', 'Current Message:' );
ImageTTFText( $im, 10, 0, 31, 95, $black, 'C:/windows/fonts/lucida~1.ttf', $m['sg'] );
ImagePNG( $im );
ImageDestroy( $im );
ImageColorDeallocate( $other );
ImageColorDeallocate( $white );
ImageColorDeallocate( $black );
ImageColorDeallocate( $blue );
ImageColorDeallocate( $grey );
unset( $client );
?> |
if anybody can help me with this i would be really gratefull!!!!!
you can download the source including the backgroud img nd the soap thing from here:
http://trix.ani-sphere.com/aprelium/sig.rar
Trix. |
|