126 lines
4.0 KiB
PHP
Executable File
126 lines
4.0 KiB
PHP
Executable File
<?php
|
|
include_once 'path.php';
|
|
|
|
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true)
|
|
exit(header("Location:../index.php"));
|
|
|
|
if($_SESSION['validUser'] === true) {
|
|
$proxyUser = isset($_SESSION['proxyUserName'])?$_SESSION['proxyUserName']:"";
|
|
$proxyPwd = isset($_SESSION['proxyPassword'])?$_SESSION['proxyPassword']:"";
|
|
$proxyIP = isset($_SESSION['ipAddress'])?$_SESSION['ipAddress']:"";
|
|
$proxyPort = isset($_SESSION['port'])?$_SESSION['port']:"";
|
|
|
|
$userName = $_SESSION['userName'];
|
|
$password = $_SESSION['password'];
|
|
$encType = $_SESSION['encType'];
|
|
|
|
$oldMask = umask(0);
|
|
$accountSettingPath = Scheduler::$user_dir."ACCOUNT_SETTINGS_FILE";
|
|
|
|
$resp = array();
|
|
umask($oldMask);
|
|
if(file_exists($accountSettingPath)){
|
|
$getAccountSettingsData = file_get_contents($accountSettingPath);
|
|
$getAccountSettingsJsonData = json_decode($getAccountSettingsData, true);
|
|
$_SESSION['multipleEngineEnable'] = 2;
|
|
if($getAccountSettingsJsonData['engineCount'] != 2)
|
|
$_SESSION['multipleEngineEnable'] = 4;
|
|
}
|
|
else{
|
|
$_SESSION['multipleEngineEnable'] = 4;
|
|
}
|
|
$file = fopen($accountSettingPath, "w+");
|
|
if(!$file) {
|
|
restartSession(); //Restart session
|
|
$resp[] = false;
|
|
$resp[] = "Failed to open account setting file : ".customErrorMsg()." <br> Account Settings File could not be created successfully";
|
|
echo json_encode($resp);
|
|
exit();
|
|
} else {
|
|
$serverAddr = getEVSServerAddr(); //Getting EVS server address
|
|
if("" == $proxyIP) {
|
|
$proxyData = "";
|
|
} else {
|
|
$proxyData = (($proxyUser != "")?urlencode($proxyUser):"").":".(($proxyPwd != "")?urlencode($proxyPwd):"")."@".($proxyIP).":".($proxyPort);
|
|
}
|
|
$accountSettingData['userName'] = $userName;
|
|
# url decode is required to handle HTML encoded characters in password
|
|
$accountSettingData['password'] = $password;
|
|
$accountSettingData['encType'] = $encType;
|
|
$accountSettingData['serverAddr'] = $serverAddr;
|
|
$accountSettingData['PROXY'] = $proxyData;
|
|
$accountSettingData['engineCount'] = $_SESSION['multipleEngineEnable'];
|
|
$accountSettingData['isSubAccount'] = $_SESSION['isSubAccount'];
|
|
$accountSettingData['userAccountStatus'] = "active";
|
|
fwrite($file, json_encode($accountSettingData,TRUE));
|
|
fclose($file);
|
|
@chmod($accountSettingPath, $permissionVal);
|
|
}
|
|
#unset($_SESSION['password']);
|
|
|
|
/* Creating Default Backup/Restore Locations - Start */
|
|
if(!file_exists($mpc))
|
|
update_mpc();
|
|
|
|
if(!file_exists($drlFile))
|
|
createRestoreLocationFile();
|
|
|
|
$localManualDir = Scheduler::$localbackup_dir."+ManualTask";
|
|
$localStartPidfilePath = "$localManualDir/".START_PID;
|
|
if(!isJobRunning($localStartPidfilePath)){
|
|
@unlink("$localManualDir/".BACKUPSETFILEDISPLAY);
|
|
}
|
|
|
|
$backupManualDir = Scheduler::$backup_dir."+ManualTask";
|
|
$backupStartPidfilePath = "$backupManualDir/".START_PID;
|
|
if(!isJobRunning($backupStartPidfilePath)){
|
|
@unlink("$backupManualDir/".BACKUPSETFILEDISPLAY);
|
|
}
|
|
|
|
$restoreManualDir = Scheduler::$restore_dir."+ManualTask";
|
|
$restoreStartPidfilePath = "$restoreManualDir/".START_PID;
|
|
if(!isJobRunning($restoreStartPidfilePath))
|
|
@unlink("$restoreManualDir/".RESTORESETFILEDISPLAY);
|
|
|
|
/* Creating Default Backup/Restore Locations - End */
|
|
isRootLevelDisplayEnabled();
|
|
|
|
clearPidsAndCancelJob(); //Remove the pids if the job is not running
|
|
killSizeFd(); //Killing the getSize process
|
|
|
|
$dedup = false;
|
|
$deviceIDExists = false;
|
|
$deviceCount = 0;
|
|
$listfail = FALSE;
|
|
if(isset($_SESSION['dedup']) && $_SESSION['dedup']){
|
|
$listop = getDedupDeviceList();
|
|
if(!$listop[0]) {
|
|
$listfail = TRUE;
|
|
}
|
|
|
|
$dedup = true;
|
|
$deviceIDExists = deviceIDExists();
|
|
if(isset($_SESSION['deviceList']))
|
|
$deviceCount = count($_SESSION['deviceList']);
|
|
}
|
|
|
|
if($listfail) {
|
|
$resp = array(FALSE, UNABLE_TO_CONNECT_EVS_SERVER);
|
|
} else {
|
|
$message = ACCOUNT_SET_SUCC;
|
|
$_SESSION['configType'] = false;
|
|
$resp = array(TRUE, $message, FALSE, $dedup, $deviceCount, $deviceIDExists);
|
|
}
|
|
|
|
#<Deepak>
|
|
//$_SESSION['validUser'] = true;
|
|
echo json_encode($resp);
|
|
exit();
|
|
} else {
|
|
$resp[] = false;
|
|
$resp[] = false;
|
|
echo json_encode($resp);
|
|
exit();
|
|
}
|
|
?>
|