*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
/**
* The admin class handles the display and user-manipulation of the 404 log.
*/
class admin_plugin_log404 extends DokuWiki_Admin_Plugin {
public function handle() {
global $ID;
if (isset($_GET['delete'])) {
$log = $this->loadHelper('log404');
$log->deleteRecord($_GET['delete']);
msg(sprintf($this->getLang('deleted'), $_GET['delete']));
send_redirect(wl($ID, array('do'=>'admin', 'page'=>$this->getPluginName()), true, '&'));
}
}
public function html() {
ptln('
'.$this->getLang('menu').'
');
$log = $this->loadHelper('log404');
$log->load();
ptln('');
foreach ($log->getRecords() as $id => $detail) {
ptln($this->getHtml($id, $detail));
}
ptln('
');
}
protected function getHtml($id, $data) {
global $ID;
$delUrl = wl($ID, array('do'=>'admin', 'page'=>$this->getPluginName(), 'delete'=>$id));
$ignoreUrl = wl($ID, array('do'=>'admin', 'page'=>$this->getPluginName(), 'ignore'=>$id));
$title = ''.$data['count'].' '.$id.'
'
. ' '.$this->getLang('go-to-page').''
. ' '.sprintf($this->getLang('delete'), $data['count']).''
. ' '.$this->getLang('ignore').''
. '';
$out = $title.'';
foreach ($data['hits'] as $hit) {
$line = $hit['date'];
if (!empty($hit['ip'])) {
$line .= ' '.$this->getLang('ip').' '.$hit['ip'];
}
if (!empty($hit['referer'])) {
$line .= ' '.$this->getLang('referer').' '.$hit['referer'].'';
}
if (!empty($hit['user_agent'])) {
$line .= ' '.$this->getLang('user-agent').' '.$hit['user_agent'];
}
// The line should never actually be empty, but still...
if (!empty($line)) {
$out .= "- $line
";
}
}
$out .= '
';
return "$out";
}
}