]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentReferrers.php
Revert r7194
[SourceForge/phpwiki.git] / lib / plugin / RecentReferrers.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3
4 /**
5  * Analyze our ACCESS_LOG
6  * Check HTTP_REFERER
7  *
8  */
9 include_once("lib/PageList.php");
10
11 class WikiPlugin_RecentReferrers extends WikiPlugin
12 {
13     function getName () {
14         return _("RecentReferrers");
15     }
16
17     function getDescription () {
18         return _("Analyse access log.");
19     }
20
21     function getVersion() {
22         return preg_replace("/[Revision: $]/", '',
23                             "\$Revision$");
24     }
25
26     function getDefaultArguments() {
27         return array_merge
28             (
29              PageList::supportedArgs(),
30              array(
31                    'limit'         => 15,
32                    'noheader'      => false,
33                    ));
34     }
35
36     function run($dbi, $argstr, &$request, $basepage) { 
37         if (!ACCESS_LOG) {
38             return HTML::div(array('class' => "error"), "Error: no ACCESS_LOG");
39         }
40         $args = $this->getArgs($argstr, $request); 
41         $table = HTML::table(array('cellpadding' => 1,
42                                    'cellspacing' => 2,
43                                    'border'      => 0,
44                                    'class'       => 'pagelist'));
45         if (!$args['noheader'] and !empty($args['caption']))
46             $table->pushContent(HTML::caption(array('align'=>'top'), $args['caption']));
47         $logs = array();
48         $limit = $args['limit'];
49         $accesslog =& $request->_accesslog;
50         if ($logiter = $accesslog->get_referer($limit, "external_only")
51             and $logiter->count()) {
52             $table->pushContent(HTML::tr(HTML::th("Target"),HTML::th("Referrer"),
53                                          HTML::th("Host"),HTML::th("Date")));
54             while($logentry = $logiter->next()) {
55                 $table->pushContent(HTML::tr(HTML::td($logentry['request']),
56                                              HTML::td($logentry['referer']),
57                                              HTML::td($logentry['host']),
58                                              HTML::td($logentry['time'])
59                                              ));
60             }
61             return $table;
62         }
63     }
64 }
65
66 // (c-file-style: "gnu")
67 // Local Variables:
68 // mode: php
69 // tab-width: 8
70 // c-basic-offset: 4
71 // c-hanging-comment-ender-p: nil
72 // indent-tabs-mode: nil
73 // End:
74 ?>