How I Made My Signature

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
A bunch of people have been asking me how I made my sig. Here is the PHP source of it:

Index.php:

PHP:
<?php

include('functionsVariables.inc.php');


############################################
## Set variables for the Winamp song file ##
############################################

   $song = $_GET['song'];
   $filename = 'winamp.txt'; 
   $maxchar = 50; 
   $mtime = filemtime($filename);
   $timestamp = time();
   $timeout = $timestamp - 480;

###################################################
## Check if a song hasn't been played in a while ##
###################################################

   if ($mtime < $timeout) {
      if (@implode('',@file($filename)) != "Winamp is currently turned off.") {
         $handle = fopen($filename, 'w');
         fwrite($handle, "Winamp is currently off.");
         fclose($handle);
      }
   }

############################################################################
## The Winamp info sender sends the song to:                              ##
##   nedren.com/signature/?hiddensongnameinurl=[B]Song Name Here[/B]      ##
## This script then records it in a file if that GET['value'] is present. ##
############################################################################

   if(isset($_GET['hiddensongnameinurl'])) { 

      $playsHandle = fopen('songPlays.txt', "r");
      $songPlays = fread($playsHandle, filesize('songPlays.txt'));
      fclose($playsHandle);

      $songPlays++;

      $playsHandle = fopen('songPlays.txt', "w");
      fwrite($playsHandle, $songPlays);
      @fclose($playsHande);

      if(is_writable($filename)) { 
         if(!$handle = fopen($filename, 'w')) { 
            echo '<b>Error:</b> Cannot write to file Winamp text file.'; 
            die();
         } 
         if(!fwrite($handle, stripslashes($song))) { 
            echo '<b>Error:</b> Cannot write to file Winamp text file.'; 
            die();
         } 
         fclose($handle); 
      }

#############################################
## Else if song is not being sent/recorded ##
#############################################
   } else {

########################################
## Get the number of total song plays ##
########################################

      $playsHandle = fopen('songPlays.txt', "r");
      $songPlays = fread($playsHandle, filesize('songPlays.txt'));
      fclose($playsHandle);

##############################################
## Load the server's uptime and load values ##
##############################################

   $loadHandle = fopen('load.txt', "r");
   $serverLoad = fread($loadHandle, filesize('load.txt'));
   if (!$serverLoad) {
      $serverLoad = '[Down]';
   } else {
      fclose($loadHandle);
   }
   
   $uptimeHandle = fopen('uptime.txt', "r");
   $serverUptime = fread($uptimeHandle, filesize('uptime.txt'));
   if (!$serverUptime) {
      $serverUptime = '[Down]';
   } else {
      fclose($uptimeHandle);
   }

 // Clean up the server's uptime. It's returned in a weird format, so yea.. :-/ 
   $serverUptime = str_replace(',', '-', $serverUptime);
   $serverUptime = str_replace('  ', ' ', $serverUptime);
   $serverUptime = str_replace('-', ' -', $serverUptime);
   // $serverUptime = str_replace('- ', '-', $serverUptime);

###########################
## Get whatpulse shiet.  ##
###########################

      $mystats = UserStats(119431); // Whatpulse function

########################
## Make actual image  ##
########################

      header("Content-type: image/gif");
      $image = imagecreatetruecolor(425, 150);
      $image2 = imagecreatefromgif('imahiddenbgimage.gif');
      imagecopy($image, $image2, 0, 0, 0, 0, 450, 150);

############################
## Make colors for image  ##
############################

      $red = imagecolorallocate($image, 231, 180, 180);
      $green = imagecolorallocate($image, 180, 220, 180);
      $white = imagecolorallocate($image, 255, 255, 255);

#############
## Borders ##
#############

imageline($image, 1, 1, 423, 1, $white);
imageline($image, 1, 148, 423, 148, $white);
imageline($image, 1, 1, 1, 149, $white);
imageline($image, 423, 1, 423, 148, $white);

##############################################
## Create somestrings to be placed on image ##
##############################################


      $font = 'lsans.ttf';
      $font2 = 'lsans.ttf';
      $font3 = '04B_03B_.TTF';

      $mouse = number_format($mystats['TotalMouseClicks']);
      $keys = number_format($mystats['TotalKeyCount']);
      $curSong = @implode('',@file($filename));

#############################
## x10Hosting related text ##
#############################

   imagettftext($image, 7, 0, 68, 46, $white, $font, "Server Load:");
   imagettftext($image, 7, 0, 126, 46, $white, $font2, $serverLoad);

   imagettftext($image, 7, 0, 165, 46, $white, $font, "Uptime:");
   imagettftext($image, 7, 0, 204, 46, $white, $font2, $serverUptime);

   $status = serviceStatus(80);
   if ($status == 'Online') { $color = $green; } else { $color = $red; }
   imagettftext($image, 7, 0, 10, 63, $white, $font, "HTTP Server:");
   imagettftext($image, 7, 0, 71, 63, $color, $font2, $status);

   $status = serviceStatus(3306);
   if ($status == 'Online') { $color = $green; } else { $color = $red; }
   imagettftext($image, 7, 0, 10, 78, $white, $font, "MySQL Server:");
   imagettftext($image, 7, 0, 75, 78, $color, $font2, $status);

   $status = serviceStatus(53);
   if ($status == 'Online') { $color = $green; } else { $color = $red; }
   imagettftext($image, 7, 0, 110, 63, $white, $font, "DNS Server:");
   imagettftext($image, 7, 0, 164, 63, $color, $font2, $status);

   $status = serviceStatus(110);
   if ($status == 'Online') { $color = $green; } else { $color = $red; }
   imagettftext($image, 7, 0, 110, 78, $white, $font, "POP3 Server:");
   imagettftext($image, 7, 0, 169, 78, $color, $font2, $status);

   $status = serviceStatus(22);
   if ($status == 'Online') { $color = $green; } else { $color = $red; }
   imagettftext($image, 7, 0, 204, 63, $white, $font, "SSH Server:");
   imagettftext($image, 7, 0, 257, 63, $color, $font2, $status);

   $status = serviceStatus(21);
   if ($status == 'Online') { $color = $green; } else { $color = $red; }
   imagettftext($image, 7, 0, 204, 78, $white, $font, "FTP Server:");
   imagettftext($image, 7, 0, 257, 78, $color, $font2, $status);

   imagettftext($image, 7, 0, 300, 43, $white, $font3, "<= 70.86.136.178");


###########################
## Personal related text ##
###########################

   imagettftext($image, 7, 0, 55, 103, $white, $font, "Username:");
   imagettftext($image, 7, 0, 108, 103, $white, $font2, "NedreN");

   imagettftext($image, 7, 0, 155, 103, $white, $font, "Country:");
   imagettftext($image, 7, 0, 197, 103, $white, $font2, "United States");


   imagettftext($image, 7, 0, 10, 120, $white, $font, "Key Strokes:");
   imagettftext($image, 7, 0, 68, 120, $white, $font2, $keys);

   imagettftext($image, 7, 0, 129, 120, $white, $font, "Mouse Clicks:");
   imagettftext($image, 7, 0, 195, 120, $white, $font2, $mouse);

   imagettftext($image, 7, 0, 10, 136, $white, $font, "Listening To:");
   imagettftext($image, 7, 0, 71, 136, $white, $font2, $curSong);

   // Random string array comes from included file.
   $randSayingKey = array_rand($randSayings);
   $arrow = '<=';
   $saying = $randSayings[$randSayingKey];
   imagettftext($image, 7, 45, 297, 85, $white, $font3, $arrow);

   if ($randSayingKey == '0') {
      imagettftext($image, 7, 0, 304, 64, $white, $font3, $saying);
   } else {
      imagettftext($image, 7, 0, 304, 79, $white, $font3, $saying);
   }

   imagettftext($image, 6, 90, 420, 145, $white, $font3, "http://NedreN.com");

##############
## PHP text ##
##############

   // PHP random array comes from included file.
   $randKey = array_rand($randFunctions);
   $phpFunction = $randFunctions[$randKey]['Name'];
   $phpDescription = $randFunctions[$randKey]['Description'];
   imagettftext($image, 6, 0, 302, 114, $white, $font, $phpFunction);
   imagettftext($image, 5, 0, 304, 122, $white, $font2, $phpDescription);

   $php = '<= I <3 PHP';
   imagettftext($image, 7, 90, 405, 85, $white, $font3, $php);

#############################
## Output image to browser ##
#############################

      imagegif($image);

########################################################################################
## Destroy image from memory. I don't want to fill up the server's ram, now do I? ;-) ##
########################################################################################

      imagedestroy($image);
      imagedestroy($image2);
   }
