]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/plugin/RecentReferrers.php
Use real list instead of middot
[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 getDescription()
33     {
34         return _("Analyse access log.");
35     }
36
37     function getDefaultArguments()
38     {
39         return array_merge
40         (
41             PageList::supportedArgs(),
42             array(
43                 'limit' => 15,
44                 'noheader' => false,
45             ));
46     }
47
48     /**
49      * @param WikiDB $dbi
50      * @param string $argstr
51      * @param WikiRequest $request
52      * @param string $basepage
53      * @return mixed
54      */
55     function run($dbi, $argstr, &$request, $basepage)
56     {
57         if (!ACCESS_LOG) {
58             return HTML::div(array('class' => "error"), _("Error: no ACCESS_LOG"));
59         }
60         $args = $this->getArgs($argstr, $request);
61         $table = HTML::table(array('class' => 'pagelist'));
62         if (!$args['noheader'] and !empty($args['caption']))
63             $table->pushContent(HTML::caption(array('style' => 'caption-side:top'), $args['caption']));
64         $limit = $args['limit'];
65         $accesslog =& $request->_accesslog;
66         if ($logiter = $accesslog->get_referer($limit, "external_only")
67             and $logiter->count()
68         ) {
69             $table->pushContent(HTML::tr(HTML::th(_("Target")), HTML::th(_("Referrer")),
70                 HTML::th(_("Host")), HTML::th(_("Date"))));
71             while ($logentry = $logiter->next()) {
72                 $table->pushContent(HTML::tr(HTML::td($logentry['request']),
73                     HTML::td($logentry['referer']),
74                     HTML::td($logentry['host']),
75                     HTML::td($logentry['time'])
76                 ));
77             }
78             return $table;
79         }
80         return HTML::raw('');
81     }
82 }
83
84 // Local Variables:
85 // mode: php
86 // tab-width: 8
87 // c-basic-offset: 4
88 // c-hanging-comment-ender-p: nil
89 // indent-tabs-mode: nil
90 // End: