View file search.php

File size: 8.63Kb
<?php
/**********************************************/
/* Автор скрипта: Александр Есин              */
/* E-Mail: [email protected] ([email protected]) */
/* ICQ: 6464729                               */
/* Site: http://ticlove.ru                    */
/**********************************************/
?>
<?php define ('SECURED', true); ?>
<?php require (dirname(__FILE__).'/_inc/sql.php'); ?>
<?php require (dirname(__FILE__).'/_inc/config.php'); ?>
<?php require (dirname(__FILE__).'/_inc/function.php'); ?>
<?php $title_page = 'Поиск анкет'; ?>
<?php $description_page = 'Поиск анкет'; ?>
<?php $keywords_page = 'Поиск анкет'; ?>
<?php
if ($_GET['new'] == true)
	 {
	      unset($_SESSION['action']);
	      unset($_SESSION['zapros']);
	      header('Location: http://'.$_SERVER['HTTP_HOST'].'/search/');
	      exit;
	 }
	 
	 //.....................................................................................................................................//
	 if (isset($_POST['action']))
	 {
	      $_SESSION['action'] = 1;
	      
	      $ya_search = (int)$_POST['ya_search'];
	      $ot = (int)$_POST['ot'];
	      $do = (int)$_POST['do'];
	      $country_id = intval($_POST['sel_country']);
	      $region_id = intval($_POST['sel_region']);
	      $city_id = intval($_POST['sel_city']);
	      $photo = intval($_POST['photo']);
	      $online = intval($_POST['online']);
	      $new = intval($_POST['new']);
	      $dr = intval($_POST['dr']);
	      $vip = intval($_POST['vip']);
	      
	      $country_sql = mysql_query("SELECT * FROM `q_country` WHERE `id_country` = '".$country_id."' LIMIT 1");
	      $region_sql = mysql_query("SELECT * FROM `q_region` WHERE `id_region` = '".$region_id."' LIMIT 1");
	      $city_sql = mysql_query("SELECT * FROM `q_city` WHERE `id_city` = '".$city_id."' LIMIT 1");
	      
	      $country_array = mysql_fetch_array($country_sql);
	      $region_array = mysql_fetch_array($region_sql);
	      $city_array = mysql_fetch_array($city_sql);
	      
	      if ($ya_search < 0 or $ya_search > 2) $ya_search = 0;
	      if ($photo < 0 or $photo > 1) $photo = 0;
	      if ($online < 0 or $online > 1) $online = 0;
	      if ($new < 0 or $new > 1) $new = 0;
	      if ($dr < 0 or $dr > 1) $dr = 0;
	      if ($vip < 0 or $vip > 1) $vip = 0;
	      
	      $_SESSION['zapros'] = '';
	      if ($ya_search == 0) $_SESSION['zapros'] .= " WHERE (`q_users`.`pol` = '1' OR `q_users`.`pol` = '2')";
	      else $_SESSION['zapros'] .= " WHERE (`q_users`.`pol` = '".$ya_search."')";
	      if (!empty($ot)) $_SESSION['zapros'] .= " AND (`q_users`.`god` <= '".(date('Y') - $ot)."')";
	      if (!empty($do)) $_SESSION['zapros'] .= " AND (`q_users`.`god` >= '".(date('Y') - $do)."')";
	      if (!empty($country_array['name_country'])) $_SESSION['zapros'] .= " AND (`q_users`.`country` = '".function_sql($country_array['name_country'])."')";
	      if (!empty($region_array['name_region'])) $_SESSION['zapros'] .= " AND (`q_users`.`region` = '".function_sql($region_array['name_region'])."')";
	      if (!empty($city_array['name_city'])) $_SESSION['zapros'] .= " AND (`q_users`.`city` = '".function_sql($city_array['name_city'])."')";
	      
	      if (!empty($photo)) $_SESSION['zapros'] .= " AND (`q_users`.`photo` > '0')";
	      if (!empty($online)) $_SESSION['zapros'] .= " AND (`q_users`.`online` > '".time()."')";
	      if (!empty($new)) $_SESSION['zapros'] .= " AND (`q_users`.`reg_date` > '".(time() - (NEW_USER * 24 * 3600))."')";
	      if (!empty($dr)) $_SESSION['zapros'] .= " AND (`q_users`.`day` = '".date('j')."' AND `q_users`.`mes` = '".date('n')."')";
	      if (!empty($vip)) $_SESSION['zapros'] .= " AND (`q_users`.`vip_status` > '0')";
	      
	      header('Location: http://'.$_SERVER['HTTP_HOST'].'/search/');
	      exit;
	 }
	 //.....................................................................................................................................//
