Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and are struggling to install it? Cronwerks now installs mods for only $3/$2.50 here.


AuthorTopic: CLOSED: Programming: Listing Images [$5]  (Read 743 times)

Spudinski

  • Basic Member
  • *
  • Reputation Power: 42
  • Spudinski has no influence.
  • Offline Offline
  • Posts: 52
  • I have cookies!
    • View Profile
    • WWW
    • Email
CLOSED: Programming: Listing Images [$5]
« on: October 05, 2009, 10:22:10 AM »
Hello there, and welcome to the first programming contest in CronWerks!

So to start off with the programming contest range, we chose something simple - yet challenging for everyone.

Your goal:
To create a single script using PHP to list the images that match a certain criteria within a given directory on the web-server, and show the results as simple text, with a image in the left-hand side of the page.

Detailed objectives:
There is a directory within a script's privileges, that holds a couple of images.
List all images that has GIF, JPG, PNG and BMP extensions - use lowercase extensions for simplicity.
Display an image no larger than 20 pixels in diameter, that's within the image's original aspect ratio.
Display a result after the listing of the total files displayed.

Hints:
The script that is most similar to the one I created will win.
The script I created has roughly 8 lines, excluding open- and closing tags.
Screenshot of how my script produces the result can be located here(NOTE: Your version should not contain stylesheets).


If you might have any questions regarding this competition, please feel free to ask in this thread.
Please PM "Spudinski" with either a text file containing your script, or just as raw text.

DO NOT POST YOUR SCRIPT HERE.


May the best programmer win,
Spudinski
« Last Edit: November 24, 2009, 08:48:26 AM by Cronus »
Logged
If you see a post that just doesn't just seem right, send me a PM.
Offering services for small-type games and websites, send me a PM if you want/need something done.

Danny696

  • Excellent Member
  • ***
  • Reputation Power: 276
  • Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.
  • Offline Offline
  • Posts: 457
    • View Profile
Re: Programming: Listing Images [$5]
« Reply #1 on: October 05, 2009, 10:33:55 AM »
Im gonna try this. And BTW Nice little comp there.
Logged
My Game: GraveYard; Madness || Projects; N/A -  Available for work. Please IM/PM me.

Spudinski

  • Basic Member
  • *
  • Reputation Power: 42
  • Spudinski has no influence.
  • Offline Offline
  • Posts: 52
  • I have cookies!
    • View Profile
    • WWW
    • Email
Re: Programming: Listing Images [$5]
« Reply #2 on: October 05, 2009, 11:33:38 AM »
Thanks for your submission danny696, but unfortunately it doesn't work out of the box.
Also, I can't get it to display anything, as well as you need to format the script correctly.
As a side note to everyone. maybe I didn't make it clear in my original post; the script should do exactly the same as mine, and deliver the same output as mine - look at the screenshot for more information.

But thanks for your effort, maybe you can think of another way (HINT:) that's not a function and resubmit it.
« Last Edit: October 05, 2009, 11:36:05 AM by Spudinski »
Logged
If you see a post that just doesn't just seem right, send me a PM.
Offering services for small-type games and websites, send me a PM if you want/need something done.

Danny696

  • Excellent Member
  • ***
  • Reputation Power: 276
  • Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.
  • Offline Offline
  • Posts: 457
    • View Profile
Re: Programming: Listing Images [$5]
« Reply #3 on: October 05, 2009, 02:18:24 PM »
Well lets saftly say ive come the closest so far
Logged
My Game: GraveYard; Madness || Projects; N/A -  Available for work. Please IM/PM me.

Spudinski

  • Basic Member
  • *
  • Reputation Power: 42
  • Spudinski has no influence.
  • Offline Offline
  • Posts: 52
  • I have cookies!
    • View Profile
    • WWW
    • Email
Re: Programming: Listing Images [$5]
« Reply #4 on: October 05, 2009, 03:53:11 PM »
Hehe... sovar. :P
Though your script is properly about 0.5% similar, it's a pretty good effort.
Logged
If you see a post that just doesn't just seem right, send me a PM.
Offering services for small-type games and websites, send me a PM if you want/need something done.

