This repository has been archived by the owner on Feb 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
reindex_file.php
61 lines (53 loc) · 2.04 KB
/
reindex_file.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @package tikiwiki
*/
// (c) Copyright 2002-2016 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
// This script will send a 1x1 transparent gif image, close connection and reindex the file corresponding to the id url argument
// The goal is to process reindexation in a background job for which the user won't have to wait
//
// This trick has been found on the official php manual page comments of the register_shutdown_function function
require_once('tiki-setup.php');
// Reindex the file for search
if (($id = (int)$_GET['id']) > 0) {
// Check feature
if ($prefs['feature_file_galleries'] == 'y'
&& $prefs['feature_search'] == 'y'
&& $prefs['feature_search_fulltext'] != 'y'
&& $prefs['search_refresh_index_mode'] == 'normal'
&& $prefs['fgal_asynchronous_indexing'] == 'y'
) {
$filegallib = TikiLib::lib('filegal');
require_once('lib/search/refresh-functions.php');
$info = $filegallib->get_file_info($id);
if ($info['galleryId'] > 0) {
$gal_info = $filegallib->get_file_gallery($info['galleryId']);
// Check perms
$tikilib->get_perm_object($info['galleryId'], 'file gallery', $gal_info, true);
if ($tiki_p_admin_file_galleries == 'y'
|| ( ( empty($fileInfo['lockedby']) || $fileInfo['lockedby'] == $user ) && $tiki_p_edit_gallery_file == 'y' )
) { // must be the owner or the locker or have the perms
error_reporting(0);
ignore_user_abort(true);
session_write_close(); // close the session to allow the user to continue browsing
register_shutdown_function('refresh_index', 'files', $id);
}
}
}
}
// Display the 1x1 transparent gif image
header('Cache-Control: no-cache');
header('Content-type: image/gif');
header('Content-length: 85');
print base64_decode(
'R0lGODlhAQABALMAAAAAAIAAAACAA' .
'ICAAAAAgIAAgACAgMDAwICAgP8AAA' .
'D/AP//AAAA//8A/wD//wBiZCH5BAE' .
'AAA8ALAAAAAABAAEAAAQC8EUAOw=='
);
flush();
exit;