Exemple #1
0
function _xRegister()
{
    global $t, $C;
    require_once 'validator.php';
    $_REQUEST = string_strip_tags($_REQUEST);
    $v =& Validator::Get();
    $v->Register($_REQUEST['return_url'], VT_VALID_HTTP_URL, "The 'URL to Send Traffic' field must be a valid HTTP URL");
    if (!string_is_empty($_REQUEST['return_url'])) {
        require_once 'http.php';
        $http = new HTTP();
        $v->Register($http->GET($_REQUEST['return_url'], null, true), VT_NOT_FALSE, "The 'URL to Send Traffic' does not seem to be working: " . $http->error);
        $_REQUEST['header'] = $http->response_headers;
        $_REQUEST['content'] = $http->body;
    }
    if ($C['flag_req_email'] || !empty($_REQUEST['email'])) {
        $v->Register($_REQUEST['email'], VT_VALID_EMAIL, "The 'E-mail Address' field must be a valid email");
    }
    if ($C['flag_req_site_name'] || !empty($_REQUEST['site_name'])) {
        $v->Register($_REQUEST['site_name'], VT_LENGTH_BETWEEN, "The 'Site Name' field must have between {$C['site_name_min']} and {$C['site_name_max']} characters", array($C['site_name_min'], $C['site_name_max']));
    }
    if ($C['flag_req_site_description'] || !empty($_REQUEST['site_description'])) {
        $v->Register($_REQUEST['site_description'], VT_LENGTH_BETWEEN, "The 'Site Description' field must have between {$C['site_description_min']} and {$C['site_description_max']} characters", array($C['site_description_min'], $C['site_description_max']));
    }
    if ($C['flag_req_icq'] || !empty($_REQUEST['icq'])) {
        $v->Register($_REQUEST['icq'], VT_IS_NUMERIC, "The 'ICQ Number' field must be numeric");
    }
    if ($C['flag_req_nickname'] || !empty($_REQUEST['nickname'])) {
        $v->Register($_REQUEST['nickname'], VT_NOT_EMPTY, "The 'Nickname' field is required");
    }
    if ($C['flag_req_banner'] || !empty($_REQUEST['banner'])) {
        $v->Register($_REQUEST['banner'], VT_VALID_HTTP_URL, "The 'Banner URL' field must be a valid HTTP URL");
        if (!string_is_empty($_REQUEST['banner'])) {
            require_once 'http.php';
            $http = new HTTP();
            $v->Register($http->GET($_REQUEST['banner'], null, true), VT_NOT_FALSE, "The 'Banner URL' does not seem to be working: " . $http->error);
        }
    }
    if ($C['flag_captcha_register']) {
        require_once 'captcha.php';
        $captcha = new Captcha();
        $captcha->Verify();
    }
    $_REQUEST['domain'] = domain_from_url($_REQUEST['return_url']);
    require_once 'dirdb.php';
    $db = new TradeDB();
    $v->Register($db->Exists($_REQUEST['domain']), VT_IS_FALSE, "The site you are trying to register already exists in our database");
    // Check blacklist
    $_REQUEST['server_ip'] = gethostbyname($domain);
    $_REQUEST['dns'] = gethostbyname($domain);
    if (($blacklisted = check_blacklist($_REQUEST)) !== false) {
        $v->SetError("You have matched one or more of our blacklist items and cannot register new trade accounts" . (!empty($blacklisted[1]) ? ": " . $blacklisted[1] : ''));
    }
    // Check category
    $categories = array_map('trim', file(FILE_CATEGORIES));
    if ($C['flag_allow_select_category'] && count($categories)) {
        $v->Register(in_array($_REQUEST['category'], $categories), VT_IS_TRUE, "You have selected an invalid category");
        $_REQUEST['categories'] = array($_REQUEST['category']);
    }
    if (!$v->Validate()) {
        $t->Assign('g_errors', $v->GetErrors());
        return _xRegisterShow();
    }
    $_REQUEST = array_merge($_REQUEST, unserialize(file_get_contents(FILE_NEW_TRADE_DEFAULTS)));
    $password = $_REQUEST['password'] = get_random_password();
    $t->AssignByRef('g_trade', $_REQUEST);
    trade_add($_REQUEST, true);
    $_REQUEST['password'] = $password;
    $t->Display('register-complete.tpl');
}
Exemple #2
0
function _xSync()
{
    $settings = unserialize(base64_decode($_REQUEST['sync']));
    // Sync blacklist
    if (isset($settings[NETWORK_SYNC_BLACKLIST]) && is_array($settings[NETWORK_SYNC_BLACKLIST])) {
        foreach ($settings[NETWORK_SYNC_BLACKLIST] as $bl_file => $file_contents) {
            file_write(DIR_BLACKLIST . '/' . $bl_file, $file_contents);
        }
    }
    // Sync categories
    if (isset($settings[NETWORK_SYNC_CATEGORIES])) {
        file_write(FILE_CATEGORIES, $settings[NETWORK_SYNC_CATEGORIES]);
    }
    // Sync countries
    if (isset($settings[NETWORK_SYNC_COUNTRIES])) {
        file_write(FILE_COUNTRIES, $settings[NETWORK_SYNC_COUNTRIES]);
    }
    // Sync groups
    if (isset($settings[NETWORK_SYNC_GROUPS])) {
        file_write(FILE_GROUPS, $settings[NETWORK_SYNC_GROUPS]);
    }
    // Sync network sites
    if (isset($settings[NETWORK_SYNC_NETWORK_SITES]) && is_array($settings[NETWORK_SYNC_NETWORK_SITES])) {
        require_once 'textdb.php';
        $db = new NetworkDB();
        foreach ($settings[NETWORK_SYNC_NETWORK_SITES] as $site) {
            if ($db->Exists($site['domain'])) {
                $db->Update($site['domain'], $site);
            } else {
                $db->Add($site);
            }
        }
        network_site_update_stored_values();
    }
    // Sync search engines
    if (isset($settings[NETWORK_SYNC_SEARCH_ENGINES])) {
        file_write(FILE_SEARCH_ENGINES, $settings[NETWORK_SYNC_SEARCH_ENGINES]);
    }
    // Sync skim schemes
    if (isset($settings[NETWORK_SYNC_SKIM_SCHEMES]) && is_array($settings[NETWORK_SYNC_SKIM_SCHEMES])) {
        foreach ($settings[NETWORK_SYNC_SKIM_SCHEMES] as $scheme => $ss_file) {
            file_write(DIR_SKIM_SCHEMES . '/' . $scheme, $ss_file['merged']);
            file_write(DIR_SKIM_SCHEMES_BASE . '/' . $scheme, $ss_file['base']);
            file_write(DIR_SKIM_SCHEMES_DYNAMIC . '/' . $scheme, $ss_file['dynamic']);
        }
    }
    // Sync trades
    if (isset($settings[NETWORK_SYNC_TRADES]) && is_array($settings[NETWORK_SYNC_TRADES])) {
        require_once 'dirdb.php';
        $db = new TradeDB();
        foreach ($settings[NETWORK_SYNC_TRADES] as $trade) {
            if ($db->Exists($trade['domain'])) {
                // Update existing
                $db->Update($trade['domain'], $trade);
            } else {
                // Create new, no confirmation
                $trade['flag_confirm'] = 0;
                trade_add($trade);
            }
        }
    }
    // Sync trade rules
    if (isset($settings[NETWORK_SYNC_TRADE_RULES])) {
        file_write(FILE_TRADE_RULES, $settings[NETWORK_SYNC_TRADE_RULES]);
    }
    network_success(true);
}
Exemple #3
0
function _xTradesAdd()
{
    global $C;
    $C['flag_register_email_admin'] = false;
    require_once 'dirdb.php';
    $db = new TradeDB();
    $domain = domain_from_url($_REQUEST['return_url']);
    $v = Validator::Get();
    $v->Register($_REQUEST['return_url'], VT_VALID_HTTP_URL, 'The Return URL must be a valid HTTP URL');
    if (!empty($domain)) {
        $v->Register($db->Exists($domain), VT_IS_FALSE, 'The trade you are trying to add already exists');
    }
    if (!$v->Validate()) {
        return JSON::Warning(array(JSON_KEY_MESSAGE => 'Trade could not be added; please fix the following items', JSON_KEY_WARNINGS => $v->GetErrors()));
    }
    $_REQUEST['domain'] = $domain;
    trade_add($_REQUEST);
    _xTradesAddShow('Trade has been successfully added');
}