
Apšylantis

Reputacija:
0
Pranešimai: 71
Įstojo: 2007-05-11
|
va mano search.php failas atsidares ji nzn ka trynt.
Code
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: search.php
| Author: Robert Gaudyn (Wooya)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once \"maincore.php\";
require_once THEMES.\"templates/header.php\";
include LOCALE.LOCALESET.\"search.php\";
add_to_title($locale['global_202']);
if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
if (isset($_GET['stext'])) {
if (is_array($_GET['stext'])) {
redirect(FUSION_SELF);
} else {
$_GET['stext'] = urlencode(stripinput($_GET['stext']));
}
} else {
$_GET['stext'] = \"\";
}
if (isset($_GET['method'])) { $_GET['method'] = ($_GET['method']==\"OR\" || $_GET['method']==\"AND\") ? $_GET['method'] : \"OR\"; }
if (!isset($_GET['method'])) { $_GET['method'] = \"OR\"; }
if (isset($_GET['datelimit'])) { $_GET['datelimit'] = isnum($_GET['datelimit']) ? $_GET['datelimit'] : 0; }
if (!isset($_GET['datelimit'])) { $_GET['datelimit'] = 0; }
if (isset($_GET['fields'])) { $_GET['fields'] = isnum($_GET['fields']) ? $_GET['fields'] : 2; }
if (!isset($_GET['fields'])) { $_GET['fields'] = 2; }
if (isset($_GET['sort'])) { $_GET['sort'] = in_array($_GET['sort'], array(\"datestamp\", \"subject\", \"author\")) ? $_GET['sort'] : \"datestamp\"; }
if (!isset($_GET['sort'])) { $_GET['sort'] = \"datestamp\"; }
if (isset($_GET['order'])) { $_GET['order'] = isnum($_GET['order']) ? $_GET['order'] : 0; }
if (!isset($_GET['order'])) { $_GET['order'] = 0; }
if (isset($_GET['chars'])) { $_GET['chars'] = isnum($_GET['chars']) ? ($_GET['chars'] > 200 ? 200 : $_GET['chars']) : 50; }
if (!isset($_GET['chars'])) { $_GET['chars'] = 50; }
if (isset($_GET['forum_id'])) { $_GET['forum_id'] = isnum($_GET['forum_id']) ? $_GET['forum_id'] : 0; }
if (!isset($_GET['forum_id'])) { $_GET['forum_id'] = 0; }
$radio_button = array();
$form_elements = array();
$available = array();
$dh = opendir(INCLUDES.\"search\");
while (false !== ($entry = readdir($dh))) {
if ($entry != \".\" && $entry != \"..\" && eregi(\"include_button.php\", $entry)) {
$available[] = str_replace(\"search_\", \"\", str_replace(\"_include_button.php\", \"\", $entry));
}
}
closedir($dh);
$available[] = \"all\";
if (isset($_GET['stype'])) { $_GET['stype'] = in_array($_GET['stype'], $available) ? $_GET['stype'] : \"articles\"; }
if (!isset($_GET['stype'])) { $_GET['stype'] = $settings['default_search']; }
for ($i = 0; $i < count($available) - 1; $i++) {
include (INCLUDES.\"search/search_\".$available[$i].\"_include_button.php\");
}
sort($radio_button);
opentable($locale['400']);
echo \"\n\";
echo \"\n\";
closetable();
function search_striphtmlbbcodes($text) {
$text = preg_replace(\"[\[(.*?)\]]\", \"\", $text);
$text = preg_replace(\"<\<(.*?)\>>\", \"\", $text);
return $text;
}
function search_textfrag($text) {
if ($_GET['chars'] != 0) {
$text = nl2br(stripslashes(substr($text, 0, $_GET['chars']).\"...\"));
} else {
$text = nl2br(stripslashes($text));
}
return $text;
}
function search_stringscount($text) {
global $swords;
$count = 0;
for ($i = 0; $i < sizeof($swords); $i++) {
$count += substr_count(strtolower($text), strtolower($swords[$i]));
}
return $count;
}
function search_querylike($field) {
global $swords;
$querylike = \"\";
for ($i = 0; $i < sizeof($swords); $i++) {
$querylike .= $field.\" LIKE '%\".$swords[$i].\"%'\".($i < sizeof($swords) - 1 ? \" \".$_GET['method'].\" \" : \"\");
}
return $querylike;
}
function search_fieldsvar() {
$fieldsvar = \"(\";
$numargs = func_num_args();
for ($i = 0; $i < $numargs; $i++) {
$fieldsvar .= func_get_arg($i).($i < $numargs - 1 ? \" || \" : \"\");
}
$fieldsvar .= \")\";
return $fieldsvar;
}
function search_globalarray($search_result) {
global $search_result_array, $global_string_count, $memory_limit;
$global_string_count += strlen($search_result);
if ($memory_limit > $global_string_count) {
$search_result_array[] = $search_result;
$memory_exhaused = false;
} else {
$memory_exhaused = true;
}
return $memory_exhaused;
}
function search_navigation($rows) {
global $site_search_count, $composevars;
$site_search_count += $rows;
$navigation_result = \"\n\".makePageNav($_GET['rowstart'], 10, ($site_search_count > 100 || search_globalarray(\"\") ? 100 : $site_search_count), 3, FUSION_SELF.\"?stype=\".$_GET['stype'].\"&stext=\".urlencode($_GET['stext']).\"&\".$composevars).\"\n \n\";
return $navigation_result;
}
$composevars = \"method=\".$_GET['method'].\"&datelimit=\".$_GET['datelimit'].\"&fields=\".$_GET['fields'].\"&sort=\".$_GET['sort'].\"&order=\".$_GET['order'].\"&chars=\".$_GET['chars'].\"&forum_id=\".$_GET['forum_id'].\"&\";
$memory_limit = str_replace(\"m\", \"\", strtolower(ini_get(\"memory_limit\"))) * 1024 * 1024;
$memory_limit = !isnum($memory_limit) ? 8 * 1024 * 1024 : $memory_limit < 8 * 1024 * 1024 ? 8 * 1024 * 1024 : $memory_limit;
$memory_limit = $memory_limit - ceil($memory_limit / 4);
$global_string_count = 0;
$site_search_count = 0;
$search_result_array = array();
$navigation_result = \"\";
$items_count = \"\";
$_GET['stext'] = urldecode($_GET['stext']);
if ($_GET['stext'] != \"\" && strlen($_GET['stext']) >= 3) {
add_to_title($locale['global_201'].$locale['408']);
opentable($locale['408']);
$fswords = explode(\" \", $_GET['stext']);
$swords = array();
$iwords = array();
for ($i = 0; $i < sizeof($fswords); $i++) {
if (strlen($fswords[$i]) >= 3) {
$swords[] = $fswords[$i];
} else {
$iwords[] = $fswords[$i];
}
}
unset($fswords);
if (sizeof($swords) == 0) { redirect(FUSION_SELF); }
if ($_GET['stype'] == \"all\") {
$dh = opendir(INCLUDES.\"search\");
while (false !== ($entry=readdir($dh))) {
if ($entry != \".\" && $entry != \"..\" && eregi(\"include.php\", $entry)) {
include (INCLUDES.\"search/\".$entry);
}
}
closedir($dh);
} else {
include INCLUDES.\"search/search_\".$_GET['stype'].\"_include.php\";
}
if (count($iwords)) {
$txt = \"\";
for ($i = 0; $i < count($iwords); $i++) {
$txt .= $iwords[$i].($i < count($iwords) - 1 ? \", \" : \"\");
}
echo \"\".sprintf($locale['502'], $txt).\" \";
}
if ($_GET['stype'] == \"all\") {
$navigation_result = search_navigation(0);
echo \"\".$items_count.\" \".THEME_BULLET.\" \".(($site_search_count>100 || search_globalarray(\"\"))?sprintf($locale['530'], $site_search_count):$site_search_count.\" \".$locale['510']).\" \";
} else {
echo $items_count.\" \";
echo (($site_search_count>100 || search_globalarray(\"\")) ? \"\".sprintf($locale['530'], $site_search_count).\" \" : \"\");
}
if ($_GET['stype'] == \"all\") {
$from = $_GET['rowstart'];
$to = (count($search_result_array) - ($_GET['rowstart'] + 10)) <= 0 ? count($search_result_array) : $_GET['rowstart'] + 10;
} else {
$from = 0;
$to = count($search_result_array) < 10 ? count($search_result_array) : 10;
}
for ($i = $from; $i < $to; $i++) {
echo $search_result_array[$i];
}
echo $navigation_result;
closetable();
} elseif (isset($_GET['stext'])) {
add_to_title($locale['global_201'].$locale['408']);
opentable($locale['408']);
echo $locale['501'];
closetable();
}
require_once THEMES.\"templates/footer.php\";
?>
|