X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 46A46D1B53E for ; Sat, 20 Sep 2003 17:32:45 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 41650-05 for ; Sat, 20 Sep 2003 14:32:34 -0300 (ADT) Received: from Ariel2.idahopower.com (ariel2.idahopower.com [204.76.190.198]) by svr1.postgresql.org (Postfix) with SMTP id BE7DED1B528 for ; Sat, 20 Sep 2003 14:32:32 -0300 (ADT) Received: from 204.76.195.33 by Ariel2.idahopower.com with ESMTP (IPCo Mail Relay at your service (MMS v4.7);); Sat, 20 Sep 2003 11:31:55 -0600 X-Server-Uuid: c4da1ae6-7048-11d2-bc8e-00a083360239 Received: from bedford.idacorp.local ([172.18.201.66]) by midway.idacorp.local with Microsoft SMTPSVC(5.0.2195.6713); Sat, 20 Sep 2003 11:32:24 -0600 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message MIME-Version: 1.0 Subject: Trouble with HTTP authentication and PostgreSQL validation Date: Sat, 20 Sep 2003 11:32:24 -0600 Message-ID: <71B8A8BEC516CF46835CA629156CF21163F5AB@bedford.idacorp.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Trouble with HTTP authentication and PostgreSQL validation Thread-Index: AcN/nSamvLvUs41gTf2kbe/zT76fdg== From: "Seader, Cameron" To: pgsql-php@postgresql.org X-OriginalArrivalTime: 20 Sep 2003 17:32:24.0139 (UTC) FILETIME=[273CB9B0:01C37F9D] X-WSS-ID: 13725081450553-01-01 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/69 X-Sequence-Number: 2346 hi, I am having trouble with the below attached script and getting it to valida= te the $SERIALNUMBER session variable received from a device. I have a data= base with a table that has the serialnumber information now i need to valid= ate it with the session variable received so that i can continue and not ge= t an HTTP 401 error every time. can someone please help me out. Thanks much appreciated. Here is the Script: 15) // 15 is kinda arbitrary, use enoug= h space for date, err and alarms. 15 characters should be fine. { // You must check for bad chars here, such as semicolon, d= epending on your flavor of SQL.=20=20 // All data in the log file should be numeric, and may includ= e symbols: minus, comma, space, or 'NULL' if the data point was not availab= le. // at some point in the future, Obvius will replace the word = "NULL" with a blank column in the log data to save space. // not checking for characters like semicolon poses a securit= y risk to your SQL database // as someone could insert a line "3,4,5,7');drop table passw= ord;('3,4,5" into the log file. (this would be very bad)=20=20=20=20=20=20= =20=20=20=20=20=20=09=20 // replace "sometable" with the name of the table you wish= to insert the data into. =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 $tmpArray =3D split(",", $szBuffer); // start = check for bad chars here, like semicolon. first split a single log entry in= to components. $nCol =3D 0; $query =3D "INSERT INTO tbl_acquidata VALUES ("; // query = prefix. finished query string is: insert into table values ('1','2','3') foreach ($tmpArray as $value) // loop through each ar= ray element by calling it "value", (one per data column,)=20 { $value =3D str_replace("\"", "", $value); // strip double quotes= =20 $value =3D str_replace("'", "", $value); // strip single quotes=09= =09=20 $value =3D str_replace(";", "", $value); // strip semicolon. (not ne= eded if you use the following MySQL command) $value =3D trim($value); // trim whitespace, tabs, e= tc, on the ENDS of the string.=20=20 //$value =3D addslashes($value); // MySQL has a special strip fu= nction just for this purpose, other SQL versions may vary. switch($nCol) { case 0: $query =3D $query . sprintf("'%s'", $value); break; // qu= ote data (utc date), first column has no leading comma case 2:=20 case 3: $query =3D $query . sprintf(",%s", $value); break; // do= n't quote hex (alarm) data, column needs leading comma seperator. default:=20 { if ($value =3D=3D "NULL") $query =3D $query . ",NULL" ; // = don't quote the word 'NULL' else $query =3D $query . sprintf(",'%s'",$value); // quote dat= a, all other columns need leading comma seperator. } } $nCol++; } $query =3D $query . ")"; // close last paren around VALUES section. // finished building sql query string. =20=20=20=20=09=09=09=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 // ***** for purposes of this example, we are just going t= o display the SQL statement back to the caller. ****=20 printf("SQL: %s \n", $query); =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 // again, this query doesn't actually execute in the sampl= e. Replace with a query apporpriate for your flavor of SQL // $result =3D sql_query($query, $SQL)=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20 $result=3D1; // force success code here, REMOVE THIS LINE. if (! $result ) { // check error message from SQL query, ignore duplicat= e warnings.=09 // $strErrorMessage =3D sql_error($SQL); if (stristr($strErrorMessage, "duplicate entry") !=3D= FALSE) { $nDuplicateCount +=3D1;=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=09=20 } else { $nRejectCount +=3D1; } printf( "WARNING: line rejected, %s: DATA: %s\n", $strEr= rorMessage, $szBuffer); } else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 { $nSuccessCount +=3D 1; } } else { printf( "WARNING: short line rejected. DATA: %s\n", $szBuf= fer); $nRejectCount +=3D1; } } gzclose($fd); // PHP automatically removes temp files when the script exits. } }=20=20 =20=20 // now that the data is in the database, check the most current data poin= t, and calculate the alarm status. // query for last record in the database, get device status,=20 =20=20 =20=20 echo "REPORT: Uploaded data file contained $nSuccessCount vaild records, = $nDuplicateCount duplicate records, and $nRejectCount rejected records.\n"; // Finally, send the result code back to the AcquiSuite. Success cause th= e log file to be purged. =20=20 // $nRejectCount =3D 1; // for this sample script, the nRejectCount is= set to 1 to prevent the AcquiSuite from flushing the log file. YOU SHOULD= REMOVE THIS LINE. if ($nRejectCount !=3D 0) { ReportFailure( "An error occurred while importing data from the data fi= le.\n", $REMOTE_ADDR, $SERIALNUMBER, $MODBUSIP, $MODBUSPORT, $MODBUSDEVICE); } else { echo "SUCCESS\n";=20=20=09=20 } // ProcessLogFileUpload /* ------------------------------------------------------------------------= -----------------------*/ /* This function sends a list of all current configuration files on the ser= ver.=20 The format is as follows: =09 CONFIGFILE,loggerconfig.ini,md5checksum,timestamp CONFIGFILE,modbus/mb001.ini,md5checksum,timestamp CONFIGFILE,modbus/mb007.ini,md5checksum,timestamp =09=09=09=09 the timestamp is in UTC time, SQL format, ie "YYYY-MM-DD HH:MM:SS" (use = blank if not present/first-time) The md5checksum is the md5 checksum of the config file. (use blank if no= t present/first-time) =09=20=20 Checksums and timestamps are stored in a database, file data can be stor= ed in the same table as a blob record. When a config file is received from the AcquiSuite, the server should ve= rify the checksum, save the config file and also save the timestamp and checksum for the file for future referen= ce.=20=20 =09=20=20 The AcquiSuite will process this response, and only exchange files liste= d in the manifest response. =09=20=20 If the config file checksum sent in the response does not match the Acqu= iSuite config file checksum, the=20=09=20=20 AcquiSuite will process the exchange. If "remote configuration" is enab= led, the AcquiSuite will check the=20 timestamp to find if the server version of the config file is newer than= the AcquiSuite version .if so the=20 AcquiSuite will request to download the configuration file from the serv= er.=20 =09=20=20 If the checksum values do not match and the AcquiSuite file timestamp is= newer, or if the server timestamp is blank,=20 or if the "remote configuration" option is not enabled, the AcquiSuite w= ill send the configuration file to=20 the server. */ function SendConfigFileManifest($REMOTE_ADDR, $SERIALNUMBER, $MODBUSIP, $MO= DBUSPORT) {=09 // printf("CONFIGFILE,loggerconfig.ini,%s,%s\n", $szConfigurationChecksum,= $szConfigurationChangeTime);=20 =09 // for each modbus device on this acquisuite, process the following line: // printf("CONFIGFILE,modbus/mb-%03d.ini,%s,%s\n", $nModbusAddress, $szCon= figurationChecksum, $szConfigurationChangeTime);=20 } /* ------------------------------------------------------------------------= -----------------------*/ /* This function sends a specific configuration file to the acquisuite.=20 The script should finish the header, and then send the config file as th= e body to the http response. No other content should be included in the response body. =09 The variables $SERIALNUMBER, $MODBUSIP, $MODBUSPORT and $MODBUSDEVICE= are used to identify the config file.=09 THe variable $MODBUSDEVICECLASS is used to verify the device the conf= iguration file is for is the same as the hardware detected on the AcquiSuite.=09=09 Special case: when MODBUSDEVICE and MODBUSDEVICECLASS are both 0, ret= urn the loggerconfig.ini file. =20=20=20=20=20=20 The AcquiSuite will confirm the md5 checksum from the manifest with t= he checksum of the downloaded file for verification. */ function SendConfigFile($REMOTE_ADDR, $SERIALNUMBER, $MODBUSIP, $MODBUSPORT= , $MODBUSDEVICE, $MODBUSDEVICECLASS) { } /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* BEGIN MAIN SCRIPT HERE ! =09=09 First check user authenticity. The AcuqiSuite uses basic http authentica= tion, the PHP scripting language=20 extracts the user/password and provides them in the variables PHP_AUTH_US= ER and PHP_AUTH_PW. Different=20 scripting languages may have different methods of providing username/pass= word paris for basic http authentication. */ if ($SENDDATATRACE =3D=3D "YES") printf("
\n");// make the output mor=
e readable
=20=20
  if(!isset($_SERVER['$PHP_AUTH_USER']))
  {   ReportAuthorizationFailure("A system serial number must be supplied t=
o upload data\n", $REMOTE_ADDR, $PHP_AUTH_USER);
      exit;
      // if your server terminates here, please read PHP Authentication com=
ments above.
  }
=20=20
  if(!isset($_SERVER['$PHP_AUTH_PW']))
  {   ReportAuthorizationFailure("A system serial number and password must =
be supplied to upload data\n", $REMOTE_ADDR, $PHP_AUTH_USER);
      exit;
      // if your server terminates here, please read PHP Authentication com=
ments above.
  }
=20=20=20=20=20
  if ($SERIALNUMBER !=3D $_SERVER['$PHP_AUTH_USER'])
  {   ReportAuthorizationFailure("SerialNumber and http authentication user=
name do not match.", $REMOTE_ADDR, $PHP_AUTH_USER);
      exit;
  }
=20=20
  // check the AcquiSuite list here, make sure the serial number provided b=
y the acquisuite is
  // one that we know about, and have tables in the database for.

  //-------------------------
  // Postgres Connection
  //-------------------------
=20
   $conn =3D pg_connect("host=3D172.18.204.64 dbname=3Dacquisuite port=3D54=
32 user=3Dpgadmin password=3Dpgadmin");
   //Db connection Problem
   if (!$conn) {
      echo "Database connection error.\n";
	  exit;
	}
	// SQL Order
	$query_parent=3D"SELECT tbl_authenticate.serial_num FROM tbl_authenticate";
	$result =3D pg_exec($conn,$query_parent);
	if (!$result) {
	  echo "SQL order problem.\n";
	  exit;
	}
=09
	// End of SQL statement
	// pg_freeresult($result);
	// pg_close($conn);
	}
=09
	/*if (!isset($_SERVER['$PHP_AUTH_USER'])) {
	  authenticate();
	 }
	 else {
	  connect($_SERVER['$PHP_AUTH_USER'],$_SERVER['$PHP_AUTH_PW']);
	 }*/
=09=20=09=20=20=20=20=20=20=20
  // CHECK PASSWORD HERE. replace "password" with a stored password value f=
or the spcific acquisuite
  // or use an SQL query to verify the password.
=20=20
  if ($_SERVER['$PHP_AUTH_PW'] !=3D "pass" )
  {   ReportAuthorizationFailure("The authentication serial number password=
 do not match.", $REMOTE_ADDR, $PHP_AUTH_USER);
  	printf("Hint: this sample script uses 'password' as the passowrd");
      exit;
  }
=20=20
  // ok, we got this far, we must have had a valid serial number and passwo=
rd.
  // Now we need to validate the data that was sent.
=20=20
/* --------- End of Authentication ----------------------------------------=
-------------------------------------------*/
/*=20
   The upload process supports several types of data exchanges for things l=
ike log and config files.=20=20
   This sample only processes log files, however the code shows branches fo=
r other connection modes.
*/

  $szChecksum =3D "";	// empty by default, get a file checksum if needed.
  if ($MODE =3D=3D "LOGFILEUPLOAD") $szChecksum =3D GetFileChecksum($LOGFIL=
E);	// calculate a checksum for the file.
  if ($MODE =3D=3D "CONFIGFILEUPLOAD") $szChecksum =3D GetFileChecksum($CON=
FIGFILE);	// calculate a checksum for the file.
=20=20=20=20=20=20=20
/* ------------------------------------------------------------------------=
-------------------------------------------*/
/*  report the variables sent by the client if the client is requesting TRA=
CE MODE.
    this must be done AFTER the checksum is calculated.
=20=20=20
    In the file /etc/sysconfig/loggerconfig.ini on the acquisuite, two vari=
ables affect how the=20
    upload log file is recorded.  You can set these manually with a text ed=
itor.  If the option
    is not present in the configuration file, the line with the option must=
 be added to the file
    to enable the feature.  The order of the items in the config file is no=
t important. Obvius=20
    may provide a debug checkbox on the data upload page on the AcquiSuite =
in the future to=20
    enable this feature.  If these are not enabled the form variable SENDDA=
TATRACE is not included
    in the form data post, and the server should assume the setting is NO f=
or both items.
=20=20=20
		SENDDATADEBUG=3DYES/NO
		SENDDATATRACE=3DYES/NO
=09
    When SENDDATATRACE is set to YES, the database server script should rep=
ort progress with verbose messages
    if set to NO, the database server script should only report problems. V=
erbose messages include complete=20
    HTTP exchange information including http response headers.
=20=20=20
    SENDDATADEBUG=3DYES causes the AcquiSuite software to report progress w=
hile uploading the data. This will also
    cause the AcquiSuite to log all response text from the remote server to=
 the uploadlog file on the AcquiSuite.=20
    The remote server should send status information and error codes to the=
 AcquiSuite when this form variable is
    set to YES to allow the user to see the upload progress and find where =
problems (if any) are happening.
=20=20=20
=20=20=20
    MODE specifies what type of transfer this is.
=20=20=20
		LOGFILEUPLOAD		 standard transfer to upload data file
		CONFIGFILEMANIFEST	request a list of config files stored by the sql serve=
r, and report date/time for each
		CONFIGFILEUPLOAD	  send a config file to the sql server
		CONFIGFILEDOWNLOAD    download a config file from the sql server
		STATUS				send operating info about the acquisuite, firmware version, upt=
ime, dial attempts, etc.
		TEST				  used for the AcquiSuite connection test.  Verify user/password =
and then return a success message.
=20=20=09=20
    The MODBUSDEVICECLASS is a unique id that allows the AcquiSuite to deci=
de what class of device
    it is working with.  It is assumed that the number and type of points s=
tored for a specific device type are the same.
    For example, the Veris 8036 power meter has several versions for 100, 3=
00, 800Amp, however the list of points are the
	same for all devices.  The deviceclass will be the same for all flavors of=
 Veris 8036 meters.
=09
	Currently, the deviceclass may be one of the following:
		MBCLASS_UNKNOWN     0
		MBCLASS_HXO         1		(3 data columns)
		MBCLASS_H8036       2		(26 data columns)
		MBCLASS_M4A4P       3		(8 data columns, A8923 basic io module)
		MBCLASS_H8035       4		(2 data columns)
		MBCLASS_H8163	   5		(29 data columns)
		MBCLASS_H663 	   6		(42 data columns)
		MBCLASS_H8238       7		(28 data columns)
		MBCLASS_H8076       8		(28 data columns)
		MBCLASS_M4A4P2      9		(32 data columns, A8923 enhanced io module, A8811 =
built-in io module)
		MBCLASS_ION6200     10		(61 data columns)
          MBCLASS_ION7300     11		(64 data columns)
          MBCLASS_ION7500     12		(64 data columns)
          MBCLASS_ION7700     13		(64 data columns)
          MBCLASS_PROMON      14		(38 data columns)
          MBCLASS_ACQUILITE   15        (28 data columns)=20=20=20
=09
	More device types may be added as new devices are included in the supporte=
d hardware list. Note: the data column count is=20
	in addition to the first 4 columns for time,error,low-alarm, and high-alar=
m.

*/

  if ($SENDDATATRACE =3D=3D "YES")
  {    echo "Logfile upload from $REMOTE_ADDR \n" ;
       echo "Got SENDDATATRACE:          " . $SENDDATATRACE . " \n";       =
         // set when the AcquiSuite requests full session debug messages
       echo "Got MODE:                   " . $MODE . "\n";						  // this s=
hows what type of exchange we are processing.=20
       echo "Got SERIALNUMBER :          " . $SERIALNUMBER . " \n" ;		     =
   // The acquisuite serial number
=20=20=20=20=20=20=20
       if ($MODE =3D=3D "LOGFILEUPLOAD")
       {   echo "Got LOGFILE_name:           " . $LOGFILE_name . " \n" ;			=
// This is original file name on the AcquiSuite flash disk.
           echo "Got LOGFILE:                " . $LOGFILE . " \n" ;				 // =
This is the PHP temp file name.
           echo "Got LOGFILE_size:           " . $LOGFILE_size . " \n" ;			=
// What PHP claims the file size is
           echo "calculated filesize:        " . filesize($LOGFILE) . "\n";=
	     // what the actual file size is.
       	echo "Got MD5CHECKSUM:            " . $MD5CHECKSUM . " \n" ;			 // =
the MD5 checksum the AcquiSuite generated prior to upload
      	 echo "calculated checksum:        " . $szChecksum . " \n" ;        =
      // the MD5 sum we calculated on the file we received.
	       echo "Got LOOPNAME:               " . $LOOPNAME . " \n" ;			    // =
The name of the AcquiSuite (modbus loop name)
	       echo "Got MODBUSIP:               " . $MODBUSIP . " \n" ;				// Cur=
rently, always 127.0.0.1, may change in future products.
	       echo "Got MODBUSPORT:             " . $MODBUSPORT . " \n" ;			  // =
currently, always 502, may change in future products.
	       echo "Got MODBUSDEVICE:           " . $MODBUSDEVICE . " \n" ;			// =
the modbus device address on the physical modbus loop. (set by dip switches)
	       echo "Got MODBUSDEVICENAME:       " . $MODBUSDEVICENAME . " \n" ;		=
// the user specified device name.=20
	       echo "Got MODBUSDEVICETYPE:       " . $MODBUSDEVICETYPE . " \n" ;		=
// the identity string returned by the modbus device identify command=20
	       echo "Got MODBUSDEVICETYPENUMBER: " . $MODBUSDEVICETYPENUMBER . " \=
n" ;  // the identity number returned by the modbus device identify command=
=20
	       echo "Got MODBUSDEVICECLASS:      " . $MODBUSDEVICECLASS . " \n" ;	=
   // a unique id number for the modbus device type.
	       echo "Got FILETIME:               " . $FILETIME . " \n" ;			    // =
the date and time the file was last modified. (in UTC time).
       }
=20=20=20=20=20=20=20
       if ($MODE =3D=3D "CONFIGFILEUPLOAD")
       {   echo "Got CONFIGFILE_name:        " . $CONFIGFILE_name . " \n" ;=
 		// This is original file name on the AcquiSuite flash disk.
           echo "Got CONFIGFILE:             " . $CONFIGFILE . " \n" ;			  =
// This is the PHP temp file name.
           echo "Got CONFIGFILE_size:        " . $CONFIGFILE_size . " \n" ;=
		 // What PHP claims the file size is
	       echo "Got MODBUSIP:               " . $MODBUSIP . " \n" ;				// Cur=
rently, always 127.0.0.1, may change in future products.
	       echo "Got MODBUSPORT:             " . $MODBUSPORT . " \n" ;			  // =
currently, always 502, may change in future products.
	       echo "Got FILETIME:               " . $FILETIME . " \n" ;			    // =
the date and time the file was last modified. (in UTC time).
           echo "calculated filesize:        " . filesize($CONFIGFILE) . "\=
n";      // what the actual file size is.
       	echo "Got MD5CHECKSUM:            " . $MD5CHECKSUM . " \n" ;			 // =
the MD5 checksum the AcquiSuite generated prior to upload
       	echo "calculated checksum:        " . $szChecksum . " \n" ;        =
      // the MD5 sum we calculated on the file we received.=20=20=20=20=20
       }=20
=20=20=20=20=20=20=20
       if ($MODE =3D=3D "CONFIGFILEMANIFEST")
       {   echo "Got LOOPNAME:               " . $LOOPNAME . " \n" ;			    =
// The name of the AcquiSuite (modbus loop name)
       }
=20=20=20=20=20=20=20
       if ($MODE =3D=3D "CONFIGFILEDOWNLOAD")
       {   echo "Got MODBUSIP:               " . $MODBUSIP . " \n" ;				// =
Currently, always 127.0.0.1, may change in future products.
	       echo "Got MODBUSPORT:             " . $MODBUSPORT . " \n" ;			  // =
currently, always 502, may change in future products.
	       echo "Got MODBUSDEVICE:           " . $MODBUSDEVICE . " \n" ;			// =
the modbus device address on the physical modbus loop. (set by dip switches)
	       echo "Got MODBUSDEVICECLASS:      " . $MODBUSDEVICECLASS . " \n" ;	=
   // a unique id number for the modbus device type.
       }

	   if ($MODE =3D=3D "STATUS")
	   {   echo "Got UPTIME:                 " . $UPTIME . " \n" ;				  // num=
ber of seconds elapsed since the AcquiSuite booted.
	       echo "Got LOOPNAME:               " . $LOOPNAME . " \n" ;			    // =
The name of the AcquiSuite (modbus loop name)
	   	echo "Got PERCENTBLOCKSINUSE:     " . $PERCENTBLOCKSINUSE . " \n" ;   =
   // percentage of disk space consumed (by blocks)
	   	echo "Got PERCENTINODESINUSE:     " . $PERCENTINODESINUSE . " \n" ;   =
   // percentage of total log file entries used=20
	   	echo "Got UPLOADATTEMPT:          " . $UPLOADATTEMPT . " \n" ;        =
   // this is upload attempt X.  Use the loggerconfig.ini file to get the m=
ax upload attempts.
	   	echo "Got ACQUISUITEVERSION:      " . $ACQUISUITEVERSION . " \n" ;    =
   // Firmware version - AcquiSuite component
	   	echo "Got USRVERSION:             " . $USRVERSION . " \n" ;           =
   // Firmware version - USR files component
	   	echo "Got ROOTVERSION:            " . $ROOTVERSION . " \n" ;          =
   // Firmware version - ROOT files component
	   	echo "Got KERNELVERSION:          " . $KERNELVERSION . " \n" ;        =
   // Firmware version - Kernel component.
	   }
=09=20=20=20
       if ($MODE =3D=3D "TEST")
       {   echo "Test mode - nothing to do.";										// Test mode.  We've=
 verified authentication, do no processing
       }
=20=20=20=20=20=20=20=20=20=20=20=20=20
  } // end if trace session reporting enabled.
=20=20
/* ------------------------------------------------------------------------=
-------------------------------------------*/
/* Decide what to do based on the MODE setting.
    Each of these subroutines must report to the client what the success/fa=
ilure status is.
*/

  if ($MODE =3D=3D "LOGFILEUPLOAD")
  {   if ($szChecksum !=3D $MD5CHECKSUM)
	  {  ReportFailure("Log file checksum does not match.", $REMOTE_ADDR, $SER=
IALNUMBER, $MODBUSIP, $MODBUSPORT, $MODBUSDEVICE);
	     exit;
	  }
      ProcessLogFileUpload($REMOTE_ADDR, $SERIALNUMBER, $MODBUSIP, $MODBUSP=
ORT, $MODBUSDEVICE, $LOGFILE,=20
	  						$MODBUSDEVICENAME, $MODBUSDEVICETYPE, $MODBUSDEVICETYPENUMBER, $MO=
DBUSDEVICECLASS);
  } // end LOGFILEUPLOAD processing
=20=20
=20=20=20=20=20=20=20
  if ($MODE =3D=3D "CONFIGFILEUPLOAD")
  {   if ($szChecksum !=3D $MD5CHECKSUM)
	  {  ReportFailure("Configuration file checksum does not match.", $REMOTE_=
ADDR, $SERIALNUMBER, $MODBUSIP, $MODBUSPORT, $MODBUSDEVICE);
	     exit;
	  }
  }  // end CONFIGFILEUPLOAD processing
=20=20=20=20=20=20=20
=20=20=20=20=20=20=20
  if ($MODE =3D=3D "CONFIGFILEMANIFEST")
  {   SendConfigFileManifest($REMOTE_ADDR, $SERIALNUMBER, $MODBUSIP, $MODBU=
SPORT);
  } // end CONFIGFILEMANIFEST processing
=20=20=20=20=20=20=20
=20=20=20=20=20=20=20
  if ($MODE =3D=3D "CONFIGFILEDOWNLOAD")
  {   SendConfigFile($REMOTE_ADDR, $SERIALNUMBER, $MODBUSIP, $MODBUSPORT, $=
MODBUSDEVICE, $MODBUSDEVICECLASS);
  } // end CONFIGFILEDOWNLOAD processing
=20=20
=20=20
  // Trap all modes we don't know about, or if mode was not set.
  if ( ($MODE !=3D "LOGFILEUPLOAD") && ($MODE !=3D "CONFIGFILEUPLOAD") && (=
$MODE !=3D "CONFIGFILEMANIFEST") && ($MODE !=3D "CONFIGFILEDOWNLOAD") && ($=
MODE !=3D "STATUS") )
  {   ReportFailure("Mode request MODE=3D$MODE is not supported.", $REMOTE_=
ADDR, $SERIALNUMBER, $MODBUSIP, $MODBUSPORT, $MODBUSDEVICE);
	  exit;
  }
=20=20=20=20=20=20
/* ------------------------------------------------------------------------=
-------------------------------------------*/
/* Clean up and exit.
*/=20=20=20=20=20=20=20

  ob_end_flush(); // send cached stuff, and stop caching. This may only be =
done after the last point where you call ReportFailure()
?>

Cameron Seader
CSeader@Idahopower.com



[INFO] -- Access Manager:
This transmission may contain information that is privileged, confidential =
and/or exempt from disclosure under applicable law.  If you are not the int=
ended recipient, you are hereby notified that any disclosure, copying, dist=
ribution, or use of the information contained herein (including any relianc=
e thereon) is STRICTLY PROHIBITED. If you received this transmission in err=
or, please immediately contact the sender and destroy the material in its e=
ntirety, whether in electronic or hard copy format.  Thank you.   A2