VERSION if(hasPHPSafeModeEnabled()) { # //$_SESSION['validUser'] = TRUE; $servDirErrorMessage = PHP_SAFEMOD_WARNING_MESSAGE; if(isAJAX()) { echo json_encode(array(FALSE, PHP_SAFEMOD_WARNING_HEADER)); } else { echo getDirPermissionHTML(PHP_SAFEMOD_WARNING_HEADER, $servDirErrorMessage); } return; } # Validate for open_basedir -> /etc: if($machine == SYNOLOGY_LOCAL && !isOpenBaseDirValid()) { # //$_SESSION['validUser'] = TRUE; if(isAJAX()) { echo json_encode(array(FALSE, PHP_OPENBASE_DIR_WARNING_HEADER)); } else { echo getDirPermissionHTML(PHP_OPENBASE_DIR_WARNING_HEADER, PHP_OPENBASE_DIR_MESSAGE); } return; } /* Checking the directory "idrive" */ if(!is_dir("$webDir/".SERVICE)) { $IDrivePath = "$webDir/".SERVICE; /* Creating the directory "idrive" if not exist */ if(!mkdir($IDrivePath, $permissionVal)) { file_put_contents($temp_file, CMDEXECUTE); file_put_contents($temp_file,"\nmkdir $IDrivePath\n",FILE_APPEND); file_put_contents($temp_file,"chmod $permissionVal $IDrivePath\n",FILE_APPEND); @chmod($temp_file, $permissionVal); $res = phpScriptExecution(OPERATIONSFILE); if("" != $res) { # //$_SESSION['validUser'] = true; $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR."$webDir/".SERVICE.": ".customErrorMsg(); echo json_encode($resp); return; } } @chmod($IDrivePath, $permissionVal); } if(!clearAppUpdateLock()) { $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR . $userProfile . ": " . customErrorMsg(); echo json_encode(array(FALSE, APP_UPDATE_IN_PROGRESS)); return; } # Check if directory is created and writable #need to check and update link if not exist. $servDirPerms = isDirectoryWritable($webDir . '/' . SERVICE); /*if(!$servDirPerms['is_exists'] || !$servDirPerms['is_writable']) { $servDirErrorHeader = INSUFFICIENT_PERMISSION_MESSAGE . $_SESSION['nasUserName']; $resp[] = FALSE; $resp[] = $servDirErrorHeader; if(isAJAX()) { echo json_encode($resp); } else { echo getDirPermissionHTML($servDirErrorHeader, ''); } return; }*/ /* Checking the directory "cache" */ $cache = "$webDir/".SERVICE."/".CACHE."/"; if(!is_dir($cache)) { $error= error_get_last(); /* Creating the directory "cache" under "idrive" if not exist */ if(!mkdir($cache, $permissionVal)) { # //$_SESSION['validUser'] = true; $servDirErrorHeader = INSUFFICIENT_PERMISSION_MESSAGE . $_SESSION['nasUserName']; $resp[] = FALSE; $resp[] = $servDirErrorHeader; if(isAJAX()) { echo json_encode($resp); } else { echo getDirPermissionHTML($servDirErrorHeader, ''); } return; } else { @chmod($cache, $permissionVal); } } /* Checking the directory "user profiles" */ $userProfile = "$webDir/" . SERVICE . "/" . USER_PROFILE; if(!is_dir($userProfile)) { /* Creating the directory "user profiles" under "idrive" if not exist */ if(!mkdir($userProfile, $permissionVal)) { # //$_SESSION['validUser'] = true; $servDirErrorHeader = INSUFFICIENT_PERMISSION_MESSAGE . $_SESSION['nasUserName']; $resp[] = FALSE; $resp[] = $servDirErrorHeader; if(isAJAX()) { echo json_encode($resp); } else { echo getDirPermissionHTML($servDirErrorHeader, ''); } return; } else { @chmod($userProfile, $permissionVal); } } # Check if directory is created and writable $servDirPerms = isDirectoryWritable($userProfile); if(!$servDirPerms['is_exists'] || !$servDirPerms['is_writable']) { $servDirErrorHeader = INSUFFICIENT_PERMISSION_MESSAGE . $_SESSION['nasUserName']; $resp[] = FALSE; $resp[] = $servDirErrorHeader; if(isAJAX()) { echo json_encode($resp); } else { echo getDirPermissionHTML($servDirErrorHeader, ''); } @chmod($userProfile, $permissionVal); return; } /* Checking the NAS user directory */ $nasUserDirectory = Scheduler::$nasUser_dir; if(!is_dir($nasUserDirectory)) { # Creating the directory "nas" under user profile if not exist if(!mkdir($nasUserDirectory, $permissionVal)) { $_SESSION['validUser'] = true; $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR . $nasUserDirectory . ": " . $php_errormsg; echo json_encode($resp); return; } @chmod($nasUserDirectory, $permissionVal); } if($_POST) { $pageSubmitted = true; $resp = array(); $userName = phpRealEscapeString(strtolower(rawurldecode($_POST["userName"]))); if (strpos($userName, '@') !== false){ $idriveUserArray = getIDriveUsernameList($userName); if(count($idriveUserArray) == 1){ $userName = $idriveUserArray[0]; $_SESSION['userName'] = $userName; } else if(count($idriveUserArray)>1){ $resp[] = false; $resp[] = "MULTIPLE_ACCOUNT"; $resp[] = $idriveUserArray; restartSession(); //Restart session echo json_encode($resp); exit; } } $accountSettingsFilePath = "$nasUserDirectory/$userName/ACCOUNT_SETTINGS_FILE"; $password = rawurldecode($_POST["passwordHidden"]); $usrDir = "$nasUserDirectory/$userName"; $temp_file = "$nasUserDirectory/$userName/temp_operationsfile.txt"; if(is_dir($usrDir)) { file_put_contents($temp_file,DIRREMOVE); @chmod($temp_file, $permissionVal); phpScriptExecution(OPERATIONSFILE, "$nasUserDirectory/$userName/"); } $invalidIDriveUser = false; $_SESSION['proxyUser'] = ''; $_SESSION['proxyPwd'] = ''; $_SESSION['proxyIP'] = ''; $_SESSION['proxyPort'] = ''; Scheduler::SetSchedulerPath($webDir, $userName, $_SESSION['nasUserName'], $machine); $out = validateIDriveLoginCGI($password); if(strpos($out, "SUCCESS") !== FALSE) { if(isset($_SESSION['multiUser'])) unset($_SESSION['multiUser']); $_SESSION['userName'] = $userName; $idriveUser = "$nasUserDirectory/$userName"; updateBackupAndRestoreSetFiles(); if(!is_dir($idriveUser)) { if(!mkdir($idriveUser, $permissionVal)) { $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR."$idriveUser : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod($idriveUser, $permissionVal); } //Create .serverAddr.txt $file = Scheduler::$user_dir.SERVER_ADDR_PATH; file_put_contents($file, $_SESSION['serverAddr']); @chmod($file,$permissionVal); updateServerAddress(); # verify write permission to IDrive directory and su $phpPath = $appPath . '/' . CONFIG; /*$appDirPerms = isDirectoryWritable($phpPath); if(!$appDirPerms['is_writable']) { $resp[] = FALSE; $resp[] = str_replace("{:APP_PATH:}", $phpPath, APP_DIR_WRITE_PERM_MISSING); echo json_encode($resp); exit; }*/ // creating default restore location directory $restoreLocation = Scheduler::$user_dir."RESTORE_DATA"; if(!is_dir($restoreLocation)) { if(!mkdir($restoreLocation, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.$restoreLocation." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod($restoreLocation, $permissionVal); } // creating backup directory if(!is_dir(Scheduler::$backup_dir)) { if(!mkdir(Scheduler::$backup_dir, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.Scheduler::$backup_dir." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod(Scheduler::$backup_dir, $permissionVal); $defaultBackupPath = Scheduler::$backup_dir.DEFAULT_BACKUPSET; if(mkdir($defaultBackupPath, $permissionVal)){ @chmod($defaultBackupPath, $permissionVal); /* Basavaraj: Removed from createDefaultBackupSet() and pasted here */ $popUpPathFrom = "$webDir/".APPDIR."/".POP_UP_LIST_FILE; $popUpPathTo = "$nasUserDirectory/$userName/".POP_UP_LIST_FILE; copy($popUpPathFrom,$popUpPathTo); } @chmod($popUpPathTo, $permissionVal); } // creating backup search directory added for search if(!is_dir(Scheduler::$backup_search_dir)) { if(!mkdir(Scheduler::$backup_search_dir, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.Scheduler::$backup_search_dir." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod(Scheduler::$backup_search_dir, $permissionVal); } // creating restore directory if(!is_dir(Scheduler::$restore_dir)) { if(!mkdir(Scheduler::$restore_dir, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.Scheduler::$restore_dir." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod(Scheduler::$restore_dir, $permissionVal); } // creating restore search directory added for search if(!is_dir(Scheduler::$restore_search_dir)) { if(!mkdir(Scheduler::$restore_search_dir, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.Scheduler::$restore_search_dir." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod(Scheduler::$restore_search_dir, $permissionVal); } // creating delete directory if(!is_dir(Scheduler::$delete_dir)) { if(!mkdir(Scheduler::$delete_dir, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.Scheduler::$delete_dir." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod(Scheduler::$delete_dir, $permissionVal); } // creating delete log directory if(!is_dir(Scheduler::$delete_log_dir)) { if(!mkdir(Scheduler::$delete_log_dir, $permissionVal)){ $resp[] = false; $resp[] = FAILED_TO_CREATE_DIR.Scheduler::$delete_log_dir." : ".customErrorMsg(); echo json_encode($resp); exit; } @chmod(Scheduler::$delete_log_dir, $permissionVal); } # create trace directory here at the time of first login $traceDir = Scheduler::$user_dir.".trace/"; if(!is_dir($traceDir)) { mkdir($traceDir); } @chmod($traceDir, 0777); // creating full path exclude file with working folder $excludeFullFile = "$nasUserDirectory/$userName/".FULL_PATH_EXCLUDE_FILE; excludeworkingfolder(); updateExcludeFiles(); $_SESSION['validUser'] = true; $_SESSION['userName'] = $userName; $passwordEscapeString = phpRealEscapeString(urldecode($_POST["passwordHidden"])); $_SESSION['password'] = base64_encode($passwordEscapeString); $exp = explode("#",$out); $exp1 = explode("_",$exp[0]); // getEVSServerAddr(); //Getting & Assigning EVS server address to session variable $_SESSION['evswebsrvr'] = $exp1[3]; if($exp1[1]=="SET"){ percentQuotaUsed($exp[1],$exp[2]); $_SESSION['totalQuota'] = humanReadableSize($exp[2]); $_SESSION['usedQuota'] = humanReadableSize($exp[1]); $_SESSION['usedQuotaOrg'] = $exp[1]; if(strpos($exp1[2], "DEFAULT") !== false){ $_SESSION['configVerified'] = true; $_SESSION['encType'] = "Default"; updateEncType(); $pass = $passwordEscapeString; encodePathWrapper($pass, "DEFAULT", ""); // getEVSServerAddr(); //Getting & Assigning EVS server address to session variable if(file_exists($mpc)){ $dir = file_get_contents($mpc); } else { $dir = getNAShostname(); } if(!$_SESSION['dedup']) $dirOutput = createDir($dir, "", "Default"); $resp[] = true; $resp[] = "Default"; $resp[] = $userName; echo json_encode($resp); exit(); } else{ $resp[] = true; $resp[] = "Private"; $resp[] = $userName; $_SESSION['configVerified'] = false; $_SESSION['encType'] = "Private"; updateEncType(); echo json_encode($resp); exit(); } } else { $resp[] = true; $resp[] = "NotSet"; $resp[] = $userName; echo json_encode($resp); //added by anil on 3jan2019 $_SESSION['totalQuota'] = humanReadableSize($exp[2]); $_SESSION['usedQuota'] = humanReadableSize($exp[1]); $_SESSION['usedQuotaOrg'] = $exp[1]; $mpcFilePath = "$nasUserDirectory/$userName/mpc.txt"; @unlink($mpcFilePath); // new code end's here. $_SESSION['configVerified'] = false; @unlink($accountSettingsFilePath); //Added by Senthil for account configuration UI issue // header("Location:$destinationURL"); exit(); } } else if(strpos($out, "INVALID_PLAN_TYPE") !== FALSE) { $invalidIDriveUser = true; Scheduler::Log('User login failed: '.INVALID_PLAN_TYPE); $resp[] = false; $resp[] = INVALID_PLAN_TYPE; echo json_encode($resp); restartSession(); //Restart session exit; } else if(strpos($out, "CANCELED_ACC") !== FALSE) { $invalidIDriveUser = true; Scheduler::Log('User login failed: '.CANCELED_ACC); $resp[] = false; $resp[] = CANCELED_ACC; echo json_encode($resp); updateAccountStatus("account has been cancelled"); restartSession(); //Restart session exit; }else if(strpos($out, "ACC_UNDER_MAINTENANCE") !== FALSE) { $invalidIDriveUser = true; Scheduler::Log('User login failed: '.ACC_UNDER_MAINTENANCE); $resp[] = false; $resp[] = ACC_UNDER_MAINTENANCE; echo json_encode($resp); updateAccountStatus("account is under maintenance"); restartSession(); //Restart session exit; }else if(strpos($out, "BLOCKED_ACC") !== FALSE) { $invalidIDriveUser = true; Scheduler::Log('User login failed: '.BLOCKED_ACC); $resp[] = false; $resp[] = BLOCKED_ACC; echo json_encode($resp); updateAccountStatus("account has been blocked"); restartSession(); //Restart session exit; }else if(strpos($out, "windows_user") !== FALSE) { $invalidIDriveUser = true; Scheduler::Log('User login failed: '.WINDOWS_USER); $resp[] = false; $resp[] = WINDOWS_USER; echo json_encode($resp); restartSession(); //Restart session exit; } else if(strpos($out, "nointernet") !== FALSE || strpos($out, "invalidproxy") !== FALSE) { $invalidIDriveUser = true; Scheduler::Log('User login failed: ' . NO_INTERNET); echo json_encode(array(FALSE, NO_INTERNET)); restartSession(); # Restart session exit; } else { $invalidIDriveUser = true; Scheduler::Log('User login failed: '.INVALID_CREDENTIAL); $resp[] = false; $resp[] = INVALID_CREDENTIAL; echo json_encode($resp); restartSession(); //Restart session exit; } } //end of $_POST else $_SESSION['multiUser'] = false; } $userNameSession = isset($_SESSION['userName'])?$_SESSION['userName']:''; $passwordSession = isset($passwordEscapeString)?$passwordEscapeString:''; $encTypeSession = isset($_SESSION['encType'])?$_SESSION['encType']:''; if($pageSubmitted == false && !isset($_SESSION['configVerified'])){ $displySetting = ''; $displyConfigure = 'none'; $displyGetPrivate = 'none'; } else if(!isset($_SESSION['encType']) && $_SESSION['configVerified'] == false) { $displySetting = 'none'; $displyConfigure = ''; $displyGetPrivate = 'none'; } else if($_SESSION['encType'] == "Private" && $_SESSION['configVerified'] === FALSE) { $displySetting = 'none'; $displyConfigure = 'none'; $displyGetPrivate = ''; } else if($_SESSION['encType'] == "Private" && $_SESSION['configVerified'] === true) { $displySetting = ''; $displyConfigure = 'none'; $displyGetPrivate = 'none'; $encTypeSession = ''; } //Redirection path to redirect back after IDrive Signup $signupRedirectPort = ":".$_SERVER['SERVER_PORT']; $signupRedirectURL = urlencode('http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST'].$signupRedirectPort.dirname($_SERVER['PHP_SELF'])); machineBasedContent($machine); isRootLevelDisplayEnabled(); $nasUserShellPerm = hasNASUserShellPermission(); $binaryChk = binaryChk(); ?>
>
Configure your IDrive account with encryption!
IDrive will set an encryption key to encrypt all your data.
Set your own private encryption key to encrypt all your data. On setting this option, you will not be able to share files / folders.
WARNING: IDrive does not store your private encryption key on its servers. It uses a special technique to encrypt your private encryption key that can only be used to verify, but not retrieve it. It is recommended that you archive it safely. Without your private encryption key, you will NOT be able to retrieve your data. We will not be able to provide the private encryption key information.
>

Encryption Key

Provide the same encryption key set by you during your first login.
Do not share the encryption key to ensure your data security.