943,817 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 531
  • PHP RSS
Dec 23rd, 2008
0

Urgently need -php script for searching image

Expand Post »
Hi
can anybody help me?
I am working in a networked system. Just i want to search all the images in the H: drive. What i am exactly trying to say is, i want a search program exactly as 'istockphoto.com' of my own. Could you tell me this is possible for writing code in php.
Pleeeeeeeeeeeeeeeeease very urgent!
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ashafaaiz is offline Offline
20 posts
since Dec 2008
Dec 23rd, 2008
0

Re: Urgently need -php script for searching image

PHP Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3.  
  4. function isImage($fileName)
  5. {
  6. $ext = substr(strrchr($fileName, '.'), 1);
  7.  
  8. if($ext <> "")
  9. {
  10. $ext = strtolower($ext);
  11. switch($ext)
  12. {
  13. case 'gif': return true;
  14. case 'jpeg': return true;
  15. case 'png': return true;
  16. case 'psd': return true;
  17. case 'bmp': return true;
  18. case 'tiff': return true;
  19. case 'jp2': return true;
  20. case 'iff': return true;
  21. case 'ico': return true;
  22. default: return false;
  23. }
  24. }
  25. else
  26. return false;
  27.  
  28. }
  29.  
  30. function ListMyFiles($dir,$MySearchFile)
  31. {
  32. if($dh = opendir($dir))
  33. {
  34. $files = Array();
  35. $inner_files = Array();
  36.  
  37. while($file = readdir($dh))
  38. {
  39. if($file != "." && $file != ".." && $file[0] != '.')
  40. {
  41. if(is_dir($dir . "/" . $file))
  42. {
  43.  
  44. $inner_files = ListMyFiles($dir . "/" . $file,$MySearchFile);
  45. if(is_array($inner_files))
  46. $files = array_merge($files, $inner_files);
  47.  
  48. }
  49. else
  50. {
  51.  
  52. if($MySearchFile == "")
  53. {
  54. if(isImage($file))
  55. {
  56. array_push($files, $dir . "/" . $file);
  57. }
  58. }
  59. else if ( strstr( $file,$MySearchFile ) )
  60. {
  61. if(isImage($file))
  62. {
  63. array_push($files, $dir . "/" . $file);
  64. }
  65. }
  66. }
  67. }
  68. }
  69.  
  70. closedir($dh);
  71. return $files;
  72. }
  73. }
  74.  
  75.  
  76. //NOTE : if u don't want to search by keywords plesae keep this field blank
  77. $MySearchFile = "test";
  78.  
  79. foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
  80. {
  81.  
  82. echo "<br>".$file_name;
  83.  
  84. }
  85.  
  86. ?>
Reputation Points: 10
Solved Threads: 5
Light Poster
manish.s is offline Offline
29 posts
since Dec 2008
Dec 24th, 2008
0

Re: Urgently need -php script for searching image

Click to Expand / Collapse  Quote originally posted by manish.s ...
PHP Syntax (Toggle Plain Text)
  1.  
  2. <?php
  3.  
  4. function isImage($fileName)
  5. {
  6. $ext = substr(strrchr($fileName, '.'), 1);
  7.  
  8. if($ext <> "")
  9. {
  10. $ext = strtolower($ext);
  11. switch($ext)
  12. {
  13. case 'gif': return true;
  14. case 'jpeg': return true;
  15. case 'png': return true;
  16. case 'psd': return true;
  17. case 'bmp': return true;
  18. case 'tiff': return true;
  19. case 'jp2': return true;
  20. case 'iff': return true;
  21. case 'ico': return true;
  22. default: return false;
  23. }
  24. }
  25. else
  26. return false;
  27.  
  28. }
  29.  
  30. function ListMyFiles($dir,$MySearchFile)
  31. {
  32. if($dh = opendir($dir))
  33. {
  34. $files = Array();
  35. $inner_files = Array();
  36.  
  37. while($file = readdir($dh))
  38. {
  39. if($file != "." && $file != ".." && $file[0] != '.')
  40. {
  41. if(is_dir($dir . "/" . $file))
  42. {
  43.  
  44. $inner_files = ListMyFiles($dir . "/" . $file,$MySearchFile);
  45. if(is_array($inner_files))
  46. $files = array_merge($files, $inner_files);
  47.  
  48. }
  49. else
  50. {
  51.  
  52. if($MySearchFile == "")
  53. {
  54. if(isImage($file))
  55. {
  56. array_push($files, $dir . "/" . $file);
  57. }
  58. }
  59. else if ( strstr( $file,$MySearchFile ) )
  60. {
  61. if(isImage($file))
  62. {
  63. array_push($files, $dir . "/" . $file);
  64. }
  65. }
  66. }
  67. }
  68. }
  69.  
  70. closedir($dh);
  71. return $files;
  72. }
  73. }
  74.  
  75.  
  76. //NOTE : if u don't want to search by keywords plesae keep this field blank
  77. $MySearchFile = "test";
  78.  
  79. foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
  80. {
  81.  
  82. echo "<br>".$file_name;
  83.  
  84. }
  85.  
  86. ?>

Hi,
Manish. Thanks for giving a remedy for my problem. But it shows some warning in opendir() that directory does not exist.
What shall i do?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ashafaaiz is offline Offline
20 posts
since Dec 2008
Dec 25th, 2008
0

Re: Urgently need -php script for searching image

Click to Expand / Collapse  Quote originally posted by ashafaaiz ...
Hi
can anybody help me?
I am working in a networked system. Just i want to search all the images in the H: drive. What i am exactly trying to say is, i want a search program exactly as 'istockphoto.com' of my own. Could you tell me this is possible for writing code in php.
Pleeeeeeeeeeeeeeeeease very urgent!

Are you publishing for other users on the internet like istockphoto (and offering for sale??) or do you just want to see your own pictures?

If it's just you and your own drive, try something like Google's free Picasa program. Otherwise look at some of the opensource php apps at sourceforge.net. Other than "searching", you are not being very specific about your needs, but there are several projects that are similar to what you describe.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gotmick is offline Offline
8 posts
since Aug 2007
Dec 26th, 2008
0

Re: Urgently need -php script for searching image

Hi,
Thank you very much for guiding me to get 'Google picasa'. This is what i am exactly wanted. But it displays all my pictures images in my computer only. When i want to search images in other system (Just i am working in a networked environment and i must share all images in all system), it displays some warning. could you help me about this problem?
Once again Thanks a lot!!!!!!!!!!!!!!!!!!!!.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
ashafaaiz is offline Offline
20 posts
since Dec 2008
Dec 26th, 2008
0

Re: Urgently need -php script for searching image

Click to Expand / Collapse  Quote originally posted by ashafaaiz ...
Hi,
When i want to search images in other system (Just i am working in a networked environment and i must share all images in all system), it displays some warning. could you help me about this problem?
Well, what does the warning say? I'm assuming the folders you want it to index are already shared on the network, so you should be able to add those folders to Picassa's index in it's settings. It might be better to map those network folders too. That makes them appear as their own hard drive in your computer. Here's more on that: http://www.ehow.com/how_2073284_map-drive-windows.html

Hope that helps.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gotmick is offline Offline
8 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: need help in php forms..plz
Next Thread in PHP Forum Timeline: Preg_Match? Explode? Please Help :D!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC