swape.net alireza balouch

18Aug/090

Swape Gallery Light

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

Tagged as: , , , No Comments
19Feb/080

favicon2png

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 24x24\> ' . $filename ;
  30. $ret = exec($StrExec);
  31. }
  32. echo '<img src="' . $filename . '" />' . $_POST['site'];
  33. }
  34. ?>
Tagged as: , , No Comments