HEX
Server: Apache
System: Linux 244.240.109.208.host.secureserver.net 5.14.0-611.11.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Dec 3 09:47:37 EST 2025 x86_64
User: icsla (1002)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/icsla/.trash/rteitel.com/documents/search.php
<?php
$version='ezgenerator search 2.2';
/*
	search.php 
	http://www.ezgenerator.com
	Copyright (c) 2004-2010 Image-line
*/
include_once ('../ezg_data/functions.php');
$rel_path='../'; 
$site_languages_array=explode('|',$f_site_languages); array_pop($site_languages_array);
$php_pages_ids=array('20','21','130','140','133','136','137','138','143','144');
$res_bgcolor='#E2E2E2';
$internal_use=false;
$internal_fl_use=false;
$alternative_db_folder='flstudio7';
$ext_indexing_dir='../help/';//internal use
$ext_indexing_fname='Index_Frame_Left.htm';//internal use
$more_dirs_to_index=array('help','help/html'); 
$gt_page=f_define_source_page();
$full_self_url=f_build_self_url('search.php');
$full_path_to_script=substr($full_self_url,0,strrpos($full_self_url, "/"));
$db_dir='../'.$f_db_folder;

function get_page_area($content,$foroutput)
{
	global $f_template_source;

	$ts=(strpos($f_template_source,'../')!==false)?$f_template_source:'../'.$f_template_source;
	if($foroutput && file_exists($ts) && strpos($content,'%CONTENT%')!==false) $content='%CONTENT%';
	elseif(strpos($content,'<!--page-->')!==false )	$content=f_GFS($content,'<!--page-->','<!--/page-->');
	else
	{
		$content=str_replace(array('<BODY','</BODY'),array('<body','</body'),$content);
		$pattern=f_GFSAbi($content,'<body','</body>');	
		$body_start_tag=substr($pattern,0,strpos($pattern,'>')+1);
		$content=f_GFSAbi($content, $body_start_tag, '</body>');
	}
	return $content;
}
function get_page_content($fname,$foroutput)
{
	$content=f_read_file($fname);
	$content=get_page_area($content,$foroutput);
	return $content;
}
function GT($fname_buffer,$html_output,$search_string='',$id='',$page_charset='')
{
	global $internal_fl_use,$f_br,$f_ct,$full_path_to_script;

	$content=''; $search_part='';
	$indir=(strpos($fname_buffer, '../')===false);
	$prefix=($indir)?'../':'';
	$fname_buffer_f=$prefix.$fname_buffer;
	$content=f_read_file($fname_buffer_f);

	if(!empty($id))
	{
		if($page_charset!=='')$content=str_replace(f_GFS($content,'charset=','"'),$page_charset,$content);
		if(strpos($content,'<!--search-->')!==false)
		{
			$search_part=$f_br.f_GFS($content,'<!--search-->','<!--/search-->');
			$search_part=str_replace('name="string"','name="string" value="'.str_replace(array('\\"','"'),array('&#34;','&#34;'),f_un_esc($search_string)).'"',$search_part);
		}
	}
	$pattern=get_page_area($content,true);
	if($search_part!='') $html_output=$search_part.$html_output;

	if($internal_fl_use==true) 	$html_output='<table class="main-p" width="952px" cellpadding="0" cellspacing="0"><tr valign="top"><td><h1>Search Result</h1></td></tr></table><table class="main-l" width="952px" cellpadding="0" cellspacing="16"><tr valign="top"><td width="100%"><p>'.$html_output.'</p></td></tr></table><p><img src="images/cap_main.gif" id="cap_main" title="" alt="" style="vertical-align: bottom; width: 952px; height: 8px;"'.$f_ct.'</p>';
	$content=str_replace($pattern,$html_output,$content);	
	if($indir) {$content=str_replace('</title>','</title> <base href="'.str_replace('documents','',$full_path_to_script).'">',$content);}
	$content=f_removeAreas($content);
	return $content;
}
function build_nav_bar($page,$search_string,$show_results,$n_pages,$l_page,$l_results,$l_from,$l_search,$id,$search_in_all,$gt_page)
{
	$dir=(strpos($gt_page,'../')===false)?'documents/':'../documents/';

	$body_section='<span class="rvts8">'.$l_page.'</span>&nbsp;';
	for($i=1; $i<=$n_pages; $i++) 
	{
		if($i==$page) {$body_section.="<span class='rvts8'>$i</span>";}
		else
		{
			$body_section.=' <a class="rvts12" href="'.$dir.'search.php?action=search' .(isset($id)?'&amp;id='.$id:'')
			.'&amp;string='.$search_string.'&amp;mr='.$show_results .'&amp;lr='.$l_results.'&amp;lp='.$l_page.'&amp;lf='.$l_from.'&amp;ls='
			.$l_search.'&amp;page='.$i.'&amp;sa='.$search_in_all.'">'.($i)."</a> ";
		}
	}
	return $body_section;
}
function clear_html_tags($html)
{
	$search_main=array("'<\?php.*?\?>'si","'<script[^>]*?>.*?</script>'si","'<!--footer-->.*?<!--/footer-->'si", "'<!--search-->.*?<!--/search-->'si", "'<!--counter-->.*?<!--/counter-->'si","'<!--mmenu-->.*?<!--/mmenu-->'si","'<!--smenu-->.*?<!--/smenu-->'si","'<!--ssmenu-->.*?<!--/ssmenu-->'si");
	$result=preg_replace($search_main,array("","","","","","","",""),$html);

	$search_more=array ("'<img.*?>'si", "'<a .*?>'si", "'<embed.*?</embed>'si", "'<object.*?</object>'si", "'<select[^>]*?>.*?</select>'si","'<[/!]*?[^<>]*?>'si","'\n'","'\r\n'","'&(quot|#34);'i","'&(amp|#38);'i","'&(lt|#60);'i", "'&(gt|#62);'i","'&(nbsp|#160);'i","'&(iexcl|#161);'i","'&(cent|#162);'i","'&(pound|#163);'i","'&(copy|#169);'i","'&#(d+);'e","'%%USER.*?%%'si", "'%%HIDDEN.*?HIDDEN%%'si","'%%DLINE.*?DLINE%%'si","'%%KEYW.*?%%'si");
	$replace_more=array ("","","","","","","","","\"","&","<",">"," ",chr(161),chr(162),chr(163),chr(169),"chr(\1)","","","","");
	$result=preg_replace($search_more,$replace_more,$result);
	$result=str_replace('%%TEMPLATE1%%','',$result);
	return f_esc($result);
}
function clear_macros($content, $id, $fields=array())
{
	if($id=='136')	//calendar
		$result=preg_replace(array("'%CALENDAR_OBJECT\(.*?\)%'si","'%CALENDAR_EVENTS\(.*?\)%'si","'%CALENDAR_.*?%'si"),array('','',''),$content);	
	elseif($id=='137')	//blog
		$result=preg_replace(array ("'%BLOG_OBJECT\(.*?\)%'si","'%BLOG_ARCHIVE\(.*?\)%'si","'%BLOG_RECENT_COMMENTS\(.*?\)%'si","'%BLOG_RECENT_ENTRIES\(.*?\)%'si","'%BLOG_CATEGORY_FILTER\(.*?\)%'si", "'%BLOG_.*?%'si"),array ('','','','','',''),$content);					
	elseif($id=='138')  //photoblog
		$result=preg_replace(array("'%BLOG_OBJECT\(.*?\)%'si","'%BLOG_EXIF_INFO\(.*?\)%'si","'%ARCHIVE_.*?%'si","'%BLOG_.*?%'si", "'%PERIOD_.*?%'si", "'%CATEGORY_.*?%'si"),array ('','','','','',''),$content);
	elseif($id=='143') //podcast  
		$result=preg_replace(array ("'%PODCAST_OBJECT\(.*?\)%'si","'%PODCAST_ARCHIVE\(.*?\)%'si","'%PODCAST_RECENT_COMMENTS\(.*?\)%'si","'%PODCAST_RECENT_EPISODES\(.*?\)%'si","'%PODCAST_CATEGORY_FILTER\(.*?\)%'si","'%PODCAST_OBJECT\(.*?\)%'si","'%PODCAST_.*?%'si"),array('','','','','','',''),$content);			
	elseif($id=='144')  //guestbook
	{
		$content=preg_replace(array("'%GUESTBOOK_OBJECT\(.*?\)%'si","'%GUESTBOOK_ARCHIVE\(.*?\)%'si","'%GUESTBOOK_ARCHIVE_VER\(.*?\)%'si", "'%GUESTBOOK_.*?%'si"),array('','','',''),$content);
		$result=str_replace(array('%HOME_LINK%','%HOME_URL%'),array('',''),$content);
	}
	elseif(in_array($id,array('21','130','140')))  //lister 
	{
		$a=array_fill(0,17,'');
		$content=preg_replace(array ("'%HASH\(.*?\)%'si","'%ITEMS\(.*?\)%'si","'%SCALE\(.*?\)%'si","'%SHOP_ITEM_DOWNLOAD_LINK\(.*?\)%'si","'%SHOP_CATEGORYCOMBO\(.*?\)%'si","'%SHOP_PREVIOUS\(.*?\)%'si","'%SHOP_NEXT\(.*?\)%'si","'%LISTER_CATEGORYCOMBO\(.*?\)%'si","'%LISTER_PREVIOUS\(.*?\)%'si","'%LISTER_NEXT\(.*?\)%'si","'<!--menu_java-->.*?<!--/menu_java-->'si","'<!--scripts2-->.*?<!--endscripts-->'si","'<!--<pagelink>/.*?</pagelink>-->'si","'<LISTER_BODY>.*?</LISTER_BODY>'si", "'<LISTERSEARCH>.*?</LISTERSEARCH>'si","'<SHOP_BODY>.*?</SHOP_BODY>'si", "'<SHOPSEARCH>.*?</SHOPSEARCH>'si","'%SHOP_.*?%'si","'%LISTER_.*?%'si","'%SLIDESHOWCAPTION_.*?%'si"),$a,$content); 
		$content=str_replace(array ('%ERRORS%','%IDEAL_VALID%','%QUANTITY%','%LINETOTAL%','%LINETOTAL%','%URL=Detailpage%','%CATEGORY_COUNT%','%SEARCHSTRING%'),array ('','','','','','','',''),$content);
		
		$a=array_fill(0,40,'');
		$result=str_replace(array ('<ITEM_VARS>','</ITEM_VARS>','<ITEM_VARS_LINE>','</ITEM_VARS_LINE>','<ITEM_HASHVARS>','</ITEM_HASHVARS>','<SHOP_DELETE_BUTTON>','</SHOP_DELETE_BUTTON>','<MINI_CART>','</MINI_CART>','<SHOP_BUY_BUTTON>','</SHOP_BUY_BUTTON>','<QUANTITY>','<RANDOM>','</RANDOM>','<SHOP>','</SHOP>','<LISTER>','</LISTER>','<ITEM_INDEX>','<ITEM_ID>','<ITEM_QUANTITY>','<ITEM_AMOUNT>','<ITEM_AMOUNT_IDEAL>','<ITEM_VAT>','<ITEM_SHIPPING>','<ITEM_CODE>','<ITEM_SUBNAME>','<ITEM_SUBNAME1>','<ITEM_SUBNAME2>','<ITEM_NAME>','<ITEM_CATEGORY>','<ITEM_VARS>','</ITEM_VARS>','<SHOP_URL>','<BANKWIRE>','</BANKWIRE>','<CATEGORY_HEADER>','</CATEGORY_HEADER>','<FROMCART>'),$a,$content);	

		if(!empty($fields)) {foreach($fields as $k=>$v) $result=str_replace('%'.$v.'%','',$result);}
	}
	$result=str_replace(array('%LINK_TO_ADMIN%','%TAGS_CLOUD%','%FLASH_TAGS_CLOUD%'),array('','',''),$result);
	return $result;
}	
function preg_pos($sPattern,$sSubject,&$occurances,&$score)
{
	global $f_uni;
	
	$sSubject=str_replace(array('&#8221;', '&#8220;', '&#8216;', '&#8217;'), array('�', '�', '�', '�'), $sSubject); 
	$sPattern=f_replace_accents($sPattern);
	$sSubject=f_replace_accents($sSubject);
	$wildcardPos=false;
	if(strpos($sPattern,'*')!==false) { $wildcardPos=strpos($sPattern,'*'); $wc='*'; }
	elseif(strpos($sPattern,'?')!==false) { $wildcardPos=strpos($sPattern,'?'); $wc='?'; }

	if($wildcardPos!==false && $wildcardPos==strlen($sPattern)-1) $sPattern_='/\W('.str_replace($wc,'',$sPattern).')/i';
	elseif($wildcardPos!==false && $wildcardPos==0)     $sPattern_='/('.str_replace($wc,'',$sPattern).')\W/i';
	elseif($wildcardPos!==false) $sPattern_='/('.str_replace($wc,'.\w*?',$sPattern).')\W/i';
	else $sPattern_='/'.($f_uni?'':'\b').'('.$sPattern.')'.($f_uni?'':'\b').'/i';
	$occurances=@preg_match_all($sPattern_,$sSubject,$aMatches,PREG_OFFSET_CAPTURE);
	if($occurances>0)
	{	
		$keywords=explode('|',$sPattern);
		foreach($aMatches[0] as $k=>$v) $temp_arr[]=$v[0];
		$string_with_matches=implode(' ',$temp_arr);
		foreach($keywords as $k=>$word) {if(strpos($string_with_matches,$word)!==false) $score++;}
		return $aMatches;
	}
	else return false;
}
function cut_result($haystack,$needle_pos,$key_words_s)
{
	global $res_bgcolor, $f_uni;
	
	$haystack=str_replace(array('&#8221;', '&#8220;', '&#8216;', '&#8217;'), array('�', '�', '�', '�'), $haystack);
	if(strlen($haystack)>400)
	{
		$x=0; $y=400;
		while(($needle_pos-$x>0) && (substr($haystack,$needle_pos-$x-1, 1)!='.') && (substr($haystack,$needle_pos-$x-1, 1)!='!') && (substr($haystack,$needle_pos-$x-1, 1)!='?') )		{ $x += 1; }  
		while((substr($haystack,$needle_pos+$y, 1)!=' ') && ($needle_pos+$y>$needle_pos) )  { $y-=1; }
		$res_block=substr($haystack,$needle_pos-$x, $x+$y);
	}
	else $res_block=$haystack; 

	$wildcardPos=false;
	if(strpos($key_words_s,'*')!==false)	{ $wildcardPos=strpos($key_words_s,'*'); $wc='*'; $key_words_s=str_replace($wc,'.\w*?',$key_words_s);}
	elseif(strpos($key_words_s,'?')!==false) { $wildcardPos=strpos($key_words_s,'?'); $wc='?'; $key_words_s=str_replace($wc,'.\w*?',$key_words_s);}

	$substr=false;
	$key_words_s_a=explode("|",$key_words_s);
	foreach($key_words_s_a as $k=>$v)
		$res_block=($substr)?preg_replace("/(".$v.")/i", "[;:]$1[:;]",$res_block):preg_replace("/(\W|\A|".($f_uni?'':'\b').")(".$v.")(\W|\Z|".($f_uni?'':'\b').")/i", "$1[;:]$2[:;]$3",$res_block);
	$res_block=str_replace("[;:]",'<span style="background:'.$res_bgcolor.';"><b>', $res_block);
	$res_block=str_replace("[:;]",'</b></span>',$res_block);
	$res_block=$res_block.(strlen($haystack)>100?" <b>...</b> ":" ");
	return $res_block;	
}
function extract_records($fname,$id,$entry_id='')
{
	global $f_max_chars;

	$records=array();

	if(file_exists($fname))
	{
		if($id=='144')
		{
			$records_str=f_read_file($fname);
			if($records_str!='')
			{
				$records_str=f_GFS($records_str,'<entries>','</entries>');
				$records=format_in_array2($records_str);
			}
			if($entry_id!='' && !empty($records)) // when extracting single record
			{
				foreach($records as $k=>$v) { if(in_array($entry_id,$v)) {$temp[]=$v; break;} }
				$records=$temp;
			}
		}
		else 
		{	
			if(filesize($fname)>0)
			{
				$fp=fopen($fname,'r');
				$php_start=fgetcsv($fp,2048);
				$db_field_names=fgetcsv($fp,2048);
				while($data=fgetcsv($fp,$f_max_chars))
				{ 
					if($data[0]!="*/ ?>")
					{
						if($entry_id!='') // when extracting single record
						{
							if($data[0]==$entry_id) { $records[]=format_in_array1($data,$db_field_names); break; }
							else continue;
						}
						else $records[]=format_in_array1($data,$db_field_names);
					}
				}
				fclose($fp);
			}
		}
	}
	return $records;
}
function format_in_array1($value,$key)
{
	$output=array();
	foreach($key as $k=>$v)
	{
		$output[$v]=current($value);
		next($value);
	}
	return $output;
}
function format_in_array2($records)
{
	$entries_array=array();
	$i=1;

	while(strpos($records, '<entry id="'.$i.'">')!==false)
	{
		$comments_buff=array();
		$main_buffer['id']=$i;

		$record='<entry id="'.$i.'">'. f_GFS($records, '<entry id="'.$i.'">', '</entry>').'</entry>';
		$entry_part=f_GFS($record, '<entry id="'.$i.'">', '<comments_data>');
		$comments_part=f_GFS($record, '<comments_data>', '</comments_data>');
		$entry_timetsamp=f_GFS ($entry_part, "<timestamp>", "</timestamp>");

		while(strpos($entry_part, '<')!==false)
		{
			$element_name=f_GFS ($entry_part, '<', '>');
			$element_value=f_GFS ($entry_part, "<$element_name>", "</$element_name>");
			$main_buffer [$element_name]=$element_value;
			$entry_part=str_replace("<$element_name>$element_value</$element_name>", '',$entry_part);
		}
		$j=1;
		while(strpos($comments_part, '<comment id="'.$j.'">')!==false)
		{
			$buff=array();
			$comment_str=f_GFS($comments_part, '<comment id="'.$j.'">', '</comment>');
			while(strpos($comment_str, '<')!==false)
			{
				$element_name=f_GFS ($comment_str, '<', '>');
				$element_value=f_GFS ($comment_str, "<$element_name>", "</$element_name>");
				$buff [$element_name]=$element_value;
				$comment_str=str_replace("<$element_name>$element_value</$element_name>", '',$comment_str);
			}
			$buff['entry_id']=$entry_timetsamp;
			$comments_buff []=$buff;
			$j++;
		}
		$main_buffer ['comments']=$comments_buff;
		$entries_array []=$main_buffer;
		$i++;
	}
	return $entries_array;
}
function db_search($search_string,$key_words_s,$pages_list,$language)
{
	global $site_languages_array,$f_max_chars,$internal_fl_use,$alternative_db_folder,$f_uni,$AccChars,$NormChars,$db_dir, $f_use_linefeed,$f_site_charsets;

	if(!$f_use_linefeed && (strpos($f_site_charsets,'Windows-1251')!==false || $f_uni)) $linux_cyrillic_fl=true; else $linux_cyrillic_fl=false;
	$multi_key=substr_count($key_words_s,'|')>0;
	
	if($f_uni)
	{
		foreach($AccChars as $k=>$v) $AccChars[$k]=utf8_encode($v);
		foreach($NormChars as $k=>$v) $NormChars[$k]=utf8_encode($v);
	}
	$result_pages=array();
	$search_db_fname=array();
	$search_in_all='true';
	$fl=true;

	foreach($site_languages_array as $k=>$v)	// check for auto reindex
	{
		$ff=$db_dir.'search_db_'.($k+1).'.ezg.php';
		if(file_exists($ff)) {$fsize=filesize($ff); if($fsize>0) {$fl=false; break;} }
	}
	if($fl) reindex(true);

	if(isset($_POST['sa'])) $search_in_all=f_strip_tags($_POST['sa']);
	elseif(isset($_GET['sa'])) $search_in_all=f_strip_tags($_GET['sa']);

	if($search_in_all=='true' || $search_in_all=='TRUE')
	{
		foreach($site_languages_array as $k=>$v) {$search_db_fname[]=$db_dir.'search_db_'.($k+1).'.ezg.php';}
	}
	else $search_db_fname[]=$db_dir.'search_db_'.$language.'.ezg.php';

	if($internal_fl_use) $search_db_fname[]='../../'.$alternative_db_folder.'/ezg_data/search_db_1.ezg.php';

	foreach($search_db_fname as $k=>$file)
	{
		$content=f_read_file($file);
		if($content!='')
		{
			foreach($pages_list as $k=>$v) 
			{
				$db_content='';
				$page_id=str_replace('<id>','',$v[10]);

				if(strpos($content, '<page_id_'.$page_id.'>')!==false) 
				{
					$page_info=f_GFS($content,'<page_id_'.$page_id.'>','</page_id_'.$page_id.'>');
					$page_title=f_GFS($page_info,'<page_title>','</page_title>');
					$page_url=f_GFS($page_info,'<page_url>','</page_url>');
					$lm_date=f_GFS($page_info,'<page_date>','</page_date>');

					if($internal_fl_use && (strpos('/flstudio7/',$file)!==false || strpos('/fl7order/',$file)!==false))
					{
						if(strpos('/flstudio7/', $file)!==false)	$page_url=str_replace('../','../../flstudio7/',$page_url);
						elseif(strpos('/fl7order/', $file)!==false) $page_url=str_replace('../','../../fl7order/',$page_url);
					}

					//handling db content
					if(in_array($v[4],array('20','21','130','140','136','138','144','143','137','99')))
					{
						$db_content=f_GFS($page_info,'<db_content>','</db_content>');
						if($db_content!='') 
						{
							$haystack=f_un_esc(urldecode($db_content));
							if($linux_cyrillic_fl) @preg_match_all("/(<id_.*._id>)(.*)(<\/id_.*._id>)/U",$haystack,$entries);
							else @preg_match_all("/(<id_.*._id>)(.*)(<\/id_.*._id>)/U",$haystack,$entries); //\w
							if(is_array($entries))
								foreach($entries[0] as $val)
								{
									$occurances=0;$score=0;
									$matches=preg_pos($key_words_s,$val,$occurances,$score);
									if(is_array($matches))
									{
										$page_url_fixed=$page_url;
										$entry_id=f_GFS($val,'<id_','_id>');
										$entry_data=f_GFS($val,'<id_'.$entry_id.'_id>','</id_'.$entry_id.'_id>');

										if($v[4]=='136') $page_url_fixed.='?event_id='.$entry_id;
										elseif($v[4]=='138') $page_url_fixed.='?photo_id='.$entry_id;
										elseif(in_array($v[4], array('144','143','137'))) $page_url_fixed.='?entry_id='.$entry_id;
										elseif(in_array($v[4], array('21','130','140')))
										{
											$fixed_entry_id=$entry_id;
											if(strpos($entry_id,'_')!==false) 
											{
												$temp=explode('_',$entry_id);
												$cat_id=$temp[0];
												$fixed_entry_id=$temp[1];
											}
											$append_url=(isset($cat_id))?'?action=item&iid='.$fixed_entry_id.'&cat='.$cat_id.'&page=1':'?cat='.$fixed_entry_id;
											$page_url_fixed=(strpos($page_url_fixed,'action=list')!==false)?str_replace('?action=list',$append_url,$page_url_fixed):$page_url_fixed.$append_url;
										}
										elseif($v[4]=='99')
										{
											$ext=(strpos($page_url_fixed,'.htm')!==false)? '.htm': '.php';
											$page_url_fixed=str_replace($ext, '_'.$entry_id.$ext, $page_url_fixed);
										}

										if($multi_key && strpos($entry_data,$search_string)!==false)$score+=100;
										$fixed_pos=$matches[0][0][1]-strlen('<id_'.$entry_id.'_id>');
										$lm_date=f_GFS($entry_data,'%%lm_','_date%%');
										$entry_data=str_replace('%%lm_'.$lm_date.'_date%%','',$entry_data);
										$entry_data=cut_result($entry_data,$fixed_pos,$key_words_s);
										$result_pages["$page_url_fixed"]=array($page_title,$page_url_fixed,$entry_data,$page_id,$lm_date,$occurances,$score);
									}
								}
						}
					}
					//handling main page
					$occurances=0;$score=0;
					$page_content=f_GFS($page_info,'<page_content>','</page_content>');
					$page_content=f_un_esc($page_content);	
					$matches=preg_pos($key_words_s,$page_content,$occurances,$score);
					if(is_array($matches))
					{
						if($multi_key && strpos($page_content,$search_string)!==false)$score+=100;
						$result_pages ["$page_url"]=array($page_title, $page_url,cut_result($page_content,$matches[0][0][1],$key_words_s),$page_id,$lm_date,$occurances,$score);
					}
				}
			}
			if(strpos($content,'<ext_pages>')!==false)
			{
				$ext_content=f_GFS($content,'<ext_pages>','</ext_pages>');
				while(strpos($ext_content,'<page_id_')!==false)
				{
					$occurances=0;$score=0;
					$page_info=f_GFS($ext_content,'<page_id','</page_id');
					$page_title=f_GFS($page_info,'<page_title>','</page_title>');
					$page_url=f_GFS($page_info,'<page_url>','</page_url>');
					$lm_date=f_GFS($page_info,'<page_date>','</page_date>');
					$page_content=f_GFS($page_info,'<page_content>','</page_content>');
					$page_content=f_un_esc($page_content);
						
					$matches=preg_pos($key_words_s,$page_content,$occurances,$score);
					if(is_array($matches))
					{
						if(!array_key_exists("$page_url",$result_pages)) 
						{
							$needle_pos=$matches[0][0][1];
							if($multi_key && strpos($page_content,$search_string)!==false)$score+=100;
							$result_pages ["$page_url"]=array($page_title, $page_url,cut_result($page_content,$needle_pos,$key_words_s),$page_url,$lm_date,$occurances,$score);										
						}
					}
					$ext_content=substr($ext_content,strpos($ext_content,'</page_id')+9);
				}
			}
		}
	}
	return $result_pages;
}
function reindex($auto=false)
{
	global $site_languages_array,$php_pages_ids,$f_max_chars,$rel_path,$f_br,$gt_page,$more_dirs_to_index,$ext_indexing_dir,
		$ext_indexing_fname,$internal_use,$query_st_time,$db_dir;

	$output='';

	foreach($site_languages_array as $kkk=>$vvv)
	{
		$buffer='';
		clearstatcache();
		$search_db_fname=$db_dir.'search_db_'.($kkk+1).'.ezg.php';

		if(file_exists($search_db_fname))
		{
			$page_reindex=(isset($_GET['pid']) && filesize($search_db_fname)>0? true: false);
			if($page_reindex)	$pages_list[]=f_get_page_params(f_strip_tags($_GET['pid']),$rel_path);
			else $pages_list=f_get_sitemap($rel_path);

			if(!$page_reindex) $buffer.="<?php echo 'hi'; exit; /* ";
			foreach($pages_list as $k=>$v)
			{
				$p_lang=array_search ($v[16], $site_languages_array);
				$page_title=(strpos($v[0],'#')!==false && strpos($v[0],'#')==0? str_replace('#','',$v[0]): $v[0]);
				$id=str_replace('<id>', '', $v[10]);

				if(strpos($v[1],'http:')===false && strpos($v[1],'https:')===false && $p_lang==$kkk && $v[20]=='FALSE') // ignore 'HIDDEN in search'
				{
					if(!in_array($v[4],$php_pages_ids))		// for NORMAL pages and PHP REQUEST pages
					{
						$main_fname=(strpos($v[1],'../')===false?'../'.$v[1]:$v[1]);
						$content=f_read_file($main_fname);
						$lm_date=f_GFS($content,'<meta name="date" content="','"');
						$content=get_page_area($content,false);	

						if($v[4]=='99') 
						{
							if(strpos($v[1],'/')===false)  {$i_content=f_read_file('i_'.$main_fname);}
							else { $ff=substr($v[1], strrpos($v[1],'/')+1); $i_content=f_read_file(str_replace($ff, 'i_'.$ff, $v[1]));}					
							if(!empty($i_content)) $i_content=clear_html_tags(get_page_area($i_content,false));	
							$content.=' '.$i_content;

							$db_part='';
							$ext=(strpos($v[1],'.htm')!==false)? '.htm': '.php'; 
							$count=2;
							$more_file=str_replace($ext, '_'.$count.$ext, $main_fname);
							while(file_exists($more_file))
							{
								$db_part.='<id_'.$count.'_id>'.clear_html_tags(get_page_content($more_file,false)).'</id_'.$count.'_id>';		
								$count++;
								$more_file=str_replace($ext, '_'.$count.$ext, $main_fname);
							}
						}
						$buffer.='<page_id_'.$id.'><page_title>'.$page_title.'</page_title><page_date>'.$lm_date.'</page_date><page_url>'
							.$v[1].'</page_url><page_content>'.clear_html_tags($content).'</page_content>'
							.(isset($db_part)? '<db_content>'.$db_part.'</db_content>':'') .'</page_id_'.$id.'>'; 
					}
					else // for special PHP pages 
					{
						$db_part='';
						if(in_array($v[4], array('20','21','130','140'))) // OEP and listers 
						{
							$dir=(strpos($v[1],'../')===false)?'../':'../'.f_GFS($v[1],'../','/').'/';
							if($v[4]=='20')	$main_fname=($v[6]=='TRUE'? $dir.$id.'.php': $dir.$id.'.html');
							else $main_fname=$dir.$id.'.html';
							$content=get_page_content($main_fname,false);
							$content=clear_html_tags($content);
							
							if($v[4]=='20')		// online editable page
							{
								$main_db_content='';
								$db_fname=$db_dir.$id.'.ezg.php';
								if(file_exists($db_fname))
								{
									$lm_date=array(filemtime($db_fname));
									$main_db_content=f_read_file($db_fname);
									
									if(strpos($main_db_content,'<ea_main')!==false) $db_part.=f_GFS($main_db_content,'<ea_main>','</ea_main>');
									$area_id=1;
									while(strpos($main_db_content,'<ea_'.$area_id)!==false)
									{
										$db_part.=f_GFS($main_db_content,'<ea_'.$area_id.'>','</ea_'.$area_id.'>');
										$area_id++;
									}
									$content.=' '.clear_html_tags($db_part);
									$buffer.='<page_id_'.$id.'><page_title>'.$page_title.'</page_title><page_date>'.max($lm_date).'</page_date> <page_url>'.$v[1].'</page_url><page_content>'.$content.'</page_content></page_id_'.$id.'>';
								}
							}
							else // lister and shop pages
							{
								$db_fname=$dir.$id.'_0.dat';
								if(file_exists($db_fname)) 
								{
									$cnt=0;$fs=filesize($db_fname);
									if($fs>0){$fp=fopen($db_fname,"r");$cats=fread($fp,$fs);fclose($fp);$cnt=count(explode("\n",$cats));}

									$fields=array();
									$field_types=array();
									$i=1;
									while($i<$cnt+1 && file_exists($dir.$id.'_'.$i.'.dat')) 
									{
										$db_fname=$dir.$id.'_'.$i.'.dat';	
										$cat_id=$i;
										if(filesize($db_fname)>0)
										{
											$md=filemtime($db_fname);
											$fp=fopen($db_fname, "r");
											$fields=fgetcsv($fp, $f_max_chars,'|');$field_types=fgetcsv($fp, $f_max_chars,'|');
											$t=fgetcsv($fp, $f_max_chars,'|');

											while($item_record=fgetcsv($fp, $f_max_chars,'|')) 
											{
												$db_part.='<id_'.$cat_id.'_'.$item_record[0].'_id>';
												foreach($item_record as $kk=>$vv) 
												{
													if(isset($field_types[$kk]) && in_array($field_types[$kk],array('1','2','13','15')) && $vv!='') $db_part.=clear_html_tags(str_replace('<%23>','#',$vv)).' ';
												}
												$db_part.='%%lm_'.$md.'_date%%';
												$db_part.='</id_'.$cat_id.'_'.$item_record[0].'_id>';
											}
											fclose($fp);
										}
										$i++;
									}
									$db_part=preg_replace("'%SLIDESHOWCAPTION_.*?%'si", "", $db_part);
									$content=clear_macros($content,$v[4],$fields);
									$limit=($v[4]=='21')?4:2;

									for($i=1; $i<=$limit; $i++)
									{
										$add_content=get_page_content($dir.($id+7-$i).'.html',false);
										$add_content=clear_html_tags($add_content);
										$content.=' '.clear_macros($add_content,$v[4],$fields);
									}
									$add_content='';
									$buffer.='<page_id_'.$id.'><page_title>'.$page_title.'</page_title><page_url>'.$v[1].'</page_url><page_content>'
									.$content.'</page_content><db_content>'.$db_part.'</db_content></page_id_'.$id.'>';
								}
							}//end listers
						}
						elseif(in_array($v[4],array('133')))			// subscribe page
						{
							$dir=(strpos($v[1],'../')===false)?'../':'../'.f_GFS($v[1],'../','/').'/';

							if(empty($v[9])) $fname=($v[6]=='TRUE'? $dir.$id.'.php': $dir.$id.'.html');
							elseif(strpos($v[9],'.')===false) $fname=($v[6]=='TRUE'? $dir.$v[9].'.php': $dir.$v[9].'.html');	
							else $fname=$dir.$v[9];							
							$content=f_read_file($fname);	
							$lm_date=f_GFS($content,'<meta name="date" content="','"');
							$content=get_page_area($content,false);		
							$content=clear_html_tags($content); 
							$buffer.='<page_id_'.$id.'><page_title>'.$page_title.'</page_title><page_date>'.$lm_date.'</page_date><page_url>'.$v[1]. '</page_url><page_content>'.$content.'</page_content></page_id_'.$id.'>';
						}
						elseif(in_array($v[4],array('136','137','138','143','144')))  //blog, pblog, cal, podcast, guestbook
						{
							$dir=(strpos($v[1],'../')===false)?'../':'../'.f_GFS($v[1],'../','/').'/';
							$main_fname=($v[6]=='TRUE'? $dir.$id.'.php': $dir.$id.'.html');  	
							$content=get_page_content($main_fname,false);	
							
							if($v[4]=='138')
							{
								$fname_arch=$dir.($id+1).'.html';
								$content.=get_page_content($fname_arch,false);
							}
							$content=clear_html_tags($content);
							$content=clear_macros($content, $v[4]);
							$dir='../'.f_GFS($v[1],'../','/').'/';

							if(in_array($v[4], array('137', '138', '143')))		// blog, photoblog, podcast
							{
								$db_fname=$db_dir.$id.'_db_blog_entries.ezg.php';
								if(!$page_reindex) $entries_records=extract_records($db_fname, $v[4]);
								elseif(isset($_GET['entryid'])) $entries_records=extract_records($db_fname, $v[4],f_strip_tags($_GET['entryid']));
								
								if(!empty($entries_records)) 
								{
									foreach ($entries_records as $key=>$val) 
									{
										$db_part.='<id_'.$val['Id'].'_id>'.clear_html_tags(urldecode($val['Title']));
										if($v[4]=='143') 
										{
											if(!empty($val['Subtitle'])) $db_part.=' '.clear_html_tags(urldecode($val['Subtitle']));
											if(!empty($val['Author']))	 $db_part.=' '.clear_html_tags(urldecode($val['Author']));
										}
										if(!empty($val['Content'])) $db_part.=' '.clear_html_tags(urldecode($val['Content']));
										$db_part.='%%lm_'.$val['Last_Modified'].'_date%%';
										$db_part.='</id_'.$val['Id'].'_id>';
									}
								}
								if(!empty($db_part))
								{
									$comments_records=extract_records($db_dir.$id.'_db_blog_comments.ezg.php', $v[4]);
									if (!empty($comments_records)) 
									{
										foreach ($comments_records as $key=>$val) 
										{
											$m='</id_'.($v[4]=='138'?$val['Photo_Id']:$val['Entry_Id']).'_id>';
											$db_part=str_replace($m,' '.clear_html_tags(urldecode($val['Visitor'])).$m, $db_part);
											if(!empty($val['Comments']))
											{
												$db_part=str_replace($m,' '.clear_html_tags(urldecode($val['Comments'])).$m, $db_part);
											}
										}
									}
								}
							}
							elseif(in_array($v[4], array('136')))   // calendar
							{
								$db_fname=$db_dir.$id.'_cal_events.ezg.php';
								if(!$page_reindex) $entries_records=extract_records($db_fname,$v[4]);
								elseif(isset($_GET['entryid'])) $entries_records=extract_records($db_fname,$v[4],f_strip_tags($_GET['entryid']));

								if(!empty($entries_records))
								{
									foreach($entries_records as $key=>$val)
									{
										$db_part.='<id_'.$val['Id'].'_id>'.clear_html_tags(urldecode($val['Short_description']));
										if(!empty($val['Details'])) $db_part.=' '.clear_html_tags(urldecode($val['Details']));
										if(!empty($val['Location'])) $db_part.=' '.clear_html_tags(urldecode($val['Location']));
										$db_part.='%%lm_'.filemtime($db_fname).'_date%%';
										$db_part.='</id_'.$val['Id'].'_id>';
									}
								}
							}
							elseif(in_array($v[4], array('144')))   // guestbook
							{
								$db_fname=$db_dir.$id.'_db_guestbook.ezg.php';
								if(!$page_reindex)				$entries_records=extract_records($db_fname,$v[4]);
								elseif(isset($_GET['entryid'])) $entries_records=extract_records($db_fname,$v[4],f_strip_tags($_GET['entryid']));
								
								if(!empty($entries_records))
								{
									foreach ($entries_records as $key=>$val)
									{
										$db_part.='<id_'.$val['timestamp'].'_id>'.clear_html_tags(urldecode($val['name']));
										if(!empty($val['surname'])) $db_part.=' '.clear_html_tags(urldecode($val['surname']));
										$db_part.=' '.clear_html_tags(urldecode($val['content'])); 
										if(!empty($val['country'])) $db_part.=' '.clear_html_tags(urldecode($val['country']));
										foreach($val['comments'] as $ka=>$va)
										{
											if(!empty($va))
											{
												$db_part.=' '.clear_html_tags(urldecode($va['visitor']));
												$db_part.=' '.clear_html_tags(urldecode($va['comments']));
											}
										}
										$db_part.='%%lm_'.$val['timestamp'].'_date%%';
										$db_part.='</id_'.$val['timestamp'] .'_id>';
									}
								}
							}
							if(!$page_reindex)
							{	
								$buffer.='<page_id_'.$id.'><page_title>'.$page_title.'</page_title><page_url>'.$v[1].'</page_url><page_content>' .$content.'</page_content>'.'<db_content>'.$db_part.'</db_content>'.'</page_id_'.$id.'>';
							}
							else $buffer.=$db_part;
							$db_part='';
						}
					}
					$content='';
				}
			}
			if(!$page_reindex)
			{
				$buffer.='<ext_pages>';
				if(!empty($more_dirs_to_index))
				{
					$file_list=array();
					foreach($more_dirs_to_index as $d_k=>$d_v)
					{
						$dir_to_index='../'.$d_v;
						if(is_dir($dir_to_index))
						{
							$handle=opendir($dir_to_index);
							while($file=readdir($handle)) //problem with php pages
							{
								if( ($file!='.') && ($file!='..') && (strpos($file,".htm")!==false || strpos($file,".php")!==false || strpos($file,".HTM")!==false || strpos($file,".PHP")!==false) )  { $file_list[]=$dir_to_index.'/'.$file; }
							}
						}
					}
					foreach($file_list as $f_k=>$f_v)
					{
						if(file_exists($f_v) && filesize($f_v)>0)
						{
							$p_content=f_read_file($f_v);
							$p_title=f_GFS($p_content,'<title>','</title>');
							if(empty($p_title)) $p_title=f_GFS($p_content,'<TITLE>','</TITLE>');
							if(empty($p_title)) $p_title=f_GFS($p_content,'<p class="pagetitle">','<p>');
							if(empty($p_title)) $p_title=$f_v;
							$p_title=clear_html_tags($p_title);
							$lm_date=f_GFS($p_content,'<meta name="date" content="','"');
							if(empty($lm_date)) $lm_date=f_GFS($p_content,'<META name="date" content="','"');
							if(empty($lm_date)) $lm_date=filemtime($f_v);
							$p_content=get_page_area($p_content,false);
							$p_content=clear_html_tags($p_content);
							$buffer.='<page_id_'.$f_v.'><page_title>'.$p_title.'</page_title><page_date>'.$lm_date.'</page_date><page_url>'.$f_v. '</page_url><page_content>'.$p_content.'</page_content></page_id_'.$f_v.'>';
							$p_content='';
						}
					}
				}
				if($internal_use && $kkk==0) //FL and EZG only
				{
					$links=array();
					$f=$ext_indexing_dir.$ext_indexing_fname;
					if(file_exists($f)&& filesize($f)>0)
					{
						$file_contents = f_read_file($f);				
						while(strpos($file_contents,'<A HREF="')!==false)
						{
							$link=f_GFS($file_contents,'<A HREF="','">');
							$title=f_GFS($file_contents,'<A HREF="'.$link.'">','</A>');
							$links[$title]=$ext_indexing_dir.str_replace('%20',' ',$link);
							$file_contents=substr($file_contents, strpos($file_contents,'<A HREF="')+9);
						}
						foreach($links as $m=>$url)
						{
							$p_content=f_read_file($url);
							$lm_date=f_GFS($p_content,'<meta name="date" content="','"');
							if(empty($lm_date)) $lm_date=f_GFS($p_content,'<META name="date" content="','"');
							if(empty($lm_date)) $lm_date=filemtime($f);
							$p_content=get_page_area($p_content,false);
							$p_content=clear_html_tags($p_content);
							$buffer.='<page_id_'.$url.'><page_title>'.$m.'</page_title><page_date>'.$lm_date.'</page_date><page_url>'.$url. '</page_url><page_content>'.$p_content.'</page_content></page_id_'.$url.'>';
							$p_content='';
						}
					}
				}
				$buffer.='</ext_pages>';
				$buffer.=" */ ?>";
			}

			if(!empty($buffer))
			{
				if(!$page_reindex)
				{if(!$fp=@fopen($search_db_fname,"w")) {print f_fmt_in_template($gt_page,f_fmt_error_msg('DBFILE_NEEDCHMOD',$search_db_fname));exit;}}
				else
				{if(!$fp=@fopen($search_db_fname,"r+")) {print f_fmt_in_template($gt_page,f_fmt_error_msg('DBFILE_NEEDCHMOD',$search_db_fname));exit;} }

				flock($fp, LOCK_EX);
				if($page_reindex)
				{ 
					$db_existing_content=fread($fp,filesize($search_db_fname));  $pg=f_strip_tags($_GET['pid']);	
					if(isset($_GET['entryid']) && strpos($db_existing_content,'<page_id_'.$pg.'>')!==false) 
					{
						$en_id=f_strip_tags($_GET['entryid']);
						$page_for_repl=f_GFSAbi($db_existing_content,'<page_id_'.$pg.'>','</page_id_'.$pg.'>');
						if(strpos($page_for_repl,'<id_'.$en_id.'_id>')!==false)
						{
							$for_repl=f_GFSAbi($page_for_repl,'<id_'.$en_id.'_id>','</id_'.$en_id.'_id>');
							$db_existing_content=str_replace($for_repl,$buffer,$db_existing_content);
						}
						else
						{ 
							$buffer=str_replace('</db_content>',$buffer.'</db_content>',$page_for_repl);
							$db_existing_content=str_replace($page_for_repl,$buffer,$db_existing_content);
						}
					}
					else break;
					$buffer=$db_existing_content;
					ftruncate($fp,0);
					fseek($fp,0);
				}
				if(fwrite($fp, $buffer)===FALSE) { print "Cannot write to file ($search_db_fname)"; exit;}
				flock($fp,LOCK_UN);
				fclose($fp);
				$output=$f_br.f_fmt_admin_title('Site Search successfully reindexed!').$f_br;
			}
		}
		elseif($auto==false && !isset($_GET['redirect'])) {$output=f_fmt_error_msg('MISSING_DBFILE',$search_db_fname);}	
	}
	//$output.=$f_br.'<div align="right"><span class="rvts8" style="font-size:9px;">Page created in '.round(f_microtime_float() - $query_st_time,4) .' seconds</span></div>'; 
	if($auto==false && !isset($_GET['redirect']))
	{
		$output=GT($gt_page,$output);
		print $output;
	}
	if(isset($_GET['redirect']))  // auto reindex after online update
	{
		$redirect_url=f_strip_tags($_GET['redirect']);
		f_url_redirect('../'.$redirect_url,false,' />');
	}
}
function process_search() 
{
	global $site_languages_array, $rel_path, $version, $f_http_prefix, $f_br, $gt_page, $query_st_time, $f_uni;
	
	$query_st_time=f_microtime_float();
	$root=(strpos($gt_page, '../')===false)?'':'../';
	$action_id=''; if(isset($_REQUEST['action'])) $action_id=f_strip_tags($_REQUEST['action']); //m

	if($action_id=="search")
	{
		$body_section='';$search_string='';$id='';$page_info='';$language=1;
		$pages_list=f_get_sitemap($rel_path);
		if(isset($_REQUEST['id']))
		{
			$id=f_strip_tags($_REQUEST['id']);
			foreach($pages_list as $k=>$v) { if(strpos($v[10],'<id>'.$id)!==false) {$page_info=$v;break;} }
			if($page_info!='') $language=array_search($page_info[16],$site_languages_array)+1;	
		}
	
		$show_results=(isset($_REQUEST['mr']) && !empty($_REQUEST['mr']))?f_strip_tags($_REQUEST['mr']):10;
		$l_results=(isset($_REQUEST['lr']) && !empty($_REQUEST['lr']))?f_strip_tags($_REQUEST['lr']):'Results';
		$l_page=(isset($_REQUEST['lp']) && !empty($_REQUEST['lp']))?f_strip_tags($_REQUEST['lp']):'Page';
		$l_from=(isset($_REQUEST['lf']) && !empty($_REQUEST['lf']))?f_strip_tags($_REQUEST['lf']):'from';
		$l_search=(isset($_REQUEST['ls']) && !empty($_REQUEST['ls']))?f_strip_tags($_REQUEST['ls']):'Search';
		$l_empty=(isset($_REQUEST['em']))?f_strip_tags($_REQUEST['em']):'';
		$page=(isset($_REQUEST['page']))?f_strip_tags($_REQUEST['page']):1;
		$search_in_all=(isset($_REQUEST['sa']))?f_strip_tags($_REQUEST['sa']):'true';
		settype($page,"integer"); settype($show_results,"integer");

		if(isset($_REQUEST['string']))
		{
			$search_string=f_un_esc(f_strip_tags(trim($_REQUEST['string'])));
			if($search_string=='') $body_section.='<br>'.$l_empty;
			else
			{
				$q_pos=strpos($search_string,'"'); // opening " (if used)
				$qs_pos=strpos($search_string,'\"');
				$qcl_pos=strrpos($search_string,'"'); // closing " (if used)
				if( (($q_pos!==false && $q_pos==0) || ($qs_pos!==false && $qs_pos==0)) && $qcl_pos==(strlen($search_string)-1))
				{
					$search_string=substr($search_string,1,strlen($search_string)-2);
					if(strpos($search_string,'\\')!==false) $search_string=substr($search_string,1,strlen($search_string)-2);
					$key_words=array($search_string);
				}
				else { $key_words=(strpos($search_string,' ')!==false? explode(' ',$search_string): array($search_string));}

				$key_words_trimmed=array();
				foreach($key_words as $k=>$v)  { if($v!='') {$key_words_trimmed[]=trim($v);} }
				$key_words_s=implode('|', $key_words_trimmed);

				$results=db_search($search_string,$key_words_s,$pages_list,$language);

				$body_section.='<table style="width:100%;">';
				$count_res=count($results);
				$first_id=(($page-1)*$show_results+1);
				$last_id=($show_results*$page>$count_res?$count_res:$show_results*$page);
				$main_result='';
				$main_result_head='<tr><td></td><td><span class="rvts24"><b>'.$l_results.': '.f_sth($search_string).'</b></span>'.$f_br.'<span class="rvts8">';

				$main_result_head.=(empty($results))?'<i>- '.$count_res.' -</i></span>':($f_br.'<b>'.$first_id.' - '
					.$last_id.'</b></span> <span class="rvts8"><i>'.$l_from.'</i></span> <span class="rvts8"><b>'.$count_res.'</b></span>');
				$main_result_head.=$f_br.'</td></tr>'; 

				if(!empty($results))
				{
					if($show_results!=0)
					{
						$n_pages=($count_res%$show_results==0? $count_res/$show_results: ceil($count_res/$show_results));
						if($count_res>$show_results)
						{
							$main_result.='<tr><td></td><td align="right">'.build_nav_bar($page,urlencode($search_string),$show_results,$n_pages,$l_page,$l_results,$l_from,$l_search,$id,$search_in_all,$gt_page).$f_br.'</td></tr>';	
						}
					}
					foreach($results as $key=>$row) { $by_score[$key]=$row[6]; $by_occur[$key]=$row[5]; } 
					if(count($key_words)>1) array_multisort($by_score,SORT_DESC, $by_occur,SORT_DESC,$results);
					else array_multisort($by_occur,SORT_DESC,$results);

					$results_cut=(count($results)>$show_results && $show_results!=0)?array_slice($results,($page-1)*$show_results,$show_results):$results; 

					$counter=($page-1)*$show_results;
					foreach($results_cut as $k=>$v)
					{
						$counter++;
						$lm_date='';
						if(isset($v[4]) && !empty($v[4]))
						{
							if(strpos($v[4],'-')!==false)
							{
								list($year,$month,$day)=explode('-',$v[4]);
								$lm_date=date('j M Y', mktime(0,0,0,(integer)$month,(integer)$day,(integer)$year)).' - ';
							}
							else $lm_date=date('j M Y', $v[4]).' - ';
						}
						if(strpos($gt_page, '../')===false)	$url=str_replace('../','',$v[1]);
						else $url=(strpos($v[1], '../')===false)? '../'. $v[1]:$v[1]; 
						$main_result.="<tr><td valign='top'><span class='rvts0'><b>".$counter.". </b></span></td>"
						."<td><a class='rvts4' href='".$url."'>".$v[0]."</a>".$f_br."<span class='rvts8'>".$v[2]."</span>".$f_br 
						."<span class='rvts8'><i># ".($f_uni? '': $v[5].' - ').$lm_date."URL: ".$f_http_prefix .str_replace('documents','',$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])) .str_replace('../','',$v[1])."</i></span>".$f_br.$f_br."</td></tr>"; 
					}
				}

				$forum_search=false;$forum_result='';$kb_result='';$flstudio_results='';
//***

//***
				if($forum_search) $body_section.=$forum_result.$f_br.$main_result_head.$main_result.$kb_result.$flstudio_results;
				else $body_section.=$main_result_head.$main_result.$kb_result.$forum_result.$flstudio_results;

				$body_section.='</table>';
				//$body_section.=$f_br.'<div align="right"><span class="rvts8" style="font-size:9px;">Page created in '.round(f_microtime_float() - $query_st_time,4) .' seconds</span></div>'; 
			}
		}
		if(isset($page_info[17])){$pi=$page_info[17];} else $pi='';
		$output=GT($gt_page, $body_section, $search_string,$id,$pi);
		if(isset($forum_result) && $forum_result!='')
			$output=str_replace('<meta name="generator"','<link type="text/css" href="../documents/search.css" rel="stylesheet">'.'<meta name="generator"',$output);
		print $output;
	}
	elseif($action_id=="reindex") reindex();
	elseif($action_id=="version")	echo $version;
	/*elseif(isset($_GET['page']) && isset($_GET['highlight']))
	{
		$result_page = '../'.$_GET['page'];
		$f_content = f_read_file($result_page);
		if(strpos($_GET['page'], '/')===false) { $f_content = str_replace('</title>', 
			'</title> <base href="http://'.$_SERVER['HTTP_HOST'].str_replace('documents','',dirname($_SERVER['PHP_SELF'])).'">',$f_content); }
		$p_content = get_page_area($f_content, true);
		
		$key_words_s = urldecode($_GET['highlight']);
		//$key_words_s = preg_quote($key_words_s);
		if(strpos($key_words_s,'*')!==false)	
			{ $wildcardPos = strpos($key_words_s,'*'); $wc='*'; $key_words_s = str_replace('*', '.w*?', $key_words_s); }
		elseif(strpos($key_words_s,'?')!==false) 
			{ $wildcardPos = strpos($key_words_s,'?'); $wc='?'; $key_words_s = str_replace('?', '.\w*?', $key_words_s); }
		else { $wildcardPos = false; }

		$pattern = '$1$2<span style="background: #FFFF40;">$3</span>$4$5';
		//$h_content=preg_replace('#(<[^/][^>]*>.*?\b|\W)('.$key_words_s.')(b|\W</[^>]*>)?#msi', $pattern, $p_content);
		$h_content=preg_replace('#(<[^/][^>]*>)(.*?)('.$key_words_s.')(.*?)(</[^>]*>)?#msi', $pattern, $p_content);
		if($wildcardPos!==false)	
		{ 
			$h_content = preg_replace('#(<[^/][^>]*>)(.*?)('.str_replace($wc,'',$key_words_s).')(.*?)(</[^>]*>)?#msi', $pattern, $h_content);	
		}
		$f_content = str_replace($p_content,$h_content,$f_content);
		print $f_content;
	}*/
}

process_search();
?>