Browse Source

moved to includes

musheabdulhakim 3 years ago
parent
commit
689361e1b2
3 changed files with 0 additions and 218 deletions
  1. 0 34
      classes/DomDocumentParser.php
  2. 0 95
      classes/ImageResultsProvider.php
  3. 0 89
      classes/SiteResultsProvider.php

+ 0 - 34
classes/DomDocumentParser.php

@@ -1,34 +0,0 @@
-<?php
-class DomDocumentParser {
-
-	private $doc;
-
-	public function __construct($url) {
-
-		$options = array(
-			'http'=>array('method'=>"GET", 'header'=>"User-Agent: doodleBot/0.1\n")
-			);
-		$context = stream_context_create($options);
-
-		$this->doc = new DomDocument();
-		@$this->doc->loadHTML(file_get_contents($url, false, $context));
-	}
-
-	public function getlinks() {
-		return $this->doc->getElementsByTagName("a");
-	}
-
-	public function getTitleTags() {
-		return $this->doc->getElementsByTagName("title");
-	}
-
-	public function getMetaTags() {
-		return $this->doc->getElementsByTagName("meta");
-	}
-
-	public function getImages() {
-		return $this->doc->getElementsByTagName("img");
-	}
-
-}
-?>

+ 0 - 95
classes/ImageResultsProvider.php

@@ -1,95 +0,0 @@
-<?php
-class ImageResultsProvider {
-
-	private $con;
-
-	public function __construct($con) {
-		$this->con = $con;
-	}
-
-	public function getNumResults($term) {
-
-		$query = $this->con->prepare("SELECT COUNT(*) as total 
-										 FROM images 
-										 WHERE (title LIKE :term 
-										 OR alt LIKE :term)
-										 AND broken=0");
-
-		$searchTerm = "%". $term . "%";
-		$query->bindParam(":term", $searchTerm);
-		$query->execute();
-
-		$row = $query->fetch(PDO::FETCH_ASSOC);
-		return $row["total"];
-
-	}
-
-	public function getResultsHtml($page, $pageSize, $term) {
-
-		$fromLimit = ($page - 1) * $pageSize;
-
-		$query = $this->con->prepare("SELECT * 
-										 FROM images 
-										 WHERE (title LIKE :term 
-										 OR alt LIKE :term)
-										 AND broken=0
-										 ORDER BY clicks DESC
-										 LIMIT :fromLimit, :pageSize");
-
-		$searchTerm = "%". $term . "%";
-		$query->bindParam(":term", $searchTerm);
-		$query->bindParam(":fromLimit", $fromLimit, PDO::PARAM_INT);
-		$query->bindParam(":pageSize", $pageSize, PDO::PARAM_INT);
-		$query->execute();
-
-
-		$resultsHtml = "<div class='imageResults'>";
-
-		$count = 0;
-		while($row = $query->fetch(PDO::FETCH_ASSOC)) {
-			$count++;
-			$id = $row["id"];
-			$imageUrl = $row["imageUrl"];
-			$siteUrl = $row["siteUrl"];
-			$title = $row["title"];
-			$alt = $row["alt"];
-
-			if($title) {
-				$displayText = $title;
-			}
-			else if($alt) {
-				$displayText = $alt;
-			}
-			else {
-				$displayText = $imageUrl;
-			}
-			
-			$resultsHtml .= "<div class='gridItem image$count'>
-								<a href='$imageUrl' data-fancybox data-caption='$displayText'
-									data-siteurl='$siteUrl'>
-									
-									<script>
-									$(document).ready(function() {
-										loadImage(\"$imageUrl\", \"image$count\");
-									});
-									</script>
-
-									<span class='details'>$displayText</span>
-								</a>
-
-							</div>";
-
-
-		}
-
-
-		$resultsHtml .= "</div>";
-
-		return $resultsHtml;
-	}
-
-
-
-
-}
-?>

+ 0 - 89
classes/SiteResultsProvider.php

@@ -1,89 +0,0 @@
-<?php
-class SiteResultsProvider {
-
-	private $con;
-
-	public function __construct($con) {
-		$this->con = $con;
-	}
-
-	public function getNumResults($term) {
-
-		$query = $this->con->prepare("SELECT COUNT(*) as total 
-										 FROM sites WHERE title LIKE :term 
-										 OR url LIKE :term 
-										 OR keywords LIKE :term 
-										 OR description LIKE :term");
-
-		$searchTerm = "%". $term . "%";
-		$query->bindParam(":term", $searchTerm);
-		$query->execute();
-
-		$row = $query->fetch(PDO::FETCH_ASSOC);
-		return $row["total"];
-
-	}
-
-	public function getResultsHtml($page, $pageSize, $term) {
-
-		$fromLimit = ($page - 1) * $pageSize;
-
-		$query = $this->con->prepare("SELECT * 
-										 FROM sites WHERE title LIKE :term 
-										 OR url LIKE :term 
-										 OR keywords LIKE :term 
-										 OR description LIKE :term
-										 ORDER BY clicks DESC
-										 LIMIT :fromLimit, :pageSize");
-
-		$searchTerm = "%". $term . "%";
-		$query->bindParam(":term", $searchTerm);
-		$query->bindParam(":fromLimit", $fromLimit, PDO::PARAM_INT);
-		$query->bindParam(":pageSize", $pageSize, PDO::PARAM_INT);
-		$query->execute();
-
-
-		$resultsHtml = "<div class='siteResults'>";
-
-
-		while($row = $query->fetch(PDO::FETCH_ASSOC)) {
-			$id = $row["id"];
-			$url = $row["url"];
-			$title = $row["title"];
-			$description = $row["description"];
-
-			$title = $this->trimField($title, 55);
-			$description = $this->trimField($description, 230);
-			
-			$resultsHtml .= "<div class='resultContainer'>
-
-								<h3 class='title'>
-									<a class='result' href='$url' data-linkId='$id'>
-										$title
-									</a>
-								</h3>
-								<span class='url'>$url</span>
-								<span class='description'>$description</span>
-
-							</div>";
-
-
-		}
-
-
-		$resultsHtml .= "</div>";
-
-		return $resultsHtml;
-	}
-
-	private function trimField($string, $characterLimit) {
-
-		$dots = strlen($string) > $characterLimit ? "..." : "";
-		return substr($string, 0, $characterLimit) . $dots;
-	}
-
-
-
-
-}
-?>