It is currently Thu May 23, 2013 1:56 pm

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Signature Shuffle Script
PostPosted: Sat Sep 20, 2008 4:05 pm 
Offline
Prince of the Shokan
Prince of the Shokan
Group: Henchman
User avatar

Joined: Sun Jun 15, 2008 1:34 am
Posts: 958
Location: Umea, Sweden
I was asked for my little magic script that I use to shuffle my signature, so here it is;
Code:
<?php
$files[0] = "http://i49.photobucket.com/albums/f271/Indomitus_Pics/GH_Forum/Mushroom_sign.gif";
$files[1] = "http://i49.photobucket.com/albums/f271/Indomitus_Pics/GH_Forum/SOTW9-edited.png";
$files[2] = "http://i49.photobucket.com/albums/f271/Indomitus_Pics/GH_Forum/Syndicate_Sign_v3.gif";
$files[3] = "http://i49.photobucket.com/albums/f271/Indomitus_Pics/GH_Forum/AGDI_QFG2_banner3.jpg";
$files[4] = "http://i49.photobucket.com/albums/f271/Indomitus_Pics/GH_Forum/Supreme_Commander_Sign.png";

$random=rand(0,count($files)-1);

readfile("$files[$random]");
?>

Is not that complicated, just copy code and replace the images link with your own.
If you wanna add more images just enter a new array object; $files[next number] = "image link";.
Then save the file as for example; "getImage.php", and upload it to a server. Make sure that server has PHP support. (thou I believe most do these days.)
Then just point your signature address to that .php file and you're done.

I don't have any free server tips, last one I used was geocities.com and that was years ago.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Sat Sep 20, 2008 8:18 pm 
Offline
I can't grant your wishes.
I can't grant your wishes.
Group: Hero
Group: Moderator
User avatar

Joined: Tue May 27, 2008 12:44 am
Posts: 2839
Location: ~Deterioration of public morals, two half-naked in winter~
I've always wanted to do this, but I never found any sort of code for it. Just a bunch of websites that you have to sign up for that'll say they'll shuffle your images for you.

Thanks!

_________________
Image
http://www.youtube.com/user/Sollah


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Sat Sep 20, 2008 8:50 pm 
Offline
Hands Off The Panda!
Hands Off The Panda!
Group: Administrator
Group: Hero
Group: TGH Staff
User avatar

Joined: Tue May 27, 2008 7:48 am
Posts: 5095
Location: Dublin, Ireland
thank you, soo much..
now I can whore out all my sigs!

_________________
Image
ლ(ಠ益ಠლ) #thegameheroes IRC, Now with girls!! <3


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Mon Apr 20, 2009 4:45 am 
Offline
B-E-N-D-E-R Beeeender
B-E-N-D-E-R Beeeender
Group: Hero
Group: BETA
User avatar

Joined: Tue May 27, 2008 12:17 am
Posts: 3015
Location: Oregon, USA
You gave me an idea: sig (and avatar) rotation based on time of day (at the server the scripts are hosted)

