templateName = "./templatepage.html"; $master->content["Menu"] = $menu; $master->content["Lang_Bar"] = $lang_bar; $master->content["Lang"] = $lang; $master->content["Description"] = $text_title[28]; $master->content["Keywords"] = $text_title[29]; $master->content["Charset"] = get_charset($lang); // ======================================== $master->content["Sign"] = "sign_".$lang."_sosedi"; $master->title = $text_title[3]; $master->content["MoreSign"] = ""; if ($translation == 1) // TITLE $s = $s."Page title: ".$text_title[3]."


"; if ( (!isset($_REQUEST['stat'])) && (!isset($_REQUEST['people'])) && (!isset($_REQUEST['country'])) && (!isset($_REQUEST['region'])) ) { $s = $s."

".$text[0]; if ($translation==1) { $s = $s." "; } $s = $s." «".$text[1]."»!"; if ($translation==1) { $s = $s." "; } $s = $s."



"; $s = $s."

"; if ($translation==1) { $s = $s."
"; } $s = $s."

"; if ($translation==1) { $s = $s."
"; } $s = $s."
"; } // ==================================АНКЕТА========================= if ( (isset($_REQUEST['people'])) && (isset($_REQUEST['anketa'])) ) { $s = $s."

"; $id_anketi = $_REQUEST['anketa']; $id_anketi = quote_smart(trim(htmlspecialchars($id_anketi))); $query = "SELECT Name,FName,ID_Country,New_Country,ID_Region,New_Region,ID_City,New_City,Polovinka,Pomestie,About FROM `Anketi` WHERE Active=1 AND ID_anketi=".$id_anketi.""; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) { $name = htmlspecialchars_decode(get_sosed_name($id_anketi,$id_lang,$id_lang_def)); $fname = htmlspecialchars_decode(get_sosed_fname($id_anketi,$id_lang,$id_lang_def)); $id_country = $row ['ID_Country']; $new_country = $row ['New_Country']; if ($id_country > 0) $name_country = list_name(1,$id_country,$id_lang,$id_lang_def); else $name_country = $new_country; $name_country = htmlspecialchars_decode($name_country); $flag = flag($id_country); $id_region = $row ['ID_Region']; $new_region = $row ['New_Region']; if ($id_region > 0) $name_region = list_name(2,$id_region,$id_lang,$id_lang_def); else $name_region = $new_region; $name_region = htmlspecialchars_decode($name_region); $id_city = $row ['ID_City']; $new_city = $row ['New_City']; if ($id_city > 0) $name_city = list_name(3,$id_city,$id_lang,$id_lang_def); else $name_city = $new_city; $name_city = htmlspecialchars_decode($name_city); $love = $row ['Polovinka']; $build = $row ['Pomestie']; $sosed_about = get_sosed_about($id_anketi,$id_lang,$id_lang_def); $about = nl2br($sosed_about); $about = htmlspecialchars_decode($about); } $age = get_age($id_anketi); $s = $s.""; if ( $love == 1 || $build == 1) { $s = $s.""; } $s = $s."
"; if ( (isset($_SESSION['id'])) && (is_active($_SESSION['id'])) ) { $s = $s."
".$text[4].""; if ($translation==1) { $s = $s." "; } } else $s=$s."
"; $s = $s."

"; if ($love == 1) // картинка ищу половинку { $s = $s.""; if ($translation==1) { $s = $s." "; } $s = $s."   "; } if ($build == 1) // картинка уже создаю своё Родовое поместье { $pos_id = get_poselenie_id($id_anketi); $s = $s."   "; if ($pos_id > 0) $s = $s.""; $s = $s.""; if ($pos_id > 0) $s = $s.""; if ($translation==1) { $s = $s." "; } } $s = $s."
"; $s = $s."".$name." ".$fname.""; if ($translation==1) { $s = $s." "; $s = $s.""; $s = $s." "; } $s = $s."
".$text[7].":"; if ($translation==1) { $s = $s." "; } $s = $s." ".$age."



".$name_country."
".$name_region."
".$name_city."

"; $count_about = strlen($about); if ($count_about>0) { if ($count_about<80) $s = $s."

".$about."

"; else $s = $s."

".$about."

"; } $s = $s."

"; } // ==================================АНКЕТЫ ЛЮДЕЙ========================= if ( (isset($_REQUEST['people'])) && (!isset($_REQUEST['anketa'])) ) { $s = $s."

