Пример #1
0
     }
 }
 if (isset($_POST["opt_limitbytraffic"]) && $_POST["opt_limitbytraffic"] == 1) {
     if (!preg_match('/^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/', $_POST['opt_date_trafic']) || empty($_POST['opt_max_trafic'])) {
         $iserr = '<b class="a">Expire-Date Traffic is not a Date..</b><b class="b">!</b><br />';
         $new_options['limitbytraffic'] = false;
     }
 }
 if (isset($_POST["opt_limit_timework"]) && $_POST["opt_limit_timework"] == 1) {
     $regtime = '/^([0-9]{1,2}):([0-5][0-9]):([0-5][0-9])$/';
     if (!preg_match($regtime, $_POST['opt_workstart']) || !preg_match($regtime, $_POST['opt_workend'])) {
         $iserr = '<b class="a">Limit by Time is not a Time format..</b><b class="b">!</b><br />';
         $new_options['limit_timework'] = false;
     }
 }
 isblankfield(isset($_POST['opt_limited_edition']) ? $_POST['opt_limited_edition'] : "", $_POST['opt_list_allow_ip']);
 if (empty($_POST['opt_download_dir'])) {
     $iserr = '<b class="a">Download directory is empty..</b><b class="b">!</b><br />';
     $new_options['download_dir'] = $options['download_dir'];
     // get from the previous config
 }
 if (empty($_POST['newusercp[]']) || empty($_POST['newpascp[]'])) {
     $iserr = '<b class="a">Username or Password login Cpanel is empty..</b><b class="b">!</b><br />';
     $new_options['loginCp'] = $options['loginCp'];
 }
 if (isset($_POST['opt_login']) && $_POST['opt_login'] == 1 && (empty($_POST['users']) || empty($_POST['pass']))) {
     $iserr = '<b class="a">Username or Password login index page is empty..</b><b class="b">!</b><br />';
     $new_options['login'] = false;
 }
 //==========================
 // Build template config.php
Пример #2
0
function write_config_file($config_file, $s)
{
    global $_debug, $close_config_page, $saved_success, $showpostn, $iserr, $day_reset_trafic;
    $ret_TEXT = '';
    $showpostn = true;
    //cek limit by ip
    if (isset($_POST['limitbyip']) && $_POST['limitbyip'] == 'on') {
        if (empty($_POST['max_free_dl'])) {
            $showpostn = true;
            $iserr = '<b class="a">Leeching per ip is empty..</b><b class="b">!</b><br>';
            return false;
        } elseif (empty($_POST['delayip'])) {
            $showpostn = true;
            $iserr = '<b class="a">Delay per ip is empty..</b><b class="b">!</b><br>';
            return false;
        }
    }
    if (isset($_POST["limitbytraffic"]) && $_POST["limitbytraffic"] == "on") {
        if (!preg_match('/^\\d{1,2}\\/\\d{1,2}\\/\\d{4}$/', $_POST['YetAnotherDate']) || empty($_POST['max_trafic'])) {
            $iserr = '<b class="a">Expire-Date Traffic is not a Date..</b><b class="b">!</b><br>';
            return false;
        }
    }
    if (isset($_POST["limit_timework"]) && $_POST["limit_timework"] == "on") {
        $regtime = '/^([0-9]{1,2}):([0-5][0-9]):([0-5][0-9])$/';
        if (!preg_match($regtime, $_POST['workstart']) || !preg_match($regtime, $_POST['workend'])) {
            $iserr = '<b class="a">Limit by Time is not a Time format..</b><b class="b">!</b><br>';
            return false;
        }
    }
    isblankfield(isset($_POST['limited_edition']) ? $_POST['limited_edition'] : "", $_POST['list_allow_ip']);
    if (empty($_POST['dir'])) {
        $showpostn = true;
        $iserr = '<b class="a">Download directory is empty..</b><b class="b">!</b><br>';
        return false;
    }
    if (empty($_POST['newusercp']) || empty($_POST['newpascp'])) {
        $showpostn = true;
        $iserr = '<b class="a">Username or Password login Cpanel is empty..</b><b class="b">!</b><br>';
        return false;
    }
    if (isset($_POST['login']) && $_POST['login'] == 'on' && (empty($_POST['user']) || empty($_POST['pass']))) {
        $showpostn = true;
        $iserr = '<b class="a">Username or Password login index page is empty..</b><b class="b">!</b><br>';
        return false;
    }
    if ($_debug) {
        $ret_TEXT .= "Debug Mode: <b class=a>ON</b><br>";
        $ret_TEXT .= "<textarea name=\"edit_text\" cols=\"122\" rows=\"20\" width=\"100%\" readonly>" . $s . "</textarea>";
    }
    $close_config_page = true;
    $saved_success = false;
    if (!$iserr) {
        $fp = @fopen($config_file, "w");
        $lip = $_POST["mip_list"];
        $fp2 = @fopen(LOG_DIR . "mip_iplist.txt", "w");
        if (!$fp) {
            $showpostn = true;
            $ret_TEXT .= "<b class=\"a\">Can't write to file..</b><b class=\"b\">!</b><br>";
            fclose($fp);
            return false;
        } else {
            @fwrite($fp, $s);
            fclose($fp);
            // saving mip list
            if ($fp2) {
                fwrite($fp2, $lip);
                fclose($fp2);
            }
            // saving traffic if changed
            if ($day_reset_trafic != $_POST['day_reset_trafic']) {
                $cur_trf = get_traffic(TRAFFIC_LST);
                upd_traffictime($cur_trf[0]);
            }
            $ret_TEXT .= '<p><b style="color:#00FF33">Saved!</b>';
            $saved_success = true;
        }
    } else {
        $ret_TEXT .= "<br>{$iserr}<br><b class=\"a\">An errors occur, configuration is not saved</b><br>";
    }
    $ret_TEXT .= '<div style="height:10px;"></div><input id="btn_back" type="button" onClick="location.href=\'./' . basename($_SERVER['PHP_SELF']) . '?mode=\'" value="Go Back to Config">&nbsp;|&nbsp;<input type="button" onClick="location.href=\'./\'" value="Go to main">';
    return $ret_TEXT;
}