229 lines
8.9 KiB
Perl
Executable File
229 lines
8.9 KiB
Perl
Executable File
#!/usr/sbin/perl
|
|
|
|
#**************************************************************************
|
|
#* *
|
|
#* Copyright (c) 1996 Silicon Graphics, Inc. *
|
|
#* All Rights Reserved *
|
|
#* *
|
|
#* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
|
|
#* *
|
|
#* The copyright notice above does not evidence any actual of intended *
|
|
#* publication of such source code, and is an unpublished work by Silicon *
|
|
#* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
|
|
#* the property of Silicon Graphics, Inc. Any use, duplication or *
|
|
#* disclosure not specifically authorized by Silicon Graphics is strictly *
|
|
#* prohibited. *
|
|
#* *
|
|
#* RESTRICTED RIGHTS LEGEND: *
|
|
#* *
|
|
#* Use, duplication or disclosure by the Government is subject to *
|
|
#* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
|
|
#* Technical Data and Computer Software clause at DFARS 52.227-7013, *
|
|
#* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
|
|
#* Supplement. Unpublished - rights reserved under the Copyright Laws of *
|
|
#* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
|
|
#* Shoreline Blvd., Mountain View, CA 94039-7311 *
|
|
#**************************************************************************
|
|
|
|
# DEMO_errors.pl
|
|
#
|
|
# Routines for handling errors
|
|
|
|
1; # Return true
|
|
|
|
sub Print_Error {
|
|
local($prompt, $message, $status, $error_message);
|
|
$prompt = shift;
|
|
$message = shift;
|
|
$status = shift;
|
|
$time_stamp = &Get_Time_Stamp;
|
|
$error_message = "$time_stamp> $prompt: $message";
|
|
&Write_Error_Message("$error_message");
|
|
&Take_Error_Action("$status");
|
|
}
|
|
|
|
sub Take_Error_Action {
|
|
local($error_message);
|
|
if ("$_[0]" ne "$STATUS_MINOR" && "$_[0]" ne "") {
|
|
$error_message = "$time_stamp> $ERROR_NOTIFY_PROMPT: Script Terminated Due To Errors" if ("$_[0]" eq "$STATUS_SERIOUS");
|
|
&Write_Error_Message("$error_message");
|
|
&Txt_Pop("Critical Error","$error_message Check error log.");
|
|
exit 0 if ("$_[0]" eq "$STATUS_SERIOUS");
|
|
}
|
|
}
|
|
|
|
|
|
sub Write_Error_Message {
|
|
local($num_lines, $too_long);
|
|
$too_long = 0; $num_lines = &Lines_In_Log;
|
|
$too_long = 1 if ($num_lines >= $ERROR_LOG_MAX_LENGTH);
|
|
open(LOG, ">>$FILE_ERROR_LOG");
|
|
print LOG "$_[0]\n";
|
|
close(LOG);
|
|
if ($too_long) {
|
|
&Trim_Log($num_lines);
|
|
}
|
|
}
|
|
|
|
sub Trim_Log {
|
|
local($total_lines, $trim_lines);
|
|
$total_lines = shift;
|
|
$trim_lines = $total_lines/2;
|
|
open(LOG, "$FILE_ERROR_LOG");
|
|
open(TMP_LOG, ">$FILE_LOG_TMP");
|
|
while (<LOG>) {
|
|
print TMP_LOG $_ if ($. >= $trim_lines);
|
|
}
|
|
close(LOG);
|
|
close(TMP_LOG);
|
|
rename("$FILE_LOG_TMP", "$FILE_ERROR_LOG");
|
|
}
|
|
|
|
sub Lines_In_Log {
|
|
local($num_lines);
|
|
open(LOG, "$FILE_ERROR_LOG");
|
|
while(<LOG>) {
|
|
$num_lines = $.;
|
|
}
|
|
close(LOG);
|
|
return($num_lines);
|
|
}
|
|
|
|
|
|
sub Get_Time_Stamp {
|
|
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
|
@weekday = (Sun,Mon,Tues,Web,Thurs,Fri,Sat);
|
|
$wday = @weekday[$wday];
|
|
@month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
|
|
$mon = $month[$mon];
|
|
$mday = " $mday" if ($mday <= 9);
|
|
$hour = " $hour" if ($hour <= 9);
|
|
$min = "0$min" if ($min <= 9);
|
|
$sec = "0$sec" if ($sec <= 9);
|
|
return("$mon $mday $hour:$min:$sec");
|
|
}
|
|
|
|
sub Print_Bad_Input_Page {
|
|
&Print_HTTP_Header("Error! Bad Input");
|
|
print "<body bgcolor=red>\n";
|
|
print "Bad input!\n";
|
|
&Print_HTTP_Footer;
|
|
}
|
|
|
|
sub Print_Directorystate_Error {
|
|
$title = "Wrong Directory Permissions/Ownership";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_DIRSTATE";
|
|
print "\">$title</a>\n<b> -- Fix this first!</b></nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Indexstate_Error {
|
|
$title = "Wrong Index Permissions/Ownership";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_INDEXSTATE";
|
|
print "\">$title</a>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Thumbstate_Error {
|
|
$title = "Wrong Thumbnail Image Permissions/Ownership";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_THUMBSTATE";
|
|
print "\">$title</a>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Thumbfound_Error {
|
|
$title = "Thumbnail Image Not Found";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_THUMBFOUND";
|
|
print "\">$title</a>\n";
|
|
print "<font size=2>Use default thumbnail image\n";
|
|
print "<input type=checkbox name=\"$CGI_ADD_THUMBNAIL_SWITCH\" value=\"$CGI_MAINT_TRUE_FLAG\" checked>\n";
|
|
print "</font\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Picstate_Error {
|
|
$title = "Wrong Demo Image Permissions/Ownership";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_PICSTATE";
|
|
print "\">$title</a>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Picfound_Error {
|
|
$title = "Demo Image Not Found";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_PICFOUND";
|
|
print "\">$title</a>\n";
|
|
print "<font size=2>Use default demo image\n";
|
|
print "<input type=checkbox name=\"$CGI_ADD_PIC_SWITCH\" value=\"$CGI_MAINT_TRUE_FLAG\" checked>\n";
|
|
print "</font>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Demostate_Error {
|
|
$title = "Wrong RUN Executable Permissions";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_DEMOSTATE";
|
|
print "\">$title</a>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Demofound_Error {
|
|
$title = "RUN Executable Not Found";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_DEMOFOUND";
|
|
print "\">$title</a>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
sub Print_Headerstate_Error {
|
|
$title = "Wrong Header Image Permissions/Ownership";
|
|
print "<nobr><img align=left vspace=5 src=\"$IMGSRC_BULLET\" border=0>\n";
|
|
print "<a target=$FRAME_DIAG onMouseOver = \"window.status = ";
|
|
print "\'Detailed Information On This Error\'; return true \" ";
|
|
print "href=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_DIAG&$CGI_SUB_SWITCH=$CGI_ERROR_POP_FLAG&";
|
|
print "$CGI_ERROR_TITLE_SWITCH=";
|
|
print &HTTP_Syntax("$title");
|
|
print "&$CGI_ERROR_FILE_SWITCH=$ERROR_FILE_HEADERSTATE";
|
|
print "\">$title</a>\n</nobr>\n<p>\n";
|
|
}
|
|
|
|
|
|
|