Location: PHPKode > projects > Epiware Document Management > Epiware_4.8.6/epi/adv_search_display.php
<?
/******************************************************************************
Epiware: Project and Document Management
http://www.epiware.com
Copyright (C) 2006 James Kern

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. 

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. 

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Epiware, Inc. and Praxis Inc, hereby disclaims all copyright
interest in the program 'Epiware' written
by James Kern, Edward Kline, Ryan Gilfether, Ray Gorospe, Patrick Waddingham

06 September 2006
James Kern, President of Epiware 
Jack Chapman, President of Praxis
*****************************************************************************/ 
   require_once("./module_prepend.php"); 
   $epi_translator->language_check(__FILE__,$db);   
   require_once("./epi_prepend.php");
   include("./document_management.inc.php");
   include("./library_header.inc.php");
   include("./search_text_common.php");
define("RETURN_TO",basename(__FILE__));
/////////////////////////////////////////////
/////////////////////////////////////////////
// THE ABOVE IS ALL REQUIRED TO RUN LIBRARY
// NO CONTECT IS OUTPUT, ALL DATA VALIADATION
/////////////////////////////////////////////
/////////////////////////////////////////////

 define("SEARCH_DEBUG",0);

//This draws the MENU widht TAB postion highlighted
define("TAB_SELECTED","LIBRARY");
require_once("./mrc_header.php");   

 $print_occurances=0;
?>



<div id="content">
<div id="page-content">




<?
$site_map_array = array(1 => "<a href=index_library.php>Library</a>","<a href=search_result.php>Search</a>","<a href=adv_doc_search.php>Advanced Search</a>","Advanced Search Results" );
site_map::draw($site_map_array);


 
 
	//----------------------------------------------
	// Do a set/get cookie and then connect to the database 
	//----------------------------------------------
  
	$crypt = new EPI_CRYPT;        
	$priv = new check_priv();	
	$user_id = $crypt->WEB_decrypt($enc_user_id);
	$group_id = $crypt->WEB_decrypt($enc_group_id);
     
 
      

	  $cm_controlled = is_cm_controlled($group_id,$db); 

 
/*
$epi_html_helper->begin_html_page(&$priv,&$epi_translator);
echo "<div align=center> "; 
$epi_menu = new epiware_project_menu($group_id,$db); 
if(!$epi_menu->add_sub_menu_by_name("epi_custom_modules",$db,false,$group_id))
{
	//put in the custom module menu
	$menu = new sys_menus();
	$menu->menu_name = "epi_custom_modules";
	$menu->menu_id = 0;
	$menu->use_under_bar = "y";
	$menu->insert($db,false);
	$epi_menu->add_sub_menu_by_name("epi_custom_modules",$db,false,$group_id);
}//end of if th custom menu is not there
//get the title bar across the top of the page 
// W is withour page...
 draw_module_title($group_id,$user_id,$is_root,$is_admin,&$db,"folder_add_2.php","W");
//,$mode="S",$width=625)
//last two parameteres are default here
//draw the main epiware menu, passing the module(tab) name 
//that is selected so that it will be highlighted 
$epi_menu->align = "left"; 
$have_form = $epi_menu->draw($db,"epi_lib"); 

 
*/








	$print_occurances = false;
	$contents_entered = false;
	$contents_found_result = false;


	/******************************************************
	 * NOW WE START OUR SEARCH
	 ******************************************************/
	//$query = "SELECT doc_id,name,title,real_name,doc_size,creation_date FROM user_docs "
	//. " WHERE group_id=$group_id AND ";

	$query="";


  //$contents=1;
 // the contents need to be searched