"; $sosed_pages = get_col_amount_massive($res_width); $pos_per_page = $sosed_pages["Sosed_col"]; // сколько колонок с фотками соседей на странице $pic_per_page = $sosed_pages["Sosed_pic"]; // сколько всего картинок с фотками будет на странице $country1 = $region1 = $city1 = $range1 = $love1 = $build1 = $to_do1 = 0; $pol1 = 2; if (isset($_REQUEST['country'])) $country1 = quote_smart(trim(htmlspecialchars($_REQUEST['country']))); if (isset($_REQUEST['region'])) $region1 = quote_smart(trim(htmlspecialchars($_REQUEST['region']))); if (isset($_REQUEST['city'])) $city1 = quote_smart(trim(htmlspecialchars($_REQUEST['city']))); if (isset($_REQUEST['range'])) $range1 = quote_smart(trim(htmlspecialchars($_REQUEST['range']))); if (isset($_REQUEST['pol'])) $pol1 = quote_smart(trim(htmlspecialchars($_REQUEST['pol']))); if (isset($_REQUEST['build'])) $build1 = quote_smart(trim(htmlspecialchars($_REQUEST['build']))); if (isset($_REQUEST['love'])) $love1 = quote_smart(trim(htmlspecialchars($_REQUEST['love']))); if ($love1 == 1) $to_do1 = 1; if ($build1 == 1) $to_do1 = 2; $count_people = count_people($pol1,$to_do1,$country1,$region1,$city1,$range1); $pages = ceil($count_people/$pic_per_page); // сколько старниц всего будет $start_page=0; if (isset($_REQUEST['page'])) { $r_page = quote_smart(trim(htmlspecialchars(intval($_REQUEST['page'])))); // if (is_string($r_page)) $r_page=1; $start_page = ($r_page-1)*$pic_per_page; $page = $r_page; } else $page = 1; $end_page = $start_page + $pic_per_page; $per_page = $pic_per_page; $x = 1; $query = "SELECT ID_anketi, Name, FName, ID_Country, Polovinka, ID_City FROM `Anketi` WHERE Active=1 "; if ($country1>0) $query = $query." AND ID_Country=".$country1; if ($region1>0) $query = $query." AND ID_Region=".$region1; if ($city1>0) $query = $query." AND ID_City=".$city1; if ($love1>0) $query = $query." AND Polovinka=".$love1; if ($pol1<2) $query = $query." AND Pol=".$pol1; if ($build1>0) $query = $query." AND Pomestie=".$build1; if ($range1>0) { $today = date('Y-m-d'); switch ($range1) { case "0": $start_date = '1900-01-01'; $end_date = $today; $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "1": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-20); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $end_date = $today; $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "2": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-30); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-20); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "3": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-40); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-30); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "4": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-50); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-40); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "5": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-60); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-50); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "6": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-70); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-60); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "7": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-80); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-70); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "8": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-150); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-80); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; default: $start_date = '1900-01-01'; $end_date = $today; $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; } } $x=0; $query = $query." ORDER BY CreateDate DESC LIMIT ".$start_page.",".$per_page; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) { $id_anketi[$x] = $row ['ID_anketi']; $id_country[$x] = $row ['ID_Country']; $country[$x] = htmlspecialchars_decode(list_name(1,$id_country[$x],$id_lang,$id_lang_def)); $id_city[$x] = $row ['ID_City']; $id_pos[$x] = get_idpos_by_idcity($id_city[$x]); $city2[$x] = htmlspecialchars_decode(list_name(3,$id_city[$x],$id_lang,$id_lang_def)); $flag[$x] = flag($id_country[$x]); $name[$x] = htmlspecialchars_decode(get_sosed_name($id_anketi[$x],$id_lang,$id_lang_def)); $fname[$x] = htmlspecialchars_decode(get_sosed_fname($id_anketi[$x],$id_lang,$id_lang_def)); $love[$x] = $row ['Polovinka']; $x++; } if (($page <> $pages) || ($page > 1)) { $s = $s."
".$text[8]; if ($translation==1) { $s = $s." "; } $s = $s." ".$page." "; $s = $s.$text[9]; if ($translation==1) { $s = $s." "; } $s = $s." ".$pages."
"; } $s = $s.""; $counter = 1; $max_columns = $pos_per_page; for ($y=0;$y<$x;$y++) { if ($counter == 1) $s = $s.""; $s = $s.""; else $s = $s.$city2[$y].""; if ($counter == $max_columns) { $s = $s.""; $counter = 0; } $counter++; } $s = $s."
0) $s = $s."class='love'"; $s = $s." href='sosedi.php?people&anketa=".$id_anketi[$y]."'>
".$name[$y]." ".$fname[$y]."

"; if ($id_pos[$y]>0) $s = $s."".$city2[$y]."
"; //Если анкет больше 50 показывать навигационную панель if ($count_people > $pic_per_page) { //навигация по страницам $s = $s."".$text[10]."
"; if ($translation==1) { $s = $s." "; } $z = "sosedi.php?people"; if ($country1>0) $z=$z."&country=".$country1; if ($region1>0) $z=$z."®ion=".$region1; if ($city1>0) $z=$z."&city=".$city1; if ($love1>0) $z=$z."&love=".$love1; if ($pol1<2) $z=$z."&pol=".$pol1; if ($build1>0) $z=$z."&build=".$build1; if ($range1>0) $z=$z."&range=".$range1; $z=$z."&page="; $s = $s."
".LeftRight($count_people,$page-1,$z,$pic_per_page)."
"; } } // =======================================ГОРОД====================================================== if ( (isset($_REQUEST['country'])) && (isset($_REQUEST['region'])) && (isset($_REQUEST['city'])) && (!isset($_REQUEST['people'])) ) { $id_country = quote_smart(trim(htmlspecialchars($_REQUEST['country']))); $id_region = quote_smart(trim(htmlspecialchars($_REQUEST['region']))); $id_city = quote_smart(trim(htmlspecialchars($_REQUEST['city']))); $name_country = htmlspecialchars_decode(list_name(1,$id_country,$id_lang,$id_lang_def)); $name_region = htmlspecialchars_decode(list_name(2,$id_region,$id_lang,$id_lang_def)); $name_city = htmlspecialchars_decode(list_name(3,$id_city,$id_lang,$id_lang_def)); $flag = flag($id_country); $s = $s."

