Exemple #1
0
function get_td($_cols, $_result, $_this_col, $_truncate, $_name_lookup = null, $_link = true)
{
    $config =& SlimStatConfig::get_instance();
    $value = $_result[$_this_col];
    if ($_link) {
        if (is_array($_name_lookup) && isset($_name_lookup[$value])) {
            $display_value = $_name_lookup[$value];
        } elseif (is_array($_name_lookup) && isset($_name_lookup[strtolower($value)])) {
            $display_value = $_name_lookup[strtolower($value)];
        } elseif (is_string($_name_lookup)) {
            $display_value = eval(str_replace("VALUE", $value, $_name_lookup));
        } else {
            $display_value = $value;
        }
        $filters_copy = $GLOBALS["filters"];
        foreach ($_cols as $col) {
            unset($filters_copy["filter_" . $col]);
            $filters_copy["filter_" . $col] = urlencode($_result[$col]);
        }
        $str = "<a href=\"?";
        $str .= SlimStat::implode_assoc("=", "&amp;", $filters_copy);
        if (strlen($display_value) > $_truncate) {
            $str .= "\" title=\"" . htmlentities($display_value);
        }
        $str .= "\">";
        $str .= utf8_encode(SlimStat::truncate($display_value, $_truncate));
        $str .= "</a>";
    } else {
        $str = SlimStat::truncate($value, $_truncate);
    }
    return $str;
}
Exemple #2
0
 function to_user_time($_server_dt)
 {
     $config =& SlimStatConfig::get_instance();
     return $_server_dt + $config->dt_offset_secs;
 }
