"; } return; } else { $operationInProgress = true; $status = new ReturnStatus(); if ($operation == "save") { // Make sure any failed attemps are deleted first. $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f /tmp/php* > /dev/null", $iRet); error_log("Call to rm -f /tmp/php* returned a \"$iRet\" and the output was \"$sRet\""); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f /tmp/saveRestore* > /dev/null", $iRet); error_log("Call to rm -f /tmp/saveRestore* returned a \"$iRet\" and the output was \"$sRet\""); save_system_state($user, $fileName); } else { // Must be a restore. $tmp_name = $_FILES['restoreFile']['tmp_name']; error_log("is_uploaded_file tmp = ".$tmp_name); error_log("is_uploaded_file = ".$_FILES['restoreFile']['name']); error_log("Flag to restore Firmware also is: " . ($bRestoreFW ? "TRUE" : "FALSE" )); $l = print_r($_FILES, TRUE); error_log($l); if (is_uploaded_file($_FILES['restoreFile']['tmp_name'])) { error_log("file uploaded successfully"); // Now lets verify that the file is good by running a "tar tf" on it // Note this file is just a tar not a gzipped tar. $sRet = system("tar tf $tmp_name", $iRet); error_log("Call to system (tar) returned a \"$iRet\" and the output was \"$sRet\""); if ($iRet != 0) { set_single_user_mode($user, false); error_log("Uploaded file was corrupt or invalid"); $status->setErrorCode("4112"); print $status->out(); exit(0); } // We need to clean up any previous failures before continuing. // Mv the current php* file so we don't delete it below $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE mv -f ". $_FILES['restoreFile']['tmp_name'] ." /tmp/sr_save > /dev/null", $iRet); error_log("Call to mv to /tmp/sr_save returned a \"$iRet\" and the output was \"$sRet\""); // Make sure any failed attemps are deleted first. $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f /tmp/php* > /dev/null", $iRet); error_log("Call to rm -f /tmp/php* returned a \"$iRet\" and the output was \"$sRet\""); $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE rm -f /tmp/saveRestore* > /dev/null", $iRet); error_log("Call to rm -f /tmp/saveRestore* returned a \"$iRet\" and the output was \"$sRet\""); // Mv the saved file back to it's original name. // Incase somethng fails the file name will be something the rest of the system knows. $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE mv -f /tmp/sr_save ". $_FILES['restoreFile']['tmp_name'] ." > /dev/null", $iRet); error_log("Call to mv from /tmp/sr_save returned a \"$iRet\" and the output was \"$sRet\""); error_log("Calling restore_system_state(user, user, ". $_FILES['restoreFile']['tmp_name'].", ". $bRestoreFW .");"); $returnCode = restore_system_state($user, $_FILES['restoreFile']['tmp_name'], $bRestoreFW); error_log("returnCode=$returnCode"); if( $returnCode != 0) { $status->setErrorCode($returnCode); } else { //CR 46077 Do the reboot automaticly // error_log("Calling Reboot directly"); // reboot($user); // Close the progress Window. print $status->closeOut(1); error_log("Distroying the Session in save/restore"); session_destroy(); unset( $_SESSION['login'] ); unset( $_SESSION['user'] ); unset( $_SESSION ); /*########################################################### # Note: The code in $status->out() calls returnStatus( 1 ) # Which closes the popup and reloads the homepage in the # main Window. ###########################################################*/ exit(0); } } else { if (is_null($_FILES["restoreFile"])) { error_log("The file you are trying to upload is too big. retoreFile was NULL"); $status->setErrorCode("4109"); } else { switch ($HTTP_POST_FILES['restoreFile']['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. Error 2"); $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 { // Run the disSpace clean script when the user enters this page. // Note this CAN-NOT be ran after the post, becase the file is uploaded at the // beginiing of the post and this will delete the file that was just uploaded. $sRet = system("/usr/bin/cmdwrap -NO_END_OF_FILE /home/embedded/library/DiskSpaceClean.sh > /dev/null 2>&1", $iRet); error_log("Call to cmdwrap DiskSpaceClean.sh returned a \"$iRet\" and the output was \"$sRet\""); $diskSpace = disk_free_space("/home/embedded/library/upload"); error_log("NEW - Free Diskspace for Restore is: ". $diskSpace ); } // Generate a temporary filename on the initial get $fileName = "/tmp/saveRestore-".date("m_d_y-His"); // Calculate the available disk space and create a displayable label $availableDiskSpace = disk_free_space("/") / 1048576.0; ?> Tools - Save&Restore