Files
resatennis_tyroltenn/www/cgi-bin/Demos/DEMO_init.pl.orig

183 lines
6.7 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_init.pl
#
# Routines to initialize the demos interface
1; # Return true;
sub Initialize_Interface {
if (&Legal_User) {
$ENV{'DISPLAY'} = "$APP_DISPLAY"; # Set the display
$ENV{'DISPLAY'} = $in{'XDP'} if ($in{'XDP'});
&Read_Tables;
} else {
&Print_Illegal_User_Warning; # Exit
}
}
sub Read_Tables {
@demo_list = &Generate_Demos_Array;
@hardware_categories = &Generate_Hardware_Array;
@features_categories = &Generate_Features_Array;
@markets_categories = &Generate_Markets_Array;
}
sub Legal_User {
# Get the name of host machine and ip address of this machine
$host_name = `/usr/bsd/hostname -s`;
chop($host_name);
($NotUsedName, $NotUsedAliases, $NotUsedAddrtype, $NotUsedLength, @Addrs) = gethostbyname($host_name);
($ip1,$ip2,$ip3,$ip4) = unpack('C4',@Addrs[0]);
$ipAddress = "$ip1.$ip2.$ip3.$ip4";
# Check to see if the server name is the same
return(( "$ENV{'REMOTE_ADDR'}" eq "$WWW_SERVER_IP" || "$ENV{'REMOTE_ADDR'}" eq "$ipAddress" ));
}
sub Print_DisplayAndLink_Script {
print <<_KAWASAKI_KX250_;
<script language="JavaScript1.1">
// null functions for Netscape 3.0 browsers so JavaScript error
// will not appear
function storeDisplayValue(dispVar) { return }
function setDoc(aDoc) { return }
</script>
<script language="JavaScript1.2">
//
// All rights reserved by Silicon Graphics Computer Systems
// David J. Anderson (sprout\@whip.mti.sgi.com)
// Eric DeBolle (debolle\@engr.sgi.com)
//
// keep the dv value here so the Main page can go on and load other content
dv = null;
nullctr = 0;
mlctr = 0;
pageDoc = null;
function storeDisplayValue(dispVar) {
dv = dispVar;
}
function reInitDisplay() {
nullctr++;
if (nullctr == 4) { dv = ":0.0"; return } // give up and use default
self.Main.initDisplay("reInit");
}
function setDoc(aDoc) {
pageDoc = aDoc;
modifyLinks();
}
function modifyLinks() {
//
// putting this function in the frameset so it can be run by either
// the BottomSide or the index pages.
mlctr++;
if ( dv == null ) { setTimeout("modifyLinks()", 3000); reInitDisplay(); return }
if ( dv == ":0.0" ) { return; }
for (i=0; i<pageDoc.links.length; i++) {
linkStr = pageDoc.links[i].href.toString(); // get the href in string form
// since this script is for Netscape 4.0 (JavaScript 1.2) I can use the
// regular expression functionality, yahoo
//
// First see if the link is one that will start a demo:
// 'ExecuteDemo' strings are found in links in left hand frame and
// on the 'Start Demo Button' on the info page
// 'DEMO_execute' strings are the old style links which are still used
// in some links on demo info pages.
if ( /ExecuteDemo/.test(linkStr) ) {
if ( /javascript:safeGo/.test(linkStr) ) { // left hand frame links
re = /'\\)\$/;
pageDoc.links[i].search = pageDoc.links[i].search.replace(re, "&XDP="+escape(dv)+"')");
}
else if ( /http:\\/\\/localhost/.test(linkStr) ) { // Start Demo Button links
pageDoc.links[i].search = pageDoc.links[i].search + "&XDP=" + escape(dv);
}
}
else if ( /DEMO_execute/.test(linkStr) ) {
if ( /http:\\/\\/localhost/.test(linkStr) ) { // old style links
pageDoc.links[i].search = pageDoc.links[i].search + "&XDP=" + escape(dv);
}
}
}
} // end modifyLinks()
_KAWASAKI_KX250_
}
sub Print_UI_Frame_Structure {
&Print_Error("$ERROR_INFO","Starting Interface","$STATUS_MINOR");
&Print_HTTP_Header("$TITLE_STRING", "$HTTP_YES_SCRIPT");
$defaultList = &Get_Default_List;
# print "<script language=\"JavaScript\">\n";
&Print_DisplayAndLink_Script;
print "</script>\n";
print "</head>\n";
print "<frameset frameborder=$FRAME_COL_BORDER framespacing=0 border=0 cols=$FRAME_SIDE_WIDTH,*>\n";
print "\t<frame src=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_SIDE\" marginwidth=0 name=$FRAME_SIDE>\n";
print "\t<frameset frameborder=$FRAME_ROW_BORDER framespacing=0 border=0 rows=*,$FRAME_TOC_HEIGHT,0>\n";
print "\t\t<frame src=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_MAIN\" name=$FRAME_MAIN NORESIZE>\n";
print "\t\t<frame src=\"$WWW_SCRIPT?$CGI_SWITCH=$FRAME_TOC\" marginheight=0 marginwidth=0 name=$FRAME_TOC NORESIZE>\n";
print "\t\t<frame src=\"javascript:void(0)\" marginwidth=0 marginheight=0 name=$FRAME_DIAG NORESIZE>\n";
print "\t</frameset>\n";
print "</frameset>\n";
print "</html>\n";
&Print_HTTP_Footer;
}
sub Print_Illegal_User_Warning {
&Print_HTTP_Header("Sorry! Foreign Host Access Not Allowed", $HTTP_YES_SCRIPT);
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "function IllegalMessage()\n";
print "\t{\n";
print "\tif (!confirm(\"The demos at this site are accessible only from the localhost.\"))\n";
print "\thistory.go(-2)\n";
print "\thistory.go(-2)\n";
print "\t}\n";
print "document.writeln(IllegalMessage())\n";
print "</SCRIPT>\n";
print "</head>\n";
print "<body bgcolor=white>\n";
&Print_HTTP_Footer;
exit 0;
}