' : Eval line Warning: to access the main script variables, they must be defined as "global" in the included file or in the first of eval commands (reason: script uses a function to process the text, and PHP has global variables defaultly inacessible inside the function bodies) Change of backward compatibility: Scripts which were using external_table function (SYS directory) must call it externaly - the function was exluded from the script! (it is reasonable). There is necessary: 1. to define using the function in index.dat (add [side_text] section with line "!externaltable.php") 2. to make this script accessible from current directory (e.g. by link to ~/monitor/www/externaltable.php) * * * STRONGLY CONFIGURABLE : - number, variables and values in the select fields - composition of the values from the select fields to the regular expression mask - appearance settings - links up/prev/next, position of menu, buttons presence, etc. * BEHAVIOUR MUST BE DEFINED IN FILE 'index.dat', without this file, the script cannot work. * The format of the configuraton file is described in the following example: # # PHP image browser configuration file # Lines begining with '#' are comments # [appearance] stylefile:page.css form_position:down # can be up / down / left / right columns:3 Selections:1 Regular:0 Selfiles:1 # List_sel:1 View_sel:1 List_reg:1 View_reg:1 # [appearance_dynamic] header_label:Computer state plots page_comment:Selection : |$plottype_comment| in |$computer_comment| computer(s), last |$timespan_comment|. prev_pg:0 next_pg:0 up:../moni_overview.php?timespan=|$timespan| mask_definition:$plottype|_|$computer|_.*|$timespan # NOT IMPLEMENTED: label_definition:$plottype| on computer |$computer|, last |$timespan|. # [header_text]

This text would be printed above the dynamic page content.

[footer_text]

This text would be printed under the dynamic page content.

[side_text] # FOLLOWING COMMAND REPLACES FUNCITON external_table used till now in the script!!! !externaltable.php

This text would be printed on the side (only if position is left/right)

