registerFunction("SaveMTemplate"); $xajax->registerFunction("DeleteTemplate"); $xajax->registerFunction("ClearTheData"); $xajax->registerFunction("DeleteLogs"); session_start(); $user = $_SESSION['user']; $in_xAjax = false; // This is the flag to let things know we are in an xAjax function $xAjax_objResponse; // The object that is returned from the xAjax function - MUST BE DEFINED GLOBALLY $NoInactivityTimer = true; // Set so the xajax calls don't look at the inactivity timer. include('common_admin_inc.htm'); include('IOB_inc.htm'); define('TEMPLATE_FILE', '/home/embedded/library/CoreService/dat/ARMTemplates'); define('TEMPLATE_FILE_T', '/home/embedded/library/CoreService/dat/ARMTemplatesT'); class CARMTemplate { var $name; var $range; var $at_bc; var $at_sn; var $at_at; var $group; var $sort; var $chart; var $type; var $selBy; function CARMTemplate( $name, $range, $at_bc, $at_sn, $at_at, $sort, $group, $selBy, $chart, $type ) { $this->name = $name; $this->range = $range; $this->attrib = $attrib; $this->sort = $sort; $this->group = $group; $this->chart = $chart; $this->type = $type; $this->selBy = $selBy;// Only used if Group is a Select By one } }; /////////////////////////////////////////////////////////////////// // Save the configration passed in to the tamplate name passed in /////////////////////////////////////////////////////////////////// function SaveMTemplate( $name, $SelTemplate ) { global $in_xAjax; global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); $in_xAjax = true; // This must be called because we set NoInactivityTimer to true because of xajax loading the page behind the sheets. // Which causes an xajax XML error if the user is redirected to the login page durring the xajax call setup. // If we are logged out this function will reload the page which will take the user back to the login page. CheckLoggedOut(); error_log("Saving a new Template"); error_log("SelTemplate = ". print_r($SelTemplate, true) ); $fh = @fopen( TEMPLATE_FILE, 'a' ); if( $fh == false ) { error_log( "Could not open file for writing."); // error_back(); } else { $myArray = array(); $myArray[] = $name; error_log("name = ". $name ); error_log("$myArray[0] = ". $myArray[0] ); $myArray = array_merge($myArray, $SelTemplate); error_log("myArray = ". print_r($myArray,true) ); $myData = implode(",", $myArray); error_log("myData = ". $myData); $myData .= "\n"; error_log("Writting to file: ". $myData); $bytesWritten = fputs( $fh, $myData ); fclose($fh); // $xAjax_objResponse->assign("IOBStat_".$iob->id, "innerHTML", $IOB_bladeStatus[$iob->status]); // $xAjax_objResponse->script('setTimeout("xajax_checkIOBStatus()",20000);'); } return $xAjax_objResponse; } /////////////////////////////////////////////////////////////////// // Delete the template passed in /////////////////////////////////////////////////////////////////// function DeleteTemplate( $name ) { global $in_xAjax; global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); $in_xAjax = true; // This must be called because we set NoInactivityTimer to true because of xajax loading the page behind the sheets. // Which causes an xajax XML error if the user is redirected to the login page durring the xajax call setup. // If we are logged out this function will reload the page which will take the user back to the login page. CheckLoggedOut(); error_log("\n\n\Delete a Template"); $buffersize = 1*(256); // 256 char chunks $buffer = ''; // We need to have the system create the temp file so we can chmod it beofre using it. $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE touch ".TEMPLATE_FILE_T, $iRet); error_log("Call to system (touch) returned a \"$iRet\" and the output was \"$sRet\""); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE chmod 666 ".TEMPLATE_FILE_T, $iRet); error_log("Call to system (chmod) returned a \"$iRet\" and the output was \"$sRet\""); error_log("\n\n\n\n\n\n\n\n\n\n\n\n\n We are using the following file names: ". TEMPLATE_FILE ." and ".TEMPLATE_FILE_T); $fh = @fopen( TEMPLATE_FILE, 'r' ); if( $fh == false ) { error_log( "Could not open file for reading."); error_back(0x0b); } else { $fhT = @fopen( TEMPLATE_FILE_T, 'w' ); if( $fhT == false ) { error_log( "Could not open file for writing."); error_back(0x0b); } $i = 0; $j = 0; while ( !feof( $fh ) ) { $buffer = fgets( $fh, $buffersize ); $tData = split(",", $buffer ); if( $tData[0] == "" ) continue; // The last one seems to be blank - pass it up bit let the loop end normally if( $tData[0] == $name ) { // This is the one we want to delete continue; } fwrite( $fhT, $buffer ); } fclose($fh); fclose($fhT); // Now delete the OLD and rename the new $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f ".TEMPLATE_FILE, $iRet); error_log("Call to system (rm TEMPLATE_FILE) returned a \"$iRet\" and the output was \"$sRet\""); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE mv -f ".TEMPLATE_FILE_T." ".TEMPLATE_FILE, $iRet); error_log("Call to system (mv TEMPLATE_FILE_T) returned a \"$iRet\" and the output was \"$sRet\""); } return $xAjax_objResponse; } /////////////////////////////////////////////////////////////////////// // Clear the php data so the data will be read from scratch next load. /////////////////////////////////////////////////////////////////////// function ClearTheData() { global $in_xAjax; global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); $in_xAjax = true; // This must be called because we set NoInactivityTimer to true because of xajax loading the page behind the sheets. // Which causes an xajax XML error if the user is redirected to the login page durring the xajax call setup. // If we are logged out this function will reload the page which will take the user back to the login page. CheckLoggedOut(); unset($_SESSION['ARM_psn']); return $xAjax_objResponse; } ///////////////////////////////////////////////////////////////////// // Delete all the Advanced reporting Data. // This will Delete all TApeAlertLog and DriveLog files and archives. // New blank files wil be create to accept new logs from this point. ///////////////////////////////////////////////////////////////////// function DeleteLogs() { global $in_xAjax; global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); $in_xAjax = true; // This must be called because we set NoInactivityTimer to true because of xajax loading the page behind the sheets. // Which causes an xajax XML error if the user is redirected to the login page durring the xajax call setup. // If we are logged out this function will reload the page which will take the user back to the login page. CheckLoggedOut(); error_log("===================================================== Rolling the logs..."); // First roll the AR logs so the main one is empty roll_logs($user, false, true); // Now delete all the archive files. $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f /home/embedded/library/CoreService/dat/DriveLog.*", $iRet); error_log("Call to system (rm DriveLog.*) returned a \"$iRet\" and the output was \"$sRet\""); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f /home/embedded/library/CoreService/dat/TapeAlertLog.*", $iRet); error_log("Call to system (rm DriveLog.*) returned a \"$iRet\" and the output was \"$sRet\""); return $xAjax_objResponse; } // This call must come AFTER ALL xajax functions have been defined. // This is what connects the php functions with the JavaScript functions. $xajax->processRequest(); /////////////////////////////////////////////////////////////////////////// // This class defines the data that will read from the TapeAlertLog files // A line of the file looks like: // 12/22/2007 12:56:59,12/22/2007 12:56:17,0,2,1210143187,rdt2,0,0,2,000158L3 //////////////////////////////////////////////////////////////////////////////// class CMediaData { var $aTime; var $serial; var $barcode; var $tapeAlert; var $use; function CMediaData($aTime, $serial, $barcode, $tapeAlert) { $this->aTime = $aTime; $this->serial = $serial; $this->barcode = $barcode; $this->tapeAlert = $tapeAlert; $this->use = true; } }; /*##################################################################### # To do this parsing in a shell script use something like the # following with the unique command. # awk '{print $3}' DriveLog | awk -F, '{print $2","$3" "$4" "$9}' # --------------------- ----------------------------------- # | | # Get Rid of the dates | # Display the 3 items we want #####################################################################*/ // A line of the file looks like: // 12/22/2007 12:56:59,12/22/2007 12:56:17,0,2,1210143187,rdt2,0,0,2,000158L3 ?>
$xajax->printJavascript(); ?>