Here's the first file needed, the reason why they're seperate files will become apparent in a moment:
It's quite large:
Spoiler
Code:
<?php
        /*
   * imagescript.php
   *
        * All code is owned by Adam Naser, unless stated otherwise.
        * This is offered with no warranty and at no charge
        * under the GNU GPL3 license (http://www.gnu.org/copyleft/gpl.html).
        *
        * Copyright © 2008 Adam Naser
        */
   function getthanksday()
   {
      // Following section of code by Angela Bradley
      // http://php.about.com/od/finishedphp1/qt/thanksgiving.htm

      //This gets today's date
      $date =time () ;

      //This makes the current year a variable
      $year = date('Y', $date) ;

      //Here we generate the first day of November
      $first_day = mktime(0,0,0,11, 1, $year) ;

      //We determine what day of the week the first falls on
      $day_of_week = date('D', $first_day) ;

      //Based upon this, we add the appropriate number of days to get to the forth Thursday of the month

      switch($day_of_week)
      {
         case "Sun": $add = 25;
                break;
         case "Mon": $add = 24;
                break;
         case "Tue": $add = 23;
                break;
         case "Wed": $add = 22;
                break;
         case "Thu": $add = 21;
                break;
         case "Fri": $add = 27;
                break;
         case "Sat": $add = 26;
                break;
      }

      $Thanks = 1 + $add;

      return $Thanks;
   }

   function getfreecomicbookday($year)
   {
      // First Saturday in May.
      $firstday = mktime(0, 0, 0, 5, 1, $year);
      $dayofweek = date('D', $firstday);

      switch($dayofweek)
      {
                        case "Sun": $day = 7;
                                    break;
                        case "Mon": $day = 6;
                                    break;
                        case "Tue": $day = 5;
                                    break;
                        case "Wed": $day = 4;
                                    break;
                        case "Thu": $day = 3;
                                    break;
                        case "Fri": $day = 2;
                                    break;
                        case "Sat": $day = 1;
                                    break;
                }

      return $day;
   }   

   function isfullmoon($month, $day, $year)
   {
      // Based on an algorithm located here http://www.voidware.com/moon_phase.htm
      if ($month < 3)
      {
         $year = $year - 1;
         $month = $month + 12;
      }

      $month = $month + 1;
      $cen = 365.25 * $year;
      $eon = 30.6 * $month;
      $days = $cen + $eon + $day - 694039.09;
      $days = days / 29.53;
      $value = floor($days);
      $days = $days - $value;
      $value = ($days * 8) + 0.5;

      if ($value > 7)
         $value = $value - 8;

      if ($value == 4)
         return true;

      else
         return false;
   }

   function getindex()
   {
      $month = date(n);   // Current month
      $day = date(j);      // Current Day of the month
      $year = date(Y);   // Current year
      $hour = date(G);   // Current hour

      // FILL THESE VALUES IN FOR YOUR BIRTHDAY (month is 1-12, day is 1-31, year is four digits)
      $bmonth = 7;      // Month of your birthday
      $bday = 16;      // Day of your birthday
      $byear = 1983;      // Year you were born (has no use currently)

      $tod = 0;      // Originally meant for time of day, has been appropriated to help with special days too

      // Special dates (will be the same image for the duration of these dates)
      // Add special dates with an else if statement after the else if thanksgiving statement block.
      // MAKE SURE YOU INCREMENT THE TOD VALUE! Otherwise, you're not allocating different signatures!
      // If you add another index, you need to adjust BOTH the avatar and signature init functions!
      if (($month == 12 && $day == 24) || ($month == 12 && $day == 25))
         $tod = 12;   // CHRISTMAS!

      else if (($month == 12 && $day == 31) || ($month == 1 && $day == 1))
         $tod = 13;   // NEW YEARS!

      else if ($month == $bmonth && $day == $bday)
         $tod = 14;   // MY BIRTHDAY!
               // It'd be very easy to make differnt sigs based on age here.

      else if ($month == 11 && $day == getthanksday())
         $tod = 15;   // THANKSGIVING!

      else if ($month == 5 && $day == getfreecomicbookday($year))
                        $tod = 17;      // FREE COMIC BOOK DAY!

      // Times of day
      else if($hour == 0)
         $tod = 0;   // Midnight

      else if ($hour == 12)
         $tod = 1;   // Noon

      else if ($hour == 6)
         $tod = 2;   // Dawn

      else if ($hour == 18)
         $tod = 3;   // Dusk

      else if ($hour == 19)
         $tod = 4;   // Early Evening

      else if ($hour > 0 && $hour < 4)
         $tod = 5;   // Early Morning

      else if (($hour > 3 && $hour < 6) || ($hour > 6 && $hour < 9))
         $tod = 6;   // Morning

      else if ($hour > 8 && $hour < 12)
         $tod = 7;   // Late Morning

      else if ($hour > 12 && $hour < 16)
         $tod = 8;   // Afternoon
   
      else if ($hour > 15 && $hour < 18)
         $tod = 9;   // Late Afternoon

      else if ($hour > 19 && $hour < 22)
         $tod = 10;   // Evening

      else if ($hour > 21)
         $tod = 11;   // Night

      if ($hour > 18 && $hour < 6 && isfullmoon($month, $day, $year) == true)
         $tod = 16;   // It's night and there's a full moon!

      return $tod;      // Return what will act as an index.
   }
?>


Save that off and name it as imagescript.php (if you change the name, you need to change it in all the files that use it as well)

The second file (the one you will add here as your signature) is this:

Spoiler
Code:
<?php
        /*
   * sig.php
   *
        * All code is owned by Adam Naser, unless stated otherwise.
        * This is offered with no warranty and at no charge
        * under the GNU GPL3 license (http://www.gnu.org/copyleft/gpl.html).
        *
        * Copyright © 2008 Adam Naser
        */
   include ("imagescript.php");

        $file[0] = "";   // Midnight
        $file[1] = "";   // Noon
        $file[2] = "";   // Dawn
        $file[3] = "";   // Dusk
        $file[4] = "";   // Early Evening
        $file[5] = "";   // Early Morning
        $file[6] = "";   // Morning
        $file[7] = "";   // Late Morning
        $file[8] = "";   // Afternoon
        $file[9] = "";   // Late Afternoon
        $file[10] = "";   // Evening
        $file[11] = "";   // Night
        $file[12] = "";   // Christmas
        $file[13] = "";   // New Years
        $file[14] = "";   // Birthday
        $file[15] = "";   // Thanksgiving
   $file[16] = ""; // Fullmoon, and evening
   $file[17] = ""; // Free Comic Book Day

   readfile($file[getindex()]);   
?>