?>


[The second half is in the next post.]
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
FunctionsVariables.inc.php:

PHP:
<?php

function serviceStatus($port) {
   $handle = @fsockopen('70.86.136.178', $port, $errno, $errstr, 30);
   if (!$handle) {
      $string = 'Down';
   } else {
      $string = 'Online';
      @fclose($handle);
   }
   return $string;
}


function UserStats($userid) {
  $WhatPulseStats = array();
  $stat_types = array("UserID", "AccountName", "Country",
      "DateJoined", "Homepage", "LastPulse", 
      "Pulses", "TotalKeyCount", "TotalMouseClicks",
      "AvKeysPerPulse", "AvClicksPerPulse", 
      "AvKPS", "AvCPS", "Rank", "TeamID", 
      "TeamName", "TeamMembers", "TeamKeys", 
      "TeamClicks", "TeamDescription", 
      "TeamDateFormed", "RankInTeam", "GeneratedTime");
     $data = @implode("", file("http://whatpulse.org/api/users/".$userid.".xml"));
     $parser = xml_parser_create();
     xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
     xml_parse_into_struct($parser, $data, $values, $tags);
     xml_parser_free($parser);
     

     foreach ($tags as $key => $val) 
     	{
         if ($key == "UserStats") 
         	{
             $ranges = $val;
             for ($i = 0; $i < count($ranges); $i += 2) 
             {
    	$offset = $ranges[$i] + 1;
    	$len = $ranges[$i + 1] - $offset;
    	$statsarray = array_slice($values, $offset, $len);
    	foreach($statsarray as $key => $value)
  	{
      for($i = 0; $i < count($stat_types); $i++)
  	{
      	if($value['tag'] == $stat_types[$i]) 
  	{
        $type = $stat_types[$i];
        $WhatPulseStats[$type] = $value['value'];
  	}
  	} 
  	} 
  	} 
  	} else {
  	continue;
  	}
  	} 
  
  return $WhatPulseStats;
}


