* @version $Id$ * @license http://opensource.org/licenses/agpl-v3.html */ /** * img.pew.cc Image Hosting * Copyright (C) 2009-2010 Daniel Triendl * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ require_once('lib/init.php'); require_once('lib/class.browse.php'); require_once('lib/class.search.php'); if (isset($_GET['q'])) { $search = new search($pdo); $images = $search->search($_GET['q']); // If we got no results, exit if (!count($images)) errorMsg("No results found."); // Only get a limited number of result $page = (isset($_GET['p']) && is_numeric($_GET['p'])) ? (int)$_GET['p'] : 1; $offset = ($page - 1) * $pagelimit; $imagecount = count($images); $images = array_slice($images, $offset, $pagelimit); // Output images ordered by relevance $output = ''; foreach ($images as $image) { $output .= '
' . htmlentities($image->original_name, ENT_QUOTES, 'UTF-8') . '
' . "\n"; $output .= 'Show
' . "\n"; } // Generate page counter $pages = '

'; for ($i = 1; $i <= ceil($imagecount/$pagelimit); $i++) { if ($i != $page) $pages .= '' . $i . ''; else $pages .= $i; $pages .= ' · '; } $pages = substr($pages, 0, -10) . '

'; outputHTML('

' . htmlentities(one_wordwrap(stripslashes_safe($_GET['q']), 5, '­'), ENT_QUOTES, 'UTF-8', false) . '

' . $output . '
' . $pages, array('title' => 'Search: ' . htmlentities(stripslashes_safe($_GET['q']), ENT_QUOTES, 'UTF-8'), 'lightbox' => true)); } else { // For advanced options $header = '' . "\n"; /*$header .= ''; $header .= '';*/ // Generate a simple search field $output = '

Search

'; outputHTML($output, array('title' => 'Search', 'header' => $header)); } ?>