From abdc5526a7f5a9dac49444e47b4af53f37574f71 Mon Sep 17 00:00:00 2001 From: Ian Date: Sat, 24 Jan 2015 20:10:18 +0100 Subject: [PATCH] statistic plugin fixes for 2.0 References s9y/Serendipity#273 --- serendipity_event_statistics/ChangeLog | 8 +- .../serendipity_event_statistics.php | 724 +++++++++--------- 2 files changed, 378 insertions(+), 354 deletions(-) diff --git a/serendipity_event_statistics/ChangeLog b/serendipity_event_statistics/ChangeLog index ed7827cc..c945e480 100644 --- a/serendipity_event_statistics/ChangeLog +++ b/serendipity_event_statistics/ChangeLog @@ -1,3 +1,9 @@ +1.54: +----- +- 2.0 markup ready (YL) +- fix spectrum image height with 2.0 +- slightly reworked last visitors + 1.53: ----- - fixed db table vistors, ip column to IPv6 length @@ -5,7 +11,7 @@ 1.52: ----- -- fixed some missing ending strong tags +- fixed some missing ending strong tags - in 2.0 other markup changes 1.51: diff --git a/serendipity_event_statistics/serendipity_event_statistics.php b/serendipity_event_statistics/serendipity_event_statistics.php index 3ebc2fe6..37e34a3d 100644 --- a/serendipity_event_statistics/serendipity_event_statistics.php +++ b/serendipity_event_statistics/serendipity_event_statistics.php @@ -1,4 +1,4 @@ -add('description', PLUGIN_EVENT_STATISTICS_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Arnan de Gans, Garvin Hicking, Fredrik Sandberg, kalkin'); - $propbag->add('version', '1.53'); + $propbag->add('version', '1.54'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', 'php' => '4.1.0' )); $propbag->add('groups', array('STATISTICS')); - $propbag->add('event_hooks', array( - 'backend_sidebar_entries' => true, + $propbag->add('event_hooks', array( + 'backend_sidebar_admin_appearance' => true, 'backend_sidebar_entries_event_display_statistics' => true, - 'frontend_configure' => true + 'frontend_configure' => true, + 'css_backend' => true )); $propbag->add('configuration', array('max_items','ext_vis_stat','stat_all','banned_bots')); @@ -42,8 +43,8 @@ class serendipity_event_statistics extends serendipity_event case 'ext_vis_stat': - $select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_OPT1, - 'yesBot' => PLUGIN_EVENT_STATISTICS_EXT_OPT2, + $select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_OPT1, + 'yesBot' => PLUGIN_EVENT_STATISTICS_EXT_OPT2, 'yesTop' => PLUGIN_EVENT_STATISTICS_EXT_OPT3); $propbag->add('type', 'select'); @@ -55,7 +56,7 @@ class serendipity_event_statistics extends serendipity_event break; case 'stat_all': - $select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_ALL1, + $select = array('no' => PLUGIN_EVENT_STATISTICS_EXT_ALL1, 'yes' => PLUGIN_EVENT_STATISTICS_EXT_ALL2); $propbag->add('type', 'select'); @@ -67,7 +68,7 @@ class serendipity_event_statistics extends serendipity_event break; case 'banned_bots': - $select = array('yes' => PLUGIN_EVENT_STATISTICS_BANNED_HOSTS1, + $select = array('yes' => PLUGIN_EVENT_STATISTICS_BANNED_HOSTS1, 'no' => PLUGIN_EVENT_STATISTICS_BANNED_HOSTS2); $propbag->add('type', 'select'); @@ -202,9 +203,48 @@ class serendipity_event_statistics extends serendipity_event } break; - case 'backend_sidebar_entries': + + case 'css_backend': ?> - + +.serendipity_statistics table { + background: #eaeaea; + background-image: -webkit-linear-gradient(#fff, #eaeaea); + background-image: linear-gradient(#fff, #eaeaea); + border-color: #ddd #bbb #999; + color: #222; + text-shadow: #fff 0 1px 1px; +} +.stats_imagecell { + vertical-align: bottom; +} +.stats_header { + width: auto; + display: block; + background: #eee; +} +.stats_header span { + text-align: right; + width: 50%; + float: right; +} +.serendipity_statistics .wide_box dl { + clear: left; + display: table; +} +.serendipity_statistics .wide_box dt { + display: table-row; +} +.serendipity_statistics .wide_box dd { + padding: 0 .5em .5em; +} + + +
  • -

    +

    -
    -
    -
    -
    -
    +
    +
    +

    -
    -
    -
    -
    -
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +
    +

    + +
    $author_stat) { ?> -
    -
    (%)
    +
    +
    (%)
    -
    -
    -
    -
    +
    + -
    -
    -
    +
    +

    -
    -
    +

    + +

    + +
    $cat_stat) { ?> -
    -
    +
    +
    -
    -
    -
    -
    +
    +
    -
    -
    -
    +
    +

    -
    -
    +

    + +

    + +
    $image_stat) { ?> -
    -
    +
    +
    -
    -
    -
    -
    +
    +
    -
    -
    -
    +
    +

    -
    -
    +
    +
    +
    +
    + +

    + +
    $com_stat) { ?> -
    -
    +
    +
    -
    -
    +
    +
    -
    -
    +
    +

    + +
    $com_stat) { @@ -401,7 +444,7 @@ class serendipity_event_statistics extends serendipity_event $link_url = ''; if (!empty($com_stat['email'])) { - $link_start = ''; + $link_start = ''; $link_end = ''; } @@ -410,66 +453,68 @@ class serendipity_event_statistics extends serendipity_event $com_stat['url'] = 'http://' . $com_stat['url']; } - $link_url = ' (' . PLUGIN_EVENT_STATISTICS_OUT_LINK . ')'; + $link_url = ' (' . PLUGIN_EVENT_STATISTICS_OUT_LINK . ')'; } if (empty($com_stat['author'])) { $com_stat['author'] = ANONYMOUS; } ?> -
    -
    +
    +
    -
    -
    -
    -
    +
    + -
    -
    -
    +
    +

    -
    -
    +

    + +

    + +
    $subscriber_stat) { ?> -
    -
    +
    +
    -
    -
    -
    -
    +
    +
    -
    -
    -
    +
    +

    -
    -
    +

    + +

    + +
    $tb_stat) { ?> -
    -
    +
    +
    -
    -
    +
    +
    -
    -
    +
    +

    + +
    $tb_stat) { @@ -477,75 +522,67 @@ class serendipity_event_statistics extends serendipity_event $tb_stat['author'] = ANONYMOUS; } ?> -
    -
    +
    +
    -
    -
    -
    -
    +
    + -
    -
    -
    +
    +

    (Needs a heading)

    -
    -
    -
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    -
    -
    -
    +
    +

    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    +
    $length_stat) { ?> -
    -
    +
    +
    -
    +
    +
    -
    -
    -
    +
    +

    -
    -
    -
    -
    -
    + + + +
    +

    + + +
    $max_items)); ?>
    - - "; - echo ".colVis {text-align: center; width:600px; font-size: 10px; background-color:#dddddd;} "; - echo ".col1 {text-align: center; width:150px; font-size: 10px; background-color:#dddddd;} "; - echo ".col2 {text-align: center; width:150px; font-size: 10px; background-color:#CCCCFF;} "; - echo ".col4 {text-align: center; width:600px; font-size: 10px; background-color:#dddddd;} "; - echo ".col5 {text-align: center; width:600px; font-size: 10px; background-color:#CCCCFF;} "; - echo ""; - + $visitors_count_today = serendipity_db_query("SELECT visits FROM {$serendipity['dbPrefix']}visitors_count WHERE year = '".$year."' AND month = '".$month."' AND day = '".$day."'", true); + $visitors_count = serendipity_db_query("SELECT SUM(visits) FROM {$serendipity['dbPrefix']}visitors_count", true); + $hits_count_today = serendipity_db_query("SELECT hits FROM {$serendipity['dbPrefix']}visitors_count WHERE year = '".$year."' AND month = '".$month."' AND day = '".$day."'", true); + $hits_count = serendipity_db_query("SELECT SUM(hits) FROM {$serendipity['dbPrefix']}visitors_count", true); + $visitors_latest = serendipity_db_query("SELECT counter_id, day, time, ref, browser, ip FROM {$serendipity['dbPrefix']}visitors ORDER BY counter_id DESC LIMIT ".$max_items.""); + $top_refs = serendipity_db_query("SELECT refs, count FROM {$serendipity['dbPrefix']}refs ORDER BY count DESC LIMIT 20"); ?> -

    -
    -
    -
    - - - - - - - - - - - - - -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    +

    - -
    - 0) { ?> - - statistics_getmonthlystats(); - $rep = $num; - rsort($rep); - $maxVisHeigh = 100/$rep[0]*2; - for ($i=1; $i < 13; $i++) { - if ($color == "col1") { - $color ="col2"; - } else { - $color ="col1"; - } +
    +
    +

    - echo '
    '; - } ?> - - 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', - '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); - $color = "col2"; - for ($i = 1; $i < 13; $i++) { - if ($color == "col1") { - $color ="col2"; - } else { - $color ="col1"; +

    + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + +
    +

    + '; + foreach($top_refs AS $key => $row) { + echo '
  • '.$row['refs'].' ('.$row['count'].')
  • '; } - echo '
    '; + echo ''; + } else { + echo " ".PLUGIN_EVENT_STATISTICS_EXT_TOPREFS_NONE.""; } - ?> -
    ' . $num[$i]; - echo '
    '; - echo '
    '. serendipity_strftime('%b', mktime(0, 0, 0, $i, 1, 2000)) .'
    - + ?> + + +
    +

    -
    0) { ?> - - statistics_getdailystats(); - $rep = $num; - rsort($rep); - for ($i=1; $i < 32; $i++) { - if ($color == "col1") { - $color ="col2"; - } else { - $color ="col1"; +
    + + + + 'Jan', '2' => 'Feb', '3' => 'Mar', '4' => 'Apr', '5' => 'May', '6' => 'Jun', '7' => 'Jul', '8' => 'Aug', '9' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); + for ($i = 1; $i < 13; $i++) { + echo ''; } - - $maxVisHeigh = 100/$rep[0]*2; - echo ''; } - echo '" width="8" alt="" align="bottom" height="'.round($num[$i]*$maxVisHeigh).'" />'; - echo '
    '; - } - ?> - - '. $i .''; - } ?> -
    '. serendipity_strftime('%b', mktime(0, 0, 0, $i, 1, 2000)) .'' . $num[$i]; - echo '
    Visits + statistics_getmonthlystats(); + for ($i=1; $i < 13; $i++) { + echo '
    ' . $num[$i] . '
    - - + ?> + + + +/~/- + statistics_getmonthlystats(); + $rep = $num; + rsort($rep); -

    - -
    - -
    -
    - - $row) { - if ($color == "col1"){$color ="col2";}else{$color ="col1";} - echo ""; - echo "\n"; - if($row['ref']!='unknown'){ - echo "\n"; - } - if($row['ref']=='unknown'){ - echo "\n"; - } - echo "\n"; - echo "\n"; - echo "\n"; - } - } - ?> -
    ".$row['day']." ".$row['time']."".wordwrap($row['ref'], 25, "
    ", 1)."
    ".wordwrap($row['ref'], 25, "
    ", 1)."
    ".wordwrap($row['browser'], 25, "
    ", 1)."
    "; - if ($row['ip']){ - $curIP = $row['ip']; - if (array_key_exists($curIP, $resolvedHosts)) { - $resolvedHost = $resolvedHosts[$curIP]; - } else { - $resolvedHost = gethostbyaddr($curIP); - $resolvedHosts[$curIP] = $resolvedHost; - } - echo wordwrap($resolvedHost, 25, "\n", 1); - } else { - echo "--"; - } - echo "

    -
    -
    -
    -
    -
    - - $row) { - if ($color == "col4") { - $color ="col5"; - } else { - $color ="col4"; - } - echo ''; - } + for ($i=1; $i < 13; $i++) { + $maxVisHeigh = 100/$rep[0]*2; + $monthHeight = round($num[$i]*$maxVisHeigh); + echo ''; + } + ?> + +
    '.$i++.'. '.$row['refs'].' ('.$row['count'].')
    ';
