/** * @version $Id: search.php 237 2014-04-25 11:47:48Z soeren $ * @package eXtplorer * @copyright soeren 2007-2014 * @author The eXtplorer project (http://extplorer.net) * @author The The QuiX project (http://quixplorer.sourceforge.net) * * @license * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * License for the specific language governing rights and limitations * under the License. * * Alternatively, the contents of this file may be used under the terms * of the GNU General Public License Version 2 or later (the "GPL"), in * which case the provisions of the GPL are applicable instead of * those above. If you wish to allow use of your version of this file only * under the terms of the GPL and not to allow others to use * your version of this file under the MPL, indicate your decision by * deleting the provisions above and replace them with the notice and * other provisions required by the GPL. If you do not delete * the provisions above, a recipient may use your version of this file * under either the MPL or the GPL." * * File-Search Functions */ function ext_search_items($dir) { // search for item if (empty($dir) && !empty($GLOBALS['__POST']["item"])) { $dir = $GLOBALS['__POST']["item"]; } if (isset($GLOBALS['__POST']["searchitem"])) { $searchitem = stripslashes($GLOBALS['__POST']["searchitem"]); $subdir = !empty($GLOBALS['__POST']["subdir"]); $content = $GLOBALS['__POST']["content"]; $list = make_list($dir, $searchitem, $subdir, $content); } else { $searchitem = NULL; $subdir = true; } if (empty($searchitem)) { show_searchform($dir); return; } // Results in JSON $items['totalCount'] = count($list); $result = get_result_array($list); $start = (int) $GLOBALS['__POST']["start"]; $limit = (int) $GLOBALS['__POST']["limit"]; if ($start < $items['totalCount'] && $limit < $items['totalCount']) { $result = array_splice($result, $start, $limit); } $items['items'] = $result; $json = new ext_Json(); while (@ob_end_clean()) { } echo $json->encode($items); }
<?php $limit_text = ""; if (!is_null($first_item_on_page) && !is_null($items_per_page)) { $limit_text = "LIMIT " . $first_item_on_page . ", " . $items_per_page; } $my_query = "SELECT * FROM songs ORDER BY rank DESC " . $limit_text; $result = $mysqli->query($my_query); $songs_list = get_result_array($result);
<?php $result = $mysqli->query("SELECT COUNT(id) AS 'row_count' FROM songs"); $result_arr = $result->fetch_assoc(); $total_items = $result_arr['row_count']; $item = 1; $total_pages = ceil($total_items / $item); $page_cur = isset($_GET['songRank']) ? $_GET['songRank'] : 1; if (empty($page_cur)) { $page_cur = 1; } $first_item_on_page = ($page_cur - 1) * $item; $limit_text = ""; if (!is_null($first_item_on_page) && !is_null($item)) { $limit_text = " LIMIT " . $first_item_on_page . ", " . $item; } $my_query = "SELECT * FROM songs WHERE rank = {$page_cur}"; $result = $mysqli->query($my_query); $songs_info = get_result_array($result); $todaySongs = (21 - $today) * (5 + 1);