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\Repository; use Doctrine\Bundle\DoctrineBundle\Repository\Servic..

Decoded Output download

<?php
 namespace Wallabag\Repository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\NoResultException; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ManagerRegistry; use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter; use Pagerfanta\Pagerfanta; use Wallabag\Entity\Entry; use Wallabag\Entity\Tag; use Wallabag\Helper\UrlHasher; class EntryRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Entry::class); } public function getBuilderForAllByUser($userId) { return $this->getSortedQueryBuilderByUser($userId); } public function getCountBuilderForAllByUser($userId) { return $this->getQueryBuilderByUser($userId); } public function getBuilderForUnreadByUser($userId) { return $this->getSortedQueryBuilderByUser($userId)->andWhere("e.isArchived = false"); } public function getCountBuilderForUnreadByUser($userId) { return $this->getQueryBuilderByUser($userId)->andWhere("e.isArchived = false"); } public function getBuilderForSameDomainByUser($userId, $entryId) { $queryBuilder = $this->createQueryBuilder("e"); return $this->getSortedQueryBuilderByUser($userId)->andWhere("e.id <> :entryId")->setParameter("entryId", $entryId)->andWhere($queryBuilder->expr()->in("e.domainName", $this->createQueryBuilder("e2")->select("e2.domainName")->where("e2.id = :entryId")->setParameter("entryId", $entryId)->getDQL())); } public function getBuilderForArchiveByUser($userId) { return $this->getSortedQueryBuilderByUser($userId, "archivedAt", "desc")->andWhere("e.isArchived = true"); } public function getCountBuilderForArchiveByUser($userId) { return $this->getQueryBuilderByUser($userId)->andWhere("e.isArchived = true"); } public function getBuilderForStarredByUser($userId) { return $this->getSortedQueryBuilderByUser($userId, "starredAt", "desc")->andWhere("e.isStarred = true"); } public function getCountBuilderForStarredByUser($userId) { return $this->getQueryBuilderByUser($userId)->andWhere("e.isStarred = true"); } public function getBuilderForSearchByUser($userId, $term, $currentRoute) { $qb = $this->getSortedQueryBuilderByUser($userId); if ("starred" === $currentRoute) { $qb->andWhere("e.isStarred = true"); } elseif ("unread" === $currentRoute || "homepage" === $currentRoute) { $qb->andWhere("e.isArchived = false"); } elseif ("archive" === $currentRoute) { $qb->andWhere("e.isArchived = true"); } $qb->andWhere("lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term) OR lower(a.text) LIKE lower(:term)")->setParameter("term", "%" . $term . "%")->leftJoin("e.tags", "t")->leftJoin("e.annotations", "a")->groupBy("e.id"); return $qb; } public function getBuilderForUntaggedByUser($userId) { return $this->sortQueryBuilder($this->getRawBuilderForUntaggedByUser($userId)); } public function getBuilderForAnnotationsByUser($userId) { return $this->getSortedQueryBuilderByUser($userId)->innerJoin("e.annotations", "a"); } public function getCountBuilderForAnnotationsByUser($userId) { return $this->getQueryBuilderByUser($userId)->innerJoin("e.annotations", "a"); } public function getRawBuilderForUntaggedByUser($userId) { return $this->getQueryBuilderByUser($userId)->leftJoin("e.tags", "t")->andWhere("t.id is null"); } public function countUntaggedEntriesByUser($userId) { return (int) $this->getRawBuilderForUntaggedByUser($userId)->select("count(e.id)")->getQuery()->getSingleScalarResult(); } public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = "created", $order = "asc", $since = 0, $tags = '', $detail = "full", $domainName = '', $isNotParsed = null) { if (!\in_array(strtolower($detail), array("full", "metadata"), true)) { throw new \Exception("Detail "" . $detail . "" parameter is wrong, allowed: full or metadata"); } $qb = $this->createQueryBuilder("e")->leftJoin("e.tags", "t")->where("e.user = :userId")->setParameter("userId", $userId); if ("metadata" === $detail) { $fieldNames = $this->getClassMetadata()->getFieldNames(); $fields = array_filter($fieldNames, function ($k) { return "content" !== $k; }); $qb->select(sprintf("partial e.{%s}", implode(",", $fields))); } if (null !== $isArchived) { $qb->andWhere("e.isArchived = :isArchived")->setParameter("isArchived", (bool) $isArchived); } if (null !== $isStarred) { $qb->andWhere("e.isStarred = :isStarred")->setParameter("isStarred", (bool) $isStarred); } if (null !== $isPublic) { $qb->andWhere("e.uid IS " . (true === $isPublic ? "NOT" : '') . " NULL"); } if (null !== $isNotParsed) { $qb->andWhere("e.isNotParsed = :isNotParsed")->setParameter("isNotParsed", (bool) $isNotParsed); } if ($since > 0) { $qb->andWhere("e.updatedAt > :since")->setParameter("since", new \DateTime(date("Y-m-d H:i:s", $since))); } if (\is_string($tags) && '' !== $tags) { foreach (explode(",", $tags) as $i => $tag) { $entryAlias = "e" . $i; $tagAlias = "t" . $i; $qb->andWhere($qb->expr()->in("e.id", $this->createQueryBuilder($entryAlias)->select($entryAlias . ".id")->leftJoin($entryAlias . ".tags", $tagAlias)->where($tagAlias . ".label = :label" . $i)->getDQL())); $qb->setParameter("label" . $i, $tag); } } if (\is_string($domainName) && '' !== $domainName) { $qb->andWhere("e.domainName = :domainName")->setParameter("domainName", $domainName); } if (!\in_array(strtolower($order), array("asc", "desc"), true)) { throw new \Exception("Order "" . $order . "" parameter is wrong, allowed: asc or desc"); } if ("created" === $sort) { $qb->orderBy("e.id", $order); } elseif ("updated" === $sort) { $qb->orderBy("e.updatedAt", $order); } elseif ("archived" === $sort) { $qb->orderBy("e.archivedAt", $order); } $pagerAdapter = new DoctrineORMAdapter($qb, true, false); return new Pagerfanta($pagerAdapter); } public function findOneWithTags($userId) { $qb = $this->createQueryBuilder("e")->innerJoin("e.tags", "t")->innerJoin("e.user", "u")->addSelect("t", "u")->where("e.user = :userId")->setParameter("userId", $userId); return $qb->getQuery()->getResult(); } public function findDistinctLanguageByUser($userId) { $results = $this->createQueryBuilder("e")->select("e.language")->where("e.user = :userId")->setParameter("userId", $userId)->andWhere("e.language IS NOT NULL")->groupBy("e.language")->orderBy("e.language", " ASC")->getQuery()->getResult(); $languages = array(); foreach ($results as $result) { $languages[$result["language"]] = $result["language"]; } return $languages; } public function findOneByUsernameAndNotArchived($username) { return $this->createQueryBuilder("e")->leftJoin("e.user", "u")->where("u.username = :username")->setParameter("username", $username)->andWhere("e.isArchived = false")->setMaxResults(1)->getQuery()->getSingleResult(); } public function removeTag($userId, Tag $tag) { $entries = $this->getSortedQueryBuilderByUser($userId)->innerJoin("e.tags", "t")->andWhere("t.id = :tagId")->setParameter("tagId", $tag->getId())->getQuery()->getResult(); foreach ($entries as $entry) { $entry->removeTag($tag); } $this->getEntityManager()->flush(); } public function removeTags($userId, $tags) { foreach ($tags as $tag) { $this->removeTag($userId, $tag); } } public function findAllByTagId($userId, $tagId, $sort = "createdAt") { return $this->getSortedQueryBuilderByUser($userId, $sort)->innerJoin("e.tags", "t")->andWhere("t.id = :tagId")->setParameter("tagId", $tagId)->getQuery()->getResult(); } public function findByUrlAndUserId($url, $userId) { return $this->findByHashedUrlAndUserId(UrlHasher::hashUrl($url), $userId); } public function findByEmptyHashedUrlAndUserId(int $userId) { return $this->createQueryBuilder("e")->where("e.hashedUrl = :empty")->setParameter("empty", '')->orWhere("e.hashedUrl is null")->andWhere("e.user = :user_id")->setParameter("user_id", $userId)->andWhere("e.url is not null")->getQuery()->getResult(); } public function findByHashedUrlAndUserId($hashedUrl, $userId) { $res = $this->createQueryBuilder("e")->where("e.hashedUrl = :hashed_url")->setParameter("hashed_url", $hashedUrl)->andWhere("e.user = :user_id")->setParameter("user_id", $userId)->getQuery()->getResult(); if (\count($res)) { return current($res); } $res = $this->createQueryBuilder("e")->where("e.hashedGivenUrl = :hashed_given_url")->setParameter("hashed_given_url", $hashedUrl)->andWhere("e.user = :user_id")->setParameter("user_id", $userId)->getQuery()->getResult(); if (\count($res)) { return current($res); } return false; } public function findByUserIdAndBatchHashedUrls($userId, $hashedUrls) { $qb = $this->createQueryBuilder("e")->select(array("e.id", "e.hashedUrl", "e.hashedGivenUrl")); $res = $qb->where("e.user = :user_id")->setParameter("user_id", $userId)->andWhere($qb->expr()->orX($qb->expr()->in("e.hashedUrl", $hashedUrls), $qb->expr()->in("e.hashedGivenUrl", $hashedUrls)))->getQuery()->getResult(); return $res; } public function countAllEntriesByUser($userId) { $qb = $this->createQueryBuilder("e")->select("count(e)")->where("e.user = :userId")->setParameter("userId", $userId); return (int) $qb->getQuery()->getSingleScalarResult(); } public function removeAllByUserId($userId) { $this->getEntityManager()->createQuery("DELETE FROM Wallabag\Entity\Entry e WHERE e.user = :userId")->setParameter("userId", $userId)->execute(); } public function removeArchivedByUserId($userId) { $this->getEntityManager()->createQuery("DELETE FROM Wallabag\Entity\Entry e WHERE e.user = :userId AND e.isArchived = TRUE")->setParameter("userId", $userId)->execute(); } public function findAllEntriesIdAndUrlByUserId($userId) { $qb = $this->createQueryBuilder("e")->select("e.id, e.url")->where("e.user = :userid")->setParameter(":userid", $userId); return $qb->getQuery()->getArrayResult(); } public function findAllEntriesIdByUserId($userId = null) { $qb = $this->createQueryBuilder("e")->select("e.id"); if (null !== $userId) { $qb->where("e.user = :userid")->setParameter(":userid", $userId); } return $qb->getQuery()->getArrayResult(); } public function findAllEntriesIdByUserIdAndNotParsed($userId = null) { $qb = $this->createQueryBuilder("e")->select("e.id")->where("e.isNotParsed = true"); if (null !== $userId) { $qb->where("e.user = :userid")->setParameter(":userid", $userId); } return $qb->getQuery()->getArrayResult(); } public function findEmptyEntriesIdByUserId($userId = null) { $qb = $this->createQueryBuilder("e")->select("e.id"); if (null !== $userId) { $qb->where("e.user = :userid AND e.content IS NULL")->setParameter(":userid", $userId); } return $qb->getQuery()->getArrayResult(); } public function findAllByUrlAndUserId($url, $userId) { return $this->createQueryBuilder("e")->where("e.url = :url")->setParameter("url", urldecode($url))->andWhere("e.user = :user_id")->setParameter("user_id", $userId)->getQuery()->getResult(); } public function getRandomEntry($userId, $type = '') { $qb = $this->getQueryBuilderByUser($userId)->select("e.id"); switch ($type) { case "unread": $qb->andWhere("e.isArchived = false"); break; case "archive": $qb->andWhere("e.isArchived = true"); break; case "starred": $qb->andWhere("e.isStarred = true"); break; case "untagged": $qb->leftJoin("e.tags", "t"); $qb->andWhere("t.id is null"); break; case "annotated": $qb->leftJoin("e.annotations", "a"); $qb->andWhere("a.id is not null"); break; } $ids = $qb->getQuery()->getArrayResult(); if (empty($ids)) { throw new NoResultException(); } $randomId = $ids[mt_rand(0, \count($ids) - 1)]["id"]; return $this->find($randomId); } private function getQueryBuilderByUser($userId) { return $this->createQueryBuilder("e")->andWhere("e.user = :userId")->setParameter("userId", $userId); } private function getSortedQueryBuilderByUser($userId, $sortBy = "createdAt", $direction = "desc") { return $this->sortQueryBuilder($this->getQueryBuilderByUser($userId), $sortBy, $direction); } private function sortQueryBuilder(QueryBuilder $qb, $sortBy = "createdAt", $direction = "desc") { return $qb->orderBy(sprintf("e.%s", $sortBy), $direction); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Wallabag\Repository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\ORM\NoResultException; use Doctrine\ORM\QueryBuilder; use Doctrine\Persistence\ManagerRegistry; use Pagerfanta\Doctrine\ORM\QueryAdapter as DoctrineORMAdapter; use Pagerfanta\Pagerfanta; use Wallabag\Entity\Entry; use Wallabag\Entity\Tag; use Wallabag\Helper\UrlHasher; class EntryRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { parent::__construct($registry, Entry::class); } public function getBuilderForAllByUser($userId) { return $this->getSortedQueryBuilderByUser($userId); } public function getCountBuilderForAllByUser($userId) { return $this->getQueryBuilderByUser($userId); } public function getBuilderForUnreadByUser($userId) { return $this->getSortedQueryBuilderByUser($userId)->andWhere("\x65\x2e\151\163\101\x72\x63\x68\151\x76\x65\x64\40\x3d\40\146\x61\154\x73\x65"); } public function getCountBuilderForUnreadByUser($userId) { return $this->getQueryBuilderByUser($userId)->andWhere("\145\x2e\151\x73\101\x72\143\x68\151\x76\145\144\40\x3d\40\146\x61\154\163\x65"); } public function getBuilderForSameDomainByUser($userId, $entryId) { $queryBuilder = $this->createQueryBuilder("\x65"); return $this->getSortedQueryBuilderByUser($userId)->andWhere("\145\x2e\x69\x64\x20\74\x3e\40\72\145\156\x74\162\171\x49\x64")->setParameter("\x65\x6e\164\162\x79\111\x64", $entryId)->andWhere($queryBuilder->expr()->in("\145\56\x64\157\x6d\141\x69\x6e\116\x61\x6d\x65", $this->createQueryBuilder("\x65\x32")->select("\x65\x32\x2e\144\157\155\x61\x69\x6e\x4e\x61\x6d\x65")->where("\x65\x32\x2e\151\144\x20\x3d\40\x3a\x65\156\164\x72\171\111\x64")->setParameter("\145\156\164\162\171\x49\x64", $entryId)->getDQL())); } public function getBuilderForArchiveByUser($userId) { return $this->getSortedQueryBuilderByUser($userId, "\141\162\x63\150\151\x76\145\144\101\164", "\144\145\163\x63")->andWhere("\x65\56\151\163\x41\162\143\150\x69\166\x65\x64\40\x3d\x20\164\162\x75\145"); } public function getCountBuilderForArchiveByUser($userId) { return $this->getQueryBuilderByUser($userId)->andWhere("\x65\x2e\151\163\x41\x72\143\x68\151\166\145\144\40\75\x20\164\x72\165\x65"); } public function getBuilderForStarredByUser($userId) { return $this->getSortedQueryBuilderByUser($userId, "\163\x74\x61\x72\162\145\144\101\164", "\144\145\163\143")->andWhere("\x65\x2e\x69\x73\x53\164\141\x72\x72\145\144\40\75\x20\164\x72\165\x65"); } public function getCountBuilderForStarredByUser($userId) { return $this->getQueryBuilderByUser($userId)->andWhere("\145\56\151\x73\x53\x74\x61\162\x72\x65\144\40\x3d\40\164\162\165\145"); } public function getBuilderForSearchByUser($userId, $term, $currentRoute) { $qb = $this->getSortedQueryBuilderByUser($userId); if ("\163\x74\x61\162\162\x65\x64" === $currentRoute) { $qb->andWhere("\x65\56\151\163\123\x74\x61\x72\162\145\144\x20\x3d\x20\x74\x72\165\145"); } elseif ("\x75\x6e\x72\145\x61\x64" === $currentRoute || "\150\x6f\x6d\x65\160\141\x67\145" === $currentRoute) { $qb->andWhere("\x65\56\151\x73\x41\162\143\x68\x69\166\145\x64\x20\x3d\x20\146\141\154\163\145"); } elseif ("\x61\162\143\150\x69\166\x65" === $currentRoute) { $qb->andWhere("\x65\56\x69\x73\x41\162\143\150\x69\x76\145\x64\x20\x3d\x20\x74\162\x75\x65"); } $qb->andWhere("\154\157\167\145\x72\50\145\56\143\x6f\156\164\145\156\x74\51\40\x4c\111\113\x45\40\154\157\x77\x65\162\x28\72\x74\x65\162\x6d\51\40\x4f\x52\40\154\x6f\167\145\x72\50\145\x2e\x74\151\x74\x6c\145\x29\x20\x4c\x49\x4b\105\40\154\157\x77\x65\162\x28\72\164\x65\x72\x6d\51\40\x4f\x52\x20\154\157\167\145\x72\50\145\56\x75\162\154\x29\40\x4c\x49\x4b\x45\40\154\x6f\x77\145\x72\x28\x3a\164\145\162\155\51\x20\117\122\x20\154\x6f\167\145\162\50\x61\x2e\x74\145\x78\164\x29\40\x4c\x49\x4b\x45\40\154\x6f\167\x65\x72\x28\x3a\x74\145\x72\x6d\51")->setParameter("\x74\145\162\x6d", "\45" . $term . "\x25")->leftJoin("\x65\56\x74\141\x67\x73", "\x74")->leftJoin("\x65\x2e\x61\x6e\x6e\157\164\x61\x74\x69\157\156\x73", "\141")->groupBy("\145\x2e\x69\144"); return $qb; } public function getBuilderForUntaggedByUser($userId) { return $this->sortQueryBuilder($this->getRawBuilderForUntaggedByUser($userId)); } public function getBuilderForAnnotationsByUser($userId) { return $this->getSortedQueryBuilderByUser($userId)->innerJoin("\x65\56\141\156\x6e\x6f\164\141\x74\151\x6f\156\x73", "\141"); } public function getCountBuilderForAnnotationsByUser($userId) { return $this->getQueryBuilderByUser($userId)->innerJoin("\x65\56\x61\156\x6e\x6f\164\x61\164\151\157\156\163", "\141"); } public function getRawBuilderForUntaggedByUser($userId) { return $this->getQueryBuilderByUser($userId)->leftJoin("\145\x2e\164\x61\147\163", "\164")->andWhere("\164\56\151\x64\x20\x69\163\x20\156\165\x6c\x6c"); } public function countUntaggedEntriesByUser($userId) { return (int) $this->getRawBuilderForUntaggedByUser($userId)->select("\x63\157\x75\156\164\x28\145\56\151\144\x29")->getQuery()->getSingleScalarResult(); } public function findEntries($userId, $isArchived = null, $isStarred = null, $isPublic = null, $sort = "\x63\x72\145\141\x74\x65\x64", $order = "\141\163\x63", $since = 0, $tags = '', $detail = "\x66\165\x6c\x6c", $domainName = '', $isNotParsed = null) { if (!\in_array(strtolower($detail), array("\x66\165\x6c\x6c", "\x6d\x65\164\x61\x64\x61\x74\x61"), true)) { throw new \Exception("\104\x65\164\141\151\x6c\40\x22" . $detail . "\42\x20\x70\141\x72\x61\155\x65\164\x65\162\40\151\163\40\167\x72\157\156\147\x2c\x20\x61\x6c\x6c\157\x77\x65\x64\x3a\40\146\x75\154\x6c\40\157\162\40\x6d\145\164\141\144\x61\x74\x61"); } $qb = $this->createQueryBuilder("\145")->leftJoin("\145\x2e\x74\141\147\163", "\164")->where("\x65\x2e\x75\163\x65\162\x20\75\40\x3a\x75\x73\145\x72\111\x64")->setParameter("\165\x73\x65\162\x49\144", $userId); if ("\155\145\x74\141\144\x61\x74\141" === $detail) { $fieldNames = $this->getClassMetadata()->getFieldNames(); $fields = array_filter($fieldNames, function ($k) { return "\x63\x6f\x6e\164\145\x6e\x74" !== $k; }); $qb->select(sprintf("\x70\x61\162\x74\151\x61\x6c\40\x65\x2e\x7b\x25\x73\x7d", implode("\x2c", $fields))); } if (null !== $isArchived) { $qb->andWhere("\x65\x2e\x69\x73\x41\x72\143\x68\x69\x76\145\144\40\x3d\40\x3a\151\x73\x41\162\x63\150\151\x76\x65\144")->setParameter("\x69\163\x41\x72\143\x68\x69\166\x65\x64", (bool) $isArchived); } if (null !== $isStarred) { $qb->andWhere("\145\x2e\151\x73\123\164\x61\x72\162\x65\x64\40\75\40\x3a\x69\x73\x53\x74\x61\162\x72\145\144")->setParameter("\151\163\123\164\141\162\x72\x65\144", (bool) $isStarred); } if (null !== $isPublic) { $qb->andWhere("\x65\x2e\x75\x69\x64\40\x49\x53\40" . (true === $isPublic ? "\x4e\x4f\x54" : '') . "\x20\116\125\114\x4c"); } if (null !== $isNotParsed) { $qb->andWhere("\145\56\x69\x73\x4e\x6f\x74\120\141\162\x73\145\144\x20\x3d\40\x3a\x69\x73\116\157\164\x50\141\162\x73\145\x64")->setParameter("\x69\163\x4e\157\x74\x50\141\162\163\x65\144", (bool) $isNotParsed); } if ($since > 0) { $qb->andWhere("\145\x2e\165\x70\x64\141\x74\x65\144\x41\x74\x20\76\x20\x3a\163\x69\156\x63\145")->setParameter("\163\x69\156\x63\145", new \DateTime(date("\x59\x2d\x6d\x2d\144\40\x48\x3a\x69\x3a\163", $since))); } if (\is_string($tags) && '' !== $tags) { foreach (explode("\x2c", $tags) as $i => $tag) { $entryAlias = "\145" . $i; $tagAlias = "\x74" . $i; $qb->andWhere($qb->expr()->in("\145\56\x69\x64", $this->createQueryBuilder($entryAlias)->select($entryAlias . "\56\151\144")->leftJoin($entryAlias . "\x2e\164\141\147\163", $tagAlias)->where($tagAlias . "\56\154\x61\x62\x65\154\40\x3d\x20\72\154\x61\142\x65\154" . $i)->getDQL())); $qb->setParameter("\154\x61\142\145\x6c" . $i, $tag); } } if (\is_string($domainName) && '' !== $domainName) { $qb->andWhere("\x65\x2e\144\157\x6d\x61\x69\156\116\x61\x6d\x65\40\75\40\72\144\157\155\x61\151\156\x4e\141\x6d\145")->setParameter("\144\x6f\x6d\141\151\156\116\141\155\x65", $domainName); } if (!\in_array(strtolower($order), array("\x61\x73\143", "\x64\x65\163\143"), true)) { throw new \Exception("\x4f\x72\x64\145\162\40\42" . $order . "\42\40\160\x61\162\141\x6d\145\164\x65\x72\x20\151\163\40\x77\x72\x6f\x6e\x67\x2c\40\141\154\154\157\167\x65\144\72\40\141\x73\143\x20\x6f\x72\x20\144\x65\x73\143"); } if ("\x63\x72\145\141\164\145\144" === $sort) { $qb->orderBy("\x65\56\x69\144", $order); } elseif ("\165\160\144\x61\x74\x65\x64" === $sort) { $qb->orderBy("\145\x2e\165\160\144\x61\x74\145\x64\101\164", $order); } elseif ("\x61\x72\x63\x68\151\166\145\144" === $sort) { $qb->orderBy("\145\56\x61\162\143\150\151\166\x65\x64\101\x74", $order); } $pagerAdapter = new DoctrineORMAdapter($qb, true, false); return new Pagerfanta($pagerAdapter); } public function findOneWithTags($userId) { $qb = $this->createQueryBuilder("\145")->innerJoin("\x65\56\x74\141\147\163", "\164")->innerJoin("\x65\x2e\165\x73\x65\162", "\165")->addSelect("\x74", "\165")->where("\145\56\x75\163\145\x72\40\75\x20\72\x75\x73\145\162\111\x64")->setParameter("\165\163\x65\x72\x49\144", $userId); return $qb->getQuery()->getResult(); } public function findDistinctLanguageByUser($userId) { $results = $this->createQueryBuilder("\145")->select("\x65\x2e\154\141\x6e\147\x75\x61\x67\145")->where("\145\x2e\x75\x73\145\162\40\75\40\x3a\165\x73\x65\x72\111\x64")->setParameter("\x75\x73\x65\x72\111\x64", $userId)->andWhere("\x65\x2e\x6c\141\156\147\x75\141\147\145\x20\111\123\x20\x4e\117\x54\40\x4e\125\x4c\114")->groupBy("\145\56\x6c\x61\x6e\147\165\x61\x67\x65")->orderBy("\x65\x2e\x6c\141\156\x67\165\x61\147\145", "\40\x41\123\x43")->getQuery()->getResult(); $languages = array(); foreach ($results as $result) { $languages[$result["\154\x61\156\147\x75\141\147\145"]] = $result["\x6c\141\x6e\147\165\141\147\x65"]; } return $languages; } public function findOneByUsernameAndNotArchived($username) { return $this->createQueryBuilder("\x65")->leftJoin("\145\56\x75\163\145\x72", "\165")->where("\165\56\165\163\x65\x72\156\141\155\145\x20\75\x20\72\165\163\145\162\x6e\141\x6d\x65")->setParameter("\x75\163\x65\x72\156\x61\155\x65", $username)->andWhere("\145\x2e\151\163\x41\x72\x63\150\x69\166\x65\144\40\x3d\x20\146\x61\x6c\163\x65")->setMaxResults(1)->getQuery()->getSingleResult(); } public function removeTag($userId, Tag $tag) { $entries = $this->getSortedQueryBuilderByUser($userId)->innerJoin("\x65\56\x74\x61\x67\x73", "\164")->andWhere("\164\x2e\151\144\40\75\x20\72\164\141\x67\111\144")->setParameter("\x74\x61\x67\x49\144", $tag->getId())->getQuery()->getResult(); foreach ($entries as $entry) { $entry->removeTag($tag); } $this->getEntityManager()->flush(); } public function removeTags($userId, $tags) { foreach ($tags as $tag) { $this->removeTag($userId, $tag); } } public function findAllByTagId($userId, $tagId, $sort = "\x63\x72\x65\x61\164\145\x64\x41\164") { return $this->getSortedQueryBuilderByUser($userId, $sort)->innerJoin("\x65\56\164\141\x67\163", "\164")->andWhere("\164\56\151\144\x20\75\40\72\x74\x61\x67\111\x64")->setParameter("\x74\141\147\x49\144", $tagId)->getQuery()->getResult(); } public function findByUrlAndUserId($url, $userId) { return $this->findByHashedUrlAndUserId(UrlHasher::hashUrl($url), $userId); } public function findByEmptyHashedUrlAndUserId(int $userId) { return $this->createQueryBuilder("\145")->where("\x65\56\150\141\x73\150\x65\x64\x55\x72\154\x20\x3d\x20\x3a\x65\x6d\160\164\x79")->setParameter("\145\155\160\x74\x79", '')->orWhere("\x65\x2e\150\x61\x73\150\145\x64\x55\x72\x6c\x20\151\163\x20\x6e\x75\x6c\x6c")->andWhere("\x65\56\x75\x73\145\162\x20\75\x20\x3a\165\x73\145\x72\137\151\x64")->setParameter("\165\x73\145\x72\x5f\x69\x64", $userId)->andWhere("\x65\56\165\162\x6c\x20\x69\163\40\156\157\x74\x20\156\x75\154\x6c")->getQuery()->getResult(); } public function findByHashedUrlAndUserId($hashedUrl, $userId) { $res = $this->createQueryBuilder("\x65")->where("\145\56\x68\x61\x73\x68\x65\x64\x55\162\x6c\x20\x3d\x20\72\150\x61\x73\150\x65\144\x5f\165\162\x6c")->setParameter("\150\x61\x73\x68\145\x64\x5f\165\x72\x6c", $hashedUrl)->andWhere("\x65\x2e\x75\163\x65\x72\40\x3d\x20\72\165\x73\145\x72\x5f\x69\x64")->setParameter("\165\x73\x65\x72\x5f\151\144", $userId)->getQuery()->getResult(); if (\count($res)) { return current($res); } $res = $this->createQueryBuilder("\145")->where("\145\x2e\150\141\x73\x68\145\x64\x47\x69\x76\145\156\x55\x72\154\40\75\40\72\x68\141\163\150\x65\144\137\147\151\166\x65\156\137\x75\x72\154")->setParameter("\x68\141\163\150\x65\x64\137\x67\151\166\x65\156\137\165\x72\154", $hashedUrl)->andWhere("\x65\x2e\165\163\x65\x72\40\x3d\40\x3a\x75\x73\145\162\x5f\151\144")->setParameter("\165\x73\x65\162\x5f\x69\144", $userId)->getQuery()->getResult(); if (\count($res)) { return current($res); } return false; } public function findByUserIdAndBatchHashedUrls($userId, $hashedUrls) { $qb = $this->createQueryBuilder("\x65")->select(array("\x65\56\151\x64", "\x65\x2e\150\141\163\x68\x65\x64\125\162\x6c", "\x65\56\150\x61\163\x68\145\x64\x47\151\166\145\x6e\x55\162\x6c")); $res = $qb->where("\145\x2e\165\x73\x65\162\x20\x3d\x20\x3a\165\x73\x65\162\137\x69\x64")->setParameter("\x75\163\x65\x72\x5f\151\144", $userId)->andWhere($qb->expr()->orX($qb->expr()->in("\x65\56\150\141\x73\150\x65\x64\x55\x72\x6c", $hashedUrls), $qb->expr()->in("\x65\56\150\x61\163\150\x65\x64\107\151\166\145\x6e\x55\162\154", $hashedUrls)))->getQuery()->getResult(); return $res; } public function countAllEntriesByUser($userId) { $qb = $this->createQueryBuilder("\x65")->select("\x63\157\x75\156\x74\x28\x65\51")->where("\145\56\x75\163\x65\162\40\x3d\x20\72\x75\x73\145\x72\x49\x64")->setParameter("\165\x73\x65\x72\111\x64", $userId); return (int) $qb->getQuery()->getSingleScalarResult(); } public function removeAllByUserId($userId) { $this->getEntityManager()->createQuery("\104\105\x4c\x45\x54\x45\x20\106\122\x4f\115\x20\x57\x61\x6c\x6c\141\142\x61\x67\x5c\x45\156\x74\151\164\171\x5c\105\x6e\x74\x72\x79\40\145\40\x57\110\105\122\105\x20\x65\x2e\165\163\x65\x72\x20\x3d\40\72\x75\x73\145\162\111\x64")->setParameter("\x75\x73\x65\x72\111\144", $userId)->execute(); } public function removeArchivedByUserId($userId) { $this->getEntityManager()->createQuery("\x44\x45\x4c\105\x54\105\40\x46\122\x4f\115\x20\x57\141\x6c\x6c\141\x62\141\x67\x5c\x45\156\164\151\164\171\134\x45\156\x74\162\x79\x20\x65\x20\127\x48\x45\x52\x45\40\x65\56\x75\163\145\x72\x20\x3d\x20\72\165\x73\x65\x72\111\144\40\x41\x4e\104\x20\145\56\x69\x73\x41\162\143\x68\x69\x76\145\x64\x20\x3d\40\124\x52\125\105")->setParameter("\165\x73\x65\162\111\x64", $userId)->execute(); } public function findAllEntriesIdAndUrlByUserId($userId) { $qb = $this->createQueryBuilder("\145")->select("\x65\56\151\144\54\40\x65\x2e\165\x72\154")->where("\145\x2e\x75\163\145\162\x20\x3d\x20\x3a\165\163\145\x72\x69\144")->setParameter("\72\x75\x73\145\162\x69\144", $userId); return $qb->getQuery()->getArrayResult(); } public function findAllEntriesIdByUserId($userId = null) { $qb = $this->createQueryBuilder("\x65")->select("\x65\x2e\151\144"); if (null !== $userId) { $qb->where("\x65\56\165\163\x65\x72\40\75\x20\72\165\163\x65\162\x69\144")->setParameter("\x3a\x75\x73\145\162\151\x64", $userId); } return $qb->getQuery()->getArrayResult(); } public function findAllEntriesIdByUserIdAndNotParsed($userId = null) { $qb = $this->createQueryBuilder("\x65")->select("\145\x2e\x69\144")->where("\145\56\151\x73\x4e\x6f\x74\120\x61\162\x73\x65\x64\40\75\x20\x74\162\165\x65"); if (null !== $userId) { $qb->where("\x65\x2e\165\x73\145\x72\40\75\x20\x3a\165\x73\x65\x72\x69\x64")->setParameter("\72\x75\x73\145\x72\x69\144", $userId); } return $qb->getQuery()->getArrayResult(); } public function findEmptyEntriesIdByUserId($userId = null) { $qb = $this->createQueryBuilder("\145")->select("\x65\x2e\151\144"); if (null !== $userId) { $qb->where("\x65\56\165\163\145\x72\40\x3d\x20\x3a\x75\163\145\x72\x69\144\40\x41\x4e\x44\x20\x65\x2e\143\157\x6e\164\x65\x6e\164\x20\111\x53\x20\116\x55\114\x4c")->setParameter("\x3a\x75\163\145\x72\151\144", $userId); } return $qb->getQuery()->getArrayResult(); } public function findAllByUrlAndUserId($url, $userId) { return $this->createQueryBuilder("\145")->where("\145\56\x75\x72\x6c\40\75\40\72\165\162\x6c")->setParameter("\165\x72\154", urldecode($url))->andWhere("\145\x2e\165\163\x65\162\x20\x3d\40\72\165\x73\145\x72\x5f\x69\x64")->setParameter("\165\163\x65\162\137\151\x64", $userId)->getQuery()->getResult(); } public function getRandomEntry($userId, $type = '') { $qb = $this->getQueryBuilderByUser($userId)->select("\145\x2e\x69\x64"); switch ($type) { case "\165\x6e\x72\x65\x61\144": $qb->andWhere("\145\56\151\163\x41\x72\x63\x68\x69\166\x65\x64\x20\x3d\40\146\x61\154\163\x65"); break; case "\141\x72\143\150\151\166\x65": $qb->andWhere("\145\56\151\x73\x41\162\x63\150\151\166\145\x64\x20\75\40\x74\x72\x75\x65"); break; case "\x73\164\x61\162\x72\145\x64": $qb->andWhere("\x65\56\151\x73\x53\x74\x61\x72\162\145\x64\x20\x3d\40\x74\162\165\145"); break; case "\165\156\164\x61\147\x67\x65\144": $qb->leftJoin("\x65\x2e\164\x61\147\x73", "\164"); $qb->andWhere("\164\56\x69\144\40\151\x73\40\x6e\165\x6c\x6c"); break; case "\x61\x6e\x6e\157\x74\141\164\145\x64": $qb->leftJoin("\x65\56\x61\156\156\157\x74\x61\x74\151\x6f\x6e\x73", "\141"); $qb->andWhere("\x61\56\151\144\40\151\163\40\156\x6f\x74\x20\156\x75\154\154"); break; } $ids = $qb->getQuery()->getArrayResult(); if (empty($ids)) { throw new NoResultException(); } $randomId = $ids[mt_rand(0, \count($ids) - 1)]["\151\x64"]; return $this->find($randomId); } private function getQueryBuilderByUser($userId) { return $this->createQueryBuilder("\145")->andWhere("\145\56\x75\163\145\x72\40\75\x20\x3a\x75\x73\145\162\x49\144")->setParameter("\165\163\x65\162\111\x64", $userId); } private function getSortedQueryBuilderByUser($userId, $sortBy = "\x63\x72\145\x61\164\145\x64\x41\164", $direction = "\x64\x65\x73\143") { return $this->sortQueryBuilder($this->getQueryBuilderByUser($userId), $sortBy, $direction); } private function sortQueryBuilder(QueryBuilder $qb, $sortBy = "\x63\x72\145\x61\164\145\144\x41\164", $direction = "\x64\x65\163\x63") { return $qb->orderBy(sprintf("\145\x2e\45\x73", $sortBy), $direction); } }

Function Calls

None

Variables

None

Stats

MD5 50cf60a928a23fafbb116df9c7e510f2
Eval Count 0
Decode Time 104 ms