"; $s = $s."
".$name_country."
".$name_region."
".$name_city."


"; $count_male = $count_female = $count_countries = $count_people = 0; $count_countries = count_countries(); $count_male = count_people(1,0,$id_country,$id_region,$id_city); $count_female = count_people(0,0,$id_country,$id_region,$id_city); $count_people = $count_male + $count_female; $count_male_love = count_people(1,1,$id_country,$id_region,$id_city); $count_female_love = count_people(0,1,$id_country,$id_region,$id_city); $count_love = $count_male_love + $count_female_love; $count_male_build = count_people(1,2,$id_country,$id_region,$id_city); $count_female_build = count_people(0,2,$id_country,$id_region,$id_city); $count_all_build = $count_male_build + $count_female_build; if ($count_male == 0) $percent_male = 0; else $percent_male = round($count_male/$count_people*100,2); if ($count_female == 0) $percent_female = 0; else $percent_female = round($count_female/$count_people*100,2); if ($count_love == 0) $percent_love = 0; else $percent_love = round($count_love/$count_people*100,2); if ($count_male_love == 0) $percent_male_love = 0; else $percent_male_love = round($count_male_love/$count_male*100,2); if ($count_female_love == 0) $percent_female_love = 0; else $percent_female_love = round($count_female_love/$count_female*100,2); if ($count_all_build == 0) $percent_build = 0; else $percent_build = round($count_all_build/$count_people*100,2); if ($count_male_build == 0) $percent_male_build = 0; else $percent_male_build = round($count_male_build/$count_male*100,2); if ($count_female_build == 0) $percent_female_build = 0; else $percent_female_build = round($count_female_build/$count_female*100,2); $s = $s."
".$text[11].""; //Статистика по населённому пункту if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12].""; // ".$text[12]." if ($translation==1) { $s = $s." "; } $s = $s."".$text[13].""; // женщин if ($translation==1) { $s = $s." "; } $s = $s."".$text[14].""; // вместе if ($translation==1) { $s = $s." "; } $s = $s."
".$text[15].""; // зарегистрировано if ($translation==1) { $s = $s." "; } $s = $s." ".$count_male." (".$percent_male."%) ".$count_female." (".$percent_female."%) ".$count_people."
".$text[16].""; // ищут половинок if ($translation==1) { $s = $s." "; } $s = $s."".$count_male_love." (".$percent_male_love."%) ".$count_female_love." (".$percent_female_love."%) ".$count_love." (".$percent_love."%)
".$text[17].""; // уже создают поместья if ($translation==1) { $s = $s." "; } $s = $s."".$count_male_build." (".$percent_male_build."%) ".$count_female_build." (".$percent_female_build."%) ".$count_all_build." (".$percent_build."%)

"; $s = $s.""; $title_age=array(" ".$text[19]." 20","20 - 29","30-39","40-49","50-59","60-69","70-79"," ".$text[20]." 80"); if ($translation==1) { $s = $s."   "; // младше $s = $s." "; // старше } for ($x=1;$x<9;$x++) { $count_male_age = count_age($x,1,$id_country,$id_region,$id_city); $count_female_age = count_age($x,0,$id_country,$id_region,$id_city); $count_all_age = $count_male_age + $count_female_age; if ($count_all_age == 0) $percent_all_age = 0; else $percent_all_age = round($count_all_age/$count_people*100,2); if ($count_male_age == 0) $percent_male_age = 0; else $percent_male_age = round($count_male_age/$count_male*100,2); if ($count_female_age == 0) $percent_female_age = 0; else $percent_female_age = round($count_female_age/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[18].""; // Распределение по возрасту if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$title_age[$x-1]." ".$count_male_age." (".$percent_male_age."%) ".$count_female_age." (".$percent_female_age."%) ".$count_all_age." (".$percent_all_age."%)


"; $s = $s." "; if ($translation==1) { $s = $s." "; } //стрелка назад } // =======================================ОБЛАСТЬ====================================================== if ( (isset($_REQUEST['country'])) && (isset($_REQUEST['region'])) && (!isset($_REQUEST['city'])) && (!isset($_REQUEST['people'])) ) { $id_country = quote_smart(trim(htmlspecialchars($_REQUEST['country']))); $id_region = quote_smart(trim(htmlspecialchars($_REQUEST['region']))); $name_country = htmlspecialchars_decode(list_name(1,$id_country,$id_lang,$id_lang_def)); $name_region = htmlspecialchars_decode(list_name(2,$id_region,$id_lang,$id_lang_def)); $flag = flag($id_country); $s = $s."

