$max_free_profiles )))) $logged[aff] = member_auth( 2, false ); $_page[header] = _t("_Search result"); //$_page[header_text] = _t("_SEARCH_SORTED"); $_page[header_text] = ('g4' != $tmpl) ? _t("_SEARCH_SORTED") : ""; // --------------- GET/POST actions // check if user poset correct data if ( !isset($_GET[LookingFor]) && !$_GET[ID] && !$_GET[NickName] && !$_GET[distance] && !$_GET[zip] && !$_GET[online_only] && !$_GET[gallery_view] && !$_GET['view_friends']) { echo ''; exit; } // check for gallery view $gallery_cols = 4; $gallery_view = $_GET[gallery_view] ? $_GET[gallery_view] : $_POST[gallery_view]; // --- move $days_forall_caff = getParam("days_forall_caff"); $no_cart = getParam("no_cart") == "on" ? 1 : 0; $membership_only = getParam("membership_only") == "on" ? 1 : 0; // --- move // search vasriables and page navigation data $ID = getID( $_GET['ID'], 0 ); $NickName = $_GET['NickName']; $zip = $_GET['zip']; $distance = $_GET['distance']; $metric = $_GET['metric']; $sortorder = $_GET['sortorder']; $sortby = $_GET['sortby']; $photos_only = $_GET['photos_only']; $online_only = $_GET['online_only']; $page = (int)$_GET['page']; $p_per_page = (int)$_GET['p_per_page']; // build search SQL query if (isset ($_GET['view_friends'])) { $f_id = (int)$_GET['view_friends']; $total_query = ", FriendList WHERE ( Profiles.ID = FriendList.Profile OR Profiles.ID = FriendList.ID ) AND ( FriendList.Profile = $f_id OR FriendList.ID = $f_id ) AND FriendList.Check = '1' AND Profiles.ID != $f_id AND Status = 'Active'"; } else if ( (isset($ID) && $_GET['ID']) || $NickName ) { $total_query = "WHERE Status = 'Active' "; if ( (isset($ID) && $_GET['ID']) ) $total_query .= "AND ID = '$ID' "; if ( $NickName ) $total_query .= "AND NickName = '$NickName' "; if ( $photos_only || $gallery_view ) $total_query .= "AND Picture = '1' "; } else { $total_query = "WHERE Status = 'Active' "; if ( $photos_only || $gallery_view ) $total_query .= "AND Picture = '1' "; if ( $online_only ) { $min = GetParam( "member_online_time" ); $total_query .= "AND LastNavTime > SUBDATE(NOW(), INTERVAL $min MINUTE)"; } if ( $zip ) { if ( ((int)$zip) == 0 ) $z_arr = db_arr("SELECT Latitude,Longitude FROM ZIPCodes WHERE City = '$zip'"); else $z_arr = db_arr("SELECT Latitude,Longitude FROM ZIPCodes WHERE ZIPCode = '$zip'"); if ( $z_arr ) { //ZIP code exists $miles2km = 0.7; // miles/kilometers ratio $fname = "zip"; // field in database with zip code $Miles = $metric == "km" ? $distance*$miles2km : $distance; $Latitude = $z_arr["Latitude"]; $Longitude = $z_arr["Longitude"]; $zcdRadius = new RadiusAssistant($Latitude,$Longitude,$Miles); $minLat = $zcdRadius->MinLatitude(); $maxLat = $zcdRadius->MaxLatitude(); $minLong = $zcdRadius->MinLongitude(); $maxLong = $zcdRadius->MaxLongitude(); //mySQL Query // $sql = "SELECT * FROM ZIPCodes WHERE $sql = "select ZIP from Profiles left join ZIPCodes on Profiles.zip = ZIPCodes.ZIPCode where Latitude >= $minLat AND Latitude <= $maxLat AND Longitude >= $minLong AND Longitude <= $maxLong"; if ($result = db_res($sql)) { $total_query .= " AND ($fname IN (-1"; while ($myrow = mysql_fetch_array($result)){ $total_query .= ",'{$myrow['ZIP']}'"; } $total_query .= ")) "; } } else { $total_query .= " AND 0 "; } } // zickl HERE !!! $respd = db_res("SELECT * FROM ProfilesDesc WHERE `search_type` <> 'none' ORDER BY `search_order` ASC"); while ( $arrpd = mysql_fetch_array($respd) ) { $fname = get_field_name ( $arrpd ); switch ($arrpd[search_type]) { case 'radio': $fval = $_GET[$fname]; if ( strlen($fval) ) { if ( $arrpd[search_where] ) $s = sprintf($arrpd[search_where], $fval, $fval, $fval, $fval ); else $s = " $fname = '$fval' "; $total_query .= "AND $s "; } break; case 'list': $fval = $_GET[$fname]; if ( count($fval) > 0 && is_array($fval) ) { $total_query .= " AND ($fname IN (-1"; while ( list( $key, $val ) = each( $fval ) ) $total_query .= ",$val"; $total_query .= ")) "; } break; case 'check': if ( $arrpd[type] == 'r' ) { $findok = 0; $funcbody = $arrpd[extra]; $func = create_function("", $funcbody); $ar = $func(); foreach ( $ar as $key => $value ) { if ( $_GET["${fname}_$key"] == "on" ) { $findok = 1; break; } } if ( $findok ) { $total_query_tmp = ""; foreach ( $ar as $key => $value ) { if ( $_GET["${fname}_$key"] == "on" ) $total_query_tmp .= ",$key"; } if ( strlen($arrpd[search_where]) > 0 ) { $s = sprintf($arrpd[search_where], $total_query_tmp, $total_query_tmp, $total_query_tmp ); $total_query .= $s; } else { $total_query .= " AND ($fname IN (-1"; $total_query .= $total_query_tmp; $total_query .= ")) "; } } } else if ( $arrpd[type] == 'e' && strlen($_GET["$fname"]) ) { $total_query .= " AND ($fname = '".$_GET["$fname"]."') "; } else if ( $arrpd[type] == 'e') { $findok = 0; $vals = preg_split ("/[,\']+/", $arrpd[extra], -1, PREG_SPLIT_NO_EMPTY); foreach ( $vals as $key ) { if ( $_GET["${fname}_$key"] == "on" ) { $findok = 1; break; } } if ( $findok ) { $total_query_tmp = ""; foreach ( $vals as $key ) { if ( $_GET["${fname}_$key"] == "on" ) $total_query_tmp .= ",'$key'"; } if ( strlen($arrpd[search_where]) > 0 ) { $s = sprintf($arrpd[search_where], $total_query_tmp, $total_query_tmp, $total_query_tmp ); $total_query .= $s; } else { $total_query .= " AND ($fname IN (-1"; $total_query .= $total_query_tmp; $total_query .= ")) "; } } } break; case 'check_set': $findok = 0; $vals = preg_split ("/[,\']+/", $arrpd[extra], -1, PREG_SPLIT_NO_EMPTY); $vv = 0; if ($fname!='Zodiac') { foreach ( $vals as $v ) { if ( strlen(trim($v)) <= 0 ) continue; if ( $_GET["${fname}_$vv"] == "on" ) { $findok = 1; break; } ++$vv; } if ( $findok ) { $cl_tmp_total = 0; $cl_tmp_total2 = ""; $cl_tmp = 1; $i = 0; foreach ( $vals as $v ) { if ( strlen(trim($v)) <= 0 ) continue; if ( $_GET[$fname."_".$i] == 'on' ) $cl_tmp_total |= $cl_tmp; if ( $cl_tmp == 128 ) { $cl_tmp_total2 = sprintf("%02x",$cl_tmp_total).$cl_tmp_total2; $cl_tmp_total = 0; $cl_tmp = 1; } else { $cl_tmp <<= 1; } ++$i; } $cl_tmp_total2 = sprintf("%02x",$cl_tmp_total).$cl_tmp_total2; if ( !strlen($cl_tmp_total2)) $cl_tmp_total2 = "0"; if ( $cl_tmp_total2 != "0" ) $total_query .= " AND ($fname & (0 + 0x$cl_tmp_total2))"; } } else { if ($zodiac) { $total_query1= " AND ("; } foreach ( $vals as $v ) { $st=$fname."_".$vv; $zodiac=$_GET[$st];; if ($zodiac!='') { switch ( strtolower($zodiac) ) { case 'aries': $sign = "03-21";$sign1 = "04-19"; break; case 'taurus': $sign = "04-20";$sign1 = "05-20"; break; case 'gemini': $sign = "05-21";$sign1 = "06-21"; break; case 'cancer': $sign = "06-22";$sign1 = "07-22"; break; case 'leo': $sign = "07-23";$sign1 = "08-22"; break; case 'virgo': $sign = "08-23";$sign1 = "09-22"; break; case 'libra': $sign = "09-23";$sign1 = "10-23"; break; case 'scorpio': $sign = "10-24";$sign1 = "11-21"; break; case 'sagittarius': $sign = "11-22";$sign1 = "12-21"; break; case 'capricorn': $sign = "12-22";$sign1 = "12-31";$sign2 = "01-01";$sign3 = "01-19"; break; case 'aquarius': $sign = "01-20";$sign1 = "02-18"; break; case 'pisces': $sign = "02-19";$sign1 = "03-20"; break; } if($total_query1 != " AND (") { $total_query1 .= " OR "; } if($zodiac=='Capricorn') { $total_query1 .= "(SUBSTRING(DateOfBirth,6,5) BETWEEN '".$sign."' AND '".$sign1."') OR (SUBSTRING(DateOfBirth,6,5) BETWEEN '".$sign2."' AND '".$sign3."') "; } else { $total_query1 .= "(SUBSTRING(DateOfBirth,6,5) BETWEEN '".$sign."' AND '".$sign1."') "; } } ++$vv; } if ($zodiac) { $total_query1 .= ") "; } $total_query .=$total_query1; } break; case 'daterange': $fval_s = $_GET["${fname}_start"]; $fval_e = $_GET["${fname}_end"]; if ( $fval_s || $fval_e ) { $fval_s = (int)( date( "Y" ) - $fval_s ); $fval_e = (int)( date( "Y" ) - $fval_e - 1 ); $fval_s = $fval_s . date( "-m-d" ); $fval_e = $fval_e . date( "-m-d" ); if ( strlen($fval_s) && $fval_e) { $total_query .= " AND (TO_DAYS($fname) BETWEEN TO_DAYS('$fval_e') AND (TO_DAYS('$fval_s')+1)) "; } } break; case 'text': $fval = $_GET[$fname]; if ( strlen($fval) ) { if ( $arrpd[search_where] ) $s = sprintf($arrpd[search_where], $fval, $fval, $fval ); else $s = " $fname LIKE '%$fval%' "; $total_query .= " AND $s "; } break; } } } $query = "SELECT COUNT(*) FROM Profiles $total_query"; $result = mysql_query( $query ); $p_num = mysql_fetch_array( $result ); $p_num = $p_num[0]; $pages_num = ceil( $p_num / $p_per_page ); $real_first_p = (int)($page - 1) * $p_per_page; $page_first_p = $real_first_p + 1; // sorting $sort_order = $_GET[sortorder] ? $_GET[sortorder] : 'DESC'; switch ( $_GET[sortby] ) { case 'Sort_By_Age': $sort_by = '( 0 - TO_DAYS(DateOfBirth) )'; break; case 'Sort_By_Price': $sort_by = 'MerchantPrice'; break; default: $sort_by = 'Priority'; break; } // determine if user is online $is_onl = "(LastNavTime > SUBDATE(NOW(), INTERVAL 5 MINUTE)) as is_onl"; // determine number of pages ( for page navigation ) $page_query = "SELECT Profiles.ID, Headline, Country, Occupation, City, Sex, Sex2, ProfileType, NickName, Children, MerchantPrice, LEFT( DescriptionMe, 180 ) AS DescriptionMe, LEFT( DescriptionYou, 100 ) AS DescriptionYou, DateOfBirth, DateOfBirth2, Pic_0_addon, Sound, $is_onl $query_add FROM Profiles $sort_add $total_query $sort_add1 ORDER BY $sort_by $sort_order, Priority DESC, Profiles.LastLoggedIn DESC LIMIT $real_first_p, $p_per_page"; $result = db_res( $page_query ); $page_p_num = mysql_num_rows( $result ); $w_ex = 12; // profile actions if ( $pa_icon_preload ) { $add_to_header = "\n"; } $row_spacer = "
"; //--------------------- $lll = get_vars(); $ai_gallery ="\""._t("_view"; $al_gallery =""; $al_gallery .= _t("_view as photo gallery").""; $ai_profiles ="\""._t("_view"; $al_profiles =""; $al_profiles .= _t("_view as profile details").""; // --------------- GET/POST actions [ END ] // --------------- page components $_ni = $_page['name_index']; $_page_cont[$_ni]['page_main_code'] = $p_num ? PageCompPageMainCode() : PageCompNoResults(); $_page_cont[$_ni]['sorting'] = $p_num > 1 ? PageCompSorting() : ""; $second = 1; $_page_cont[$_ni]['page_navigation'] = $p_num > 1 ? PageCompNavigation() : ""; $_page_cont[$_ni]['page_navigation_short'] = $p_num > 1 ? PageCompNavigationShort() : ""; $second = 2; $_page_cont[$_ni]['page_navigation2'] = $p_num > 1 ? PageCompNavigation() : ""; $_page_cont[$_ni]['page_navigation_short2'] = $p_num > 1 ? PageCompNavigationShort() : ""; $func = "MenuLoggedMemberCustom"; $_page_cont[$_ni]['custom_menu'] = $func( CustomMenuFuncSearchResult() ); $_page_cont[$_ni]['add_to_header'] = $add_to_header; $_page_cont[$_ni]['row_spacer'] = $row_spacer; $_page_cont[$_ni]['ai_gallery'] = $ai_gallery; $_page_cont[$_ni]['ai_profiles'] = $ai_profiles; $_page_cont[$_ni]['db_color'] = $search_result_db_color; // --------------- [END] page components PageCode(); // --------------- page components functions /** * Place HTML code for Sorting */ function PageCompSorting () { global $p_num; global $content_w; global $tmpl; ob_start(); ?>