?>
<?php include (dirname(__FILE__).'/include/header.php'); ?>
<div id="block_left">
<?php include (dirname(__FILE__).'/include/lider.php'); ?>
</div>
<div id="content_page">
<?php if (empty($_SESSION['action'])) include (dirname(__FILE__).'/include/poisk.php'); ?>
<?php
$col = USERS_ALL_PAGE;
if (isset($_GET['start'])) $start = abs(intval($_GET['start']));
else $start = 0;
$count_p = mysql_result(mysql_query("SELECT COUNT(*) FROM `q_anketa` INNER JOIN `q_users` ON `q_users`.`id_user` = `q_anketa`.`id_user` ".$_SESSION['zapros'].";"), 0);
if ($count_p > 0) {
?>
<div class="left" style="padding-top: 20px;">
<div class="tit_zag">Результаты поиска: <?php echo $count_p; ?></div>
</div>
<div class="left" style="padding-top: 20px; padding-left: 10px;">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?new=true">Новый поиск</a>
</div>
<div class="clear"></div>
<div class="tit_zag_hr"></div>
<?php
if ($start >= $count_p) $start = 0;
$q = mysql_query("SELECT * FROM `q_anketa` INNER JOIN `q_users` ON `q_users`.`id_user` = `q_anketa`.`id_user` ".$_SESSION['zapros']." ORDER BY `q_users`.`top_search` DESC LIMIT ".$start.", ".$col);
?>
<?php $i = 1; ?>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<?php while ($array = mysql_fetch_array($q)) { ?>
<td width="50%" valign="top" style="padding-top: 10px; padding-left: 15px; padding-right: 15px; <?php echo ($i == 1 ? 'border-right: 1px solid #ccc;' : ''); ?>">
<!-- info user -->
<table width="100%" cellspacing="0" cellpadding="0" style="<?php echo ($array['vip_status'] == 1 ? 'background: url(../images/user-vip-bg.gif); border: 1px solid #ff8800;' : 'background: url(../images/user-bg.jpg); border: 1px solid #ccc;'); ?> padding: 6px 10px; border-radius: 10px;">
<tr>
<td width="125" valign="top" align="left">
<a href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/id<?php echo $array['id_user']; ?>">
<div style="<?php echo (!empty($array['avatar']) ? "background: url('http://".$_SERVER['HTTP_HOST']."/".DIR_PHOTOS."/".$array['id_user']."/".str_replace('_s', '_p', $array['avatar'])."') no-repeat; width: 110px; height: 146px; ".($array['vip_status'] == 1 ? 'border: 3px solid #ff8800;' : 'border: 3px solid #ccc;') : "background: url('http://".$_SERVER['HTTP_HOST']."/images/no_photo_norm.png'); width: 110px; height: 146px; ".($array['vip_status'] == 1 ? 'border: 3px solid #ff8800;' : 'border: 3px solid #ccc;')); ?>">
<div style="margin-top: -25px; margin-left: -15px; position: absolute;">
<?php if ($array['vip_status'] == 1) { ?><img class="title_help" src="/images/vip.png" alt="" width="52" height="52" title="VIP-пользователь" /> <?php } ?>
<?php if (function_online($array['online']) == TRUE) { ?>
<div style="left: 20px; top: 155px; position: absolute;">
<img class="title_help" src="/images/on.gif" alt="Сейчас на сайте" title="Сейчас на сайте" />
</div>
<?php } ?>
</div>
</div>
</a>
</td>
<td valign="top" align="left">
<a class="<?php echo ($array['pol'] == 1 ? 'm_color' : 'zh_color'); ?>" href="http://<?php echo $_SERVER['HTTP_HOST']; ?>/id<?php echo $array['id_user']; ?>"><?php echo htmlspecialchars($array['name'], ENT_QUOTES); ?></a><br/>
<span class="vozrast">Возраст: <?php echo function_vozrast_n($array['god'].'-'.$array['mes'].'-'.$array['day']); ?></span><br/>
<span class="city"><?php echo htmlspecialchars($array['city'], ENT_QUOTES); ?>, <?php echo htmlspecialchars($array['country'], ENT_QUOTES); ?></span><br/>
<?php if (!empty($array['photo'])) { ?>
<div style="padding-top: 75px;">
<span class="photos"><span class="photos_ico"></span> <?php echo $array['photo']; ?></span>
</div>
<?php } ?>
</td>
<td valign="top" align="right">
<?php if (!empty($array['top_up'])) { ?>
<img class="title_help" src="/images/up_small.png" alt="" width="16" height="16" title="Поднимал<?php echo ($array['pol'] == 1 ? '' : 'а'); ?> анкету «наверх» <?php echo function_vizit($array['top_up']); ?>" />
<?php } ?>
</td>
</tr>
</table>
<!-- /info user -->
<div class="hr"></div>
<?php if ($i == 1) { ?>
</td>
<?php } else { ?>
</td></tr><tr>
<?php $i = 0; ?>
<?php } ?>
<?php $i++; ?>
<?php } ?>
</tr>
</table>
<div class="clear"></div>
<?php page('/search/page', $col, $start, $count_p, $end_url = ''); ?>
<?php } else { ?>
<div style="text-align: center;">По Вашему запросу ничего не найдено. Попробуйте изменить параметры поиска</div>
<?php } ?>
<div style="padding: 10px 0;"><a href="<?php echo $_SERVER['PHP_SELF']; ?>?new=true">Новый поиск</a></div>
</div>
<div class="clear"></div>
<?php include (dirname(__FILE__).'/include/footer.php'); ?>