If you for some reason need to contact us, please do so by mailing us using our online contact form.

News TESTER / 2007-09-01 13:59:34 / Jonas

Hello!

This is a paragraph,
I can tell by the pixel and from
seeing quite a few parahraphs in my time.

CODE OH SHIT

“Jeg er sjov!”
Leif Panduro

GRrrreereAAT!

hello




Posted in News / Tags: katt, häst, hund, åsna

News krakel / 2007-09-01 01:19:31 / Jonas

spektakel

“kusin vitamin”
‘oh shit’
katt

I need cookies!




Posted in News / Tags: test, test, test

News Another test / 2007-09-01 01:17:00 / Jonas

Woah

caaaats
cats!
BE GONE!
be here!

\“cats\”:http://www.satf.net
\”!http://www.satf.net/images/general.png!\”:http://www.satf.net/

LOL cat bc.. ASP

oh shit…

KARAMBA

\“what\‘s this?\”
Leif Panduro

Oh shit.




Posted in News / Tags: test, test and test

General Hello, test! / 2007-09-01 01:03:08 / Jonas

THIS IS AWESOME!

Giddy-oh!

this just in

cooode

awesome

<?php
$hello
?>

Goood.




Posted in General / Tags: cats, dogs, letterboxes

General PHP tutorial: List images between a number range / 2007-05-27 23:25:49 / Jonas

Learn how to easily list all images with a specified number range from a homepage with one single function!

The script (and function) clarification

Basically, this function is just a nested loop (a loop inside a loop), with the use of 2 for loops, which will display images. Let’s say you know there’s a 100 images you want to download from www.example.com/images that have the filenames in the range of 001.jpg-100.jpg, and you don’t have access to any sort of directory listing, a script to do it would be nice instead of having to type it all in manually.

We’ll start off with the function.

	function getImages($start, $end, $digits, $url, $ext)
{

If you have done any PHP before, this isn’t unfamiliar to you, for you others, I’ll explain it.

To make a function you simply begin with the word function, followed by the name of the function and then a beginning and a finishing parenthesis. Inside the parenthesis, you put the parameters seperated by commas.

In my case, I have the parameters $start, $stop, $digits, $url and $ext.

$start is what number the first image will have. If it’s 1, 001 or 00001, you simply put 1.
$end is the opposite of $start, $end should be the value of the last image, in the example mentioned above, this should be 100 (or 0100 or 00100, put in 100 to be on the safe side).
$digits is the number of digits the image has (i.e. 005 has 3 digits), this is to make the imagename appear correctly, if we didn’t include this, the imagenames would be 1.jpg, 2.jpg instead of 001.jpg, 002.jpg, etc.
$url is the url to the image, without the numbers. If you have an image at http://www.example.com/images/DCN001.jpg the url would be http://www.example.com/images/DCN (including the image-prefix).

$ext is the extension i.e. .jpg. This could also be used if the image-name is 001SOMETHING.jpg, then the extension would be SOMETHING.jpg to conclude the urls.

That was the creating of the new function, now to the actual function.

For me? No, for $i!

Now it’s loop-time!

for($i = $start; $i <= $end; $i++)
{

This is a for-loop (note: not a complete one, you must end it too)

It generally says “I equals to start (which is a parameter), while I is lesser than or equal to end (also a parameter), increment I once (+1)”.

      $z = '';

      for($n = 0; $n < ($digits - strlen($i)); $n++)

Here we declare the variable ‘z’ to be nothing, just to start the variable, then ANOTHER for-loop makes its presence (thus making it a nested loop.

This for-loop is a bit different though, if you compare it to the first one.

The big difference is the $n < ($digits - strlen($i)) part.

$digits, which I’ve already explained, is the value of how many digits the filename contains in its range, is subtracted by how many actual digits the variable contains(02 = 2, 555 = 3) using the strlen function.

int strlen ( string string )
Returns the length of the given string.

If we say that we have digits set to 3 and the value of $i is currently 4, which is only one single digit (1), it would mean 3 – 1 which is equal to 2.

And moving along to the actual zero-adding:

         $z .= "0";

shock

That’s not a lot of code!

We started the variable $z in the former code-block, and now we simply concatenate zeroes onto that string, adding 2 zeroes to the number if it’d be 2 (if we still have $digits set to three), adding 1 zero to the number if it’d be 25 and adding 0 zeroes to the number if it’d be 100.

Now it’s just some finishing touches that has to be made before the function is done.

      }

      $ret = "&lt;img src=\"" . $url . $z . $i . $ext . "\"
height=\"200\" width=\"200\" title=\"" . $z . $i . "\"
/>&lt;br /&gt;\n";

      echo $ret;

   }

}

