• Announcements

    • xper

      MSFN Sponsorship and AdBlockers!   07/10/2016

      Dear members, MSFN is made available via subscriptions, donations and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, become a site sponsor and ads will be disabled automatically and by subscribing you get other sponsor benefits.
Sign in to follow this  
Followers 0
eXPerience-XP

IP Sig

151 posts in this topic

well the qoutes not wrapping to the next line

Heres the code i used im i doing something wrong?

<?php
header ("Content-type: image/png");
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');

$image = imagecreatefromgif("bg.gif");
$back_color = ImageColorAllocate ($image, 0, 5, 5);
$white = ImageColorAllocate($im, 255, 255, 255);
$ip = ( !empty($_SERVER['REMOTE_ADDR']) ) ? $_SERVER['REMOTE_ADDR'] : ( ( !empty($_ENV['REMOTE_ADDR']) ) ? $_ENV['REMOTE_ADDR'] : $REMOTE_ADDR );
$quotes = file('quotes.txt');
$quote = array_rand($quotes);
$joke = wordwrap($quotes[$quote], 40, "\n", 1);
$joke = explode("\n", $joke);


ImageString  ($image, 2, 12, 50, "You are $ip", $white);
ImageString ($image, 2, 12, 70,  "Your Running:", $white);
ImageString  ($image, 2, 12, 90, "$HTTP_USER_AGENT", $white);
for($i=0; $i<count($joke); $i++) {
ImageString  ($image, 2, 12, 110,  $joke[$i], $white);}
Imagepng($image);
imagedestroy($image);
?>

Looks fine to me! :)

0

Share this post


Link to post
Share on other sites

howdy again...

I have a question.. since we stopped using the imagettftext for text, and went on to imagestring.. maybe the option is available.. how do I center a text string? thanks :)

0

Share this post


Link to post
Share on other sites
I've tried including the OS and browser but it has never come out properly for me... I'll post it in here as soon as I find out...

Well since this site was invaluable to me in figuring out how that signature image worked, here you go for OS and browser detection. This isn't my code but snips I located on the web in several places so I don't know who the original author is. It might not be perfect, but it's a really good start.

Code removed due to a bug,  new code with bugcatcher is a few post down

0

Share this post


Link to post
Share on other sites

Flynn: your IP sig says... "Your ISP is: www.85.31" needless to say... that's wrong. just thought you should know.

0

Share this post


Link to post
Share on other sites
Flynn: your IP sig says... "Your ISP is: www.85.31" needless to say... that's wrong. just thought you should know.

I guess then your IP isn't resolving and it's just ripping the last part of your IP

0

Share this post


Link to post
Share on other sites

Ok here is the code with a bug catcher to catch non-resolved IPs as un4given1 pointed out.

$ip = The IP

$isp = The domain you need to prefix it with "www."

$endos = The OS

// get IP and resolve IP
$ip = $REMOTE_ADDR;
$resolved = gethostbyaddr ($REMOTE_ADDR);



// 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";
}
}

0

Share this post


Link to post
Share on other sites

Thanks Flynn! Very useful! :rolleyes:

And welcome to MSFN! :)

0

Share this post


Link to post
Share on other sites

**** i wish you had postted sonner i had to find out how to do it by asking the creator of the dansoft script

test.png

One question tho is there any way to make it say windows me?

CAuse i use winme and it says im using windows 98

0

Share this post


Link to post
Share on other sites
One question tho is there any way to make it say windows me?

You know someone else pointed that out to me today :) I have no idea why the author of the code left out Me but it should be a simple fix

Add these two like line one each just under the 98 entries the resemble

Just under "Win98|Windows 98", insert this

"WinME|Windows ME",

Just under "Windows 98|Windows 98", insert this

"Windows ME|Windows ME",

Report back if this works as I have never had a ME machine and the other person had yet to report back if the patch worked.

0

Share this post


Link to post
Share on other sites

what's wrong with this code? it just gives me the red x image box.

<?php
header ("Content-type: image/png");
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');

