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 50require_once(DOKU_INC.'inc/indexer.php'); 51 52$ID = cleanID($_REQUEST['id']); 53if(!$ID) indexer_stop(); 54 55// check if indexing needed 56$last = @filemtime(metaFN($ID,'.indexed')); 57if($last > @filemtime(wikiFN($ID))) indexer_stop(); 58 59// try to aquire a lock 60$lock = $conf['lockdir'].'/_indexer.lock'; 61while(!@mkdir($lock,0777)){ 62 if(time()-@filemtime($lock) > 60*5){ 63 // looks like a stale lock - remove it 64 @rmdir($lock); 65 }else{ 66 indexer_stop(); 67 } 68} 69 70// do the work 71idx_addPage($ID); 72 73// we're finished 74io_saveFile(metaFN($ID,'.indexed'),' '); 75@rmdir($lock); 76indexer_stop(); 77 78//Setup VIM: ex: et ts=4 enc=utf-8 : 79 80// No trailing PHP closing tag - no output please! 81// See Note at http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php 82