public function index()
 {
     $input = null;
     $output = null;
     $clear_form = (bool) $this->input->post('test_form_clear');
     $is_example = (bool) $this->input->post('test_form_example');
     if ($clear_form) {
         // Do nothing, all has been already initialized.
     } elseif ($is_example) {
         $input = @file_get_contents($this->load->path('test.json'));
         try {
             $output = $this->parser->parse_string($input, null, true, 'jsonmin');
         } catch (Exception $e) {
             $output = $e->getMessage();
         }
     } else {
         $validation_rules = array(array('field' => 'input', 'label' => 'Input JSON source', 'rules' => 'trim'));
         $this->form_validation->set_rules($validation_rules);
         if ($this->form_validation->run()) {
             $input = $this->input->post('input');
             try {
                 $output = $this->parser->parse_string($input, null, true, 'jsonmin');
             } catch (Exception $e) {
                 $output = $e->getMessage();
             }
         } elseif (validation_errors()) {
             $output = null;
             $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
             $this->template->set('validation_errors', validation_errors_array());
         }
     }
     $this->template->set('clear_form', $clear_form)->set('is_example', $is_example)->set('input', $input)->set('output', $output)->enable_parser_body('i18n')->build('jsonmin');
 }
 public function index()
 {
     $this->load->parser();
     $validation_rules = array(array('field' => 'email_test_form_captcha', 'label' => 'Captcha', 'rules' => 'nohtml|trim|callback__captcha'));
     $success = false;
     $messages = array();
     $this->form_validation->set_rules($validation_rules);
     if ($this->form_validation->run()) {
         $custom_text = $this->input->post('custom_text');
         $custom_html = trim($custom_text) != '' ? $this->parser->parse_string($custom_text, null, true, array('textile' => array('restricted_mode' => true))) : '';
         $success = (bool) Events::trigger('email_test', array('custom_text' => $custom_html));
         if ($success) {
             $messages[] = $this->lang->line('mailer_your_message_has_been_sent');
         } else {
             if ($this->registry->get('email_debugger') != '') {
                 $messages[] = $this->lang->line('mailer_error') . '<br /><br />' . $this->registry->get('email_debugger');
             } else {
                 $messages[] = $this->lang->line('mailer_error');
             }
         }
     } else {
         $messages = validation_errors_array();
     }
     extract(Modules::run('email/test/get_message'));
     $has_logo = file_exists(DEFAULTFCPATH . 'apple-touch-icon-precomposed.png');
     $body = $this->parser->parse_string($body, array('has_logo' => $has_logo, 'logo_src' => default_base_url('apple-touch-icon-precomposed.png')), true, 'mustache');
     $this->captcha->clear();
     $this->template->set(compact('success', 'messages', 'subject', 'body'))->enable_parser_body('i18n')->build('email_test');
 }
 public function index()
 {
     $validation_rules = array(array('field' => 'country_1', 'label' => 'Country 1', 'rules' => 'nohtml|trim|required'), array('field' => 'country_2', 'label' => 'Country 2', 'rules' => 'nohtml|trim|required'));
     $country_1 = null;
     $country_2 = null;
     $country_names = array();
     if ($this->driver_ok) {
         $country_names = $this->countries->dropdown('id', 'name');
     }
     $this->form_validation->set_rules($validation_rules);
     $success = false;
     $messages = array();
     if ($this->form_validation->run()) {
         // Read data.
         $country_1 = (int) $this->input->post('country_1');
         $country_2 = (int) $this->input->post('country_2');
         // Process data.
         $country_1_name = $this->countries->select('name')->as_value()->get($country_1);
         $country_2_name = $this->countries->select('name')->as_value()->get($country_2);
         $messages[] = 'You have just chosen:<br />' . '<strong>Country 1:</strong> ' . $country_1_name . '<br />' . '<strong>Country 2:</strong> ' . $country_2_name;
         $success = true;
     } elseif (validation_errors()) {
         $messages = validation_errors_array();
         $this->template->set('validation_errors', $messages);
     }
     $this->template->set(compact('success', 'messages', 'country_1', 'country_2', 'country_names'))->set('driver_ok', $this->driver_ok)->set_partial('scripts', 'jquery_chosen_scripts')->build('jquery_chosen');
 }
