#!/usr/bin/perl -w { # statisticker_web_interface.pl WJS Jul 03 # $version = "statisticker_web_interface.pl version 1.3c 10 Jun 2012"; # 10 Jun 12. v 1.3c WJS # Bug fix: cannot depend on $! to tell if open succeeded. No # getting around explicitly processing the return from open. # [Begin 1.3c] # 4 Aug 08. v 1.3b WJS # Reformat some error messages. # [Begin 1.3b] # 25 Oct 07. v 1.3a WJS # Use check_build_opt_env_var from wjs_web*.pl # [Begin 1.3a] # 23 Aug 05. v 1.3 WJS # Recode to pass object spec as hidden form var. Makes things # more consistent w/matlab & netcdf stuff. Also, avoids the # PATH_INFO/QUERY_STRING issues that led to matlab & netcdf # using hidden variable # 19 Aug 05. v 1.3 WJS # Recode to use "alpha variable display" menu as subroutine # 6 Aug 05. v 1.3 WJS # Test for some "nothingness" a bit sooner than previously # Recode to use get_JGOFS_record, etc # [Begin 1.3] # 10 Dec 04. v 1.2e WJS # Change perl location # 18 Jun 04. v 1.2e WJS # Didn't like the 1.2d code. Changed it, but don't intend to # release this until more needs to be done # [Begin 1.2e] # 18 Jun 04. v 1.2d WJS # Bug fix: 1.2c fix done poorly. Try to do better # [Begin 1.2d] # 28 May 04. v 1.2c WJS # Bug fix: using build-opt-env.pl's DISPSS instead of SUBSELS. This # is a regression error of some kind - code was correct in 1.2 # [Begin 1.2c] # 6 Mar 04. v 1.2b WJS # New version mostly for housekeeping purposes # "use Errno" to define EPIPE and ESPIPE # [Begin 1.2b] # # 28 Feb 04. v 1.2a WJS # New list requires test for EPIPE # To get new list to log problems to web server log, need # -error switch (plus -nopipeerr switch to NOT log those errors) # Simplify a few "if defined x then if x" tests to "if x" - perl # can sometimes actually be helpful! # Bug fix: syntax error in forming read error message # Bug fix: build-opt-env does not always define all of its env vars # Check for the ones we need. # Bug fix: empty varname fix of 26 Feb uncovered a problem where # we assumed a hash existed (even if empty) # 27 Feb 04. v 1.2a WJS # build-opt-env.pl on synthesis:1988 (my test) defines env var OBJ. # On globec:80 (real OOserver) env var is OBJECT. Change to # latter, (& add OBJECT defn to :1988 build-opt-env.pl) # 26 Feb 04. v 1.2a WJS # Now it seems that close is returning 29. Assume that's normal... # Bug fix: get rid of "extra", empty varname (due to failure to chomp) # Not sure how long that's been an issue... # 25 Feb 04. v 1.2a WJS # Replace backtick operator w/ explicit open/read/close to pipe # It seems that using backtick sets $! to 29 on Solaris (2 versions) # and linux using Solaris perls 5.004 & 5.8, whereas Irix perl 5.6 OK # Now it seems that close is returning 29. Assume that's normal... # [Begin 1.2a-test release only. Every variant had something wrong...] # 8 Oct 03. v 1.2 WJS # Bug fix: split /[\t]+/ was not working as I thought it would. # Didn't figure out why, of course - just added -z to list (which # produces the string being split). Is this a butt-biter? Stay tuned... # 25 Sep 03. v 1.2 WJS # By default, select all stats except distinct # 24 Sep 03. v 1.2 WJS # Typo fix in comment # 11 Sep 03. v 1.2 WJS # Allow user to select alpha comparisons. Default offering to our # "usual" (try to numerically decode 1st val of each var) # [Begin 1.2] # 4 Sep 03. v 1.1a WJS # Using @ to set off stats-specific parameters seems to work better than # # [Begin 1.1a] # 29 Aug 03. v 1.1 WJS # Recode for statisticker v 3.1. # Put web interface version info onto web page as comment. # [Begin 1.1] # 25 Jul 03. v 1.0 WJS # [Needs build-opt-env.pl] # [Needs ctime.pl] # [Needs cgi-lib.pl] # [Begin 1.0] ### require ("cgi-lib.pl"); require ("ctime.pl"); require ("wjs_web_perl_utilities.pl"); # List separator character. Pick something that doesn't mean anything # to perl pattern matcher (as well as a char unlikely to appear in # our valid strings, too!) $sep = ","; # statisticker uses subset of characters illegal to outer to distinguish # its portion of QUERY_STRING from outers. See statisticker doc. # Code here should be able to use any one of these - select for minimal # interference w/other programs' special chars. Similar argument applies # to character used to separate list of vars that need to be compared # alphabetically $illegal_outer_char = "@"; $stat_DISTINCT_key = $illegal_outer_char . "DISTINCT" . $illegal_outer_char; $stat_ROWS_ARE_STATS_key = $illegal_outer_char . "ROWS_ARE_STATS" . $illegal_outer_char; $stat_alpha_comp_key = $illegal_outer_char . "alpha" . $illegal_outer_char; $alpha_comp_list_sep = "+"; # Variables we are going to get from form defined as their form variable # names (including hidden variables) $object_form_var_name = "object_spec"; $irreg = "irregular_data_treatment"; $orientation = "orientation"; $selected_statistics = "stats"; $form_action = "form_action"; $alpha_comp_list = "alpha_vars"; # Define values for how to treat irregular data. $skip_irregular = "skip_irregular"; $skip_missing = "skip_missing"; $include_all = "include_all"; # Define values for orientation $stats_are_rows = "stats_are_rows"; $stats_are_columns = "stats_are_columns"; # Define form action routine. $form_action_routine = $ENV{"SCRIPT_NAME"} ? $ENV{"SCRIPT_NAME"} : "/jg/stat_web_interface.pl"; # Associate variables w/values, along w/descriptive strings for form user # As coded, order does NOT determine order on form (no way to do so w/o # coding change). Permissible values for $selected_statistics come from # $get_statisticker_info $values{$irreg} = join $sep, ( "$skip_irregular,Skip all irregular data," . "$skip_missing,Skip missing but count other irregular data," . "$include_all,Include all data" ); $values{$orientation} = join $sep, ( "$stats_are_rows,Rows," . "$stats_are_columns,Columns" ); # List defaults. Default for $selected_statistics is each one. I # Suppose for completeness I should "do" that, but I didn't. $defaults{$irreg} = $skip_irregular; $defaults{$orientation} = $stats_are_columns; # Set up environment. Assume .pl routine is in our directory $build_opt_env = "./build-opt-env.pl"; &check_r_access($build_opt_env); require $build_opt_env; # Check that build-opt-env set up things as expected $topdir = &check_build_opt_env_var("OPTHOME",$build_opt_env); $bindir = "$topdir/bin"; ($stat_obj,$special_stat_name_list,$addend_list,$stat_name_list) = &get_statisticker_info ($sep); @statisticker_var_roots = split ($sep,$stat_name_list); ($stat_name_for_distinct_count, $stat_name_for_stat_column, $stat_name_for_variables_column) = split ($sep,$special_stat_name_list); &ReadParse(*form_info); # Main purpose of putting form action routine on form as a hidden # variable is to distinguish between use of this program in the # "put the form up" and "process the form results" modes. The # consistency check is just on general principles - anyone who de- # liberately mis-routes things here can change the hidden value as well. if ( $after_submit = (defined $form_info{$form_action}) ) { ($form_info{$form_action} eq $form_action_routine) || &quit ("Submit action routine should be same as form value" , "Action = $form_action_routine; " . "Form value = $form_info{$form_action}" ); } if ($after_submit) { &process_form; } else { &print_form; } exit; } sub print_form { &printheader(); print "\n"; #