本文整理汇总了PHP中Validator::ValidationError方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::ValidationError方法的具体用法?PHP Validator::ValidationError怎么用?PHP Validator::ValidationError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::ValidationError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
示例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;
//.........这里部分代码省略.........
示例3: lxAdEdit
function lxAdEdit()
{
global $DB, $C;
VerifyAdministrator();
$v = new Validator();
$v->Register($_REQUEST['weight'], V_NUMERIC, 'The Weight value must be filled in and numeric');
$v->Register($_REQUEST['raw_clicks'], V_NUMERIC, 'The Raw Clicks value must be filled in and numeric');
$v->Register($_REQUEST['unique_clicks'], V_NUMERIC, 'The Unique Clicks value must be filled in and numeric');
$v->Register($_REQUEST['ad_url'], V_URL, 'The Ad URL is not properly formatted');
$v->Register($_REQUEST['ad_html_raw'], V_EMPTY, 'The Ad HTML value must be filled in');
if (!$v->Validate()) {
return $v->ValidationError('lxShAdEdit');
}
$t = new Template();
$t->assign_by_ref('ad', $_REQUEST);
$t->assign_by_ref('config', $C);
$_REQUEST['ad_html'] = $t->parse($_REQUEST['ad_html_raw']);
$t->cleanup();
$DB->Update('UPDATE `lx_ads` SET ' . '`ad_url`=?, ' . '`ad_html_raw`=?, ' . '`ad_html`=?, ' . '`weight`=?, ' . '`raw_clicks`=?, ' . '`unique_clicks`=?, ' . '`tags`=? ' . 'WHERE `ad_id`=?', array($_REQUEST['ad_url'], $_REQUEST['ad_html_raw'], $_REQUEST['ad_html'], $_REQUEST['weight'], $_REQUEST['raw_clicks'], $_REQUEST['unique_clicks'], $_REQUEST['tags'], $_REQUEST['ad_id']));
$GLOBALS['message'] = 'Advertisement successfully updated';
$GLOBALS['added'] = true;
lxShAdEdit();
}
示例4: 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');
}
示例5: 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();
}
示例6: tlxGeneralSettingsSave
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();
}