The first thing here that is done, is finishing the second loop.

Then we summarize everything in the $ret (short for return) variable which contains the whole image-tag including url, number and correct extension before we echo it out!

Now we’ve closed all brackets and finished everything.
...except now we need to use it!

And that is the easiest part of the tutorial (which isn’t that hard at all).

I have a couple of screenshots from my very odd-looking computer which I will demonstrate with:

getImages(424, 434, 5, "http://www.satf.net/upload/DSC", ".JPG");

This will, in the sourcecode, display:

<img src="http://www.satf.net/upload/DSC00424.JPG" height="200"
width="200" title="00424" /><br />
<img src="http://www.satf.net/upload/DSC00425.JPG" height="200"
width="200" title="00425" /><br />
<img src="http://www.satf.net/upload/DSC00426.JPG" height="200"
width="200" title="00426" /><br />
<img src="http://www.satf.net/upload/DSC00427.JPG" height="200"
width="200" title="00427" /><br />
<img src="http://www.satf.net/upload/DSC00428.JPG" height="200"
width="200" title="00428" /><br />
<img src="http://www.satf.net/upload/DSC00429.JPG" height="200"
width="200" title="00429" /><br />
<img src="http://www.satf.net/upload/DSC00430.JPG" height="200"
width="200" title="00430" /><br />
<img src="http://www.satf.net/upload/DSC00431.JPG" height="200"
width="200" title="00431" /><br />
<img src="http://www.satf.net/upload/DSC00432.JPG" height="200"
width="200" title="00432" /><br />
<img src="http://www.satf.net/upload/DSC00433.JPG" height="200"
width="200" title="00433" /><br />
<img src="http://www.satf.net/upload/DSC00434.JPG" height="200"
width="200" title="00434" /><br />

Now you’re probably thinking, “Should I just download all these images by my own now? This function was a waste of time!!”. Well it wasn’t. Now you simply go into your file menu and press Save As, choose the correct settings (download full webpage with images) and, as you may have guessed, you download all images to your harddrive.(Atleast with Firefox, Opera and Internet Explorer).

final result

Full code

<?php

/*

Code and tutorial made by pihl.
You may use the code but we would greatly appreciate a link to this site.

(c) 2006 Jonas Skovmand

*/

function getImages($start, $end, $digits, $url, $ext)
{
   for($i = $start; $i <= $end; $i++)

   {
      $z = '';
      for($n = 0; $n < ($digits - strlen($i)); $n++)
      {

         $z .= "0";
      }
      $ret = "<img src=\"" . $url . $z . $i . $ext . "\"
height=\"200\" width=\"200\" title=\"" . $z . $i . "\" /><br
/>\n";
      echo $ret;
   }
}
getImages(424, 434, 5, "http://www.satf.net/upload/upload/DSC", ".JPG");

?>

You might say that there’s a thousand ways this can be done better with some program or browser plugin, but this is just a simple way to do it with php.

Hope you enjoyed this tutorial!




Posted in General / Tags: php, tutorial, for, loop, images, development, html

General DAME / 2007-05-16 14:46:00 / Jonas

Awesome Lucky Star video :D

Get the Flash Player to see this player.




Posted in General / Tags: test, development, lucky star

News Another test... / 2007-02-11 12:00:03 / Jonas

Filip is chillin’ out, maxin’, relaxin’ all cool…

User submitted image:
http://www.satf.net/upload/pihl/fillegif.gif




Posted in News / Tags: news, development, test

General Test / 2007-02-11 00:00:00 / Jonas

This is strictly a test. Please don’t kill me…

woop.




Posted in General / Tags: news, development, test

© 2004-2007 Jonas Skovmand - Unoriginal until proven otherwise.
http://www.satf.info | http://www.satf.net/upload