]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentReferrers.php
HTML::raw
[SourceForge/phpwiki.git] / lib / plugin / RecentReferrers.php
1 <?php
2
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 along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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     {
34         return _("RecentReferrers");
35     }
36
37     function getDescription()
38     {
39         return _("Analyse access log.");
40     }
41
42     function getDefaultArguments()
43     {
44         return array_merge
45         (
46             PageList::supportedArgs(),
47             array(
48                 'limit' => 15,
49                 'noheader' => false,
50             ));
51     }
52
53     function run($dbi, $argstr, &$request, $basepage)
54     {
55         if (!ACCESS_LOG) {
56             return HTML::div(array('class' => "error"), "Error: no ACCESS_LOG");
57         }
58         $args = $this->getArgs($argstr, $request);
59         $table = HTML::table(array('cellpadding' => 1,
60             'cellspacing' => 2,
61             'border' => 0,
62             'class' => 'pagelist'));
63         if (!$args['noheader'] and !empty($args['caption']))
64             $table->pushContent(HTML::caption(array('align' => 'top'), $args['caption']));
65         $limit = $args['limit'];
66         $accesslog =& $request->_accesslog;
67         if ($logiter = $accesslog->get_referer($limit, "external_only")
68             and $logiter->count()
69         ) {
70             $table->pushContent(HTML::tr(HTML::th("Target"), HTML::th("Referrer"),
71                 HTML::th("Host"), HTML::th("Date")));
72             while ($logentry = $logiter->next()) {
73                 $table->pushContent(HTML::tr(HTML::td($logentry['request']),
74                     HTML::td($logentry['referer']),
75                     HTML::td($logentry['host']),
76                     HTML::td($logentry['time'])
77                 ));
78             }
79             return $table;
80         }
81         return HTML::raw('');
82     }
83 }
84
85 // Local Variables:
86 // mode: php
87 // tab-width: 8
88 // c-basic-offset: 4
89 // c-hanging-comment-ender-p: nil
90 // indent-tabs-mode: nil
91 // End: