public function index() { if ($this->method == 'POST' && isset($this->postData['username']) && isset($this->postData['password'])) { if (\Admin::checkAuthorization($this->postData['username'], $this->postData['password'])) { return $this->app->redirect($this->workURL); } } $error = array('user_undefined' => 'Пользователь неопределён'); $this->app['error_local'] = $error; return $this->app['twig']->render($this->getTemplateName(__METHOD__)); }
public function __construct(Application $app, $modelName = '') { $this->app = $app; $this->request = $app['request']; if (session_id()) { session_write_close(); $this->app['request']->getSession()->save(); } $this->app['request']->getSession()->start(); $this->admin = \Admin::getInstance(); $this->app['userlogin'] = $this->admin->getLogin(); $this->baseDir = rtrim(str_replace(array("src", "Controller"), '', __DIR__), '//'); $this->getPathInfo(); $this->setRequestMethod(); $this->setAjaxFlag(); $this->getData(); $this->setDataTablePluginSettings(); $modelName = "Model\\" . (empty($modelName) ? 'BaseStalker' : str_replace(array("\\", "Controller"), '', $modelName)) . 'Model'; $this->db = FALSE; $modelName = class_exists($modelName) ? $modelName : 'Model\\BaseStalkerModel'; if (class_exists($modelName)) { $this->db = new $modelName(); if (!$this->db instanceof $modelName) { $this->db = FALSE; } } $uid = $this->admin->getId(); if ($this->db !== FALSE && !empty($uid)) { $this->app['userTaskMsgs'] = $this->db->getCountUnreadedMsgsByUid($uid); } $this->app['user_id'] = $uid; $this->app['reseller'] = $this->admin->getResellerID(); $this->db->setReseller($this->app['reseller']); $this->db->setAdmin($this->app['user_id'], $this->app['userlogin']); $this->saveFiles = $app['saveFiles']; $this->setSideBarMenu(); $this->setTopBarMenu(); if ($this->app['userlogin'] == 'admin') { $this->access_level = 8; } else { $this->setAccessLevel(); } if (isset($this->data['set-dropdown-attribute'])) { $this->set_dropdown_attribute(); exit; } }
public function video_logs_json($param = array()) { $response = array(); $fields = array('id' => '`video_log`.`id` as `id`', 'video_id' => '`video_log`.`video_id` as `video_id`', 'login' => '`administrators`.`login` as `login`', 'actiontime' => '`actiontime`', '`video`.`name`' => 'IF(ISNULL(`video`.`name`), `video_log`.`video_name`, `video`.`name`) as `video_name`', 'action' => '`action`'); if ($this->isAjax) { if ($no_auth = $this->checkAuth()) { return $no_auth; } } $param = !empty($this->data) ? $this->data : array(); $query_param = $this->prepareDataTableParams($param); if (!\Admin::isPageActionAllowed('myvideolog')) { $query_param['where']["moderator_id"] = $_SESSION['uid']; } if (!empty($this->data['video_id'])) { $query_param['where']['video_id'] = $this->data['video_id']; } $query_param['select'] = array_merge($query_param['select'], array_diff($fields, $query_param['select'])); if (empty($query_param['order'])) { $query_param['order']['actiontime'] = 'desc'; } $this->cleanQueryParams($query_param, array_keys($fields), $fields); $response['recordsTotal'] = $this->db->getTotalRowsVideoLog($query_param['where']); $response["recordsFiltered"] = $this->db->getTotalRowsVideoLog($query_param['where'], $query_param['like']); if (empty($query_param['limit']['limit'])) { $query_param['limit']['limit'] = 50; } $response['data'] = $this->db->getVideoLog($query_param); $response['data'] = array_map(function ($row) { $row['actiontime'] = (int) strtotime($row['actiontime']); return $row; }, $response['data']); $response['data'] = $this->setLocalization($response['data'], 'action'); $this->setLinksForVideoLog($response['data']); $response["draw"] = !empty($this->data['draw']) ? $this->data['draw'] : 1; if ($this->isAjax) { $response = $this->generateAjaxResponse($response); return new Response(json_encode($response), empty($error) ? 200 : 500); } else { return $response; } }