Exemplo n.º 1
0
 /**
  * Display contact form
  */
 function indexAction()
 {
     Display::set("adPage", "contact");
     if (!Config::get("contactPageEnabled")) {
         return $this->return404();
     }
 }
Exemplo n.º 2
0
 /**
  * Index page
  */
 function indexAction()
 {
     //set adPage
     Display::set("adPage", "index");
     //set META description
     $this->set("metaDescription", Config::get("siteDescription"));
     $cache = Cacher::getInstance();
     //retrieve predefinied html directoryDescription from db
     if (($message = $cache->load("directoryDescription")) === null) {
         $message = $this->customMessage->findByPk("directoryDescription")->toArray();
         $cache->save($message, null, null, array("custommessage"));
     }
     $this->set("directoryDescription", $message);
 }
Exemplo n.º 3
0
 function showAllAction()
 {
     if (!Config::get("allCategoriesPageEnabled")) {
         return $this->return404();
     }
     Display::set("adPage", "allcategories");
     //get all categories first parents then childs to build tree
     $c = new Criteria();
     $c->addOrder("parentCategoryId, name");
     $categories = $this->category->findAll($c, "categoryId, parentCategoryId, name, urlName, validatedSitesCount");
     $tree = new NavigationTree();
     foreach ($categories as $category) {
         $value = $category;
         //add node to tree
         $tree->addNode($category['categoryId'], $category['parentCategoryId'], $value);
     }
     //build tree
     $this->set("allCategories", $tree->render());
 }
Exemplo n.º 4
0
 /**
  * Show keywords starting with letter
  */
 function showAction($letter)
 {
     if (!Config::get('keywordsEnabled') || !preg_match("#^[A-Z0-9]\$#", $letter)) {
         return $this->return404();
     }
     //set adPage for display
     Display::set("adPage", "letter{$letter}");
     $keywordGroups = array();
     //retrieve keywors which start with $letter
     $keywords = $this->keyword->getKeywordsWithPrefix($letter);
     $keywordIds = array();
     foreach ($keywords as $keyword) {
         $keywordIds[] = $keyword['keywordId'];
     }
     //Count validated sites which contain keyword
     $c = new Criteria();
     $c->add("keywordId", $keywordIds, "IN");
     $c->addGroup("keywordId");
     $c->addInnerJoin("sites", "sites.siteId", "keywordsofsites.siteId");
     $c->add("status", "validated");
     $sitesCountsForKeyword = $this->keywordsOfSite->getArray($c, "count(*)", "keywordId");
     //foreach keyword on this page check have many sites include it and push it to prefix group
     foreach ($keywords as $keyword) {
         //if some site have this keyword
         if (isset($sitesCountsForKeyword[$keyword['keywordId']])) {
             $keyword['count'] = $sitesCountsForKeyword[$keyword['keywordId']];
         } else {
             //if no set counter to default 0
             $keyword['count'] = 0;
         }
         //if group for this prefix doesn't exists so far
         if (!isset($keywordGroups[$keyword['prefix']]['keywords'])) {
             //create group for this prefix
             $keywordGroups[$keyword['prefix']]['keywords'] = array();
         }
         //add keyword to prefix group
         $keywordGroups[$keyword['prefix']]['keywords'][] = $keyword;
     }
     $this->set("letter", $letter);
     $this->set("keywordGroups", $keywordGroups);
 }
Exemplo n.º 5
0
 /**
  * Display sites which containt searched phrase
  */
 function searchAction($searchQuery = "")
 {
     //set adPage for ads
     Display::set("adPage", "search");
     Display::set("searchPanel", true);
     $searchedItems = array();
     $this->request->fromArray($_GET);
     $searchValues = $this->request->toArray();
     $this->set("searchValuesJson", JsonView::php2js($searchValues));
     $page = !empty($this->request->page) ? $this->request->page : 1;
     $resultsCount = 0;
     //if something was searched
     if (!empty($searchValues)) {
         //get sites which containt searched phrase
         $searchedItems = $this->siteSearcher->searchValidated($searchValues, $page);
         $resultsCount = $this->siteSearcher->getFoundRowsCount();
         //if this phrase have matched sites save tag
         if (!empty($searchedItems) && !empty($this->request->phrase)) {
             $this->searchTag->addSearchTag($this->request->phrase, $searchedItems[0]);
         }
         $this->set('searchValues', $searchValues);
         //prepare data for pagination
         $totalPages = empty($searchedItems) ? 0 : ceil($resultsCount / Config::get("sitesPerPageInSearch"));
     } else {
         //nothing was searched
         $searchedItems = array();
         $totalPages = 0;
         $page = 1;
     }
     $this->set("resultsCount", $resultsCount);
     $this->set("searchedSites", $searchedItems);
     $searchArray = array();
     foreach (explode("&", ltrim($searchQuery, "?")) as $searchPair) {
         if (strpos($searchPair, "=") === false) {
             continue;
         }
         list($key, $value) = explode("=", $searchPair);
         if (!$value || in_array($key, array("page", "search"))) {
             continue;
         }
         $searchArray[urldecode($key)] = urldecode($value);
     }
     $paginationBaseLink = "/site/search/?" . str_replace("%", "%%", http_build_query($searchArray)) . "&page=";
     $this->set("pageNavigation", array("baseLink" => $paginationBaseLink, "totalPages" => $totalPages, "currentPage" => $page));
 }
Exemplo n.º 6
0
 protected function return404()
 {
     header('Status: 404 Not Found');
     header('HTTP/1.0 404 Not Found');
     $this->niceName = "front";
     $this->viewFile = "404";
     Display::set("adPage", "error404");
     echo $this->render();
     exit;
 }
Exemplo n.º 7
0
 /**
  * Executes custom query
  * @return resource MySQL result resource
  */
 public function sqlQuery($sql)
 {
     if (!$this->connected) {
         $this->connect();
         $this->connected = true;
         $this->sqlQuery("SET NAMES " . Config::get('DEFAULT_CHARSET'));
     }
     $startTime = microtime(true);
     $res = mysql_query($sql);
     $endTime = microtime(true);
     $queryTime = $endTime - $startTime;
     if ($this->debug) {
         echo sprintf("%f", $queryTime) . "<br>";
         echo "<b>" . $sql . "</b><br><br>";
     }
     $this->queriesCnt++;
     $this->queriesTime += $queryTime;
     Display::set("queriesCount", $this->queriesCnt);
     Display::set("queriesTime", $this->queriesTime);
     if (!$res) {
         echo $sql;
         $error = mysql_error();
         $errornr = mysql_errno();
         trigger_error("B³±d SQL {$error} ({$errornr})");
     }
     $this->lastInsertId = mysql_insert_id();
     $this->lastAffectedRows = mysql_affected_rows();
     return $res;
 }