]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentReferrers.php
more logging fixes
[SourceForge/phpwiki.git] / lib / plugin / RecentReferrers.php
1 <?php // -*-php-*-
2 rcs_id('$Id: RecentReferrers.php,v 1.2 2004-11-07 18:34:29 rurban Exp $');
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: 1.2 $");
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) return;
35         $args = $this->getArgs($argstr, $request); 
36         $table = HTML::table(array('cellpadding' => 1,
37                                    'cellspacing' => 2,
38                                    'border'      => 0,
39                                    'class'       => 'pagelist'));
40         if (!$args['noheader'] and !empty($args['caption']))
41             $table->pushContent(HTML::caption(array('align'=>'top'), $args['caption']));
42         $logs = array();
43         $limit = $args['limit'];
44         $accesslog =& $request->_accesslog;
45         if ($logiter = $accesslog->get_referer($limit, "external_only")
46             and $logiter->count()) {
47             $table->pushContent(HTML::tr(HTML::th("Target"),HTML::th("Referrer"),
48                                          HTML::th("Host"),HTML::th("Date")));
49             while($logentry = $logiter->next()) {
50                 $table->pushContent(HTML::tr(HTML::td($logentry['request']),
51                                              HTML::td($logentry['referer']),
52                                              HTML::td($logentry['host']),
53                                              HTML::td($logentry['time'])
54                                              ));
55             }
56             return $table;
57         }
58     }
59 }
60
61 // $Log: not supported by cvs2svn $
62 // Revision 1.1  2004/11/06 04:52:29  rurban
63 // simple version at first
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 ?>