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!

<?php

function isImage($fileName)
{
	$ext = substr(strrchr($fileName, '.'), 1);	
	
	if($ext <> "")
	{
		$ext = strtolower($ext);
		switch($ext)
		{
			case 'gif': return true;
			case 'jpeg': return true;
			case 'png': return true;
			case 'psd': return true;
			case 'bmp': return true;
			case 'tiff': return true;
			case 'jp2': return true;
			case 'iff': return true;
			case 'ico': return true;
			default: return false;
		}
	}
	else
		 return false;
	
}

function ListMyFiles($dir,$MySearchFile) 
{
	    if($dh = opendir($dir)) 
	   {
		$files = Array();
		$inner_files = Array();

		while($file = readdir($dh)) 
		{
			    if($file != "." && $file != ".." && $file[0] != '.') 
			    {
					if(is_dir($dir . "/" . $file)) 
					{
						
					    $inner_files = ListMyFiles($dir . "/" . $file,$MySearchFile);
					    if(is_array($inner_files)) 
						$files = array_merge($files, $inner_files); 
					    
					} 
					else 
					{
						
						if($MySearchFile == "")
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
						else if ( strstr( $file,$MySearchFile ) )
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
					}
			    }
		}

		closedir($dh);
		return $files;
	    }
}


//NOTE : if u don't want to search by keywords plesae keep this field blank
$MySearchFile = "test";

foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
{
    
    echo "<br>".$file_name;
    
}  

?>
<?php

function isImage($fileName)
{
	$ext = substr(strrchr($fileName, '.'), 1);	
	
	if($ext <> "")
	{
		$ext = strtolower($ext);
		switch($ext)
		{
			case 'gif': return true;
			case 'jpeg': return true;
			case 'png': return true;
			case 'psd': return true;
			case 'bmp': return true;
			case 'tiff': return true;
			case 'jp2': return true;
			case 'iff': return true;
			case 'ico': return true;
			default: return false;
		}
	}
	else
		 return false;
	
}

function ListMyFiles($dir,$MySearchFile) 
{
	    if($dh = opendir($dir)) 
	   {
		$files = Array();
		$inner_files = Array();

		while($file = readdir($dh)) 
		{
			    if($file != "." && $file != ".." && $file[0] != '.') 
			    {
					if(is_dir($dir . "/" . $file)) 
					{
						
					    $inner_files = ListMyFiles($dir . "/" . $file,$MySearchFile);
					    if(is_array($inner_files)) 
						$files = array_merge($files, $inner_files); 
					    
					} 
					else 
					{
						
						if($MySearchFile == "")
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
						else if ( strstr( $file,$MySearchFile ) )
						{
							if(isImage($file))
							{
								array_push($files, $dir . "/" . $file);
							}
						}
					}
			    }
		}

		closedir($dh);
		return $files;
	    }
}


//NOTE : if u don't want to search by keywords plesae keep this field blank
$MySearchFile = "test";

foreach(ListMyFiles('includes/',$MySearchFile) as $file_name)
{
    
    echo "<br>".$file_name;
    
}  

?>

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?

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.

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!!!!!!!!!!!!!!!!!!!!.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.