]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentReferrers.php
Use WikiPlugin_WikiAdminSelect::getDefaultArguments instead of PageList::supportedArg...
[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                    'debug'         => false
34                    ));
35     }
36
37     function run($dbi, $argstr, &$request, $basepage) { 
38         if (!ACCESS_LOG) {
39             return HTML::div(array('class' => "error"), "Error: no ACCESS_LOG");
40         }
41         $args = $this->getArgs($argstr, $request); 
42         $table = HTML::table(array('cellpadding' => 1,
43                                    'cellspacing' => 2,
44                                    'border'      => 0,
45                                    'class'       => 'pagelist'));
46         if (!$args['noheader'] and !empty($args['caption']))
47             $table->pushContent(HTML::caption(array('align'=>'top'), $args['caption']));
48         $logs = array();
49         $limit = $args['limit'];
50         $accesslog =& $request->_accesslog;
51         if ($logiter = $accesslog->get_referer($limit, "external_only")
52             and $logiter->count()) {
53             $table->pushContent(HTML::tr(HTML::th("Target"),HTML::th("Referrer"),
54                                          HTML::th("Host"),HTML::th("Date")));
55             while($logentry = $logiter->next()) {
56                 $table->pushContent(HTML::tr(HTML::td($logentry['request']),
57                                              HTML::td($logentry['referer']),
58                                              HTML::td($logentry['host']),
59                                              HTML::td($logentry['time'])
60                                              ));
61             }
62             return $table;
63         }
64     }
65 }
66
67 // (c-file-style: "gnu")
68 // Local Variables:
69 // mode: php
70 // tab-width: 8
71 // c-basic-offset: 4
72 // c-hanging-comment-ender-p: nil
73 // indent-tabs-mode: nil
74 // End:
75 ?>