registerFunction("getEKM"); session_start(); $user = $_SESSION['user']; $in_xAjax = false; $xAjax_objResponse; include('common_admin_inc.htm'); $akmResult = akm_get_error_codes(); //error_log("akm_get_errorcodes = ". print_r($akmResult,true) ); class EKMdata { var $primaryIP; var $primaryPort; // default is 3801 (decimal) var $secondaryIP; var $secondaryPort; // default is 3801 (decimal) function EKMdata( $primaryIP, $primaryPort, $secondaryIP, $secondaryPort ) { $this->primaryIP = $primaryIP; $this->primaryPort = $primaryPort; $this->secondaryIP = $secondaryIP; $this->secondaryPort = $secondaryPort; } }; function getEKM() { // !?! NOTE: Not using this function - but I left it in case I wanted to switch to using it in the future. global $in_xAjax; // global $xAjax_objResponse; $user = $_SESSION['user']; $xAjax_objResponse = new xajaxResponse(); /// $in_xAjax = true; error_log("Calling get_ekm($user);"); $ekm_data = get_ekm( $user ); error_log("ekm_data = ". print_r($ekm_data, true) ); $xAjax_objResponse->assign("primIP", "value", $ekm_data->primaryIP ); $xAjax_objResponse->assign("primPort", "value", $ekm_data->primaryPort ); $xAjax_objResponse->assign("secIP", "value", $ekm_data->secondaryIP ); $xAjax_objResponse->assign("secPort", "value", $ekm_data->secondaryPort ); // Some Debug examples //$xAjax_objResponse->script('alert(xajax.$("testlevel[1]").value);'); //$xAjax_objResponse->script('alert(xajax.viewSource());'); /// $in_xAjax = false; return $xAjax_objResponse; } $xajax->processRequest(); /*******************************************************************************************/ // Handle the progress screen if opened and set the NEW data if ($_SERVER[REQUEST_METHOD] == "POST") { $operationInProgress = true; $status = new ReturnStatus(); // By calling this here on all the QKM pages during the post the will all get the same error. $iAkmReady = akm_servers_available($user, true); // $iAkmReady = (akm_servers_available($user) == 1); error_log("akm_servers_available returned: ". print_r($iAkmReady, true)); error_log($_SERVER['PHP_SELF']." POST = ". print_r($_POST, true) ); $tmp_name = $_FILES['KeyFile']['tmp_name']; error_log("_FILES = ". print_r($_FILES, true) ); error_log("The File has been uploaded - we will now verify it."); if(is_uploaded_file($_FILES['KeyFile']['tmp_name'])) { /* CMIResult::FirmwareUpdateInProgress = 4125 */ //set_single_user_mode($user, true, 4125); $fileName = "/tmp/".$_FILES['KeyFile']['name']; error_log("The file has been uploaded. We are now going to move it to ". $fileName ); if(!move_uploaded_file($_FILES['KeyFile']['tmp_name'], $fileName)) { error_log("Failed to moved the uploaded file ". $fileName); $status->setErrorCode("4108"); } $keyList = akm_import_keys($user, $fileName); error_log("The Keys that imported were:\n". print_r($keyList,true) ); do { // NOTE: The check progress may not be started when you call it the first time so t get around this I am doing the sleep before chacking the status. sleep(10); @reset_inactive_timer($user); $akmStatus = akm_key_import_progress($user, 0); error_log("Looped - akm_key_import_progress returned: ". print_r($akmStatus,true) ); }while( $akmStatus->status != $akmResult->StatusFinished ); error_log("\n\n\n>>>>>>>>>>>>>>>>>>>>>>>>> We have finished the progress check <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n"); error_log("\akm_key_import_progress returned: ". print_r($akmStatus,true) ); error_log("$akmStatus->status != $akmResult->StatusFinished"); if( $akmStatus->status != $akmResult->SUCCEEDED && $akmStatus->status != $akmResult->StatusFinished ) { error_log("Setting errorcode ->". $akmStatus->status ); $status->setErrorCode( $akmStatus->status ); } print $status->out(); // else if( sizeof($keyList) != 0 ) // { // error_log("Closing the progress window."); // /*########################################################### // # Note: The code in $status->out() calls returnStatus( 1 ) // # Which closes the popup and reloads the homepage in the // # main Window. // ###########################################################*/ // // Close the progress Window. // //print $status->closeOut(1); // print $status->out(); // } // else // { // error_log("Problem Importing Key(s)"); // $status->setErrorCode(4112); //Force corrupt file // } } else { if (is_null($_FILES["KeyFile"])) { error_log("The file is too big. key file was NULL"); $status->setErrorCode("4109"); } else { switch ($HTTP_POST_FILES['KeyFile']['error']) { case 1 : //uploaded file exceeds the upload_max_filesize directive in php.ini case 2 : //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form error_log("The file you are trying to upload is too big."); $status->setErrorCode("4109"); break; case 3 : //uploaded file was only partially uploaded error_log("The file you are trying upload was only partially uploaded."); $status->setErrorCode("4110"); break; case 4 : //no file was uploaded error_log("You must select an image for upload."); $status->setErrorCode("4111"); break; default : //a default error, just in case! :) error_log("There was a problem with your upload."); $status->setErrorCode("4108"); break; } } } print $status->out(); return; } else { //$akmServAvail = (@akm_servers_available($user) == 1); $akmServAvail = akm_servers_available($user); if( $akmServAvail == 1 ) { // Load the data up on the get of the page. $ver = akm_get_software_version($user); //!?! This has Code that checks for the new Townsedn code over the OLD error_log("akm_get_software_version returned ". print_r($ver,true) ); } } $akmStatus = @akm_key_import_progress($user, 0); error_log("\akm_key_import_progress returned: ". print_r($akmStatus,true) ); error_log("$akmStatus->status != $akmResult->StatusFinished"); if( $akmStatus->status == $akmResult->StatusFinished || $akmStatus->status == $akmResult->StatusNotStarted ) $libBusy = false; else $libBusy = true; ?>
$xajax->printJavascript(); ?>