📄 oracletool.pl
字号:
next; } if ($parameter eq "MENUIMAGE") { $menuimage = "$val"; $themevarcount++; next; } if ($parameter eq "BGIMAGE") { $bgimage = "$val"; $themevarcount++; next; } if ($parameter eq "FONTCOLOR") { $fontcolor = "$val"; $themevarcount++; next; } if ($parameter eq "HEADINGFONTCOLOR") { $headingfontcolor = "$val"; $themevarcount++; next; } if ($parameter eq "INFOCOLOR") { $infocolor = "$val"; $themevarcount++; next; } if ($parameter eq "LINKCOLOR") { $linkcolor = "$val"; $themevarcount++; next; } if ($parameter eq "FONT") { $font = "$val"; $themevarcount++; next; } if ($parameter eq "HEADINGFONT") { $headingfont = "$val"; $themevarcount++; next; } if ($parameter eq "FONTSIZE") { $fontsize = "$val"; $themevarcount++; next; } if ($parameter eq "HEADINGCOLOR") { $headingcolor = "$val"; $themevarcount++; next; } if ($parameter eq "CELLCOLOR") { $cellcolor = "$val"; $themevarcount++; next; } if ($parameter eq "BORDERCOLOR") { $bordercolor = "$val"; $themevarcount++; next unless ($themevarcount == 15); } if (($themevarcount) && ($themevarcount == 15)) { push @{ $themes{$theme} }, $description; push @{ $themes{$theme} }, $bgcolor; push @{ $themes{$theme} }, $menuimage; push @{ $themes{$theme} }, $bgimage; push @{ $themes{$theme} }, $fontcolor; push @{ $themes{$theme} }, $headingfontcolor; push @{ $themes{$theme} }, $infocolor; push @{ $themes{$theme} }, $linkcolor; push @{ $themes{$theme} }, $font; push @{ $themes{$theme} }, $headingfont; push @{ $themes{$theme} }, $fontsize; push @{ $themes{$theme} }, $headingcolor; push @{ $themes{$theme} }, $cellcolor; push @{ $themes{$theme} }, $bordercolor; undef $themevarcount; next; } # If a parameter does not match a "hard coded" parameter # above, assume it is an environmental variable. $ENV{$parameter} = $val; } close(CONFIG); if ((($debug) || ($logging)) && (! $logfile)) { undef $debug; undef $logging; } logit("Done reading config file.");# Check to be sure that a theme exists, in case it came# from a cookie. If someone creates a personal theme and# then installs a new version of the tool, their theme# may not exist anymore, but it will still be in the# OracletoolTheme cookie. Default, in this case. logit("MyTheme is set to $mytheme"); foreach $key(keys %themes) { if ($mytheme eq $key) { $theme = $mytheme; last; } else { $theme = "Default1"; } } logit("Theme is set to $theme"); foreach $key(keys %plugins) { logit("Plugin $key: Program $plugins{$key}"); }# Now set the variables for the selected theme. @themevars = @{ $themes{$theme} }; $description = $themevars[0]; $bgcolor = $themevars[1]; $menuimage = $themevars[2]; $bgimage = $themevars[3]; $fontcolor = $themevars[4]; $headingfontcolor = $themevars[5]; $infocolor = $themevars[6]; $linkcolor = $themevars[7]; $font = $themevars[8]; $headingfont = $themevars[9]; $fontsize = $themevars[10]; $headingcolor = $themevars[11]; $cellcolor = $themevars[12]; $bordercolor = $themevars[13];# Print environment to debug if enabled.# logit("Summary of ENV settings");# foreach $key(keys %ENV) {# logit("VAR: $key SETTING: $ENV{$key}");# }}sub createMainPage() { logit("Enter subroutine createMainPage");# This sub will be called if this script is invoked without a 'database=....'# element in the URL. # Get the connection strings from the tnsnames.ora file. my @sids = GetTNS();# Start creating main page my $bgline = "<BODY BGCOLOR=$bgcolor>\n"; if ($bgimage) { if ((-e "$ENV{'DOCUMENT_ROOT'}/$bgimage") && (-r "$ENV{'DOCUMENT_ROOT'}/$bgimage")) { logit("Background image is $ENV{'DOCUMENT_ROOT'}/$bgimage and is readable"); $bgline = "<BODY BACKGROUND=$bgimage>\n"; } }print << "EOF";Content-type: Text/html\n\n<HTML> <HEAD> <TITLE>Oracletool v$VERSION</TITLE> </HEAD> $bgline <CENTER> <H2> <FONT COLOR="$fontcolor" FACE="$font" SIZE="5"> Oracletool v$VERSION </FONT> </H2> </CENTER> <BR><BR> <TABLE BGCOLOR="BLACK" WIDTH="400" CELLPADDING="1" CELLSPACING="0" BORDER="0"> <TR> <TD VALIGN="TOP"> <TABLE BGCOLOR="$headingcolor" WIDTH="100%" CELLPADDING="2" CELLSPACING="1" BORDER="0"> <TR ALIGN="LEFT"> <TD> <TABLE> <TR> <TD ALIGN="LEFT"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'>EOFprint " <STRONG>Select an instance.</STRONG>\n" if (! $oraclenames);print " <STRONG>Select or enter an instance name.</STRONG>\n" if ($oraclenames);print <<"EOF"; <FORM METHOD="POST" ACTION="$scriptname"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <P> <SELECT NAME="database">EOFmy $sid;foreach $sid (@sids) { print " <OPTION VALUE=\"$sid\">$sid</OPTION>\n";}print <<"EOF"; </SELECT> </TD>EOF if ($oraclenames) { print <<"EOF"; </TR> <TR> <TD> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <INPUT TYPE="TEXT" NAME="namesdatabase" SIZE="20"> </TD>EOF } print <<"EOF"; </TR> <TR> <TD ALIGN="LEFT" VALIGN="TOP"> <FONT COLOR='$fontcolor' SIZE='$fontsize' FACE='$font'> <INPUT TYPE="HIDDEN" NAME="object_type" VALUE="FRAMEPAGE"> <INPUT TYPE="SUBMIT" VALUE="Connect"> <INPUT TYPE="CHECKBOX" NAME="expire" VALUE="Yep">Expire password cookie </P> </FORM> <P> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </TD> </TR> </TABLE> </BODY></HTML>EOF logit("Exit subroutine createMainPage");}sub dbConnect { logit("Enter subroutine dbConnect"); my $database = shift; my $username = shift; my $password = shift; loginfo(" Log - Host: $ENV{'REMOTE_HOST'} IP: $ENV{'REMOTE_ADDR'} DB: $database Command: $object_type Theme: $theme") if $logging;# Attempt to make connection to the database.. my $data_source = "dbi:Oracle:$database"; logit(" Datasource: $data_source"); logit(" ORACLE_HOME $ENV{'ORACLE_HOME'}"); logit(" TNS_ADMIN $ENV{'TNS_ADMIN'}"); logit(" Connecting..."); my $dbh = DBI->connect($data_source,$username,$password,{PrintError=>0});# If it fails, act on a couple of different Oracle errors.# Bring up the password screen for either of these errors.# ORA-01017 - "Invalid username/password; logon denied." # ORA-01004 - "Default username feature not supported; logon denied."# ORA-01005 - "null password given; logon denied."# Show an error message for these errors.# ORA-12224 - "The connection request could not be completed because the listener is not running."# ORA-01034 - "Oracle was not started up."# ORA-01090 - "Shutdown in progress - connection is not permitted""# ORA-12154 - "The service name specified is not defined correctly in the TNSNAMES.ORA file."# ORA-12505 - "TNS:listener could not resolve SID given in connect descriptor."# ORA-12545 - "TNS:name lookup failure." unless ($dbh) { logit(" Failed login with username \"$username\". $ENV{'REMOTE_HOST'} IP: $ENV{'REMOTE_ADDR'}"); loginfo(" Failed login with username \"$username\". $ENV{'REMOTE_HOST'} IP: $ENV{'REMOTE_ADDR'}"); if ( $DBI::errstr =~ /ORA-01017|ORA-01004|ORA-01005/ ) { EnterPasswd($database); exit; } if ( $DBI::errstr =~ /ORA-12224/ ) { ErrorPage ("You received an ORA-12224, which usually means the listener is down, or your connection definition in your tnsnames.ora file is incorrect. Check both of these things and try again."); exit; } if ( $DBI::errstr =~ /ORA-01034/ ) { ErrorPage ("You received an ORA-01034, which usually means the database is down. Check to be sure the database is up and try again."); exit; } if ( $DBI::errstr =~ /ORA-01090/ ) { ErrorPage ("You received an ORA-01090, which means the database is in the process of coming down."); exit; } if ( $DBI::errstr =~ /ORA-12154/ ) { ErrorPage ("You received an ORA-12154, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose."); exit; } if ( $DBI::errstr =~ /ORA-12505/ ) { ErrorPage ("You received an ORA-12505, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose, or the database you are trying to connect to is not defined to the listener that is running on that node."); exit; } if ( $DBI::errstr =~ /ORA-12545/ ) { ErrorPage ("You received an ORA-12545, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose. (Possibly the node name)."); exit; } ErrorPage ("Unable to connect to Oracle ($DBI::errstr)\n"); exit; } logit(" Got successful connection"); logit("Exit subroutine dbConnect"); return ($dbh);}sub setTheme { logit("Enter subroutine setTheme"); my ($message,$duration,$url,$cookie,$path,$bgline); $theme = $object_name; $path = dirname($scriptname); $cookie = cookie(-name=>"OracletoolTheme",-value=>"$theme",-expires=>"+10y",-path=>"$path"); print header(-cookie=>[$cookie]); $message = "Your personal theme has been set to $theme.<BR>Oracletool will restart with a connection to instance $database."; $duration = "4"; $url = "$scriptname?database=$database&object_type=FRAMEPAGE"; $bgline = "<BODY BGCOLOR=$bgcolor>\n"; if ($bgimage) { if ((-e "$ENV{'DOCUMENT_ROOT'}/$bgimage") && (-r "$ENV{'DOCUMENT_ROOT'}/$bgimage")) { logit(" Background image is $ENV{'DOCUMENT_ROOT'}/$bgimage and is readable"); $bgline = "<BODY BACKGROUND=$bgimage>\n"; } } print <<"EOF";<HTML> <HEAD> <TITLE>Theme is set to $theme.</TITLE> <META HTTP-EQUIV="Refresh" Content="$duration;URL=$url"> </HEAD> $bgline <FONT FACE="$font" SIZE="$fontsize" COLOR="$fontcolor"> <CENTER> $message </CENTER </BODY</HTML>EOF logit("Exit subroutine setTheme"); exit;}sub doProperties { logit("Enter subroutine doProperties"); my $properties = cookie("OracletoolProps"); if ($properties) { ($schema_cols,$fontsize,$menufontsize,$textarea_w,$textarea_h,$rowdisplay) = split (/%/, $properties); } else { # Set the variables that are not taken care of by a theme. $menufontsize = "2"; $schema_cols = "5"; $textarea_w = "40"; $textarea_h = "20"; $rowdisplay = "25"; } logit("Exit subroutine doProperties");}sub setProperties { logit("Enter subroutine setProperties"); my ($cookie,$properties,$message,$duration,$url,$path,$bgline); # Compare the selected properties with the ones set in this users # default theme, where applicable. If they are different, then # update a properties cookie. These parameters were passed in by # names that make no sense, in order to cut down on global variables. # $schema holds the value for $schema_cols. # $schema_cols is the number of columns wide to display the toplevel # schema list. $schema_cols = $schema; # $explainschema holds the value for $fontsize. # If not set, use value from theme. $fontsize = $explainschema; # $expire holds the value for $menufontsize.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -