Added a debug mode.

This commit is contained in:
JT Smith 2002-08-08 03:50:02 +00:00
parent 3ce32801d2
commit f698899ab6
4 changed files with 36 additions and 26 deletions

View file

@ -27,8 +27,8 @@ insert into international values (76,'EventsCalendar',1,'Delete only this event.
insert into international values (77,'EventsCalendar',1,'Delete this event <b>and</b> all of its recurrences.');
insert into international values (78,'EventsCalendar',1,'Don\'t delete anything, I made a mistake.');
update wobject set editTimeout=editTimeout*3600;
insert into international values (707,"WebGUI",1,"Show debugging?");
insert into settings values ('showDebug',0);

View file

@ -29,21 +29,6 @@ sub page {
my ($debug, %contentHash, $w, $cmd, $pageEdit, $wobject, $wobjectOutput, $extra, $originalWobject, $proxyWobjectId,
$sth, $httpHeader, $header, $footer, $content, $operationOutput, $adminBar, %hash);
WebGUI::Session::open($_[0],$_[1]);
if ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3)) {
$debug = '<table bgcolor="#ffffff" style="color: #000000; font-size: 10pt; font-family: helvetica;">';
while (my ($section, $hash) = each %session) {
while (my ($key, $value) = each %$hash) {
if (ref $value eq 'ARRAY') {
$value = '['.join(', ',@$value).']';
} elsif (ref $value eq 'HASH') {
$value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}';
}
$debug .= '<tr><td align="right"><b>'.$section.'.'.$key.':</b></td><td>'.$value.'</td>';
}
$debug .= '<tr height=10><td>&nbsp;</td><td>&nbsp</td></tr>';
}
$debug .='</table>';
}
if (exists $session{form}{op}) {
$cmd = "WebGUI::Operation::www_".$session{form}{op};
$operationOutput = eval($cmd);
@ -55,11 +40,13 @@ sub page {
} else {
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobjectId=".$session{form}{wid});
if (${$wobject}{namespace} eq "") {
WebGUI::ErrorHandler::warn("Wobject [$session{form}{wid}] appears to be missing or corrupt, but was requested "
WebGUI::ErrorHandler::warn("Wobject [$session{form}{wid}] appears to be missing or "
."corrupt, but was requested "
."by $session{user}{username} [$session{user}{userId}].");
$wobject = ();
} else {
$extra = WebGUI::SQL->quickHashRef("select * from ${$wobject}{namespace} where wobjectId=${$wobject}{wobjectId}");
$extra = WebGUI::SQL->quickHashRef("select * from ${$wobject}{namespace}
where wobjectId=${$wobject}{wobjectId}");
tie %hash, 'Tie::CPHash';
%hash = (%{$wobject},%{$extra});
$wobject = \%hash;
@ -68,21 +55,24 @@ sub page {
if ($wobject) {
if (${$wobject}{pageId} != $session{page}{pageId}) {
($proxyWobjectId) = WebGUI::SQL->quickArray("select wobject.wobjectId from wobject,WobjectProxy
where wobject.wobjectId=WobjectProxy.wobjectId and wobject.pageId=".$session{page}{pageId}."
where wobject.wobjectId=WobjectProxy.wobjectId
and wobject.pageId=".$session{page}{pageId}."
and WobjectProxy.proxiedWobjectId=".${$wobject}{wobjectId});
${$wobject}{_WobjectProxy} = $proxyWobjectId;
}
unless (${$wobject}{pageId} == $session{page}{pageId} || ${$wobject}{pageId} == 2 || ${$wobject}{_WobjectProxy} ne "") {
$wobjectOutput .= WebGUI::International::get(417);
WebGUI::ErrorHandler::warn($session{user}{username}." [".$session{user}{userId}."] attempted to access wobject ["
.$session{form}{wid}."] on page '".$session{page}{title}."' [".$session{page}{pageId}."].");
WebGUI::ErrorHandler::warn($session{user}{username}." [".$session{user}{userId}
."] attempted to access wobject ["
.$session{form}{wid}."] on page '".$session{page}{title}."' ["
.$session{page}{pageId}."].");
} else {
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
$w = eval{$cmd->new($wobject)};
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wojbect: ${$wobject}{namespace}.") if($@);
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wojbect: ${$wobject}{namespace}. Root Cause: ".$@) if($@);
$cmd = "www_".$session{form}{func};
$wobjectOutput = eval{$w->$cmd};
WebGUI::ErrorHandler::fatalError("Web method doesn't exist in wojbect: ${$wobject}{namespace} / $session{form}{func}.") if($@);
WebGUI::ErrorHandler::fatalError("Web method doesn't exist in wojbect: ${$wobject}{namespace} / $session{form}{func}. Root Cause: ".$@) if($@);
}
}
}
@ -135,12 +125,12 @@ sub page {
$wobject = \%hash;
$cmd = "WebGUI::Wobject::".${$wobject}{namespace};
$w = eval{$cmd->new($wobject)};
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wojbect: ${$wobject}{namespace}.") if($@);
WebGUI::ErrorHandler::fatalError("Couldn't instanciate wojbect: ${$wobject}{namespace}. Root cause: ".$@) if($@);
if ($w->inDateRange) {
$contentHash{${$wobject}{templatePosition}} .= '<div class="wobject'.${$wobject}{namespace}.'" id="wobjectId'.${$wobject}{wobjectId}.'">';
$contentHash{${$wobject}{templatePosition}} .= '<a name="'.${$wobject}{wobjectId}.'"></a>';
$contentHash{${$wobject}{templatePosition}} .= eval{$w->www_view};
WebGUI::ErrorHandler::fatalError("No view method in wojbect: ${$wobject}{namespace}.") if($@);
WebGUI::ErrorHandler::fatalError("No view method in wojbect: ${$wobject}{namespace}. Root cause: ".$@) if($@);
$contentHash{${$wobject}{templatePosition}} .= "</div>\n\n";
}
}
@ -151,6 +141,23 @@ sub page {
$content = WebGUI::Template::generate(\%contentHash,1);
}
}
if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Privilege::isInGroup(3))) {
$debug = '<div style="background-color: #ffdddd;color: #000000;">'
.$session{debug}{warning}.'</div>';
$debug .= '<table bgcolor="#ffffff" style="color: #000000; font-size: 10pt; font-family: helvetica;">';
while (my ($section, $hash) = each %session) {
while (my ($key, $value) = each %$hash) {
if (ref $value eq 'ARRAY') {
$value = '['.join(', ',@$value).']';
} elsif (ref $value eq 'HASH') {
$value = '{'.join(', ',map {"$_ => $value->{$_}"} keys %$value).'}';
}
$debug .= '<tr><td align="right"><b>'.$section.'.'.$key.':</b></td><td>'.$value.'</td>';
}
$debug .= '<tr height=10><td>&nbsp;</td><td>&nbsp</td></tr>';
}
$debug .='</table>';
}
if ($session{header}{redirect} ne "") {
return $session{header}{redirect};
} else {

View file

@ -84,6 +84,7 @@ sub warn {
}
$log = FileHandle->new(">>".$logfile) or fatalError("Can't open log file for warning.");
print $log localtime(time)." ".$0." WARNING: ".$_[0]."\n";
$session{debug}{warning} .= localtime(time)." ".$0." WARNING: ".$_[0]."<p>";
$log->close;
}

View file

@ -210,6 +210,7 @@ sub www_editMiscSettings {
$f = WebGUI::HTMLForm->new;
$f->hidden("op","editMiscSettingsSave");
$f->yesNo("preventProxyCache",WebGUI::International::get(400),$session{setting}{preventProxyCache});
$f->yesNo("showDebug",WebGUI::International::get(707),$session{setting}{showDebug});
$f->select("onCriticalError",\%criticalError,WebGUI::International::get(413),[$session{setting}{onCriticalError}]);
$f->submit;
$output .= $f->print;
@ -223,6 +224,7 @@ sub www_editMiscSettings {
sub www_editMiscSettingsSave {
if (WebGUI::Privilege::isInGroup(3)) {
_saveSetting("preventProxyCache");
_saveSetting("showDebug");
_saveSetting("onCriticalError");
return www_manageSettings();
} else {