IPB

Welcome Guest ( Log In | Register )


There are 20 online users browsing:
0 members and 20 visitors
Google.com, Gigablast.com, Yahoo.com, MSN Bot

> Random Gallery Image
tn_gallery_2_49964.jpg

Goto Month

July 2008

  SMTWTFS
»
1
2
3
4
5
»
6
7
8
9
10
11
12
»
13
14
15
16
17
18
19
»
20
21
22
23
24
25
26
»
28
29
30

> Latest Discussions
NickTheGreek @ 05-13-08 20:54
Read: 24   Comments: 0
NickTheGreek @ 05-13-08 20:54
Read: 87   Comments: 0
NickTheGreek @ 05-13-08 20:54
Read: 40   Comments: 0

 
> Dynamic Signature Scripts : ModPort Dynamic Signature
Posted by NickTheGreek - 07-5-07 14:54 - 0 comments

File Name: ModPort Dynamic Signature
File Submitter: NickTheGreek
File Submitted: 5 Jul 2007
File Category: Dynamic Signature Scripts

Ok first of all before you start u have to be able to host this image on a host that is linux and has GD Gfx Library installed on that server....


====
Needs:
a pre-made sig (Gif)
Server with GD Library
A TTF font
====

1. Ok to start load up your FTP and make a new folder (i called it sigs) and upload your font to sigs/fonts and call it font.TTF

2. Open NotePad and put this in:

CODE
ForceType application/x-httpd-php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^sig.gif$ signature.php [L]


theres other ways but this is the only way i no

and save it as ".htaccess" (without quotes ^^)

(This just tells the eveyone the goes to http://YOURSITE.com/sigs/sig.gif to act as http://YOURSITE.com/sigs/signature.php)

3. Now open your text editor (eg. DreamWaver etc..) and put the following code in.....

Random BG:

CODE
<?
$random_image = array("",
                 "sigg.gif",
                 "sigg1.gif",
                 "sigg2.gif",
                 "sigg3.gif",
                 "sigg4.gif",
                 "sigg5.gif");

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



this will alow you to have more than one image as your sig and it will be ramdomly generated.....if you only have one image change the $random_image array and only have one image then change the $rnd = rand(1,6); to $rnd = rand(1,1);


Start:

CODE
    $im = imagecreatefromgif($random_image[$rnd]);
    $blue  = ImageColorAllocate ($im, 30 , 100, 190);
    $red   = ImageColorAllocate ($im, 255,   0,   0);
    $white = ImageColorAllocate ($im, 255, 255, 255);
    $black = ImageColorAllocate ($im,   0,   0,   0);


this creates the image and allows you to have more than one color (colors are in RGB) you can add more after tongue.gif

Add IP:

CODE
$ip = $REMOTE_ADDR;
$resolved = gethostbyaddr ($REMOTE_ADDR);
$font = 'fonts/font.TTF';

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];
}


This allows you to have the veiwers IP to show up on the image..


Add Viewers OS:

