Beispiel #1
0
 public function report($params)
 {
     $this->resetStatus();
     $inputs = array('height' => array('name' => 'height', 'required' => true, 'number' => true), 'weight' => array('name' => 'weight', 'required' => true, 'number' => true), 'neck' => array('name' => 'neck', 'required' => true, 'number' => true), 'waist' => array('name' => 'waist', 'required' => true, 'number' => true), 'extras' => array('name' => 'extras', 'alfanum' => true));
     Session::get('gender') == 2 ? $inputs['hip'] = array('required' => true, 'numeric' => true) : ($params['hip'] = '');
     $v = Validation::check($inputs);
     if ($v == false) {
         $this->status['errors'] = Flash::showMessages();
         $this->return_json($this->status);
         return false;
     } else {
         $r = new MfrUserReport();
         $r->last_updated = time();
         $r->user_id = Session::get('id');
         $r->height = $params['height'];
         $r->weight = $params['weight'];
         $r->neck_measurement = $params['neck'];
         $r->waist_measurement = $params['waist'];
         $r->waist_measurement = $params['waist'];
         $r->hip_measurement = $params['hip'];
         $r->waist_measurement = $params['waist'];
         $r->observations = $params['extras'];
         $r->save();
         $this->status['success'] = 'ok';
     }
     return $this->return_json($this->status);
 }
Beispiel #2
0
 public function move($file, $destination = false)
 {
     /**
      * @param $file
      * @param bool|false $destination
      * @return bool
      * @desc moves the file to the correct destination
      */
     if ($this->validate($file)) {
         # Unique Name;
         $file_name_new = time() . '_' . uniqid('', true) . '.' . $this->file_ext;
         # Setting the destination
         if ($destination == false) {
             $destination = FILE_PATH . DS . 'uploads';
         }
         $destination = trim(trim($destination, DS), '/') . DS . $file_name_new;
         # Move the uploaded file
         if (move_uploaded_file($this->file_tmp, $destination)) {
             $this->reset();
             return $destination;
         } else {
             Flash::setMessages(array(Lang::get(4)));
             return false;
         }
     }
 }
Beispiel #3
0
 public function signup($params = array())
 {
     # Requirements
     $this->load();
     $this->status['status'] = 'fail';
     # Params
     $user_login = $params['username'];
     $user_name = $params['name'];
     $user_email = $params['email'];
     $user_password = $params['password'];
     $user_password_2 = $params['password_confirm'];
     $brought_by = $params['code'];
     $brought_by = str_replace('#mfr_', '', strtolower($brought_by));
     # Validation
     if (!Session::csrf($params['mariana-csrf'])) {
         $this->status['errors'] = array(Lang::get('csrf-check-fail'));
         $this->return_json($this->status);
         return header('HTTP/1.0 200 OK');
     }
     $inputs = array('username' => array('name' => 'username', 'required' => true, 'alfanum' => true), 'password' => array('name' => 'password', 'required' => true, 'alfanum' => true, 'min' => 3, 'max' => 32), 'password_confirm' => array('name' => 'password_confirm', 'matches' => 'password', 'required' => true), 'email' => array('required' => true, 'email' => true));
     if (Validation::check($inputs) === false) {
         $this->status['errors'] = Framework\Session\Flash::showMessages();
         $this->return_json($this->status);
         return header('HTTP/1.0 200 OK');
     }
     $check_if_username_exists = WpUsers::wp_unique_user($user_login, $user_email);
     if ($check_if_username_exists) {
         $this->status['errors'] = $check_if_username_exists;
         $this->return_json($this->status);
         return header('HTTP/1.0 200 OK');
     }
     # Create entry on both databases
     $user_id = wp_create_user($user_login, $user_password, $user_email);
     MfrUsers::wp_create_user($user_id, $user_name, $brought_by);
     # Notify
     wp_new_user_notification($user_id, $user_password);
     # Sign the user in
     $params = array();
     $params['username'] = $user_login;
     $params['password'] = $user_password;
     $this->login($params);
     $this->return_json($this->status);
     # Forcing code 200 - Dunno why but keeps failing on this specific function
     return header('HTTP/1.0 200 OK');
 }
Beispiel #4
0
    <?php 
}
?>
    <div>
        <button onclick="login()" type="submit"><b>Login</b></button>
        <small ><a onclick="recovery()">Forgot your password?</a></small>
        <br>
        <small><span ><ul id="recovery_errors"></ul></span></small>
        <small>
            <span >
                <ul id="login_errors">
                    <?php 
if (\Mariana\Framework\Session\Flash::showMessages()) {
    ?>
                        <?php 
    foreach (\Mariana\Framework\Session\Flash::showMessages() as $flash) {
        ?>
                            <p><?php 
        echo $flash;
        ?>
</p>
                        <?php 
    }
    ?>
                    <?php 
}
?>
                </ul>
            </span>
        </small>
    </div>
Beispiel #5
0
 public static function check(array $items = array())
 {
     foreach ($items as $key => $item) {
         $request = self::checkRequest($key);
         isset($item['name']) && $item['name'] ? $name = $item['name'] : ($name = $key);
         foreach ($item as $rule => $value) {
             if ($request) {
                 if ($rule !== 'name') {
                     self::validateItem($request, $rule, $value) !== false ?: self::setError("Invalid value in the following input: " . $rule);
                 }
             }
         }
     }
     if (self::$error_count > 0) {
         Flash::setMessages(self::$errors);
         return false;
     } else {
         return true;
     }
 }