示例#1
0
 public function create()
 {
     if ($post = $this->input->post()) {
         $form = new Validation($post);
         $form->add_rules('title', 'required');
         $form->add_rules('introduction', 'required');
         if ($form->validate()) {
             $island = ORM::factory('island');
             $island->user_id = Auth::instance()->get_user()->id;
             $island->title = $post['title'];
             $island->introduction = $post['introduction'];
             $now = date('Y-m-d H:i:s');
             $island->created = $now;
             $island->modified = $now;
             $island->save();
             if ($island->saved) {
                 $this->session->set_flash('notice', 'Created new island!');
                 url::redirect('/sail/' . $island->code);
             } else {
                 $this->session->set_flash('error', 'Failed to create new island!');
             }
         } else {
             var_dump($form->errors());
             die;
             $this->session->set_flash('error', 'Error validating.');
         }
     }
 }
示例#2
0
 /**
  * Triggers error if identity exists.
  * Validation callback.
  *
  * @param	Validation	Validation object
  * @param	string	  field name
  * @return	void
  */
 public function unique_identity(Validation $validation, $field)
 {
     $identity_exists = (bool) DB::select(array('COUNT("*")', 'total_count'))->from($this->_table_name)->where('identity', '=', $validation['identity'])->and_where('provider', '=', $validation['provider'])->execute($this->_db)->get('total_count');
     if ($identity_exists) {
         $validation->error($field, 'identity_available', array($validation[$field]));
     }
 }
示例#3
0
 public function register($name, $password, $password2, $email)
 {
     if ($password != $password2) {
         throw new UserError('Heslo sa nezhoduje.');
     }
     //overenie spravneho tvaru hesla
     $validation = new Validation();
     $validation->checkPasswordLength($password);
     //aktualny cas
     $date = new DateTime();
     $time = $date->getTimestamp();
     //activation key
     $key = md5(uniqid(rand(), true));
     //data pre DB
     $user = array('name' => $name, 'password' => $this->returnHash($password), 'registration_date' => $time, 'last_visit' => $time, 'email' => $email, 'activation_key' => $key);
     //vlozenie dat do DB
     try {
         Database::insert('users', $user);
     } catch (PDOException $error) {
         throw new UserError('Zadané meno alebo email sa už používa');
     }
     //odoslanie aktivacneho emailu
     try {
         $emailSender = new EmailSender();
         $message = 'Dobrý deň,<br><br>';
         $message .= 'pre dokončenie Vašej registrácie na stránke www.tomasblazy.com kliknite na nasledujúci link:<br><br>';
         $message .= 'www.tomasblazy.com/registracia/' . $name . '/' . $key . '<br><br>';
         $message .= 'V prípade, že ste o žiadnu registráciu nežiadali, tento email ignorujte.<br><br>';
         $message .= 'Ďakujeme<br><br>Tím CodingBlog<br><a href="http://tomasblazy.com">tomasblazy.com</a>';
         $emailSender->send($email, 'Aktivácia účtu na Coding Blog', $message, 'CodingBlog', '*****@*****.**');
     } catch (PDOException $error) {
         throw new UserError($error->getMessage(), 'warning');
     }
 }
 public function validate(Validation $array, $save = FALSE)
 {
     // uses PHP trim() to remove whitespace from beginning and end of all fields before validation
     $array->pre_filter('trim');
     $this->unvalidatedFields = array('survey_attribute_id', 'website_id', 'default_text_value', 'default_float_value', 'default_int_value', 'default_date_start_value', 'default_date_end_value', 'default_date_type_value', 'control_type_id');
     return parent::validate($array, $save, array());
 }
