1<?php 2/** 3 * DokuWiki indexer 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10require_once(DOKU_INC.'inc/init.php'); 11require_once(DOKU_INC.'inc/indexer.php'); 12//close session 13session_write_close(); 14 15 16$ID = cleanID($_REQUEST['id']); 17if(!$ID) sendGIF(); 18 19// check if indexing needed 20$last = @filemtime(metaFN($ID,'.indexed')); 21if($last > @filemtime(wikiFN($ID))) sendGIF(); 22 23// keep running 24@ignore_user_abort(true); 25 26// try to aquire a lock 27$lock = $conf['lockdir'].'/_indexer.lock'; 28while(!@mkdir($lock)){ 29 if(time()-@filemtime($lock) > 60*5){ 30 // looks like a stale lock - remove it 31 @rmdir($lock); 32 }else{ 33 sendGIF(); 34 } 35} 36 37// do the work 38idx_addPage($ID); 39 40// we're finished 41io_saveFile(metaFN($ID,'.indexed'),''); 42@rmdir($lock); 43sendGIF(); 44 45/** 46 * Just send a 1x1 pixel blank gif to the browser and exit 47 */ 48function sendGIF(){ 49 header('Content-Type: image/gif'); 50 print base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7'); 51 exit; 52} 53 54//Setup VIM: ex: et ts=4 enc=utf-8 : 55?> 56