How I Made My Signature

Discussion in 'Graphics & Webdesign' started by Bryon, Jan 9, 2006.

  1. Bryon

    Bryon I Fix Things

    Messages:
    8,149
    Likes Received:
    101
    Trophy 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($playsHandlefilesize('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($handlestripslashes($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($playsHandlefilesize('songPlays.txt'));
          
    fclose($playsHandle);

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

       
    $loadHandle fopen('load.txt'"r");
       
    $serverLoad fread($loadHandlefilesize('load.txt'));
       if (!
    $serverLoad) {
          
    $serverLoad '[Down]';
       } else {
          
    fclose($loadHandle);
       }
       
       
    $uptimeHandle fopen('uptime.txt'"r");
       
    $serverUptime fread($uptimeHandlefilesize('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(425150);
          
    $image2 imagecreatefromgif('imahiddenbgimage.gif');
          
    imagecopy($image$image20000450150);

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

          
    $red imagecolorallocate($image231180180);
          
    $green imagecolorallocate($image180220180);
          
    $white imagecolorallocate($image255255255);

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

    imageline($image114231$white);
    imageline($image1148423148$white);
    imageline($image111149$white);
    imageline($image4231423148$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($image706846$white$font"Server Load:");
       
    imagettftext($image7012646$white$font2$serverLoad);

       
    imagettftext($image7016546$white$font"Uptime:");
       
    imagettftext($image7020446$white$font2$serverUptime);

       
    $status serviceStatus(80);
       if (
    $status == 'Online') { $color $green; } else { $color $red; }
       
    imagettftext($image701063$white$font"HTTP Server:");
       
    imagettftext($image707163$color$font2$status);

       
    $status serviceStatus(3306);
       if (
    $status == 'Online') { $color $green; } else { $color $red; }
       
    imagettftext($image701078$white$font"MySQL Server:");
       
    imagettftext($image707578$color$font2$status);

       
    $status serviceStatus(53);
       if (
    $status == 'Online') { $color $green; } else { $color $red; }
       
    imagettftext($image7011063$white$font"DNS Server:");
       
    imagettftext($image7016463$color$font2$status);

       
    $status serviceStatus(110);
       if (
    $status == 'Online') { $color $green; } else { $color $red; }
       
    imagettftext($image7011078$white$font"POP3 Server:");
       
    imagettftext($image7016978$color$font2$status);

       
    $status serviceStatus(22);
       if (
    $status == 'Online') { $color $green; } else { $color $red; }
       
    imagettftext($image7020463$white$font"SSH Server:");
       
    imagettftext($image7025763$color$font2$status);

       
    $status serviceStatus(21);
       if (
    $status == 'Online') { $color $green; } else { $color $red; }
       
    imagettftext($image7020478$white$font"FTP Server:");
       
    imagettftext($image7025778$color$font2$status);

       
    imagettftext($image7030043$white$font3"<= 70.86.136.178");


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

       
    imagettftext($image7055103$white$font"Username:");
       
    imagettftext($image70108103$white$font2"NedreN");

       
    imagettftext($image70155103$white$font"Country:");
       
    imagettftext($image70197103$white$font2"United States");


       
    imagettftext($image7010120$white$font"Key Strokes:");
       
    imagettftext($image7068120$white$font2$keys);

       
    imagettftext($image70129120$white$font"Mouse Clicks:");
       
    imagettftext($image70195120$white$font2$mouse);

       
    imagettftext($image7010136$white$font"Listening To:");
       
    imagettftext($image7071136$white$font2$curSong);

       
    // Random string array comes from included file.
       
    $randSayingKey array_rand($randSayings);
       
    $arrow '<=';
       
    $saying $randSayings[$randSayingKey];
       
    imagettftext($image74529785$white$font3$arrow);

       if (
    $randSayingKey == '0') {
          
    imagettftext($image7030464$white$font3$saying);
       } else {
          
    imagettftext($image7030479$white$font3$saying);
       }

       
    imagettftext($image690420145$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($image60302114$white$font$phpFunction);
       
    imagettftext($image50304122$white$font2$phpDescription);

       
    $php '<= I <3 PHP';
       
    imagettftext($image79040585$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: Jan 10, 2006
  2. Bryon

    Bryon I Fix Things

    Messages:
    8,149
    Likes Received:
    101
    Trophy Points:
    48
    FunctionsVariables.inc.php:

    PHP:

    <?php

    function serviceStatus($port) {
       
    $handle = @fsockopen('70.86.136.178'$port$errno$errstr30);
       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($parserXML_OPTION_CASE_FOLDING0);
         
    xml_parser_set_option($parserXML_OPTION_SKIP_WHITE1);
         
    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:
     
  3. Alejandro

    Alejandro Staff Staff Member Community Support

    Messages:
    9,438
    Likes Received:
    1
    Trophy Points:
    38
    Great, I'm gonna try to understand this. Thanks! BTW, I give your sig a well deserved 10!! ;)
     
  4. TarinC

    TarinC New Member

    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    0
    wow... thats amazing... 10
     
  5. Brandon

    Brandon Guest

    Can you show us the image?
     
  6. mattspec

    mattspec Active Member

    Messages:
    1,390
    Likes Received:
    0
    Trophy Points:
    36
    thats phenom, is there a way to make a windows media player stat though?
     
  7. Bryon

    Bryon I Fix Things

    Messages:
    8,149
    Likes Received:
    101
    Trophy 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. :-/
     
  8. SEÑOR

    SEÑOR The Guy Everyone Hates

    Messages:
    4,638
    Likes Received:
    0
    Trophy Points:
    0
  9. dharmil

    dharmil New Member

    Messages:
    1,656
    Likes Received:
    0
    Trophy Points:
    0
    NedreN you know 2 much

    how did you learn all this php
     
  10. Bryon

    Bryon I Fix Things

    Messages:
    8,149
    Likes Received:
    101
    Trophy 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.
     
  11. dharmil

    dharmil New Member

    Messages:
    1,656
    Likes Received:
    0
    Trophy 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: Jan 10, 2006
  12. Brandon

    Brandon Guest

  13. Bryon

    Bryon I Fix Things

    Messages:
    8,149
    Likes Received:
    101
    Trophy 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
     
  14. Phil

    Phil Retired Staff

    Messages:
    7,344
    Likes Received:
    0
    Trophy 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.
     
  15. moose

    moose New Member

    Messages:
    1,056
    Likes Received:
    0
    Trophy Points:
    0
    Very cool.. lol VERY COOL.
     
  16. minievan

    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
     
  17. TarinC

    TarinC New Member

    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    0
    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: Jan 16, 2006
  18. oscar.j4l

    oscar.j4l New Member

    Messages:
    362
    Likes Received:
    0
    Trophy 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
     
  19. Bryon

    Bryon I Fix Things

    Messages:
    8,149
    Likes Received:
    101
    Trophy 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($loadHandle1);
       
    $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($uptimeHandle1);
       
    $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.
     
  20. TarinC

    TarinC New Member

    Messages:
    698
    Likes Received:
    0
    Trophy Points:
    0

Share This Page