"; $s = $s."
".$name_country."
".$name_region."


"; $count_male = $count_female = $count_countries = $count_people = 0; $count_countries = count_countries(); $count_male = count_people(1,0,$id_country,$id_region); $count_female = count_people(0,0,$id_country,$id_region); $count_people = $count_male + $count_female; $count_male_love = count_people(1,1,$id_country,$id_region); $count_female_love = count_people(0,1,$id_country,$id_region); $count_love = $count_male_love + $count_female_love; $count_male_build = count_people(1,2,$id_country,$id_region); $count_female_build = count_people(0,2,$id_country,$id_region); $count_all_build = $count_male_build + $count_female_build; if ($count_male == 0) $percent_male = 0; else $percent_male = round($count_male/$count_people*100,2); if ($count_female == 0) $percent_female = 0; else $percent_female = round($count_female/$count_people*100,2); if ($count_love == 0) $percent_love = 0; else $percent_love = round($count_love/$count_people*100,2); if ($count_male_love == 0) $percent_male_love = 0; else $percent_male_love = round($count_male_love/$count_male*100,2); if ($count_female_love == 0) $percent_female_love = 0; else $percent_female_love = round($count_female_love/$count_female*100,2); if ($count_all_build == 0) $percent_build = 0; else $percent_build = round($count_all_build/$count_people*100,2); if ($count_male_build == 0) $percent_male_build = 0; else $percent_male_build = round($count_male_build/$count_male*100,2); if ($count_female_build == 0) $percent_female_build = 0; else $percent_female_build = round($count_female_build/$count_female*100,2); $s = $s."
".$text[21].""; // Cтатистика по области if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$text[15]." ".$count_male." (".$percent_male."%) ".$count_female." (".$percent_female."%) ".$count_people."
".$text[16]." ".$count_male_love." (".$percent_male_love."%) ".$count_female_love." (".$percent_female_love."%) ".$count_love." (".$percent_love."%)
".$text[17]." ".$count_male_build." (".$percent_male_build."%) ".$count_female_build." (".$percent_female_build."%) ".$count_all_build." (".$percent_build."%)

"; $s = $s.""; $title_age=array(" ".$text[19]." 20","20 - 29","30-39","40-49","50-59","60-69","70-79"," ".$text[20]." 80"); for ($x=1;$x<9;$x++) { $count_male_age = count_age($x,1,$id_country,$id_region); $count_female_age = count_age($x,0,$id_country,$id_region); $count_all_age = $count_male_age + $count_female_age; if ($count_all_age == 0) $percent_all_age = 0; else $percent_all_age = round($count_all_age/$count_people*100,2); if ($count_male_age == 0) $percent_male_age = 0; else $percent_male_age = round($count_male_age/$count_male*100,2); if ($count_female_age == 0) $percent_female_age = 0; else $percent_female_age = round($count_female_age/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[18]."
".$text[12]."".$text[13]."".$text[14]."
".$title_age[$x-1]." ".$count_male_age." (".$percent_male_age."%) ".$count_female_age." (".$percent_female_age."%) ".$count_all_age." (".$percent_all_age."%)

"; $s = $s.""; $query = "SELECT Cities.ID_City, RusName FROM `Cities`,`Anketi` WHERE Cities.ID_City=Anketi.ID_City AND Anketi.Active=1 AND Anketi.ID_Region=".$id_region." GROUP BY ".get_order_lang($lang)." ORDER BY ".get_order_lang($lang)." ASC"; // $query = "SELECT * FROM `Cities` WHERE ID_Region=".$id_region." GROUP BY RusName ORDER BY RusName ASC"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) { $id_city = $row ['ID_City']; $name = htmlspecialchars_decode(list_name(3,$id_city,$id_lang,$id_lang_def)); $count_male_city = count_age(0,1,$id_country,$id_region,$id_city); $count_female_city = count_age(0,0,$id_country,$id_region,$id_city); $count_all_city = $count_male_city + $count_female_city; if ($count_all_city == 0) $percent_all_city = 0; else $percent_all_city = round($count_all_city/$count_people*100,2); if ($count_male_city == 0) $percent_male_city = 0; else $percent_male_city = round($count_male_city/$count_male*100,2); if ($count_female_city == 0) $percent_female_city = 0; else $percent_female_city = round($count_female_city/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[22].""; // Распределение по населённым пунктам if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$name.""; if ($translation==1) { $s = $s." "; } $s = $s."".$count_male_city." (".$percent_male_city."%) ".$count_female_city." (".$percent_female_city."%) ".$count_all_city." (".$percent_all_city."%)


