Index: stattraq/wp-stattraq/reporter/options.php
===================================================================
--- stattraq/wp-stattraq/reporter/options.php	(revision 603)
+++ stattraq/wp-stattraq/reporter/options.php	(working copy)
@@ -1,5 +1,10 @@
 <?php
-require_once('../wp-admin/auth.php');
+if(file_exists('../wp-admin/auth.php')) {
+    require_once('../wp-admin/auth.php');
+} else {
+    require_once(ABSPATH . '/wp-admin/admin-functions.php');
+    auth_redirect();
+}
 
 function getPageContent(){
 global $wpdb, $tablestattraq, $table_stattraq_options, $options;
Index: stattraq/wp-stattraq/reporter/summary.php
===================================================================
--- stattraq/wp-stattraq/reporter/summary.php	(revision 603)
+++ stattraq/wp-stattraq/reporter/summary.php	(working copy)
@@ -325,7 +325,7 @@
 	<?php echo  PrintTimestamp();?>
 </div>
 </div>
-<?
+<?php
 	}
 	
 	function getPageTitle(){return 'Summary';}
Index: stattraq/wp-stattraq/reporter/referrer.php
===================================================================
--- stattraq/wp-stattraq/reporter/referrer.php	(revision 603)
+++ stattraq/wp-stattraq/reporter/referrer.php	(working copy)
@@ -1,4 +1,4 @@
-<?
+<?php
 
 $showReferrerType = getVar("showReferrerType",0);
 
