$code = $_POST['code'];
if ($securimage->check($code) == false) {
die("Sorry, the code entered did not match.");
} else {
$valid = true;
}
function createNew() { $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required|is_unique[user.login]'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('first', 'First', "required"); $this->form_validation->set_rules('last', 'last', "required"); $this->form_validation->set_rules('email', 'Email', "required|is_unique[user.email]"); if ($this->form_validation->run() == FALSE) { $this->load->view('account/newForm'); } else { include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { echo "The security code entered was incorrect.<br /><br />"; echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again."; exit; } $user = new User(); $user->login = $this->input->post('username'); $user->first = $this->input->post('first'); $user->last = $this->input->post('last'); $clearPassword = $this->input->post('password'); $user->encryptPassword($clearPassword); $user->email = $this->input->post('email'); $this->load->model('user_model'); $error = $this->user_model->insert($user); $this->load->view('account/loginForm'); } }
function createNew() { include_once $_SERVER['DOCUMENT_ROOT'] . '/tanks/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { // the code was incorrect // you should handle the error so that the form processor doesn't continue // or you can use the following code if there is no validation echo "The security code entered was incorrect.<br /><br />"; echo "Please go <a href='javascript:history.go(-1)'>back</a> and try again."; exit; } $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required|is_unique[user.login]'); $this->form_validation->set_rules('password', 'Password', 'required'); $this->form_validation->set_rules('first', 'First', "required"); $this->form_validation->set_rules('last', 'last', "required"); $this->form_validation->set_rules('email', 'Email', "required|is_unique[user.email]"); if ($this->form_validation->run() == FALSE) { $this->load->view('account/newForm'); } else { //FIXME: notify user on success $user = new User(); $user->login = $this->input->post('username'); $user->first = $this->input->post('first'); $user->last = $this->input->post('last'); $clearPassword = $this->input->post('password'); $user->encryptPassword($clearPassword); $user->email = $this->input->post('email'); $this->load->model('user_model'); $this->user_model->insert($user); $this->load->view('account/loginForm'); } }
function findpassword() { if (strtoupper($_SERVER['REQUEST_METHOD']) === 'POST') { $this->load->helper(array('server')); include_once FCPATH . 'resource/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($this->input->post('captcha_code')) === false) { json_response(array('success' => FALSE, 'msg' => 'Error Captcha')); } else { $this->form_validation->set_rules('username', 'Username Or Email', 'trim|required'); if ($this->form_validation->run() === FALSE) { json_response(array('success' => FALSE, 'msg' => validation_errors())); } else { $username = trim($this->input->post('username')); $this->db->where('username', $username); $this->db->or_where('email', $username); $row = $this->db->get('users')->row(); if ($row) { // send change password link email to user json_response(array('success' => TRUE, 'msg' => 'Send Success Info')); } else { json_response(array('success' => FALSE, 'msg' => 'Invalid User')); } } } } else { $this->load->view('findpassword'); } }
public function test(&$element, $value, $group = null, &$input = null, &$form = null) { // If the field is empty and not required, the field is valid. require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_mightytouch' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'securimage.php'; $img = new Securimage(); return $img->check($value); }
public function run($form) { $img = new Securimage(); try { $code = $form->get('code'); if (!$img->check($code)) { throw new CaptchaIncorretoException(); } $nome = $form->get('nome'); $empresa = $form->get('empresa'); $telefone = $form->get('telefone'); $assunto = $form->get('assunto'); $mensagem = $form->get('mensagem'); $msg = new Mensagem(null, $nome, $empresa, $telefone, $assunto, $mensagem, Constants::$_ATIVO); $fachada = Fachada::getInstance(); $fachada->cadastroMensagem()->cadastrar($msg); $this->setMessage("Mensagem cadastrada com sucesso.", Constants::$_MSG_SUCCESS); $this->load('100%'); $this->setForward(Forward::go(FaleConoscoPage::$NM_PAGINA . '&msg_cadastro=sucesso')); } catch (CaptchaIncorretoException $e) { $this->setMessage("As letras não foram digitadas corretamente! Por favor, tente novamente...", Constants::$_MSG_ERROR); $this->load('100%'); $this->setForward(Forward::$_BACK); } }
function process_si_contact_form() { if ($_SERVER['REQUEST_METHOD'] == 'POST' && @$_POST['do'] == 'contact') { // if the form has been submitted /*foreach($_POST as $key => $value) { if (!is_array($key)) { // sanitize the input data if ($key != 'ct_message') $value = strip_tags($value); $_POST[$key] = htmlspecialchars(stripslashes(trim($value))); } }*/ $captcha = @$_POST['ct_captcha']; // the user's entry for the captcha code //$name = substr($name, 0, 64); // limit name to 64 characters // Only try to validate the captcha if the form has no errors // This is especially important for ajax calls require_once dirname(__FILE__) . '/securimage.php'; $securimage = new Securimage(); if ($securimage->check($captcha) == false) { echo 'denaied123'; } else { echo 'success123'; } } // POST }
public static function captchaCheck() { $_POST['captcha_code'] = empty($_POST['captcha_code']) ? '' : $_POST['captcha_code']; if (include public_path(config('coaster::admin.public') . '/securimage/securimage.php')) { $secure_image = new \Securimage(); } return isset($secure_image) ? $secure_image->check($_POST['captcha_code']) : false; }
public function validate(AF_Element $element) { if (class_exists('Securimage')) { $securimage = new Securimage(); return $securimage->check($element->value); } else { die('AF_SecurimageValidator ERROR! Class Securimage not found.'); } }
function check_captha($captcha = "") { $securimage = new Securimage(); if ($securimage->check($captcha) == false) { return false; } else { return true; } }
function is_validate_captcha($code) { // CAPTCHA Class include_once dirname(__FILE__) . '/lib/securimage/securimage.php'; $securimage = new Securimage(); if (false == $securimage->check($code)) { return 0; } return 1; }
function verifyCaptcha($captcha) { $this->load->library('securimage/securimage'); $securimage = new Securimage(); // set error message if the captcha code is incorrect if ($securimage->check($captcha) == false) { $this->form_validation->set_message('verifyCaptcha', 'Verification code does not match the displayed image'); return false; } return true; }
/** * キャプチャコードチェック。 */ public function checkCaptcha($check) { App::import('Vendor', 'Securimage', array('file' => 'securimage/securimage.php')); $securimage = new Securimage(); foreach ($check as $key => $value) { if ($securimage->check($value) === false) { return false; } } return true; }
public function _valid_captcha($captcha) { /*Captcha*/ $this->load->library('securimage'); $securimage = new Securimage(); if (!$securimage->check($captcha)) { return FALSE; } else { return TRUE; } }
function validateCaptcha($captchacode, $errorMsg) { $result = ""; include_once 'lib/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($captchacode) == false) { // the code was incorrect $result = $errorMsg . "<br />"; } return $result; }
public function _check_captcha() { $this->load->library('securimage/securimage'); $securimage = new Securimage(); if (!$securimage->check($this->input->post('captcha'))) { $this->form_validation->set_message('_check_captcha', 'The code you entered is invalid'); return FALSE; } else { return TRUE; } }
function captchacheck($usercode) { global $error, $error_die; include_once 'functions/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($usercode) == false) { $error[] = 'The Validation Code Entered Is Not Correct.'; return false; } else { return true; } }
function securimage_check() { require_once "packages/securimage/securimage.php"; $securimage = new Securimage(); $sickrs = $securimage->check($_POST['securimages']); unset($_POST['securimage']); if (!$sickrs) { return false; } else { return true; } }
public function action_index() { // load language \Lang::load('account'); // form submitted if (\Input::method() == 'POST') { $data['account_email'] = \Security::strip_tags(trim(\Input::post('account_email'))); // validate form. $validate = \Validation::forge(); $validate->add('account_email', \Lang::get('account_email'), array(), array('required', 'valid_email')); if (!\Extension\NoCsrf::check()) { // validate token failed $output['form_status'] = 'error'; $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token'); } elseif (!$validate->run()) { // validate failed $output['form_status'] = 'error'; $output['form_status_message'] = $validate->show_errors(); } else { // validate pass include APPPATH . 'vendor' . DS . 'securimage' . DS . 'securimage.php'; $securimage = new \Securimage(); if ($securimage->check(\Input::post('captcha')) == false) { $output['form_status'] = 'error'; $output['form_status_message'] = \Lang::get('account_wrong_captcha_code'); } else { $continue_form = true; } if (isset($continue_form) && $continue_form === true) { // try to send reset password email $result = \Model_Accounts::sendResetPasswordEmail($data); if ($result === true) { $output['hide_form'] = true; $output['form_status'] = 'success'; $output['form_status_message'] = \Lang::get('account_please_check_your_email_to_confirm_reset_password'); } else { if (is_string($result)) { $output['form_status'] = 'error'; $output['form_status_message'] = $result; } } } } // re-populate form $output['account_email'] = trim(\Input::post('account_email')); } // <head> output ---------------------------------------------------------------------------------------------- $output['page_title'] = $this->generateTitle(\Lang::get('account_forgot_username_or_password')); // <head> output ---------------------------------------------------------------------------------------------- return $this->generatePage('front/templates/account/forgotpw_v', $output, false); }
function add($s) { if (empty($_POST)) { if (isset($_COOKIE['contacts'])) { $errors['val']['contacts'] = $_COOKIE['contacts']; } else { $errors = NULL; } $block_html = Html::pageCommercialAdd($errors); $s->assign("block_html",$block_html); $s->assign("YANDEX_KEY",YANDEX_KEY); $s->assign("LAT_CENTER_REGION",LAT_CENTER_REGION); $s->assign("LON_CENTER_REGION",LON_CENTER_REGION); $s->display("commercial_add.tpl"); } else { $errors = Commercial::checkForm($_REQUEST,''); require_once './libs/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $errors['captcha']['is_error'] = 1; } if (!isset($errors['is_error'])&&!isset($errors['captcha']['is_error'])) { //Дом уже есть в бд if (isset($_POST['tenement_id']) && $_POST['tenement_id']>0) { $tenement_id = intval($_POST['tenement_id']); $tenement = new Tenement(); $tenement->find($tenement_id); if (!$tenement->id) { echo "Дом не найден"; exit(); } } $commercial_id = Commercial::addStatic($_POST); setcookie('contacts',stripslashes($_POST['contacts'])); $_SESSION['last_commercial_id'] = $commercial_id; if ($commercial_id > 0) header("Location: /commercial.html?action=view&id=".$commercial_id); exit(); } else { //echo "Error:".print_r($errors); $block_html = Html::pageCommercialAdd($errors); $s->assign("YANDEX_KEY",YANDEX_KEY); if (isset($_SESSION['admin'])) $s->assign("is_admin",$_SESSION['admin']); $s->assign("block_html",$block_html); $s->display("commercial_add.tpl"); } } }
function lwiki_auth_securimage_check(&$errorMessage) { $scode = $_POST['lwiki_simi']; if (!$scode || $scode == '') { $errorMessage = '画像認証コードが入力されていません。'; return 2; } require_once 'securimage.php'; $simg = new Securimage(); if ($simg->check($scode) !== true) { $errorMessage = '画像認証に失敗。'; return 1; } }
function _process() { global $osC_Language, $messageStack; if (isset($_POST['department_email']) && !empty($_POST['department_email'])) { $department_email = osc_sanitize_string($_POST['department_email']); if (!osc_validate_email_address($department_email)) { $messageStack->add('contact', $osC_Language->get('field_departments_email_error')); } } else { $department_email = STORE_OWNER_EMAIL_ADDRESS; } if (isset($_POST['name']) && !empty($_POST['name'])) { $name = osc_sanitize_string($_POST['name']); } else { $messageStack->add('contact', $osC_Language->get('field_customer_name_error')); } if (isset($_POST['email']) && !empty($_POST['email'])) { $email_address = osc_sanitize_string($_POST['email']); if (!osc_validate_email_address($email_address)) { $messageStack->add('contact', $osC_Language->get('field_customer_concat_email_error')); } } else { $messageStack->add('contact', $osC_Language->get('field_customer_concat_email_error')); } if (isset($_POST['telephone']) && !empty($_POST['telephone'])) { $telephone = osc_sanitize_string($_POST['telephone']); } if (isset($_POST['enquiry']) && !empty($_POST['enquiry'])) { $enquiry = osc_sanitize_string($_POST['enquiry']); } else { $messageStack->add('contact', $osC_Language->get('field_enquiry_error')); } if (ACTIVATE_CAPTCHA == '1') { if (isset($_POST['captcha_code']) && !empty($_POST['captcha_code'])) { $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $messageStack->add('contact', $osC_Language->get('field_concat_captcha_check_error')); } } else { $messageStack->add('contact', $osC_Language->get('field_concat_captcha_check_error')); } } if ($messageStack->size('contact') === 0) { osc_email(STORE_OWNER, $department_email, $osC_Language->get('contact_email_subject'), $enquiry . '<br /><br /><br />' . $osC_Language->get('contact_telephone_title') . $telephone, $name, $email_address); osc_redirect(osc_href_link(FILENAME_INFO, 'contact=success', 'AUTO', true, false)); } }
private function validate() { if (strlen($this->request->post['username']) < 2) { $this->error['username'] = $this->data['text_invalid_username']; } if (CAPTCHA_FAILED_LOGIN_COUNT > 0 && $this->data['failed_login_count'] > CAPTCHA_FAILED_LOGIN_COUNT) { require_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php'; $image = new Securimage(); if ($image->check($this->request->post['captcha']) != true) { $this->error['captcha'] = 'captcha error'; } } if (!$this->error) { return true; } else { return false; } }
function captcha_check($code = "", $auto = true) { session_start(); if ($code == "") { $code = @$_POST['captcha']; } $securimage = new Securimage(); if ($securimage->check($code) == false) { if ($auto) { echo '-44'; exit; } else { return -1; } } else { return 0; } }
/** * Constructor * * Create a new text field * * @param FormHandler $form The form where this field is located on * @param string $name The name of the field * @return \FormHandler\Field\Text * @author Teye Heimans * @author Marien den Besten */ public function __construct(FormHandler $form, $name) { static $bCaptcha = true; if (!$bCaptcha) { trigger_error("Please use only one Captcha field on a page", E_USER_WARNING); } $bCaptcha = false; if (!isset($_SESSION)) { trigger_error("Please make sure you have an active session", E_USER_WARNING); } $this->image = new \FormHandler\Button\Image($form, $name . '_image'); $this->image->setExtra('onclick="return false;" style="cursor:default;"'); // call the constructor of the Field class parent::__construct($form, $name)->setSize(\FormHandler\Configuration::get('captcha_length'))->setWidth(\FormHandler\Configuration::get('captcha_width'))->setMaxlength(0)->setValidator(new \FormHandler\Validator\FunctionCallable(function ($value) { require_once __DIR__ . '/../FHTML/securimage/securimage.php'; $img = new \Securimage(); $valid = $img->check($value); return $valid == true; }))->setRequired(true); }
public function run($form) { //TODO $img = new Securimage(); try { $code = $form->get('code'); if (!$img->check($code)) { throw new CaptchaIncorretoException(); } //pega valores do form preenchido $nome = $form->get('nome'); $cpf = $form->get('cpf'); $rg = $form->get('rg'); $cep = $form->get('cep'); $rua = $form->get('rua'); $numero = $form->get('numero'); $bairro = $form->get('bairro'); $complemento = $form->get('complemento'); $cidade = $form->get('cidade'); $estado = $form->get('estado'); $telefone = $form->get('telefone'); $celular = $form->get('celular'); $email = $form->get('email'); $senha = $form->get('senha'); //cria o objeto $usuario = new Usuario(null, null, $nome, $cpf, $rg, $cep, $rua, $numero, $bairro, $complemento, $cidade, $estado, $telefone, $celular, $email, $senha, Constants::$_ATIVO); //persiste objeto $fachada = Fachada::getInstance(); $fachada->cadastroUsuario()->cadastrarCliente($usuario); SessionManager::setUser($usuario); //mensagem de sucesso $this->setMessage("Usuário cadastrado com sucesso.", Constants::$_MSG_SUCCESS); $this->load('100%'); $this->setForward(Forward::go(HomePage::$NM_PAGINA . '&msg_cadastro=ok')); } catch (CaptchaIncorretoException $e) { $this->setMessage("As letras não foram digitadas corretamente! Por favor, tente novamente...", Constants::$_MSG_ERROR); $this->load('100%'); $this->setForward(Forward::$_BACK); } }
function add($s) { if (empty($_POST)) { if (isset($_COOKIE['contacts'])) { $errors['val']['contacts'] = $_COOKIE['contacts']; } else { $errors = NULL; } $block_html = Html::pageLandAdd($errors); $s->assign("block_html",$block_html); $s->assign("YANDEX_KEY",YANDEX_KEY); $s->assign("LAT_CENTER_REGION",LAT_CENTER_REGION); $s->assign("LON_CENTER_REGION",LON_CENTER_REGION); $s->display("land_add.tpl"); } else { $errors = Land::checkForm($_REQUEST,''); require_once './libs/securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $errors['captcha']['is_error'] = 1; } if (!isset($errors['is_error'])&&!isset($errors['captcha']['is_error'])) { $land_id = Land::addStatic($_POST); setcookie('contacts',stripslashes($_POST['contacts'])); $_SESSION['last_land_id'] = $land_id; if ($land_id > 0) header("Location: /land.html?action=view&id=".$land_id); exit(); } else { //echo "Error:".print_r($errors); $block_html = Html::pageLandAdd($errors); $s->assign("YANDEX_KEY",YANDEX_KEY); if (isset($_SESSION['admin'])) $s->assign("is_admin",$_SESSION['admin']); $s->assign("block_html",$block_html); $s->display("land_add.tpl"); } } }
function _process() { global $osC_Database, $messageStack, $osC_Language; $data = array(); $data['url'] = osc_sanitize_string($_POST['url']); if (isset($_POST['title']) && !empty($_POST['title'])) { $data['title'] = osc_sanitize_string($_POST['title']); } else { $messageStack->add('guestbook', $osC_Language->get('field_guestbook_title_error')); } if (isset($_POST['email']) && !empty($_POST['email']) && osc_validate_email_address($_POST['email'])) { $data['email'] = $_POST['email']; } else { $messageStack->add('guestbook', $osC_Language->get('field_guestbook_email_error')); } if (isset($_POST['content']) && !empty($_POST['content'])) { $data['content'] = osc_sanitize_string($_POST['content']); } else { $messageStack->add('guestbook', $osC_Language->get('field_guestbook_content_error')); } if (ACTIVATE_CAPTCHA == '1') { if (isset($_POST['captcha_code']) && !empty($_POST['captcha_code'])) { $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { $messageStack->add('guestbook', $osC_Language->get('field_guestbook_verify_code_error')); } } else { $messageStack->add('guestbook', $osC_Language->get('field_guestbook_verify_code_error')); } } if ($messageStack->size('guestbook') === 0) { if (toC_Guestbook::saveEntry($data)) { $messageStack->add_session('guestbook', $osC_Language->get('success_guestbook_saved'), 'success'); } osc_redirect(osc_href_link(FILENAME_INFO, 'guestbook')); } }
public function AskAction() { $ask = new Consult($this->context); $expert = $this->db->query(' SELECT cc.id, cc.name, cc.alt_name, ud.FirstName, ud.LastName, ud.UserID FROM UserData as ud, consult_category as cc, consult_user_category as cu WHERE ud.UserID=cu.uid and cc.id=cu.cid')->fetchall(); $category = $this->db->query('select id, name, alt_name, img from consult_category order by id')->fetchall(); $time = date("Y-m-d H:i:s", time()); $email = Tools::getValue('mail'); $name = Tools::getValue('name'); empty(Tools::getValue('q', '')) ? $uri = 0 : ($uri = Tools::getValue('q', '')); if (!empty($_POST['sendRequ'])) { $send_r = 1; } if (Tools::isPost()) { $content = array('title' => 'Вы задали вопрос', 'template' => 'send_to_back', 'data' => array('[year]' => date("Y", time()), '[name]' => $name, '[email]' => $email, '[question]' => Tools::getValue('body'))); } if (!empty($_POST)) { $image = new Securimage(); if ($image->check($_POST['captcha_code']) == true) { $this->db->prepare('insert into consult_questions (title, body, name, email, uid, cid, isRequest, isAnswer, pid, questiondate) values ("' . Tools::getValue('title') . '","' . Tools::getValue('body') . '","' . $name . '","' . $email . '","' . Tools::getValue('setExpName') . '","' . Tools::getValue('setCatName') . '","' . $send_r . '","1","' . $uri . '","' . $time . '")')->execute(); if (!empty($_POST['copyTo'])) { Mailer::send($email, $content, 'Вы задали вопрос', null, null); } return AddAlertMessage('success', 'Ваш вопрос был сохранен, ожидайте ответа.!', '/consult/'); } else { return AddAlertMessage('warning', 'Вы неверно указали код с картинки', $_SERVER['REQUEST_URI']); } } $this->view->breadcrumbs = array(array('url' => '/', 'title' => 'Главная'), array('url' => '/consult/', 'title' => 'Консультации'), array('url' => '../consult/ask', 'title' => 'Задать вопрос')); $this->view->setVars(array('category' => $category, 'expert' => $expert)); unset($_SESSION['captcha_keystring']); $this->view->generate(); }
if ($settings['email_verification'] == "1") { $result = dbquery("SELECT user_email, user_info FROM " . DB_NEW_USERS); while ($new_users = dbarray($result)) { $user_info = unserialize($new_users['user_info']); if ($new_users['user_email'] == $email) { $error = "· " . $locale['409'] . "<br />\n"; } if ($user_info['user_name'] == $username) { $error = "· " . $locale['407'] . "<br />\n"; break; } } } if ($settings['display_validation'] == "1") { $securimage = new Securimage(); if (!isset($_POST['captcha_code']) || $securimage->check($_POST['captcha_code']) == false) { $error .= "· " . $locale['410'] . "<br />\n"; } else { $log['response_seci'] = $_POST['captcha_code']; } } $user_hide_email = isnum($_POST['user_hide_email']) ? $_POST['user_hide_email'] : "1"; if ($settings['email_verification'] == "0") { $user_offset = isset($_POST['user_offset']) ? is_numeric($_POST['user_offset']) ? $_POST['user_offset'] : "0" : "0"; $profile_method = "validate_insert"; $db_fields = ""; $db_values = ""; $result = dbquery("SELECT tuf.field_name FROM " . DB_USER_FIELDS . " tuf\r\n\t\t\tINNER JOIN " . DB_USER_FIELD_CATS . " tufc ON tuf.field_cat = tufc.field_cat_id\r\n\t\t\tORDER BY field_cat_order, field_order"); if (dbrows($result)) { while ($data = dbarray($result)) { if (file_exists(LOCALE . LOCALESET . "user_fields/" . $data['field_name'] . ".php")) {
function verify() { global $CFG; if ($this->info && $this->compare_fields) { foreach ($this->compare_fields as $name => $comp_name) { if ($this->info[$comp_name]) { if ($this->info[$comp_name] != $this->info[$name]) { $this->errors[$name] = $CFG->compare_error; } } unset($this->info[$name]); } } if ($_REQUEST['is_caco'][$this->name]) { include_once 'securimage/securimage.php'; $securimage = new Securimage(); if ($securimage->check($_REQUEST['caco']) == false) { $this->errors[] = $CFG->capcha_error; } } if ($this->info && $this->verify_fields) { foreach ($this->info as $name => $value) { if (array_key_exists($name, $this->verify_fields)) { // date range verification if (strstr($this->verify_fields[$name], 'date')) { $this->verify_fields[$name] = str_replace($this->verify_fields[$name], 'date:', ''); $dates = explode('|', $this->verify_fields[$name]); if (!empty($dates[0])) { $e0 = strtotime($value) > strtotime($dates[0]); } if (!empty($dates[1])) { $e1 = strtotime($value) > strtotime($dates[1]); } if ($e0 || $e1) { $this->errors[$name] = $CFG->verify_date_error; } continue; } switch ($this->verify_fields[$name]) { case 'email': if (!Email::verifyAddress($value)) { $this->errors[$name] = $CFG->verify_email_error; } break; case 'phone': if (!ValidateData::validatePhone($value)) { $this->errors[$name] = $CFG->verify_phone_error; } break; case 'user': if (!ValidateData::validatePhone($value)) { $this->errors[$name] = $CFG->verify_phone_error; } break; case 'password': if (!preg_match($CFG->pass_regex, $value)) { $this->errors[$name] = $CFG->verify_password_error; } break; case 'zip': if (!ValidateData::validateZip($value)) { $this->errors[$name] = $CFG->verify_zip_error; } break; case 'checkbox': if ($value == 'N') { $this->errors[$name] = $CFG->verify_default_error; } break; case '': case true: if (strlen(trim($value)) == 0) { $this->errors[$name] = $CFG->verify_default_error; } elseif (!$CFG->backstage_mode) { if ($_REQUEST['db_fields'][$name] == 'vchar' || $_REQUEST['db_fields'][$name] == 'int') { $delete_whitespace = @in_array($name, $this->delete_whitespace); if (String::sanitize($value, true, $delete_whitespace)) { $this->errors[$name] = $CFG->verify_invalid_char_error; } } } break; default: if (!preg_match($this->verify_fields[$name], $value)) { $this->errors[$name] = $CFG->verify_custom_error; } break; } } } if ($this->info && $this->unique_fields && !($this->record_id > 0)) { foreach ($this->unique_fields as $name => $err_message) { if (@array_key_exists($name, $this->errors)) { continue; } if (!DB::isUniqueValue($this->table, $name, $this->info[$name])) { $this->errors[$name] = !empty($err_message) ? $err_message : $CFG->value_exists_error; } } } if ($_REQUEST['cat_selects']) { foreach ($_REQUEST['cat_selects'] as $name => $v) { if (!$this->info['cat_selects'][$name]) { $this->info['cat_selects'][$name] = array(); } } foreach ($this->info['cat_selects'] as $name => $values) { if ($this->verify_fields[$name]) { $name_parts = explode('|', $this->verify_fields[$name]); $cat_select_min = $name_parts[1]; if (!is_array($values) || count($values) < $cat_select_min) { $this->errors[$name] = str_ireplace('[n]', $cat_select_min, $CFG->verify_cat_select_error); } } } } if ($_REQUEST['files']) { foreach ($_REQUEST['files'] as $name => $reqs) { if (!@in_array($name, $this->attached_file_fields)) { $found = false; if (array_key_exists($name, $this->verify_fields)) { if (is_array($this->temp_files)) { foreach ($this->temp_files as $k => $v) { if (stristr($k, $name)) { $found = true; } } } if (is_array($_FILES[$this->name]['name'])) { foreach ($_FILES[$this->name]['name'] as $k => $v) { if (stristr($k, $name)) { if (!empty($v)) { $found = true; } } } } if (!$found) { $this->errors[$name] = $CFG->verify_file_required_error; } } } } } return is_array($this->errors); } }