public function actionIndex() { $this->View->title = 'Mi cuenta'; $modelAccount = new FormAccount(); $contact = Users::find()->one(Gbox::$components->user->id); $modelAccount->firstname = $contact->firstname; $modelAccount->lastname = $contact->lastname; $modelAccount->email = $contact->email; $modelAccount->username = $contact->username; if (Gbox::getRequest()->isPost() && $modelAccount->load(Gbox::getRequest()->post())) { if (!empty($modelAccount->password) && $modelAccount->password != $modelAccount->password_confirm) { $modelAccount->addError('password_confirm', 'La contraseña debe coincidir con la confirmación.'); } if ($modelAccount->validate()) { $table = new Users(); $table->firstname = $modelAccount->firstname; $table->lastname = $modelAccount->lastname; $table->email = $modelAccount->email; if (!empty($modelAccount->password) && $modelAccount->password == $modelAccount->password_confirm) { $table->password = crypt($modelAccount->password, '$2y$10$' . Gbox::getConfig()->params['salt']); } if ($table->update(Gbox::$components->user->id)) { $msg = 'Se ha editado su cuenta con éxito.'; Session::set('response', ['msg' => $msg, 'type' => 'success']); } else { Session::set('response', ['msg' => 'Ha ocurrido un error al editar su cuenta.', 'type' => 'danger']); } } else { Session::set('response', ['msg' => 'Ocurrió un error, revise los campos y vuelva a intentarlo.', 'type' => 'warning']); } } return $this->render('index', ['modelAccount' => $modelAccount]); }
public function actionIndex() { $files = []; $dir = \Gbox::$components->debug->getPath(); if ($handle = opendir($dir)) { while (false !== ($entry = readdir($handle))) { if ($entry != '.' && $entry != '..' && strpos($entry, 'debug') === 0) { $data = Json::decode(file_get_contents(\Gbox::$components->debug->getFile($entry))); if ($data[0]['session'] == session_id()) { // $files[] = $entry; $files[filemtime($dir . $entry)] = $entry; } } } closedir($handle); krsort($files); } Session::set('files-debug', $files); if (!($current = \Gbox::getRequest()->get('id'))) { reset($files); $current = current($files); Session::set('files-debug-current', $current); } Session::set('files-debug-current', $current); return $this->render('index', ['files' => $files]); }
public function login($user = null, $remember = 0) { if ($user === null) { $this->_identity = null; return false; } else { if (is_numeric($user)) { $this->id = $user; $data = get_object_vars($this->findIdentity($this->id)); } else { $data = get_object_vars($user); $this->id = $user->{$this->keyId()}; } foreach ($data as $key => $value) { if ($key === 'id') { continue; } if (property_exists($this, $key)) { $this->{$key} = $value; } } $data = Gbox::arrayToObject($data); $this->isGuest = false; if ($remember > 1) { $cookie_id = new Cookie(); $cookie_id->name = '__' . $this->alias(); $cookie_id->value = $this->id; $cookie_id->expire = time() + $remember; $cookie_auth_key = new Cookie(); $cookie_auth_key->name = '__' . $this->alias() . '_auth_key'; $cookie_auth_key->value = $this->auth_key; $cookie_auth_key->expire = time() + $remember; Gbox::getResponse()->getCookies()->set($cookie_id); Gbox::getResponse()->getCookies()->set($cookie_auth_key); } Session::set('__' . $this->alias(), $this->id); Session::set('__' . $this->alias() . '_auth_key', $this->auth_key); return true; } }