Example #1
0
function txGeneralSettingsSave()
{
    global $C;
    VerifyAdministrator();
    CheckAccessList();
    $server = GetServerCapabilities();
    $GLOBALS['_server_'] = $server;
    $v = new Validator();
    $required = array('document_root' => 'Document Root', 'install_url' => 'TGPX URL', 'cookie_domain' => 'Cookie Domain', 'from_email' => 'E-mail Address', 'from_email_name' => 'E-mail Name', 'date_format' => 'Date Format', 'time_format' => 'Time Format', 'dec_point' => 'Decimal Point', 'thousands_sep' => 'Thousands Separator', 'max_submissions' => 'Global Submissions Per Day', 'submissions_per_person' => 'Submissions Per Person', 'max_links' => 'Maximum Links Allowed', 'min_desc_length' => 'Minimum Description Length', 'max_desc_length' => 'Maximum Description Length', 'min_thumb_size' => 'Minimum Gallery Thumb Size', 'max_thumb_size' => 'Maximum Gallery Thumb Size', 'max_keywords' => 'Maximum Keywords', 'gallery_weight' => 'Default Gallery Weight', 'font_dir' => 'Font Directory', 'min_code_length' => 'Minimum Code Length', 'max_code_length' => 'Maximum Code Length', 'permanent_hold' => 'Permanent Holding Period', 'submitted_hold' => 'Submitted Holding Period', 'page_permissions' => 'Page Permissions');
    if ($_REQUEST['allow_multiple_cats']) {
        $required['max_categories'] = 'Maximum Categories';
    }
    foreach ($required as $field => $name) {
        $v->Register($_REQUEST[$field], V_EMPTY, "The {$name} field is required");
    }
    $v->Register($_REQUEST['min_thumb_size'], V_REGEX, "The 'Minimum Gallery Thumb Size' value must be in WxH format", '~\\d+x\\d+~');
    $v->Register($_REQUEST['max_thumb_size'], V_REGEX, "The 'Maximum Gallery Thumb Size' value must be in WxH format", '~\\d+x\\d+~');
    if (!$v->Validate()) {
        $C = array_merge($C, $_REQUEST);
        return $v->ValidationError('txShGeneralSettings');
    }
    if (!isset($_REQUEST['compression'])) {
        $_REQUEST['compression'] = 80;
    }
    list($_REQUEST['min_thumb_width'], $_REQUEST['min_thumb_height']) = explode('x', trim($_REQUEST['min_thumb_size']));
    list($_REQUEST['max_thumb_width'], $_REQUEST['max_thumb_height']) = explode('x', trim($_REQUEST['max_thumb_size']));
    $_REQUEST['document_root'] = preg_replace('~/$~', '', $_REQUEST['document_root']);
    $_REQUEST['install_url'] = preg_replace('~/$~', '', $_REQUEST['install_url']);
    $_REQUEST['preview_url'] = preg_replace('~/$~', '', $_REQUEST['preview_url']);
    $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']);
    $_REQUEST['preview_dir'] = DirectoryFromRoot($_REQUEST['document_root'], $_REQUEST['preview_url']);
    $_REQUEST = array_merge($server, $_REQUEST);
    WriteConfig($_REQUEST);
    CleanupThumbSizes();
    $GLOBALS['message'] = 'Your settings have been successfully updated';
    txShGeneralSettings();
}
Example #2
0
function tlxGeneralSettingsSave()
{
    global $C;
    VerifyAdministrator();
    CheckAccessList();
    $server = GetServerCapabilities();
    $GLOBALS['_server_'] = $server;
    $v = new Validator();
    $required = array('document_root' => 'Document Root', 'install_url' => 'ToplistX URL', 'cookie_domain' => 'Cookie Domain', 'from_email' => 'E-mail Address', 'from_email_name' => 'E-mail Name', 'date_format' => 'Date Format', 'time_format' => 'Time Format', 'dec_point' => 'Decimal Point', 'thousands_sep' => 'Thousands Separator', 'secret_key' => 'Secret Key', 'forward_url' => 'Default Forward URL', 'alternate_out_url' => 'Alternate Out URL', 'redirect_code' => 'Redirect Status Code', 'max_rating' => 'Maximum Site Rating', 'min_comment_length' => 'Minimum Comment Length', 'max_comment_length' => 'Maximum Comment Length', 'comment_interval' => 'Comment Interval', 'min_desc_length' => 'Minimum Description Length', 'max_desc_length' => 'Maximum Description Length', 'max_keywords' => 'Maximum Keywords', 'return_percent' => 'Default Return Percent', 'banner_max_width' => 'Maximum Banner Width', 'banner_max_height' => 'Maximum Banner Height', 'banner_max_bytes' => 'Maximum Banner Filesize', 'font_dir' => 'Font Directory', 'min_code_length' => 'Minimum Code Length', 'max_code_length' => 'Maximum Code Length');
    if (!$_REQUEST['using_cron']) {
        $required['rebuild_interval'] = 'Rebuild Interval';
        $v->Register($_REQUEST['rebuild_interval'], V_GREATER_EQ, 'The Rebuild Interval must be 60 or larger', 60);
    }
    foreach ($required as $field => $name) {
        $v->Register($_REQUEST[$field], V_EMPTY, "The {$name} field is required");
    }
    $_REQUEST['return_percent'] /= 100;
    $_REQUEST['document_root'] = preg_replace('~/$~', '', $_REQUEST['document_root']);
    $_REQUEST['install_url'] = preg_replace('~/$~', '', $_REQUEST['install_url']);
    $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $_SERVER['HTTP_HOST']);
    $_REQUEST['banner_dir'] = DirectoryFromRoot($_REQUEST['document_root'], $_REQUEST['banner_url']);
    if (!$v->Validate()) {
        $C = array_merge($C, $_REQUEST);
        return $v->ValidationError('tlxShGeneralSettings');
    }
    $_REQUEST = array_merge($server, $_REQUEST);
    WriteConfig($_REQUEST);
    $GLOBALS['message'] = 'Your settings have been successfully updated';
    tlxShGeneralSettings();
}