示例#5
0
 public function pdoEditModelAction($id)
 {
     $this->_view->title = 'Model Edit Form';
     $this->_view->link = base_url() . 'pdo-database/pdo-model/pdo-edit-model/' . $id;
     $users = new Users();
     $row = $users->get($id);
     if (empty($row)) {
         redirect('pdo-database/pdo-model/pdo-model');
     }
     $this->_view->data = $row;
     if (!empty($_POST)) {
         $val = new Validation();
         $val->source = $_POST;
         $val->addValidator(array('name' => 'first_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'last_name', 'type' => 'string', 'required' => true));
         $val->addValidator(array('name' => 'email', 'type' => 'email', 'required' => true));
         $val->addValidator(array('name' => 'address', 'type' => 'string', 'required' => true));
         $val->run();
         if (sizeof($val->errors) == 0) {
             $data = array('first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'email' => $_POST['email'], 'address' => $_POST['address']);
             $users->update($id, $data);
             redirect('pdo-database/pdo-model/pdo-model');
         }
         $this->_view->errorMessage = $val->errorMessage();
         $this->_view->data = $_POST;
     }
     $this->renderView('pdo-database/pdo-model/_form');
 }
 public function index()
 {
     if ($this->auth->logged_in()) {
         $this->template->title = 'Already Logged In';
         $this->template->content = new View('login/login_message');
         $this->template->content->message = 'You are already logged in.<br />';
         $this->template->content->link_to_home = 'YES';
         $this->template->content->link_to_logout = 'YES';
         return;
     }
     $this->template->title = 'Forgotten Password Email Request';
     $this->template->content = new View('login/forgotten_password');
     if (request::method() == 'post') {
         $post = new Validation($_POST);
         $post->pre_filter('trim', TRUE);
         $post->add_rules('UserID', 'required');
         $returned = $this->auth->user_and_person_by_username_or_email($_POST['UserID']);
         if (array_key_exists('error_message', $returned)) {
             $this->template->content->error_message = $returned['error_message'];
             return;
         }
         $user = $returned['user'];
         $person = $returned['person'];
         if (!$this->check_can_login($user)) {
             return;
         }
         $this->auth->send_forgotten_password_mail($user, $person);
         $this->template->title = 'Email Sent';
         $this->template->content = new View('login/login_message');
         $this->template->content->message = 'An email providing a link which will allow your password to be reset has been sent to the specified email address, or if a username was provided, to the registered email address for that user.<br />';
     }
 }
示例#7
0
文件: form.php 项目: uzura8/flockbird
 public static function get_fieid_attribute(Validation $val, $name, $default_value = null, $is_textarea = false, $optional_attr = array())
 {
     $field = $val->fieldset()->field($name);
     $label = '';
     $input_attr = array();
     $is_required = false;
     if (is_callable(array($field, 'get_attribute'))) {
         $input_attr = $field->get_attribute();
         $input_attr = Arr::filter_keys($input_attr, array('validation', 'label'), true);
         if ((is_null($default_value) || empty($default_value) && !strlen($default_value)) && !is_null($field->get_attribute('value'))) {
             $default_value = $field->get_attribute('value');
         }
         $is_required = $field->get_attribute('required') == 'required';
         $label = $field->get_attribute('label');
     }
     if (!is_array($optional_attr)) {
         $optional_attr = (array) $optional_attr;
     }
     if ($optional_attr) {
         $input_attr += $optional_attr;
     }
     if (empty($input_attr['id'])) {
         $input_attr['id'] = Site_Form::get_field_id($name);
     }
     if (empty($input_attr['class'])) {
         $input_attr['class'] = 'form-control';
     }
     return array($default_value, $label, $is_required, $input_attr);
 }
 public function validate(Validation $array, $save = FALSE)
 {
     $array->pre_filter('trim');
     $array->add_rules('title', 'required');
     $this->unvalidatedFields = array('code', 'abbreviation', 'description', 'category_id', 'deleted');
     return parent::validate($array, $save);
 }
 function register()
 {
     global $timezones;
     $this->pageTitle = __('register', true);
     $this->set('tzs', $timezones);
     $this->set('utz', $this->data['User']['tz']);
     if (!empty($this->data)) {
         $this->Security->requirePost('register');
         $v = new Validation();
         if ($this->data['User']['email'] !== $this->data['User']['confemail']) {
             $this->User->invalidate('confemail');
         }
         if ($this->User->findByEmail($this->data['User']['email']) || !$v->email($this->data['User']['email'])) {
             $this->User->invalidate('email');
         }
         if ($this->data['User']['password'] !== $this->data['User']['confpass']) {
             $this->User->invalidate('confpass');
         }
         if (!$v->url($this->data['User']['website']) && !empty($this->data['User']['website'])) {
             $this->User->invalidate('website');
         }
         if ($this->User->validates()) {
             $clean = new Sanitize();
             // Generate and set the password, salt and activation key
             $pass = $this->Hash->password($this->data['User']['password'], $this->data['User']['email']);
             $this->data['User']['active'] = $this->Hash->keygen(10, true);
             $this->data['User']['password'] = $pass['pass'];
             $this->data['User']['salt'] = $pass['salt'];
             // Save a few fields from the wrath of cleanArray()
             $temp = array('lat' => $this->data['User']['lat'], 'lng' => $this->data['User']['lng'], 'tz' => $this->data['User']['tz'], 'email' => $this->data['User']['email']);
             // Scrub 'a dub
             $clean->clean($this->data);
             $this->data['User']['email'] = $clean->escape($temp['email']);
             $this->data['User']['lng'] = floatval($temp['lng']);
             $this->data['User']['lat'] = floatval($temp['lat']);
             $this->data['User']['tz'] = intval($temp['tz']);
             $this->data['User']['role'] = 0;
             $this->User->begin();
             if ($this->User->save($this->data)) {
                 $this->Email->to = $this->data['User']['email'];
                 $this->Email->replyTo = $this->data['User']['email'];
                 $this->Email->from = APP_NAME . ' <' . APP_EMAIL . '>';
                 $this->Email->subject = sprintf(__('email_subject_welcome', true), APP_NAME);
                 $this->Email->template = 'register';
                 $this->Email->sendAs = 'both';
                 $this->set('actcode', $this->data['User']['active']);
                 if ($this->Email->send()) {
                     $this->User->commit();
                     $this->Session->setFlash('Account created!');
                 } else {
                     $this->User->rollback();
                     $this->Session->setFlash('Error!');
                 }
             } else {
                 $this->User->rollback();
                 $this->Session->setFlash('Error\'d');
             }
         }
     }
 }
 public function handler()
 {
     access::verify_csrf();
     $form = $this->_get_form();
     $errors = array_fill_keys(array_keys($form), "");
     if ($_POST) {
         $post = new Validation($_POST);
         $post->add_rules("updates_enabled", array("valid", "numeric"));
         $post->add_rules("popular_enabled", array("valid", "numeric"));
         $post->add_rules("updates_limit", array("valid", "numeric"));
         $post->add_rules("popular_limit", array("valid", "numeric"));
         $post->add_rules("updates_description", "length[0,2048]");
         $post->add_rules("popular_description", "length[0,2048]");
         if ($post->validate()) {
             foreach (array("updates", "popular") as $album) {
                 $album_defn = unserialize(module::get_var("dynamic", $album));
                 $album_defn->enabled = $post["{$album}_enabled"];
                 $album_defn->description = $post["{$album}_description"];
                 $album_defn->limit = $post["{$album}_limit"] === "" ? null : $post["{$album}_limit"];
                 module::set_var("dynamic", $album, serialize($album_defn));
             }
             message::success(t("Dynamic Albums Configured"));
             url::redirect("admin/dynamic");
         } else {
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors());
         }
     }
     print $this->_get_view($form, $errors);
 }
示例#11
0
文件: ORM.php 项目: ariol/adminshop
 public function validate(CM_Form_Abstract $form)
 {
     if ($this->_extra_validation) {
         $values = array();
         foreach ($form->get_values() as $name => $value) {
             $values[$name] = $value->get_raw();
             $this->_extra_validation->label($name, $form->get_field($name)->get_label());
         }
         // Validation только read-only, поэтому создаем новый объект
         $this->_extra_validation = $this->_extra_validation->copy($values);
     }
     try {
         $this->get_model()->check($this->_extra_validation);
     } catch (ORM_Validation_Exception $e) {
         $errors = $e->errors('validation');
         if ($external = arr::get($errors, '_external')) {
             $errors = arr::merge($errors, $external);
             unset($errors['_external']);
         }
         foreach ($errors as $name => $error) {
             $form->get_field($name)->set_error($error);
         }
         return FALSE;
     }
     return TRUE;
 }
示例#12
0
function valid($action = 'moderator', $no = 0)
{
    require_once CORE_DIR . "/admin/validate.php";
    $validate = new Validation();
    $allowed = $validate->verify($action);
    return $allowed;
}
示例#13
0
 public function reset()
 {
     if ($this->owner->logged_in()) {
         url::redirect('/admin/testimonials/display');
     }
     $login_shell = new View('admin/login_shell');
     $login_shell->content = new View('admin/reset');
     if (empty($_POST)) {
         die($login_shell);
     }
     $post = new Validation($_POST);
     $post->pre_filter('trim');
     $post->add_rules('email', 'required', 'valid::email');
     # if Post is good, atttempt to log owner in.
     if ($post->validate()) {
         $owner = ORM::factory('owner')->find($_POST['email']);
         if (!$owner->loaded) {
             die('email does not have an account');
         }
         $pw = text::random('alnum', 8);
         $owner->password = $pw;
         $owner->save();
         $replyto = 'unknown';
         $body = "Your auto-generated password is: {$pw} \r\n" . "Change your password to something more appropriate by going here:\r\n" . "http://pluspanda.com/admin/account?old={$pw} \r\n\n" . "Thank you! - Jade from pluspanda";
         # to do FIX THE HEADERS.
         $subject = 'Your Pluspanda Password Has Been Reset =)';
         $headers = "From: noreply@pluspanda.com \r\n" . "Reply-To: Jade \r\n" . 'X-Mailer: PHP/' . phpversion();
         mail($_POST['email'], $subject, $body, $headers);
         die('Please check your email for your new password!');
     }
     # error
     $login_shell->content->alert = alerts::display(array('error' => 'Invalid Email or Password.'));
     $login_shell->content->values = $_POST;
     die($login_shell);
 }
示例#14
0
 private function form_handler($page_name, $newsletter)
 {
     $view = new View('public_newsletter/newsletters/form');
     $view->page_name = $page_name;
     $values = array('name' => '', 'email' => '');
     $view->values = $values;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim');
         $post->add_rules('name', 'required');
         $post->add_rules('email', 'required', 'valid::email');
         if (!$post->validate()) {
             $view->errors = arr::overwrite($values, $post->errors('form_error_messages'));
             $view->values = arr::overwrite($values, $post->as_array());
             return $view;
         }
         include Kohana::find_file('vendor', 'CMBase');
         $cm = new CampaignMonitor(null, null, $newsletter->cm_list_id);
         $result = $cm->subscriberAdd($_POST['email'], $_POST['name']);
         if ($result['Result']['Code'] != 0) {
             kohana::log('error', $result['Result']['Message']);
             return 'There was an error adding you to the emailing list. Please try again later.';
         }
         return 'Thank you! You have been adding to our mailing list.';
     }
     return $view;
 }
示例#15
0
 public function action_edit_field()
 {
     $field_id = $this->request->param('options');
     xml::to_XML(array('field' => array('@id' => $field_id, '$content' => User::get_data_field_name($field_id))), $this->xml_content);
     if (count($_POST) && isset($_POST['field_name'])) {
         $post = new Validation($_POST);
         $post->filter('trim');
         $post->rule('Valid::not_empty', 'field_name');
         if ($post->validate()) {
             $post_values = $post->as_array();
             if ($post_values['field_name'] != User::get_data_field_name($field_id) && !User::field_name_available($post_values['field_name'])) {
                 $post->add_error('field_name', 'User::field_name_available');
             }
         }
         // Retry
         if ($post->validate()) {
             $post_values = $post->as_array();
             User::update_field($field_id, $post_values['field_name']);
             $this->add_message('Field ' . $post_values['field_name'] . ' updated');
             $this->set_formdata(array('field_name' => $post_values['field_name']));
         } else {
             $this->add_error('Fix errors and try again');
             $this->add_form_errors($post->errors());
             $this->set_formdata(array_intersect_key($post->as_array(), $_POST));
         }
     } else {
         $this->set_formdata(array('field_name' => User::get_data_field_name($field_id)));
     }
 }
示例#16
0
 /**
  * Performs validation checks on the geometry file - Checks that at least
  * one of them has been specified using the applicable validation rules
  *
  * @param Validation $array Validation object containing the field names to be checked
  */
 public function file_check(Validation $array)
 {
     // Ensure at least a geometry URL or geometry file has been specified
     if (empty($array->kml_file) and empty($array->kml_file_old)) {
         $array->add_error('geometry_url', 'atleast');
     }
 }
示例#17
0
 /**
  * Validate the item name.  It can't conflict with other names, can't contain slashes or
  * trailing periods.
  */
 public function valid_name(Validation $v, $field)
 {
     $postage_band = ORM::factory("postage_band")->where("name", "=", $this->name)->find();
     if ($postage_band->loaded() && $postage_band->id != $this->id) {
         $v->add_error("name", "in_use");
     }
 }
示例#18
0
 public function action_show()
 {
     $arr = [];
     //Получаем данные из формы
     if (isset($_POST['submit'])) {
         //Проверяем введенные данные на корректность
         $post = new Validation($_POST);
         $post->rule('prime', 'not_empty')->rule('prime', 'numeric');
         if ($post->check()) {
             $max = $_POST['prime'];
             $arr = Controller_PrimeNumber::getPrime($max);
             Controller_DataArchive::saveDB($max, $arr);
         } else {
             $errors = $post->errors('comments');
         }
     }
     //Подготавливаем данные для вида
     $view = View::factory('index');
     if (isset($errors)) {
         $view->err = $errors;
     } else {
         if (!empty($arr)) {
             $view->arr = $arr;
         }
     }
     $this->response->body($view);
 }
示例#19
0
 public function add()
 {
     if (isset($_POST['save'])) {
         $post = new Validation(array_merge($_POST, $_FILES));
         $post->pre_filter('trim', 'typeName', 'typeDescription', 'typeShortDescription', 'metaTitle', 'metaDescription', 'metaKeywords');
         $post->add_rules('typeName', 'required');
         if (!$post->validate()) {
             $errors = $post->errors('form_errors');
             foreach ($errors as $error) {
                 echo '<p class="error">' . $error . '</p>';
             }
         } else {
             $id = $this->uri->segment(3);
             $type = ORM::factory('products_type')->find($id);
             $type->name = $post->typeName;
             $type->category_id = $post->category;
             $type_desc = ORM::factory('products_types_description')->where('id', $type->products_types_description_id)->find();
             $type_desc->short_description = $post->typeShortDescription;
             $type_desc->description = $post->typeDescription;
             $type_desc->meta_title = $post->metaTitle;
             $type_desc->meta_description = $post->metaDescription;
             $type_desc->meta_keywords = $post->metaKeywords;
             $type_desc->title_url = $post->metaUrl;
             $type_desc->image_alt = $post->image_alt;
             $type_desc->video = $post->video;
             if (!empty($_FILES['image']['name'])) {
                 // uses Kohana upload helper
                 $_FILES = Validation::factory($_FILES)->add_rules('image', 'upload::valid', 'upload::type[gif,jpg,jpeg,png]', 'upload::size[2M]');
                 if ($_FILES->validate()) {
                     // Temporary file name
                     $filename = upload::save('image', basename($_FILES['image']['tmp_name']));
                     $file = basename($_FILES['image']['name']);
                     // Resize, sharpen, and save the image
                     Image::factory($filename)->save(DOCROOT . '../../env/product_type_images/' . $file);
                     // Remove the temporary file
                     unlink($filename);
                     $type_desc->image = $file;
                     $type_desc->save();
                 } else {
                     $errors = $_FILES->errors('form_user');
                 }
             }
             $type_desc->save();
             $type->products_types_description_id = $type_desc->id;
             $type->save();
             if (!empty($post->productTypeSites)) {
                 foreach ($post->productTypeSites as $site_id) {
                     $sc = ORM::factory('sites_types')->where('products_type_id', $type->id)->where('site_id', $site_id)->find();
                     if ($sc->id == 0) {
                         $sc->products_type_id = $type->id;
                         $sc->site_id = $site_id;
                         $sc->save();
                     }
                 }
             }
             url::redirect(url::base() . $this->uri->segment(1) . '/' . $this->uri->segment(2) . '/' . $type->id);
         }
     }
     $this->_renderView();
 }
示例#20
0
 private function executeFormValidation()
 {
     $validation = new Validation($this->myView->data);
     $fields['title'] = ['Mandatory'];
     $fields['text'] = ['Mandatory'];
     return $validation->execute($fields);
 }
示例#21
0
 public function password_validate(Validation $array, $save = FALSE)
 {
     $array->pre_filter('trim');
     $array->add_rules('password', 'required', 'length[7,30]', 'matches[password2]');
     $this->forgotten_password_key = NULL;
     return parent::validate($array, $save);
 }
示例#22
0
 public function validate(Validation $array, $save = FALSE)
 {
     $array->pre_filter('trim');
     $array->add_rules('term', 'required');
     $array->add_rules('language_id', 'required');
     return parent::validate($array, $save);
 }
示例#23
0
 function login()
 {
     $authorized = false;
     $error = array();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (strlen($_POST['userid']) > 0) {
             $validation = new Validation();
             if ($message = $validation->userid($_POST['userid'], 'ユーザー名')) {
                 $error[] = $message;
             } else {
                 $userid = $_POST['userid'];
             }
             $_POST['password'] = trim($_POST['password']);
             if ($message = $validation->alphaNumeric($_POST['password'], 'パスワード')) {
                 $error[] = $message;
             } else {
                 $password = md5($_POST['password']);
             }
             if (count($error) <= 0) {
                 $connection = new Connection();
                 $query = sprintf("SELECT id,userid,password,realname,user_group,authority FROM %suser WHERE userid = '%s'", DB_PREFIX, $connection->quote($userid));
                 $data = $connection->fetchOne($query);
                 $connection->close();
                 if (count($data) > 0 && $data['userid'] === $userid && $data['password'] === $password) {
                     $authorized = true;
                 } else {
                     $error[] = 'ユーザー名もしくはパスワードが<br />異なります。';
                 }
             }
         } else {
             $error[] = 'ユーザー名を入力してください。';
         }
     } elseif (isset($_SESSION['status'])) {
         if ($_SESSION['status'] == 'idle') {
             $error[] = '自動的にログアウトしました。<br />ログインしなおしてください。';
         } elseif ($_SESSION['status'] == 'expire') {
             $error[] = 'ログインの有効期限が切れました。<br />ログインしなおしてください。';
         }
         session_unregister('status');
     }
     if ($authorized === true && count($error) <= 0) {
         session_regenerate_id();
         $_SESSION['logintime'] = time();
         $_SESSION['accesstime'] = $_SESSION['logintime'];
         $_SESSION['authorized'] = md5(__FILE__ . $_SESSION['logintime']);
         $_SESSION['userid'] = $data['userid'];
         $_SESSION['realname'] = $data['realname'];
         $_SESSION['group'] = $data['user_group'];
         $_SESSION['authority'] = $data['authority'];
         if (isset($_SESSION['referer'])) {
             header('Location: ' . $_SESSION['referer']);
             session_unregister('referer');
         } else {
             header('Location: index.php');
         }
         exit;
     } else {
         return $error;
     }
 }