示例#4
0
function validation_errors_json()
{
    $error_array = validation_errors_array();
    if (is_array($error_array)) {
        return Zend_Json::encode($error_array);
    }
    return FALSE;
}
 public function index()
 {
     $output = null;
     $validation_rules = array(array('field' => 'input', 'label' => 'Input CSS source', 'rules' => 'trim'));
     $this->form_validation->set_rules($validation_rules);
     if ($this->form_validation->run()) {
         $output = $this->parser->parse_string($this->input->post('input'), null, true, 'cssmin');
     } elseif (validation_errors()) {
         $output = null;
         $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
         $this->template->set('validation_errors', validation_errors_array());
     }
     $this->template->set(compact('output'))->enable_parser_body('i18n')->build('cssmin');
 }
 public function index()
 {
     $this->load->library('form_validation');
     $register_rules = array(array('field' => 'username', 'label' => $this->lang->line('ui_username') . ' / ' . 'E-mail', 'rules' => 'nohtml|trim|required|valid_email'), array('field' => 'password', 'label' => 'lang:ui_password', 'rules' => 'nohtml|trim|required|matches[confirm_password]'), array('field' => 'confirm_password', 'label' => 'lang:ui_confirm_password', 'rules' => 'nohtml|trim|required'), array('field' => 'first_name', 'label' => 'lang:ui_first_name', 'rules' => 'nohtml|trim|required'), array('field' => 'last_name', 'label' => 'lang:ui_last_name', 'rules' => 'nohtml|trim'), array('field' => 'gender', 'label' => 'lang:ui_gender', 'rules' => 'nohtml|trim'), array('field' => 'date_of_birth', 'label' => 'lang:ui_date_of_birth', 'rules' => 'nohtml|trim'), array('field' => 'captcha', 'label' => 'Captcha', 'rules' => 'nohtml|trim|callback__captcha'));
     $this->form_validation->set_rules($register_rules);
     if ($this->form_validation->run()) {
         $username = $this->input->post('username');
         $password = $this->input->post('password');
         $firstName = $this->input->post('first_name');
         $lastName = $this->input->post('last_name');
         $gender = $this->input->post('gender');
         $dateOfBirth = $this->input->post('date_of_birth');
         if ($this->_register($username, $password, $firstName, $lastName, $gender, $dateOfBirth)) {
             if ($this->input->get('continue')) {
                 redirect($this->input->get('continue'));
             }
             $this->session->set_flashdata('confirmation_message', '<nobr>Hello, <strong>' . $username . '</strong>.</nobr>');
             redirect(site_url());
         } else {
             $error_message = 'Wrong username or password.';
             // Code for the real authentication system.
             //switch ($this->_last_login_error()) {
             //
             //    case LOGIN_USER_UNVERIFIED:
             //        $error_message = 'The user account has not been verified by e-mail.';
             //        break;
             //
             //    case LOGIN_USER_SUSPENDED:
             //        $error_message = 'The user has been suspended';
             //        break;
             //
             //    default:
             //        $error_message = $error_message = 'Wrong username or password.';
             //        break;
             //}
             $this->template->set('error_message', $error_message);
         }
     } elseif (validation_errors()) {
         $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
         $this->template->set('validation_errors', validation_errors_array());
     }
     $this->captcha->clear();
     $this->template->prepend_title('Login')->set_partial('scripts', 'register_scripts')->enable_parser_body('i18n')->build('register');
 }
 public function index()
 {
     $this->output->set_header('Content-Type: application/json; charset=utf-8');
     $success = false;
     $messages = array();
     $settings = $this->settings->get(array('contact_form_has_phone', 'contact_form_phone_required', 'contact_form_has_organization', 'contact_form_organization_required'));
     extract($settings);
     if (!$contact_form_has_phone) {
         $contact_form_phone_required = false;
     }
     if (!$contact_form_has_organization) {
         $contact_form_organization_required = false;
     }
     $data = $this->input->post();
     if (!empty($data)) {
         if ($this->settings->get('mailer_enabled')) {
             $validation_rules = array(array('field' => 'contact_form_first_name', 'label' => 'lang:contact_first_name', 'rules' => 'nohtml|trim|required'), array('field' => 'contact_form_last_name', 'label' => 'lang:contact_last_name', 'rules' => 'nohtml|trim|required'), array('field' => 'contact_form_email', 'label' => 'lang:contact_email', 'rules' => 'nohtml|trim|required|valid_email'), array('field' => 'contact_form_phone', 'label' => 'lang:contact_phone', 'rules' => 'nohtml|trim' . ($contact_form_phone_required ? '|required' : '')), array('field' => 'contact_form_organization', 'label' => 'lang:contact_organization', 'rules' => 'nohtml|trim' . ($contact_form_organization_required ? '|required' : '')), array('field' => 'contact_form_subject', 'label' => 'lang:contact_subject', 'rules' => 'nohtml|trim|required'), array('field' => 'contact_form_message', 'label' => 'lang:contact_message', 'rules' => 'nohtml|trim|required|min_length[15]'), array('field' => 'contact_form_captcha', 'label' => 'Captcha', 'rules' => 'nohtml|trim|callback__captcha'));
             $this->form_validation->set_rules($validation_rules);
             if ($this->form_validation->run()) {
                 $data = $this->_prepare_data($data);
                 $data = $this->_load_email_template($data);
                 $data = $this->_create_email($data);
                 $success = (bool) Events::trigger('email', $data);
                 if ($success) {
                     $messages[] = $this->lang->line('mailer_your_message_has_been_sent');
                     Events::trigger('contact_form_submitted', $data);
                 } else {
                     $messages[] = $this->lang->line('mailer_error');
                 }
             } elseif (validation_errors_array()) {
                 $messages = validation_errors_array();
             } else {
                 $messages[] = 'Validation error.';
             }
         } else {
             $messages[] = $this->lang->line('mailer_disabled_error');
         }
     }
     $messages_html = $this->_prepare_messages_html($success, $messages);
     $this->captcha->clear();
     $this->output->set_output(json_encode(compact('success', 'messages', 'messages_html')));
 }
 public function index()
 {
     $validation_rules = array(array('field' => 'email', 'label' => 'Email', 'rules' => 'nohtml|trim|required|valid_email'), array('field' => 'captcha', 'label' => 'Captcha', 'rules' => 'nohtml|trim|callback__captcha'));
     $email = null;
     $gravatar = null;
     $profile = null;
     $last_error = 0;
     $this->form_validation->set_rules($validation_rules);
     if ($this->form_validation->run()) {
         $email = $this->input->post('email');
         $gravatar = $this->gravatar->get($email);
         $profile = $this->gravatar->get_profile_data($email);
         $last_error = $this->gravatar->last_error($email);
     } elseif (validation_errors()) {
         $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
         $this->template->set('validation_errors', validation_errors_array());
     }
     $this->captcha->clear();
     $this->template->set(compact('email', 'gravatar', 'profile', 'last_error'))->enable_parser_body('i18n')->build('gravatar_test');
 }
 public function index()
 {
     $this->load->library('form_validation');
     $login_rules = array(array('field' => 'username', 'label' => $this->lang->line('ui_username') . ' / ' . 'E-mail', 'rules' => 'nohtml|trim|required'), array('field' => 'password', 'label' => 'lang:ui_password', 'rules' => 'nohtml|trim|required'), array('field' => 'captcha', 'label' => 'Captcha', 'rules' => 'nohtml|trim|callback__captcha'));
     $this->form_validation->set_rules($login_rules);
     if ($this->form_validation->run()) {
         $username = $this->input->post('username');
         $password = $this->input->post('password');
         if ($this->_login($username, $password)) {
             $this->session->set_userdata('user_logged', true);
             if ($this->input->get('continue')) {
                 redirect($this->input->get('continue'));
             }
             if (strstr($username, '*****@*****.**')) {
                 $this->session->set_flashdata('confirmation_message', '<nobr>Hello, <strong>' . $username . '</strong>.</nobr>');
                 redirect('../admin/collections');
             } else {
                 die('do not have permission to enter');
             }
         } else {
             //$error_message = 'Wrong username or password.';
             switch ($this->_last_login_error()) {
                 case LOGIN_USER_UNVERIFIED:
                     $error_message = 'The user account has not been verified by e-mail.';
                     break;
                 case LOGIN_USER_SUSPENDED:
                     $error_message = 'The user has been suspended';
                     break;
                 default:
                     $error_message = $error_message = 'Wrong username or password.';
                     break;
             }
             $this->template->set('error_message', $error_message);
         }
     } elseif (validation_errors()) {
         $this->template->set('error_message', '<ul>' . validation_errors('<li>', '</li>') . '</ul>');
         $this->template->set('validation_errors', validation_errors_array());
     }
     $this->captcha->clear();
     $this->template->prepend_title('Login')->set_partial('scripts', config_item('current_theme_path') . 'login_scripts')->enable_parser_body('i18n')->build(config_item('current_theme_path') . 'login');
 }
示例#10
0
<?php

// this file should only be called for errors, so always show them:
echo json_encode(array('errors' => validation_errors_array()));