[liphp] Sample Code (Improved)

Alexander (Sasha) Mejenkov [email protected]
Fri, 17 Oct 2003 13:21:23 +0400


Hello Orrin,

Here is improved (and simplified) script that passes exact value of
user's screen resolution.

By the way it gives an actual screen resolution, not the
current browser window. You can certain it yourself by changing
browser's window and running script again


<?php
if (isset($_GET['resolution'])) {
                $resolution = "Screen resolution is  ".urldecode($_GET['resolution']);
                $agent = "agent.log";
                $fd1 = fopen($agent, "a");
                $today = getdate();
                $year = $today['year'];
                $month = $today['mon'];
                $day = $today['mday'];
                $hour = $today['hours'];
                $min = $today['minutes'];
                $adata = $_SERVER["HTTP_USER_AGENT"];
                $agent_log = "$year-$month-$day $hour:$min  ";
                $agent_log .=  "{$adata}\n";
                $agent_log .=  "$resolution\n";
                fwrite($fd1, "$agent_log");
                fclose($fd1);
                echo $agent_log;
        }
else {
?>
<SCRIPT LANGUAGE="JavaScript">
<!--
var height=0;
var width=0;
if (self.screen)      // for NN4 � IE4
{
        width = screen.width
        height = screen.height
}
else if (self.java)    // for NN3
{
        var jkit = java.awt.Toolkit.getDefaultToolkit();
        var scrsize = jkit.getScreenSize();
        width = scrsize.width;
        height = scrsize.height;
}

window.location='<?php echo $_SERVER['PHP_SELF'];?>'+'?resolution='+width+'x'+height;
// -->
</SCRIPT>
<?php
}
?>


-- 
Best regards,
 Alexander                            mailto:[email protected]