当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::SetError方法代码示例

本文整理汇总了PHP中Validator::SetError方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::SetError方法的具体用法?PHP Validator::SetError怎么用?PHP Validator::SetError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator::SetError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: txReportAdd

function txReportAdd()
{
    global $DB, $C, $L, $t, $domain;
    $gallery = $DB->Row('SELECT * FROM `tx_galleries` WHERE `gallery_id`=?', array($_REQUEST['id']));
    $v = new Validator();
    $v->Register($_REQUEST['reason'], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $L['REPORT']));
    if (!$gallery) {
        $v->SetError($L['BAD_GALLERY_ID']);
    }
    if ($C['report_captcha']) {
        VerifyCaptcha($v);
    }
    if (!$v->Validate()) {
        return $v->ValidationError('txShReportAdd', TRUE);
    }
    $DB->Update('INSERT INTO `tx_reports` VALUES (?,?,?,?,?)', array(null, $gallery['gallery_id'], $_SERVER['REMOTE_ADDR'], MYSQL_NOW, $_REQUEST['reason']));
    $_REQUEST['report_id'] = $DB->InsertID();
    $t->assign_by_ref('report', $_REQUEST);
    $t->display($domain['template_prefix'] . 'report-complete.tpl');
    flush();
    // See if we need to e-mail any administrators
    $reports_waiting = $DB->Count('SELECT COUNT(*) FROM `tx_reports`');
    $t->assign('reports_waiting', $reports_waiting);
    $administrators =& $DB->FetchAll('SELECT * FROM `tx_administrators`');
    foreach ($administrators as $administrator) {
        if ($administrator['reports_waiting'] > 0) {
            if ($administrator['notifications'] & E_CHEAT_REPORT && $reports_waiting % $administrator['reports_waiting'] == 0) {
                SendMail($administrator['email'], 'email-admin-reports.tpl', $t);
            }
        }
    }
}
开发者ID:Cyberspace-Networks,项目名称:TGPX,代码行数:32,代码来源:report.php

示例2: txAddGallery