// I edited out the random function array and the random string arrays.

$randFunctions = array('Moo');
$randSayings = array('Moo');

?>

Well there ya go. I'm not going to explain it all, and it's kinda messy. A bunch of people asked how I made it, so there ya go. I figured I would just post the source in here.

Also, could you "rate" my sig? (1 through 10, whatever you people usually do in here.)


:sleep2:
 

Alejandro

Staff
Staff member
Community Support
Messages
9,436
Reaction score
1
Points
38
Great, I'm gonna try to understand this. Thanks! BTW, I give your sig a well deserved 10!! ;)
 

mattspec

Active Member
Messages
1,390
Reaction score
0
Points
36
thats phenom, is there a way to make a windows media player stat though?
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Not sure. I have a winamp plugin that sends the song to the URL every time you play a new song. I don't know abotu windows media player though.

"Can you show us the image?"

Find it. ;-)

I couldn't do everything with PHP though because of the transparacy and crap, which sucks, but whatever. :-/
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
I do have much to do in the "winter months". ;-) So yea.. I sit around a lot and work on PHP stuff.

I started in 2003 with PHP, and here I am nowww.
 

dharmil

New Member
Messages
1,656
Reaction score
0
Points
0
that slike 2 years so yeah
ofcoruse you are good

i also wanted to know how you posted php page in your sig
 
Last edited:

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
I should, get rid of that.... Hmm. I thought I just did nedren.com/signature/

I guess not. Haha, but it did work, didn't it? :p
 

Phil

Retired Staff
Messages
7,344
Reaction score
0
Points
36
Tis a very nice sig... I wonder how many people are going to be using somthing just like it in there sig. I bet quite alot in time soon to come.
 
M

minievan

Guest
Its amazing, Im really Jealous 11/10!! I cant find a blooming tutorial on google :'(

-Spams on AIM-

Pfft, Busy :(

Just Kidding <3
 

TarinC

New Member
Messages
698
Reaction score
0
Points
0
Phil said:
Tis a very nice sig... I wonder how many people are going to be using somthing just like it in there sig. I bet quite alot in time soon to come.

ya ur right.. people would use this.. but the problem is the source he gave us dont work :| other than that.. its amazing. 10/10
 
Last edited:

oscar.j4l

New Member
Messages
362
Reaction score
0
Points
0
it does work, but you need to configure it to work with your files, [i think], im working on doing it, but im lazy as hell right now
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Yea the file names need to be "altered", if not taken out. Also I have a cron script that updates "uptime.txt" and "load.txt" (I think those are the names..

Here it is:
PHP:
   $loadHandle = fopen('http://staff.x10hosting.com/jackmunchServerInfo.php?type=load', "r");
   stream_set_timeout($loadHandle, 1);
   $serverLoad = fread($loadHandle, '1000');
   if (!$serverLoad) {
      $serverLoad = '[Down]';
   } else {
      fclose($loadHandle);
   }
   
   $uptimeHandle = fopen('http://staff.x10hosting.com/jackmunchServerInfo.php?type=uptime', "r");
   stream_set_timeout($uptimeHandle, 1);
   $serverUptime = fread($uptimeHandle, '1000');
   if (!$serverUptime) {
      $serverUptime = '[Down]';
   } else {
      fclose($uptimeHandle);
   }

   $loadHandle = fopen('load.txt', "w");
   fwrite($loadHandle, $serverLoad);
   @fclose($loadHande);

   $uptimeHandle = fopen('uptime.txt', "w");
   fwrite($uptimeHandle, $serverUptime);
   @fclose($uptimeHande);

I have it run every minute. The reason being is that if I had the values loaded (Originally I had it like this) every time the image was loaded, it took a good few seconds with 10+ fopen/fsockopen calls.
 
Top