1<?php 2/** 3 * This overwrites the DOKU_CONF. Each animal gets its own configuration and data directory. 4 */ 5 6function displayAndExit($r) { 7 $l = 'en'; 8 if($r != 'unknown') { 9 $farmconf = array(); 10 require_once(DOKU_FARM_PLUGIN.'animal.class.php'); 11 $a = new dokuwiki_farm_animal(DOKU_FARM_ANIMAL, null); 12 $conf = $a->getWikiConf(); 13 if(isset($conf['editable']['lang']) && !empty($conf['editable']['lang'])) $l = $conf['editable']['lang']; 14 if(isset($conf['protected']['lang']) && !empty($conf['protected']['lang'])) $l = $conf['protected']['lang']; 15 }else{ 16 $conf = array(); 17 include dirname(__FILE__).'/../conf/local.php'; 18 if(isset($conf['lang']) && !empty($conf['lang'])) $l = $conf['lang']; 19 } 20 $lang = array(); 21 @include DOKU_FARM_PLUGIN.'lang/en/lang.php'; 22 if($l != 'en') @include DOKU_FARM_PLUGIN.'lang/'.$l.'/lang.php'; 23 @include DOKU_FARM_PLUGIN.'customlang/en/lang.php'; 24 if($l != 'en') @include DOKU_FARM_PLUGIN.'customlang/'.$l.'/lang.php'; 25 26 $title = str_replace('%s', DOKU_FARM_ANIMAL, $lang['message_'.$r.'_title']); 27 $msg = str_replace('%s', DOKU_FARM_ANIMAL, $lang['message_'.$r.'_desc']); 28 29 echo '<html> 30 <head> 31 <title>'.$title.'</title> 32 </head> 33 <body> 34 <h3>'.$title.'</h3> 35 <p>'.$msg.'</p> 36 </body> 37</html>'; 38 exit(); 39} 40 41$cf = fullpath(dirname(__FILE__).'/../').'/lib/plugins/farm/config.php'; 42$vhf = fullpath(dirname(__FILE__).'/../').'/lib/plugins/farm/virtual_hosts.php'; 43 44if(@file_exists($cf)) { 45 $farmconf = array(); 46 include $cf; 47 48 $barn = $farmconf['farmfsroot'].$farmconf['barn']; 49 $plugin = $farmconf['farmfsroot'].$farmconf['farmer'].'lib/plugins/farm/'; 50 define('DOKU_FARM_PLUGIN', $plugin); 51 52 $animal = null; 53 if(isset($_REQUEST['virtual_animal']) && @file_exists($vhf)) { 54 $host = $_SERVER['HTTP_HOST']; 55 foreach(explode("\n", @file_get_contents($vhf)) as $l) { 56 if(preg_match('`^\s*([^\s]+)\s+([^\s#]+)`', $l, $m)) { 57 if($m[1] == $host) { 58 $animal = $m[2]; 59 define('DOKU_BASE', '/'); 60 define('DOKU_REL', '/'); 61 $p = isset($_SERVER['HTTPS']) ? ((!preg_match('`off`i', $_SERVER['HTTPS']) && $_SERVER['HTTPS']) ? 'https' : 'http') : 'http'; 62 define('DOKU_URL', $p.'://'.$m[1].'/'); 63 break; 64 } 65 } 66 } 67 } 68 69 if(!$animal) { 70 $animal = isset($_REQUEST['animal']) && !empty($_REQUEST['animal']) ? $_REQUEST['animal'] : null; 71 if(!preg_match('`^[a-z0-9\_\.\-]+$`i', $animal)) $animal = null; 72 } 73 74 if($animal) { 75 define('DOKU_FARM_ANIMAL', $animal); 76 if(!@is_dir($barn.$animal)) displayAndExit('unknown'); 77 78 $status = null; 79 $locked = null; 80 foreach(explode("\n", @file_get_contents($barn.$animal.'/animal.meta')) as $l) { 81 if(preg_match('`^\s*([^\s]+)\s+:\s+([^\s]+)`', $l, $m)) { 82 if($m[1] == 'status') $status = $m[2]; 83 if($m[1] == 'locked') $locked = ($m[2] != null && $m[2] != '0'); 84 } 85 } 86 if(!$status) $status = 'open'; 87 88 if($status != 'open') displayAndExit($status); 89 90 $isfarmer = false; 91 define('DOKU_CONF', $barn.$animal.'/conf/'); 92 $wr = $farmconf['farmwebroot']; 93 if(preg_match('`^([^:]+://)?([^/]+)?/?(.*)$`i', $wr, $m)) $wr = $m[3]; 94 $exp = !$farmconf['userewrite'] ? $farmconf['farmer'] : (!$farmconf['farmrewrite'] ? $farmconf['barn'] : '').$animal.'/'; 95 define('DOKU_ANIMAL_BASEDIR', $wr); 96 if(!defined('DOKU_BASE')) define('DOKU_BASE', '/'.$wr.$exp); 97 if(!defined('DOKU_REL')) define('DOKU_REL', DOKU_BASE); 98 if(!defined('DOKU_URL')) define('DOKU_URL', '/'.$farmconf['farmwebroot'].$exp); 99 }else{ 100 // no animal name passed, we are the farmer 101 $isfarmer = true; 102 define('DOKU_CONF', $farmconf['farmfsroot'].$farmconf['farmer'].'conf/'); 103 } 104 define('DOKU_IS_FARMER', $isfarmer); 105} 106 107$config_cascade = array( 108 'main' => array( 109 'default' => array(DOKU_INC.'conf/dokuwiki.php'), 110 'local' => array(DOKU_CONF.'local.php'), 111 'protected' => array(DOKU_CONF.'local.protected.php'), 112 ), 113 'acronyms' => array( 114 'default' => array(DOKU_INC.'conf/acronyms.conf'), 115 'local' => array(DOKU_CONF.'acronyms.local.conf'), 116 ), 117 'entities' => array( 118 'default' => array(DOKU_INC.'conf/entities.conf'), 119 'local' => array(DOKU_CONF.'entities.local.conf'), 120 ), 121 'interwiki' => array( 122 'default' => array(DOKU_INC.'conf/interwiki.conf'), 123 'local' => array(DOKU_CONF.'interwiki.local.conf'), 124 ), 125 'license' => array( 126 'default' => array(DOKU_INC.'conf/license.php'), 127 'local' => array(DOKU_CONF.'license.local.php'), 128 ), 129 'mediameta' => array( 130 'default' => array(DOKU_INC.'conf/mediameta.php'), 131 'local' => array(DOKU_CONF.'mediameta.local.php'), 132 ), 133 'mime' => array( 134 'default' => array(DOKU_INC.'conf/mime.conf'), 135 'local' => array(DOKU_CONF.'mime.local.conf'), 136 ), 137 'scheme' => array( 138 'default' => array(DOKU_INC.'conf/scheme.conf'), 139 'local' => array(DOKU_CONF.'scheme.local.conf'), 140 ), 141 'smileys' => array( 142 'default' => array(DOKU_INC.'conf/smileys.conf'), 143 'local' => array(DOKU_CONF.'smileys.local.conf'), 144 ), 145 'wordblock' => array( 146 'default' => array(DOKU_INC.'conf/wordblock.conf'), 147 'local' => array(DOKU_CONF.'wordblock.local.conf'), 148 ) 149); 150 151?> 152