# Access to script variables using eval: >global $computer; echo "Computer:'$computer'" [extensions] jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF # [select_values] !computer_array:computer:Computer:pecny.asu.cas.cz! all=.* Pecny=pecny.asu.cas.cz Pecny0=pecny0.asu.cas.cz Pecny1=pecny1.asu.cas.cz Pecny2=pecny2.asu.cas.cz GOP=gop.asu.cas.cz GOP1=gop1.asu.cas.cz GOP2=gop2.asu.cas.cz GOPA=gopa.asu.cas.cz GOPB=gopb.asu.cas.cz Athena=athena.fsv.cvut.cz !time_array:timespan:Time span:.*! all=.* day=day week=week month=month year=year !type_array:plottype:Plot type! all=.* Cpu load + users #=Cpuload Memory load=Memload Disks=Drives Traffic=Traffic Processes=Process # # FILE FORMAT REMARKS: # 1. In an appearance section, all variables mentioned shall be filled # # 2. In dynamic variables can be added link to values unknown in the # configuration file, but supposed to be known as a variables in the script. # The format is # text....text|$variable_name|text...text # - zero value disables link. # - in this section, all variables are obligatory. # - There are important variables: # a) header_label : Header of the page # b) mask_definition : Here is defined, how the mask for file selection is composed # from select variables. Segments are divided by '|' # The result is used as regular expression, so '.' means any char, '*' repeating, etc. # $plottype|_|$computer|_.*|$timespan => Memload_Pecny.asu.cas.cz_.*day # # 3. Extensions section lists allowed file extensions divided by '|' # # 4. last section defines SELECT fields. # - If the parameter is not set in calling, the value is set to the defined default, if no default is defined, then to the first. # - Fields are ordered by order shown in form that can differ from mask order. # - Values in one field description are separated by ':' char # 1. Name of array with possible settings stored # 2. Name of variable that sets the value in calling from url parameters # 3. Array description to label SELECT # 4. Default value of parameter (IN PROGRESS!) # - Values of select options are dividet bu '=' character, the fist is the label, # the second is the variable value that is used in composing of view mask. # # 5. Sections "header_text", "side_text" and "footer_text": # Text is ouptutted direclty to the desired position in the script (begining, under menu and in the end) # Lines begining with '!' provides including the filename on the line (e.g. !header.php or !http://neco.nekde/x.html) # Lines begining with '>" are proceeded by function eval. # Warning: To access variables of the main script, name them as global first in the included file or eval command! * */ // OBEJITI register_globals = Off while (list($index,$hodnota) = Each($_COOKIE)){ $$index = $_COOKIE[$index]; # echo " COOKIE > ".$index." = ".$HTTP_COOKIE_VARS[$index]."
"; } while (list($index,$hodnota) = Each($_GET)){ $$index = $_GET[$index]; # echo " GET > ".$index." = ".$HTTP_GET_VARS[$index]."
"; } while (list($index,$hodnota) = Each($_POST)){ $$index = $_POST[$index]; # echo " POST > ".$index." = ".$HTTP_POST_VARS[$index]."
"; } #while (list($index,$hodnota) = Each($HTTP_COOKIE_VARS)){ # $$index = $HTTP_COOKIE_VARS[$index]; # // echo " COOKIE > ".$$index." = ".$HTTP_COOKIE_VARS[$index]."
"; #} #while (list($index,$hodnota) = Each($HTTP_GET_VARS)){ # $$index = $HTTP_GET_VARS[$index]; # // echo " GET > ".$$index." = ".$HTTP_GET_VARS[$index]."
"; #} #while (list($index,$hodnota) = Each($HTTP_POST_VARS)){ # $$index = $HTTP_POST_VARS[$index]; # // echo " POST > ".$$index." = ".$HTTP_POST_VARS[$index]."
"; #} function IsInArray($value,$array){ $result=0; for($i=0;$i"; if ($line[0]=='[') { $section=SubStr(Chop($line),1,-1); $line=ReadWithoutComment($datfile,'#',511); //echo $section."
"; continue; } switch ($section) { case "header_text": case "footer_text": case "side_text": $$section .= chop($line). "\n"; break; case "appearance": List($variable,$value) = Explode (":",Chop($line),2); ${$variable}=$value; //echo "$variable : ${$variable}
"; break; case "appearance_dynamic": List($variable,$value) = Explode (":",Chop($line),2); ${$variable}=$value; $dynamic_variables[]=$variable; //echo "dynamic $variable : ${$variable}
"; break; case "default_start": List($variable,$value) = Explode (":",Chop($line),2); if (!defined(${$variable})){ ${$variable}=$value; } case "fields": break; case "extensions": $extension_line=Chop($line); break; case "select_values": if ($line[0]=='!') { //$field_name=SubStr(Chop($line),1,-1); List($field_name,$varname,$description,$defaultvalue) = Explode (":",SubStr(Chop($line),1,-1),4); $fields_i++; $fields[$field_name]=$varname; $descriptions[$field_name]=$description; $defaults[$field_name]=$defaultvalue; $line=ReadWithoutComment($datfile,'#',511); //echo $field_name."
"; } // if List($label,$value) = Explode ("=",Chop($line),2); $fields_content[$field_name][$label]=$value; $fields_labels[$field_name][$value]=$label; //echo "fields_content[$field_name][$label] : ".$value."
"; //echo "fields_labels[$field_name][$value] : ".$label."
"; break; } $line=ReadWithoutComment($datfile,'#',511); } FClose($datfile); if(($submit=="View_all") || ($submit== "View_sel.") || ($submit == "View_reg.") ){ $view="all"; UnSet($selfiles); } if($submit=="View_none"){ $view="none"; UnSet($selfiles); } if((($submit=="List_reg.") || ($submit== "List_sel."))||($submit=="View_selected")){ $view=""; } // Default values in case of problems with configuration file #if ($form_position != "down") { $form_position = "up"; } if (! $stylefile ) { $stylefile = ""; } if (! $columns ) { $columns = 2; } if ($Selections !=0 ) { $Selections = 1; } if ($Regular !=0 ) { $Regular = 1; } if ($Selfiles !=0 ) { $Selfiles = 1; } if (! $header_label ) { $header_label = "File list"; } if (! $title ) { $title = "Dynamic file list"; } if (($form_position == "left") || ($form_position == "right")) { $form_shape="vertical"; $columns=1; } else { $form_shape="horizontal"; } // Setting of variables: // a) Default values of field values ($computer, $timespan, etc.) // b) If exists in array, variables [field_varieble]_comment are created (e.g. $computer_comment) reset ($fields); while (list ($field, $varname) = each ($fields)) { //echo "$field, $varname, ${$varname}, ".$fields_labels[$field][${$varname}]."
\n"; // if neni promenna definovana if( !$fields_labels[$field][${$varname}] ) { if ($defaults[$field]){ ${$varname} = $defaults[$field]; } else { reset ($fields_content[$field]); ${$varname} = current ($fields_content[$field]); } } //echo "$varname = ${$varname}
"; $commentvarname = "${varname}_comment"; ${$commentvarname} = $fields_labels[$field][${$varname}]; //echo "$commentvarname = ${$commentvarname}
"; } // Actions dependent on button changing list from selects: if((($submit == "List_sel.") || ($submit=="View_sel.")) || !$mask){ // Definition of actual mask from selects // former command : $mask = "${plottype}_${computer}_.*${timespan}"; $mask_array = Explode ("|",$mask_definition); //echo "$mask_definition = "; $mask = ""; for ($i=0; $i"; } //echo "mask set to = $mask
\n"; } // Creating dynamic variables : Links, etc.: //$variables = Array("up", "next_pg", "prev_pg"); for ($j=0; $j"; } else $variable_transformed_value .= $variable_array[$i]; } ${$variable} = $variable_transformed_value; //echo "'$variable' set to $variable_transformed_value
\n"; } // Links table and header ?> <? echo $title; ?> \n"; } ?> "; ?>

