<table cellpadding="0" cellspacing="0" style="margin:2px 0px;"><tr><td class="btm">
<?php 
if (ismode()){
	include "../last_gal.php";
}else{echo "&nbsp;";}
?>
</td><td style="width:90%;padding:3px;" class="btm"><p class="sm btm" style="padding:3px;">&nbsp;</p></tr></table>

<FORM class="black_block sm" style="color:#FCCE92;font-size: smaller;" METHOD="POST" id="fchangedirect" action="online.php?p=<?php echo $_GET['p'];  ?>&u=1<?php if(isset($_GET['tag'])){echo "&tag=" . $_GET['tag'];} ?>">
<?php 
genfndf("restrict_find");
genfndf("user_name");
?>
<input class="cinline" title="Также искать строку в дополнительном поле" name="in_name" type="Checkbox" <?php if ($_POST['in_name'] == 'on'){echo " checked";}elseif (empty($_POST['user_name'])){echo " checked";} ?> onclick="javascript:if(event.ctrlKey == false){document.getElementById('fchangedirect').submit();}"><input class="cinline" title="Также искать строку в поле описания (медленный поиск)" name="in_desk" type="Checkbox" <?php if ($_POST['in_desk'] == 'on'){echo " checked";}elseif (empty($_POST['user_name'])){echo " checked";} ?> onclick="javascript:if(event.ctrlKey == false){document.getElementById('fchangedirect').submit();}">&nbsp;В поле /&nbsp;В описании</FORM>

<?php
if (isset($_POST['user_name']) and $_POST['user_name']<>"" and $_POST['user_name'] <> "Введите слово или жмите Enter"){
$_POST['user_name'] = addslashes($_POST['user_name']);
finds5last_set($_GET['p'], $_POST['user_name']);
switch($_POST['restrict_find']){
case "1": $_POST['user_name'] = "%" . $_POST['user_name'] . "%";break;
case "2": $_POST['user_name'] .= "%";break;
case "3": $_POST['user_name'] = "%" . $_POST['user_name'];break;
}

unset($tmp2);

for($k=1;$k<=count($obase);$k++){
$query = "select name, word2, jobid from obd_" . (99+$k*2) . " where 1=1";
if ($_POST['user_name'] <> ""){
	$query = $query . " and (name like '" . $_POST['user_name'];
	if (isset($_POST['in_name']) == 'on'){$query = $query . "' or word2 like '" . $_POST['user_name'];}
	if (isset($_POST['in_desk']) == 'on'){$query = $query . "' or desk like '" . $_POST['user_name'];}
	$query = $query . "')";
}

$result = mysql_query($query);
$num_result = mysql_num_rows($result);
if ($num_result){$tmp2[] = array($k, $num_result);}
}


//проверка лимита
$z = count($tmp2);
if (isset($_GET['l'])){$i = $_GET['l'];}else{$i = 0;}
?>
<div class="black_block_c">
<?php
	if ($z){
		
	if (isset($_POST['restrict_find'])){
		if (empty($_SESSION['back1_restrict_find'])){$_SESSION['back1_restrict_find'] = $_POST['restrict_find'];
		}elseif (empty($_SESSION['back2_restrict_find'])){$_SESSION['back2_restrict_find'] = $_POST['restrict_find'];
		}else {$_SESSION['back1_restrict_find'] = $_SESSION['back2_restrict_find'];$_SESSION['back2_restrict_find'] = $_POST['restrict_find'];}
	}else{
		if (empty($_SESSION['back1_restrict_find'])){$_SESSION['back1_restrict_find'] = "none";
		}elseif (empty($_SESSION['back2_restrict_find'])){$_SESSION['back2_restrict_find'] = "none";
		}else {$_SESSION['back1_restrict_find'] = $_SESSION['back2_restrict_find'];$_SESSION['back2_restrict_find'] = "none";}
	}

	if (isset($_POST['user_name'])){
		if (empty($_SESSION['back1_user_name'])){$_SESSION['back1_user_name'] = substr_replace('%', '', $_POST['user_name']);
		}elseif (empty($_SESSION['back2_user_name'])){$_SESSION['back2_user_name'] = substr_replace('%', '', $_POST['user_name']);
		}else {$_SESSION['back1_user_name'] = $_SESSION['back2_user_name'];$_SESSION['back2_user_name'] = substr_replace('%', '', $_POST['user_name']);}
	}else{
		if (empty($_SESSION['back1_user_name'])){$_SESSION['back1_user_name'] = "none";
		}elseif (empty($_SESSION['back2_user_name'])){$_SESSION['back2_user_name'] = "none";
		}else {$_SESSION['back1_user_name'] = $_SESSION['back2_user_name'];$_SESSION['back2_user_name'] = "none";}
	}

	if ($_POST['in_desk'] == 'on'){
		if (empty($_SESSION['back1_in_desk'])){$_SESSION['back1_in_desk'] = 'on';
		}elseif (empty($_SESSION['back2_in_desk'])){$_SESSION['back2_in_desk'] = 'on';
		}else {$_SESSION['back1_in_desk'] = $_SESSION['back2_in_desk'];$_SESSION['back2_in_desk'] = 'on';}
	}else{
		if (empty($_SESSION['back1_in_desk'])){$_SESSION['back1_in_desk'] = "none";
		}elseif (empty($_SESSION['back2_in_desk'])){$_SESSION['back2_in_desk'] = "none";
		}else {$_SESSION['back1_in_desk'] = $_SESSION['back2_in_desk'];$_SESSION['back2_in_desk'] = "none";}
	}

	if ($_POST['in_name'] == 'on'){
		if (empty($_SESSION['back1_in_name'])){$_SESSION['back1_in_name'] = 'on';
		}elseif (empty($_SESSION['back2_in_name'])){$_SESSION['back2_in_name'] = 'on';
		}else {$_SESSION['back1_in_name'] = $_SESSION['back2_in_name'];$_SESSION['back2_in_name'] = 'on';}
	}else{
		if (empty($_SESSION['back1_in_name'])){$_SESSION['back1_in_name'] = "none";
		}elseif (empty($_SESSION['back2_in_name'])){$_SESSION['back2_in_name'] = "none";
		}else {$_SESSION['back1_in_name'] = $_SESSION['back2_in_name'];$_SESSION['back2_in_name'] = "none";}
	}


		$k = $i;
		for($i;$i<count($tmp2) and $i< $k + $_SESSION['listnumb'];$i++){
?>
<div class="p_block"><?php
echo "<span style='font-weight : bold;'>[&nbsp;";
	echo $i + 1;
echo  "&nbsp;]</span> "; ?>



<a class="a_show_hide" title="Открыть базу данных" href='<?php echo 'javascript:document.getElementById("to_back").setAttribute("action", "online.php?p=' . (99 + $tmp2[$i][0]*2) . '");' . 'document.getElementById("to_back").submit();';  ?>'>
<?php echo $obase[$tmp2[$i][0]][0]; ?></a>
</div>
<p class="sm" style="padding:0px 7px;">
Количество совпадений: <?php echo $tmp2[$i][1]; ?>
</p>
<?php
	}
	}else{
		none_project();
	}
?>
</div>
<?php
require "../find_project_res.php";
}
?>
<div class="ssm">Если нужно установить/сбросить флажок без отправки запроса поиска, при его модификации зажмите CTRL.</div>
<?php finds5last_get($_GET['p']); ?>
</td></tr></table>