示例#24
0
 public function add_photo($id)
 {
     $album = ORM::factory("item", $id);
     access::required("view", $album);
     access::required("add", $album);
     access::verify_csrf();
     $file_validation = new Validation($_FILES);
     $file_validation->add_rules("Filedata", "upload::valid", "upload::type[gif,jpg,png,flv,mp4]");
     if ($file_validation->validate()) {
         // SimpleUploader.swf does not yet call /start directly, so simulate it here for now.
         if (!batch::in_progress()) {
             batch::start();
         }
         $temp_filename = upload::save("Filedata");
         try {
             $name = substr(basename($temp_filename), 10);
             // Skip unique identifier Kohana adds
             $title = item::convert_filename_to_title($name);
             $path_info = pathinfo($temp_filename);
             if (array_key_exists("extension", $path_info) && in_array(strtolower($path_info["extension"]), array("flv", "mp4"))) {
                 $movie = movie::create($album, $temp_filename, $name, $title);
                 log::success("content", t("Added a movie"), html::anchor("movies/{$movie->id}", t("view movie")));
             } else {
                 $photo = photo::create($album, $temp_filename, $name, $title);
                 log::success("content", t("Added a photo"), html::anchor("photos/{$photo->id}", t("view photo")));
             }
         } catch (Exception $e) {
             unlink($temp_filename);
             throw $e;
         }
         unlink($temp_filename);
     }
     print "File Received";
 }
 public function activate()
 {
     access::verify_csrf();
     $post = new Validation($_POST);
     $post->add_rules("activate_users", "required");
     $post->add_rules("activate", "alpha_numeric");
     if ($post->validate()) {
         $names = array();
         if (!empty($post->activate)) {
             foreach ($post->activate as $id) {
                 $user = register::create_new_user($id);
                 $names[] = $user->name;
             }
             message::success(t("Activated %users.", array("users" => implode(", ", $names))));
         }
         $count = ORM::factory("pending_user")->where("state", "!=", 2)->count_all();
         if ($count == 0) {
             site_status::clear("pending_user_registrations");
         }
         url::redirect("admin/register");
     }
     list($form, $errors) = $this->_get_form();
     $form = array_merge($form, $post->as_array());
     $errors = array_merge($errors, $post->errors());
     print $this->_get_admin_view($form, $errors);
 }
