• 0

Random Sigs


Question

I have one signature, soon to be a couple, in http://www.alexkelm.com/signatures/

Now i've seen people, like timdorr, using those "PHP sigs" well php is enabled on my account but i don't understand how?

How can I setup my profile on Neowin for signature, to randomly roate through the signatures (all *.pngs) in /signatures/ and exclude the ones from /source/ :D

Thanks so much.

- Alex

Link to comment
Share on other sites

Recommended Posts

  • 0

With an .htaccess file containing the following:

RewriteEngine on
RewriteRule sig.php(.*) sig.jpg$1

Whenever someone access yourserver.com/sig.jpg , the server actually loads sig.php. But as image.php outputs an jpg header, invision will never know it's really an php script :)

How would one implement this ? :huh:

Link to comment
Share on other sites

  • 0

I can't get mine to work.

Can someone put the code for PNG's up, as if there are say, 3 files in it, so I can see how it works?

signature.php

Doesn't work

Link to comment
Share on other sites

  • 0

I can't get mine to work.

Can someone put the code for PNG's up, as if there are say, 3 files in it, so I can see how it works?

signature.php

Doesn't work

<?php

Header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
Header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
Header("Pragma: no-cache");
Header("Content-Type: image/gif");
srand((double)microtime()*1000000);

$i = 0;
$dir = opendir("sigs/");
while(($im = readdir($dir))) {
   if($im != ".." && $im != "."){
	  $image[$i] = $im;
	  $i++;
   }
}
closedir($dir);

$len = count($image)-1;
$n = rand(0,$len);

if(!readfile("sigs/".$image[$n])){
  readfile("icons/error.gif");
}

?>

That will look in the folder "sigs" (placed under this file in the dir) and show you any image in that folder (image type of no matter).

https://www.neowin.net/staff/joel/sig.php

Try it.

Link to comment
Share on other sites

  • 0
hmm, wait, if you could use flash, you could use actionscript for this couldn't you?

Yes you could, but that's like taking a hammer to a screw.

Link to comment
Share on other sites

  • 0

I use ASP.NET as the backend platform for my rotating sigs. I created a generic service that works like so:

http://sig.fidelitydesign.net/<folder&a...*images.ext>

Where <folder> is the folder and id of the collection. Then to access a random image from the collection, I simply call:

http://sig.fidelitydesign.net/<folder.ext>

So, for my Volvic sigs, the images are location in: http://sig.fidelitydesign.net/volvic/*.jpg,

and can insert the image using the url: http://sig.fidelitydesign.net/volvic.jpg

volvic.jpg

I was thinking I might turn this into a free web servicefor anyone to use. You can upload your image collection, and the script will handle the rest. If anyone would be interested in using such a service, let me know and I will see about making it public.

Link to comment
Share on other sites

  • 0

:( i've never even hosted a website before and it seems like i have no idea what i'm doing.

i made the sigs folder in public_html folder which you apparently have to put it in to make it accessible on the website and i also put the sig.php in the public_html folder. but if i try and go to the url at http://madonion.freesitespace.net/sig.php it doesn't work, you get the cannot download error, it looks like it tries to download it rather than render it on the webpage.

however http://madonion.freesitespace.net/index.php which is in the exact same folder does work.

can anyone help me?

Link to comment
Share on other sites

  • 0

You didn't setup the paths correctly in your script by the look of it. If you view the source of the image, this is what you see. For the sake of debugging, comment out the "header('Content-type: image/jpeg');" (or similar) line so you can see the errors easily.

&lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  opendir(sig/) [&lt;a href='function.opendir'&gt;function.opendir&lt;/a&gt;]: failed to open dir: No such file or directory in &lt;b&gt;/home/madonion/public_html/sig.php&lt;/b&gt; on line &lt;b&gt;9&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  readdir(): supplied argument is not a valid Directory resource in &lt;b&gt;/home/madonion/public_html/sig.php&lt;/b&gt; on line &lt;b&gt;10&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  closedir(): supplied argument is not a valid Directory resource in &lt;b&gt;/home/madonion/public_html/sig.php&lt;/b&gt; on line &lt;b&gt;16&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  readfile(sig/) [&lt;a href='function.readfile'&gt;function.readfile&lt;/a&gt;]: failed to open stream: No such file or directory in &lt;b&gt;/home/madonion/public_html/sig.php&lt;/b&gt; on line &lt;b&gt;21&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Warning&lt;/b&gt;:  readfile(icons/error.gif) [&lt;a href='function.readfile'&gt;function.readfile&lt;/a&gt;]: failed to open stream: No such file or directory in &lt;b&gt;/home/madonion/public_html/sig.php&lt;/b&gt; on line &lt;b&gt;22&lt;/b&gt;&lt;br /&gt;

Link to comment
Share on other sites

  • 0

thanks, it was just a file path issue. kinda embarrasing as i did coursework on php for a whole year :s

anyway, i was also wondering if it is possible to make it so that when you click on the images they go to different pages, or is that way too complicated?

Link to comment
Share on other sites

  • 0

I've done this too, just use sessions to track which image you last sent the user and send them on to the relevant link based on it. It's dependant on cookies, but there's no other way (without resorting to flash).

Link to comment
Share on other sites

  • 0

&lt;?php

// Firefox doesn't render SVG in &lt;img&gt;, Safari doesn't do the sizing correctly, and in my tests Opera only loads it properly the first time.
// $files = array_merge(glob("*.png"),glob("*.jpg"),glob("*.jpeg"),glob("*.gif"),glob("*.svg"),glob("*.svgz"));
$files = array_merge(glob("*.png"),glob("*.jpg"),glob("*.jpeg"),glob("*.gif"));
$file = array_rand(array_flip($files));

$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/$file",TRUE,307);
//echo "Location: http://$host$uri/$file" . "\n";

?&gt;

This is what I'm using (well, was) for my avatar, but it's really, really generic.

Edit: av.png

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.