コード例 #1
0
 public function _process()
 {
     appMakeTemplateReady($this->template);
     $v = new v6_validator($_POST, $this->template);
     $v->check_string('first_name', 'First Name', 2, 25, true);
     $v->check_string('last_name', 'Last Name', 2, 25, true);
     $v->check_email('email', 'E-Mail Address', true);
     $v->check_password('passwd', 'Password', 4, 20, true, false);
     if (empty($v->message) == false) {
         $this->template->message = 'Please fix input errors.';
         $this->template->show('signup.form');
     } else {
         if ($this->template->user->is_dupe_email($_POST['email']) == true) {
             $this->template->message = 'Please correct input errors below.';
             $this->template->email_hint = 'Account already exists with this email address.';
             $this->template->show('signup.form');
         } else {
             $this->template->user->first_name = $_POST['first_name'];
             $this->template->user->last_name = $_POST['last_name'];
             $this->template->user->email = strtolower($_POST['email']);
             $this->template->user->passwd = $_POST['passwd'];
             $this->template->user->save();
             $this->template->message = 'Account created successfully.  You may now login';
             $this->template->show('login.form');
         }
     }
 }
コード例 #2
0
 public function _process()
 {
     appMakeTemplateReady($this->template);
     $v = new v6_validator($_POST, $this->template);
     $v->check_email('email', 'E-Mail Address', true);
     $v->check_password('passwd', 'Password', 4, 20, true, false);
     if (empty($v->message) == false) {
         $this->template->message = 'Please fix input errors.';
         $this->template->show('login.form');
     } else {
         $acl = new v6_acl('users', 'email', 'passwd');
         if ($acl->authenticate($_POST['email'], $_POST['passwd']) == true) {
             $this->json['mgr_before'] = clone $this->template->mgr;
             // user provided good credentials
             $this->template->mgr->update($acl->user_table->id);
             header('location: /');
         } else {
             // user blew it
             $this->template->message = 'Login Failed';
             $this->template->show('login.form');
         }
     }
 }
コード例 #3
0
 function delete_record($table_name, $var_name, $reqd_admin_level = 0, $must_be_logged_id = false)
 {
     global $registry;
     // start fresh
     $this->data = array();
     $this->data['status'] = AJAX_NO_ERROR;
     $this->data['message'] = '';
     if (isset($this->record) == true) {
         unset($this->record);
     }
     $mgr = new v6_manager();
     $mgr->UserIsLoggedIn(false);
     if (isset($must_be_logged_id) && $must_be_logged_id == true && $mgr->IsLoggedIn == false) {
         $this->data['status'] = AJAX_ACCESS_DENIED;
         $this->data['message'] = 'Access Denied (ADR-1)';
         return $this->data['status'];
     }
     if ($reqd_admin_level == 2 && $mgr->is_almighty == false) {
         $this->data['status'] = AJAX_ACCESS_DENIED;
         $this->data['message'] = 'Access Denied (ADR-2)';
         return $this->data['status'];
     }
     if ($reqd_admin_level == 1 && ($mgr->is_almighty == false && $mgr->is_admin == false)) {
         $this->data['status'] = AJAX_ACCESS_DENIED;
         $this->data['message'] = 'Access Denied (ADR-3)';
         return $this->data['status'];
     }
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->data['status'] = AJAX_ACCESS_DENIED;
         $this->data['message'] = 'Access Denied (ADR-4)';
         return $this->data['status'];
     }
     $registry->helper->load('v6_validator');
     $validator = new v6_validator($_POST);
     // make sure the querystring is a valid number...
     $validator->CheckNumber($var_name, 'Id', 0, 999999);
     $message = $validator->message;
     if (empty($message) == false) {
         $this->data['status'] = AJAX_VALIDATION_FAILURE;
         $this->data['message'] = $message;
         return $this->data['status'];
     }
     $this->record = new v6_table($table_name);
     $this->record->delete_by_id($_POST[$var_name]);
     $this->data['status'] = AJAX_RECORD_DELETED;
     $this->data['message'] = 'Record Deleted';
     return $this->data['status'];
 }