CODE
$os = $HTTP_USER_AGENT;
$oslist = Array (

"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",

"Mac_68000|MacOS m68K",
"Mac_68K|MacOS m68K",
"Mac_PowerPC|MacOS PPC",
"Mac_PPC|MacOS PPC",
"Macintosh|MacOS",

"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",
"Debian|Debian GNU/Linux",

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



Thats a list of OS so it will show up


Add Viewers Browser:

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


now were you place $browser it will show the viewers browser


Finaly Create The Image:

CODE
    ImageString($im, 3, 5, 0, "$ip", $white);
    ImageString($im, 3, 5, 10, "$endos ", $white);
    ImageString($im, 3, 5, 20, "$browser", $white);

    Header("Content-Type: image/gif");
    Imagegif($im,'',100);
    ImageDestroy ($im);

?>



If you want to change the color of the text then change the $white till anything thats allready set at the top of the script




Now save it as signature.php and upload it to the folder you created and goto http://YOURSITE.com/sigs/sig.gif

[source]ModPort[/source]

Click here to download this file
Read 298 times - make a comment   

> Dynamic Signature Scripts : How to make a dynamic forum signature
Posted by NickTheGreek - 07-5-07 14:45 - 0 comments

File Name: How to make a dynamic forum signature
File Submitter: NickTheGreek
File Submitted: 5 Jul 2007
File Category: Dynamic Signature Scripts

How to make a dynamic forum signature


Ever thought it would be cool to have a forum signature that changes every time? But figured it would be a pain to somehow have an automated process upload a new one ever N minutes? Well it's very simple, and does not require anything but a bit of php code, so you do need a php enabled host. You don't even need lot of bandwidth either! This short guide will show you how you can make your own rotational signature for use in forums, emails and other places!

Setting up the folder

First, you need to setup a folder where the main image is. The main image is the image you will link to, this is actually not an image but php code which we will look at soon. You need to be running a server that uses apache and php, and type the following in your .htaccess file:

CODE
ForceType application/x-httpd-php


You should also create a file called "number.txt" which is used in the code to randomize the image. This will force all files to run as php. There's other ways of doing it so it only affects specific files, but this is the simplest one and works well since you can use a gif file or whatever, heck, you can even start your own service and put everyone's sig in that folder! If you want to specify specific files to run as php, you can lookup apache's documentation for other ways to do this, but in this case we'll simply make a folder that parses everything as php.
Notice: Do not store any other files in this folder, this folder should only be for the "fake" image and number.txt.

The code

The concept behind this is quite simple. First, you have separate images (preferably all the same physical size). These can be hosted anywhere, it does not need to be the same server, as long as they are not in the folder that you are forcing all files to run as php! Otherwise it will try to run a real image file as php and that does not work! Then, the script simply goes through them and displays a different one each time!

The main image is actually code, and not image data. But it's renamed to .jpg or .gif instead of .php. There are mainly two parts to this and many ways to do it.

The first part is a way of shuffling the available sig images. The way I do it is to simply have a file with a number and raise that number every time the script is executed, and depending on what the number is, a sig is displayed. If you have 9 sig images, you just need to make sure that when the number reaches 9, it goes back to 1.

The second part of this code is to display the signature, this involves using a HTTP header and simply redirecting to the image et voila!

File: Display1.php

If you simply named your images "image1","image2" etc you can even use this code which is much more efficient and compact:

File: Display2.php

As you can see, the code is quite simple, and there's many ways you can code it to randomize it. In mine, it simply rolls through all of them equaly, but more sophisticated code could be used to completly make the choosing random, however the point of this article is simply to show the basics and did not want to confuse you with more complex code.



Final notes

Here are a few things you should keep in mind:
# Make sure that the folder that is keeping number.txt is chmodded to 777 as the script needs to write to that file! The file itself also has to be chmodded to 777.
# If it does not work, it could be due to a parse error, to check for a parse error, simply put the path to the fake image in your address bar and it will run the php as text instead of an image and you will see the errors.
# When you do link to the sig directly, because of the header, it will redirect your browser to the sig image it is suppost to display, so your address bar will actually display the path to the real image, so if you hit refresh, it will just display that and not run the script again.
# Don't forget to actually create a number.txt file and put a number in it! That's assuming you are using the provided code.


Well this is it! I hope you've enjoyed it and that you will have fun making your friends wonder how you did it!

Later added notes: Not sure what I was thinking when I wrote this but the code above can be greatly simplified by using rand() instead of a file, check the forum thread for more info.





Click here to download this file
Read 380 times - make a comment   

> Dynamic Signature Scripts : PHP Dynamic Signature: Now Playing (Winamp)
Posted by NickTheGreek - 07-5-07 13:49 - 0 comments

File Name: PHP Dynamic Signature: Now Playing (Winamp)
File Submitter: NickTheGreek
File Submitted: 5 Jul 2007
File Category: Dynamic Signature Scripts

PHP Dynamic Signature: Now Playing (Winamp)

In this tutorial I will teach you how to make a dynamic image using PHP.

The image will have text saying the last two songs you listened to (if you are currently listening) or the last song you listened to (if you aren't currently listening).

In order to get this info, you will have to be using Winamp, and this plugin.

Once you've installed the plugin you have to set up a template that will upload every time you change the song.
For this tutorial the template you should use it the following:
[np:IsPlaying]Now[/np:IsPlaying][np:NotPlaying]Last[/np:NotPlaying]
A1:[np:Artist1]:A1
T1:[np:Title1]:T1
A2:[np:Artist2]:A2
T2:[np:Title2]:T2
Just save that as a .html file in your /Winamp/np_templates folder.

Then go to the plugin preferences (In Winamp, Ctrl + P > Plug-ins > General Purpose > Now Playing plug-in vN.N > Configure > HTML Settings tab) select your template name from the dropdown box and check 'Use template.'

Then, go to the FTP tab and fill in your FTP info.
Set the filename to 'data.txt' (without quotes)

Now, whenever your song changes, a file will be uploaded to your server (to the path specified) with the following format:
'Now' or 'Last' - Depending on whether or not you are listening now.
A1:Artist 1:A1
T1:Title 1:T1
A2:Artits 2:A2
T2:Title 2:T2
Now we need the PHP code to parse this file, and write the data to an image.

CODE
<?php

    // Cut Function
    function cut($str,$len) {
        if (strlen($str) > $len) {
            return substr($str,0,$len).'...';
        } else {
            return $str;
        }
    }
    // EO :: Cut Function
    
    // Create The Image

    header("Content-type: image/png");
    $bg = "bg.png";

    $im = @ImageCreateFromPNG($bg);
    
    // EO :: Create Image

    // NP

    $file = file("data.txt");
    if(!$file)
    {
        $now = "Error.";
    }
    if (trim($file[0]) == "Last")
    {
        $now = "Not Listening To Winamp.";
        $a1        = explode("A1:", $file[1]);
        $a2        = explode(":A1", $a1[1]);
        $a         = $a2[0];
    
        $t1        = explode("T1:", $file[2]);
        $t2        = explode(":T1", $t1[1]);
        $t         = $t2[0];
        
        $last = "Last Played: ".$a." - ".$t;
    }
    
    if (trim($file[0]) == "Now")
    {
    
        $a1        = explode("A1:", $file[1]);
        $a2        = explode(":A1", $a1[1]);
        $a         = $a2[0];
        
        $t1        = explode("T1:", $file[2]);
        $t2        = explode(":T1", $t1[1]);
        $t         = $t2[0];
        
        $now  = "Now Playing: ".$a." - ".$t;

        $a3        = explode("A2:", $file[3]);
        $a4        = explode(":A2", $a3[1]);
        $la        = $a4[0];
        
        $t3        = explode("T2:", $file[4]);
        $t4        = explode(":T2", $t3[1]);
        $lt        = $t4[0];
        
        if ($la == "" || $lt == "" || $la == " " || $lt == " ")
            $last = "Last Played: No data.";
        else
            $last = "Last Played: ".$la." - ".$lt;
        
    }
    
    // EO :: NP

    $width = 50;
    $font  = 2;
    $white = imagecolorallocate($im, 255, 255, 255);
    $black = imagecolorallocate($im, 0, 0, 0);
    
    imagestring($im, $font, 10, 6, cut($now, $width), $white);
    imagestring($im, $font, 10, 6, cut($last, $width), $white);
    
    ImagePNG($im);
    ImageDestroy($im);
    

?>


Now for the explanation:
The first few lines are a cut function that cuts a string to the specified length. We will use this for chopping off text that is longer than the length of the image.

Then we actually create the image from a background file that you have.
After that we parse the data.txt file that has all of the song info:
1. Check to see if you are listening now, or not.
2. Extract the Artists and Titles.

Now we will have two variables set – one for current, and one for last.

All we have to do now is write the strings to the image.

$width will be the width of the text (anything more will get turnicated)

$font will be the size of the font.

Not much more to explain, the rest is self explanitory.



Click here to download this file
Read 353 times - make a comment   

Lo-Fi Version Time is now: 25th July 2008 - 03:45 PM