define("OFFSET", 0);

define("YSECS", 365*24*60*60);
define("DSECS", 24*60*60);
define("HSECS", 60*60);
define("MSECS", 60);

function countdown($detail, $year, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0) {
$years = $days = $hours = $minutes = $seconds = 0;
$now = mktime() + OFFSET*60*60;
$then = mktime($hour, $minute, $second, $month, $day, $year);
$cdown = abs($then - $now);

if ($detail == 1) $years = round($cdown/YSECS);
else $years = floor($cdown/YSECS);
$cdown %= YSECS;
if ($detail == 2) $days = round($cdown/DSECS);
else $days = floor($cdown/DSECS);
$cdown %= DSECS;
if ($detail == 3) $hours = round($cdown/HSECS);
else $hours = floor($cdown/HSECS);
$cdown %= HSECS;
if ($detail == 4) $minutes = round($cdown/MSECS);
else $minutes = floor($cdown/MSECS);
$cdown %= MSECS;
$seconds = $cdown;

$tnums = array($years, $days, $hours, $minutes, $seconds);
$ttext = array("year", "day", "hour", "minute", "second");

$shown = 0;

for ($i=0;$i<$detail;$i++) {
 if ($tnums[$i]) {
 echo "$tnums[$i] $ttext[$i]";
 $shown++;
 if ($tnums[$i] != 1) echo "s";
 $count = 0;
 for ($j=$i+1;$j<$detail;$j++) {
   if ($tnums[$j]) $count++;
 }
 switch($count) {
   case 0: break 2;
   case 1: if ($shown>1) echo ","; echo " and "; break;
   default: echo ", "; break;
 }
 }
}
if ($now > $then) echo " ago";
if ($now == $then) echo "now";
}
$tilxmas = countdown(2, 2003,12,25);

$image = imagecreatefromgif("xmas.gif");

$white = imagecolorallocate($image, 255, 255, 255);

$font = "candycane.ttf";

imagettftext ($image, 24, 0, 5, 5, $white, $font, $tilxmas);

imagepng($image);
imagedestroy($image);

?>

here's the image:

xmas.gif

Can't figure it out :-/

0

Share this post


Link to post
Share on other sites

Just found this on php.net under the imagecreatefromgif entry:

imagecreatefromgif() returns an empty string on failure. It also outputs an error message, which unfortunately displays as a broken link in a browser.
also:
dpetrov at nchcapital dot cm

26-Aug-1999 01:37

Support for PNG images was added to GD with the removal of GIF support. Latest patches for PHP 3.0 add new functions, in particular ImageCreateFromPng() and ImagePng(). At the time of writing, for some odd reason, PHP 4.0 does NOT have these functions.

  • check the PHP version on the server the script is running from.
  • check there for a function to output an error message in case the imagecreate functions bails out with an error.
  • Can you read a GIF to output a PNG? I've only done reading from the same type as the output (read GIF->Output GIF, read JPG -> Output JPG, and so on)

0

Share this post


Link to post
Share on other sites
Report back if this works as I have never had a ME machine and the other person had yet to report back if the patch worked.

nope it didnt work it still says windows 98

But if anybody is interested heres how to show the browser name

Use $browser to call it

   //browser type	
   $agent = $HTTP_USER_AGENT;
   if ( strstr($agent, "MSIE 5") ) $browser = "using IE 5";
   elseif ( strstr($agent, "MSIE 6") ) $browser = "using IE 6";
   elseif ( strstr($agent, "MSIE 4") ) $browser = "using IE 4";
   elseif ( strstr($agent, "Firebird") ) $browser = "using Firebird";
   elseif ( strstr($agent, "Safari") ) $browser = "using Safari";
   elseif ( strstr($agent, "Mozilla/5") ) $browser = "using Mozilla/Netscape 5";
   elseif ( strstr($agent, "Mozilla/6") ) $browser = "using Netscape 6";
   elseif ( strstr($agent, "Mozilla/4") ) $browser = "using Netscape 4";
   elseif ( strstr($agent, "Opera") ) $browser = "using Opera";
   else $browser = "";

