/** * @Route("/") * * @return Response */ public function indexAction() { //$content = str_replace("\\n", "\\\\n", json_encode($this->service->getAllContent())); /*$content = json_encode([[ 'id' => '1', 'description' => '2', 'text' => '3' ]]);*/ // the URI being requested (e.g. /about) minus any query parameters $category = $this->category_service->getCategoryList(); $content = $this->content_service->getAllContent(0); $keyWords = $this->content_service->getTextById(IndexController::KEYWORDS_CONTENT_ID); $description = $this->content_service->getTextById(IndexController::DESCRIPTION_CONTENT_ID); $response = implode('', [$this->_initDocType(), $this->_initHead($keyWords, $description), $this->_initBody($category, $content)]); return new Response($response); }
/** * @param $email * @return array */ public function notify($email) { try { $author = $this->em->getRepository('Yasoon\\Site\\Entity\\AuthorEntity')->findOneByEmail($email); if (empty($author)) { return ['error' => true, 'errorType' => 'nouser']; } if ($author->getRole() == 4) { return ['error' => true, 'errorType' => 'admin']; } $newPass = ''; for ($i = 0; $i < 10; $i++) { $newPass .= mt_rand(0, mt_rand(5, 9)); } $author->setNewpass($newPass); $this->em->merge($author); $this->em->flush(); $name = $author->getName(); $protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://'; $link = $protocol . $_SERVER['HTTP_HOST'] . '/api/author/change_pass/' . $author->getEmail() . '/' . md5($newPass); $message = $this->contentService->getAllContent(0)[5]['text']; $message = str_replace(['%email%', '%newpass%', '%link%'], [$author->getEmail(), $newPass, $link], $message); $request = $this->mailer->send($author->getEmail(), 'Восстановление пароля Yasoon', $message); if ($request) { return ['error' => true, 'errorType' => 'alliswell']; } return ['error' => true, 'errorType' => 'notSent ']; } catch (\Exception $e) { return ['error' => true, 'errorType' => 'empty']; } }