PDA

View Full Version : get_resolution php



tehro0n
سه شنبه 09 شهریور 1389, 03:45 صبح
من کدی دارم که با استفاده از کوکی رزولوشین کاربر رو می گیره و ذخیره می کنه.
این کد به تنهایی کار می کنه اما وقتی در مکانی که دارای document.write است قرار می دم دیگه کار نمی کنه و صفحه هیچی رو نشون نمیده!
در این فایل نمایش های بعضی چیزها با document.write انجام میشه.


if (isset($_COOKIE["users_res"])) {
$_screen = $_COOKIE["users_res"];
} else {
include("resolution");
$_screen = $screen_width."x".$screen_height;
}

فایل resolution.php


<script language="javascript">
<!--
function writeCookie() {
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_res="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
if (document.cookie) {
location = '<?php echo $GLOBALS['callget_res_page_name']; ?>';
}
}


function checkRes(width, height) {
if(width != screen.width || height != screen.height) {
writeCookie();
} else {
return true;
}
}
//-->
</script>

<?php
if (isset($_COOKIE["users_res"])) {
$screen_res = $_COOKIE["users_res"];
$screen_res_tmp = explode("x", $screen_res);
$screen_width = $screen_res_tmp[0];
$screen_height = $screen_res_tmp[1];
?>
<script language="javascript">
<!--
checkRes(<?php echo $screen_width; ?>, <?php echo $screen_height; ?>);
//-->
</script>
<?php
} else { //means cookie is not found set it using Javascript
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>
<?php
}
?>

tehro0n
چهارشنبه 10 شهریور 1389, 16:55 عصر
کسی نمی دونه چی کار باید بکنم؟