Пример #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);
 }
Пример #2
0
 public function index()
 {
     View::render('layout.php');
     $_POST['username'] = '******';
     $_POST['password'] = '******';
     $inputs = array('username' => array('name' => 'nome de utilizador', 'required' => true, 'alfanum' => true), 'password' => array('name' => 'palavra passe', 'matches' => 'username', 'alfanum' => true, 'min' => 3, 'max' => 32));
     \Mariana\Framework\Validation\Validation::check($inputs);
     /*
     echo '<pre>';
     var_dump(Users::where('id',1)->contacts()->get());
     echo '</pre>';
     //$u = Users::where('id','1')->join('comments','user_id')->get();
     //echo $u;
     /*
     $u = Users::all();
     foreach($u as $delete){
     
     }
     $u = new Users();
     $u->name = md5(rand(1,10));
     $u->password = md5(rand(1,10));
     $u->save('array');
     
     
     $u = new Users(37);
     $u->password = '******';
     $u->save('array');
     
     var_dump($u);
     
     $u = Users::all();
     
     echo '<pre>' , var_dump(Users::where('name','=','0')->as_array()->get(1)), '</pre>';
     echo '<pre>' , var_dump(Users::all('array')), '</pre>';
     echo '<pre>';
         foreach($u as $single){
             echo $single->id;
         }
     echo '</pre>';
     echo '<pre>' ;
     foreach ((array)\Mariana\Framework\Session\Flash::showMessages() as $m) {
         echo $m;
     };
     echo '</pre>';
     $v = new View('upload');
     
     
     /*
     $to = "*****@*****.**";
     $subject = "teste";
     
     $e = new Mariana\Framework\Email\Email();
     //$e->SendMail("*****@*****.**",$to,$subject,"lorem ipsum");
     //include_once(ROOT."/mvc/views/layout.php");
     
     $v = new View('layout');
     //Log::store('security','teste se isto está a fazer o log como deve de ser',true);
     
     
     $c = new \Mariana\Framework\Cache\Cache();
     
     if($c->isCache('feedzz')){
        $c->write('feedzz' , 'xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz');
     }
     echo $c->read('feedzz');
     
     /*
     $scope = array($to,$subject);
     $v = new View("layout.html");
     $v->with($scope);
     /*
             $u = Users::find(1);
             print_r($u);
     
             $content = file_get_contents($_SERVER['DOCUMENT_ROOT']."/app/frameworkz/email/templates/bluechimp/base_boxed_2column_query.html");
             echo $content;
     
     
             //echo "<pre>";
     /*
             $u = Users::find(33);
             $u->contactNumber();
             print_r($u->toArray());
     
             print_r($u);
     */
     /*
             $u = Users::find(33);
             $u->contactNumbers();
             print_r($u->toArray());
     
             print_r($u);
     
     *
             $u = Users::where("id",">","33")->get();
             $u->usersContactNumber();
     
             print_r($u);
     
     
             $u = Users::where("id",">","33")->get();
             $u->usersContactNumbers();
     
             print_r($u);
     */
     /*
             $u = Users::find(33);
             $u->contactNumbers();
             print_r($u->toArray());
     
            // print_r(->contactNumber());
             print_r(Users::find(33)->contactNumbers());
     
             //print_r(Users::find(33));
     
     /*
             echo "<hr>";
             print_r(
                 Users::where("id","1",">")
                     ->get()
                     ->toArray()
             );
             echo "<hr>";
     */
     /*
     $u = new Users();
     $u->first_name = "josélio";
     $u->last_name = "maria";
     $u->email = "*****@*****.**";
     $u->save();
     print_r($u);
     
     $u = new Users(2);
     $u->first_name = "peter";
     $u->last_name = "north";
     $u->email = "*****@*****.**";
     $u->save();
     print_r($u);
     
     print_r(
         Users::where("id","1",">")
             ->offset(5)
             ->first()
     );
     
     print_r(
         Users::where("id","1",">")
             ->offset(3)
             ->last()
     );
     
     print_r(
         Users::where("id","1")
             ->also("email","*****@*****.**")
             ->get()
     );
     
     
     /*
     print_r(
     Users::where("id","1")
         ->first()
     );
     
     
     
     /*
     echo "User Model - select without specific query<br>";
     print_r(
         Users::where("id","0",">")
             ->also("email","*****@*****.**")
             ->get()
     );
     echo "<hr>";
     
     echo "User Model - select without specific query<br>";
     print_r(
         Users::where("id","0",">")
             ->offset(2)
             ->desc()
             ->get(3)
     );
     echo "<hr>";
     echo "</pre>";
     */
     echo "</pre>";
 }
Пример #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');
 }