Exemple #3
0
function unique_table($_cols, $_truncate, $_where_clause = "", $_filters = array())
{
    $config =& SlimStatConfig::get_instance();
    $thead = array("first" => array(isset($config->i18n->fields[$_cols["display"]]) ? $config->i18n->fields[$_cols["display"]] : $_cols["display"]), "last" => array("&nbsp", $config->i18n->hits, $config->i18n->since));
    $tbody = array();
    $results = SlimStat::get_unique_data($_cols, $_where_clause, $_cols["display"], $_filters);
    foreach ($results as $result) {
        $display_value = $result[$_cols["display"]];
        if (isset($config->i18n->name_lookups[$_cols["display"]])) {
            if (is_array($config->i18n->name_lookups[$_cols["display"]]) && isset($config->i18n->name_lookups[$_cols["display"]][$display_value])) {
                $display_value = $config->i18n->name_lookups[$_cols["display"]][$display_value];
            } elseif (is_string($config->i18n->name_lookups[$_cols["display"]])) {
                $display_value = eval(str_replace("VALUE", $display_value, $config->i18n->name_lookups[$_cols["display"]]));
            }
        }
        $row = array("first" => array(), "last" => array());
        $str = "<a href=\"?filter_" . $_cols["display"] . "=" . urlencode($result[$_cols["display"]]);
        $str .= "\" title=\"" . $config->i18n->link_title("details_filtered", "FIELD", strtolower($config->i18n->fields[$_cols["display"]])) . "\">";
        $str .= SlimStat::truncate($display_value, $_truncate - (int) (SlimStat::strlen($config->i18n->hits) + SlimStat::strlen($config->i18n->since))) . "</a>";
        $row["first"][] = $str;
        $str = "<a href=\"" . $result[$_cols["href"]] . "\" class=\"external\" rel=\"nofollow\"";
        $str .= " title=\"" . $config->i18n->link_title("external", "FIELD", strtolower($config->i18n->fields[$_cols["href"]])) . "\">";
        $str .= "<img src=\"external.gif\" width=\"9\" height=\"9\" alt=\"\" /></a>";
        $row["last"][] = $str;
        /*$str = "<a href=\"".$result[$_cols["href"]]."\" class=\"external\" rel=\"nofollow\"";
        		$str .= " title=\"".$config->i18n->fields[ $_cols["title"] ].": ".htmlentities( $result[$_cols["title"]] )."\">";
        		$str .= SlimStat::truncate( $display_value, $config->truncate - 6 )."</a>";
        		$row["first"][] = $str;*/
        $row["last"][] = $result["hits"];
        $row["last"][] = $config->i18n->time_label($result["mindt"], time());
        $tbody[] = $row;
    }
    return SlimStat::render_table($thead, $tbody);
}
Exemple #4
0
function show_paths()
{
    $config =& SlimStatConfig::get_instance();
    // get max visit
    $query = "SELECT MAX(`visit`) FROM `" . SlimStat::my_esc($config->database) . "`.`" . SlimStat::my_esc($config->stats) . "`";
    if ($result = mysql_query($query)) {
        list($max_visit) = mysql_fetch_row($result);
    }
    $str = "";
    // get requests
    $query = "SELECT * FROM `" . SlimStat::my_esc($config->database) . "`.`" . SlimStat::my_esc($config->stats) . "` WHERE ";
    if (!$config->show_crawlers) {
        $query .= "`browser` != '" . SlimStat::my_esc($config->i18n->crawler) . "' AND ";
    }
    $query .= "`visit` >= " . ($max_visit - $config->rows);
    $query .= " ORDER BY `visit` DESC, `dt`";
    if ($result = mysql_query($query)) {
        $prev_visit = 0;
        $visits = array();
        $visit = array();
        $pages = array();
        while ($assoc = mysql_fetch_assoc($result)) {
            if ($assoc["visit"] != $prev_visit && !empty($visit)) {
                $visits[] = $visit;
                $visit = array();
            }
            $visit[] = $assoc;
            $prev_visit = $assoc['visit'];
        }
        if (!empty($visit)) {
            $visits[] = $visit;
        }
        $str .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
        $str .= "<tr><th>" . $config->i18n->fields["remote_ip"] . "</th>";
        $str .= "<th>" . $config->i18n->when . "</th>";
        $str .= "<th>" . $config->i18n->fields["browser"] . "</th>";
        $str .= "<th>" . $config->i18n->fields["platform"] . "</th>";
        $str .= "<th>" . $config->i18n->fields["country"] . "</th></tr>\n";
        $usr_today = SlimStat::to_user_time(time());
        $svr_today = SlimStat::to_server_time(mktime(0, 0, 0, date("n", $usr_today), date("d", $usr_today), date("Y", $usr_today)));
        foreach ($visits as $visit) {
            $is_today = $visit[0]["dt"] >= $svr_today;
            $mindt = SlimStat::time_label($visit[0]["dt"]);
            $maxdt = SlimStat::time_label($visit[sizeof($visit) - 1]["dt"]);
            $str .= "<tr><td class=\"accent\">" . htmlentities(SlimStat::get_domain($visit[0]["remote_ip"])) . "</td>";
            $str .= "<td class=\"accent\">";
            if ($is_today) {
                $str .= $mindt == $maxdt ? $mindt : $mindt . "-" . $maxdt;
            } else {
                $str .= SlimStat::time_label($visit[0]["dt"], time());
            }
            $str .= "</td>";
            $str .= "<td class=\"accent\">" . htmlentities($visit[0]["browser"]);
            if ($visit[0]["version"] != $config->i18n->indeterminable) {
                $str .= " " . htmlentities($visit[0]["version"]);
            }
            $str .= "</td><td class=\"accent\">" . htmlentities($visit[0]["platform"]) . "</td>";
            $str .= "<td class=\"accent\">" . htmlentities($visit[0]["country"]) . "</td></tr>\n";
            $prev_dt = "";
            foreach ($visit as $hit) {
                $str .= "<tr><td>";
                $str .= "<a href=\"" . $hit["resource"] . "\" class=\"external\"";
                $str .= "\" title=\"" . $config->i18n->link_title("external", "FIELD", strtolower($config->i18n->fields["resource"])) . "\">";
                $str .= "<img src=\"external.gif\" width=\"9\" height=\"9\" alt=\"\" /></a>&nbsp;&nbsp;";
                $str .= "<a href=\"?filter_resource=" . urlencode($hit["resource"]);
                $str .= "\" title=\"" . $config->i18n->link_title("details_filtered", "FIELD", strtolower($config->i18n->fields["resource"])) . "\">";
                if (isset($config->i18n->name_lookups["resource"][$hit["resource"]])) {
                    $str .= SlimStat::truncate($config->i18n->name_lookups["resource"][$hit["resource"]], 53);
                } else {
                    $str .= SlimStat::truncate($hit["resource"], 53);
                }
                $str .= "</a></td>";
                $dt_label = SlimStat::time_label($hit["dt"]);
                if (!$is_today && $prev_dt == "" || $mindt != $maxdt && $dt_label != $prev_dt) {
                    $str .= "<td>" . $dt_label . "</td>";
                } else {
                    $str .= "<td>&nbsp;</td>";
                }
                $prev_dt = $dt_label;
                if ($hit["referer"] != "" && $hit["domain"] != SlimStat::trim_referer($_SERVER["SERVER_NAME"])) {
                    $str .= "<td colspan=\"3\" class=\"last\">";
                    $str .= "<a href=\"?filter_domain=" . urlencode($hit["domain"]);
                    $str .= "\" title=\"" . $config->i18n->link_title("details_filtered", "FIELD", strtolower($config->i18n->fields["domain"])) . "\"";
                    $str .= ">" . htmlentities(SlimStat::truncate($hit["domain"], 30)) . "</a>&nbsp;&nbsp;";
                    $str .= "<a href=\"" . $hit["referer"] . "\" class=\"external\" rel=\"nofollow\"";
                    $str .= "\" title=\"" . $config->i18n->link_title("external", "FIELD", strtolower($config->i18n->fields["referer"])) . "\">";
                    $str .= "<img src=\"external.gif\" width=\"9\" height=\"9\" alt=\"\" /></a>";
                } else {
                    $str .= "<td colspan=\"3\">&nbsp;</td>";
                }
                $str .= "</tr>\n";
            }
        }
        $str .= "</table>\n";
        return $str;
    }
}
Exemple #5
0
 * of the License, or (at your option) any later version.
 * 
 * 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"];
?>