// THIS WILL NOT BE USED!!!!!!
	if($contents != "")
	{

		$print_occurances = true;
		$contents_entered = true;
		$group_directory = DOCUMENT_DIRECTORY."/".$group_id;
		$text_directory = $group_directory."/text" ;
 	   $limiting_file = build_limiting_file($db,$group_directory,$group_id,$user_id,$crypt);




      if(defined("BINARY_LOCATION")){
		   $command = BINARY_LOCATION . "/glimpse -licy -f $limiting_file -L 600:50:40 -H $text_directory '$contents'";
		} else {
		   $command = "/usr/bin/glimpse -licy -f $limiting_file -L 600:50:40 -H $text_directory '$contents'";
	   }



		$returned_result = `$command`;
		$content_find = explode("\n",$returned_result);



		if($returned_result != "")
		{
			// create an array where the key is the 'name' of the file
			// and the value is it's occurance count
			$contents_array = array();
	
			if(is_array($content_find))
			{
				$contents_found_result = true;
				$query .= "(";
		
				for($i=0; $i < count($content_find)-1; ++$i)
				{
					// find the last space that divides the filename from the number of occurences
					$temp = explode(": ", $content_find[$i]);
		
					// get the file name
					$pos = strrpos($temp[0], "/");
					$name = substr($temp[0], $pos+1, strlen($temp[0])-$pos-5);
					$contents_array[$name] = $temp[1];
		
					$query .= "name='".$name."' OR ";
				}
		
				// strip off the trailing ' OR '
				if(substr($query, strlen($query)-4, 4) == " OR ")
					$query = substr($query, 0, strlen($query)-4);
		
				$query .= ") AND ";
			}
		}
	}

	if($file_name != "")
	{
		if($file_name_logical == "equals")
			$query .= "user_docs.real_name='$file_name' AND ";
		else
		{
			$file_name = explode(" ",$file_name);
			if(is_array($file_name))
			{
				for($i=0; $i<count($file_name); ++$i)
					$query .= "user_docs.real_name LIKE '%".$file_name[$i]."%' AND ";
			}
			else
				$query .= "user_docs.real_name LIKE '%$file_name%' AND ";
		}
	}

	if($title != "")
	{
		if($title_logical == "equals")
			$query .= "user_docs.title='$title' AND ";
		else
		{
			$title = explode(" ",$title);
			if(is_array($title))
			{
				for($i=0; $i<count($title); ++$i)
					$query .= "user_docs.title LIKE '%".$title[$i]."%' AND ";
			}
			else
				$query .= "user_docs.title LIKE '%$title%' AND ";
		}
	}

	if($author != "")
	{
		if($author_logical == "equals")
			$query .= "user_docs.author='$author' AND ";
		else
		{
			$author = explode(" ",$author);
			if(is_array($author))
			{
				for($i=0; $i<count($author); ++$i)
					$query .= "user_docs.author LIKE '%".$author[$i]."%' AND ";
			}
			else
				$query .= "user_docs.author LIKE '%$author%' AND ";
		}
	}

	if($description != "")
	{
		if($description_logical == "equals")
			$query .= "user_docs.description='$description' AND ";
		else
		{
			$description = explode(" ",$description);
			if(is_array($description))
			{
				for($i=0; $i<count($description); ++$i)
					$query .= "user_docs.description LIKE '%".$description[$i]."%' AND ";
			}
			else
				$query .= "user_docs.description LIKE '%$description%' AND ";
		}
	}

	if($ident != "")
	{
	   $ident=htmlentities($ident);
		if($ident_logical == "equals")
			$query .= "user_docs.identification_num='$ident' AND ";
		else
		{
			$ident = explode(" ",$ident);
			if(is_array($ident))
			{
				for($i=0; $i<count($ident); ++$i)
					$query .= "user_docs.identification_num LIKE '%".$ident[$i]."%' AND ";
			}
			else
				$query .= "user_docs.identification_num LIKE '%$ident%' AND ";
		}
	}

	if($revision_num != "")
	{
		if($revision_num_logical == "equals")
			$query .= "user_docs.revision_num='$revision_num' AND ";
		else
		{
			$revision_num = explode(" ",$revision_num);
			if(is_array($revision_num))
			{
				for($i=0; $i<count($revision_num); ++$i)
					$query .= "user_docs.revision_num LIKE '%".$revision_num[$i]."%' AND ";
			}
			else
				$query .= "user_docs.revision_num LIKE '%$revision_num%' AND ";
		}
	}

	/*	   LEAVE THIS OUT FOR NOW UNTIL WE CAN FIGURE OUT WHAT TO DO
	if($uploaded_by != "")
	{
		if($uploaded_by_logical == "equals")
		{
				// first we need to get a list of matching 
			// user_id's to the name submitted
			$_query = "SELECT user_id FROM users WHERE
			$query .= "identification_num='$uploaded_by' AND ";
		}
		else
		{
			$ident = explode(" ",$ident);
			if(is_array($ident))
			{
				for($i=0; $i<count($ident); ++$i)
					$query .= "identification_num LIKE '%".$ident[$i]."%' AND ";
			}
			else
				$query .= "identification_num LIKE '%$ident%' AND ";
		}
	}
	*/

	if($start_creation_date_month!="" && $start_creation_date_day!="" && $start_creation_date_year!="" &&
		$end_creation_date_month!="" && $end_creation_date_day!="" && $end_creation_date_year!="")
	{
		$start_date = $start_creation_date_year."-".$start_creation_date_month."-".$start_creation_date_day;
		$end_date = $end_creation_date_year."-".$end_creation_date_month."-".$end_creation_date_day;

		$query .= "user_docs.creation_date >= '$start_date' AND user_docs.creation_date <= '$end_date' AND ";
	}

	if($start_revision_date_month!="" && $start_revision_date_day!="" && $start_revision_date_year!="" &&
		$end_revision_date_month!="" && $end_revision_date_day!="" && $end_revision_date_year!="")
	{
		$start_date = $start_revision_date_year."-".$start_revision_date_month."-".$start_revision_date_day;
		$end_date = $end_revision_date_year."-".$end_revision_date_month."-".$end_revision_date_day;

		$query .= "user_docs.revision_date >= '$start_date' AND user_docs.revision_date <= '$end_date' AND ";
	}

	if($start_upload_date_month!="" && $start_upload_date_day!="" && $start_upload_date_year!="" &&
		$end_upload_date_month!="" && $end_upload_date_day!="" && $end_upload_date_year!="")
	{
		$start_date = $start_upload_date_year."-".$start_upload_date_month."-".$start_upload_date_day;
		$end_date = $end_upload_date_year."-".$end_upload_date_month."-".$end_upload_date_day;

		$query .= "user_docs.upload_date >= '$start_date' AND user_docs.upload_date <= '$end_date' AND ";
	}

	// strip off the trailing ' AND '
	if(substr($query, strlen($query)-5, 5) == " AND ")
		$query = substr($query, 0, strlen($query)-5);
