Beispiel #1
0
 public function run()
 {
     if ($this->registry->get('user')->isUserLoggedIn()) {
         RegistryFactory::start('cookie')->remove('userSession');
         RegistryFactory::start('session')->remove('userSession');
     }
     Server::setReferData(['search' => Server::getReferData()['search']]);
     Server::headerLocationReferer();
 }
 public function run()
 {
     $this->request = $this->http->request->all();
     $this->query->setQuery('options');
     $option = $this->query->getQuery()[0];
     $controller = new ConfDecorator(new Options());
     $controller->find(1)->setSiteTitle($this->request['title'] ?? $option->getSiteTitle())->setSiteDescription($this->request['description'] ?? $option->getSiteDescription())->setAdminEmail($this->request['email'] ?? $option->getAdminEmail())->setViewLimit($this->request['viewLimit'] ?? $option->getViewLimit())->setDateFormat($this->request['dateFormat'] ?? $option->getDateFormat())->setBaseUrl($this->getBaseUrl() ?? $option->getBaseUrl())->setRequestUri($this->request['requestURI'] ?? $option->getRequestUri())->setTheme($this->request['theme'] ?? $option->getTheme())->insert();
     Server::headerLocationReferer();
 }
Beispiel #3
0
 /**
  *
  * @param string $key
  * @return (array|integer)
  */
 public function getFormResponseData(string $key = "")
 {
     $responseArray = Server::getReferData();
     if ($key != "") {
         return @$responseArray[$key] ?? null;
     } else {
         return $responseArray;
     }
 }
Beispiel #4
0
 public function run()
 {
     $adminMail = RegistryFactory::start('file')->register('Conf\\Conf')->getAdminEmail();
     $transport = \Swift_MailTransport::newInstance();
     $message = \Swift_Message::newInstance()->setSubject('Message from CMS')->setFrom($this->http->request->get('from'))->setTo($adminMail)->setBody($this->http->request->get('body'));
     $mailer = \Swift_Mailer::newInstance($transport);
     $mailer->send($message);
     Server::setReferData(['send' => 1]);
     Server::headerLocationReferer();
 }
Beispiel #5
0
 /**
  *
  * @param Command $command
  */
 private function savePassword(Command $command)
 {
     $hash = $command->entity()->getPassword();
     if (!HashPass::verifyPassword($this->http->request->get('userPassword'), $hash)) {
         Server::setReferData(['error' => ['validPassword' => 1]]);
         Server::headerLocationReferer();
     } else {
         $command->setPassword($this->http->request->get('userNewPassword'))->update(['password' => []]);
     }
 }
Beispiel #6
0
 public function run()
 {
     $this->action = $this->http->router->get('action');
     $this->alias = $this->http->router->get('alias');
     $this->view->addView('theme/post-edit.html');
     if ($this->action === 'delete' && $this->alias) {
         $controller = new Command(new Posts());
         $controller->findOneBy(['alias' => $this->alias])->remove();
         Server::headerLocation($this->url('admin-post-list', ['action' => 'view']));
     }
 }
Beispiel #7
0
 public function run()
 {
     $this->action = $this->http->router->get('action');
     $this->id = $this->http->router->get('id');
     $this->request = $this->http->request->all();
     if ($this->action === 'save') {
         $this->saveMenuEntityAndSetLastAddedId();
         $this->saveMenuItemsEntity();
         $this->removeMenuItemsEntity();
         Server::headerLocation($this->url('admin-menu-edit', ['action' => 'edit', 'id' => $this->lastId]));
     } elseif ($this->action === 'delete' && $this->id) {
         $this->removeMenuWithMenuItems();
     }
     Server::headerLocation($this->url('admin-menu-list', ['action' => 'view']));
 }
 public function run()
 {
     Server::setReferData(['form' => 'registration']);
     if ($this->registry->get('user')->isUserLoggedIn()) {
         Server::setReferData(['error' => ['userMustBeLogout' => 1]]);
         Server::headerLocationReferer();
     }
     $this->login = $this->http->request->get('userLogin');
     $this->email = $this->http->request->get('userEmail');
     $this->password = $this->http->request->get('userPassword');
     $controller = new Command(new Users());
     $controller->setLogin($this->login)->setEmail($this->email)->setPassword($this->password)->setRegDate(new \DateTime('now'))->setLogDate(new \DateTime('now'))->setRole('user')->insert(['login' => ['unique'], 'email' => ['unique'], 'password' => []]);
     $this->sendMail();
     Server::setReferData(['registrationSuccess' => 1]);
     Server::headerLocationReferer();
 }