示例#26
0
 public function process($parameters)
 {
     //do control panela maju pristup len prihlaseny uzivatelia
     $this->checkUser();
     //hlavicka stranky
     $this->head['title'] = 'Ovládací panel';
     $userManager = new UserManager();
     $validation = new Validation();
     //zadane URL pre odhlasenie
     if (!empty($parameters[0]) && $parameters[0] == 'odhlasit') {
         $userManager->logOut();
         $this->redirect('prihlasenie');
     }
     //data pre sablonu
     $user = $userManager->returnUser();
     $this->data['admin'] = $user['admin'];
     $this->data['userRank'] = $validation->returnUserRank($user['admin']);
     $this->data['user'] = $user['name'];
     $this->data['avatar'] = $user['avatar'];
     $this->data['registrationDate'] = $user['registration_date'];
     $this->data['lastVisit'] = $user['last_visit'];
     $this->data['comments'] = $user['comments'];
     $this->data['articles'] = $user['articles'];
     $this->data['sex'] = $user['sex'];
     $this->data['email'] = $user['email'];
     //nastavenie sablony
     $this->view = 'controlPanel';
 }
示例#27
0
 public function validate(Validation $array, $save = FALSE)
 {
     // uses PHP trim() to remove whitespace from beginning and end of all fields before validation
     $array->pre_filter('trim');
     $this->unvalidatedFields = array('user_id', 'website_id', 'site_role_id');
     return parent::validate($array, $save);
 }
 public function validation_settings(Validation $v)
 {
     // Rules
     $v->add_rules('good_id', 'required', 'numeric', 'length[30]', array($v, 'unique_ids'));
     $v->add_rules('bad_id', 'required', 'numeric', 'length[30]', array($v, 'unique_ids'));
     // Errors
 }
示例#29
0
 public function getUserName($fatherId)
 {
     require_once 'validation.php';
     $obj_val = new Validation();
     $username = $obj_val->IdToUserName($fatherId);
     return $username;
 }
 public function getUserId($user_name)
 {
     require_once 'Validation.php';
     $obj_vali = new Validation();
     $user_id = $obj_vali->userNameToId($user_name);
     return $user_id;
 }