0

Share this post


Link to post
Share on other sites

Sweet! Now we can make our own IP sigs! :rolleyes:

Now to find out how to rotate backgrounds... :)

0

Share this post


Link to post
Share on other sites
Now to find out how to rotate backgrounds... :rolleyes:

This snippent of code will rotate (random) backgrounds :)

Of course you need to change it around a bit to match your script (image type and names) maybe, notice the first variable in the array is left blank "", I did this just to make the image numbers match the array number without using 0 as an image number.

You also need to change your "createfrom" line to include the new random variable.

The only problem with this is that the browser doesn't refresh all the time because the linked image name remains the same, depending on your browser settings of course.

// random background

$random_image = array("",
                   "bg1.png",
                   "bg2.png",
                   "bg3.png",
                   "bg4.png");

srand ((double) microtime() * 1000000);
$rnd = rand(1,4);

// create the image
$image = imagecreatefrompng($random_image[$rnd]);

0

Share this post


Link to post
Share on other sites

Ok, well I'm trying to follow all of this. I have a file called .htaccess and it looks like this

<Files ipaddress.jpg>
ForceType application/x-httpd-php
</Files>

I also have a file called ipaddress.jpg that looks like this:

<?php
Header ('Content-type: image/png');
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');

// create the image
$image = imagecreatefrompng("bg.png");

// 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, 206, 129, 18);
$blue = imagecolorallocate($image, 0, 0, 255);

// set the font and print text
$font = 'Arial.ttf'

ImageTTFText ($image, 8, 0, 10, 17, $white, $font, "Your IP Address is... ".$REMOTE_ADDR);

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

?>

When I open the jpg through a php enabled browser, it just gives me the code back for ipaddress. No image just code. The bg.png is also in that folder. :)

BTW: I am using a Windows Apache server with php, and in my php info I can't find anything with "GD" in it, I searched.

0

Share this post


Link to post
Share on other sites

you need to replace the png things since your going to use a jpg file so try this:

<?php
Header ('Content-type: image/jpg');
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');

// create the image
$image = imagecreatefrompng("bg.png");

// 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, 206, 129, 18);
$blue = imagecolorallocate($image, 0, 0, 255);

// set the font and print text
$font = 'Arial.ttf'

ImageTTFText ($image, 8, 0, 10, 17, $white, $font, "Your IP Address is... ".$REMOTE_ADDR);

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

?>

This should work. Report back if it doesnt

0

Share this post


Link to post
Share on other sites

Anyone know how to center text on a PHP sig?

0

Share this post


Link to post
Share on other sites

Anyone know how to stream a movie file into a sig? :) It should be possible. Just tell the player application to output the move to a 30 frame animated gif every second. Whoosh, 100 kb streaming gif movie player. I have no idea what I'm talking about.

0

Share this post


Link to post
Share on other sites

I dont think thats possible using this script

Its easier just to make a gif out of the clip using an animator :)

0

Share this post


Link to post
Share on other sites

I think to achive this you would need to create a script that would automatically create the SIG from the new image output. This could be done by simply deleting the old one and renaming the new one the same as the old, but to create the stream, i donno.

0

Share this post


Link to post
Share on other sites

It would be pretty cool to have entire movies playing in your sig, movies that normally couldn't be turned into a regular gif.

0

Share this post


Link to post
Share on other sites

Hrmm, it doesn't seem to be working. The sig just displays me code of php, so I don't think that the .htaccess is working. The weird thing is, it doesn't look like it's in the directory, but If i type it in from command line it works. Do I have to tell my http.conf to look for .htaccess ?

0

Share this post


Link to post
Share on other sites
Hrmm, it doesn't seem to be working. The sig just displays me code of php, so I don't think that the .htaccess is working. The weird thing is, it doesn't look like it's in the directory, but If i type it in from command line it works. Do I have to tell my http.conf to look for .htaccess ?

Yes... I think there's an option for it in the httpd.conf file... :)

0

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.