MS IE 8 не работет реффер $_SERVER['HTTP_REFERER']
PHP
хотел использовать изменение сессии для хранения дат, с изменением по урл,
но в ие 8 почему то пустое значение $_SERVER['HTTP_REFERER']
как мне получить это значение
вот код
$URL=$_SERVER['HTTP_REFERER'];увы, но ие 8 не передает рефер по джавескрипту
$strainer1='';$strainer2=''; $strainer3='';
$namepage=$_GET['page'];
if ( strpos($namepage,"news")===FALSE ){$thisnews=0;}else{$thisnews=1;}
if ((isset($_SESSION['show_top_year'])) and (isset($_SESSION['show_top_month'])) ){}else {$user_day =-2;}
if (isset($_SESSION['show_top_year'])) { $user_year = $_SESSION['show_top_year']; } else {$user_year = date("Y"); $_SESSION['show_top_year'] = date("Y");}
if (isset($_SESSION['show_top_month'])) { $user_month = $_SESSION['show_top_month']; }else {$user_month = date("m");$_SESSION['show_top_month'] = date("m");}
if (($_SESSION['show_top_day'])<>'') { $user_day = $_SESSION['show_top_day'];} else {$user_day = date("d");$_SESSION['show_top_day'] = date("d");}//
if ( $user_year==0){$user_year =1 ; }
if ( $user_month==0){ $user_month =1 ; }
if ( $user_day==0){ $user_day =0 ; }/**/
$month_arr = array(
1 => 'Январь',2 => 'Февраль',3 => 'Март',4 => 'Апрель',5 => 'Май',6 => 'Июнь',7 => 'Июль',8 => 'Август',
9 => 'Сентябрь',10 => 'Октябрь',11 => 'Ноябрь',12 => 'Декабрь'
);
$max_day = array(1 => 31,2 => 28,3 => 31,4 => 30,5 => 31,6 => 30,7 => 31,8 => 31,9 => 30,10 => 31,11 => 30,12 => 31);
if (checkdate(2, 29, $user_year))$max_day[2]=29; else $max_day[2]=28; // а какой это у нас год? =)
//проверим высокостный ли год на PHP
$day_arr = array ();
if (isset($_SESSION['show_top_month']) ) {
$day_arr[0] ='Любая';
for($i= 1;$i<$max_day [$user_month]+1;$i++){ $day_arr[$i] = $i; }
$user_day = $_SESSION['show_top_day'];
if ($user_day<=0){$user_day=0;}
}
if ( ($user_month== date("m") ) and ($user_year== date("Y") ))
{ unset($day_arr) ; $day_arr = array ();
$day_arr[-2] ='Сегодня';
$day_arr[-1] ='Вчера';
for($i= date("d")-2;$i>0;$i--){ $day_arr[$i] = $i; }
$user_day = $_SESSION['show_top_day'];
} else {
}
$query =' SELECT min( YEAR (`news_date`)) as minyear FROM `module_news`;
$row = $db->GetRow($query);
if ($row) $minyear = $row['minyear']; else $minyear= date("Y");
$year_arr = array ();
/* date("Y")-2 заменит на мин год новости запросом в бд*/
for($i= date("Y");$i>$minyear-1;$i--)
{
$year_arr[$i] = $i;
}
if (($user_day=='')and ($user_month!= date("m") ) and ($user_year!= date("Y") )) { $user_day = 0 ;}//
// select для дня
if ($thisnews==1) {$strainer1.= "
";}
else { $strainer1.= "
";}
foreach($day_arr as $day_nom=>$day_name)
{
$strainer1.= "$day_name
";
}
$strainer1.="
";
// select для месяца
if ($thisnews==1) {$strainer2.= "
";}
else { $strainer2.= "
";}
foreach($month_arr as $month_nom=>$month_name)
{
if (!( ($user_month== date("m") ) and ($user_year== date("Y") )) )
{
$strainer2.= "$month_name
";
}
else
{
$strainer2.= "
$month_nom==$user_month ? "selected=selected" : NULL ).">$month_name
";
}
}
$strainer2.="
";
// select для года
if ($thisnews==1) { $strainer3.= "
";}
else { $strainer3.= "
";}
foreach($year_arr as $year_nom=>$year_name)
{
$strainer3.= "$year_name
";
}
$strainer3.="
";
if( isset( $_GET['show_top_year'] )){
$TrueDate=$_SESSION['show_top_day'];
if ( $_SESSION['show_top_day']== 0) $TrueDate= date("d");
if ( $_SESSION['show_top_day'] == -1) $TrueDate= date("d")-1;
if ( $_SESSION['show_top_day'] == -2) $TrueDate= date("d")-2;
if (!checkdate($_SESSION['show_top_month'],$TrueDate, $_GET['show_top_year'])) { $_SESSION['show_top_day'] = 0 ; $_GET['show_top_year'] =date("Y");}
// die($TrueDate. $_SESSION['show_top_day'] );
$_SESSION['show_top_year'] = $_GET['show_top_year'] ;
// if (strpos($URL, "?show_top_year=")>0) $URL= substr($URL,0,strpos($URL, "?show_top_year="));
$pos=strpos($URL, "?show_top_year=");
if ($pos>0) $URL= substr($URL,0,$pos);
if ($URL<>'') header ("Location: ". $URL);
}
if( isset( $_GET['show_top_month'] )){
$TrueDate=$_SESSION['show_top_day'];
if ( $_SESSION['show_top_day'] == 0) $TrueDate= date("d");
if ( $_SESSION['show_top_day'] == -1) $TrueDate= date("d")-1;
if ( $_SESSION['show_top_day'] == -2) $TrueDate= date("d")-2;
if (!checkdate( $_GET['show_top_month'],$TrueDate, $_SESSION['show_top_year'])) { $_SESSION['show_top_day'] = 0 ; $_GET['show_top_month'] =date("m"); }
$_SESSION['show_top_month'] = $_GET['show_top_month'] ;
$pos=strpos($URL, "?show_top_month=");
if ($pos>0) $URL= substr($URL,0,$pos);
//if (strpos($URL, "?show_top_month=")>0) $URL= substr($URL,0,strpos($URL, "?show_top_month="));
if ($URL<>'') header ("Location: ". $URL);
}
if( isset( $_GET['show_top_day'] )){
$TrueDate=$_GET['show_top_day'];
if ( $_GET['show_top_day'] == 0) $TrueDate= date("d");
if ( $_GET['show_top_day'] == -1) $TrueDate= date("d")-1;
if ( $_GET['show_top_day'] == -2) $TrueDate= date("d")-2;
if (!checkdate($_SESSION['show_top_month'], $TrueDate, $_SESSION['show_top_year']))
{// $_GET['show_top_day'] =$TrueDate;
$_SESSION['show_top_day'] = 0 ;
}
else $_SESSION['show_top_day'] = $_GET['show_top_day'] ;
$pos=strpos($URL, "?show_top_day=");
if ($pos>0) $URL= substr($URL,0,$pos);
if ($URL<>'') header ("Location: ". $URL);
}
а это условия для выбора новостей за сегодня, вчера,и за определенный день, в зависимости от значения переменных фильтра сессий на php
if ( ($_SESSION['show_top_day']==0)) // любая
{
}
if (($_SESSION['show_top_day']==-2)) // СЕГОДНЯ
{
$query1 .= " AND (DAY( news_date ) = DAY( CURDATE()) ) ";
$query2 .= " AND (DAY( news_date ) = DAY( CURDATE()) ) ";
$stainer_date.=" AND (DAY( news_date ) = DAY( CURDATE()) ) ";
}
if($_SESSION['show_top_day']==-1) //ВЧЕРА
{
$query1 .= " AND (DAY( news_date )= DAY( (CURDATE()-1)) ) ";
$query2 .= " AND (DAY( news_date )= DAY( (CURDATE()-1)) ) ";
$stainer_date.= " AND (DAY( news_date )= DAY( (CURDATE()-1)) ) ";
}
if(( $_SESSION['show_top_day']) and($_SESSION['show_top_day']>0) )
{
$query1 .= " AND ( DAY( news_date ) = '".$_SESSION['show_top_day']."')";
$query2 .= " AND ( DAY( news_date ) = '".$_SESSION['show_top_day']."')";
$stainer_date.=" AND ( DAY( news_date ) = '".$_SESSION['show_top_day']."')";
}
if($_SESSION['show_top_month']>0)
{
$query1 .= " AND ( MONTH ( news_date ) = '".$_SESSION['show_top_month']."')";
$query2 .= " AND ( MONTH ( news_date ) = '".$_SESSION['show_top_month']."')";
$stainer_date.= " AND ( MONTH ( news_date ) = '".$_SESSION['show_top_month']."')";
}
if($_SESSION['show_top_year']>1)
{
$query1 .= " AND ( YEAR ( news_date ) = '".$_SESSION['show_top_year']."')";
$query2 .= " AND ( YEAR ( news_date ) = '".$_SESSION['show_top_year']."')";
$stainer_date.= " AND ( YEAR ( news_date ) = '".$_SESSION['show_top_year']."')";
}
}// конец only_today
$_SESSION['stainer_date'] =$stainer_date;
} // end strainer
Комментарии
Оставить комментарий
Выполнение скриптов на стороне сервера PHP (LAMP) NodeJS (Backend)
Термины: Выполнение скриптов на стороне сервера PHP (LAMP) NodeJS (Backend)