<?php
        
/////////////////////////////////////////////////////////
        //
        //  AHNAR CSA3004 APT University of Malta
        //  Ian Bugeja 2005
        //
        //////////////////////////////////////////////////////////

        
session_start();
        
header("Cache-control: private"); // IE 6 Fix.

        
$url $_REQUEST["ahurl"];
        
$title $_REQUEST["ahtit"];
    
        
$_SESSION["bookmark"][] = $url;
    
        if (
$url == end($_SESSION['visited'])) //hope that user has not opened another page before to bookmark this
        
{
            
//as page has been bookmarked then last page keywords should be made more important
            
if (isset($_SESSION['keywords'])) //keywords in session exists
                
foreach($_SESSION['keywords'] as &$okey)
                {
                        if (isset(
$_SESSION['latestkeys']))
                        foreach(
$_SESSION['latestkeys'] as  $lk)
                        {
                                if (
$lk[0] == $okey[0])
                                {
                                        
$okey[1] = $okey[1]+5;     //BOOST
                                
}
                        }
                }
        }

        
$browser $_SERVER['HTTP_USER_AGENT'];
        if (
stripos($browser"Firefox") !== false)   //only Firefox and MSIE handled
        
{
                
$browsermessage1 "sorry Firefox user but this feature works only under Microsoft Internet Explorer Browser <br>";
                
$browsermessage2 "right click on the above link and bookmark it. <br><br>";
        }
        else
        {
                
$browsermessage1 "";
                
$browsermessage2 "";
        }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
        <head>
                <title>AHNAR Bookmark</title>
            <link rel="stylesheet" href="ahnarstyle.css">

        <?php
          
echo "<script language=\"JavaScript1.2\">\r\n";
          echo 
"    var bookmarkurl=\"$url\"\r\n";
          echo 
"    var bookmarktitle=\"$title\"\r\n";
          echo 
"    function addbookmark()\r\n";
          echo 
"    {\r\n";
          echo 
"        if (document.all) { window.external.AddFavorite(bookmarkurl, bookmarktitle)\r\n window.close()\r\n }";
          echo 
"    }\r\n";
          echo 
"</script>";
        
?>

        </head>

        <body class="ahnarbody" onload="addbookmark()">

                <h1 class="ahnarlarge">AHNAR Bookmark&nbsp;&nbsp;&nbsp;&nbsp;
                <span class="ahnarmedium">[<a href="javascript:close()">Close</a>]</span>
                <hr style="color:white"></h1><br>
                <?php   echo $browsermessage1;
                        echo 
"Bookmark URL: <a href='$url'>$url</a> <br>";
                        echo 
$browsermessage2;
                
?>
                Select the right bookmark location...<br><br>
                Bookmarked pages indicate that they are of mayor importance<br>
                The resulting bookmark does not use AHNAR as a gateway but is the direct URL to the site<br>


        </body>
</html>