fork download
  1. <?
  2. header('Content-Type: text/html; charset=utf-8');
  3.  
  4. // ini_set('display_errors',1);
  5. // error_reporting(E_ALL);
  6.  
  7. $regexp = '/[,.;\s ]+/';
  8. $country= $_GET[country];
  9. $city= $_GET[city];
  10.  
  11. $first= preg_split ($regexp, $_GET[country]);
  12. $second= preg_split ($regexp, $_GET[city]);
  13.  
  14. if ($first[1]== false){
  15. $first[0] = preg_replace ("/[^a-zа-я]/ui","/",$first[0]);
  16. unset($first[1]);
  17. }
  18. if ($second[1]== false){
  19. $second[0] = preg_replace ("/[^a-zа-я]/ui","/",$second[0]);
  20. unset($second[1]);
  21. }
  22.  
  23. $link = mysql_connect(localhost, 'sletatru_fedort', '*hrkq6J3');
  24. mysql_select_db ('sletatru_fedort', $link);
  25.  
  26. if ($first[0] == "" ){
  27. $linkcountry[0] = '0';
  28. }else{
  29. foreach ($first as $count){
  30. $str_sql_query = "SELECT id FROM dbCountries WHERE name COLLATE UTF8_GENERAL_CI LIKE '$count' OR alias COLLATE UTF8_GENERAL_CI LIKE '$count' OR alias1 COLLATE UTF8_GENERAL_CI LIKE '$count%' OR alias2 COLLATE UTF8_GENERAL_CI LIKE '$count'";
  31. $countrysSql[] = mysql_query($str_sql_query, $link);
  32. }
  33. foreach ($countrysSql as $countryTable){
  34. while ($line = mysql_fetch_array($countryTable, MYSQL_NUM)) {
  35. foreach ($line as $a){
  36. $linkcountry[] =$a;
  37. }
  38. }
  39. }
  40. }
  41.  
  42. if ($second[0] == "" ){
  43. $linkcity[0] = '832';
  44. }else{
  45. foreach ($second as $cit){
  46. $str_sql_query = "SELECT id FROM dptCities WHERE name COLLATE UTF8_GENERAL_CI LIKE '$cit' OR synonymus COLLATE UTF8_GENERAL_CI LIKE '$cit' OR synonymus1 COLLATE UTF8_GENERAL_CI LIKE '$cit' OR synonymus2 COLLATE UTF8_GENERAL_CI LIKE '$cit' ";
  47. $citiesSql[] = mysql_query($str_sql_query, $link);
  48. }
  49. foreach ($citiesSql as $cityTable){
  50. while ($sline = mysql_fetch_array($cityTable, MYSQL_NUM)) {
  51. foreach ($sline as $s=>$a){
  52. $linkcity[] =$a;
  53. }
  54. }
  55. }
  56. }
  57.  
  58. if ($linkcountry == NULL){
  59. $linkcountry[0]=0;
  60. }
  61. if ($linkcity == NULL){
  62. $linkcity[0]=832;
  63. }
  64. //Тут запиливаем взрослых и детей
  65.  
  66.  
  67. preg_match_all('/\d{1,3}/', $_GET[kids], $preg);
  68. if (!empty($preg[0][1])){
  69. $kids = 2;
  70. }else{
  71. $kids = $preg[0][0];
  72. }
  73. if ($kids > 3){
  74. $kids = 0;
  75. }
  76.  
  77. preg_match_all('/\d{1,3}/', $_GET[adults], $preg);
  78. if (!empty($preg[0][1])){
  79. $adults = 2;
  80. }else{
  81. $adults = $preg[0][0];
  82. }
  83. if ($adults == 0){
  84. $adults = 2;
  85. }else if ($adults > 4){
  86. $adults = 1;
  87. }
  88.  
  89. //Тут запилим количество ночей
  90. preg_match_all('/\d{1,3}/', $_GET[nights], $preg);
  91. $nightsmin = $preg[0][0];
  92. $nightsmax = $preg[0][1];
  93.  
  94. if ($nightsmin==0){
  95. $nightsmin = 14 ;
  96. }else if ($nightsmax==0){
  97. $nightsmax = $nightsmin ;
  98. }else if ($nightsmax < $nightsmin){
  99. $y = $nightsmax;
  100. $nightsmax = $nightsmin;
  101. $nightsmin = $y;
  102. }
  103. if (($_GET[from] == NULL)&&($_GET[to] != NULL)){
  104. $dateF = date_create($_GET[to]);
  105. $dateT = date_create($_GET[to]);
  106. date_modify($dateF, '-7 day');
  107. $dateto = date_format($dateT, 'd-m-Y');
  108. $datefrom = date_format($dateF, 'd-m-Y');
  109. echo $datefrom, '<br>';
  110. echo $dateto, '<br>';
  111. }
  112. if (($_GET[from] != NULL)&&($_GET[to] == NULL)){
  113. $dateF = date_create($_GET[from]);
  114. $dateT = date_create($_GET[from]);
  115. $dateT = date_modify($dateT, '+7 day');
  116. $dateto = date_format($dateT, 'd-m-Y');
  117. $datefrom = date_format($dateF, 'd-m-Y');
  118. }
  119. if (($_GET[from] != NULL)&&($_GET[to] != NULL)){
  120. $dateF = date_create($_GET[from]);
  121. $dateT = date_create($_GET[to]);
  122. $dateto = date_format($dateT, 'd-m-Y');
  123. $datefrom = date_format($dateF, 'd-m-Y');
  124. }
  125.  
  126. //Звезды и еда
  127. $s = preg_replace ("/\[|\]/ui","",$_GET[stars]);
  128. $m = preg_replace ("/\[|\]/ui","",$_GET[meal]);
  129. $st = explode(', ', $s);
  130. $me = explode(', ', $m);
  131.  
  132.  
  133. $foodAndStars = array(
  134. '1*' => '401', //отныне одна звезда - это две звезды!
  135. '2*' => '401',
  136. '3*' => '402',
  137. '4*' => '403',
  138. '5*' => '404',
  139. 'Apts' => '405',
  140. 'Villas' => '406',
  141. 'HV1' => '410',
  142. 'HV2' => '411',
  143. 'Любая' => '',
  144. 'Любое' => '',
  145. 'UAI' => '116',
  146. 'AI' => '115',
  147. 'FB' => '112',
  148. 'FB+' => '121',
  149. 'HB' => '113',
  150. 'HB+' => '122',
  151. 'BB' => '114',
  152. 'RO' => '117',
  153. );
  154. foreach ($st as $ars){
  155. $star[]= $foodAndStars[$ars];
  156. }
  157. $stars = implode(',' ,$star);
  158.  
  159. foreach ($me as $al){
  160. $mea[]= $foodAndStars[$al];
  161. }
  162. $meal = implode(',' ,$mea);
  163.  
  164. if (in_array('Любая', $st)) {
  165. $stars = '';
  166. }
  167.  
  168. if (in_array('Любое', $me)) {
  169. $meal = '';
  170. }
  171.  
  172. $numbers = count($linkcity) + count($linkcountry);
  173. if ($numbers == 2){
  174. header("Location: https://s...content-available-to-author-only...t.ru/?callback=search&country={$linkcountry[0]}&city={$linkcity[0]}&stars={$stars}&meal={$meal}&adults={$adults}&kids={$kids}&datefrom={$datefrom}&dateto={$dateto}&nightsmin={$nightsmin}&nightsmax={$nightsmax}");
  175. }else{
  176. foreach ($linkcity as $n=>$id){
  177. foreach ($linkcountry as $k=>$did){
  178. echo "<div style=\"padding:10; font-size:20\";>$second[$n] - $first[$k]<a href=https://s...content-available-to-author-only...t.ru/?callback=search&country={$did}&city={$id}&stars={$stars}&meal={$meal}&adults={$adults}&kids={$kids}&datefrom={$datefrom}&dateto={$dateto}&nightsmin={$nightsmin}&nightsmax={$nightsmax} target=_blank style=\"padding:10; font-size:20\";>Link</a></div>";
  179. }
  180. }
  181. }
  182. ?>
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
<?
header('Content-Type: text/html; charset=utf-8');

