Urgently need -php script for searching image

Reply

Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Urgently need -php script for searching image

 
0
  #1
Dec 23rd, 2008
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!
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: manish.s is an unknown quantity at this point 
Solved Threads: 1
manish.s manish.s is offline Offline
Newbie Poster

Re: Urgently need -php script for searching image

 
0
  #2
Dec 23rd, 2008
  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. ?>
-- Manish Singh
manish.s@neuralit.com
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Re: Urgently need -php script for searching image

 
0
  #3
Dec 24th, 2008
Originally Posted by manish.s View Post
  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?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 8
Reputation: gotmick is an unknown quantity at this point 
Solved Threads: 0
gotmick gotmick is offline Offline
Newbie Poster

Re: Urgently need -php script for searching image

 
0
  #4
Dec 25th, 2008
Originally Posted by ashafaaiz View 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!

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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 19
Reputation: ashafaaiz is an unknown quantity at this point 
Solved Threads: 1
ashafaaiz ashafaaiz is offline Offline
Newbie Poster

Re: Urgently need -php script for searching image

 
0
  #5
Dec 26th, 2008
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!!!!!!!!!!!!!!!!!!!!.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 8
Reputation: gotmick is an unknown quantity at this point 
Solved Threads: 0
gotmick gotmick is offline Offline
Newbie Poster

Re: Urgently need -php script for searching image

 
0
  #6
Dec 26th, 2008
Originally Posted by ashafaaiz View Post
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC