Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Wallabag\Controller\Api; use Hateoas\Configuration\Route as HateoasRoute;..

Decoded Output download

<?php
 namespace Wallabag\Controller\Api; use Hateoas\Configuration\Route as HateoasRoute; use Hateoas\Representation\Factory\PagerfantaFactory; use Nelmio\ApiDocBundle\Annotation\Operation; use OpenApi\Annotations as OA; use Pagerfanta\Pagerfanta; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Routing\Annotation\Route; use Wallabag\Entity\Entry; use Wallabag\Entity\Tag; use Wallabag\Event\EntryDeletedEvent; use Wallabag\Event\EntrySavedEvent; use Wallabag\Helper\ContentProxy; use Wallabag\Helper\EntriesExport; use Wallabag\Helper\TagsAssigner; use Wallabag\Helper\UrlHasher; use Wallabag\Repository\EntryRepository; use Wallabag\Repository\TagRepository; class EntryRestController extends WallabagRestController { public function getEntriesExistsAction(Request $request, EntryRepository $entryRepository) { $this->validateAuthentication(); $returnId = null === $request->query->get("return_id") ? false : (bool) $request->query->get("return_id"); $hashedUrls = $request->query->all("hashed_urls"); $hashedUrl = $request->query->get("hashed_url", ''); if (!empty($hashedUrl)) { $hashedUrls[] = $hashedUrl; } $urls = $request->query->all("urls"); $url = $request->query->get("url", ''); if (!empty($url)) { $urls[] = $url; } $urlHashMap = array(); foreach ($urls as $urlToHash) { $urlHash = UrlHasher::hashUrl($urlToHash); $hashedUrls[] = $urlHash; $urlHashMap[$urlHash] = $urlToHash; } if (empty($hashedUrls)) { throw $this->createAccessDeniedException("URL is empty?, logged user id: " . $this->getUser()->getId()); } $results = array_fill_keys($hashedUrls, null); $res = $entryRepository->findByUserIdAndBatchHashedUrls($this->getUser()->getId(), $hashedUrls); foreach ($res as $e) { $_hashedUrl = array_keys($hashedUrls, "blah", true); if (array() !== array_keys($hashedUrls, $e["hashedUrl"], true)) { $_hashedUrl = $e["hashedUrl"]; } elseif (array() !== array_keys($hashedUrls, $e["hashedGivenUrl"], true)) { $_hashedUrl = $e["hashedGivenUrl"]; } else { continue; } $results[$_hashedUrl] = $e["id"]; } if (false === $returnId) { $results = array_map(function ($v) { return null !== $v; }, $results); } $results = $this->replaceUrlHashes($results, $urlHashMap); if (!empty($url) || !empty($hashedUrl)) { $hu = array_keys($results)[0]; return $this->sendResponse(array("exists" => $results[$hu])); } return $this->sendResponse($results); } public function getEntriesAction(Request $request, EntryRepository $entryRepository) { $this->validateAuthentication(); $isArchived = null === $request->query->get("archive") ? null : (bool) $request->query->get("archive"); $isStarred = null === $request->query->get("starred") ? null : (bool) $request->query->get("starred"); $isPublic = null === $request->query->get("public") ? null : (bool) $request->query->get("public"); $isNotParsed = null === $request->query->get("notParsed") ? null : (bool) $request->query->get("notParsed"); $sort = strtolower($request->query->get("sort", "created")); $order = strtolower($request->query->get("order", "desc")); $page = (int) $request->query->get("page", 1); $perPage = (int) $request->query->get("perPage", 30); $tags = \is_array($request->query->get("tags")) ? '' : (string) $request->query->get("tags", ''); $since = $request->query->get("since", 0); $detail = strtolower($request->query->get("detail", "full")); $domainName = null === $request->query->get("domain_name") ? '' : (string) $request->query->get("domain_name"); try { $pager = $entryRepository->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isPublic, $sort, $order, $since, $tags, $detail, $domainName, $isNotParsed); } catch (\Exception $e) { throw new BadRequestHttpException($e->getMessage()); } $pager->setMaxPerPage($perPage); $pager->setCurrentPage($page); $pagerfantaFactory = new PagerfantaFactory("page", "perPage"); $paginatedCollection = $pagerfantaFactory->createRepresentation($pager, new HateoasRoute("api_get_entries", array("archive" => $isArchived, "starred" => $isStarred, "public" => $isPublic, "notParsed" => $isNotParsed, "sort" => $sort, "order" => $order, "page" => $page, "perPage" => $perPage, "tags" => $tags, "since" => $since, "detail" => $detail), true)); return $this->sendResponse($paginatedCollection); } public function getEntryAction(Entry $entry) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); return $this->sendResponse($entry); } public function getEntryExportAction(Entry $entry, Request $request, EntriesExport $entriesExport) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); return $entriesExport->setEntries($entry)->updateTitle("entry")->updateAuthor("entry")->exportAs($request->attributes->get("_format")); } public function deleteEntriesListAction(Request $request, EntryRepository $entryRepository, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $urls = json_decode($request->query->get("urls", array())); if (empty($urls)) { return $this->sendResponse(array()); } $results = array(); foreach ($urls as $key => $url) { $entry = $entryRepository->findByUrlAndUserId($url, $this->getUser()->getId()); $results[$key]["url"] = $url; if (false !== $entry) { $eventDispatcher->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME); $this->entityManager->remove($entry); $this->entityManager->flush(); } $results[$key]["entry"] = $entry instanceof Entry ? true : false; } return $this->sendResponse($results); } public function postEntriesListAction(Request $request, EntryRepository $entryRepository, EventDispatcherInterface $eventDispatcher, ContentProxy $contentProxy) { $this->validateAuthentication(); $urls = json_decode($request->query->get("urls", array())); $limit = $this->getParameter("wallabag.api_limit_mass_actions"); if (\count($urls) > $limit) { throw new BadRequestHttpException("API limit reached"); } $results = array(); if (empty($urls)) { return $this->sendResponse($results); } foreach ($urls as $key => $url) { $entry = $entryRepository->findByUrlAndUserId($url, $this->getUser()->getId()); $results[$key]["url"] = $url; if (false === $entry) { $entry = new Entry($this->getUser()); $contentProxy->updateEntry($entry, $url); } $this->entityManager->persist($entry); $this->entityManager->flush(); $results[$key]["entry"] = $entry instanceof Entry ? $entry->getId() : false; $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); } return $this->sendResponse($results); } public function postEntriesAction(Request $request, EntryRepository $entryRepository, ContentProxy $contentProxy, LoggerInterface $logger, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $url = $request->request->get("url"); $entry = $entryRepository->findByUrlAndUserId($url, $this->getUser()->getId()); if (false === $entry) { $entry = new Entry($this->getUser()); $entry->setUrl($url); } $data = $this->retrieveValueFromRequest($request); try { $contentProxy->updateEntry($entry, $entry->getUrl(), array("title" => !empty($data["title"]) ? $data["title"] : $entry->getTitle(), "html" => !empty($data["content"]) ? $data["content"] : $entry->getContent(), "url" => $entry->getUrl(), "language" => !empty($data["language"]) ? $data["language"] : $entry->getLanguage(), "date" => !empty($data["publishedAt"]) ? $data["publishedAt"] : $entry->getPublishedAt(), "image" => !empty($data["picture"]) ? $data["picture"] : $entry->getPreviewPicture(), "authors" => \is_string($data["authors"]) ? explode(",", $data["authors"]) : $entry->getPublishedBy())); } catch (\Exception $e) { $logger->error("Error while saving an entry", array("exception" => $e, "entry" => $entry)); } if (null !== $data["isArchived"]) { $entry->updateArchived((bool) $data["isArchived"]); } if (null !== $data["isStarred"]) { $entry->updateStar((bool) $data["isStarred"]); } if (!empty($data["tags"])) { $tagsAssigner->assignTagsToEntry($entry, $data["tags"]); } if (!empty($data["origin_url"])) { $entry->setOriginUrl($data["origin_url"]); } if (null !== $data["isPublic"]) { if (true === (bool) $data["isPublic"] && null === $entry->getUid()) { $entry->generateUid(); } elseif (false === (bool) $data["isPublic"]) { $entry->cleanUid(); } } if (empty($entry->getDomainName())) { $contentProxy->setEntryDomainName($entry); } if (empty($entry->getTitle())) { $contentProxy->setDefaultEntryTitle($entry); } $this->entityManager->persist($entry); $this->entityManager->flush(); $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); return $this->sendResponse($entry); } public function patchEntriesAction(Entry $entry, Request $request, ContentProxy $contentProxy, LoggerInterface $logger, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $data = $this->retrieveValueFromRequest($request); if (!empty($data["content"])) { try { $contentProxy->updateEntry($entry, $entry->getUrl(), array("html" => $data["content"]), true); } catch (\Exception $e) { $logger->error("Error while saving an entry", array("exception" => $e, "entry" => $entry)); } } if (!empty($data["title"])) { $entry->setTitle($data["title"]); } if (!empty($data["language"])) { $contentProxy->updateLanguage($entry, $data["language"]); } if (!empty($data["authors"]) && \is_string($data["authors"])) { $entry->setPublishedBy(explode(",", $data["authors"])); } if (!empty($data["picture"])) { $contentProxy->updatePreviewPicture($entry, $data["picture"]); } if (!empty($data["publishedAt"])) { $contentProxy->updatePublishedAt($entry, $data["publishedAt"]); } if (null !== $data["isArchived"]) { $entry->updateArchived((bool) $data["isArchived"]); } if (null !== $data["isStarred"]) { $entry->updateStar((bool) $data["isStarred"]); } if (!empty($data["tags"])) { $entry->removeAllTags(); $tagsAssigner->assignTagsToEntry($entry, $data["tags"]); } if (null !== $data["isPublic"]) { if (true === (bool) $data["isPublic"] && null === $entry->getUid()) { $entry->generateUid(); } elseif (false === (bool) $data["isPublic"]) { $entry->cleanUid(); } } if (!empty($data["origin_url"])) { $entry->setOriginUrl($data["origin_url"]); } if (empty($entry->getDomainName())) { $contentProxy->setEntryDomainName($entry); } if (empty($entry->getTitle())) { $contentProxy->setDefaultEntryTitle($entry); } $this->entityManager->persist($entry); $this->entityManager->flush(); $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); return $this->sendResponse($entry); } public function patchEntriesReloadAction(Entry $entry, ContentProxy $contentProxy, LoggerInterface $logger, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); try { $contentProxy->updateEntry($entry, $entry->getUrl()); } catch (\Exception $e) { $logger->error("Error while saving an entry", array("exception" => $e, "entry" => $entry)); return new JsonResponse(array(), 304); } if ($this->getParameter("wallabag.fetching_error_message") === $entry->getContent()) { return new JsonResponse(array(), 304); } $this->entityManager->persist($entry); $this->entityManager->flush(); $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); return $this->sendResponse($entry); } public function deleteEntriesAction(Entry $entry, Request $request, EventDispatcherInterface $eventDispatcher) { $expect = $request->query->get("expect", "entry"); if (!\in_array($expect, array("id", "entry"), true)) { throw new BadRequestHttpException(sprintf("expect: 'id' or 'entry' expected, %s given", $expect)); } $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $response = $this->sendResponse(array("id" => $entry->getId())); if ("entry" === $expect) { $e = clone $entry; $response = $this->sendResponse($e); } $eventDispatcher->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME); $this->entityManager->remove($entry); $this->entityManager->flush(); return $response; } public function getEntriesTagsAction(Entry $entry) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); return $this->sendResponse($entry->getTags()); } public function postEntriesTagsAction(Request $request, Entry $entry, TagsAssigner $tagsAssigner) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $tags = $request->request->get("tags", ''); if (!empty($tags)) { $tagsAssigner->assignTagsToEntry($entry, $tags); } $this->entityManager->persist($entry); $this->entityManager->flush(); return $this->sendResponse($entry); } public function deleteEntriesTagsAction(Entry $entry, Tag $tag) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $entry->removeTag($tag); $this->entityManager->persist($entry); $this->entityManager->flush(); return $this->sendResponse($entry); } public function deleteEntriesTagsListAction(Request $request, TagRepository $tagRepository, EntryRepository $entryRepository) { $this->validateAuthentication(); $list = json_decode($request->query->get("list", array())); if (empty($list)) { return $this->sendResponse(array()); } $results = array(); foreach ($list as $key => $element) { $entry = $entryRepository->findByUrlAndUserId($element->url, $this->getUser()->getId()); $results[$key]["url"] = $element->url; $results[$key]["entry"] = $entry instanceof Entry ? $entry->getId() : false; $tags = $element->tags; if (false !== $entry && !empty($tags)) { $tags = explode(",", $tags); foreach ($tags as $label) { $label = trim($label); $tag = $tagRepository->findOneByLabel($label); if (false !== $tag) { $entry->removeTag($tag); } } $this->entityManager->persist($entry); $this->entityManager->flush(); } } return $this->sendResponse($results); } public function postEntriesTagsListAction(Request $request, EntryRepository $entryRepository, TagsAssigner $tagsAssigner) { $this->validateAuthentication(); $list = json_decode($request->query->get("list", array())); if (empty($list)) { return $this->sendResponse(array()); } $results = array(); foreach ($list as $key => $element) { $entry = $entryRepository->findByUrlAndUserId($element->url, $this->getUser()->getId()); $results[$key]["url"] = $element->url; $results[$key]["entry"] = $entry instanceof Entry ? $entry->getId() : false; $tags = $element->tags; if (false !== $entry && !empty($tags)) { $tagsAssigner->assignTagsToEntry($entry, $tags); $this->entityManager->persist($entry); $this->entityManager->flush(); } } return $this->sendResponse($results); } private function replaceUrlHashes(array $results, array $urlHashMap) { $newResults = array(); foreach ($results as $hash => $res) { if (isset($urlHashMap[$hash])) { $newResults[$urlHashMap[$hash]] = $res; } else { $newResults[$hash] = $res; } } return $newResults; } private function retrieveValueFromRequest(Request $request) { return array("title" => $request->request->get("title"), "tags" => $request->request->get("tags", array()), "isArchived" => $request->request->get("archive"), "isStarred" => $request->request->get("starred"), "isPublic" => $request->request->get("public"), "content" => $request->request->get("content"), "language" => $request->request->get("language"), "picture" => $request->request->get("preview_picture"), "publishedAt" => $request->request->get("published_at"), "authors" => $request->request->get("authors", ''), "origin_url" => $request->request->get("origin_url", '')); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Wallabag\Controller\Api; use Hateoas\Configuration\Route as HateoasRoute; use Hateoas\Representation\Factory\PagerfantaFactory; use Nelmio\ApiDocBundle\Annotation\Operation; use OpenApi\Annotations as OA; use Pagerfanta\Pagerfanta; use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\Routing\Annotation\Route; use Wallabag\Entity\Entry; use Wallabag\Entity\Tag; use Wallabag\Event\EntryDeletedEvent; use Wallabag\Event\EntrySavedEvent; use Wallabag\Helper\ContentProxy; use Wallabag\Helper\EntriesExport; use Wallabag\Helper\TagsAssigner; use Wallabag\Helper\UrlHasher; use Wallabag\Repository\EntryRepository; use Wallabag\Repository\TagRepository; class EntryRestController extends WallabagRestController { public function getEntriesExistsAction(Request $request, EntryRepository $entryRepository) { $this->validateAuthentication(); $returnId = null === $request->query->get("\x72\145\164\x75\162\x6e\x5f\x69\144") ? false : (bool) $request->query->get("\x72\x65\164\x75\x72\x6e\137\151\144"); $hashedUrls = $request->query->all("\150\x61\163\150\x65\x64\x5f\165\162\154\x73"); $hashedUrl = $request->query->get("\x68\141\x73\x68\145\144\137\x75\162\x6c", ''); if (!empty($hashedUrl)) { $hashedUrls[] = $hashedUrl; } $urls = $request->query->all("\165\x72\x6c\163"); $url = $request->query->get("\x75\162\x6c", ''); if (!empty($url)) { $urls[] = $url; } $urlHashMap = array(); foreach ($urls as $urlToHash) { $urlHash = UrlHasher::hashUrl($urlToHash); $hashedUrls[] = $urlHash; $urlHashMap[$urlHash] = $urlToHash; } if (empty($hashedUrls)) { throw $this->createAccessDeniedException("\x55\x52\x4c\40\x69\163\x20\x65\155\x70\x74\x79\77\x2c\x20\x6c\x6f\147\147\x65\144\40\165\163\145\162\40\151\x64\72\x20" . $this->getUser()->getId()); } $results = array_fill_keys($hashedUrls, null); $res = $entryRepository->findByUserIdAndBatchHashedUrls($this->getUser()->getId(), $hashedUrls); foreach ($res as $e) { $_hashedUrl = array_keys($hashedUrls, "\x62\x6c\x61\x68", true); if (array() !== array_keys($hashedUrls, $e["\x68\x61\163\x68\145\144\125\162\x6c"], true)) { $_hashedUrl = $e["\150\141\x73\150\x65\144\x55\162\154"]; } elseif (array() !== array_keys($hashedUrls, $e["\x68\x61\x73\150\x65\144\107\151\x76\145\156\125\162\154"], true)) { $_hashedUrl = $e["\150\141\163\x68\x65\x64\107\x69\166\145\156\x55\162\154"]; } else { continue; } $results[$_hashedUrl] = $e["\x69\x64"]; } if (false === $returnId) { $results = array_map(function ($v) { return null !== $v; }, $results); } $results = $this->replaceUrlHashes($results, $urlHashMap); if (!empty($url) || !empty($hashedUrl)) { $hu = array_keys($results)[0]; return $this->sendResponse(array("\x65\x78\x69\163\x74\x73" => $results[$hu])); } return $this->sendResponse($results); } public function getEntriesAction(Request $request, EntryRepository $entryRepository) { $this->validateAuthentication(); $isArchived = null === $request->query->get("\x61\x72\143\x68\x69\x76\145") ? null : (bool) $request->query->get("\141\x72\143\x68\151\166\x65"); $isStarred = null === $request->query->get("\163\x74\141\162\162\145\x64") ? null : (bool) $request->query->get("\x73\x74\x61\x72\x72\145\x64"); $isPublic = null === $request->query->get("\160\165\142\x6c\151\x63") ? null : (bool) $request->query->get("\x70\165\x62\x6c\151\x63"); $isNotParsed = null === $request->query->get("\x6e\x6f\x74\x50\141\162\163\145\144") ? null : (bool) $request->query->get("\x6e\x6f\x74\x50\x61\162\x73\145\x64"); $sort = strtolower($request->query->get("\x73\157\x72\164", "\x63\162\x65\x61\x74\145\144")); $order = strtolower($request->query->get("\157\x72\x64\x65\x72", "\144\x65\x73\x63")); $page = (int) $request->query->get("\160\x61\147\x65", 1); $perPage = (int) $request->query->get("\x70\145\162\x50\141\147\145", 30); $tags = \is_array($request->query->get("\164\x61\147\x73")) ? '' : (string) $request->query->get("\x74\141\x67\x73", ''); $since = $request->query->get("\163\x69\156\x63\145", 0); $detail = strtolower($request->query->get("\x64\145\164\141\151\154", "\146\x75\x6c\x6c")); $domainName = null === $request->query->get("\x64\157\155\x61\151\x6e\x5f\x6e\x61\x6d\x65") ? '' : (string) $request->query->get("\x64\157\155\x61\x69\156\137\156\141\x6d\145"); try { $pager = $entryRepository->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $isPublic, $sort, $order, $since, $tags, $detail, $domainName, $isNotParsed); } catch (\Exception $e) { throw new BadRequestHttpException($e->getMessage()); } $pager->setMaxPerPage($perPage); $pager->setCurrentPage($page); $pagerfantaFactory = new PagerfantaFactory("\160\141\147\145", "\160\145\x72\x50\x61\147\x65"); $paginatedCollection = $pagerfantaFactory->createRepresentation($pager, new HateoasRoute("\141\x70\151\x5f\147\x65\x74\x5f\145\156\x74\162\x69\x65\163", array("\x61\162\x63\150\x69\166\x65" => $isArchived, "\163\164\141\x72\162\145\x64" => $isStarred, "\x70\x75\x62\154\x69\143" => $isPublic, "\156\157\x74\120\x61\162\x73\x65\144" => $isNotParsed, "\163\x6f\162\x74" => $sort, "\x6f\x72\x64\145\162" => $order, "\160\141\147\x65" => $page, "\x70\145\162\x50\x61\x67\x65" => $perPage, "\164\141\147\x73" => $tags, "\163\x69\x6e\143\145" => $since, "\x64\145\164\141\151\154" => $detail), true)); return $this->sendResponse($paginatedCollection); } public function getEntryAction(Entry $entry) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); return $this->sendResponse($entry); } public function getEntryExportAction(Entry $entry, Request $request, EntriesExport $entriesExport) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); return $entriesExport->setEntries($entry)->updateTitle("\x65\x6e\x74\x72\171")->updateAuthor("\145\x6e\x74\x72\171")->exportAs($request->attributes->get("\137\146\x6f\162\x6d\141\x74")); } public function deleteEntriesListAction(Request $request, EntryRepository $entryRepository, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $urls = json_decode($request->query->get("\165\162\154\163", array())); if (empty($urls)) { return $this->sendResponse(array()); } $results = array(); foreach ($urls as $key => $url) { $entry = $entryRepository->findByUrlAndUserId($url, $this->getUser()->getId()); $results[$key]["\x75\162\x6c"] = $url; if (false !== $entry) { $eventDispatcher->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME); $this->entityManager->remove($entry); $this->entityManager->flush(); } $results[$key]["\145\x6e\164\x72\x79"] = $entry instanceof Entry ? true : false; } return $this->sendResponse($results); } public function postEntriesListAction(Request $request, EntryRepository $entryRepository, EventDispatcherInterface $eventDispatcher, ContentProxy $contentProxy) { $this->validateAuthentication(); $urls = json_decode($request->query->get("\165\x72\154\163", array())); $limit = $this->getParameter("\167\141\154\154\141\142\141\x67\x2e\x61\x70\x69\137\x6c\x69\x6d\151\x74\137\155\141\163\x73\x5f\x61\143\x74\x69\157\x6e\163"); if (\count($urls) > $limit) { throw new BadRequestHttpException("\101\120\x49\40\x6c\x69\x6d\151\164\40\x72\x65\x61\x63\x68\x65\x64"); } $results = array(); if (empty($urls)) { return $this->sendResponse($results); } foreach ($urls as $key => $url) { $entry = $entryRepository->findByUrlAndUserId($url, $this->getUser()->getId()); $results[$key]["\165\162\x6c"] = $url; if (false === $entry) { $entry = new Entry($this->getUser()); $contentProxy->updateEntry($entry, $url); } $this->entityManager->persist($entry); $this->entityManager->flush(); $results[$key]["\145\x6e\x74\162\171"] = $entry instanceof Entry ? $entry->getId() : false; $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); } return $this->sendResponse($results); } public function postEntriesAction(Request $request, EntryRepository $entryRepository, ContentProxy $contentProxy, LoggerInterface $logger, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $url = $request->request->get("\165\x72\x6c"); $entry = $entryRepository->findByUrlAndUserId($url, $this->getUser()->getId()); if (false === $entry) { $entry = new Entry($this->getUser()); $entry->setUrl($url); } $data = $this->retrieveValueFromRequest($request); try { $contentProxy->updateEntry($entry, $entry->getUrl(), array("\164\151\164\x6c\145" => !empty($data["\x74\151\164\x6c\x65"]) ? $data["\164\x69\x74\154\x65"] : $entry->getTitle(), "\x68\x74\x6d\x6c" => !empty($data["\143\157\x6e\x74\x65\x6e\164"]) ? $data["\143\x6f\x6e\x74\145\156\164"] : $entry->getContent(), "\x75\162\154" => $entry->getUrl(), "\x6c\141\x6e\147\x75\x61\147\145" => !empty($data["\154\x61\156\x67\165\141\x67\145"]) ? $data["\154\x61\x6e\x67\165\141\147\x65"] : $entry->getLanguage(), "\x64\141\x74\145" => !empty($data["\x70\x75\x62\154\151\163\x68\x65\x64\101\x74"]) ? $data["\160\165\142\154\x69\x73\150\145\x64\x41\164"] : $entry->getPublishedAt(), "\151\x6d\141\x67\145" => !empty($data["\160\151\x63\x74\165\162\145"]) ? $data["\160\151\x63\x74\165\162\145"] : $entry->getPreviewPicture(), "\141\x75\x74\x68\157\x72\x73" => \is_string($data["\x61\165\x74\150\x6f\x72\163"]) ? explode("\54", $data["\141\165\164\150\x6f\x72\x73"]) : $entry->getPublishedBy())); } catch (\Exception $e) { $logger->error("\105\x72\162\x6f\162\x20\167\x68\151\154\145\40\x73\141\x76\151\156\147\x20\x61\156\x20\x65\x6e\x74\x72\x79", array("\x65\x78\143\145\160\164\151\x6f\x6e" => $e, "\x65\x6e\x74\162\171" => $entry)); } if (null !== $data["\x69\x73\101\x72\143\150\151\x76\145\144"]) { $entry->updateArchived((bool) $data["\151\163\101\162\143\150\x69\166\145\144"]); } if (null !== $data["\151\x73\x53\164\141\162\x72\x65\x64"]) { $entry->updateStar((bool) $data["\151\x73\123\164\x61\162\x72\x65\144"]); } if (!empty($data["\x74\141\x67\x73"])) { $tagsAssigner->assignTagsToEntry($entry, $data["\164\141\x67\163"]); } if (!empty($data["\x6f\162\151\x67\151\x6e\137\165\x72\x6c"])) { $entry->setOriginUrl($data["\157\162\x69\x67\151\x6e\137\x75\162\x6c"]); } if (null !== $data["\x69\163\120\165\142\154\151\143"]) { if (true === (bool) $data["\x69\163\x50\x75\142\x6c\x69\143"] && null === $entry->getUid()) { $entry->generateUid(); } elseif (false === (bool) $data["\151\x73\120\x75\x62\x6c\x69\143"]) { $entry->cleanUid(); } } if (empty($entry->getDomainName())) { $contentProxy->setEntryDomainName($entry); } if (empty($entry->getTitle())) { $contentProxy->setDefaultEntryTitle($entry); } $this->entityManager->persist($entry); $this->entityManager->flush(); $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); return $this->sendResponse($entry); } public function patchEntriesAction(Entry $entry, Request $request, ContentProxy $contentProxy, LoggerInterface $logger, TagsAssigner $tagsAssigner, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $data = $this->retrieveValueFromRequest($request); if (!empty($data["\x63\157\156\164\145\x6e\164"])) { try { $contentProxy->updateEntry($entry, $entry->getUrl(), array("\150\164\x6d\154" => $data["\143\x6f\x6e\164\145\x6e\164"]), true); } catch (\Exception $e) { $logger->error("\105\162\x72\x6f\162\40\167\x68\x69\154\145\x20\x73\141\x76\151\x6e\147\40\141\156\x20\x65\x6e\x74\x72\x79", array("\x65\x78\x63\x65\x70\x74\151\157\156" => $e, "\145\x6e\x74\x72\x79" => $entry)); } } if (!empty($data["\164\x69\x74\x6c\145"])) { $entry->setTitle($data["\164\x69\164\x6c\x65"]); } if (!empty($data["\x6c\x61\x6e\147\x75\141\x67\x65"])) { $contentProxy->updateLanguage($entry, $data["\x6c\x61\x6e\x67\165\141\x67\145"]); } if (!empty($data["\141\165\x74\150\x6f\x72\163"]) && \is_string($data["\x61\x75\164\150\x6f\162\163"])) { $entry->setPublishedBy(explode("\x2c", $data["\x61\165\164\x68\157\162\x73"])); } if (!empty($data["\x70\151\x63\x74\x75\x72\145"])) { $contentProxy->updatePreviewPicture($entry, $data["\x70\x69\x63\164\x75\162\x65"]); } if (!empty($data["\x70\165\x62\154\x69\163\x68\145\x64\101\164"])) { $contentProxy->updatePublishedAt($entry, $data["\x70\x75\x62\x6c\151\x73\x68\145\x64\101\x74"]); } if (null !== $data["\151\163\101\x72\x63\150\151\x76\x65\144"]) { $entry->updateArchived((bool) $data["\151\x73\x41\162\x63\150\151\166\x65\144"]); } if (null !== $data["\151\163\123\x74\141\162\162\145\144"]) { $entry->updateStar((bool) $data["\151\163\123\164\x61\162\162\x65\144"]); } if (!empty($data["\164\141\147\x73"])) { $entry->removeAllTags(); $tagsAssigner->assignTagsToEntry($entry, $data["\164\x61\147\163"]); } if (null !== $data["\151\x73\x50\165\x62\x6c\151\x63"]) { if (true === (bool) $data["\x69\163\120\165\142\154\151\143"] && null === $entry->getUid()) { $entry->generateUid(); } elseif (false === (bool) $data["\151\x73\120\x75\142\154\x69\x63"]) { $entry->cleanUid(); } } if (!empty($data["\x6f\x72\151\x67\x69\156\137\x75\x72\154"])) { $entry->setOriginUrl($data["\x6f\162\x69\147\x69\x6e\137\x75\162\154"]); } if (empty($entry->getDomainName())) { $contentProxy->setEntryDomainName($entry); } if (empty($entry->getTitle())) { $contentProxy->setDefaultEntryTitle($entry); } $this->entityManager->persist($entry); $this->entityManager->flush(); $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); return $this->sendResponse($entry); } public function patchEntriesReloadAction(Entry $entry, ContentProxy $contentProxy, LoggerInterface $logger, EventDispatcherInterface $eventDispatcher) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); try { $contentProxy->updateEntry($entry, $entry->getUrl()); } catch (\Exception $e) { $logger->error("\105\162\162\x6f\162\x20\167\x68\x69\154\x65\x20\x73\x61\x76\151\x6e\147\x20\141\x6e\40\x65\156\x74\162\x79", array("\x65\170\x63\x65\x70\x74\151\157\156" => $e, "\145\x6e\164\x72\x79" => $entry)); return new JsonResponse(array(), 304); } if ($this->getParameter("\x77\x61\x6c\x6c\141\142\141\147\56\x66\x65\x74\143\150\x69\x6e\147\x5f\145\162\x72\157\x72\137\155\x65\x73\163\x61\147\145") === $entry->getContent()) { return new JsonResponse(array(), 304); } $this->entityManager->persist($entry); $this->entityManager->flush(); $eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME); return $this->sendResponse($entry); } public function deleteEntriesAction(Entry $entry, Request $request, EventDispatcherInterface $eventDispatcher) { $expect = $request->query->get("\x65\x78\160\x65\143\x74", "\145\x6e\x74\x72\171"); if (!\in_array($expect, array("\151\144", "\145\x6e\x74\x72\x79"), true)) { throw new BadRequestHttpException(sprintf("\145\170\160\x65\143\164\72\40\47\x69\144\x27\x20\x6f\x72\40\x27\x65\156\x74\x72\x79\x27\x20\x65\x78\x70\x65\x63\164\x65\x64\54\40\45\163\x20\147\151\166\x65\156", $expect)); } $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $response = $this->sendResponse(array("\x69\x64" => $entry->getId())); if ("\x65\156\x74\x72\171" === $expect) { $e = clone $entry; $response = $this->sendResponse($e); } $eventDispatcher->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME); $this->entityManager->remove($entry); $this->entityManager->flush(); return $response; } public function getEntriesTagsAction(Entry $entry) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); return $this->sendResponse($entry->getTags()); } public function postEntriesTagsAction(Request $request, Entry $entry, TagsAssigner $tagsAssigner) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $tags = $request->request->get("\x74\141\x67\x73", ''); if (!empty($tags)) { $tagsAssigner->assignTagsToEntry($entry, $tags); } $this->entityManager->persist($entry); $this->entityManager->flush(); return $this->sendResponse($entry); } public function deleteEntriesTagsAction(Entry $entry, Tag $tag) { $this->validateAuthentication(); $this->validateUserAccess($entry->getUser()->getId()); $entry->removeTag($tag); $this->entityManager->persist($entry); $this->entityManager->flush(); return $this->sendResponse($entry); } public function deleteEntriesTagsListAction(Request $request, TagRepository $tagRepository, EntryRepository $entryRepository) { $this->validateAuthentication(); $list = json_decode($request->query->get("\x6c\x69\x73\164", array())); if (empty($list)) { return $this->sendResponse(array()); } $results = array(); foreach ($list as $key => $element) { $entry = $entryRepository->findByUrlAndUserId($element->url, $this->getUser()->getId()); $results[$key]["\165\162\x6c"] = $element->url; $results[$key]["\x65\x6e\x74\x72\171"] = $entry instanceof Entry ? $entry->getId() : false; $tags = $element->tags; if (false !== $entry && !empty($tags)) { $tags = explode("\54", $tags); foreach ($tags as $label) { $label = trim($label); $tag = $tagRepository->findOneByLabel($label); if (false !== $tag) { $entry->removeTag($tag); } } $this->entityManager->persist($entry); $this->entityManager->flush(); } } return $this->sendResponse($results); } public function postEntriesTagsListAction(Request $request, EntryRepository $entryRepository, TagsAssigner $tagsAssigner) { $this->validateAuthentication(); $list = json_decode($request->query->get("\x6c\x69\x73\164", array())); if (empty($list)) { return $this->sendResponse(array()); } $results = array(); foreach ($list as $key => $element) { $entry = $entryRepository->findByUrlAndUserId($element->url, $this->getUser()->getId()); $results[$key]["\165\x72\154"] = $element->url; $results[$key]["\x65\156\164\x72\x79"] = $entry instanceof Entry ? $entry->getId() : false; $tags = $element->tags; if (false !== $entry && !empty($tags)) { $tagsAssigner->assignTagsToEntry($entry, $tags); $this->entityManager->persist($entry); $this->entityManager->flush(); } } return $this->sendResponse($results); } private function replaceUrlHashes(array $results, array $urlHashMap) { $newResults = array(); foreach ($results as $hash => $res) { if (isset($urlHashMap[$hash])) { $newResults[$urlHashMap[$hash]] = $res; } else { $newResults[$hash] = $res; } } return $newResults; } private function retrieveValueFromRequest(Request $request) { return array("\164\151\x74\x6c\145" => $request->request->get("\164\x69\164\154\x65"), "\164\x61\x67\x73" => $request->request->get("\164\141\x67\163", array()), "\151\x73\101\162\x63\150\151\166\x65\x64" => $request->request->get("\x61\x72\x63\150\x69\x76\145"), "\x69\163\123\164\x61\162\x72\x65\144" => $request->request->get("\163\164\x61\162\162\145\x64"), "\151\163\x50\x75\x62\154\x69\143" => $request->request->get("\x70\165\x62\154\151\x63"), "\143\157\156\164\145\156\x74" => $request->request->get("\x63\x6f\x6e\164\145\156\x74"), "\x6c\141\156\147\165\141\x67\145" => $request->request->get("\x6c\141\156\x67\165\x61\147\x65"), "\160\151\143\x74\x75\162\x65" => $request->request->get("\x70\x72\x65\x76\x69\145\x77\x5f\160\x69\x63\164\x75\162\145"), "\160\x75\142\154\x69\x73\x68\145\144\101\164" => $request->request->get("\160\x75\142\x6c\x69\163\150\145\144\137\x61\164"), "\x61\165\164\x68\157\162\x73" => $request->request->get("\141\x75\164\x68\157\x72\x73", ''), "\157\162\151\147\151\x6e\x5f\x75\x72\x6c" => $request->request->get("\157\162\151\147\151\x6e\137\x75\x72\154", '')); } }

Function Calls

None

Variables

None

Stats

MD5 99ecf9117eaca5647232709a7c2bccbe
Eval Count 0
Decode Time 120 ms