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