[liphp] Sample Code

Alexander (Sasha) Mejenkov [email protected]
Fri, 17 Oct 2003 12:51:17 +0400


Hello Orrin,

Here is how you can find out agent's screen resolution and include it
into your log

<?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;
}
<?php  
$JS_string = "";
?>
if (width <= 800 && height <= 600) { 
        document.write('<?php echo 
'<script>window.location="'.$_SERVER['PHP_SELF'].'?resolution='.urlencode("less than or equal 800x600").'"</script>'?>');
}
else { 
        document.write('<?php echo 
'<script>window.location="'.$_SERVER['PHP_SELF'].'?resolution='.urlencode("greater than 800x600").'"</script>'?>');
}
// -->
</SCRIPT>
<?php
}
?>


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