Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class IndexController extends Controller {
- public function _init() {
- $this->layout->name = "Index";
- if (!checkLogged()) {
- $this->_redirect(BASE_URL . 'signin');
- }
- }
- public function changePasswordAction() {
- // don't need create layout
- $this->setNoRender();
- $password = trim($_POST['current_pass']);
- $new_password = trim($_POST['new_pass']);
- $repeat_new_password = trim($_POST['repeat_pass']);
- $user_id = $_SESSION['user'][id];
- $model_user = new Model_Azuser();
- $oneUser = $model_user->findOneUser($user_id);
- if ($_POST) {
- if (md5($password) === $oneUser['password']) {
- if (strlen($new_password) >= 6 && strlen($new_password) <= 100) {
- if ($new_password == $repeat_new_password) {
- $data = array(
- 'password' => md5($new_password)
- );
- $model_user->updatePassword($user_id, $data);
- $r = 0;
- } else {
- $r = 1;
- $msg = "Password does not match. Please try again.";
- }
- } else {
- $r = 2;
- $msg = 'Password must contain at least 6 characters. Please try again.';
- }
- } else {
- $r = 3;
- $msg = "Your current password is incorrect. Please try again.";
- }
- if($this->_isAjaxRequest()){
- $this->setNoRender();
- $res = array(
- 'r' => $r,
- 'msg'=>$msg,
- );
- echo json_encode($res);
- }
- }
- }
- public function indexAction() {
- $model_user = new Model_Azuser();
- $oneUser = $_SESSION['user'];
- $currentTeam = $_SESSION['currentTeam'];
- if (!$currentTeam) {
- $this->_redirect(BASE_URL . 'team/listTeam');
- }
- $this->view->config = $currentTeam;
- $myProfile = array(
- "azStackUserID" => $oneUser['id'],
- "userCredentials" => $oneUser['password'],
- "fullname" => $oneUser['fullname'],
- "avatar" => $oneUser['avatar90'] ? (EMMA_STATIC_URL . $oneUser['avatar90']) : '',
- "userId" => null,
- "status" => 1,
- "currentTime" => time()
- );
- $this->view->myProfile = json_encode($myProfile);
- }
- /**
- * Logout
- */
- public function signoutAction() {
- setcookie('user', "", time() - (60 * 60 * 24 * 7), "/");
- unset($_SESSION['user']);
- unset($_SESSION['currentTeam']);
- $this->_redirect(BASE_URL . 'signin');
- }
- }
Add Comment
Please, Sign In to add comment