Danny696

  • Excellent Member
  • ***
  • Reputation Power: 276
  • Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.
  • Offline Offline
  • Posts: 457
    • View Profile
Re: Programming: Listing Images [$5]
« Reply #5 on: October 06, 2009, 08:47:14 AM »
is the 0.5 the <?php and ?
Logged
My Game: GraveYard; Madness || Projects; N/A -  Available for work. Please IM/PM me.

Spudinski

  • Basic Member
  • *
  • Reputation Power: 42
  • Spudinski has no influence.
  • Offline Offline
  • Posts: 52
  • I have cookies!
    • View Profile
    • WWW
    • Email
Re: Programming: Listing Images [$5]
« Reply #6 on: October 06, 2009, 10:45:37 AM »
Funny bunny, but yea.
Logged
If you see a post that just doesn't just seem right, send me a PM.
Offering services for small-type games and websites, send me a PM if you want/need something done.

HauntedDawg

  • Basic Member
  • *
  • Reputation Power: 12
  • HauntedDawg has no influence.
  • Offline Offline
  • Posts: 27
    • View Profile
Re: Programming: Listing Images [$5]
« Reply #7 on: October 28, 2009, 03:03:17 PM »
I sent my script in. Does exactly what your's does with 2 extra line's ;)

Online view: http://deadlykillah.net/ajax_launcher.php?display_images
Logged

Danny696

  • Excellent Member
  • ***
  • Reputation Power: 276
  • Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.Danny696 has a powerful will.
  • Offline Offline
  • Posts: 457
    • View Profile
Re: Programming: Listing Images [$5]
« Reply #8 on: October 29, 2009, 05:28:02 AM »
Bar green is blue lol.
Logged
My Game: GraveYard; Madness || Projects; N/A -  Available for work. Please IM/PM me.

HauntedDawg

  • Basic Member
  • *
  • Reputation Power: 12
  • HauntedDawg has no influence.
  • Offline Offline
  • Posts: 27
    • View Profile
Re: Programming: Listing Images [$5]
« Reply #9 on: October 29, 2009, 01:51:10 PM »
Logged

Spudinski

  • Basic Member
  • *
  • Reputation Power: 42
  • Spudinski has no influence.
  • Offline Offline
  • Posts: 52
  • I have cookies!
    • View Profile
    • WWW
    • Email
Re: Programming: Listing Images [$5]
« Reply #10 on: November 04, 2009, 10:10:18 AM »
Hmm.... Does nobody know the answer to this?
Ok, ok, I'll give you guys yet another hint...

It's not anything to do with the dir or readdir functions, as they take to long, and simply because there's a shorter way.
Logged
If you see a post that just doesn't just seem right, send me a PM.
Offering services for small-type games and websites, send me a PM if you want/need something done.

Spudinski

  • Basic Member
  • *
  • Reputation Power: 42
  • Spudinski has no influence.
  • Offline Offline
  • Posts: 52
  • I have cookies!
    • View Profile
    • WWW
    • Email
Re: Programming: Listing Images [$5]
« Reply #11 on: November 16, 2009, 12:01:09 AM »
The last contestant was danny696, he was also incorrect.
This competition has been going for a long time, don't you think?
The next one will be a little bit easier, or at least something people can have a bit at.

The solution to this contest was the following:
$directory './images/';
$images glob($directory '{*.jpg,*.png,*.bmp,*.gif}'GLOB_BRACE);

$counter 0;
foreach(
$images as $image) {
    echo 
'<img src="./' $image '" style="max-width:20px;max-height:20px"> ' basename($image) . '<br />';
    
$counter++;

echo 
'<p>Total files that match criteria: ' number_format($counter) . '</p>';

The main goal was to discover the function glob(), but I guess no-one knew of this.
Reference(s) that might help you understand better: http://php.net/glob


* Contest Closed *
« Last Edit: November 16, 2009, 12:04:42 AM by Spudinski »
Logged
If you see a post that just doesn't just seem right, send me a PM.
Offering services for small-type games and websites, send me a PM if you want/need something done.