悠悠楠杉
网站页面
把以下代码放到模板下的play.php
PHP代码(放到<!DOCTYPE html>之前)
<?php
$play = $_GET['play'];
preg_match('#/.*?/(.*?).html#',$play,$str);
// print_r($str[1]);
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
$full_url = $http_type.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(isset($_COOKIE[$str[1]])){
if(!isset($_GET['id']) || $_GET['id'] != $_COOKIE[$str[1]]){
$idwz = stripos($full_url,'&id=');
if($idwz !== false){
$full_url = substr($full_url,0,$idwz);
}
header('location:'.$full_url.'&id='.$_COOKIE[$str[1]]);
}
}
?>
js代码(放到
之前)
<script>
$(function(){
$('body').on('click','.btn.btn-min.btn-gray',function(){
id = $(this).attr('id');
str = '<?php echo $str[1];?>';
if(str != ''){
document.cookie = str+'='+id;
}
})
$('#selectyear').on('change',function(){
xuanzhe = $("#selectyear").find("option:selected");
str = '<?php echo $str[1];?>';
if(str != ''){
document.cookie = str+'_year='+xuanzhe.attr("year");
}
})
id = '<?php if(isset($_GET['id']) && $_GET['id']){echo $_GET['id'];}?>';
if(id != ''){
<?php
echo '$(".btn-play-active").attr("style","");$(".btn-play-active").removeClass("btn-play-active");';
if($Prefix != $dyPrefix && $Prefix != $dsjPrefix && $Prefix != $dmPrefix){
if((isset($_COOKIE[$str[1].'_year']) && $_COOKIE[$str[1].'_year']) || (isset($_GET['year']) && $_GET['year'])){
$year = isset($_COOKIE[$str[1].'_year']) ? $_COOKIE[$str[1].'_year'] : $_GET['year'];
echo '$(\'#selectyear\').find(\'option[year="'.$year.'"]\').attr("selected",true);qieyear();';
echo "if(id.indexOf('-') != '-1'){setTimeout(function(){sid = id.split('-')[0];\$(\"[href='#\"+sid+\"']\").click();},1000)}else{setTimeout(function(){sid = \$('#'+id).parent().parent().parent().attr('id');\$(\"[href='#\"+sid+\"']\").click()},1000);}setTimeout(function(){\$('#'+id).click()},1000);";
}else{
echo "tabId = $('#'+id).parent().parent().parent().attr('id');$(\"[href='#\"+tabId+\"']\").click();$('#'+id).click();";
}
}else{
echo "$('#'+id).click();";
}
?>
}
})
</script>