// ini_set('display_errors',1);
// error_reporting(E_ALL);

$regexp = '/[,.;\s ]+/';
$country= $_GET[country];
$city= $_GET[city];

$first= preg_split ($regexp, $_GET[country]);
$second= preg_split ($regexp, $_GET[city]);

if ($first[1]== false){
	$first[0] = preg_replace ("/[^a-zа-я]/ui","/",$first[0]);
	unset($first[1]);
}
if ($second[1]== false){
	$second[0] = preg_replace ("/[^a-zа-я]/ui","/",$second[0]);
	unset($second[1]);
}

mysql_set_charset('utf8');
$link = mysql_connect(localhost, 'sletatru_fedort', '*hrkq6J3');
mysql_select_db ('sletatru_fedort', $link);

if ($first[0] == "" ){
	$linkcountry[0] = '0';
}else{
foreach ($first as $count){
	$str_sql_query = "SELECT id FROM dbCountries WHERE name COLLATE UTF8_GENERAL_CI LIKE '$count' OR alias COLLATE UTF8_GENERAL_CI LIKE '$count' OR alias1 COLLATE UTF8_GENERAL_CI LIKE '$count%' OR alias2 COLLATE UTF8_GENERAL_CI LIKE '$count'";
	$countrysSql[] = mysql_query($str_sql_query, $link);
}
foreach ($countrysSql as $countryTable){ 
while ($line = mysql_fetch_array($countryTable, MYSQL_NUM)) { 
foreach ($line as $a){
$linkcountry[] =$a;
}
} 
}
}