"; $s = $s." "; } // =======================================СТРАНА======================================================= if ( (isset($_REQUEST['country'])) && (!isset($_REQUEST['region'])) && (!isset($_REQUEST['city'])) && (!isset($_REQUEST['people']))) { $id_country = quote_smart(trim(htmlspecialchars($_REQUEST['country']))); $name_country = htmlspecialchars_decode(list_name(1,$id_country,$id_lang,$id_lang_def)); $flag = flag($id_country); $s = $s."

"; $s = $s."
".$name_country."


"; $count_male = $count_female = $count_countries = $count_people = 0; $count_countries = count_countries(); $count_male = count_people(1,0,$id_country); $count_female = count_people(0,0,$id_country); $count_people = $count_male + $count_female; $count_male_love = count_people(1,1,$id_country); $count_female_love = count_people(0,1,$id_country); $count_love = $count_male_love + $count_female_love; $count_male_build = count_people(1,2,$id_country); $count_female_build = count_people(0,2,$id_country); $count_all_build = $count_male_build + $count_female_build; if ($count_male == 0) $percent_male = 0; else $percent_male = round($count_male/$count_people*100,2); if ($count_female == 0) $percent_female = 0; else $percent_female = round($count_female/$count_people*100,2); if ($count_love == 0) $percent_love = 0; else $percent_love = round($count_love/$count_people*100,2); if ($count_male_love == 0) $percent_male_love = 0; else $percent_male_love = round($count_male_love/$count_male*100,2); if ($count_female_love == 0) $percent_female_love = 0; else $percent_female_love = round($count_female_love/$count_female*100,2); if ($count_all_build == 0) $percent_build = 0; else $percent_build = round($count_all_build/$count_people*100,2); if ($count_male_build == 0) $percent_male_build = 0; else $percent_male_build = round($count_male_build/$count_male*100,2); if ($count_female_build == 0) $percent_female_build = 0; else $percent_female_build = round($count_female_build/$count_female*100,2); $s = $s."
".$text[23].""; // Cтатистика по стране if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$text[15]." ".$count_male." (".$percent_male."%) ".$count_female." (".$percent_female."%) ".$count_people."
".$text[16]." ".$count_male_love." (".$percent_male_love."%) ".$count_female_love." (".$percent_female_love."%) ".$count_love." (".$percent_love."%)
".$text[17]." ".$count_male_build." (".$percent_male_build."%) ".$count_female_build." (".$percent_female_build."%) ".$count_all_build." (".$percent_build."%)

"; $s = $s.""; $title_age=array(" ".$text[19]." 20","20 - 29","30-39","40-49","50-59","60-69","70-79"," ".$text[20]." 80"); for ($x=1;$x<9;$x++) { $count_male_age = count_age($x,1,$id_country); $count_female_age = count_age($x,0,$id_country); $count_all_age = $count_male_age + $count_female_age; if ($count_all_age == 0) $percent_all_age = 0; else $percent_all_age = round($count_all_age/$count_people*100,2); if ($count_male_age == 0) $percent_male_age = 0; else $percent_male_age = round($count_male_age/$count_male*100,2); if ($count_female_age == 0) $percent_female_age = 0; else $percent_female_age = round($count_female_age/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[18]."
".$text[12]."".$text[13]."".$text[14]."
".$title_age[$x-1]." ".$count_male_age." (".$percent_male_age."%) ".$count_female_age." (".$percent_female_age."%) ".$count_all_age." (".$percent_all_age."%)

"; $s = $s.""; $query = "SELECT Regions.ID_Region, RusName FROM `Regions`,`Anketi` WHERE Regions.ID_Region=Anketi.ID_Region AND Anketi.Active=1 AND Anketi.ID_Country=".$id_country." GROUP BY ".get_order_lang($lang)." ORDER BY ".get_order_lang($lang)." ASC"; // $query = "SELECT * FROM `Regions` WHERE ID_Country=".$id_country." GROUP BY RusName ORDER BY RusName ASC"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) { $id_region = $row ['ID_Region']; $name = htmlspecialchars_decode(list_name(2,$id_region,$id_lang,$id_lang_def)); $count_male_region = count_age(0,1,$id_country,$id_region); $count_female_region = count_age(0,0,$id_country,$id_region); $count_all_region = $count_male_region + $count_female_region; if ($count_all_region == 0) $percent_all_region = 0; else $percent_all_region = round($count_all_region/$count_people*100,2); if ($count_male_region == 0) $percent_male_region = 0; else $percent_male_region = round($count_male_region/$count_male*100,2); if ($count_female_region == 0) $percent_female_region = 0; else $percent_female_region = round($count_female_region/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[24].""; // Распределение по областям if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$name.""; if ($translation==1) { $s = $s." "; } $s = $s."".$count_male_region." (".$percent_male_region."%) ".$count_female_region." (".$percent_female_region."%) ".$count_all_region." (".$percent_all_region."%)


"; $s = $s." "; } // =======================================ОБЩАЯ СТАТИСТИКА====================================================== if (isset($_REQUEST['stat'])) { $s = $s."

