Esempio n. 1
0
function date_table($_dt, $_title, $_n_loops, $_end_increment, $_dt_decrement, $_filters)
{
    $config =& SlimStatConfig::get_instance();
    $thead = array("first" => array(isset($config->i18n->fields[$_title]) ? $config->i18n->fields[$_title] : $_title), "last" => array($config->i18n->hits));
    $tbody = array();
    if ($config->show_visits && !isset($_filters["filter_visit"])) {
        $thead["last"][] = $config->i18n->visits;
    }
    if ($config->show_uniques) {
        $thead["last"][] = $config->i18n->uniques;
    }
    for ($i = 0; $i < $_n_loops; $i++) {
        $dt_start = SlimStat::to_server_time(strtotime(date("Y-m-d 00:00:00", $_dt)));
        $dt_end = SlimStat::to_server_time(strtotime(date("Y-m-d 23:59:59", $_dt + eval("return (" . $_end_increment . ");"))));
        $assoc = SlimStat::get_hits_visits_uniques($dt_start, $dt_end, $_filters);
        if ($assoc["hits"] > 0) {
            $row = array("first" => array(), "last" => array());
            if (isset($_filters["filter_dt_start"]) && isset($_filters["filter_dt_end"]) && $dt_start == $_filters["filter_dt_start"] && $dt_end == $_filters["filter_dt_end"]) {
                $row["first"][] = "<em>" . SlimStat::date_period_label($dt_start, $dt_end) . "</em>";
            } else {
                $str = "<a href=\"?";
                $filters_copy = $_filters;
                $printed_show = false;
                if (sizeof($filters_copy) == 0 || sizeof($filters_copy) == 2 && isset($filters_copy["filter_dt_start"]) && isset($filters_copy["filter_dt_end"])) {
                    if ($dt_start == $GLOBALS["today_dt_start"] && $dt_end == $GLOBALS["today_dt_end"]) {
                        $str .= "show=today";
                        $printed_show = true;
                    } elseif ($dt_start == $GLOBALS["thisweek_dt_start"] && $dt_end == $GLOBALS["thisweek_dt_end"]) {
                        $str .= "show=thisweek";
                        $printed_show = true;
                    } elseif ($dt_start == $GLOBALS["thismonth_dt_start"] && $dt_end == $GLOBALS["thismonth_dt_end"]) {
                        $str .= "show=thismonth";
                        $printed_show = true;
                    }
                }
                unset($filters_copy["filter_dt_start"]);
                unset($filters_copy["filter_dt_end"]);
                $str .= SlimStat::implode_assoc("=", "&amp;", $filters_copy);
                if (!$printed_show) {
                    $str .= (empty($filters_copy) ? "" : "&amp;") . "filter_dt_start=" . $dt_start . "&amp;filter_dt_end=" . $dt_end;
                }
                $str .= "\">" . SlimStat::date_period_label($dt_start, $dt_end) . "</a>";
                $row["first"][] = $str;
            }
            $row["last"][] = $assoc["hits"];
            if ($config->show_visits && !isset($_filters["filter_visit"])) {
                $row["last"][] = $assoc["visits"];
            }
            if ($config->show_uniques) {
                $row["last"][] = $assoc["uniques"];
            }
            $tbody[] = $row;
        }
        $_dt -= eval("return (" . $_dt_decrement . ");");
    }
    return SlimStat::render_table($thead, $tbody, true);
}
Esempio n. 2
0
 function get_total_hits_visits_uniques()
 {
     return SlimStat::get_hits_visits_uniques(SlimStat::get_first_hit());
 }
Esempio n. 3
0
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
ob_start("ob_gzhandler");
// Load the SlimStat files
include_once realpath(dirname(__FILE__)) . "/_config.php";
include_once realpath(dirname(__FILE__)) . "/_functions.php";
$config =& SlimStatConfig::get_instance();
SlimStat::connect();
$hvu = SlimStat::get_hits_visits_uniques(mktime(0, 0, 0) - $config->dt_offset_secs, mktime(23, 59, 59) - $config->dt_offset_secs);
// Make sure the browser knows that this is an xml file
header("Content-Type: application/xhtml+xml; charset=UTF-8");
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
?>
<shortstat>
	<websiteinfo>
		<name><?php 
