include ('common_admin_inc.htm');
$diskSpace = disk_free_space("/home/embedded/library/upload");
error_log("Free Diskspace for Firmware upload is: ". $diskSpace );
$doDiskClean = 0;
if($_SERVER[REQUEST_METHOD] == "POST")
{
if($_POST[RunDiskClean] == '1' )
{
$doDiskClean = 1;
}
else
{
$operationInProgress = true;
$status = new ReturnStatus();
$tmp_name = $_FILES['softwareUpdate']['tmp_name'];
error_log("The File has been uploaded - we will now verify it.");
$l = print_r($_FILES, TRUE);
error_log($l);
if(is_uploaded_file($_FILES['softwareUpdate']['tmp_name']))
{
/* CMIResult::FirmwareUpdateInProgress = 4125 */
set_single_user_mode($user, true, 4125);
$iRet = update_system_software($user, $_FILES['softwareUpdate']['tmp_name']);
if( $iRet == 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);
error_log("Distroying the Session in updateSoftware");
session_destroy();
unset( $_SESSION['login'] );
unset( $_SESSION['user'] );
unset( $_SESSION );
error_log("Exiting now!!!");
exit(0);
}
else
{
error_log("Problem Upgrading Software");
set_single_user_mode($user, false);
error_log("Failed software update");
$status->setErrorCode($iRet);
}
}
else
{
if (is_null($_FILES["softwareUpdate"]))
{
error_log("The file is too big. softwareUpdate was NULL");
$status->setErrorCode("4109");
}
else
{
switch ($HTTP_POST_FILES['softwareUpdate']['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;
}
}
?>
Setup License
Disk Space Preparation
Please wait while the library frees up disk space for the Firmware upload.
if( $doDiskClean == true )
{
$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 Firmware upload is: ". $diskSpace );
}
?>