replacing the cli cmds with variables and configuration in config.php
[gwvp-mini.git] / gwvpmini / gwvpmini_activity.php
index 107cb48..3e3cf2e 100644 (file)
@@ -71,7 +71,8 @@ function gwvpmini_HomePageActivityLog()
 {
        global $BASE_URL;
        
-       $id = $_SESSION["id"];
+       $id = -1;
+       if(isset($_SESSION["id"])) $id = $_SESSION["id"];
        
        if($id < 0) {
                $ents = gwvpmini_GetActivityLog();
@@ -81,7 +82,7 @@ function gwvpmini_HomePageActivityLog()
        
        echo "<h2>News</h2>";
        echo "<table border=\"1\">";
-       foreach($ents as $vals) {
+       if($ents != null) foreach($ents as $vals) {
                /*
                 *              $ret[$nent]["type"] = $vals["activity_type"];
                $ret[$nent]["date"] = $vals["activity_date"];
@@ -141,7 +142,29 @@ function gwvpmini_TimeDiffText($time)
        if($tdiff < 60) return "$tdiff Seconds Ago";
        if($tdiff < 3600) return "".(int)($tdiff/60)." Minutes Ago";
        if($tdiff < 86400) return "".(int)($tdiff/3600)." Hours Ago";
-       return "".(int)($tdiff/86400)." Days Ago";
+       if($tdiff < 2592000) {
+               return "".(int)($tdiff/86400)." Days Ago";
+       }
+       if($tdiff < 31536000) {
+               $months = (int)($tdiff/2592000);
+               $days = (int)(($tdiff%2592000)/86400);
+               
+               $txt = "$months Month";
+               if($months > 1) $txt .= "s";
+               if($days > 0) $txt .= " and $days Day";
+               if($days > 1) $txt .= "s";
+               return $txt." ago";
+       }
+       
+       $years = (int)($tdiff/31536000);
+       $months = (int)(($tdiff%31536000)/2592000);
+       $txt = "$years Year";
+       if($years > 1) $txt .= "s";
+       if($months > 0) $txt .= " and $months Month";
+       if($months > 1) $txt .= "s";
+       
+       return $txt." ago";\r
+       
 }
 
 ?>
\ No newline at end of file