?>


 

<?
	$IS_ADMIN = is_admin($user_id,$db,$group_id);
//	$library_header = new library_header(__FILE__,$db,$IS_ADMIN,$cm_controlled);

/*	 

  $message = "<A href=\"JavaScript:history.back()\">";
  $message .= "<font face=\"" . FONT_FACE . "\" color=\""  . TITLE_FONT_ON .  "\" ><B>";   
  $message .= epi_translate("back to previous page",__FILE__,$db);
  $message .= "</b></font></a>";
  $menu_title = "<b class=\"medtitle\">".epi_translate($words,__FILE__,$db)."</b>";  
  print "<BR>";
  print_menu_title($menu_title,300,$message);
*/
	print "<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH=625>\n";
	print "<TR><TD>&nbsp;</TD></TR>\n";

//	$db->debug_sql();
//	print "contents_entered=$contents_entered<BR>";
//	print "contents_found_result=$contents_found_result<BR>";
			   
	// NO contect search...  Just META Data..
	$contents_entered=false;
	// now perform the query
	if(($contents_entered && $contents_found_result) || !$contents_entered)
	{
   // print $query;
    if(!$contents_entered){
	    build_limiting_sql($db,$group_id,$user_id,$crypt,$query);
	 }

	  /*
  	  $result = $db->perform_looping_query($query);
		while($row = $db->get_next_row($result))
		{
			print "<TR>";
			print "<TD COLSPAN=2>";
			print "<FONT FACE='".FONT_FACE."' SIZE='+1'>";
			print "<A HREF=\"verify_owner_2.php?doc_id=".$crypt->WEB_encrypt($row["doc_id"])."\"><B>".$row["title"]."</B></A>";
			print "</FONT>";
			print "</TD>";
			print "</TR>\n";
	
			print "<TR>";
			print "<TD>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#555555'>";

		   print epi_translate("Occurences",__FILE__,$db);

			print ": </FONT>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#770000'>AAA";
	
			if($print_occurances)
				print $contents_array[$row["name"]];
			else
				print "N/A";
	
			print "</FONT>";
			print "</TD>";
			print "<TD>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#555555'>";
			print epi_translate("Size",__FILE__,$db);			 
			print ": </FONT>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#006600'>".intval($row["doc_size"]/1000)."<B>k</B></FONT>";
			print "</TD>";
			print "</TR>\n";
	
			$dt = date("M-d-Y",strtotime($row["creation_date"]));
	
			print "<TR>";
			print "<TD>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#555555'>";
			print epi_translate("File",__FILE__,$db); 
			print ": </FONT>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#006600'><B>".$row["real_name"]."</B></FONT>";
			print "</TD>";
			print "<TD>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#555555'>";
			print epi_translate("Date Created",__FILE__,$db);
			print ": </FONT>";
			print "<FONT FACE='".FONT_FACE."' COLOR='#006600'><B>".$dt."</B></FONT>";
			print "</TD>";
			print "</TR>\n";
	
			print "<TR><TD>&nbsp;</TD></TR>\n";
		}
	  */

	}
	 

	print "</TABLE>\n";
 

?>

</div>
</div>
<?
require_once("./mrc_footer.php");   
?>



Return current item: Epiware Document Management