]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentReferrers.php
Replace tabs by spaces; remove EOL spaces
[SourceForge/phpwiki.git] / lib / plugin / RecentReferrers.php
1 <?php // -*-php-*-
2 rcs_id('$Id$');
3 /*
4  * Copyright (C) 2004 $ThePhpWikiProgrammingTeam
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 /**
24  * Analyze our ACCESS_LOG
25  * Check HTTP_REFERER
26  *
27  */
28 include_once("lib/PageList.php");
29
30 class WikiPlugin_RecentReferrers extends WikiPlugin
31 {
32     function getName () {
33         return _("RecentReferrers");
34     }
35
36     function getDescription () {
37         return _("Analyse access log.");
38     }
39
40     function getVersion() {
41         return preg_replace("/[Revision: $]/", '',
42                             "\$Revision$");
43     }
44
45     function getDefaultArguments() {
46         return array_merge
47             (
48              PageList::supportedArgs(),
49              array(
50                    'limit'            => 15,
51                    'noheader'      => false,
52                    ));
53     }
54
55     function run($dbi, $argstr, &$request, $basepage) {
56         if (!ACCESS_LOG) {
57             return HTML::div(array('class' => "error"), "Error: no ACCESS_LOG");
58         }
59         $args = $this->getArgs($argstr, $request);
60         $table = HTML::table(array('cellpadding' => 1,
61                                    'cellspacing' => 2,
62                                    'border'      => 0,
63                                    'class'       => 'pagelist'));
64         if (!$args['noheader'] and !empty($args['caption']))
65             $table->pushContent(HTML::caption(array('align'=>'top'), $args['caption']));
66         $logs = array();
67         $limit = $args['limit'];
68         $accesslog =& $request->_accesslog;
69         if ($logiter = $accesslog->get_referer($limit, "external_only")
70             and $logiter->count()) {
71             $table->pushContent(HTML::tr(HTML::th("Target"),HTML::th("Referrer"),
72                                          HTML::th("Host"),HTML::th("Date")));
73             while($logentry = $logiter->next()) {
74                 $table->pushContent(HTML::tr(HTML::td($logentry['request']),
75                                              HTML::td($logentry['referer']),
76                                              HTML::td($logentry['host']),
77                                              HTML::td($logentry['time'])
78                                              ));
79             }
80             return $table;
81         }
82     }
83 }
84
85 // (c-file-style: "gnu")
86 // Local Variables:
87 // mode: php
88 // tab-width: 8
89 // c-basic-offset: 4
90 // c-hanging-comment-ender-p: nil
91 // indent-tabs-mode: nil
92 // End:
93 ?>