Cleaning up the administrative UI.
This commit is contained in:
parent
e8bab4e22b
commit
ca32410535
6 changed files with 489 additions and 588 deletions
|
|
@ -18,6 +18,7 @@ use strict;
|
|||
use WebGUI::DateTime;
|
||||
use WebGUI::Icon;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Operation::Shared;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
|
|
@ -27,159 +28,175 @@ our @ISA = qw(Exporter);
|
|||
our @EXPORT = qw(&www_viewPageReport &www_viewStatistics &www_viewTrafficReport &www_killSession
|
||||
&www_viewLoginHistory &www_viewActiveSessions);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _submenu {
|
||||
my (%menu);
|
||||
tie %menu, 'Tie::IxHash';
|
||||
$menu{WebGUI::URL::page("op=viewActiveSessions")} = WebGUI::International::get(423);
|
||||
$menu{WebGUI::URL::page("op=viewLoginHistory")} = WebGUI::International::get(424);
|
||||
$menu{WebGUI::URL::page("op=viewPageReport")} = WebGUI::International::get(796);
|
||||
# $menu{WebGUI::URL::page("op=viewTrafficReport")} = WebGUI::International::get(797);
|
||||
$menu{WebGUI::URL::page('op=viewStatistics')} = WebGUI::International::get(144);
|
||||
return menuWrapper($_[0],\%menu);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_killSession {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::Session::end($session{form}{sid});
|
||||
return www_viewActiveSessions();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
WebGUI::Session::end($session{form}{sid});
|
||||
return www_viewActiveSessions();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewActiveSessions {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $p, @row, $i, $sth, %data);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = '<h1>'.WebGUI::International::get(425).'</h1>';
|
||||
$sth = WebGUI::SQL->read("select * from users,userSession where users.userId=userSession.userId");
|
||||
while (%data = $sth->hash) {
|
||||
$row[$i] = '<tr class="tableData"><td>'.$data{username}.' ('.$data{userId}.')</td>';
|
||||
$row[$i] .= '<td>'.$data{sessionId}.'</td>';
|
||||
$row[$i] .= '<td>'.epochToHuman($data{expires},"%H:%n%p %M/%D/%y").'</td>';
|
||||
$row[$i] .= '<td>'.epochToHuman($data{lastPageView},"%H:%n%p %M/%D/%y").'</td>';
|
||||
$row[$i] .= '<td>'.$data{lastIP}.'</td>';
|
||||
$row[$i] .= '<td align="center">'.deleteIcon("op=killSession&sid=$data{sessionId}").'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=viewActiveSessions'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr class="tableHeader"><td>'.WebGUI::International::get(428).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(435).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(432).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(430).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(431).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(436).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
$output = '<h1>'.WebGUI::International::get(425).'</h1>';
|
||||
$sth = WebGUI::SQL->read("select * from users,userSession where users.userId=userSession.userId");
|
||||
while (%data = $sth->hash) {
|
||||
$row[$i] = '<tr class="tableData"><td>'.$data{username}.' ('.$data{userId}.')</td>';
|
||||
$row[$i] .= '<td>'.$data{sessionId}.'</td>';
|
||||
$row[$i] .= '<td>'.epochToHuman($data{expires},"%H:%n%p %M/%D/%y").'</td>';
|
||||
$row[$i] .= '<td>'.epochToHuman($data{lastPageView},"%H:%n%p %M/%D/%y").'</td>';
|
||||
$row[$i] .= '<td>'.$data{lastIP}.'</td>';
|
||||
$row[$i] .= '<td align="center">'.deleteIcon("op=killSession&sid=$data{sessionId}").'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
return $output;
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=viewActiveSessions'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr class="tableHeader"><td>'.WebGUI::International::get(428).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(435).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(432).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(430).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(431).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(436).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewLoginHistory {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $p, @row, $i, $sth, %data);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = '<h1>'.WebGUI::International::get(426).'</h1>';
|
||||
$sth = WebGUI::SQL->read("select * from users,userLoginLog where users.userId=userLoginLog.userId order by userLoginLog.timeStamp desc");
|
||||
while (%data = $sth->hash) {
|
||||
$data{username} = 'unknown user' if ($data{userId} == 0);
|
||||
$row[$i] = '<tr class="tableData"><td>'.$data{username}.' ('.$data{userId}.')</td>';
|
||||
$row[$i] .= '<td>'.$data{status}.'</td>';
|
||||
$row[$i] .= '<td>'.epochToHuman($data{timeStamp},"%H:%n%p %M/%D/%y").'</td>';
|
||||
$row[$i] .= '<td>'.$data{ipAddress}.'</td>';
|
||||
$row[$i] .= '<td>'.$data{userAgent}.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=viewLoginHistory'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr class="tableHeader"><td>'.WebGUI::International::get(428).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(434).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(429).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(431).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(433).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBar($session{form}{pn});
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
$output = '<h1>'.WebGUI::International::get(426).'</h1>';
|
||||
$sth = WebGUI::SQL->read("select * from users,userLoginLog where users.userId=userLoginLog.userId order by userLoginLog.timeStamp desc");
|
||||
while (%data = $sth->hash) {
|
||||
$data{username} = 'unknown user' if ($data{userId} == 0);
|
||||
$row[$i] = '<tr class="tableData"><td>'.$data{username}.' ('.$data{userId}.')</td>';
|
||||
$row[$i] .= '<td>'.$data{status}.'</td>';
|
||||
$row[$i] .= '<td>'.epochToHuman($data{timeStamp},"%H:%n%p %M/%D/%y").'</td>';
|
||||
$row[$i] .= '<td>'.$data{ipAddress}.'</td>';
|
||||
$row[$i] .= '<td>'.$data{userAgent}.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
return $output;
|
||||
$sth->finish;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=viewLoginHistory'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= '<tr class="tableHeader"><td>'.WebGUI::International::get(428).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(434).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(429).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(431).'</td>';
|
||||
$output .= '<td>'.WebGUI::International::get(433).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $p->getBar($session{form}{pn});
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewPageReport {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $count, $user, $data, $sth, $page, $pageId);
|
||||
$sth = WebGUI::SQL->read("select pageTitle,pageId,userId,ipAddress,wobjectId from pageStatistics order by pageTitle,userId,ipAddress");
|
||||
while ($data = $sth->hashRef) {
|
||||
if ($data->{userId} == 1) {
|
||||
$user = $data->{ipAddress};
|
||||
} else {
|
||||
$user = $data->{userId};
|
||||
}
|
||||
$page->{$data->{pageId}}{pageTitle} = $data->{pageTitle};
|
||||
$page->{$data->{pageId}}{users}{$user}++;
|
||||
$page->{$data->{pageId}}{views}++;
|
||||
$page->{$data->{pageId}}{interact}++ if ($data->{wobjectId});
|
||||
}
|
||||
$sth->finish;
|
||||
$output = '<h1>Page Statistics</h1>';
|
||||
$output .= '<table><tr><td>Page Title</td><td>Page Views</td><td>Unique Visitors</td><td>Wobject Interactions</td></tr>';
|
||||
foreach $pageId (keys %{$page}) {
|
||||
$output .= '<tr><td>'.$page->{$pageId}{pageTitle}.'</td>';
|
||||
$output .= '<td>'.$page->{$pageId}{views}.'</td>';
|
||||
$count = 0;
|
||||
foreach (keys %{$page->{$pageId}{users}}) {
|
||||
$count++;
|
||||
unless ($session{setting}{trackPageStatistics}) {
|
||||
$output .= WebGUI::International::get(802);
|
||||
} else {
|
||||
$sth = WebGUI::SQL->read("select pageTitle,pageId,userId,ipAddress,wobjectId
|
||||
from pageStatistics order by pageTitle,userId,ipAddress");
|
||||
while ($data = $sth->hashRef) {
|
||||
if ($data->{userId} == 1) {
|
||||
$user = $data->{ipAddress};
|
||||
} else {
|
||||
$user = $data->{userId};
|
||||
}
|
||||
$page->{$data->{pageId}}{pageTitle} = $data->{pageTitle};
|
||||
$page->{$data->{pageId}}{users}{$user}++;
|
||||
$page->{$data->{pageId}}{views}++;
|
||||
$page->{$data->{pageId}}{interact}++ if ($data->{wobjectId});
|
||||
}
|
||||
$output .= '<td>'.$count.'</td>';
|
||||
$output .= '<td>'.$page->{$pageId}{interact}.'</td></tr>';
|
||||
$sth->finish;
|
||||
$output .= '<table width="100%" cellpadding="3" cellspacing="0" border="1">
|
||||
<tr><td class="tableHeader">'.WebGUI::International::get(798).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(799).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(800).'</td>
|
||||
<td class="tableHeader">'.WebGUI::International::get(801).'</td></tr>';
|
||||
foreach $pageId (keys %{$page}) {
|
||||
$output .= '<tr><td class="tableData">'.$page->{$pageId}{pageTitle}.'</td>';
|
||||
$output .= '<td class="tableData">'.$page->{$pageId}{views}.'</td>';
|
||||
$count = 0;
|
||||
foreach (keys %{$page->{$pageId}{users}}) {
|
||||
$count++;
|
||||
}
|
||||
$output .= '<td class="tableData">'.$count.'</td>';
|
||||
$output .= '<td class="tableData">'.$page->{$pageId}{interact}.'</td></tr>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
}
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewStatistics {
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $data, $header, $userAgent, $request, $response, $version, $referer);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$userAgent = new LWP::UserAgent;
|
||||
$userAgent->agent("WebGUI-Check/2.0");
|
||||
$userAgent->timeout(10);
|
||||
$header = new HTTP::Headers;
|
||||
$referer = "http://webgui.web.getversion/".$session{env}{SERVER_NAME}.$session{env}{REQUEST_URI};
|
||||
chomp $referer;
|
||||
$header->referer($referer);
|
||||
$request = new HTTP::Request (GET => "http://www.plainblack.com/downloads/latest-version.txt", $header);
|
||||
$response = $userAgent->request($request);
|
||||
$version = $response->content;
|
||||
chomp $version;
|
||||
$output .= helpIcon(12);
|
||||
$output .= '<h1>'.WebGUI::International::get(437).'</h1>';
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(145).'</td><td class="tableData">'.$WebGUI::VERSION.' ('.WebGUI::International::get(349).': '.$version.')</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from userSession");
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(146).'</td><td class="tableData">'.$data.' (<a href="'.WebGUI::URL::page("op=viewActiveSessions").'">'.WebGUI::International::get(423).'</a> / <a href="'.WebGUI::URL::page("op=viewLoginHistory").'">'.WebGUI::International::get(424).'</a>)</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from page where parentId>25");
|
||||
$data++;
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(147).'</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from wobject");
|
||||
$data--;
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(148).'</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from style where styleId>25");
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(427).'</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from users where userId>25");
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(149).'</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from groups where groupId>25");
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(89).'</td><td class="tableData">'.$data.'</td></tr>';
|
||||
$output .= '</table>';
|
||||
} else {
|
||||
$output = WebGUI::Privilege::adminOnly();
|
||||
}
|
||||
return $output;
|
||||
$userAgent = new LWP::UserAgent;
|
||||
$userAgent->agent("WebGUI-Check/2.0");
|
||||
$userAgent->timeout(10);
|
||||
$header = new HTTP::Headers;
|
||||
$referer = "http://webgui.web.getversion/".$session{env}{SERVER_NAME}.$session{env}{REQUEST_URI};
|
||||
chomp $referer;
|
||||
$header->referer($referer);
|
||||
$request = new HTTP::Request (GET => "http://www.plainblack.com/downloads/latest-version.txt", $header);
|
||||
$response = $userAgent->request($request);
|
||||
$version = $response->content;
|
||||
chomp $version;
|
||||
$output .= helpIcon(12);
|
||||
$output .= '<h1>'.WebGUI::International::get(437).'</h1>';
|
||||
$output .= '<table>';
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(145).':</td><td class="tableData">'.$WebGUI::VERSION.'</td></tr>';
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(349).':</td><td class="tableData">'.$version.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from page where parentId>1000 and parentId<>3");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(147).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from page where parentId>1000 and parentId=0");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(795).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from page where parentId=5");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(794).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from wobject where wobjectId > 0 and pageId<>3");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(148).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from style where styleId>1000");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(427).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from template where templateId>1000");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(792).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from collateral where collateralId>1000");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(793).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from userSession");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(146).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from users where userId>25");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(149).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from groups where groupId>25");
|
||||
$output .= '<tr><td align="right" class="tableHeader">'.WebGUI::International::get(89).':</td><td class="tableData">'.$data.'</td></tr>';
|
||||
$output .= '</table>';
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewTrafficReport {
|
||||
return WebGUI::Privilege::adminOnly() unless WebGUI::Privilege::isInGroup(3);
|
||||
return WebGUI::Privilege::adminOnly() unless (WebGUI::Privilege::isInGroup(3));
|
||||
my ($output, $data);
|
||||
$output = '<h1>Pages</h1>';
|
||||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-2592000));
|
||||
|
|
@ -198,7 +215,7 @@ sub www_viewTrafficReport {
|
|||
($data) = WebGUI::SQL->quickArray("select count(*) from pageStatistics where dateStamp>=".(time()-86400)
|
||||
." group by ipAddress,userId");
|
||||
$output .= "Last 24 hours: ".$data."<br>";
|
||||
return $output;
|
||||
return _submenu($output);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue