Arkadaşlar bir arkadaşlık scriptinde quick search bölümünde sadece karşı cinsin aranmasını istiyorum. Yani ben kadın ardığım kadın ya da ben erkek aradığım erkek kısmını kaldırıp sadece karşı cins aranmalı. Bu konuda bana yardımcı olabilecek var mıdır?
Not: Kodun tamamını yüklemediği için rar dosyası olarak ayrıca koydum.
Not: Kodun tamamını yüklemediği için rar dosyası olarak ayrıca koydum.
PHP:
<?php
/**
* Quick search form, functions and results listings
* @subpackage User Mode
**/
include "./include/config.php";
include "./common.php";
include "./include/config_index.php";
include "./include/functions_index.php";
include "./include/functions_auth.php";
include "./include/class.lang.php";
include "./include/class.percent.php";
$user = auth_index_user();
RefreshAccount($user);
$smarty->assign("sub_menu_num", '3');
if(!$user[0]) ////// if user not registered
header("location: ".$config["site_root"]."/index.php");
if(!$user[8]) ////// if user status = 0
AlertPage(GetRightModulePath(__FILE__));
IsFileAllowed($user[0], GetRightModulePath(__FILE__));
$multi_lang = new MultiLang($config, $dbconn);
///// default multilanguage field for select
$field_name = $multi_lang->DefaultFieldName();
///// check ins messages if user not guest
if($user[3] != 1){
GetAlertsMessage();
SetModuleStatistic(GetRightModulePath(__FILE__));
}
$sel = isset($_POST["sel"]) ? $_POST["sel"] : (isset($_GET["sel"]) ? $_GET["sel"] : "");
switch($sel){
case "search": SearchTable("", $sel); break;
case "search_name": SearchTable("", $sel); break;
case "search_h": SearchTable("", $sel); break;
case "search_on": SearchTable("", $sel); break;
case "search_bd": SearchTable("", $sel); break;
case "search_new": SearchTable("", $sel); break;
case "search_top": SearchTable("", $sel); break;
case "search_keyword": SearchTable("", $sel); break;
case "search_tag": SearchTable("", $sel); break;
case "addlist": $res = AddToHotList(); $_GET["par"] = "send"; SearchTable($res["err"], $res["par"]); break;
case "blacklist": $res = AddToBlackList(); $_GET["par"] = "send"; SearchTable($res["err"], $res["par"]); break;
case "kiss": $res = SendKiss(); $_GET["par"]="send"; SearchTable($res["err"], $res["par"]); break;
case "search_all": SearchTable("", $sel); break;
case "search_referred": SearchTable("", $sel); break;
case "be_couple": $res = MakeCoupleAction(); $_GET["par"]="send"; SearchTable($res["err"], $res["par"]); break;
default: SearchForm();
}
function SearchForm(){
global $lang, $config, $config_index, $smarty, $dbconn, $user, $_SESSION, $multi_lang, $field_name;
Banners(GetRightModulePath(__FILE__));
LeftMenu();
IndexHomePage();
$file_name = (isset($_SERVER["PHP_SELF"]))?AfterLastSlash($_SERVER["PHP_SELF"]):"quick_search.php";
$smarty->assign("active_user_info", GetActiveUserInfo($user));
$set_arr = array("max_age_limit", "min_age_limit", "icon_male_default", "icon_female_default", "icons_folder", "zip_letters", "zip_count", "use_shoutbox_feature");
$settings = GetSiteSettings($set_arr);
// search table
$search_type = 1;
$table_key = $multi_lang->TableKey(COUNTRY_SPR_TABLE);
$rs_user = $dbconn->Execute("SELECT id_country, id_region, id_city FROM ".USERS_TABLE." WHERE id='".$user[0]."'");
$row_user = $rs_user->GetRowAssoc(false);
$strSQL = "select distinct id, name from ".COUNTRY_SPR_TABLE." order by name ";
$rs = $dbconn->Execute($strSQL);
$i = 0;
$spr_arr = array();
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$spr_arr[$i]["id"] = $row["id"];
$spr_arr[$i]["name"] = stripslashes($row["name"]);
if ($row_user["id_country"] == $spr_arr[$i]["id"])
$spr_arr[$i]["sel"] = 1;
$rs->MoveNext();
$i++;
}
$smarty->assign("countries", $spr_arr);
$strSQL = " SELECT DISTINCT id, name FROM ".REGION_SPR_TABLE." WHERE id_country='".$row_user["id_country"]."' GROUP BY id ORDER BY name ";
$rs = $dbconn->Execute($strSQL);
$i=0;
$spr_arr = array();
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$spr_arr[$i]["id"] = $row["id"];
$spr_arr[$i]["name"] = stripslashes($row["name"]);
if ($row_user["id_region"] == $spr_arr[$i]["id"])
$spr_arr[$i]["sel"] = 1;
$rs->MoveNext();
$i++;
}
$smarty->assign("regions", $spr_arr);
$spr_arr = array();
$strSQL = " SELECT DISTINCT id, name FROM ".CITY_SPR_TABLE." WHERE id_region='".$row_user["id_region"]."' GROUP BY id ORDER BY name ";
$rs = $dbconn->Execute($strSQL);
$i=0;
$spr_arr = array();
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$spr_arr[$i]["id"] = $row["id"];
$spr_arr[$i]["name"] = stripslashes($row["name"]);
if ($row_user["id_city"] == $spr_arr[$i]["id"])
$spr_arr[$i]["sel"] = 1;
$rs->MoveNext();
$i++;
}
$smarty->assign("cities", $spr_arr);
$form["zip_count"] = $settings["zip_count"];
if ($user[3] !=1) {
//// gender select
$strSQL = "SELECT a.gender, b.gender as gender_search, b.couple as couple_search, b.age_min, b.age_max, b.id_relationship FROM ".USERS_TABLE." as a, ".USER_MATCH_TABLE." as b where b.id_user=a.id AND a.id='".$user[0]."'";
$rs = $dbconn->Execute($strSQL);
$row = $rs->GetRowAssoc(false);
$data["gender_1"] = $row["gender"];
$data["gender_2"] = $row["gender_search"];
$data["couple_2"] = $row["couple_search"];
$data["age_min"] = $row["age_min"];
$data["age_max"] = $row["age_max"];
if ($row["id_relationship"] !='' && $row["id_relationship"] !='0') {
$data["arr_relationship"] = explode(',',$row["id_relationship"]);
} else {
$data["arr_relationship"] = 0;
}
} else {
$data["gender_1"] = 2;
$data["gender_2"] = 1;
}
$gender_arr[0]["id"] = '1';
$gender_arr[0]["name"] = $lang["gender"]["1"];
$gender_arr[0]["name_search"] = $lang["gender_search"]["1"];
$gender_arr[0]["sel"] = (intval($data["gender_1"]) == 1) ? 1 : 0;
$gender_arr[0]["sel_search"] = (intval($data["gender_2"]) == 1) ? 1 : 0;
$gender_arr[1]["id"] = '2';
$gender_arr[1]["name"] = $lang["gender"]["2"];
$gender_arr[1]["name_search"] = $lang["gender_search"]["2"];
$gender_arr[1]["sel"] = (intval($data["gender_1"]) == 2) ? 1 : 0;
$gender_arr[1]["sel_search"] = (intval($data["gender_2"]) == 2) ? 1 : 0;
$smarty->assign("gender", $gender_arr);
$max_age = $settings["max_age_limit"];
$min_age = $settings["min_age_limit"];
$max_age_arr = range(intval($max_age), intval($min_age));
$smarty->assign("age_max", $max_age_arr);
$min_age_arr = range(intval($min_age), intval($max_age));
$smarty->assign("age_min", $min_age_arr);
//// distance select
$strSQL = "SELECT DISTINCT id, name, type FROM ".DISTANCE_SPR_TABLE." GROUP BY id ORDER BY id, name DESC";
$rs = $dbconn->Execute($strSQL);
$i=0;
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$distances_arr[$i]["id"] = $row["id"];
$distances_arr[$i]["name"] = $row["name"];
$distances_arr[$i]["type"] = ($row["type"] == "mile") ? $lang["distance"]["mile"] : $lang["distance"]["km"];
$rs->MoveNext();
$i++;
}
$smarty->assign("distances", $distances_arr);
//// relationships select
$strSQL = "select distinct a.id, b.".$field_name." as name from ".RELATION_SPR_TABLE." a left join ".REFERENCE_LANG_TABLE." b on b.table_key='".$multi_lang->TableKey(RELATION_SPR_TABLE)."' and b.id_reference=a.id order by a.sorter ";
$rs = $dbconn->Execute($strSQL);
$i = 0;
while(!$rs ->EOF){
$row = $rs->GetRowAssoc(false);
$relation_arr[$i]["id"] = $row["id"];
$relation_arr[$i]["name"] = $row["name"];
if ( is_array($data["arr_relationship"]) && in_array($relation_arr[$i]["id"], $data['arr_relationship']) ) {
$relation_arr[$i]["sel"] = 1;
} else {
$relation_arr[$i]["sel"] = 0;
}
$rs->MoveNext();
$i++;
}
$smarty->assign("relation", $relation_arr);
$strSQL = "Select DISTINCT tag, COUNT(id) as tag_count from ".TAGS_TABLE." group by tag order by tag";
$rs = $dbconn->Execute($strSQL);
$i=0;
$tags=array();
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$tags[$i]["tag"] = stripslashes($row["tag"]);
$tags[$i]["count"] = $row["tag_count"];
$tags[$i]["size"] = floor($tags[$i]["count"]/5) + 9;
$tags[$i]["searchlink"] = $file_name."?sel=search_tag&tag=".$tags[$i]["tag"];
$rs->MoveNext();
$i++;
}
$smarty->assign("tags", $tags);
$form["search_type"] = $search_type;
$form["search_action"] = $file_name;
$form["search_hiddens_1"] = "<input type=hidden name=sel value=search>";
$form["search_hiddens_1"] .= "<input type=hidden name=flag_country value=0>";
$form["search_hiddens_1"] .= "<input type=hidden name=search_type id=search_type value=".$search_type.">";
$form["search_hiddens_2"] = "<input type=hidden name=sel value=search_name>";
$form["search_hiddens_4"] = "<input type=hidden name=sel value=search_keyword>";
$form["search_3_birthday"] = "./".$file_name."?sel=search_bd";
$form["search_3_online"] = "./".$file_name."?sel=search_on";
$form["search_3_hotlist"] = "./".$file_name."?sel=search_h";
$form["search_3_new"] = "./".$file_name."?sel=search_new";
$smarty->assign("show_shoutbox", $settings["use_shoutbox_feature"]);
$smarty->assign("section", $lang["subsection"]);
$smarty->assign("form", $form);
$smarty->assign("data", $data);
$smarty->assign("header", $lang["homepage"]);
$smarty->assign("header_s", $lang["search"]);
$smarty->assign("script", "location");
$smarty->display(TrimSlash($config["index_theme_path"])."/quick_search_form.tpl");
exit;
}
function SearchTable($err="", $par=""){
global $lang, $config, $config_index, $smarty, $dbconn, $user, $multi_lang, $field_name;
Banners(GetRightModulePath(__FILE__));
LeftMenu();
IndexHomePage();
$file_name = (isset($_SERVER["PHP_SELF"]))?AfterLastSlash($_SERVER["PHP_SELF"]):"quick_search.php";
$smarty->assign("active_user_info", GetActiveUserInfo($user));
$percent = new Percent($config, $dbconn, $user[0]);
$page = isset($_REQUEST["page"])?$_REQUEST["page"]:"";
$filter = isset($_REQUEST["filter"])?$_REQUEST["filter"]:"";
$view = isset($_REQUEST["view"]) && $_REQUEST["view"] == "gallery" ? "gallery" : "list";
if(!isset($_GET["par"])) unset($_SESSION["search_page"]);
if((strval($page) == "") || (strval($page) == "0")){
if (isset($_SESSION["search_page"]))
$page = $_SESSION["search_page"];
else
$page = 1;
}else{
$page = intval($page);
$_SESSION["search_page"] = $page;
}
////////// settings
$set_arr = array("max_age_limit", "min_age_limit", "icon_male_default", "icon_female_default", "icons_folder", "zip_letters", "zip_count", "show_users_connection_str", "show_users_comments", "show_users_group_str", "use_kiss_types", "thumb_max_width", "use_shoutbox_feature","use_friend_types");
$settings = GetSiteSettings($set_arr);
$strSQL = " SELECT couple FROM ".USERS_TABLE." WHERE id='".$user[0]."' ";
$rs = $dbconn->Execute($strSQL);
$is_coupled = $rs->fields[0];
$smarty->assign("is_coupled", $is_coupled);
$default_photos['1'] = $settings['icon_male_default'];
$default_photos['2'] = $settings['icon_female_default'];
$strSQL = "";
$gender_1 = $gender_2 = $couple_2 = $age_min = $age_max = $country = $region = $city = $foto = $online = $within = $distance = 0;
$zipcode = $nick = $word = $tag = "";
switch($par){
case "search":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// if isnt set post vars echo err
$gender_1 = isset($_REQUEST["gender_1"])?intval($_REQUEST["gender_1"]):0;
$gender_2 = isset($_REQUEST["gender_2"])?intval($_REQUEST["gender_2"]):0;
$couple_2 = isset($_REQUEST["couple_2"])?intval($_REQUEST["couple_2"]):0;
$age_min = isset($_REQUEST["age_min"])?intval($_REQUEST["age_min"]):0;
$age_max = isset($_REQUEST["age_max"])?intval($_REQUEST["age_max"]):0;
$country = isset($_REQUEST["country"])?intval($_REQUEST["country"]):0;
$region = isset($_REQUEST["region"])?intval($_REQUEST["region"]):0;
$city = isset($_REQUEST["city"])?intval($_REQUEST["city"]):0;
$zipcode = isset($_REQUEST["zipcode"])?$_REQUEST["zipcode"]:"";
$zipcode = FormFilter($zipcode);
$foto = isset($_REQUEST["foto_only"])?intval($_REQUEST["foto_only"]):0;
$online = isset($_REQUEST["online_only"])?intval($_REQUEST["online_only"]):0;
$within = isset($_REQUEST["within"])?intval($_REQUEST["within"]):0;
$distance = isset($_REQUEST["distance"])?intval($_REQUEST["distance"]):0;
if (!isset($_REQUEST["relation"])) {
if (isset($_SESSION["search_pars"]["relation"])) {
$relation = $_SESSION["search_pars"]["relation"];
} else {
$relation = "";
}
} else {
$relation = $_REQUEST["relation"];
}
if(isset($_GET["par"]) && ($_GET["par"]=="back" || $_GET["par"]=="send")){ ////if user clicked on back to list button
$gender_1 = $_SESSION["search_pars"]["gender_1"];
$gender_2 = $_SESSION["search_pars"]["gender_2"];
$couple_2 = $_SESSION["search_pars"]["couple_2"];
$age_min = $_SESSION["search_pars"]["age_min"];
$age_max = $_SESSION["search_pars"]["age_max"];
$country = $_SESSION["search_pars"]["country"];
$region = $_SESSION["search_pars"]["region"];
$city = $_SESSION["search_pars"]["city"];
$zipcode = $_SESSION["search_pars"]["zipcode"];
$foto = $_SESSION["search_pars"]["foto"];
$online = $_SESSION["search_pars"]["online"];
$within = $_SESSION["search_pars"]["within"];
$distance = $_SESSION["search_pars"]["distance"];
$relation = $_SESSION["search_pars"]["relation"];
}
if (isset($relation) && !is_array($relation) && strlen($relation)>=3) {
$relation = explode(',',$relation);
}
$search_type = isset($_POST["search_type"])?intval($_POST["search_type"]):1;
if( (!isset($gender_1)) && (!isset($gender_2)) && (!isset($age_min)) && (!isset($age_max)) && (!isset($country) || !isset($zipcode))){
$smarty->assign("empty", "1");
}else if( ($within == 1) && (!intval($city)) ){
$err = $lang["distance"]["specify_city"];
$smarty->assign("empty", "1");
}else{
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$foto_substr = $zip_substr = $relation_substr = $online_substr = "";
if($foto == 1){
$foto_substr = " and a.icon_path <> '' ";
}
if($online == 1){
$strSQL = "Select distinct a.id
from ".USERS_TABLE." a , ".ACTIVE_SESSIONS_TABLE." e
where a.id=e.id_user and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'";
$rs = $dbconn->Execute($strSQL);
$id_arr = array();
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$id_arr[] = $row["id"];
$rs->MoveNext();
}
if (!count($id_arr)) $id_arr[0] = '0';
$online_substr = " and a.id in (".join(",", $id_arr).") ";
}
if ($relation !='') {
if (is_array($relation)) {
$relation_substr = " and ( ";
$_arr = array();
$not_empty = false;
foreach ($relation as $value) {
if (trim($value) != '') {
$not_empty = true;
array_push($_arr, " ((b.id_relationship LIKE '".$value."') OR (b.id_relationship LIKE '".$value.",%') OR (b.id_relationship LIKE '%,".$value.",%') OR (b.id_relationship LIKE '%,".$value."')) ");
}
}
$relation_substr .= implode(" OR ", $_arr);
if ($not_empty != false) {
$relation_substr .= " OR ((b.id_relationship LIKE '0') OR (b.id_relationship LIKE '0,%') OR (b.id_relationship LIKE '%,0,%') OR (b.id_relationship LIKE '%,0')) ";
$relation_substr .= ")";
} else {
$relation_substr = "";
}
$relation_str = implode(",",$relation);
} elseif (intval($relation)>0) {
$relation_substr = " AND (((b.id_relationship LIKE '".$relation."') OR (b.id_relationship LIKE '".$relation.",%') OR (b.id_relationship LIKE '%,".$relation.",%') OR (b.id_relationship LIKE '%,".$relation."')) or ((b.id_relationship LIKE '0') OR (b.id_relationship LIKE '0,%') OR (b.id_relationship LIKE '%,0,%') OR (b.id_relationship LIKE '%,0'))) ";
$relation_str = $relation;
} else {
$relation_str = "";
$relation_substr = "";
}
} else {
$relation_str = "";
$relation_substr = "";
}
$zip_substr = "";
if($search_type == '1'){
if($country){
$country_str = " and a.id_country = '".$country."' ";
if($region) $country_str .= " and a.id_region = '".$region."' ";
if($city) $country_str .= " and a.id_city = '".$city."' ";
if($within == 1){
$city_arr = CityInRadius($city,$distance);
if (count($city_arr)) $country_str = " and a.id_city in (".join(",", $city_arr).") ";
}
$zip_substr = $country_str;
}
}elseif($search_type == '2'){
if($zipcode){
$country_arr = array();
$region_arr = array();
$city_arr = array();
////// select id_ countries and cities which have dem zipcodes (if searched user live in city but didnt write his zipcode only city)
$rs = $dbconn->Execute("select distinct id_country, id_region, id from ".CITY_SPR_TABLE." where zip_code like '%".addslashes($zipcode)."%'");
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
array_push($country_arr, $row["id_country"]);
array_push($region_arr, $row["id_region"]);
array_push($city_arr, $row["id"]);
$rs->MoveNext();
}
if($country)
array_push($country_arr, $country);
if($region)
array_push($region_arr, $region);
if($city)
array_push($city_arr, $city);
$country_unique_arr = array_unique($country_arr);
$region_unique_arr = array_unique($region_arr);
$city_unique_arr = array_unique($city_arr);
if(count($country_unique_arr)>0)$country_str = implode(",", $country_unique_arr);
if(count($region_unique_arr)>0)$region_str = implode(",", $region_unique_arr);
if(count($city_unique_arr)>0)$city_str = implode(",", $city_unique_arr);
if(isset($city_str)) $city_str = " a.id_city in ( ".$city_str.")";
if(isset($country_str)) $country_str = " a.id_country in ( ".$country_str.")";
if(isset($region_str)) $region_str = " a.id_region in ( ".$region_str.")";
if( !isset($country_str) && !isset($city_str) && !isset($region_str)){
$zip_substr = " and a.zipcode like '".$zipcode."' ";
}else{
$_arr = array();
if ($city_str) {
array_push($_arr, $city_str);
}
if ($region_str) {
array_push($_arr, $region_str);
}
if ($country_str) {
array_push($_arr, $country_str);
}
$zip_substr = "and ( ( ".implode(' AND ', $_arr)." ) or a.zipcode like '".$zipcode."' ) ";
}
}
}
unset($_SESSION["search_pars"]);
//// search parametrs and id array put in sessoin
$_SESSION["search_pars"]["gender_1"] = $gender_1;
$_SESSION["search_pars"]["gender_2"] = $gender_2;
$_SESSION["search_pars"]["couple_2"] = $couple_2;
$_SESSION["search_pars"]["age_min"] = $age_min;
$_SESSION["search_pars"]["age_max"] = $age_max;
$_SESSION["search_pars"]["country"] = $country;
$_SESSION["search_pars"]["region"] = $region;
$_SESSION["search_pars"]["city"] = $city;
$_SESSION["search_pars"]["zipcode"] = $zipcode;
$_SESSION["search_pars"]["foto"] = $foto;
$_SESSION["search_pars"]["online"] = $online;
$_SESSION["search_pars"]["within"] = $within;
$_SESSION["search_pars"]["distance"] = $distance;
$_SESSION["search_pars"]["relation"] = $relation;
$strSQL = "Select distinct a.id, a.icon_path, e.id_user as session
from ".USER_MATCH_TABLE." b, ".USERS_TABLE." a
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where a.gender='".$gender_2."' and b.gender='".$gender_1."' and a.couple='".$couple_2."'
and STRCMP(date_format(a.date_birthday, '%Y%m%d'), date_format('".DateFromAge($age_min-1)."', '%Y%m%d')) <=0
and STRCMP(date_format(a.date_birthday, '%Y%m%d'), date_format('".DateFromAge($age_max+1)."', '%Y%m%d')) >= 0
and a.id <> '".$user[0]."'".$foto_substr." ".$zip_substr." ".$relation_substr." ".$online_substr." and b.id_user=a.id
and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0'
ORDER BY a.date_topsearched DESC, a.date_registration DESC ";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_name":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// if isnt set post vars echo err
$nick = isset($_REQUEST["nick"])?$_REQUEST["nick"]:"";
$nick = FormFilter($nick);
if(isset($_GET["par"]) && ($_GET["par"]=="back" || $_GET["par"]=="send")){ ////if user clicked on back to list button
$nick = $_SESSION["search_pars"]["nick"];
}
if(!isset($nick) || $nick == ""){
$smarty->assign("empty", "1");
}else{
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
//// search parametrs and id array put in sessoin
$_SESSION["search_pars"]["nick"] = $nick;
$strSQL = "Select distinct a.id, a.icon_path, e.id_user as session
from ".USERS_TABLE." a
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where LOWER(a.login) like '%".strtolower($nick)."%' and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_on":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " Select distinct a.id, a.icon_path, e.id_user as session
from ".USERS_TABLE." a , ".ACTIVE_SESSIONS_TABLE." e
where a.id=e.id_user and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_bd":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " Select distinct a.id, a.icon_path, e.id_user as session
from ".USERS_TABLE." a
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where a.date_birthday like '%-".date("m")."-".date("d")."%' and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_new":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " Select distinct a.id, a.icon_path, e.id_user as session
from ".USERS_TABLE." a
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where a.date_registration > (now() - interval 1 day) and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_h":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " Select distinct a.id, a.icon_path, e.id_user as session
from ".HOTLIST_TABLE." h, ".USERS_TABLE." a
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where a.id=h.id_user and h.id_friend='".$user[0]."' and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_top":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " SELECT DISTINCT a.id, a.icon_path, st.id_user as session
FROM ".USERS_TABLE." a
LEFT JOIN ".USER_TOPTEN_TABLE." e on a.id=e.id_user
LEFT JOIN ".ACTIVE_SESSIONS_TABLE." st on a.id=st.id_user
WHERE (e.id>0) AND a.status='1' AND a.visible='1' AND a.root_user = '0' AND a.guest_user='0'
GROUP BY a.id
ORDER BY e.rating desc";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_keyword":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// if isnt set post vars echo err
$word = isset($_REQUEST["word"])?$_REQUEST["word"]:"";
$word = FormFilter($word);
if(isset($_GET["par"]) && ($_GET["par"]=="back" || $_GET["par"]=="send")){ ////if user clicked on back to list button
$word = $_SESSION["search_pars"]["word"];
}
if(!isset($word) || $word == ""){
$smarty->assign("empty", "1");
}else{
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
//// search parametrs and id array put in sessoin
$_SESSION["search_pars"]["word"] = $word;
$id_arr = array();
$or_substr = "";
$rs = $dbconn->Execute("Select id from ".LANGUAGE_TABLE);
$id_langs = array();
while(!$rs->EOF){
$id_langs[] = "a.lang_".$rs->fields[0]." like '%".ucfirst(strtolower($word))."%'";
$rs->MoveNext();
}
$like_substr = join(" or ", $id_langs);
$strSQL = "Select b.id_user as id from ".REFERENCE_LANG_TABLE." a, ".PERSON_SPR_USER_TABLE." b
where a.table_key=7 and a.id_reference=b.id_value and (".$like_substr.")";
$rs = $dbconn->Execute($strSQL);
while(!$rs->EOF){
$id_arr[] = $rs->fields[0];
$rs->MoveNext();
}
$strSQL = "Select b.id_user as id from ".REFERENCE_LANG_TABLE." a, ".PORTRAIT_SPR_USER_TABLE." b
where a.table_key=9 and a.id_reference=b.id_value and (".$like_substr.")";
$rs = $dbconn->Execute($strSQL);
while(!$rs->EOF){
$id_arr[] = $rs->fields[0];
$rs->MoveNext();
}
$strSQL = "Select b.id_user as id from ".REFERENCE_LANG_TABLE." a, ".INTERESTS_SPR_USER_TABLE." b
where a.table_key=3 and a.id_reference=b.id_spr and b.id_value<>'' and (".$like_substr.")";
$rs = $dbconn->Execute($strSQL);
while(!$rs->EOF){
$id_arr[] = $rs->fields[0];
$rs->MoveNext();
}
if (count($id_arr)) $or_substr = " or a.id in (".join(",", $id_arr).") ";
$strSQL = "Select distinct a.id, a.icon_path, e.id_user as session
from ".USERS_TABLE." a
left join ".USER_UPLOAD_TABLE." b on a.id=b.id_user
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where b.status='1' AND (a.comment like '%".$word."%' or a.headline like '%".$word."%' or b.user_comment like '%".$word."%' ".$or_substr.")
and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_tag":
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////// if isnt set post vars echo err
$tag = isset($_REQUEST["tag"])?$_REQUEST["tag"]:"";
$tag = FormFilter($tag);
if(isset($_GET["par"]) && ($_GET["par"]=="back" || $_GET["par"]=="send")){ ////if user clicked on back to list button
$tag = $_SESSION["search_pars"]["tag"];
}
if(!isset($tag) || $tag == ""){
$smarty->assign("empty", "1");
}else{
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
//// search parametrs and id array put in sessoin
$_SESSION["search_pars"]["tag"] = $tag;
$strSQL = "Select distinct a.id, a.icon_path, e.id_user as session
from ".TAGS_TABLE." b, ".USERS_TABLE." a
left join ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
where b.tag = '".$tag."' and b.id_user = a.id and a.status='1' and a.visible='1' and a.root_user = '0' and a.guest_user='0' and a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
break;
case "search_all":
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " SELECT DISTINCT a.id, a.icon_path, e.id_user AS session
FROM ".USERS_TABLE." a
LEFT JOIN ".ACTIVE_SESSIONS_TABLE." e on a.id=e.id_user
WHERE a.status='1' AND a.visible='1' AND a.root_user = '0' AND a.guest_user='0' AND a.id != '".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
break;
case "search_referred":
unset($_SESSION["id_arr"], $_SESSION["search_pars"]);
$strSQL = " SELECT DISTINCT a.id, a.icon_path
FROM ".USERS_TABLE." a
LEFT JOIN ".USER_REFER_TABLE." urt ON urt.id_user=a.id
WHERE urt.id_user=a.id AND urt.id_refer='".$user[0]."'
ORDER BY a.date_topsearched DESC, a.date_registration DESC
";
break;
}
if($strSQL !=""){
unset($_SESSION["id_arr"], $_SESSION["id_arr2"], $_SESSION["with_arr"], $_SESSION["without_arr"], $_SESSION["online_arr"], $_SESSION["offline_arr"]);
$rs = $dbconn->Execute($strSQL);
$i = 0;
while(!$rs->EOF){
$row = $rs->GetRowAssoc(false);
$_SESSION["id_arr"][$i] = $row["id"];
if(strlen($row["icon_path"])){
$_SESSION["with_arr"][$i] = $row["id"];
}else{
$_SESSION["without_arr"][$i] = $row["id"];
}
if(intval($row["session"])){
$_SESSION["online_arr"][$i] = $row["id"];
}else{
$_SESSION["offline_arr"][$i] = $row["id"];
}
$rs->MoveNext();
$i++;
}
switch($filter){
case "all":
$_SESSION["id_arr"] = isset($_SESSION["id_arr"])?$_SESSION["id_arr"]:array();
break;
case "photo":
$_SESSION["id_arr"] = isset($_SESSION["with_arr"])?$_SESSION["with_arr"]:array();
break;
case "online":
$_SESSION["id_arr"] = isset($_SESSION["online_arr"])?$_SESSION["online_arr"]:array();
break;
default:
$_SESSION["id_arr"] = isset($_SESSION["id_arr"])?$_SESSION["id_arr"]:array();
$filter = 'all';
break;
}
$num_records = count($_SESSION["id_arr"]);
///////// page
$numpage = ($view == "gallery")?$config_index["search_gallery_numpage"]:$config_index["search_numpage"];
$lim_min = ($page-1)*$numpage;
$lim_max = min($numpage, ($num_records-$lim_min) );
$limit_str = " limit ".$lim_min.", ".$lim_max;
if($num_records>0){
switch($par){
case "search":
$strSQL = "SELECT distinct a.id, a.login, a.phone, a.gender, a.date_birthday, a.icon_path, a.id_country, a.id_city, a.id_region, SUBSTRING(a.comment,1, 165) as comment, DATE_FORMAT(a.date_last_seen,'".$config["date_format"]."') as date_last_login FROM ".USERS_TABLE." a WHERE a.id in ( ".implode(",", $_SESSION["id_arr"])." )
ORDER BY a.date_topsearched DESC, a.date_registration
?>