Jump to content

My Dynamic Sig!


Recommended Posts

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

jammin, if oyu have like an old like 486 box, youcould run a webserver off that, or run one off a folding box...

 

oh and markie, cheers, we started an in thing i guess, or, you started it :( i want in too /cry

474519[/snapback]

 

:lol: you started it really, you made the announcement that you have a dynamic sig. I just.. made one and put it there (and got a couple of PMs about it a long time ago :P )

 

True true, something which could be done when I move into a house next year. At the moment it would be impossible.

474520[/snapback]

 

You could run Apache and PHP on your own computer quite easily :P I would offer to let you use my little home server, but bandwidth is an issue for me, sorry!!

Share this post


Link to post
Share on other sites

Like this:

 

<?php
   $ftpit = 1;
   $server = "dslftp.dsl.pipex.com";
   $user = "xxx";
   $pass = "xxx";

   if (!$ftpit) {
       header("Content-type: image/gif");
   }


// get temperature info

 $fp = @fsockopen("localhost", "6666", $errno, $errstr, 1);
 if ($fp) {
   $temps = fread($fp, 1024);
 } else {
   echo "Not connected";
 }

 $temps = explode("\n", $temps);
 for ($i = 0; $i < count($temps); $i++) {
   $temps[$i] = explode(" : ", $temps[$i]);
 }

 $temps[0][0] = "CPU";
 $temps[0][1] .= " C";
 $temps[1][0] = "CPU";
 $temps[1][1] .= " C";
 $temps[2][0] = "Case";
 $temps[2][1] .= " C";
 $temps[3][0] = "CPU Fan";
 $temps[3][1] .= " RPM";
 $temps[4][0] = "";
 $temps[4][1] = "";
 $temps[5][0] = "";
 $temps[5][1] = "";
 $temps[6][0] = "Vcore";
 $temps[6][1] .= "v";
 $temps[6][1] = " ". substr($temps[6][1], 2, strlen($temps[6][1]));
 $temps[7][0] = "";
 $temps[7][1] = "";
 $temps[8][0] = "3.3v Rail";
 $temps[8][1] .= "v";
 $temps[9][0] = "5v Rail";
 $temps[9][1] .= "v";
 $temps[10][0] = "12v Rail";
 $temps[10][1] .= "v";
 $temps[11][0] = "";
 $temps[11][1] = "";
 $temps[12][0] = "";
 $temps[12][1] = "";



   $uptime = `/usr/local/bin/scriptuptime`;
   $uptime = explode("\n", $uptime);
   $os = `uname -mrs`;
   $os = str_replace("\n", "", $os);
   $ips = `ifconfig fxp0 | grep inet | grep -v inet6 | awk {'print $2'}`;
   $ips = str_replace("\n", " / ", $ips);
   $ips = substr($ips, 0, -3);
   //$fortune = `/usr/games/fortune zippy`;
   //$fortune = str_replace("\n", " ", $fortune);
   $thres = 78;
   $host = `hostname -s`;
   $host = str_replace("\n", "", $host);
   //$lastupdate = `date`;
   //$lastupdate = str_replace("\n", "", $lastupdate);

//    if (strlen($fortune) > $thres) {
//       $ihoffset += (floor(strlen($fortune) / $thres) * 15);
//    }

$backgroundpic = imagecreatefromjpeg("briefcase.jpg");
list($owidth, $oheight) = getimagesize("briefcase.jpg");
   $im = @imagecreatetruecolor(480, 85 + $ihoffset) or die ("Cannot Initialize new GD image stream");

   $background_color = imagecolorallocate($im, 0, 0, 255);
   .ext_color = imagecolorallocate($im, 255, 0, 0);
   $text_color = imagecolorallocate($im, 255, 255, 0);

   $red_color = imagecolorallocate($im, 255, 0, 0);
   $green_color = imagecolorallocate($im, 0, 255, 0);
   $bar_color = imagecolorallocate($im, 255, 255, 0);

   $fortunetext_color = imagecolorallocate($im, 0, 180, 0);

imagefill($im, 0, 0, $background_color);
imagecopyresampled($im, $backgroundpic, 340, -3, 0, 0, $owidth * 0.16, $oheight * 0.14, $owidth, $oheight);

   $line = 0;
   imagestring($im, 3, 0, $line, "Hostname", .ext_color); $line += 15;
   imagestring($im, 3, 0, $line, "OS", .ext_color); $line += 15;
   imagestring($im, 3, 0, $line, "Uptime", .ext_color); $line += 15;
   imagestring($im, 3, 0, $line, "Load Avg", .ext_color); $line += 15;
//    imagestring($im, 3, 0, $line, "Last Update", .ext_color);
   imagestring($im, 3, 0, $line, "Temps/volts", .ext_color);

   $line = 0;
   imagestring($im, 2, 90, $line, "$host | $ips", $text_color); $line += 15;
   imagestring($im, 2, 90, $line, "$os", $text_color); $line += 15;
   imagestring($im, 2, 90, $line, "$uptime[0] days, $uptime[1] hours, $uptime[2] mins & $uptime[3] secs", $text_color); $line += 15;
   imagestring($im, 2, 90, $line, "1 min: $uptime[5], 5 min: $uptime[6], 15 min: $uptime[7]", $text_color); $line += 15;
//    imagestring($im, 2, 90, $line, $lastupdate, $text_color);
   imagestring($im, 2, 90, $line, "CPU: ". $temps[1][1] .", Case: ". $temps[2][1] .", VCore:". $temps[6][1], $text_color);

$cpu = substr($temps[1][1], 0, -2);
$case = substr($temps[2][1], 0, -2);
$core = substr($temps[6][1], 0, -1);

$y = 77;

//

if ($cpu < 50) {
$color = $green_color;
} else {
$color = $red_color;
}

$lstart = 0;
$lend = 70;
$end = 90 + ((($cpu - $lstart) / ($lend - $lstart)) * 65);
imagefilledrectangle($im, 90, $y - 2, $end, $y + 2, $color);

imageline($im, $end, $y - 2, $end, $y + 2, $bar_color);
imageline($im, 90, $y - 2, 90, $y + 2, $bar_color);
imageline($im, 155, $y - 2, 155, $y + 2, $bar_color);

//

if ($case < 30) {
$color = $green_color;
} else {
$color = $red_color;
}


$lstart = 0;
$lend = 70;
$end = 167 + (( ($case - $lstart) / ($lend - $lstart)) * 65);
imagefilledrectangle($im, 167, $y - 2, $end, $y + 2, $color);

imageline($im, $end, $y - 2, $end, $y + 2, $bar_color);
imageline($im, 167, $y - 2, 167, $y + 2, $bar_color);
imageline($im, 232, $y - 2, 232, $y + 2, $bar_color);

//imagestring($im, 1, 169, $y - 4, $lstart."C", $text_color);
//imagestring($im, 1, 216, $y - 4, $lend."C", $text_color);

//

if ($core > 1.83) {
$color = $green_color;
} else {
$color = $red_color;
}

$lstart = 1.79;
$lend = 1.86;
$end = 253 + ( ( ($core - $lstart) / ($lend - $lstart) ) * 65);
imagefilledrectangle($im, 253, $y - 2, $end, $y + 2, $color);

imageline($im, $end, $y - 2, $end, $y + 2, $bar_color);
imageline($im, 253, $y - 2, 253, $y + 2, $bar_color);
imageline($im, 318, $y - 2, 318, $y + 2, $bar_color);

//imagestring($im, 1, 245, 76, $lstart."v", $text_color);
//imagestring($im, 1, 313, 76, $lend."v", $text_color);

   $line += 10;

/*
   if (strlen($fortune) > $thres) {
       do {
           $cnt = 0;
           $line += 15;
           $tmp = substr($fortune, $cnt, $cnt + $thres);
           imagestring($im, 2, 0, $line, $tmp, $fortunetext_color);
           $fortune = substr($fortune, $cnt + $thres, strlen($fortune));
           $cnt += $thres;
       } while (strlen($fortune) != 0);
   } else {
       $line += 15;
       imagestring($im, 2, 0, $line, $fortune, $fortunetext_color);
   }
*/


   if ($ftpit) {
       imagecolortransparent($im, $background_color);
       imagegif($im, "sig.gif");
   } else {
//imagecolortransparent($im, $background_color);
       imagegif($im);
   }

   imagedestroy($im);

   if ($ftpit) {
       $id = ftp_connect($server);
       if (!$id) {
          echo "Connection failed to $server.";
          exit;
       }

       $login = ftp_login($id, $user, $pass);
       if (!$login) {
          echo "Login to $server with user $user failed.";
          ftp_close($id);
          exit;
       }

       ftp_pasv($id, TRUE);
       $upload = ftp_put($id, "sig.gif", "sig.gif", FTP_BINARY);
       if (!$upload) {
          echo "Upload of \"sig.gif\" to $server as user $user failed.";
       }

       ftp_close($id);
   }
?>

Share this post


Link to post
Share on other sites

lol. Well, if anyone wants to hack up that code to suit their needs (it probably won't work with Linux, definately not Windows, without hacking it up anyways).. feel free :rolleyes:

 

I was gonna have the temperatures displayed on a dynamic thermometer image I made like...

 

http://bone.servebeer.com/pages/status/dra...31.7&endtemp=70

 

The images were kinda too big though, so I stuck to text and merged an image of the actual computer at the side ( my briefcase pooter server thing in the cupboard! :D )

Share this post


Link to post
Share on other sites

lol I like making fun little things like that. Computer stuff keeps me plenty occupied :P I enjoy programming, well, until next year at uni when I am doing advanced internet tech (java..... website redundant programming stuff), intro to graphics (opengl 2d game) followed by graphics II (opengl 3d something or other).

 

I'm going to die. Many times. "I enjoy programming" I think I may say that as much as possible, while i still can!

Share this post


Link to post
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...