"; global $imgends; for ($i=0;$i\n"); if (Ereg("($tst)$",$filename)) return true; } return false; } function Listfiles($selfiles){ for($i=0;$i./$selfiles[$i]/   \n"); } elseif (is_image($selfiles[$i])){ echo("


$selfiles[$i]

\n"); } else { echo("

\n"); } } } function Headers($prev_pg, $up, $next_pg, $header_label, $page_comment){ ?> prev"; } if ($up!="0") { echo ""; } if ($next_pg!="0") { echo ""; } ?>
upnext
'.$header_label.""; } if ($page_comment!="0") { echo '

'.$page_comment."

"; } } // headers // Processing of texts in header, footer and side. // Planned performance: Processing of PHP code, including external files function process($text){ $textarr=Explode("\n",$text); for ($i=0; $i"; include($filename); break; case '>': # EVAL $cmd = substr($textarr[$i],1); # echo "$cmd"; eval($cmd); break; default: echo $textarr[$i]; } } # echo $text; } // Browse through files $DIR = OpenDir("."); while ( $filename = ReadDir($DIR)) { #if (Is_File($filename)){ if(Ereg("($extension_line)$",$filename)) // allowed files only if(Ereg("$mask",$filename)) // user mask $filenames[]=$filename; #} } CloseDir($DIR); if($filenames){ Sort($filenames); } // selected files definition for($i=0;$i\n"; Listfiles($selfiles); echo ""; } elseif( $form_position == "down"){ Headers($prev_pg, $up, $next_pg, $header_label, $page_comment); process($header_text); echo "\n
\n"; Listfiles($selfiles); echo "
"; } elseif( $form_position == "left") { Headers($prev_pg, $up, $next_pg, $header_label, $page_comment); process($header_text); echo "
\n"; } else { # up Headers($prev_pg, $up, $next_pg, $header_label, $page_comment); process($header_text); echo "
\n"; } ?>
\n"; }?> '.$descriptions[$field_name].' : '; echo '\n"; if ($form_shape == "vertical" ){ echo "\n"; } next($fields_content); next($fields_labels); } if ($List_sel && $Selfiles) { echo ''; } else { echo "";} if ($View_sel) { echo ''; } else { echo "";} ?> \n"; } } # Selections if($Regular == "1"){ ?> >Regexp mask  \n"; } ?> \n"; } if ($List_reg && $Selfiles) { echo ''; } else { echo "";} if ($View_reg) { echo ''; } else { echo "";} ?> \n"; } } # Regular ?>
View selection
       

">
       

\n"; } if($Selfiles == "1"){ ?>
\n"; }?> \n"; }?>
\n"); if(($i % $columns) == $columns - 1) { echo("\n"); $rows++; } } ?>
$filenames[$i] 
10) {?>
\n"; }?> \n"; }?>
10 echo "
"; } # selfiles ?>

$selfiles[$i]

\n"); } }*/ # form positioning 2 if( $form_position == "left"){ //external_table($timespan, $calltimespan, $computer, "center"); //echo "
\n"; process($side_text); echo "
\n"; #Headers($prev_pg, $up, $next_pg, $header_label, $page_comment); Listfiles($selfiles); echo "
\n"; } elseif( $form_position == "right"){ //external_table($timespan, $calltimespan, $computer, "center"); //echo "
\n"; process($side_text); echo "
\n"; } elseif( $form_position == "down"){ //external_table($timespan, $calltimespan, $computer, "center"); process($side_text); /* echo "
\n"; */ echo "
\n"; } else { # up echo "\n"; Listfiles($selfiles); /* echo "
\n"; */ //external_table($timespan, $calltimespan, $computer, "center"); process($side_text); /* echo "
\n"; */ echo "\n"; } process($footer_text); ?>