Files
resatennis_tyroltenn/IDrive/.config/addPreferences.php

196 lines
6.2 KiB
PHP
Executable File

<?php
require_once 'path.php';
if(!isset($_SESSION['validUser']) || $_SESSION['validUser'] !== true)
{
header("Location:../index.php");
exit();
}
$pageSubmitted = false;
$partialData = array();
$fullData = array();
unset($_SESSION['partialEntry']);
unset($_SESSION['fullEntry']);
if($_SESSION['validUser'] === true)
{
if($_POST)
{
if($userName!='' && $_POST["backupLocation"] != ""){
if(file_exists($excludePartialFilePath))
unlink($excludePartialFilePath);
if(file_exists($excludeFullFile))
unlink($excludeFullFile);
if($_POST['hiddenStatus']==2){
file_put_contents($excludePartialFilePath, "\/.\n");
@chmod($excludePartialFilePath, $permissionVal);
$_SESSION['showHidden']="Hide";
}
else if($_POST['hiddenStatus']==1)
$_SESSION['showHidden']="Show";
if($_POST['hiddenEngineStatus']==2){
$_SESSION['multipleEngineEnable']="2";
}
else{
$_SESSION['multipleEngineEnable']="4";
}
if(isset($_POST['selectedPartial']) && ($_POST['selectedPartial'] != "")) {
$i=0;
foreach($_POST['selectedPartial'] as $selectedPartial)
{
$selectedPartial = phpRealEscapeString($selectedPartial);
$_SESSION['partialEntry'][$i] = $selectedPartial;
file_put_contents($excludePartialFilePath, $selectedPartial."\n", FILE_APPEND);
$i++;
}
@chmod($excludePartialFilePath, $permissionVal);
}
$isRootLevel = (int)$_POST['displayRoot'];
if($isRootLevel != isRootLevelDisplayEnabled()){
unset($_SESSION['sharedDirectoriesRaw']);
file_put_contents(Scheduler::$user_dir . DISPLAY_ROOT_FILENAME, $isRootLevel);
}
@chmod(Scheduler::$user_dir . DISPLAY_ROOT_FILENAME,$permissionVal);
if($_POST['selectedFull'] != "") {
$selectedFull = $_POST['selectedFull'];
$imgType = $_POST['imgType'];
# Checking whether first entry of POST is working directory
/*$servicePath = getOriginalServicePath();
if(checkServicePath($servicePath, phpRealEscapeString(trim($selectedFull[0],"\n")))) {
$_SESSION['fullEntry'][] = $servicePath;
$_SESSION['fullEntry'][] = 'folder';
$_SESSION['fullEntry'][] = "undefined";
$_SESSION['fullEntry'][] = "undefined";
file_put_contents($excludeFullFile, $servicePath . "\n" . "folder\nundefined\nundefined\n");
# if first entry is servie directory just shift 1 element from type and path array
array_shift($selectedFull);
array_shift($imgType);
}*/
foreach($selectedFull as $index => $selectedFile) {
$selectedFile = phpRealEscapeString($selectedFile);
if(substr($selectedFile, -1) == "/")
$entry = substr($selectedFile, 0, -1);
else
$entry = $selectedFile;
$entry = trim($entry,"\n");
$imgType[$index] = trim($imgType[$index],"\n");
# Make sure it doesn't cause any duplicate entries
if(isset($_SESSION['fullEntry']) && in_array($entry, $_SESSION['fullEntry']))
continue;
$_SESSION['fullEntry'][] = $entry;
$_SESSION['fullEntry'][] = $imgType[$index];
$_SESSION['fullEntry'][] = "undefined";
$_SESSION['fullEntry'][] = "undefined";
file_put_contents($excludeFullFile, ($entry ."\n" . $imgType[$index] . "\nundefined\nundefined\n"), FILE_APPEND);
}
@chmod($excludeFullFile, $permissionVal);
}
/* Update backup location to mpc.txt */
update_mpc($_POST["backupLocation"]);
/* Proxy Settings - Start */
$accountSettingsFilePath = Scheduler::$user_dir."ACCOUNT_SETTINGS_FILE";
$accountSettingsData = readAccountSettingsFile();
$accountSettingsData['engineCount'] = 2;
if($_POST['hiddenEngineStatus']!=2)
$accountSettingsData['engineCount'] = 4;
if($_POST["proxy_option"]!='No-Proxy' && $_POST["ipAddress"] != "")
{
if(($file = fopen($accountSettingsFilePath, "a+")) != FALSE)
{
$accountSettingsData['PROXY'] = urlencode($_POST["userName"]).":".urlencode(base64_decode($_POST["password"]))."@".$_POST["ipAddress"].":".$_POST["port"];
ftruncate($file, 0);
fwrite($file, json_encode($accountSettingsData,TRUE));
fclose($file);
@chmod($accountSettingsFilePath, $permissionVal);
$_SESSION['proxy_option'] = $_POST["proxy_option"]=='autodetect'?'autodetect':'Manual';
$_SESSION['ipAddress'] = $_POST["ipAddress"];
$_SESSION['port'] = $_POST["port"];
$_SESSION['proxyUserName']= $_POST["userName"];
$_SESSION['proxyPassword']= $_POST["password"];
}
else
{
print "File ".ACCOUNT_SETTINGS_FILE." could not be opened successfully";
exit;
}
} else {
if(($file = fopen($accountSettingsFilePath, "a+")) != FALSE)
{
$accountSettingsData['PROXY'] = '';
ftruncate($file, 0);
fwrite($file, json_encode($accountSettingsData,TRUE));
fclose($file);
@chmod($accountSettingsFilePath, $permissionVal);
}
}
unsetProxySessions();
//}
/* For Bandwidth throttle - Start*/
$bandwidthFilePath = Scheduler::$user_dir.BW_FILE;
$bandWidth = $_POST["bandWidth"];
if($bandWidth == 100 || $bandWidth == "")
{
if(file_exists($bandwidthFilePath)){ unlink($bandwidthFilePath); }
}
else
{
file_put_contents($bandwidthFilePath, $bandWidth);
@chmod($bandwidthFilePath, $permissionVal);
}
/* For Bandwidth throttle - End*/
/* Proxy Settings - End */
/* Relative/Mirror Path Settings - Start */
$relativeFile = Scheduler::$user_dir.RELATIVE_FILE;
if($_POST["pathType"])
{
$pathtypeToset = "--".$_POST["pathType"];
file_put_contents($relativeFile, $pathtypeToset);
@chmod($relativeFile, $permissionVal);
} else if(file_exists($relativeFile))
unlink($relativeFile);
/* Relative/Mirror Path Settings - End */
print PREFERENCES_SUCC;
exit();
} else {
$_SESSION['proxy_option']=$_POST["proxy_option"];
if($_POST["proxy_option"]=='Manual' || $_POST["proxy_option"]=='autodetect'){
$_SESSION['ipAddress']=$_POST["ipAddress"];
$_SESSION['port']=$_POST["port"];
$_SESSION['proxyUserName']=$_POST["userName"];
$_SESSION['proxyPassword']=$_POST["password"];
}
else
unsetProxySessions();
}
}
}
?>