public function checkActivation() { $active = Session::get('active'); if ($active !== '1') { $this->return_json(array('fail' => Lang::get('fail-registered-users') . '.<br>' . Lang::get('fail-chat-unregistered'))); die; } }
public static function current_status($id = false) { if ($id == false) { $id = Session::get('id'); } $progress = (array) MfrUsersProgress::where('user_id', $id)->as_array()->last(); return array(array('key' => Lang::get('current-objective'), 'value' => $progress['objective'], 'prefix' => ''), array('key' => Lang::get('cardio'), 'value' => $progress['cardio'] . ' ' . Lang::get('days'), 'prefix' => Lang::get('per-week')), array('key' => Lang::get('kcals'), 'value' => $progress['kcals'], 'prefix' => 'kcals'), array('key' => Lang::get('protein'), 'value' => $progress['protein'], 'prefix' => 'g/' . Lang::get('day')), array('key' => Lang::get('carbs'), 'value' => $progress['carbs'], 'prefix' => 'g/' . Lang::get('day')), array('key' => Lang::get('fats'), 'value' => $progress['fats'], 'prefix' => 'g/' . Lang::get('day')), array('key' => Lang::get('macros'), 'value' => $progress['macros'], 'prefix' => 'HC/P/G')); }
public static function wp_unique_user($user_login, $user_email) { # check for uniqueness of username $u = self::where('user_login', $user_login)->get(); if (sizeof($u) > 0) { return array(Lang::get('username-exists-error')); } # check for uniqueness of email $u = self::where('user_email', $user_email)->get(); if (sizeof($u) > 0) { return array(Lang::get('email-exists-error')); } return false; }
public static function workoutInstructionsFacade($workout_id) { $sql = 'SELECT instructions FROM `mfr_treinos` WHERE id = ? LIMIT 1'; $stmt = \Mariana\Framework\Database::getConnection()->prepare($sql); $stmt->bindParam(1, $workout_id); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); $result = explode(',', $result['instructions']); $instructions = array(); foreach ($result as $value) { array_push($instructions, Lang::get($value)); } return $instructions; }
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; } } }
public function myRecipes() { $scope = array('title' => 'Make Fit Real User Area', 'website' => $this->website, 'csrf' => $this->csrf, 'intro-title' => Lang::get('intro-title-diet')); $navbar_stuff = $this->navbar_stuff(); $scope['navbar-stuff'] = $navbar_stuff['stuff']; $scope['navbar-links'] = $navbar_stuff['links']; $scope['coaching-status'] = MfrUsers::current_status(); $scope['average-status']['kcals'] = $scope['coaching-status'][2]['value'] / 4; $scope['average-status']['protein'] = $scope['coaching-status'][3]['value'] / 4; $scope['average-status']['carbs'] = $scope['coaching-status'][4]['value'] / 4; $scope['average-status']['fat'] = $scope['coaching-status'][5]['value'] / 4; $scope['average-status']['macros'] = $scope['coaching-status'][6]['value']; $scope['recipes'] = MfrUserRecipes::allRecipes(Session::get('id')); View::render('coaching/user/diet/adapt-from-blog/index.php', $scope); }
public static function singleRecipe() { return array('refs' => array(array('name' => 'ref 1 name', 'image' => COACHING_URL . '/app/www/img/recipe_sample.png', 'description' => 'xxx yyy vasom kjzomasaig jsamjxk jnvfk r jjz ksdfjn rsjijv sdfu sjvnfuin jksnerfiuw buyerb', 'alimentos' => array(array('name' => 'alimento 1', 'quantity' => '100g'), array('name' => 'alimento 2', 'quantity' => '200g')), 'macros' => array(array('name' => Lang::get('kcals'), 'quantity' => '2000'), array('name' => Lang::get('protein'), 'quantity' => '175'), array('name' => Lang::get('carbs'), 'quantity' => '300'), array('name' => Lang::get('fats'), 'quantity' => '75'))), array('name' => 'ref 2 name', 'image' => COACHING_URL . '/app/www/img/recipe_sample.png', 'description' => 'xxx yyy vasom kjzomasaig jsamjxk jnvfk r jjz ksdfjn rsjijv sdfu sjvnfuin jksnerfiuw buyerb', 'alimentos' => array(array('name' => 'alimento 1', 'quantity' => '100g'), array('name' => 'alimento 2', 'quantity' => '200g')), 'macros' => array(array('name' => Lang::get('kcals'), 'quantity' => '2000'), array('name' => Lang::get('protein'), 'quantity' => '175'), array('name' => Lang::get('carbs'), 'quantity' => '300'), array('name' => Lang::get('fats'), 'quantity' => '75')))), 'macros' => array(array('name' => Lang::get('kcals'), 'quantity' => '2000'), array('name' => Lang::get('protein'), 'quantity' => '175'), array('name' => Lang::get('carbs'), 'quantity' => '300'), array('name' => Lang::get('fats'), 'quantity' => '75'))); }
public function organizeRecipe(array $recipe_array, $carbs_per_recipe, $protein_per_recipe, $fat_per_recipe) { $recipe_num = sizeof($recipe_array); $return = array(); $return['refs'] = array(); $return['macros'] = array(); $total['kcals'] = 0; $total['protein'] = 0; $total['carbs'] = 0; $total['fats'] = 0; foreach ($recipe_array as $recipe) { $recipe_description = $this->calcSingleRecipe($carbs_per_recipe, $protein_per_recipe, $fat_per_recipe, $recipe); $tmp_alimentos = array(); foreach ($recipe_description as $items) { foreach ($items as $item) { if (is_array($item)) { array_push($tmp_alimentos, array('name' => $item['name'], 'quantity' => $item['quantity'])); } } } $recipe_info = MfrUserRecipes::find($recipe)[0]; $tmp_ref = array('name' => $recipe_info->name, 'image' => $recipe_info->thumbnail, 'description' => $recipe_info->instructions, 'alimentos' => $tmp_alimentos, 'macros' => array(array('name' => Lang::get('kcals'), 'quantity' => ($recipe_description['macros']['carbs'] + $recipe_description['macros']['protein']) * 4 + $recipe_description['macros']['fats'] * 9), array('name' => Lang::get('protein'), 'quantity' => $recipe_description['macros']['protein']), array('name' => Lang::get('carbs'), 'quantity' => $recipe_description['macros']['carbs']), array('name' => Lang::get('fats'), 'quantity' => $recipe_description['macros']['fats']))); $total['kcals'] = $total['kcals'] + ($recipe_description['macros']['carbs'] + $recipe_description['macros']['protein']) * 4 + $recipe_description['macros']['fats'] * 9; $total['protein'] = $total['protein'] + $recipe_description['macros']['protein']; $total['carbs'] = $total['carbs'] + $recipe_description['macros']['carbs']; $total['fats'] = $total['fats'] + $recipe_description['macros']['fats']; array_push($return['refs'], $tmp_ref); } $return['macros'] = array(array('name' => Lang::get('kcals'), 'quantity' => $total['kcals']), array('name' => Lang::get('protein'), 'quantity' => $total['protein']), array('name' => Lang::get('carbs'), 'quantity' => $total['carbs']), array('name' => Lang::get('fats'), 'quantity' => $total['fats'])); return $return; }
/** * Default method; */ public function tracking($request = array()) { $user_id = Session::get('id'); $time = time(); /** * @recieved: * POST http://localhost:8000/coaching/workout-tracking/ array(4) { ["workout-id"]=>string(1) "1" ["workout-day"]=>string(1) "1" ["weight"]=>array(3) { [11]=>string(1) "0" [1]=>string(1) "0" [16]=>string(1) "0" } ["exercise-complete"]=>array(3) { [11]=>string(5) "false" [1]=>string(5) "false" [16]=>string(5) "false" } } * @objective: update into mfr-treinos-progresso if ( ['exercise-complete'][id] = "true" */ foreach ($request['exercise-complete'] as $key => $pair) { $exercise_id = $key; if ($pair == 'true') { $sql = 'UPDATE `mfr_treinos_progresso` SET `weight` = ?, `last_updated` = ?, `attempts` = 0 WHERE `mfr_treinos_progresso`.`user_id` = ? AND `mfr_treinos_progresso`.`exercise_id` = ? AND `mfr_treinos_progresso`.`workout_id` = ?;'; $stmt = Database::getConnection()->prepare($sql); $stmt->bindParam(1, $request['weight'][$key]); $stmt->bindParam(2, $time); $stmt->bindParam(3, $user_id); $stmt->bindParam(4, $key); $stmt->bindParam(5, $request['workout-id']); $stmt->execute(); } if ($pair == 'false') { if ($request['attempts'][$key] + 1 > 3) { array_push($this->errors, Lang::get('maximum-attemps-at-exercise')); (double) ($new_weight = (double) $request['weight'][$key] * 0.75); $sql = 'UPDATE `mfr_treinos_progresso` SET `weight` = ?, `last_updated` = ?, `attempts` = 0 WHERE `mfr_treinos_progresso`.`user_id` = ? AND `mfr_treinos_progresso`.`exercise_id` = ? AND `mfr_treinos_progresso`.`workout_id` = ?;'; $stmt = Database::getConnection()->prepare($sql); $stmt->bindParam(1, $new_weight); $stmt->bindParam(2, $time); $stmt->bindParam(3, $user_id); $stmt->bindParam(4, $key); $stmt->bindParam(5, $request['workout-id']); $stmt->execute(); } else { $attempts = $request['attempts'][$key] + 1; $sql = 'UPDATE `mfr_treinos_progresso` SET `last_updated` = ?, `attempts` = ? WHERE `user_id` = ? AND `mfr_treinos_progresso`.`exercise_id` = ? AND `workout_id` = ?;'; $stmt = Database::getConnection()->prepare($sql); $stmt->bindParam(1, $time); $stmt->bindParam(2, $attempts); $stmt->bindParam(3, $user_id); $stmt->bindParam(4, $key); $stmt->bindParam(5, $request['workout-id']); $stmt->execute(); } } } echo json_encode(array('success' => 'ok', 'errors' => $this->errors)); }
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'); }
</form> </div> <!-- // Closing the template --> </div><!-- //Account end ---> <script src="<?php echo mfr_path(); ?> app/www/js/report.js" ></script> <script> var toast_report_success = "<?php echo \Mariana\Framework\Language\Lang::get('success'); ?> "; var toast_report_message = "<?php echo \Mariana\Framework\Language\Lang::get('toast-success-message'); ?> "; $('#user-report-form').submit(function(e) { e.preventDefault(); var height = $('#user-first-report-height').val(); var weight = $('#user-first-report-weight').val(); var neck = $('#user-first-report-neck').val(); var waist = $('#user-first-report-waist').val(); var hip = $('#user-first-report-hip').val(); var extras = $('#user-first-report-extras').val(); var report = new Report('<?php echo mfr_path();
private function navbar_stuff() { Session::get('nice_name') ? $nice_name = Session::get('nice_name') : ($nice_name = Lang::get('guest')); Session::get('id') ? $logout = Lang::get('logout') : ($logout = Lang::get('sign-in')); switch (Session::get('level')) { case 1: // Make Fit Real Manager $links = $this->user_links; break; case 2: // Make Fit Real Coach $links = $this->coach_links; break; default: // Make Fit Real User $links = $this->manager_links; } return array('stuff' => array('welcome' => Lang::get('hello'), 'user_nice_name' => $nice_name, 'logout' => $logout, 'please-contact-admin' => Lang::get('please-contact-admin'), 'unable-to-preform-action' => Lang::get('unable-to-preform-action'), 'fail' => Lang::get('fail'), 'success' => Lang::get('success')), 'links' => $links); }