print $config->sitename;
?>
</name>
		<url>http://<?php 
print $_SERVER["HTTP_HOST"];
?>
</url>
	</websiteinfo>
Esempio n. 4
0
        }
        ?>
					<?php 
        if ($config->show_uniques) {
            ?>
<td class="last"><?php 
            print $hvu["uniques"];
            ?>
</td><?php 
        }
        ?>
				</tr>
				<?php 
        // last month
        $svr_dt_start = SlimStat::to_server_time(mktime(0, 0, 0, date("n", $usr_dt) - 1, 1, date("Y", $usr_dt)));
        $hvu = SlimStat::get_hits_visits_uniques($svr_dt_start, $svr_dt - 1);
        ?>
				<tr>
					<td><a href="?filter_dt_start=<?php 
        print $dt_start;
        ?>
&amp;filter_dt_end=<?php 
        print $dt - 1;
        ?>
" title="<?php 
        print $config->i18n->link_title('details_dt', 'DT', $config->i18n->date_periods['last_month']);
        ?>
"><?php 
        print ucfirst($config->i18n->date_periods["last_month"]);
        ?>
</a></td>
Esempio n. 5
0
     print "</channel>\n";
 } elseif ($_SERVER["QUERY_STRING"] == "daily") {
     print "<channel>\n";
     print "<title>SlimStat: Daily feed for " . $config->sitename . "</title>\n";
     print "<link>http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["PHP_SELF"]) . "/</link>\n";
     print "<description>SlimStat: " . $config->sitename . ": " . $config->i18n->module_titles["daily"] . "</description>\n";
     print "<pubDate>" . date("r") . "</pubDate>\n";
     print "<lastBuildDate>" . date("r", strtotime(date("Y-m-d 00:00:00"))) . "</lastBuildDate>\n";
     print "<docs>http://blogs.law.harvard.edu/tech/rss</docs>\n";
     print "<ttl>60</ttl>\n\n";
     $dt = time() - 60 * 60 * 24;
     for ($i = 0; $i < 7; $i++) {
         $dt_start = strtotime(date("Y-m-d 00:00:00", $dt)) - $config->dt_offset_secs;
         $dt_end = strtotime(date("Y-m-d 23:59:59", $dt)) - $config->dt_offset_secs;
         $filters = array("filter_dt_start" => $dt_start, "filter_dt_end" => $dt_end);
         $hvu = SlimStat::get_hits_visits_uniques($dt_start, $dt_end);
         print "<item>\n";
         print "<title>" . SlimStat::date_period_label($dt_start + $config->dt_offset_secs, $dt_end + $config->dt_offset_secs) . "</title>\n";
         print "<link>http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["PHP_SELF"]) . "/?filter_dt_start=" . $dt_start . "&amp;filter_dt_end=" . $dt_end . "</link>\n";
         print "<description>";
         if (isset($hvu["hits"])) {
             print $config->i18n->hits . ": " . $hvu["hits"] . "&lt;br /&gt;";
         }
         if (isset($hvu["visits"])) {
             print $config->i18n->visits . ": " . $hvu["visits"] . "&lt;br /&gt;";
         }
         if (isset($hvu["uniques"])) {
             print $config->i18n->uniques . ": " . $hvu["uniques"] . "&lt;br /&gt;";
         }
         print "</description>\n";
         print "<guid isPermaLink=\"true\">http://" . $_SERVER["SERVER_NAME"] . dirname($_SERVER["PHP_SELF"]) . "/?filter_dt_start=" . $dt_start . "&amp;filter_dt_end=" . $dt_end . "</guid>\n";