+                        if ($num[$i]*$maxVisHeigh/2 <= 33) {
+                            echo '-';
+                        } else if ($num[$i]*$maxVisHeigh/2 > 33 && $num[$i]*$maxVisHeigh/2 < 66) {
+                            echo '~';
+                        } else {
+                            echo '+';
+                        }
+                        echo '
    -
    -
    + +
    - +

    + + 0) { ?> + + + + + '. $i .''; + } + ?> + + + + statistics_getdailystats(); + for ($i=1; $i < 32; $i++) { + echo ''; + } + ?> + + + + statistics_getdailystats(); + $rep = $num; + rsort($rep); + + for ($i=1; $i < 32; $i++) { + $maxVisHeigh = 100/$rep[0]*2; + $dailyHeight = round($num[$i]*$maxVisHeigh); + echo ''; + } + ?> + +
    Visits' . $num[$i] . '
    +/~/-';
+                        if ($num[$i]*$maxVisHeigh/2 <= 33) {
+                            echo '-';
+                        } else if ($num[$i]*$maxVisHeigh/2 > 33 && $num[$i]*$maxVisHeigh/2 < 66) {
+                            echo '~';
+                        } else {
+                            echo '+';
+                        }
+                        echo '
    + + + +
    +

    + +
    + $row) { + echo '
    '.$row['day'].' ('.$row['time'].')'; + echo "" . ($row['ip'] ? gethostbyaddr($row['ip']) : '-') . "\n"; + echo "
    \n"; + + if($row['ref'] != 'unknown'){ + echo "
    ".$row['ref']."
    \n"; + } + if($row['ref'] == 'unknown'){ + echo "
    ".$row['ref']."
    \n"; + } + echo "
    ".$row['browser']."
    \n"; + } + } +?> +
    +
    +
    +set_config('db_indices_created', '2');