Index: stattraq/wp-stattraq/reporter/query_strings.php
===================================================================
--- stattraq/wp-stattraq/reporter/query_strings.php	(revision 603)
+++ stattraq/wp-stattraq/reporter/query_strings.php	(working copy)
@@ -1,4 +1,4 @@
-<?
+<?php
 function getPageTitle()
 {
 	return "Search Terms";
Index: stattraq/wp-stattraq/reporter/chart_maker.php
===================================================================
--- stattraq/wp-stattraq/reporter/chart_maker.php	(revision 603)
+++ stattraq/wp-stattraq/reporter/chart_maker.php	(working copy)
@@ -1,10 +1,25 @@
 <?php
+require_once('../../wp-config.php');
 require_once('../utils.php');
-require_once('../../wp-config.php');
 $options = loadOptions();
 $chart = getVar("chart","hit_counter");
 $limitPage = getVar("limitPage",0); // the page number for the SQL query limit
 $limitNumber = getVar("limitNumber", 30); // the number of results to be returned in the query
+
+$time_frame = getVar('time_frame', 8);
+$year = getVar("year", date("Y"));
+$month = getVar("month", date("m"));
+$day = getVar("day", date("d"));
+$hour = getVar("hour", date("H"));
+$minute = getVar("minute", date("i"));
+$date_format = getVar("date_format","%Y-%m-%d %H:i");
+$startDate = getVar("startDate", date("Ymd000000"));
+$endDate = getVar("endDate", date("Ymd235959"));
+$imageWidth = getVar("width",600);
+$imageHeight = getVar("height",270);
+$betweenClause = "";
+$orderBy = getVar("orderBy", "dd DESC");
+
 $views = array("hit_counter", "ip_address", "page_views", "query_strings", "referrer", "session", "sessions", "summary", "user_agent", "user_counter");
 if(in_array($chart, $views))
 {
@@ -31,20 +46,6 @@
 //chart=hit_counter
 // time_frame=$time_frame&year=$year&month=$month&day=$day&date_format=$date_format&startDate=$startDate&endDate=$endDate&width=600&height=270
 
-$time_frame = getVar('time_frame', 8);
-$year = getVar("year", date("Y"));
-$month = getVar("month", date("m"));
-$day = getVar("day", date("d"));
-$hour = getVar("hour", date("H"));
-$minute = getVar("minute", date("i"));
-$date_format = getVar("date_format","%Y-%m-%d %H:i");
-$startDate = getVar("startDate", date("Ymd000000"));
-$endDate = getVar("endDate", date("Ymd235959"));
-$imageWidth = getVar("width",600);
-$imageHeight = getVar("height",270);
-$betweenClause = "";
-$orderBy = getVar("orderBy", "dd DESC");
-
 if($time_frame != 4)
 {
 	$betweenClause = " WHERE access_time BETWEEN '$startDate' AND '$endDate'";
@@ -144,8 +145,9 @@
 	}
 
 	
-	
-   Imagestring($image, 2, 2, $imageHeight-14, "$totalHits hits from $startDate - $endDate", $text);
+   $sd =  date( get_settings('date_format') . ' ' . get_settings('time_format'),mktime( substr($startDate,8,2), substr($startDate,10,2), substr($startDate,12,2), substr($startDate,4,2), substr($startDate,6,2), substr($startDate,0,4))); 
+   $ed =  date( get_settings('date_format') . ' ' . get_settings('time_format'),mktime( substr($endDate,8,2), substr($endDate,10,2), substr($endDate,12,2), substr($endDate,4,2), substr($endDate,6,2), substr($endDate,0,4))); 
+   Imagestring($image, 2, 2, $imageHeight-14, "$totalHits hits from " . $sd . " to " . $ed , $text);
 
    // Print out the header to tell the browser which file format we're sending in.
    if ($outputFormat == "png")
Index: stattraq/wp-stattraq/reporter/hit_counter.php
===================================================================
--- stattraq/wp-stattraq/reporter/hit_counter.php	(revision 603)
+++ stattraq/wp-stattraq/reporter/hit_counter.php	(working copy)
@@ -1,4 +1,4 @@
-<?
+<?php
 function getPageTitle()
 {
 	return "Hit Counter";
@@ -108,7 +108,7 @@
 echo "<tbody>\n";
 $i = 1;
 foreach ($rows as $key => $row) {
-$str = $row[2];
+$str = $row->dd;
     $year = $row->year;
 	 $month = $row->month;
 	 $day = $row->day;
Index: stattraq/wp-stattraq/access_detail.php
===================================================================
--- stattraq/wp-stattraq/access_detail.php	(revision 603)
+++ stattraq/wp-stattraq/access_detail.php	(working copy)
@@ -1,6 +1,16 @@
 <?php
-require_once('../wp-admin/auth.php');
-require_once("utils.php");
+require_once('../wp-config.php');
+require_once('utils.php');
+$options = loadOptions();
+if($options['disable_login'] == false)
+{
+    if(file_exists('../wp-admin/auth.php')) {
+        require_once('../wp-admin/auth.php');
+    } else {
+        require_once(ABSPATH . '/wp-admin/admin-functions.php');
+        auth_redirect();
+    }
+}
 $line_id = getVar("line_id", null);
 $access_time = date("Y-m-d H:i:s");
 $ip_address = "0.0.0.0";
@@ -26,20 +36,20 @@
 	<legend>Access Detail</legend>
 <dl>
 	<dt><strong>Access Time: </strong></dt>
-		<dd><?=$row->access_time;?></dd>
+		<dd><?php echo $row->access_time;?></dd>
 	<dt><strong>IP Address: </strong></dt>
-		<dd><?=$row->ip_address;?></>
-		<a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?=$row->ip_address?>" target="_blank">whois</a></dd>
+		<dd><?php echo $row->ip_address;?></>
+		<a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php echo $row->ip_address?>" target="_blank">whois</a></dd>
 	<dt><strong>URL: </strong></dt>
-		<dd><?=$row->url;?></dd>
+		<dd><?php echo $row->url;?></dd>
 	<dt><strong>Article ID: </strong></dt>
-		<dd><?=$row->article_id;?></dd>
+		<dd><?php echo $row->article_id;?></dd>
 	<dt><strong>User Agent: </strong></dt>
-		<dd><?=$row->user_agent;?></dd>
+		<dd><?php echo $row->user_agent;?></dd>
 	<dt><strong>Browser: </strong></dt> 
-		<dd><?=$row->browser;?></dd>
+		<dd><?php echo $row->browser;?></dd>
 	<dt><strong>Referrer: </strong></dt>
-		<dd><?=$row->referrer;?></dd>
+		<dd><?php echo $row->referrer;?></dd>
 </dl>
 	<a href="javascript:window.close();">Close</a>
 </fieldset>
Index: stattraq/wp-stattraq/index.php
===================================================================
--- stattraq/wp-stattraq/index.php	(revision 603)
+++ stattraq/wp-stattraq/index.php	(working copy)
@@ -3,11 +3,15 @@
 timer_start();
 require_once('utils.php');
 $options = loadOptions();
-if($options['options_defaults_disable_login'] != false)
+if($options['disable_login'] == false)
 {
-	require_once('../wp-admin/auth.php');
+    if(file_exists('../wp-admin/auth.php')) {
+    	require_once('../wp-admin/auth.php');
+    } else {
+        require_once(ABSPATH . '/wp-admin/admin-functions.php');
+        auth_redirect();
+    }
 }
-
 $year = (int)getVar('year',date("Y"));
 $month = (int)getVar('month',date("m"));
 $day = (int)getVar('day',date("d"));
Index: stattraq/wp-content/plugins/stattraq.php
===================================================================
--- stattraq/wp-content/plugins/stattraq.php	(revision 603)
+++ stattraq/wp-content/plugins/stattraq.php	(working copy)
@@ -17,32 +17,45 @@
 $tablestattraq = $table_prefix . 'stattraq';
 $table_stattraq_options = $table_prefix . 'stattraq_options';
 function stat_traq_event($passed_param){
-global $doing_rss, $p, $tablestattraq, $wpdb, $browser_type;
-$wpdb->hide_errors();
-$s_id = session_id();
-// need to get the real article_id or type of server request (RSS, RDF, ATOM, Ping, etc)
-if(!isset($article_id)){
-if (($p != '')){
-	$p = intval($p);
-	$article_id = $p;
-}else if(isset($doing_rss) && $doing_rss == 1){
-	$article_id = "Feed";
-}else{
-	$article_id = 0; // default/mixed page - not just for one article
-}
-}
-if(!isset($s_id)){$s_id = session_id();}
+    global $wp_query, $doing_rss, $p, $tablestattraq, $wpdb, $browser_type,$posts;
 
-$ipAddress = statTraqGetIPAddress();
-$urlRequested = $_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) ? "?".$_SERVER['QUERY_STRING'] : '' );
-$browser = statTraqGetBrowser();
-$referrer = (isset($_SERVER['HTTP_REFERER']) ? "'" . $_SERVER['HTTP_REFERER'] . "'" :"NULL");
-$userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "NULL");
-$search_phrase = statTraqGetSearchPhrase($referrer);
-if (!strstr($_SERVER['PHP_SELF'], 'wp-admin') && !strstr($_SERVER['PHP_SELF'], 'wp-stattraq'))
-	$wpdb->query("INSERT INTO $tablestattraq (session_id, access_time, ip_address, url, article_id, referrer, user_agent, browser, user_agent_type, search_phrase) values ('".$s_id."', NOW(), '$ipAddress','$urlRequested', '$article_id', $referrer,'$userAgent','$browser', $browser_type, " . ($search_phrase==null?"NULL" : "'$search_phrase'") . ")");
-$wpdb->show_errors();
-return $passed_param;
+    $wpdb->hide_errors();
+    $s_id = session_id();
+    // need to get the real article_id or type of server request (RSS, RDF, ATOM, Ping, etc)
+    if(!isset($article_id)) {
+        if (($p != '')){
+        	$p = intval($p);
+        	$article_id = $p;
+        } else if(isset($doing_rss) && $doing_rss == 1) {
+        	$article_id = "Feed";
+/*        } elseif (isset($wp_query) == true) {
+                $article_id = $wp_query->get_queried_object_id();
+        } else {
+*/
+        } elseif (isset($wp_query) == true) {
+            if($wp_query->is_page == true || $wp_query->is_single == true )
+                $article_id = $wp_query->get_queried_object_id();
+            else
+                $article_id = 0;
+        } else {
+        	$article_id = 0; // default/mixed page - not just for one article
+        }
+    }
+    if(!isset($s_id)){
+        $s_id = session_id();
+    }
+    
+    $ipAddress = statTraqGetIPAddress();
+    $urlRequested = $_SERVER['PHP_SELF'] . (isset($_SERVER['QUERY_STRING']) ? "?".$_SERVER['QUERY_STRING'] : '' );
+    $browser = statTraqGetBrowser();
+    $referrer = (isset($_SERVER['HTTP_REFERER']) ? "'" . $_SERVER['HTTP_REFERER'] . "'" :"NULL");
+    $userAgent = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "NULL");
+    $search_phrase = statTraqGetSearchPhrase($referrer);
+    if (!strstr($urlRequested, 'wp-admin') && !strstr($urlRequested, 'wp-stattraq') && !strstr($urlRequested, 'favicon.ico')) {
+      $wpdb->query("INSERT INTO $tablestattraq (session_id, access_time, ip_address, url, article_id, referrer, user_agent, browser, user_agent_type, search_phrase) values ('".$s_id."', NOW(), '$ipAddress','$urlRequested', '$article_id', $referrer,'$userAgent','$browser', $browser_type, " . ($search_phrase==null?"NULL" : "'$search_phrase'") . ")");
+    }
+    $wpdb->show_errors();
+    return $passed_param;
 }
 
 function statTraqGetBrowser()
@@ -349,4 +362,4 @@
 }
 // add the call to the API request
 add_action('shutdown', 'stat_traq_event');
-?>
\ No newline at end of file
+?>