function txAddGallery()
{
    global $DB, $C, $L, $t, $domain;
    // Set some default values
    $defaults = array('weight' => $C['gallery_weight'], 'clicks' => 0, 'submit_ip' => $_SERVER['REMOTE_ADDR'], 'sponsor_id' => null, 'type' => 'submitted', 'format' => $C['allow_format'] ? $_REQUEST['format'] : FMT_PICTURES, 'status' => 'pending', 'previous_status' => null, 'date_scanned' => MYSQL_NOW, 'date_added' => MYSQL_NOW, 'date_approved' => null, 'date_scheduled' => null, 'date_displayed' => null, 'date_deletion' => null, 'allow_scan' => 1, 'allow_preview' => 1, 'has_preview' => 0, 'times_selected' => 0, 'used_counter' => 0, 'build_counter' => 0, 'tags' => $domain['tags']);
    $_REQUEST = array_merge($_REQUEST, $defaults);
    $v = new Validator();
    // Verify and grab partner account
    $partner = null;
    if (!IsEmptyString($_REQUEST['username']) || !IsEmptyString($_REQUEST['password'])) {
        $partner = $DB->Row('SELECT * FROM `tx_partners` WHERE `username`=? AND `password`=?', array($_REQUEST['username'], sha1($_REQUEST['password'])));
        if (!$partner) {
            $v->SetError($L['INVALID_LOGIN']);
        } else {
            // Setup the correct weight value for this account
            $_REQUEST['weight'] = $partner['weight'];
            $_REQUEST['partner'] = $partner['username'];
            $_REQUEST['email'] = $partner['email'];
            $_REQUEST['nickname'] = $partner['name'];
            if (!empty($partner['categories'])) {
                $partner['categories'] = unserialize($partner['categories']);
            }
            // Nickname not required for partner accounts
            if ($C['require_nickname']) {
                $v->Register($_REQUEST['nickname'], V_EMPTY, $L['NO_PARTNER_NICKNAME']);
            }
            // Check if the partner account is active and valid to submit
            if ($partner['status'] == 'suspended') {
                $v->SetError($L['ACCOUNT_SUSPENDED']);
            } else {
                if ($partner['status'] != 'active') {
                    $v->SetError($L['ACCOUNT_PENDING']);
                }
            }
            // Check active dates
            if (!IsEmptyString($partner['date_end']) && !IsEmptyString($partner['date_start'])) {
                $now = strtotime(MYSQL_NOW);
                $end = strtotime($partner['date_end']);
                $start = strtotime($partner['date_start']);
                if ($now < $start || $now > $end) {
                    $start_time = date("{$C['date_format']} {$C['time_format']}", $start);
                    $end_time = date("{$C['date_format']} {$C['time_format']}", $end);
                    $v->SetError(sprintf($L['ACCOUNT_EXPIRED'], $start_time, $end_time));
                }
            }
            if ($partner['domains']) {
                $partner['domains'] = unserialize($partner['domains']);
                if ($domain) {
                    if (!$partner['domains_as_exclude'] && !in_array($domain['domain_id'], $partner['domains']) || $partner['domains_as_exclude'] && in_array($domain['domain_id'], $partner['domains'])) {
                        $v->SetError($L['BAD_PARTNER_DOMAIN']);
                    }
                }
            }
        }
    }
    // See if only accepting submissions from partners
    if (!$partner && $C['submit_status'] == 'partner') {
        $v->SetError($L['PARTNERS_ONLY']);
    }
    // Do partner account validation
    if (!$v->Validate()) {
        return $v->ValidationError('txShGallerySubmit', TRUE);
    }
    $v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']);
    $v->Register($_REQUEST['gallery_url'], V_URL, sprintf($L['INVALID_URL'], $L['GALLERY_URL']));
    if ($C['require_keywords']) {
        $v->Register($_REQUEST['keywords'], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $L['KEYWORDS']));
    }
    if ($C['require_nickname']) {
        $v->Register($_REQUEST['nickname'], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $L['NAME']));
    }
    if ($C['require_description']) {
        $v->Register($_REQUEST['description'], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $L['DESCRIPTION']));
    }
    // Check description length if required or provided
    if ($C['require_description'] || !IsEmptyString($_REQUEST['description'])) {
        $v->Register($_REQUEST['description'], V_LENGTH, sprintf($L['DESCRIPTION_LENGTH'], $C['min_desc_length'], $C['max_desc_length']), "{$C['min_desc_length']},{$C['max_desc_length']}");
    }
    // Format keywords and check number
    $_REQUEST['keywords'] = FormatSpaceSeparated($_REQUEST['keywords']);
    $keywords = explode(' ', $_REQUEST['keywords']);
    $v->Register(count($keywords), V_LESS_EQ, sprintf($L['MAXIMUM_KEYWORDS'], $C['max_keywords']), $C['max_keywords']);
    // Validation of user defined fields
    $fields =& GetUserGalleryFields();
    foreach ($fields as $field) {
        if ($field['on_submit']) {
            if ($field['required']) {
                $v->Register($_REQUEST[$field['name']], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $field['label']));
            }
            if (!IsEmptyString($_REQUEST[$field['name']]) && $field['validation']) {
                $v->Register($_REQUEST[$field['name']], $field['validation'], $field['validation_message'], $field['validation_extras']);
            }
        }
    }
    // Check the global number of submissions
    if (!$partner && $C['max_submissions'] != -1) {
        $todays_submissions = $DB->Count('SELECT COUNT(*) FROM `tx_galleries` WHERE type=? AND (partner=? OR partner IS NULL) AND `date_added` BETWEEN ? AND ?', array('submitted', '', MYSQL_CURDATE . ' 00:00:00', MYSQL_CURDATE . ' 23:59:59'));
        if ($todays_submissions >= $C['max_submissions']) {
            $t->display($domain['template_prefix'] . 'submit-full-global.tpl');
            return;
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:TGPX,代码行数:101,代码来源:submit.php

示例3: tlxPasswordReset

function tlxPasswordReset($errors = null)
{
    global $C, $DB, $L, $t;
    $v = new Validator();
    $v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']);
    if (!empty($_REQUEST['email'])) {
        $account = $DB->Row('SELECT * FROM `tlx_accounts` WHERE `email`=?', array($_REQUEST['email']));
        if (!$account) {
            $v->SetError($L['NO_MATCHING_EMAIL']);
        } else {
            if ($account['status'] != STATUS_ACTIVE) {
                $v->SetError($L['ACCOUNT_PENDING']);
            } else {
                if ($account['suspended']) {
                    $v->SetError($L['ACCOUNT_SUSPENDED']);
                }
            }
        }
    }
    if (!$v->Validate()) {
        return $v->ValidationError('tlxShPasswordReset', TRUE);
    }
    $confirm_id = md5(uniqid(rand(), TRUE));
    $DB->Update('DELETE FROM `tlx_account_confirms` WHERE `username`=?', array($account['username']));
    $DB->Update('INSERT INTO `tlx_account_confirms` VALUES (?,?,?)', array($account['username'], $confirm_id, MYSQL_NOW));
    $t->assign_by_ref('account', $account);
    $t->assign('confirm_id', $confirm_id);
    SendMail($account['email'], 'email-account-password-confirm.tpl', $t);
    $t->display('accounts-password-reset-confirm.tpl');
}
开发者ID:hackingman,项目名称:ToplistX,代码行数:30,代码来源:accounts.php

示例4: Validator

function &ValidateCategoryInput($adding = FALSE)
{
    global $DB;
    $v = new Validator();
    $v->Register($_REQUEST['name'], V_EMPTY, 'The Category Name(s) field must be filled in');
    $v->Register($_REQUEST['forward_url'], V_EMPTY, 'The Forward URL field must be filled in');
    $v->Register($_REQUEST['title_min_length'], V_EMPTY, 'The Site Title Length fields must be filled in');
    $v->Register($_REQUEST['title_max_length'], V_EMPTY, 'The Site Title Length fields must be filled in');
    $v->Register($_REQUEST['desc_min_length'], V_EMPTY, 'The Description Length fields must be filled in');
    $v->Register($_REQUEST['desc_max_length'], V_EMPTY, 'The Description Length fields must be filled in');
    $v->Register($_REQUEST['banner_max_width'], V_EMPTY, 'The Max Banner Width field must be filled in');
    $v->Register($_REQUEST['banner_max_height'], V_EMPTY, 'The Max Banner Height field must be filled in');
    $v->Register($_REQUEST['banner_max_bytes'], V_EMPTY, 'The Max Banner Filesize field must be filled in');
    if (strpos($_REQUEST['name'], ',') !== FALSE) {
        $v->SetError('Category names may not contain commas');
    }
    foreach (explode("\n", $_REQUEST['name']) as $name) {
        $name = trim($name);
        if (strtoupper($name) == 'MIXED') {
            $v->SetError('The word MIXED is reserved and cannot be used as a category name');
        }
        if (preg_match('~^-~', $name)) {
            $v->SetError('Category names cannot start with a dash (-) character');
        }
        if ($adding) {
            if ($DB->Count('SELECT COUNT(*) FROM `tlx_categories` WHERE `name`=?', array($name))) {
                $v->SetError('The category ' . $name . ' already exists');
            }
        } else {
        }
    }
    return $v;
}
开发者ID:hackingman,项目名称:ToplistX,代码行数:33,代码来源:functions.php

示例5: lxEditAccount

function lxEditAccount()
{
    global $DB, $C, $t, $L;
    $account = ValidUserLogin();
    if ($account === FALSE) {
        lxShLogin($L['INVALID_LOGIN']);
        return;
    } else {
        if ($account['status'] != 'active') {
            lxShLogin($account['status'] == 'suspended' ? $L['SUSPENDED_ACCOUNT'] : $L['PENDING_ACCOUNT']);
            return;
        } else {
            $password = $account['password'];
            $v = new Validator();
            $v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']);
            $v->Register($_REQUEST['name'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['NAME']}");
            if (!empty($_REQUEST['password'])) {
                $v->Register($_REQUEST['password'], V_EQUALS, $L['NO_PASSWORD_MATCH'], $_REQUEST['confirm_password']);
                $v->Register($_REQUEST['password'], V_LENGTH, $L['PASSWORD_LENGTH'], '4,9999');
                $password = sha1($_REQUEST['password']);
            }
            // Validation of user defined fields
            $fields =& GetUserAccountFields();
            foreach ($fields as $field) {
                if ($field['on_edit']) {
                    if ($field['required']) {
                        $v->Register($_REQUEST[$field['name']], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$field['label']}");
                    }
                    if ($field['validation']) {
                        $v->Register($_REQUEST[$field['name']], $field['validation'], $field['validation_message'], $field['validation_extras']);
                    }
                }
            }
            // E-mail exists?
            if ($DB->Count('SELECT COUNT(*) FROM lx_users WHERE username!=? AND email=?', array($account['username'], $_REQUEST['email']))) {
                $v->SetError($L['DUPLICATE_EMAIL']);
            }
            // Check blacklist
            $blacklisted = CheckBlacklistAccount($_REQUEST);
            if ($blacklisted !== FALSE) {
                $v->SetError(sprintf($L['BLACKLIST_MATCHED'], $blacklisted[0]['match'], $blacklisted[0]['reason']));
            }
            if (!$v->Validate()) {
                $errors = join('<br />', $v->GetErrors());
                lxShEdit($errors);
                return;
            }
            // Update pre-defined data
            $DB->Update('UPDATE lx_users SET ' . 'password=?, ' . 'name=?, ' . 'email=? ' . 'WHERE username=?', array($password, $_REQUEST['name'], $_REQUEST['email'], $account['username']));
            // Update user defined fields
            UserDefinedUpdate('lx_user_fields', 'lx_user_field_defs', 'username', $account['username'], $_REQUEST, FALSE);
            // Back to the account overview
            lxLogin(null, 'accountupdate');
        }
    }
}
开发者ID:hackingman,项目名称:LinkX,代码行数:56,代码来源:account.php

示例6: lxAddAdministrator

function lxAddAdministrator()
{
    global $DB, $C;
    VerifyAdministrator();
    $user_count = $DB->Count('SELECT COUNT(*) FROM lx_administrators WHERE username=?', array($_REQUEST['username']));
    $validator = new Validator();
    $validator->Register($_REQUEST['username'], V_LENGTH, 'The username must be between 3 and 32 characters in length', array('min' => 3, 'max' => 32));
    $validator->Register($_REQUEST['username'], V_ALPHANUM, 'The username can only contain letters and numbers');
    $validator->Register($_REQUEST['password'], V_LENGTH, 'The password must contain at least 4 characters', array('min' => 4, 'max' => 999));
    $validator->Register($_REQUEST['email'], V_EMAIL, 'The e-mail address is not properly formatted');
    if ($user_count > 0) {
        $validator->SetError('An administrator account already exists with that username');
    }
    if (!$validator->Validate()) {
        $GLOBALS['errstr'] = join('<br />', $validator->GetErrors());
        lxShAddAdministrator();
        return;
    }
    // Determine the privileges and notifications for this account
    $privileges = GenerateFlags($_REQUEST, '^p_');
    $notifications = GenerateFlags($_REQUEST, '^e_');
    // Add account data to the database
    $DB->Update('INSERT INTO lx_administrators VALUES (?,?,?,?,?,?,?,?,?,?)', array($_REQUEST['username'], sha1($_REQUEST['password']), NULL, NULL, $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['type'], $_REQUEST['categories'], $notifications, $privileges));
    $GLOBALS['message'] = 'New administrator successfully added';
    $GLOBALS['added'] = true;
    UnsetArray($_REQUEST);
    lxShAddAdministrator();
}
开发者ID:hackingman,项目名称:LinkX,代码行数:28,代码来源:index.php

示例7: lxEditLink

function lxEditLink()
{
    global $DB, $C, $L, $t;
    $v = new Validator();
    // Make sure user is allowed to edit this link
    $link = $DB->Row('SELECT * FROM lx_links JOIN lx_link_fields USING (link_id) WHERE lx_links.link_id=?', array($_REQUEST['link_id']));
    if ($_REQUEST['noaccount']) {
        if (!empty($link['username']) || $link['site_url'] != $_REQUEST['login_site_url'] || $link['password'] != sha1($_REQUEST['login_password']) || $link['email'] != $_REQUEST['login_email']) {
            $t->assign('error', $L['LINK_EDIT_REFUSED']);
            $t->display('error-nice.tpl');
            return;
        }
    } else {
        $account = ValidUserLogin();
        if (!$account || $account['username'] != $link['username']) {
            $t->assign('error', $L['LINK_EDIT_REFUSED']);
            $t->display('error-nice.tpl');
            return;
        }
    }
    $v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']);
    $v->Register($_REQUEST['site_url'], V_URL, "{$L['INVALID_URL']}: {$L['SITE_URL']}");
    $v->Register($_REQUEST['title'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['TITLE']}");
    $v->Register($_REQUEST['description'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['DESCRIPTION']}");
    $v->Register($_REQUEST['keywords'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['KEYWORDS']}");
    $v->Register($_REQUEST['name'], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$L['NAME']}");
    $v->Register($_REQUEST['description'], V_LENGTH, sprintf($L['DESCRIPTION_LENGTH'], $C['min_desc_length'], $C['max_desc_length']), "{$C['min_desc_length']},{$C['max_desc_length']}");
    $v->Register($_REQUEST['title'], V_LENGTH, sprintf($L['TITLE_LENGTH'], $C['min_title_length'], $C['max_title_length']), "{$C['min_title_length']},{$C['max_title_length']}");
    // Format keywords and check number
    $_REQUEST['keywords'] = FormatKeywords($_REQUEST['keywords']);
    $keywords = explode(' ', $_REQUEST['keywords']);
    $v->Register(count($keywords), V_LESS, sprintf($L['MAXIMUM_KEYWORDS'], $C['max_keywords']), $C['max_keywords']);
    if (!empty($_REQUEST['password'])) {
        $v->Register($_REQUEST['password'], V_EQUALS, $L['NO_PASSWORD_MATCH'], $_REQUEST['confirm_password']);
    }
    // See if URL already exists
    if ($DB->Count('SELECT COUNT(*) FROM lx_links WHERE site_url=? AND link_id!=?', array($_REQUEST['site_url'], $link['link_id']))) {
        $v->SetError($L['DUPLICATE_URL']);
    }
    // Validation of user defined fields
    $fields =& GetUserLinkFields();
    foreach ($fields as $field) {
        if ($field['on_edit']) {
            if ($field['required']) {
                $v->Register($_REQUEST[$field['name']], V_EMPTY, "{$L['REQUIRED_FIELD']}: {$field['label']}");
            }
            if ($field['validation']) {
                $v->Register($_REQUEST[$field['name']], $field['validation'], $field['validation_message'], $field['validation_extras']);
            }
        }
    }
    $_REQUEST['allow_redirect'] = $link['allow_redirect'];
    $_REQUEST['recip_required'] = $link['recip_required'];
    // Scan link
    $scan_result =& ScanLink($_REQUEST);
    // Make sure site URL is working
    if (!$scan_result['site_url']['working']) {
        $v->SetError(sprintf($L['BROKEN_URL'], $L['SITE_URL'], $scan_result['site_url']['error']));
    }
    // Setup HTML code for blacklist check
    $_REQUEST['html'] = $scan_result['site_url']['html'];
    if (!empty($_REQUEST['recip_url'])) {
        $_REQUEST['html'] .= ' ' . $scan_result['recip_url']['html'];
        // Make sure recip URL is working
        if (!$scan_result['recip_url']['working']) {
            $v->SetError(sprintf($L['BROKEN_URL'], $L['RECIP_URL'], $scan_result['recip_url']['error']));
        }
    }
    // Verify recip link was found
    if ($_REQUEST['recip_required'] && !$scan_result['has_recip']) {
        $v->SetError($L['NO_RECIP_FOUND']);
    }
    // Check blacklist
    $blacklisted = CheckBlacklistLink($_REQUEST);
    if ($blacklisted !== FALSE) {
        $v->SetError(sprintf($L['BLACKLIST_MATCHED'], $blacklisted[0]['match'], $blacklisted[0]['reason']));
    }
    if (!$v->Validate()) {
        $errors = join('<br />', $v->GetErrors());
        lxShEdit($errors);
        return;
    }
    if ($C['approve_link_edits']) {
        $_REQUEST['submit_ip'] = $_SERVER['REMOTE_ADDR'];
        $DB->Update('UPDATE lx_links SET is_edited=1,edit_data=? WHERE link_id=?', array(base64_encode(serialize($_REQUEST)), $link['link_id']));
    } else {
        // Update password, if necessary
        $password = $link['password'];
        if ($_REQUEST['noaccount'] && !empty($_REQUEST['password'])) {
            $password = sha1($_REQUEST['password']);
        }
        // Update link data
        $DB->Update('UPDATE lx_links SET ' . 'site_url=?, ' . 'recip_url=?, ' . 'title=?, ' . 'description=?, ' . 'name=?, ' . 'email=?, ' . 'submit_ip=?, ' . 'keywords=?, ' . 'date_modified=?, ' . 'password=?, ' . 'has_recip=? ' . 'WHERE link_id=?', array($_REQUEST['site_url'], $_REQUEST['recip_url'], $_REQUEST['title'], $_REQUEST['description'], $_REQUEST['name'], $_REQUEST['email'], $_SERVER['REMOTE_ADDR'], $_REQUEST['keywords'], MYSQL_NOW, $password, $scan_result['has_recip'], $link['link_id']));
        // Update user defined fields
        UserDefinedUpdate('lx_link_fields', 'lx_link_field_defs', 'link_id', $_REQUEST['link_id'], $_REQUEST, FALSE);
    }
    // Get category information
    $categories = array();
    $result = $DB->Query('SELECT * FROM lx_categories JOIN lx_link_cats USING (category_id) WHERE link_id=?', array($link['link_id']));
    while ($category = $DB->NextRow($result)) {
//.........这里部分代码省略.........
开发者ID:hackingman,项目名称:LinkX,代码行数:101,代码来源:submit.php

示例8: txSendPasswordReset

function txSendPasswordReset()
{
    global $DB, $C, $t, $L, $domain;
    $v = new Validator();
    $v->Register($_REQUEST['email'], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $L['EMAIL']));
    if (!IsEmptyString($_REQUEST['email'])) {
        $partner = $DB->Row('SELECT * FROM `tx_partners` WHERE `email`=?', array($_REQUEST['email']));
        if (!$partner) {
            $v->SetError($L['NO_MATCHING_EMAIL']);
        } else {
            if ($partner['status'] == 'suspended') {
                $v->SetError($L['ACCOUNT_SUSPENDED']);
            } else {
                if ($partner['status'] != 'active') {
                    $v->SetError($L['ACCOUNT_PENDING']);
                }
            }
        }
    }
    if (!$v->Validate()) {
        return $v->ValidationError('txShPasswordReset', TRUE);
    }
    $confirm_id = md5(uniqid(rand(), TRUE));
    $DB->Update('DELETE FROM `tx_partner_confirms` WHERE `username`=?', array($partner['username']));
    $DB->Update('INSERT INTO `tx_partner_confirms` VALUES (?,?,?)', array($partner['username'], $confirm_id, MYSQL_NOW));
    $t->assign_by_ref('partner', $partner);
    $t->assign('confirm_id', $confirm_id);
    SendMail($partner['email'], $domain['template_prefix'] . 'email-partner-reset-confirm.tpl', $t);
    $t->display($domain['template_prefix'] . 'partner-reset-confirm.tpl');
}
开发者ID:Cyberspace-Networks,项目名称:TGPX,代码行数:30,代码来源:partner.php

示例9: FormatCommaSeparated

function &ValidateCategoryInput($adding = FALSE)
{
    global $DB;
    if ($_REQUEST['movies_preview_size'] == 'custom') {
        $_REQUEST['movies_preview_size'] = $_REQUEST['movies_preview_size_custom'];
    }
    if ($_REQUEST['pics_preview_size'] == 'custom') {
        $_REQUEST['pics_preview_size'] = $_REQUEST['pics_preview_size_custom'];
    }
    $_REQUEST['pics_extensions'] = FormatCommaSeparated($_REQUEST['pics_extensions']);
    $_REQUEST['movies_extensions'] = FormatCommaSeparated($_REQUEST['movies_extensions']);
    $v = new Validator();
    $v->Register($_REQUEST['name'], V_EMPTY, 'The Category Name(s) field must be filled in');
    $v->Register($_REQUEST['per_day'], V_NUMERIC, 'The Submissions Per Day field must be numeric');
    if (strpos($_REQUEST['name'], ',') !== FALSE) {
        $v->SetError('Category names may not contain commas');
    }
    $names = array();
    foreach (explode("\n", $_REQUEST['name']) as $name) {
        $name = trim($name);
        if (strtoupper($name) == 'MIXED') {
            $v->SetError('The word MIXED is reserved and cannot be used as a category name');
        }
        if (preg_match('~^-~', $name)) {
            $v->SetError('Category names cannot start with a dash (-) character');
        }
        if ($adding) {
            if ($DB->Count('SELECT COUNT(*) FROM `tx_categories` WHERE `name`=?', array($name)) < 1) {
                $names[] = $name;
            }
        } else {
            $names[] = $name;
        }
    }
    $_REQUEST['name'] = join("\n", $names);
    if (isset($_REQUEST['pics_allowed'])) {
        $v->Register($_REQUEST['pics_extensions'], V_EMPTY, 'The Pictures File Extensions field must be filled in');
        $v->Register($_REQUEST['pics_minimum'], V_NUMERIC, 'The Pictures Minimum Thumbs field must be numeric');
        $v->Register($_REQUEST['pics_maximum'], V_NUMERIC, 'The Pictures Maximum Thumbs field must be numeric');
        $v->Register($_REQUEST['pics_file_size'], V_NUMERIC, 'The Pictures Minimum Filesize field must be numeric');
        if (isset($_REQUEST['pics_preview_allowed'])) {
            $v->Register($_REQUEST['pics_preview_size'], V_REGEX, 'The Pictures Preview Dimensions must in WIDTHxHEIGHT format', '~^\\d+x\\d+$~');
        }
    }
    if (isset($_REQUEST['movies_allowed'])) {
        $v->Register($_REQUEST['movies_extensions'], V_EMPTY, 'The Movies File Extensions field must be filled in');
        $v->Register($_REQUEST['movies_minimum'], V_NUMERIC, 'The Movies Minimum Thumbs field must be numeric');
        $v->Register($_REQUEST['movies_maximum'], V_NUMERIC, 'The Movies Maximum Thumbs field must be numeric');
        $v->Register($_REQUEST['movies_file_size'], V_NUMERIC, 'The Movies Minimum Filesize field must be numeric');
        if (isset($_REQUEST['movies_preview_allowed'])) {
            $v->Register($_REQUEST['movies_preview_size'], V_REGEX, 'The Movies Preview Dimensions must in WIDTHxHEIGHT format', '~^\\d+x\\d+$~');
        }
    }
    return $v;
}
开发者ID:Cyberspace-Networks,项目名称:TGPX,代码行数:55,代码来源:functions.php

示例10: txAdministratorEdit

function txAdministratorEdit()
{
    global $DB, $C;
    VerifyAdministrator();
    $administrator = $DB->Row('SELECT * FROM `tx_administrators` WHERE `username`=?', array($_REQUEST['username']));
    $v = new Validator();
    $v->Register($_REQUEST['email'], V_EMAIL, 'The e-mail address is not properly formatted');
    if ($_REQUEST['password']) {
        $v->Register($_REQUEST['password'], V_LENGTH, 'The password must contain at least 4 characters', array('min' => 4, 'max' => 999));
    }
    if (isset($_REQUEST['e_cheat_report']) && !is_numeric($_REQUEST['reports_waiting'])) {
        $v->SetError('The number of reports waiting must be filled in and numeric');
    }
    if (isset($_REQUEST['e_partner_request']) && !is_numeric($_REQUEST['requests_waiting'])) {
        $v->SetError('The number of requests waiting must be filled in and numeric');
    }
    if (!$v->Validate()) {
        return $v->ValidationError('txShAdministratorEdit');
    }
    if ($_REQUEST['password']) {
        // Password has changed, so invalidate any current session that may be active
        if ($_REQUEST['username'] != $_SERVER['REMOTE_USER']) {
            $DB->Update('UPDATE `tx_administrators` SET `session`=NULL,`session_start`=NULL WHERE `username`=?', array($_REQUEST['username']));
        }
        $_REQUEST['password'] = sha1($_REQUEST['password']);
    } else {
        $_REQUEST['password'] = $administrator['password'];
    }
    // Determine the privileges and notifications for this account
    $privileges = GenerateFlags($_REQUEST, '^p_');
    $notifications = GenerateFlags($_REQUEST, '^e_');
    // Update account information
    $DB->Update('UPDATE `tx_administrators` SET ' . '`password`=?, ' . '`name`=?, ' . '`email`=?, ' . '`type`=?, ' . '`notifications`=?, ' . '`rights`=?, ' . '`reports_waiting`=?, ' . '`requests_waiting`=? ' . 'WHERE `username`=?', array($_REQUEST['password'], $_REQUEST['name'], $_REQUEST['email'], $_REQUEST['type'], $notifications, $privileges, $_REQUEST['reports_waiting'], $_REQUEST['requests_waiting'], $_REQUEST['username']));
    $GLOBALS['message'] = 'Administrator account successfully updated';
    $GLOBALS['added'] = true;
    txShAdministratorEdit();
}
开发者ID:hackingman,项目名称:TGPX,代码行数:37,代码来源:index.php


注:本文中的Validator::SetError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。