There is nothing wrong here except your browser.....

2009/08/18

Swape Gallery Light

Filed under: Scripts — Tags: , , , — admin @ 8:40 pm

SGL is a php5 script to list pictures.
This script finds all the pictures in a directory under ./test_pic/ and makes menus based on directories.

All you have to do is putt your pictures in ./test_pic/ directory. Or edit $strPathToFiles = ‘./test_pic’; in sgl4.class.php file.

You can organize your pictures by category, by putting it under sub-directories.

The thumbs/ directory must be writable (CHMOD 755) to generate thumbnails automatically first time you visit the site. It will help loading your images faster.

HOW TO INSTALL

All you have to do is unzip the file.
Unpack the sgl4.php and configure the paths.

Putt your pictures under ./test_pic/ directory.
And don’t forget to chmod 755 thumbs directory.

SYSTEM REQUIRED.

Server with PHP5.

Download: sgl4

2008/04/17

Checkbox value

Filed under: Tips & Tricks — Tags: , — admin @ 1:06 pm

When you post a form with checkbox it dose not return any value when the checkbox is not ticked.
This is something that should have been fixed a long time ago.
But for now here is the solution:

  1. <form action="?" method="post">
  2. <input name="myCheckbox" type="hidden" value="0" />
  3. <input name="myCheckbox" type="checkbox" />
  4. </form>

You put an hidden input before checkbox input with the same name.
Since the last checkbox overwrite the value when it is checked, the hidden input do not return “0″ but when the checkbox is not checked, the hidden input with the same name returns a “0″.

So when the checkbox is checked it returns “on” and when it is not checked it returns “0″

And to make it easier to click on the ckeckbox use “label” tag around the name.

Before:

My Checkbox

After:

This way you can click on the checkbox label and make it checked.
The correct way to write an checkbox checked from the start is like this:

  1. <input checked="checked" name="myCheckbox" type="checkbox" />
  2. My Checkbox
  3. </label>

2008/02/19

favicon2png

Filed under: Scripts — Tags: , , — admin @ 9:22 pm

Here is a script to download the favicon.ico files from a website and save it as a png file.

You must have imagemagick installed on your server to convert the ico file to png.

  1.  
  2. <!— html code —->
  3. <form action="?" method="post">
  4.   <input id="site" name="site" type="text"
  5. value="<?php echo $_POST['site']; ?/>" />
  6.   <input type="submit" />
  7. </form>
  8.  
  9. < ?php
  10. //— favicon2png by Alireza Balouch @ swape.net 2008
  11.  
  12. if($_POST[’site’] != ){
  13.  
  14. //finding the hostname
  15. $host = parse_url($_POST[’site’]);
  16. $host = $host[‘host’];
  17. $host = explode(‘.’ , $host);
  18. $host = $host[count($host) -2];
  19. $filename = ‘img/’ . $host . ‘.png’;
  20.  
  21. if (!is_file($filename)){
  22. // getting the favicon
  23. $handle = fopen( $_POST[’site’] . ‘/favicon.ico’, "rb");
  24. $contents = stream_get_contents($handle);
  25. fclose($handle);
  26.  
  27. file_put_contents(‘fav.ico’ , $contents );
  28. // converting to png
  29. $StrExec = ‘/usr/local/bin/convert fav.ico -resize 24×24\> . $filename ;
  30. $ret = exec($StrExec);
  31. }
  32. echo ‘<img src="’ . $filename . ‘" />’ . $_POST[’site’];
  33. }
  34. ?>
Powered by WordPress. Design by Alireza Balouch. Top