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 9/** 10 * Just send a 1x1 pixel blank gif to the browser and exit 11 12 */ 13function sendGIF(){ 14 $img = base64_decode('R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7'); 15 header('Content-Type: image/gif'); 16 header('Content-Length: '.strlen($img)); 17 header('Connection: Close'); 18 print $img; 19 // Browser should drop connection after this 20 // Thinks it's got the whole image 21} 22 23// Make sure image is sent to the browser immediately 24ob_implicit_flush(TRUE); 25 26// keep running after browser closes connection 27@ignore_user_abort(true); 28 29sendGIF(); 30 31// Switch off implicit flush again - we don't want to send any more output 32ob_implicit_flush(FALSE); 33 34// Catch any possible output (e.g. errors) 35// - probably not needed but better safe... 36ob_start(); 37 38// Called to exit - we don't want any output going anywhere 39function indexer_stop() { 40 ob_end_clean(); 41 exit(); 42} 43 44// Now start work 45if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 46require_once(DOKU_INC.'inc/init.php'); 47//close session 48session_write_close(); 49 50 51$ID = cleanID($_REQUEST['id']); 52if(!$ID) indexer_stop(); 53 54// check if indexing needed 55$last = @filemtime(metaFN($ID,'.indexed')); 56if($last > @filemtime(wikiFN($ID))) indexer_stop(); 57 58// try to aquire a lock 59$lock = $conf['lockdir'].'/_indexer.lock'; 60while(!@mkdir($lock,0777)){ 61 if(time()-@filemtime($lock) > 60*5){ 62 // looks like a stale lock - remove it 63 @rmdir($lock); 64 }else{ 65 indexer_stop(); 66 } 67} 68 69require_once(DOKU_INC.'inc/indexer.php'); 70 71// do the work 72idx_addPage($ID); 73 74// we're finished 75io_saveFile(metaFN($ID,'.indexed'),''); 76@rmdir($lock); 77indexer_stop(); 78 79//Setup VIM: ex: et ts=4 enc=utf-8 : 80 81// No trailing PHP closing tag - no output please! 82// See Note at http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php 83