Example #1
0
function iriValueTable($fld, $fldtitle, $limit = 0, $param = "", $queryfld = "", $exclude = "")
{
    /* Maddler 04112007: param addedd */
    global $wpdb;
    $table_name = $wpdb->prefix . "statpress";
    if ($queryfld == '') {
        $queryfld = $fld;
    }
    print "<div class='wrap'><h2>{$fldtitle}</h2><table style='width:100%;padding:0px;margin:0px;' cellpadding=0 cellspacing=0><thead><tr><th style='width:400px;background-color:white;'></th><th style='width:150px;background-color:white;'><u>" . __('Visits', 'statpress') . "</u></th><th style='background-color:white;'></th></tr></thead>";
    print "<tbody id='the-list'>";
    $rks = $wpdb->get_var("SELECT count({$param} {$queryfld}) as rks FROM {$table_name} WHERE 1=1 {$exclude};");
    if ($rks > 0) {
        $sql = "SELECT count({$param} {$queryfld}) as pageview, {$fld} FROM {$table_name} WHERE 1=1 {$exclude}  GROUP BY {$fld} ORDER BY pageview DESC";
        if ($limit > 0) {
            $sql = $sql . " LIMIT {$limit}";
        }
        $qry = $wpdb->get_results($sql);
        $tdwidth = 450;
        $red = 131;
        $green = 180;
        $blue = 216;
        $deltacolor = round(250 / count($qry), 0);
        //      $chl="";
        //      $chd="t:";
        foreach ($qry as $rk) {
            $pc = round($rk->pageview * 100 / $rks, 1);
            if ($fld == 'date') {
                $rk->{$fld} = irihdate($rk->{$fld});
            }
            if ($fld == 'urlrequested') {
                $rk->{$fld} = iri_StatPress_Decode($rk->{$fld});
            }
            //      $chl.=urlencode(my_substr($rk->$fld,0,50))."|";
            //      $chd.=($tdwidth*$pc/100)."|";
            print "<tr><td style='width:400px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'>" . my_substr($rk->{$fld}, 0, 50);
            if (strlen("{$rk->fld}") >= 50) {
                print "...";
            }
            // <td style='text-align:right'>$pc%</td>";
            print "</td><td style='text-align:center;'>" . $rk->pageview . "</td>";
            print "<td><div style='text-align:right;padding:2px;font-family:helvetica;font-size:7pt;font-weight:bold;height:16px;width:" . number_format($tdwidth * $pc / 100, 1, '.', '') . "px;background:" . irirgbhex($red, $green, $blue) . ";border-top:1px solid " . irirgbhex($red + 20, $green + 20, $blue) . ";border-right:1px solid " . irirgbhex($red + 30, $green + 30, $blue) . ";border-bottom:1px solid " . irirgbhex($red - 20, $green - 20, $blue) . ";'>{$pc}%</div>";
            print "</td></tr>\n";
            $red = $red + $deltacolor;
            $blue = $blue - $deltacolor / 2;
        }
    }
    print "</table>\n";
    //  $chl=my_substr($chl,0,strlen($chl)-1);
    //  $chd=my_substr($chd,0,strlen($chd)-1);
    //  print "<img src=http://chart.apis.google.com/chart?cht=p3&chd=".($chd)."&chs=400x200&chl=".($chl)."&chco=1B75DF,92BF23>\n";
    print "</div>\n";
}
Example #2
0
function iriValueTable($fld, $fldtitle, $limit = 0, $param = "", $queryfld = "", $exclude = "")
{
    /* Maddler 04112007: 添加了参数 */
    global $wpdb;
    $table_name = $wpdb->prefix . "statpress";
    $to_time = current_time('timestamp');
    if (strlen(get_option("statpress_details_period")) > 0) {
        $period = get_option("statpress_details_period");
    } else {
        $period = "1 month";
        update_option("statpress_details_period", $period);
    }
    $from_time = strtotime('-' . $period, $to_time);
    $exclude .= " and (statuscode != '404' or statuscode is null)";
    #$fc_statpress = $wpdb->query("select * from $table_name where feed!='' and timestamp between $from_time and $to_time;");
    //$qry = $wpdb->get_results("select count(DISTINCT(IP)) as feedcounts from $table_name where feed!='' and timestamp between $from_time and $to_time;");
    if ($queryfld == '') {
        $queryfld = $fld;
    }
    print "<div class='wrap'><table align=center><tr><td align=center>";
    print "<h3>{$fldtitle}</h3>(" . __("recently", "statpresscn") . " " . $period . ")<table style='width:100%;padding:0px;margin:0px;' cellpadding=0 cellspacing=0><thead><tr><th style='width:220px;background-color:white;'></th><th style='width:60px;background-color:white;'><u>" . __('Visits', 'statpresscn') . "</u></th><th style='background-color:white;'></th></tr></thead>";
    print "<tbody id='the-list'>";
    $rks = $wpdb->get_var("SELECT count({$param} {$queryfld}) as rks FROM {$table_name} where timestamp between {$from_time} and {$to_time} {$exclude};");
    if ($rks > 0) {
        $sql = "SELECT count({$param} {$queryfld}) as pageview, {$fld} FROM {$table_name} where timestamp between {$from_time} and {$to_time} {$exclude}  GROUP BY {$fld} ORDER BY pageview DESC";
        if ($limit > 0) {
            $sql = $sql . " LIMIT {$limit}";
        }
        $qry = $wpdb->get_results($sql);
        $tdwidth = 250;
        $red = 131;
        $green = 180;
        $blue = 216;
        $deltacolor = round(250 / count($qry), 0);
        //	    $chl="";
        //	    $chd="t:";
        foreach ($qry as $rk) {
            $pc = round($rk->pageview * 100 / $rks, 1);
            if ($fld == 'date') {
                $rk->{$fld} = irihdate($rk->{$fld});
            }
            if ($fld == 'urlrequested') {
                $rk->{$fld} = iri_StatPress_Decode($rk->{$fld});
            }
            //			$chl.=urlencode(substr($rk->$fld,0,50))."|";
            //			$chd.=($tdwidth*$pc/100)."|";
            print "<tr><td style='width:250px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'>";
            if ($fld == "referrer") {
                echo "<a href='" . $rk->{$fld} . "' target='_heart5'>";
            }
            echo iri_StatPress_Abbrevia(urldecode($rk->{$fld}), 26);
            if ($fld == "referrer") {
                echo "</a>";
            }
            print "</td><td style='text-align:center;'>" . $rk->pageview . "</td>";
            // <td style='text-align:right'>$pc%</td>";
            print "<td><div style='text-align:right;padding:2px;font-family:helvetica;font-size:7pt;font-weight:bold;height:16px;width:" . $tdwidth * $pc / 100 . "px;background:" . irirgbhex($red, $green, $blue) . ";border-top:1px solid " . irirgbhex($red + 20, $green + 20, $blue) . ";border-right:1px solid " . irirgbhex($red + 30, $green + 30, $blue) . ";border-bottom:1px solid " . irirgbhex($red - 20, $green - 20, $blue) . ";'>{$pc}%</div>";
            print "</td></tr>\n";
            $red = $red + $deltacolor;
            $blue = $blue - $deltacolor / 2;
        }
    }
    print "</table>\n</td><td bgcolor=gray><font color=white>*vs*</font></td>";
    print "<td align=center><h3>{$fldtitle}</h3>(" . __("all stats days", "statpresscn") . ")<table style='width:100%;padding:0px;margin:0px;' cellpadding=0 cellspacing=0><thead><tr><th style='width:220px;background-color:white;'></th><th style='width:60px;background-color:white;'><u>" . __('Visits', 'statpresscn') . "</u></th><th style='background-color:white;'></th></tr></thead>";
    print "<tbody id='the-list'>";
    $rks = $wpdb->get_var("SELECT count({$param} {$queryfld}) as rks FROM {$table_name} WHERE 1=1 {$exclude};");
    if ($rks > 0) {
        $sql = "SELECT count({$param} {$queryfld}) as pageview, {$fld} FROM {$table_name} WHERE 1=1 {$exclude}  GROUP BY {$fld} ORDER BY pageview DESC";
        if ($limit > 0) {
            $sql = $sql . " LIMIT {$limit}";
        }
        $qry = $wpdb->get_results($sql);
        $tdwidth = 250;
        $red = 131;
        $green = 180;
        $blue = 216;
        $deltacolor = round(250 / count($qry), 0);
        //	    $chl="";
        //	    $chd="t:";
        foreach ($qry as $rk) {
            $pc = round($rk->pageview * 100 / $rks, 1);
            if ($fld == 'date') {
                $rk->{$fld} = irihdate($rk->{$fld});
            }
            if ($fld == 'urlrequested') {
                $rk->{$fld} = iri_StatPress_Decode($rk->{$fld});
            }
            print "<tr><td style='width:250px;overflow: hidden; white-space: nowrap; text-overflow: ellipsis;'>";
            if ($fld == "referrer") {
                echo "<a href='" . $rk->{$fld} . "' target='_heart5'>";
            }
            echo iri_StatPress_Abbrevia(urldecode($rk->{$fld}), 26);
            if ($fld == "referrer") {
                echo "</a>";
            }
            print "</td><td style='text-align:center;'>" . $rk->pageview . "</td>";
            // <td style='text-align:right'>$pc%</td>";
            print "<td><div style='text-align:right;padding:2px;font-family:helvetica;font-size:7pt;font-weight:bold;height:16px;width:" . $tdwidth * $pc / 100 . "px;background:" . irirgbhex($red, $green, $blue) . ";border-top:1px solid " . irirgbhex($red + 20, $green + 20, $blue) . ";border-right:1px solid " . irirgbhex($red + 30, $green + 30, $blue) . ";border-bottom:1px solid " . irirgbhex($red - 20, $green - 20, $blue) . ";'>{$pc}%</div>";
            print "</td></tr>\n";
            $red = $red + $deltacolor;
            $blue = $blue - $deltacolor / 2;
        }
    }
    print "</table>\n";
    print "</td></table>";
    //	print "<img src=http://chart.apis.google.com/chart?cht=p3&chd=".($chd)."&chs=400x200&chl=".($chl)."&chco=1B75DF,92BF23>\n";
    print "</div>\n";
}