function logoutAction() { if (!User::factory()->_admin) { HTTP::redirect('backend/' . Route::controller() . '/login'); } User::factory()->logout(); HTTP::redirect('backend/' . Route::controller() . '/login'); }
public function before() { User::factory()->is_remember(); $this->redirects(); $cron = new Cron(); $cron->check(); $this->config(); $this->access(); }
public function loginAction() { $login = Arr::get($_POST, 'login'); $password = Arr::get($_POST, 'password'); $remember = Arr::get($_POST, 'remember'); $u = User::factory(); $user = $u->get_user_if_isset($login, $password, 1); if (!$user or $user->role == 'user') { die(json_encode(array('msg' => 'Логин или пароль введены неверно!'))); } $u->auth($user, $remember); die(json_encode(array('success' => true))); }
function sendAction() { $id = (int) Route::param('id'); $user = Model::getRow($id); if (!$user) { Message::GetMessage(0, 'Пользователь не существуют!'); HTTP::redirect('backend/admins/index'); } if ($user->deleted || $user->status == 0) { Message::GetMessage(1, 'Пользователь удален или заблокирован!'); HTTP::redirect('backend/admins/index'); } if (!filter_var($user->email, FILTER_VALIDATE_EMAIL)) { Message::GetMessage(1, 'E-Mail пользователя некорректен!'); HTTP::redirect('backend/admins/index'); } // Generate new password for user and save it to his account $password = User::factory()->generate_random_password(); User::factory()->update_password($user->id, $password); // Send E-Mail to user with instructions how recover password $mail = Common::factory('mail_templates')->getRow(5); if ($mail) { $from = array('{{site}}', '{{ip}}', '{{date}}', '{{password}}'); $to = array(Arr::get($_SERVER, 'HTTP_HOST'), System::getRealIP(), date('d.m.Y H:i'), $password); $subject = str_replace($from, $to, $mail->subject); $text = str_replace($from, $to, $mail->text); Email::send($subject, $text, $user->email); } Message::GetMessage(1, 'Новый пароль отправлен на E-Mail пользователя!'); HTTP::redirect('backend/admins/index'); }
function editAction() { $result = DB::select()->from($this->tablename)->where('id', '=', Route::param('id'))->find(); // Set edit access for myself orders if ($result->creator_id == User::info()->id) { User::factory()->_current_access = 'edit'; } if (User::info()->role_id != 2 and $result->admin_brone == 1) { $this->no_access(); } $afisha = DB::select('afisha.*', array('places.name', 'place'), 'places.filename')->from('afisha')->join('places')->on('afisha.place_id', '=', 'places.id')->where('afisha.id', '=', $result->afisha_id)->find(); // Generate and parse inner map $orderSeats = array(); $viewKeys = array_filter(explode(',', $result->seats_keys)); if (count($viewKeys)) { $prices = DB::select()->from('prices')->where('afisha_id', '=', $result->afisha_id)->find_all(); if (count($prices)) { $pricesIds = array(); foreach ($prices as $key => $value) { $pricesIds[] = $value->id; } $seatsQuery = DB::select()->from('seats')->where('view_key', 'IN', $viewKeys)->where('price_id', 'IN', $pricesIds)->execute()->as_array(); foreach ($seatsQuery as $key => $value) { $orderSeats[$value['view_key']] = $value; } } } $seatsStr = array(); if ($afisha) { $seats = \Modules\Afisha\Models\Afisha::getMapSeats($result->afisha_id); $mapObj = Map::factory()->loadFile($afisha->filename); $innerMap = $mapObj->parseDomOrder($orderSeats, $seats, true, true); $seatsArr = array(); foreach ($seats as $seat) { $seatsArr[] = $seat['view_key']; } try { $dom = Map::factory()->loadFile($afisha->filename)->getDomInstance(); $gTag = $dom->getElementsByTagName('g'); foreach ($gTag as $el) { $id = $el->getAttribute('id'); if (in_array($id, $seatsArr)) { if ($el->parentNode->hasAttribute('data-plase')) { $place = $el->parentNode->getAttribute('data-plase'); } elseif ($el->parentNode->parentNode->hasAttribute('data-plase')) { $place = $el->parentNode->parentNode->getAttribute('data-plase'); } if ($place) { $place = str_replace('(левая сторона)', '(лев. сторона)', $place); $place = str_replace('(правая сторона)', '(пр. сторона)', $place); $seatsStr[$id] = str_replace(array('места', 'Места'), 'место', $place); $dataInit = json_decode($el->getAttribute('data-init')); $seatsStr[$id] .= $dataInit->seat; } } } } catch (\Exception $e) { die('Ошибка загрузки карты'); } } else { $innerMap = ''; $afisha = Arr::to_object(array()); } $map = View::tpl(array('map' => $innerMap), 'Map/Main'); $payer = null; if ($result->payer_id != 0) { $payer = DB::select()->from('users')->where('id', '=', $result->payer_id)->find(); } $this->_seo['h1'] = 'Заказ №' . Route::param('id'); $this->_seo['title'] = 'Заказ №' . Route::param('id'); $this->setBreadcrumbs('Заказ №' . Route::param('id'), 'backend/afisha_orders/edit/' . (int) Route::param('id')); $this->_content = View::tpl(array('obj' => $result, 'afisha' => $afisha, 'map' => $map, 'pay_statuses' => $this->pay_statuses, 'seat_statuses' => $this->seat_statuses, 'tpl_folder' => $this->tpl_folder, 'tablename' => $this->tablename, 'seatsStr' => $seatsStr, 'payer' => $payer), $this->tpl_folder . '/Inner'); }
public function before() { User::factory()->is_remember(); $this->config(); }
/** * @return bool */ static function caccess() { return User::factory()->_current_access; }
function addAction() { if ($_POST) { $post = $_POST['FORM']; $post['status'] = Arr::get($_POST, 'status', 0); $post['password'] = trim(Arr::get($_POST, 'password')); if (Model::valid($post)) { if ($post['password']) { $post['password'] = User::factory()->hash_password($post['password']); } $res = Model::insert(Model::$table, $post)->execute(); if ($res[1]) { Message::GetMessage(1, 'Вы успешно добавили данные!'); if (Arr::get($_POST, 'button', 'save') == 'save-close') { HTTP::redirect('backend/' . Route::controller() . '/index'); } else { if (Arr::get($_POST, 'button', 'save') == 'save-add') { HTTP::redirect('backend/' . Route::controller() . '/add'); } else { HTTP::redirect('backend/' . Route::controller() . '/edit/' . $res[0]); } } } else { Message::GetMessage(0, 'Не удалось добавить данные!'); } } unset($post['password']); $result = Arr::to_object($post); } else { $result = Model::getRow(Route::param('id')); } $this->_toolbar = Widgets::get('Toolbar/Edit'); $this->_seo['h1'] = 'Редактирование'; $this->_seo['title'] = 'Редактирование'; $this->setBreadcrumbs('Редактирование', 'backend/' . Route::controller() . '/edit/' . Route::param('id')); $this->_content = View::tpl(array('obj' => $result, 'tpl_folder' => $this->tpl_folder), $this->tpl_folder . '/Form'); }