"; $count_male = $count_female = $count_countries = $count_people = 0; $count_countries = count_countries(); $count_male = count_people(1); $count_female = count_people(0); $count_people = $count_male + $count_female; $count_male_love = count_people(1,1); $count_female_love = count_people(0,1); $count_love = $count_male_love + $count_female_love; $count_male_build = count_people(1,2); $count_female_build = count_people(0,2); $count_all_build = $count_male_build + $count_female_build; if ($count_male == 0) $percent_male = 0; else $percent_male = round($count_male/$count_people*100,2); if ($count_female == 0) $percent_female = 0; else $percent_female = round($count_female/$count_people*100,2); if ($count_love == 0) $percent_love = 0; else $percent_love = round($count_love/$count_people*100,2); if ($count_male_love == 0) $percent_male_love = 0; else $percent_male_love = round($count_male_love/$count_male*100,2); if ($count_female_love == 0) $percent_female_love = 0; else $percent_female_love = round($count_female_love/$count_female*100,2); if ($count_all_build == 0) $percent_all_build = 0; else $percent_all_build = round($count_all_build/$count_people*100,2); if ($count_male_build == 0) $percent_male_build = 0; else $percent_male_build = round($count_male_build/$count_male*100,2); if ($count_female_build == 0) $percent_female_build = 0; else $percent_female_build = round($count_female_build/$count_female*100,2); $s = $s."
".$text[26]; // На данный момент зарегистрировались if ($translation==1) { $s = $s." "; } $s = $s." ".$count_people." ".$text[27]; // человек из if ($translation==1) { $s = $s." "; } $s = $s." ".$count_countries." ".$text[28]; // стран if ($translation==1) { $s = $s." "; } $s = $s."

"; $s = $s."
".$text[29].""; // Общая статистика if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$text[15]." ".$count_male." (".$percent_male."%) ".$count_female." (".$percent_female."%) ".$count_people."
".$text[16]." ".$count_male_love." (".$percent_male_love."%) ".$count_female_love." (".$percent_female_love."%) ".$count_love." (".$percent_love."%)
".$text[17]." ".$count_male_build." (".$percent_male_build."%) ".$count_female_build." (".$percent_female_build."%) ".$count_all_build." (".$percent_all_build."%)

"; $s = $s.""; $title_age=array(" ".$text[19]." 20","20 - 29","30-39","40-49","50-59","60-69","70-79"," ".$text[20]." 80"); for ($x=1;$x<9;$x++) { $count_male_age = count_age($x,1); $count_female_age = count_age($x,0); $count_all_age = $count_male_age + $count_female_age; if ($count_all_age == 0) $percent_all_age = 0; else $percent_all_age = round($count_all_age/$count_people*100,2); if ($count_male_age == 0) $percent_male_age = 0; else $percent_male_age = round($count_male_age/$count_male*100,2); if ($count_female_age == 0) $percent_female_age = 0; else $percent_female_age = round($count_female_age/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[18]."
".$text[12]."".$text[13]."".$text[14]."
".$title_age[$x-1]." ".$count_male_age." (".$percent_male_age."%) ".$count_female_age." (".$percent_female_age."%) ".$count_all_age." (".$percent_all_age."%)

"; $s = $s.""; $query = "SELECT Countries.ID_Country FROM `Countries`,`Anketi` WHERE Countries.ID_Country=Anketi.ID_Country AND Anketi.Active=1 GROUP BY ".get_order_lang($lang)." ORDER BY ".get_order_lang($lang)." ASC"; // $query = "SELECT * FROM Countries ORDER BY RusName ASC"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) { $id_country = $row ['ID_Country']; $name = htmlspecialchars_decode(list_name(1,$id_country,$id_lang,$id_lang_def)); $count_male_country = count_age(0,1,$id_country); $count_female_country = count_age(0,0,$id_country); $count_all_country = $count_male_country + $count_female_country; if ($count_all_country == 0) $percent_all_country = 0; else $percent_all_country = round($count_all_country/$count_people*100,2); if ($count_male_country == 0) $percent_male_country = 0; else $percent_male_country = round($count_male_country/$count_male*100,2); if ($count_female_country == 0) $percent_female_country = 0; else $percent_female_country = round($count_female_country/$count_female*100,2); $s = $s.""; } $s = $s."
".$text[30].""; // Распределение по странам if ($translation==1) { $s = $s." "; } $s = $s."
".$text[12]."".$text[13]."".$text[14]."
".$name.""; if ($translation==1) { $s = $s." "; } $s = $s." ".$count_male_country." (".$percent_male_country."%) ".$count_female_country." (".$percent_female_country."%) ".$count_all_country." (".$percent_all_country."%)

