1<?php 2/** 3 * DokuWiki mainscript 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9 define('DOKUWIKIVERSION','2005-01-17'); 10 11 ini_set('short_open_tag',"1"); 12 require_once("conf/dokuwiki.php"); 13 require_once("inc/common.php"); 14 require_once("inc/html.php"); 15 require_once("inc/parser.php"); 16 require_once("lang/en/lang.php"); 17 require_once("lang/".$conf['lang']."/lang.php"); 18 require_once("inc/auth.php"); 19 20 //import variables 21 $QUERY = trim($_REQUEST['id']); 22 $ID = cleanID($_REQUEST['id']); 23 $REV = $_REQUEST['rev']; 24 $ACT = $_REQUEST['do']; 25 $IDX = $_REQUEST['idx']; 26 $DATE = $_REQUEST['date']; 27 $RANGE = $_REQUEST['lines']; 28 $HIGH = $_REQUEST['s']; 29 if(empty($HIGH)) $HIGH = getGoogleQuery(); 30 31 $TEXT = cleanText($_POST['wikitext']); 32 $PRE = cleanText($_POST['prefix']); 33 $SUF = cleanText($_POST['suffix']); 34 $SUM = $_REQUEST['summary']; 35 36 //we accept the do param as HTTP header, too: 37 if(!empty($_SERVER['HTTP_X_DOKUWIKI_DO'])){ 38 $ACT = trim(strtolower($_SERVER['HTTP_X_DOKUWIKI_DO'])); 39 } 40 41 if(!empty($IDX)) $ACT='index'; 42 //set defaults 43 if(empty($ID)) $ID = $conf['start']; 44 if(empty($ACT)) $ACT = 'show'; 45 46 header('Content-Type: text/html; charset='.$lang['encoding']); 47 48 if($ACT == 'debug'){ 49 html_debug(); 50 exit; 51 } 52 53 //already logged in? 54 if($_SERVER['REMOTE_USER'] && $ACT=='login') $ACT='show'; 55 //handle logout 56 if($ACT=='logout'){ 57 auth_logoff(); 58 $ACT='login'; 59 } 60 61 //handle register 62 if($ACT=='register' && register()){ 63 $ACT='login'; 64 } 65 66 //do saving after spam- and conflictcheck 67 if($ACT == $lang['btn_save'] && auth_quickaclcheck($ID)){ 68 if(checkwordblock()){ 69 //spam detected 70 $ACT = 'wordblock'; 71 }elseif($DATE != 0 && @filemtime(wikiFN($ID)) > $DATE ){ 72 //newer version available -> ask what to do 73 $ACT = 'conflict'; 74 }else{ 75 //save it 76 saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM); //use pretty mode for con 77 //unlock it 78 unlock($id); 79 //show it 80 header("Location: ".wl($ID, '','doku.php',true)); 81 exit(); 82 } 83 } 84 85 //make infos about current page available 86 $INFO = pageinfo(); 87 88 //Editing: check if locked by anyone - if not lock for my self 89 if(($ACT == 'edit' || $ACT == $lang['btn_preview']) && $INFO['editable']){ 90 $lockedby = checklock($ID); 91 if($lockedby){ 92 $ACT = 'locked'; 93 }else{ 94 lock($ID); 95 } 96 }else{ 97 //try to unlock 98 unlock($ID); 99 } 100 101 102 //display some infos 103 if($ACT == 'check'){ 104 check(); 105 $ACT = 'show'; 106 } 107 108 //check which permission is needed 109 if(in_array($ACT,array('preview','wordblock','conflict','lockedby'))){ 110 if($INFO['exists']){ 111 $permneed = AUTH_EDIT; 112 }else{ 113 $permneed = AUTH_CREATE; 114 } 115 }elseif(in_array($ACT,array('revisions','show','edit'))){ 116 $permneed = AUTH_READ; 117 }else{ 118 $permneed = AUTH_NONE; 119 } 120 121 //start output 122 if(substr($ACT,0,6) != 'export') html_header(); 123 if(html_acl($permneed)){ 124 if($ACT == 'edit'){ 125 html_edit(); 126 }elseif($ACT == $lang['btn_preview']){ 127 html_edit($TEXT); 128 html_show($TEXT); 129 }elseif($ACT == 'wordblock'){ 130 html_edit($TEXT,'wordblock'); 131 }elseif($ACT == 'search' && !empty($QUERY)){ 132 html_search(); 133 }elseif($ACT == 'revisions'){ 134 html_revisions(); 135 }elseif($ACT == 'diff'){ 136 html_diff(); 137 }elseif($ACT == 'recent'){ 138 html_recent(); 139 }elseif($ACT == 'index'){ 140 html_index($IDX); 141 }elseif($ACT == 'backlink'){ 142 html_backlinks(); 143 }elseif($ACT == 'conflict'){ 144 html_conflict(con($PRE,$TEXT,$SUF),$SUM); 145 html_diff(con($PRE,$TEXT,$SUF),false); 146 }elseif($ACT == 'locked'){ 147 html_locked($lockedby); 148 }elseif($ACT == 'login'){ 149 html_login(); 150 }elseif($ACT == 'register' && $conf['openregister']){ 151 html_register(); 152 }elseif($ACT == 'export_html'){ 153 html_head(); 154 print "<body>\n"; 155 print parsedWiki($ID,$REV,false); 156 print "</body>\n</html>\n"; 157 }elseif($ACT == 'export_raw'){ 158 header("Content-Type: text/plain"); 159 print rawWiki($ID,$REV); 160 }else{ 161 $ACT='show'; 162 html_show(); 163 } 164 } 165 if(substr($ACT,0,6) != 'export') html_footer(); 166 167?> 168