}
if (isset($_POST['save']) && $_POST['save']) {
    unset($input_errors);
    if (empty($input_errors)) {
        $config['onebuttoninstaller']['enable'] = isset($_POST['enable']) ? true : false;
        if (isset($_POST['enable'])) {
            $config['onebuttoninstaller']['storage_path'] = !empty($_POST['storage_path']) ? $_POST['storage_path'] : $g['media_path'];
            $config['onebuttoninstaller']['storage_path'] = rtrim($config['onebuttoninstaller']['storage_path'], '/');
            // ensure to have NO trailing slash
            if (!isset($_POST['path_check']) && strpos($config['onebuttoninstaller']['storage_path'], "/mnt/") === false) {
                $input_errors[] = gettext("The common directory for all extensions MUST be set to a directory below <b>'/mnt/'</b> to prevent to loose the extensions after a reboot on embedded systems!");
            } else {
                if (!is_dir($config['onebuttoninstaller']['storage_path'])) {
                    mkdir($config['onebuttoninstaller']['storage_path'], 0775, true);
                }
                change_perms($_POST['storage_path']);
                $config['onebuttoninstaller']['path_check'] = isset($_POST['path_check']) ? true : false;
                $config['onebuttoninstaller']['re_install'] = isset($_POST['re_install']) ? true : false;
                $config['onebuttoninstaller']['auto_update'] = isset($_POST['auto_update']) ? true : false;
                $config['onebuttoninstaller']['show_beta'] = isset($_POST['show_beta']) ? true : false;
                $savemsg .= get_std_save_message(write_config()) . " ";
                require_once "{$config['onebuttoninstaller']['rootfolder']}onebuttoninstaller-start.php";
            }
        } else {
            $savemsg .= get_std_save_message(write_config()) . " ";
        }
    }
    // end of empty input_errors
}
$pconfig['enable'] = isset($config['onebuttoninstaller']['enable']) ? true : false;
$pconfig['storage_path'] = !empty($config['onebuttoninstaller']['storage_path']) ? $config['onebuttoninstaller']['storage_path'] : $g['media_path'];
     // Check port range.
     if ($_POST['port'] && (1024 > $_POST['port'] || 65535 < $_POST['port'])) {
         $input_errors[] = sprintf(gettext("The attribute '%s' must be in the range from %d to %d."), gettext("Port"), 1024, 65535);
     }
     // Check directories (if exist & permisssions)
     if (!empty($_POST['incompletedir'])) {
         change_perms($_POST['incompletedir']);
     }
     if (!empty($_POST['watchdir'])) {
         change_perms($_POST['watchdir']);
     }
     if (!empty($_POST['downloaddir'])) {
         change_perms($_POST['downloaddir']);
     }
     if (!empty($_POST['configdir'])) {
         change_perms($_POST['configdir']);
     }
 }
 if (empty($input_errors)) {
     $config['bittorrent']['enable'] = isset($_POST['enable']) ? true : false;
     $config['bittorrent']['port'] = $_POST['port'];
     $config['bittorrent']['downloaddir'] = strlen($_POST['downloaddir']) > 1 ? rtrim($_POST['downloaddir'], '/') : $_POST['downloaddir'];
     $config['bittorrent']['configdir'] = strlen($_POST['configdir']) > 1 ? rtrim($_POST['configdir'], '/') : $_POST['configdir'];
     $config['bittorrent']['username'] = $_POST['username'];
     $config['bittorrent']['password'] = $_POST['password'];
     $config['bittorrent']['authrequired'] = isset($_POST['authrequired']) ? true : false;
     $config['bittorrent']['peerport'] = $_POST['peerport'];
     $config['bittorrent']['portforwarding'] = isset($_POST['portforwarding']) ? true : false;
     $config['bittorrent']['uplimit'] = $_POST['uplimit'];
     $config['bittorrent']['downlimit'] = $_POST['downlimit'];
     $config['bittorrent']['pex'] = isset($_POST['pex']) ? true : false;
Beispiel #3
0
 /**
  * Method to change the permission for files recursively
  *
  * @param $dir
  * @param null $mod
  * @param bool $recursive
  * @return array $errors
  */
 function chmodDirFiles($dir, $mod = null, $recursive = true)
 {
     $errors = [];
     chmod($dir, 0755);
     if ($recursive && ($objs = glob($dir . DIRECTORY_SEPARATOR . "*"))) {
         foreach ($objs as $file) {
             if (is_dir($file)) {
                 chmodDirFiles($file, $mod, $recursive);
             } else {
                 if (!change_perms($file, decoct($mod))) {
                     $errors[] = $file;
                 }
             }
         }
     }
     return $errors;
 }
        }
    }
}
if (isset($_POST['save']) && $_POST['save']) {
    unset($input_errors);
    if (empty($input_errors)) {
        $config['onebuttoninstaller']['storage_path'] = !empty($_POST['storage_path']) ? $_POST['storage_path'] : $g['media_path'];
        $config['onebuttoninstaller']['storage_path'] = rtrim($config['onebuttoninstaller']['storage_path'], '/');
        // ensure to have NO trailing slash
        if (!isset($_POST['path_check']) && strpos($config['onebuttoninstaller']['storage_path'], "/mnt/") === false) {
            $input_errors[] = gettext("The common directory for all extensions MUST be set to a directory below <b>'/mnt/'</b> to prevent to loose the extensions after a reboot on embedded systems!");
        } else {
            if (!is_dir($config['onebuttoninstaller']['storage_path'])) {
                mkdir($config['onebuttoninstaller']['storage_path'], 0775, true);
            }
            change_perms($config['onebuttoninstaller']['storage_path']);
            $config['onebuttoninstaller']['path_check'] = isset($_POST['path_check']) ? true : false;
            $install_dir = $config['onebuttoninstaller']['storage_path'] . "/";
            // get directory where the installer script resides
            if (!is_dir("{$install_dir}onebuttoninstaller/log")) {
                mkdir("{$install_dir}onebuttoninstaller/log", 0775, true);
            }
            $return_val = mwexec("fetch {$verify_hostname} -vo {$install_dir}onebuttoninstaller/onebuttoninstaller-install.php 'https://raw.github.com/crestAT/nas4free-onebuttoninstaller/master/onebuttoninstaller/onebuttoninstaller-install.php'", true);
            if ($return_val == 0) {
                chmod("{$install_dir}onebuttoninstaller/onebuttoninstaller-install.php", 0775);
                require_once "{$install_dir}onebuttoninstaller/onebuttoninstaller-install.php";
            } else {
                $input_errors[] = sprintf(gettext("Installation file %s not found, installation aborted!"), "{$install_dir}onebuttoninstaller/onebuttoninstaller-install.php");
                return;
            }
            mwexec("rm -Rf ext/OBI; rm -f OBI.php", true);