"); ?> (Or use MTCommentDate if you're doing this within MTComments tags.) See http://www.gyford.com/phil/writing/2003/03/18/new_markers_in_m.php for further help. */ ///////////////////////////////// // EDIT THESE VARIABLES. // Your site's domain name. $domain = "www.yourdomain.com"; // The path to your weblog. // You can leave this if there will only be one weblog at this domain. $weblogpath = "/"; // The HTML you want displayed for new or old items. $newtext = "NEW"; $oldtext = "old"; // The time a user's session will last in seconds. 5400 = 90 minutes. $sessiontime = 5400; // How long until cookies expire in seconds. 2592000 = 30 days. $cookieexpire = 2592000; // ///////////////////////////////// // GET THE USER'S COOKIES. // The last time the user viewed a page on the site. $lastview = isset($HTTP_COOKIE_VARS["lastview"]) ? $HTTP_COOKIE_VARS["lastview"] : ""; // The time the user's current session started. $sessionstart = isset($HTTP_COOKIE_VARS["sessionstart"]) ? $HTTP_COOKIE_VARS["sessionstart"] : ""; // The time of the user's last page view in the previous session. $prevsession = isset($HTTP_COOKIE_VARS["prevsession"]) ? $HTTP_COOKIE_VARS["prevsession"] : ""; // SET COOKIES. $timenow = time(); if ($lastview == "" || $sessionstart == "") { // The user has NOT been to the site before... $sessionstart = $timenow; setcookie("sessionstart", $sessionstart, time()+$cookieexpire, $weblogpath, $domain); } elseif (($timenow - $sessionstart) > $sessiontime) { // This is a new session for the user... $prevsession = $lastview; setcookie("prevsession", $prevsession, time()+$cookieexpire, $weblogpath, $domain); $sessionstart = $timenow; setcookie("sessionstart", $sessionstart, time()+$cookieexpire, $weblogpath, $domain); } $lastview = $timenow; setcookie("lastview", $lastview, time()+$cookieexpire, $weblogpath, $domain); // Call this function to output either an old or new marker. // $itemtime is of the form "YYYY-MM-DD hh:mm:ss". // We could just pass it unixtime but we can't generate time in // this format from the Movable Type templates. function newItemMarker ($itemtime) { global $prevsession, $newtext, $oldtext; // Translate $itemtime into unixtime format. $itemtime = strtotime($itemtime); if ($prevsession == "") { // The user's first time here. $new = true; } elseif ($itemtime > $prevsession) { // This item appeared since the user's previous session. $new = true; } else { // It's old. $new = false; } if ($new) { print $newtext; } else { print $oldtext; } } ?>