limit = 24;
$search->page = @$_GET['page'];
$searchResult = $search->getResult($_GET['text']);
?>
Библиотека Javascript. SE@RCHER
SE@RCHER :::: Библиотека JAVASCRIPT
1997-2005 г.г.
SE@RCHER :::: Библиотека JAVASCRIPT
1997-2005 г.г.
SE@RCHER :::: Библиотека JAVASCRIPT
1997-2005 г.г.
другие разделы:
Блок
Календарь
Обрамление
Скрипт
Форма
Видео
Калькулятор
Окно
Статус
Фото
Время
Кнопка
|
Фон
Таблица
Фотогалерея
Линк
Подсказка
Текст
Тег
Звук
Стиль
Титул
Редирект
Меню
IFRAME
|
getNumPages()>1):?>
getNumPages(); $i++):?>
page):?>
- =$i+1?> - =$i+1?>
getNumPages()>1):?>
getNumPages(); $i++):?>
page):?>
- =$i+1?> - =$i+1?>
class SimpleSearch {
var $records = array();
var $page;
var $limit;
var $numPages;
function SimpleSearch($filepath) {
$records = file($filepath);
for ($i=0; $irecords[$i] = explode(' ### ', $records[$i]);
$this->records[$i][1] = strtolower(trim($this->records[$i][1]));
}
}
function getResult(&$text) {
$result = array();
$text = strtolower(trim($text));
$words = preg_split('~[^-а-яa-z0-9]+~', $text);
foreach ($words as $k => $v) if (strlen($v)<2) unset($words[$k]);
sort($words);
$text = implode(' ', $words);
if (strlen($text))
for ($i=0; $irecords); $i++)
for ($j=0; $jrecords[$i][1], $words[$j])) {
$result[] = $this->records[$i]; break;
}
usort($result, array($this, 'cmp'));
if ($this->limit) {
$this->page = abs((int)$this->page);
if ($this->page<1 || ($this->page-1)*$this->limit > sizeof($result)-1) $this->page = 1;
$this->numPages = ceil(sizeof($result)/$this->limit);
$result = array_slice($result, ($this->page-1)*$this->limit, $this->limit);
}
return $result;
}
function getNumPages() {
return $this->numPages;
}
function cmp($a, $b) {
return strcasecmp($a[1], $b[1]);
}
}
?>