Beispiel #9
0
 public function run()
 {
     $this->request = $this->http->request->all();
     // Initialize
     $controller = new Command(new Posts());
     $date = new \DateTime();
     // Find entity by id to update
     if ($this->request['id']) {
         $controller->find($this->request['id']);
         $date = $controller->entity()->getDate('DateTime');
     }
     $alias = $controller->getAlias($this->request['title']);
     $public = (int) $this->request['public'] ?? 0;
     $controller->setReference('category', $this->getCategoryId())->setReference('author', $this->view->getUserId())->setDate($date)->setTitle($this->request['title'])->setAlias($alias)->setContent($this->request['content'])->setPublic($public)->insert(['date' => [], 'title' => [], 'alias' => [], 'content' => []]);
     Server::headerLocation($this->url('admin-post-edit', ['action' => 'edit', 'alias' => $alias]));
 }
Beispiel #10
0
 public function run()
 {
     if ($this->registry->get('user')->isUserLoggedIn()) {
         Server::headerLocationReferer();
     }
     $this->login = $this->http->request->get('userLogin');
     $this->column = $this->isEmail($this->login) ? 'email' : 'login';
     $this->password = $this->http->request->get('userPassword');
     $this->remember = $this->http->request->get('userRemember', null);
     $userId = $this->getUserId();
     if ($userId === 0) {
         Server::setReferData(['form' => 'login', 'error' => ['valid' . ucfirst($this->column) . '_or_password' => 1]]);
         Server::headerLocationReferer();
     } else {
         $controller = new Command(new Users());
         $controller->find($userId)->setLogDate(new \DateTime('now'))->update();
         $this->setSession();
         Server::headerLocationReferer();
     }
 }
Beispiel #11
0
 public function run()
 {
     Server::setReferData(['form' => 'remind']);
     if ($this->registry->get('user')->isUserLoggedIn()) {
         Server::headerLocationReferer();
     }
     $controller = new Command(new Users());
     $controller->findOneBy(['email' => $this->http->request->get('userEmail')]);
     if ($controller->entity() === null) {
         // If email not exists
         Server::setReferData(['error' => ['findEmail' => 1]]);
         Server::headerLocationReferer();
     } else {
         $this->setRandomPasword();
         $this->updatePassword($controller);
         $this->sendMail($controller);
         Server::setReferData(['remindSuccess' => 1]);
         Server::headerLocationReferer();
     }
 }
Beispiel #12
0
 private function sendErrorsIfExists()
 {
     if (count($this->errorArray)) {
         foreach ($this->command->entitySettersArray as $key => $data) {
             // Repleca reference entities instances to its referenced id
             if (is_object($data)) {
                 if (method_exists($data, 'getId')) {
                     $this->command->entitySettersArray[$key] = $data->getId();
                 } else {
                     unset($this->command->entitySettersArray[$key]);
                 }
             }
         }
         Server::setReferData(array('data' => $this->command->entitySettersArray, 'error' => $this->errorArray));
         Server::headerLocationReferer();
     }
 }
Beispiel #13
0
 private function setSearchToReferData()
 {
     Server::setReferData(['search' => $this->search]);
     Server::setRefererSession();
 }
Beispiel #14
0
 /**
  * Method checks if admin panel route is open and then valid permission to
  * stay there. If user is admin (or moderator) method loads necessary extensions
  */
 public function loadAdmin()
 {
     if ($this->http->isAdmin()) {
         // If not logged open login panel
         if (!$this->user->isUserLoggedIn()) {
             $this->view->loadFile('../../admin/extensions/Index/login.html');
             exit;
         }
         // Check permissions
         if ($this->user->getUserSession()->getRole() != 'admin') {
             Server::headerLocation();
             // Go to main page
         }
         // Admin view helper classes
         $this->viewHelper->add($this->conf['adminViewHelper'] ?? []);
         $this->registry->set('App\\Admin\\Admin', new Admin($this->adminExtension, $this->yaml));
     }
 }
Beispiel #15
0
 /**
  *
  * @param string $name
  */
 private function addResponseInputValue(string $name)
 {
     if ($this->formAction === 'registration') {
         $response = Server::getReferData();
         $field = str_replace('user', '', $name);
         if (!@$response['error']['valid' . $field] && !@$response['error']['unique' . $field]) {
             FormGenerator::addItem(['value' => @$response['data']['set' . $field]]);
         }
     }
 }