swape.net alireza balouch

24Apr/080

FileDate Mover v1.0

FileDate Mover is a program that moves files from one directory to directory tree based on file date.
If you have a file that have a date 2006.12.24 then it makes directory called 2006/12/filename.ext.
This program runs through a directory and moves all the files to date-based-directory-tree.
You can edit the i18n.ini file to change the settings.

rprog = datemove.exe -d

If you remove -d, then it moves the files from this month too. But if you use -d, it will ignore files that where made this month.

In the zip file you find these files:

  • i18n.ini settings file.
  • datemove.exe CMD based version of this program. Run datemove in cmd for usage options.
  • datemoveX.exe Gui-based version of this program.
  • src\ Directory containing the sourcefile in php.

Download: datemove

Tagged as: , No Comments
24Apr/080

Directory/File-chooser tool


This is an open and free program.

Here is a small GUI for those old DOS command. With this program you can run programs with given file or directory input and output.

Here is how the ini file looks like:

  1. [gui]
  2. lprog=Title of the window goes here
  3. lin= INPUT:
  4. lout= OUTPUT:
  5. lrun= RUN
  6. lexit= CLOSE
  7. lcof= Choose a output file / directory
  8. lcif= Choose a input file / directory
  9. lrunbox= "Done!"
  10. lfot= Out File
  11. lfit= Inn file
  12. [run]
  13. rprog = notepad.exe
  14. rodir = 0
  15. ridir = 0

rprog ::: you can choose the program to run.
rodir ::: 0=File 1=Directory
ridir ::: 0=File 1=Directory (If given file or directory dose not exist, it will be created.)

So now you can make your own windows based GUI from those good old DOS commands.

Download: fdc1

Tagged as: , No Comments
17Apr/080

Checkbox value

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>
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
6Feb/070

Semi-transparent png fix in IE6 with CSS

This example shows how you can show semi-transparent png images in IE and don't mess up the code in other browsers. It uses only CSS and no JavaScript.I use the attribute style to make a style for other browsers then IE. And I'm using the filter style that works only for IE in the normal section.But first you have to make a semi transparent png image.
Then make an div layer and set a class name "mydiv"

And here is the CSS code:

  1. .mydiv{
  2. background-repeat: repeat;
  3. position: relative;
  4. display: block;
  5. width:250px;
  6. height:200px;
  7. text-align: center;
  8. /* Mozilla Firefox and other non IE based browsers ignores the filter style*/
  9. filter:progid:DXImageTransform.Microsoft.AlphaImageLoader( enabled=true, sizingMethod=scale src="back_g.png");
  10. }   
  11.  
  12. /* IE ignores this part IE can not read styles with [attribute]*/
  13. .mydiv[class]{
  14. background-image: url(back_g.png);
  15. }
  16. body{
  17. background-image: url(BG.png);
  18. background-repeat: repeat;
  19. }

Since IE can not show semi-transparent png images, we have to use the filter style that only works in ie. But if we use this code we have to make sure that other browsers can show the png file as well. So we use the styles with attributes. And since IE can not read this part, we can put everything that IE dose not need to read there.

Tagged as: , , No Comments