dynamic sig help

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
northwst
-


Joined: 12 Jan 2006
Posts: 29

PostPosted: Sun Mar 05, 2006 9:10 pm    Post subject: dynamic sig help Reply with quote

Can anyone tell me whats wrong here.

when using the $agent to get browser it is displaying alot of info too much I think. I have a log file under "log" folder called "access" that has the same info displayed when using $agent. Could it be pulling the info from here, or am I stupid.

Code:
<?php
Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

// set the dimensions
$img_width = 350;
$img_height = 140;

$image = imagecreatefromjpeg("http://northwst.servemp3.com/sigs/sig.jpg");

// set the colours
$cool  = imagecolorallocate($image, 81, 86, 96);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red   = imagecolorallocate($image, 255, 0, 0);
$grey  = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 58, 160, 2);
$blue  = imagecolorallocate($image, 0, 0, 255);
$orange = imagecolorallocate($image, 244, 197, 32);

// set the font and print text
$font = 'C:/WINDOWS/fonts/batmfa__.ttf';

$pagefile = "C:\pagefile.sys";

$uptime = (time() - filemtime($pagefile));
$updays = floor($uptime / (24*3600));
$uptime = $uptime - ($updays * (24*3600));
$uphours = floor($uptime / (3600));
$uptime = $uptime - ($uphours * (3600));
$upminutes = floor($uptime /(60));
$uptime = $uptime - ($upminutes * 60);
$upsecs = $uptime;



// counter - CHMOD your counter file to 777
$viewss = file("/views.txt");
$views = $viewss[0]; $views++;
$fp = fopen("/views.txt", "w");
fwrite($fp, $views);
fclose($fp);
$counter = "$views People Clicked This Link";

$agent = ($_SERVER['HTTP_USER_AGENT']); //this shows info one the browser


// get IP and resolve IP
$ip = $_SERVER['REMOTE_ADDR'];
$resolved = gethostbyaddr ($REMOTE_ADDR);

$text = "Your IP is: $ip!";
$text2 = "northwst.servemp3.com";
$text3 = "Browser: $agent"; // this is the text on the 2nd line


// check for non resolve of IP and rip domain if resolved
if ($resolved == $ip) {
$isp = ".. Can't Resolve IP";
}
else
{
$str = preg_split("/\./", $resolved);
$i = count($str);
$x = $i - 1;
$n = $i - 2;
$isp = $str[$n] . "." . $str[$x];
}

// Simple OS Detection
$os = $HTTP_USER_AGENT;
$oslist = Array (

// Windows
"Win|Windows",
"Win16|Windows",
"Win95|Windows 95",
"Win98|Windows 98",
"WinME|Windows ME",
"Win32|Windows",
"WinNT|Windows NT",
"Windows 3.1|Windows 3.1",
"Windows 95|Windows 95",
"Windows CE|Windows CE",
"Windows 98|Windows 98",
"Windows ME|Windows ME",
"Windows NT|Windows NT",
"Windows NT 5.0|Windows 2000",
"Windows NT 5.1|Windows XP",

// Macintosh
"Mac_68000|MacOS m68K",
"Mac_68K|MacOS m68K",
"Mac_PowerPC|MacOS PPC",
"Mac_PPC|MacOS PPC",
"Macintosh|MacOS",

// Unices
"X11|UNIX",
"BSD|BSD",
"SunOS|SunOS",
"IRIX|IRIX",
"HP-UX|HP-UX",
"AIX|AIX",
"QNX|QNX",
"SCO_SV|SCO UNIX",
"FreeBSD|FreeBSD",
"NetBSD|NetBSD",

// Linux
"Linux|Linux",
"Debian|Debian GNU/Linux",

// Other
"BeOS|BeOS",
"OS/2|OS/2",
"AmigaOS|AmigaOS",

);

foreach ($oslist as $osnow) {
$osnow = explode ("|", $osnow);
if (eregi ($osnow[0], $os)) {
$endos = $osnow[1];
$check = "No";
} elseif ($check != "No") {
$endos = "Unknown";
}
}
/*
to output the OS, use $endos
to output the IP, use $ip
to output the resolved IP, use $resolved
*/

ImageTTFText ($image, 7, 0, 110, 90, $orange, $font, $text);

ImageTTFTEXT ($image, 7, 0, 105, 100, $orange, $font, "Your OS Is: $endos");

ImageTTFTEXT ($image, 6, 0, 2, 137, $orange, $font, $text3);

ImageTTFTEXT ($image, 7, 0, 100, 123, $orange, $font, $text2);

ImageTTFTEXT ($image, 7, 0, 120, 110, $orange, $font, "Viewed $views Times");

ImageTTFTEXT ($image, 7, 0, 107, 80, $orange, $font, "Uptime: Days $updays  $uphours:$upminutes:$upsecs");


// output and destroy
imagepng($image);
imagedestroy($image);

?>


and yes I know I need to rewrite some of this it is not written very well
thank you for anyones input on this.
Back to top View user's profile Send private message Visit poster's website
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Mar 05, 2006 10:49 pm    Post subject: Reply with quote

$_SERVER['HTTP_USER_AGENT'] holds the value of the http_user_agent header sent by the browser, that's where it gets the information from. You will have to format it to how you want it.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Sun Mar 05, 2006 11:10 pm    Post subject: Reply with quote

Here is a little snippet you can add to your code to give the browser name.

Code:


$agent = $_SERVER['HTTP_USER_AGENT'];
$mo = explode(" ",$agent);
if(stristr($agent,"msie")){$agent = "Internet Exploder";}
else if(stristr($agent,"opera")){$agent = "Opera";}
else if(stristr($agent,"netscape")){$agent = "Netscape";}
else if(stristr($agent,"konqueror")){$agent = "Konqueror";}
else if(stristr($agent,"mozilla")){$agent = $mo[0];}
else{$agent = "Unknown";}

Back to top View user's profile Send private message Visit poster's website
northwst
-


Joined: 12 Jan 2006
Posts: 29

PostPosted: Mon Mar 06, 2006 1:45 am    Post subject: Reply with quote

thank you for the code and Help
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group