示例#1
0
 unset($input_errors);
 $pconfig = $_POST;
 // Input validation.
 if (isset($_POST['enable']) && $_POST['enable']) {
     $reqdfields = explode(" ", "port documentroot");
     $reqdfieldsn = array(gettext("Port"), gettext("Document root"));
     $reqdfieldst = explode(" ", "port string");
     if ("https" === $_POST['protocol']) {
         $reqdfields = array_merge($reqdfields, explode(" ", "certificate privatekey"));
         $reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Certificate"), gettext("Private key")));
         $reqdfieldst = array_merge($reqdfieldst, explode(" ", "certificate privatekey"));
     }
     do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
     do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, $input_errors);
     // Check if port is already used.
     if (services_is_port_used($_POST['port'], "websrv")) {
         $input_errors[] = sprintf(gettext("Port %ld is already used by another service."), $_POST['port']);
     }
     // Check Webserver document root if auth is required
     if (isset($_POST['authentication']) && !is_dir($_POST['documentroot'])) {
         $input_errors[] = gettext("Webserver document root is missing.");
     }
 }
 if (empty($input_errors)) {
     $config['websrv']['enable'] = isset($_POST['enable']) ? true : false;
     $config['websrv']['protocol'] = $_POST['protocol'];
     $config['websrv']['port'] = $_POST['port'];
     $config['websrv']['documentroot'] = $_POST['documentroot'];
     $config['websrv']['uploaddir'] = $_POST['uploaddir'];
     $config['websrv']['runasuser'] = $_POST['runasuser'];
     $config['websrv']['privatekey'] = base64_encode($_POST['privatekey']);
示例#2
0
 if ($_POST['ipv6dns1'] && !is_ipv6addr($_POST['ipv6dns1']) || $_POST['ipv6dns2'] && !is_ipv6addr($_POST['ipv6dns2'])) {
     $input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary DNS server.");
 }
 if (isset($_POST['ntp_enable'])) {
     $t = (int) $_POST['ntp_updateinterval'];
     if ($t < 0 || $t > 0 && $t < 6 || $t > 1440) {
         $input_errors[] = gettext("The time update interval must be either between 6 and 1440.");
     }
     foreach (explode(' ', $_POST['ntp_timeservers']) as $ts) {
         if (!is_domain($ts)) {
             $input_errors[] = gettext("A NTP time server name may only contain the characters a-z, 0-9, '-' and '.'.");
         }
     }
 }
 // Check if port is already used.
 if (services_is_port_used(!empty($_POST['webguiport']) ? $_POST['webguiport'] : 80, "sysgui")) {
     $input_errors[] = sprintf(gettext("Port %ld is already used by another service."), !empty($_POST['webguiport']) ? $_POST['webguiport'] : 80);
 }
 // Check Webserver document root if auth is required
 if (isset($config['websrv']['enable']) && isset($config['websrv']['authentication']['enable']) && !is_dir($config['websrv']['documentroot'])) {
     $input_errors[] = gettext("Webserver document root is missing.");
 }
 if (empty($input_errors)) {
     // Store old values for later processing.
     $oldcert = $config['system']['webgui']['certificate'];
     $oldkey = $config['system']['webgui']['privatekey'];
     $oldwebguiproto = $config['system']['webgui']['protocol'];
     $oldwebguiport = $config['system']['webgui']['port'];
     $oldwebguihostsallow = $config['system']['webgui']['hostsallow'];
     $oldlanguage = $config['system']['language'];
     $config['system']['hostname'] = strtolower($_POST['hostname']);
}
if ($_POST) {
    unset($input_errors);
    $pconfig = $_POST;
    // Input validation.
    if ($_POST['enable']) {
        $reqdfields = explode(" ", "servername port dbdir content admin_pw");
        $reqdfieldsn = array(gettext("Server name"), gettext("Port"), gettext("Database directory"), gettext("Content"), gettext("Password"));
        $reqdfieldst = explode(" ", "string port string array password");
        do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
        $reqdfields = array_merge($reqdfields, array("rescaninterval"));
        $reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Rescan interval")));
        $reqdfieldst = array_merge($reqdfieldst, array("numeric"));
        do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, &$input_errors);
        // Check if port is already used.
        if (services_is_port_used($_POST['port'], "daap")) {
            $input_errors[] = sprintf(gettext("Port %ld is already used by another service."), $_POST['port']);
        }
    }
    if (!$input_errors) {
        $config['daap']['enable'] = $_POST['enable'] ? true : false;
        $config['daap']['servername'] = $_POST['servername'];
        $config['daap']['port'] = $_POST['port'];
        $config['daap']['dbdir'] = $_POST['dbdir'];
        $config['daap']['content'] = $_POST['content'];
        $config['daap']['rescaninterval'] = $_POST['rescaninterval'];
        $config['daap']['alwaysscan'] = $_POST['alwaysscan'] ? true : false;
        $config['daap']['scantype'] = $_POST['scantype'];
        $config['daap']['admin_pw'] = $_POST['admin_pw'];
        write_config();
        $retval = 0;
示例#4
0
     // !!! Note !!! It seems TransmissionBT does not support special characters,
     // so use 'alias' instead of 'password' check.
     $reqdfields = array_merge($reqdfields, explode(" ", "username password"));
     $reqdfieldsn = array_merge($reqdfieldsn, array(gettext("Username"), gettext("Password")));
     $reqdfieldst = array_merge($reqdfieldst, explode(" ", "alias alias"));
 }
 do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
 // Add additional type checks
 if (isset($_POST['umask'])) {
     $reqdfields = array_merge($reqdfields, explode(" ", "umask"));
     $reqdfieldsn = array_merge($reqdfieldsn, array(gettext("User mask")));
     $reqdfieldst = array_merge($reqdfieldst, explode(" ", "filemode"));
 }
 do_input_validation_type($_POST, $reqdfields, $reqdfieldsn, $reqdfieldst, $input_errors);
 // Check if port is already used.
 if (services_is_port_used($_POST['port'], "bittorrent")) {
     $input_errors[] = sprintf(gettext("Port %ld is already used by another service."), $_POST['port']);
 }
 // 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']);