Now, I need to discuss some "features" of this. First of all (I haven't tried this yet, but it should work) you can use this for your avatar too. You just copy the above (sig.php) to another script file with the urls for your avatar images for each time/day.

The times of day are, sort of, obvious, so I'll skip them.
There's also some holidays, such as Christmas and American Thanksgiving (feel free to change the Thanksgiving function in imagescript.php to find a different date), New Years, and Free comic book day.

I also added in a calculation of when the full moon is, it only outputs that index number if it's also between dusk and dawn. This is, of course, so you can have werewolf sigs and avatars.

Some areas to note, you need to alter the birthday values in getindex in the imagescript.php file ... unless you want to celebrate my birthday. I like video games, btw.

So ... if you want to add a new special date, this is what you need to do:

1. Go to imagescript.php where Thanksgiving, Christmas, and all that crap is assigning a value to $tod, you need to add in a new else if block. You should be able to use the surrounding else if blocks as a rubric to go off of.

2. When you assign a value to $tod, you need to make sure it's a NEW value. and it has to be an integer and positive. If you notice, the last value before the area of code that covers time of day, generally, will have the newest index value, so you just add one to that and use that as the new index.

3. Once you've done that you need to go to your sig.php file and add a new entry for that address, just copy the format of the other entries. And that's it.

When you add the urls to the sig.php file, if there's a time of day you don't want to utilize, you can use the same image as another entry. The alternative, is to go in and re-edit all my time of day operations ... I don't suggest doing that. It would take a lot more time.

You can also create multiple sets of sigs (in different files, or even in the sig.php file) to have sets of profiles for times of year, or something like that, if you wanted.

You can use the exact same format in another file for your avatar as well, as stated earlier ... anyway. Enjoy?

_________________
Image


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Mon Apr 20, 2009 8:44 am 
Offline
The Mad Prince
The Mad Prince
Group: Administrator
Group: Villain
Group: TGH Staff
User avatar

Joined: Mon Apr 21, 2008 3:04 pm
Posts: 13452
Location: Highland Kingdom
That is sweet.

_________________
Image
Listen to YIBR... I'm listening to it now... and it's not completely horrible... - (Not So) Jolly Roger


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Sat May 09, 2009 8:57 pm 
Offline
Prince of the Shokan
Prince of the Shokan
Group: Henchman
User avatar

Joined: Sun Jun 15, 2008 1:34 am
Posts: 958
Location: Umea, Sweden
O_o
Holy Crap, you took that simply little script and knocked it out of the park, wow nice work man.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Sat May 09, 2009 10:07 pm 
Offline
B-E-N-D-E-R Beeeender
B-E-N-D-E-R Beeeender
Group: Hero
Group: BETA
User avatar

Joined: Tue May 27, 2008 12:17 am
Posts: 3015
Location: Oregon, USA
I never even thought about it before, honestly, that it would appear like image code externally. So, thanks for pointing that out. Opens all sorts of neat possibilities, like, real-time stats from playing games online, for an example.

... and I want someone to use the werewolf functionality ... I think it's neat.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Thu Jul 23, 2009 2:17 am 
Offline
Aheeheeheehee
Aheeheeheehee
Group: Sidekick
User avatar

Joined: Fri Jun 27, 2008 3:18 am
Posts: 1907
Location: Michigan
I am so totally going to use this!

Since it took so long for somebody to do my request here, I also had people do some on another forum I am a part of. However that forum doesn't have the php capabilities this one does, or at least I don't think so. I'd still like to see somebody take up my request, but for now this will be great.

_________________
Image
ImageImageImage
CLICK HERE TO PLAY MAIDENS OF REALIA - A TEAM STRATEGY GAME BY YOURS TRULY.


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Thu Jul 23, 2009 2:50 am 
Offline
B-E-N-D-E-R Beeeender
B-E-N-D-E-R Beeeender
Group: Hero
Group: BETA
User avatar

Joined: Tue May 27, 2008 12:17 am
Posts: 3015
Location: Oregon, USA
What are you talking about? You have to host the scripts somewhere (where they will run) ... the forums themselves don't know they're scripts (unless they explicitly check), all they get is an image file as a result of making this page request.

But it all hinges on you uploading it to a server that has PHP installed. No one can do that for you unless you work out a hosting deal.

_________________
Image


Top
 Profile  
 
 Post subject: Re: Signature Shuffle Script
PostPosted: Thu Jul 23, 2009 3:53 pm 
Offline
Aheeheeheehee
Aheeheeheehee
Group: Sidekick
User avatar

Joined: Fri Jun 27, 2008 3:18 am
Posts: 1907
Location: Michigan
Well I got it to work, so yay me.

_________________
Image
ImageImageImage
CLICK HERE TO PLAY MAIDENS OF REALIA - A TEAM STRATEGY GAME BY YOURS TRULY.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group