https://reisub.nsupdate.info/git
/
friendica.git
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use correct entry list in Module\Directory
[friendica.git/.git]
/
mod
/
search.php
diff --git
a/mod/search.php
b/mod/search.php
index
2810b23
..
4144e26
100644
(file)
--- a/
mod/search.php
+++ b/
mod/search.php
@@
-4,7
+4,6
@@
*/
use Friendica\App;
*/
use Friendica\App;
-use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
@@
-13,18
+12,15
@@
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
-use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Database\DBA;
use Friendica\Model\Item;
+use Friendica\Module\BaseSearchModule;
use Friendica\Util\Strings;
use Friendica\Util\Strings;
-require_once 'include/conversation.php';
-require_once 'mod/dirfind.php';
-
function search_saved_searches() {
$o = '';
function search_saved_searches() {
$o = '';
- $search = (
(x($_GET,'search')
) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
+ $search = (
!empty($_GET['search']
) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
intval(local_user())
$r = q("SELECT `id`,`term` FROM `search` WHERE `uid` = %d",
intval(local_user())
@@
-60,10
+56,10
@@
function search_saved_searches() {
function search_init(App $a) {
function search_init(App $a) {
- $search = (
(x($_GET,'search')
) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
+ $search = (
!empty($_GET['search']
) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
if (local_user()) {
if (local_user()) {
- if (
x($_GET,'save'
) && $search) {
+ if (
!empty($_GET['save']
) && $search) {
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
DBA::escape($search)
$r = q("SELECT * FROM `search` WHERE `uid` = %d AND `term` = '%s' LIMIT 1",
intval(local_user()),
DBA::escape($search)
@@
-72,7
+68,7
@@
function search_init(App $a) {
DBA::insert('search', ['uid' => local_user(), 'term' => $search]);
}
}
DBA::insert('search', ['uid' => local_user(), 'term' => $search]);
}
}
- if (
x($_GET,'remove'
) && $search) {
+ if (
!empty($_GET['remove']
) && $search) {
DBA::delete('search', ['uid' => local_user(), 'term' => $search]);
}
DBA::delete('search', ['uid' => local_user(), 'term' => $search]);
}
@@
-92,14
+88,6
@@
function search_init(App $a) {
}
}
-
-
-function search_post(App $a) {
- if (x($_POST,'search'))
- $a->data['search'] = $_POST['search'];
-}
-
-
function search_content(App $a) {
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
function search_content(App $a) {
if (Config::get('system','block_public') && !local_user() && !remote_user()) {
@@
-108,12
+96,9
@@
function search_content(App $a) {
}
if (Config::get('system','local_search') && !local_user() && !remote_user()) {
}
if (Config::get('system','local_search') && !local_user() && !remote_user()) {
- System::httpExit(403,
- ["title" => L10n::t("Public access denied."),
- "description" => L10n::t("Only logged in users are permitted to perform a search.")]);
- killme();
- //notice(L10n::t('Public access denied.').EOL);
- //return;
+ $e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a search."));
+ $e->httpdesc = L10n::t("Public access denied.");
+ throw $e;
}
if (Config::get('system','permit_crawling') && !local_user() && !remote_user()) {
}
if (Config::get('system','permit_crawling') && !local_user() && !remote_user()) {
@@
-133,10
+118,7
@@
function search_content(App $a) {
if (!is_null($result)) {
$resultdata = json_decode($result);
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
if (!is_null($result)) {
$resultdata = json_decode($result);
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
- System::httpExit(429,
- ["title" => L10n::t("Too Many Requests"),
- "description" => L10n::t("Only one search per minute is permitted for not logged in users.")]);
- killme();
+ throw new \Friendica\Network\HTTPException\TooManyRequestsException(L10n::t("Only one search per minute is permitted for not logged in users."));
}
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), Cache::HOUR);
} else
}
Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), Cache::HOUR);
} else
@@
-145,16
+127,12
@@
function search_content(App $a) {
Nav::setSelected('search');
Nav::setSelected('search');
- $search = '';
- if (x($a->data,'search'))
- $search = Strings::escapeTags(trim($a->data['search']));
- else
- $search = ((x($_GET,'search')) ? Strings::escapeTags(trim(rawurldecode($_GET['search']))) : '');
+ $search = (!empty($_REQUEST['search']) ? Strings::escapeTags(trim(rawurldecode($_REQUEST['search']))) : '');
$tag = false;
$tag = false;
- if (
x($_GET,'tag'
)) {
+ if (
!empty($_GET['tag']
)) {
$tag = true;
$tag = true;
- $search = (
x($_GET,'tag'
) ? '#' . Strings::escapeTags(trim(rawurldecode($_GET['tag']))) : '');
+ $search = (
!empty($_GET['tag']
) ? '#' . Strings::escapeTags(trim(rawurldecode($_GET['tag']))) : '');
}
// contruct a wrapper for the search header
}
// contruct a wrapper for the search header
@@
-170,13
+148,13
@@
function search_content(App $a) {
$search = substr($search,1);
}
if (strpos($search,'@') === 0) {
$search = substr($search,1);
}
if (strpos($search,'@') === 0) {
- return
dirfind_content($a
);
+ return
BaseSearchModule::performSearch(
);
}
if (strpos($search,'!') === 0) {
}
if (strpos($search,'!') === 0) {
- return
dirfind_content($a
);
+ return
BaseSearchModule::performSearch(
);
}
}
- if (
x($_GET,'search-option'
))
+ if (
!empty($_GET['search-option']
))
switch($_GET['search-option']) {
case 'fulltext':
break;
switch($_GET['search-option']) {
case 'fulltext':
break;
@@
-184,11
+162,9
@@
function search_content(App $a) {
$tag = true;
break;
case 'contacts':
$tag = true;
break;
case 'contacts':
- return dirfind_content($a, "@");
- break;
+ return BaseSearchModule::performSearch('@');
case 'forums':
case 'forums':
- return dirfind_content($a, "!");
- break;
+ return BaseSearchModule::performSearch('!');
}
if (!$search)
}
if (!$search)