"; } // выводим результат $master->content["Content"] = $s; $master->Fill(); function lis_name($what,$id) { switch ($what) { case "1": $of_what = "Country"; $of_table = "Countries"; break; case "2": $of_what = "Region"; $of_table = "Regions"; break; case "3": $of_what = "City"; $of_table = "Cities"; break; default: $of_what = "Country"; $of_table = "Countries"; break; } $what_name = ""; $query = "SELECT RusName FROM ".$of_table." WHERE ID_".$of_what."=".$id." "; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $what_name = $row ['RusName']; return $what_name; //русские названия стран, областей,городов } function list_name($what,$id,$id_lang,$id_lang_def) { switch ($what) { case "1": $of_what = "Country"; $of_table = "Countries"; break; case "2": $of_what = "Region"; $of_table = "Regions"; break; case "3": $of_what = "City"; $of_table = "Cities"; break; default: $of_what = "Country"; $of_table = "Countries"; break; } if ( $_SESSION['Translator']==1 && $_SESSION['Trans_to_lang']==$lang ) $translation=1; $query = "SELECT Text FROM Translations WHERE ID_Language='".$id_lang."' AND Module='".$of_table."' AND Mark=".$id." ORDER BY Mark ASC"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $text = $row ['Text']; if (strlen($text)<1) { $query = "SELECT Text FROM Translations WHERE ID_Language='".$id_lang_def."' AND Module='".$of_table."' AND Mark=".$id." ORDER BY Mark ASC"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $text = $row ['Text']; } if (strlen($text)<1) { $query = "SELECT RusName FROM ".$of_table." WHERE ID_".$of_what."=".$id." "; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $text = $row ['RusName']; } return $text; //названия стран, областей,городов } function count_countries() { $counter_countries=0; $query = "SELECT count(ID_Country) AS Countries FROM `Anketi` WHERE ID_Country>0 AND Active=1 GROUP BY ID_Country"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) { $count_people = $row ['Countries']; $counter_countries++; } return $counter_countries; //стран } function flag($country) { $query = "SELECT Domain FROM `Countries` WHERE ID_Country=".$country.""; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $flag = $row ['Domain']; $flag = $flag.".png"; return $flag; //флаг страны } function count_people($pol,$to_do=0,$country=0,$region=0,$city=0,$range=0) { $query = "SELECT count(Pol) AS Pol FROM `Anketi` WHERE Active=1 "; if ($pol <2) { $query = $query."AND Pol=".$pol." "; } if ($to_do>0) { switch ($to_do) { case 1: $query = $query."AND Polovinka=1 "; break; case 2: $query = $query."AND Pomestie=1 "; break; default: break; } } if ($country>0) { $query = $query."AND ID_Country=".$country." "; } if ($region>0) { $query = $query."AND ID_Region=".$region." "; } if ($city>0) { $query = $query."AND ID_City=".$city." "; } if ($range>0) { $today = date('Y-m-d'); switch ($range) { case "0": $start_date = '1900-01-01'; $end_date = $today; $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "1": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-20); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $end_date = $today; $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "2": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-30); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-20); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "3": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-40); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-30); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "4": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-50); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-40); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "5": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-60); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-50); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "6": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-70); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-60); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "7": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-80); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-70); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; case "8": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-150); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-80); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; default: $start_date = '1900-01-01'; $end_date = $today; $query = $query." AND (Born BETWEEN '".$start_date."' AND '".$end_date."')"; break; } } $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $count_people_pol = $row ['Pol']; return $count_people_pol; } function get_age($id_anketi) { $query = "SELECT Born FROM `Anketi` WHERE ID_anketi=".$id_anketi.""; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $born = $row ['Born']; $today_unix = mktime(0, 0, 0, date("m"), date("d"), date("Y")); sscanf($born,"%04d-%02d-%02d",$t_year,$t_month,$t_day); $born_unix = mktime(0,0,0,$t_month,$t_day,$t_year); $age_unix = $today_unix - $born_unix; $age = floor($age_unix/ (365*24*60*60)); return $age; //флаг страны } function count_age($range,$pol,$country=0,$region=0,$city=0) { $today = date('Y-m-d'); $count_age = 0; switch ($range) { case "0": $start_date = '1900-01-01'; $end_date = $today; break; case "1": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-20); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $end_date = $today; break; case "2": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-30); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-20); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; case "3": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-40); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-30); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; case "4": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-50); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-40); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; case "5": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-60); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-50); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; case "6": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-70); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-60); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; case "7": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-80); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-70); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; case "8": $z_date = mktime(0, 0, 0, date("m"), date("d")+1, date("Y")-150); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $start_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); $z_date = mktime(0, 0, 0, date("m"), date("d"), date("Y")-80); $t_date = getdate($z_date); $t_day = $t_date['mday']; $t_month = $t_date['mon']; $t_year = $t_date['year']; $end_date = sprintf("%04d-%02d-%02d",$t_year,$t_month,$t_day); break; default: $start_date = '1900-01-01'; $end_date = $today; break; } $query = "SELECT Count(Born) AS Born FROM `Anketi` WHERE Active=1 AND (Born BETWEEN '$start_date' AND '$end_date') AND Pol=".$pol." "; if ($country>0) { $query = $query."AND ID_Country=".$country." "; } if ($region>0) { $query = $query."AND ID_Region=".$region." "; } if ($city>0) { $query = $query."AND ID_City=".$city." "; } $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $count_age = $row ['Born']; return $count_age; //число людей в возрастной группе } function quote_smart($value) { // если magic_quotes_gpc включена - используем stripslashes if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Если переменная - число, то экранировать её не нужно // если нет - то окружем её кавычками, и экранируем if (!is_numeric($value)) { $value = "'" . mysqli_real_escape_string($value) . "'"; } return $value; } function is_active($id) { $id = quote_smart(trim(htmlspecialchars(intval($id)))); $query = "SELECT Active FROM Anketi WHERE ID_anketi='$id' "; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $active = $row ['Active']; return $active; } function get_sosed_name($id_sosed,$id_lang,$id_lang_def) { $id_sosed = quote_smart(trim(htmlspecialchars($id_sosed))); $query = "SELECT Text FROM Translations WHERE ID_Language=".$id_lang." AND Module='sosed_name' AND Mark=".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $name = $row ['Text']; if (strlen($name)<1) { $query = "SELECT Text FROM Translations WHERE ID_Language=".$id_lang_def." AND Module='sosed_name' AND Mark=".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $name = $row ['Text']; } if (strlen($name)<1) { $query = "SELECT Name FROM Anketi WHERE ID_anketi =".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $name = $row ['Name']; } return $name; } function get_sosed_fname($id_sosed,$id_lang,$id_lang_def) { $id_sosed = quote_smart(trim(htmlspecialchars($id_sosed))); $query = "SELECT Text FROM Translations WHERE ID_Language=".$id_lang." AND Module='sosed_fname' AND Mark=".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $fname = $row ['Text']; if (strlen($fname)<1) { $query = "SELECT Text FROM Translations WHERE ID_Language=".$id_lang_def." AND Module='sosed_fname' AND Mark=".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $fname = $row ['Text']; } if (strlen($fname)<1) { $query = "SELECT FName FROM Anketi WHERE ID_anketi =".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $fname = $row ['FName']; } return $fname; } function get_sosed_about($id_sosed,$id_lang,$id_lang_def) { $id_sosed = quote_smart(trim(htmlspecialchars($id_sosed))); $query = "SELECT Text FROM Translations WHERE ID_Language=".$id_lang." AND Module='sosed_about' AND Mark=".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $fname = $row ['Text']; if (strlen($fname)<1) { $query = "SELECT Text FROM Translations WHERE ID_Language=".$id_lang_def." AND Module='sosed_about' AND Mark=".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $fname = $row ['Text']; } if (strlen($fname)<1) { $query = "SELECT About FROM Anketi WHERE ID_anketi =".$id_sosed; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $fname = $row ['About']; } return $fname; } function get_idpos_by_idcity($id_city) { $id_city = quote_smart(trim(htmlspecialchars($id_city))); $query = "SELECT ID_Poselenia FROM Cities WHERE ID_City=".$id_city; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $id_pos = $row ['ID_Poselenia']; if ($id_pos==NULL) $id_pos=0; return $id_pos; } function LeftRight($records,$r_start,$URL,$inpage) { $str=""; if($records<=$inpage) return; /* if($r_start!=0) { $str.="« "; $str.=" "; }else $str.="« ‹ "; */ if($records%$inpage==0) $add=0; else $add=1; $page_count=(intval($records/$inpage)+$add); if($r_start>$page_count || $r_start<=0) $r_start=0; #Считаем количество страниц if($records%$inpage==0) $add=0; else $add=1; $page_count=(intval($records/$inpage)+$add); if ($r_start<5) {$sstart=0;$send=10;} if ($r_start>=5) {$sstart=$r_start-5;$send=$r_start+5;} if ($r_start>($page_count-5)) {$sstart=$page_count-10;$send=$page_count;} #Ссылки на первые 10 страниц, начиная с первой if($r_start<5) { $sstart=0; $send=10; } #Ссылки на 10 страниц, влево и вправо по 5, относительно текущей if($r_start>=5 and $r_start<=($page_count-5)){ $sstart=$r_start-5; $send=$r_start+5; } #Ссылки на последние 10 страниц if($r_start>($page_count-5)) { $sstart=$page_count-10; $send=$page_count; } if($sstart<0) $sstart=0; if($send*$inpage>$records) $send=$page_count; #Выводим список ссылок for($i=$sstart;$i<$send;$i++) { if($i==$r_start) $str.="".($i+1)." "; else $str.="".($i+1)." "; } /* if($r_start+1<$page_count) { $str.=""; $str.=" »"; } else $str.="› »"; */ return($str); } function get_poselenie_id($id) { $id = quote_smart(trim(htmlspecialchars(intval($id)))); $query = "SELECT ID_Poselenia FROM Sosedi_Pos WHERE ID_Anketi=$id"; $result = mysqli_query ($query) or die ("Ошибка выполнения запроса: ".mysqli_error()); while ($row = mysqli_fetch_array ($result)) $idpos = $row ['ID_Poselenia']; if ($idpos>0) return $idpos; else return false; } ?>