if ($second[0] == "" ){
	$linkcity[0] = '832';
}else{
foreach ($second as $cit){
	$str_sql_query = "SELECT id FROM dptCities WHERE name COLLATE UTF8_GENERAL_CI LIKE '$cit' OR synonymus COLLATE UTF8_GENERAL_CI LIKE '$cit' OR synonymus1 COLLATE UTF8_GENERAL_CI LIKE '$cit' OR synonymus2 COLLATE UTF8_GENERAL_CI LIKE '$cit' ";
	$citiesSql[] = mysql_query($str_sql_query, $link);
}
foreach ($citiesSql as $cityTable){
while ($sline = mysql_fetch_array($cityTable, MYSQL_NUM)) {
foreach ($sline as $s=>$a){
$linkcity[] =$a;
}
} 
}
}

if ($linkcountry == NULL){
	$linkcountry[0]=0;
}
if ($linkcity == NULL){
	$linkcity[0]=832;
}
//Тут запиливаем взрослых и детей


preg_match_all('/\d{1,3}/', $_GET[kids], $preg); 
if (!empty($preg[0][1])){
	$kids = 2;
}else{
$kids = $preg[0][0];
}
if ($kids > 3){
	$kids = 0;
}

preg_match_all('/\d{1,3}/', $_GET[adults], $preg); 
if (!empty($preg[0][1])){
	$adults = 2;
}else{
$adults = $preg[0][0];
}
if ($adults == 0){
	$adults = 2;
}else if ($adults > 4){
	$adults = 1;
}

//Тут запилим количество ночей
preg_match_all('/\d{1,3}/', $_GET[nights], $preg); 
$nightsmin = $preg[0][0];
$nightsmax = $preg[0][1];

if ($nightsmin==0){
	$nightsmin = 14 ;
}else if ($nightsmax==0){
	$nightsmax = $nightsmin ;
}else if ($nightsmax < $nightsmin){
	$y = $nightsmax;
	$nightsmax = $nightsmin;
	$nightsmin = $y;
}	
if (($_GET[from] == NULL)&&($_GET[to] != NULL)){
	$dateF = date_create($_GET[to]);
	$dateT = date_create($_GET[to]);
	date_modify($dateF, '-7 day');
	$dateto = date_format($dateT, 'd-m-Y');
	$datefrom = date_format($dateF, 'd-m-Y');
	echo $datefrom, '<br>';
	echo $dateto, '<br>';
}
	if (($_GET[from] != NULL)&&($_GET[to] == NULL)){
	$dateF = date_create($_GET[from]);
	$dateT = date_create($_GET[from]);
	$dateT = date_modify($dateT, '+7 day');
	$dateto = date_format($dateT, 'd-m-Y');
	$datefrom = date_format($dateF, 'd-m-Y');	
} 
if (($_GET[from] != NULL)&&($_GET[to] != NULL)){
	$dateF = date_create($_GET[from]);
	$dateT = date_create($_GET[to]);
	$dateto = date_format($dateT, 'd-m-Y');
	$datefrom = date_format($dateF, 'd-m-Y');
}

//Звезды и еда
$s = preg_replace ("/\[|\]/ui","",$_GET[stars]);
$m = preg_replace ("/\[|\]/ui","",$_GET[meal]);
$st = explode(', ', $s);
$me = explode(', ', $m);


$foodAndStars = array(
    '1*' => '401', //отныне одна звезда - это две звезды!
    '2*' => '401',
    '3*' => '402',
	'4*' => '403',
	'5*' => '404',
	'Apts' => '405',
	'Villas' => '406',
	'HV1' => '410',
	'HV2' => '411',
	'Любая' => '',
	'Любое' => '',
    'UAI' => '116',
    'AI' => '115',
    'FB' => '112',
	'FB+' => '121',
	'HB' => '113',
	'HB+' => '122',
	'BB' => '114',
	'RO' => '117',
);
foreach ($st as $ars){
$star[]= $foodAndStars[$ars];
}
$stars = implode(',' ,$star);

foreach ($me as $al){
$mea[]= $foodAndStars[$al];
}
$meal = implode(',' ,$mea);

if (in_array('Любая', $st)) {
	$stars = '';
}

if (in_array('Любое', $me)) {
	$meal = '';
}

$numbers = count($linkcity) + count($linkcountry);
if ($numbers == 2){
	header("Location: https://s...content-available-to-author-only...t.ru/?callback=search&country={$linkcountry[0]}&city={$linkcity[0]}&stars={$stars}&meal={$meal}&adults={$adults}&kids={$kids}&datefrom={$datefrom}&dateto={$dateto}&nightsmin={$nightsmin}&nightsmax={$nightsmax}");
}else{
foreach ($linkcity as $n=>$id){
	foreach ($linkcountry as $k=>$did){
		echo "<div style=\"padding:10; font-size:20\";>$second[$n] - $first[$k]<a href=https://s...content-available-to-author-only...t.ru/?callback=search&country={$did}&city={$id}&stars={$stars}&meal={$meal}&adults={$adults}&kids={$kids}&datefrom={$datefrom}&dateto={$dateto}&nightsmin={$nightsmin}&nightsmax={$nightsmax} target=_blank style=\"padding:10; font-size:20\";>Link</a></div>";
	}
}
}
?>