1) { if (!is_dir($path)) { // Check if directory exists. $input_errors[] = sprintf(gtext("Directory %s doesn't exist!"), $path); } else { $path_check = explode("/", $path); // Split path to get directory names. $path_elements = count($path_check); // Get path depth. $fp = substr(sprintf('%o', fileperms("/$path_check[1]/$path_check[2]")), -1); // Get mountpoint permissions for others. if ($fp >= 5) { // Some applications needs at least read & search permission at the mountpoint. $directory = "/$path_check[1]/$path_check[2]"; // Set to the mountpoint. for ($i = 3; $i < $path_elements - 1; $i++) { // Traverse the path and set permissions to rx. $directory = $directory."/$path_check[$i]"; // Add next level. exec("chmod o=+r+x \"$directory\""); // Set permissions to o=+r+x. } $path_elements = $path_elements - 1; $directory = $directory."/$path_check[$path_elements]"; // Add last level. exec("chmod 775 {$directory}"); // Set permissions to 775. //exec("chown {$_POST['who']} {$directory}*"); // This is not yet functional. } else { $input_errors[] = sprintf(gtext("%s needs at least read & execute permissions at the mount point for directory %s! Set the Read and Execute bits for Others (Access Restrictions | Mode) for the mount point %s (in Disks | Mount Point | Management or Disks | ZFS | Datasets) and hit Save in order to take them effect."), $application, $path, "/{$path_check[1]}/{$path_check[2]}"); } } } } if (isset($_POST['save-install']) && $_POST['save-install']) { unset($input_errors); if (empty($input_errors)) { $config['plex']['storage_path'] = !empty($_POST['storage_path']) ? $_POST['storage_path'] : $g['media_path']; $config['plex']['storage_path'] = rtrim($config['plex']['storage_path'],'/'); // Ensure to have NO trailing slash. if (!isset($_POST['path_check']) && (strpos($config['plex']['storage_path'], "/mnt/") === false)) { $input_errors[] = gtext("The common directory for extensions MUST be set to a directory below '/mnt/' to prevent to loose the extension after a reboot on embedded systems!"); } else { if (!is_dir($config['plex']['storage_path'])) mkdir($config['plex']['storage_path'], 0775, true); change_perms($config['plex']['storage_path']); $config['plex']['path_check'] = isset($_POST['path_check']) ? true : false; $install_dir = $config['plex']['storage_path']."/"; // Get directory where the installer script resides. if (!is_dir("{$install_dir}plex/log")) { mkdir("{$install_dir}plex/log", 0775, true); } $return_val = mwexec("fetch -avo {$install_dir}plex/plexinit --no-verify-peer --timeout=30 {$git_url}", true); if ($return_val == 0) { // Perform cleanup for obsolete files on upgrade/reinstall. if (is_file("plex-gui.php")) { if (is_file("{$install_dir}plex/version")) unlink("{$install_dir}plex/version"); if (is_dir("{$install_dir}plex/conf")) exec("rm -rf {$install_dir}plex/conf"); if (is_dir("{$install_dir}plex/gui")) exec("rm -rf {$install_dir}plex/gui"); if (is_dir("{$install_dir}plex/locale-plex")) exec("rm -rf {$install_dir}plex/locale-plex"); if (is_dir("ext/plex-gui")) exec("rm -rf ext/plex-gui"); if (is_file("plex-gui.php")) unlink("plex-gui.php"); } chmod("{$install_dir}plex/plexinit", 0775); exec("sh {$install_dir}plex/plexinit -o"); exec("php {$install_dir}plex/postinit"); if (is_file("{$install_dir}plex/postinit")) unlink("{$install_dir}plex/postinit"); exec("echo '{$date}: {$application} extension successfully installed' > {$install_dir}plex/log/{$logfile}"); } else { $input_errors[] = sprintf(gtext("Installation file %s not found, installation aborted!"), "{$install_dir}plex/plexinit"); return; } mwexec("rm -rf ext/plex-install; rm -f plex-install.php", true); header("Location:plex-gui.php"); } } } if (isset($_POST['cancel']) && $_POST['cancel']) { $return_val = mwexec("rm -rf ext/plex-install; rm -f plex-install.php", true); if (is_dir("ext")) exec("if [ ! $(ls -A ext) ]; then rm -r ext; fi"); if ($return_val == 0) { $savemsg .= $application." ".gtext("not installed"); } else { $input_errors[] = $application." removal failed"; } header("Location:index.php"); } $pconfig['storage_path'] = !empty($config['plex']['storage_path']) ? $config['plex']['storage_path'] : $g['media_path']; $pconfig['path_check'] = isset($config['plex']['path_check']) ? true : false; include("fbegin.inc"); ?>