15cfb8815Schris<?php 25cfb8815Schris/** 35cfb8815Schris * Dokuwiki installation assistance 45cfb8815Schris * 55cfb8815Schris * @author Chris Smith <chris@jalakai.co.uk> 65cfb8815Schris */ 75cfb8815Schris 85cfb8815Schrisif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/'); 95cfb8815Schrisif(!defined('DOKU_CONF')) define('DOKU_CONF',DOKU_INC.'conf/'); 105cfb8815Schrisif(!defined('DOKU_LOCAL')) define('DOKU_LOCAL',DOKU_INC.'conf/'); 115cfb8815Schris 12*47248316SAndreas Gohr// kill magic quotes 13*47248316SAndreas Gohrif (get_magic_quotes_gpc() && !defined('MAGIC_QUOTES_STRIPPED')) { 14*47248316SAndreas Gohr if (!empty($_GET)) remove_magic_quotes($_GET); 15*47248316SAndreas Gohr if (!empty($_POST)) remove_magic_quotes($_POST); 16*47248316SAndreas Gohr if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE); 17*47248316SAndreas Gohr if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST); 18*47248316SAndreas Gohr @ini_set('magic_quotes_gpc', 0); 19*47248316SAndreas Gohr define('MAGIC_QUOTES_STRIPPED',1); 20*47248316SAndreas Gohr} 21*47248316SAndreas Gohr@set_magic_quotes_runtime(0); 22*47248316SAndreas Gohr@ini_set('magic_quotes_sybase',0); 235cfb8815Schris 24*47248316SAndreas Gohr// language strings 25*47248316SAndreas Gohrrequire_once(DOKU_INC.'inc/lang/en/lang.php'); 26*47248316SAndreas Gohr$LC = preg_replace('/[^a-z\-]+/','',$_REQUEST['l']); 27*47248316SAndreas Gohrif(!$LC) $LC = 'en'; 28*47248316SAndreas Gohrif($LC && $LC != 'en' ) { 29*47248316SAndreas Gohr require_once(DOKU_INC.'inc/lang/'.$LC.'/lang.php'); 30*47248316SAndreas Gohr} 31*47248316SAndreas Gohr 32*47248316SAndreas Gohr// initialise variables ... 33*47248316SAndreas Gohr$error = array(); 34*47248316SAndreas Gohr 35*47248316SAndreas Gohr$dokuwiki_hash = array( 36*47248316SAndreas Gohr '2005-09-22' => 'e33223e957b0b0a130d0520db08f8fb7', 37*47248316SAndreas Gohr '2006-03-05' => '51295727f79ab9af309a2fd9e0b61acc', 38*47248316SAndreas Gohr '2006-03-09' => '51295727f79ab9af309a2fd9e0b61acc', 39*47248316SAndreas Gohr 'devel' => '732131839d559198b985e183eefe9a63', 40*47248316SAndreas Gohr); 41*47248316SAndreas Gohr 42*47248316SAndreas Gohr 43*47248316SAndreas Gohr 44*47248316SAndreas Gohr// begin output 45*47248316SAndreas Gohrheader('Content-Type: text/html; charset=utf-8'); 46*47248316SAndreas Gohr?> 47*47248316SAndreas Gohr<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 48*47248316SAndreas Gohr "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 49*47248316SAndreas Gohr<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $LC?>" 50*47248316SAndreas Gohr lang="<?php echo $LC?>" dir="<?php echo $lang['direction']?>"> 51*47248316SAndreas Gohr<head> 52*47248316SAndreas Gohr <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 53*47248316SAndreas Gohr <title>DokuWiki Installer</title> 54*47248316SAndreas Gohr <style type="text/css"> 55*47248316SAndreas Gohr body { width: 90%; margin: 0 auto; font: 84% Verdana, Helvetica, Arial, sans-serif; } 56*47248316SAndreas Gohr img { border: none } 57*47248316SAndreas Gohr br.cl { clear:both; } 58*47248316SAndreas Gohr code { font-size: 110%; color: #008000; } 59*47248316SAndreas Gohr fieldset { border: none } 60*47248316SAndreas Gohr label { display: block;} 61*47248316SAndreas Gohr input.text { width: 30em; margin: 0 0.5em; } 62*47248316SAndreas Gohr </style> 63*47248316SAndreas Gohr <script type="text/javascript" language="javascript"> 64*47248316SAndreas Gohr function acltoggle(){ 65*47248316SAndreas Gohr var cb = document.getElementById('acl'); 66*47248316SAndreas Gohr var fs = document.getElementById('acldep'); 67*47248316SAndreas Gohr if(!cb || !fs) return; 68*47248316SAndreas Gohr if(cb.checked){ 69*47248316SAndreas Gohr fs.style.display = ''; 70*47248316SAndreas Gohr }else{ 71*47248316SAndreas Gohr fs.style.display = 'none'; 72*47248316SAndreas Gohr } 73*47248316SAndreas Gohr } 74*47248316SAndreas Gohr window.onload = function(){ 75*47248316SAndreas Gohr acltoggle(); 76*47248316SAndreas Gohr var cb = document.getElementById('acl'); 77*47248316SAndreas Gohr if(cb) cb.onchange = acltoggle; 78*47248316SAndreas Gohr }; 79*47248316SAndreas Gohr </script> 80*47248316SAndreas Gohr</head> 81*47248316SAndreas Gohr<body style=""> 82*47248316SAndreas Gohr <h1 style="float:left"> 83*47248316SAndreas Gohr <img src="http://wiki.splitbrain.org/_media/wiki:dokuwiki-64.png" 84*47248316SAndreas Gohr style="vertical-align: middle;" alt="" /> 85*47248316SAndreas Gohr <?php echo $lang['i_installer']?> 86*47248316SAndreas Gohr </h1> 87*47248316SAndreas Gohr <div style="float:right; margin: 1em;"> 88*47248316SAndreas Gohr <?php langsel()?> 89*47248316SAndreas Gohr </div> 90*47248316SAndreas Gohr <br class="cl" /> 91*47248316SAndreas Gohr 92*47248316SAndreas Gohr <div style="float: right; width: 34%;"> 93*47248316SAndreas Gohr <?php 94*47248316SAndreas Gohr if(@file_exists(DOKU_INC.'inc/lang/'.$LC.'/install.html')){ 95*47248316SAndreas Gohr include(DOKU_INC.'inc/lang/'.$LC.'/install.html'); 96*47248316SAndreas Gohr }else{ 97*47248316SAndreas Gohr include(DOKU_INC.'inc/lang/en/install.html'); 98*47248316SAndreas Gohr } 99*47248316SAndreas Gohr ?> 100*47248316SAndreas Gohr </div> 101*47248316SAndreas Gohr 102*47248316SAndreas Gohr <div style="float: left; width: 58%;"> 103*47248316SAndreas Gohr <?php 104*47248316SAndreas Gohr if(! (check_functions() && check_permissions()) ){ 105*47248316SAndreas Gohr echo '<p>'.$lang['i_problems'].'</p>'; 106*47248316SAndreas Gohr print_errors(); 107*47248316SAndreas Gohr }elseif(!check_configs()){ 108*47248316SAndreas Gohr echo '<p>'.$lang['i_modified'].'</p>'; 109*47248316SAndreas Gohr print_errors(); 110*47248316SAndreas Gohr }elseif($_REQUEST['submit']){ 111*47248316SAndreas Gohr if(!check_data($_REQUEST['d'])){ 112*47248316SAndreas Gohr print_errors(); 113*47248316SAndreas Gohr print_form($_REQUEST['d']); 114*47248316SAndreas Gohr }elseif(!store_data($_REQUEST['d'])){ 115*47248316SAndreas Gohr echo '<p>'.$lang['i_failure'].'</p>'; 116*47248316SAndreas Gohr print_errors(); 117*47248316SAndreas Gohr }else{ 118*47248316SAndreas Gohr echo '<p>'.$lang['i_success'].'</p>'; 119*47248316SAndreas Gohr } 120*47248316SAndreas Gohr }else{ 121*47248316SAndreas Gohr print_form($_REQUEST['d']); 122*47248316SAndreas Gohr } 123*47248316SAndreas Gohr ?> 124*47248316SAndreas Gohr </div> 125*47248316SAndreas Gohr 126*47248316SAndreas Gohr<div style="clear: both"> 127*47248316SAndreas Gohr <a href="http://wiki.splitbrain.org/wiki:dokuwiki"><img src="lib/tpl/default/images/button-dw.png" alt="driven by DokuWiki" /></a> 128*47248316SAndreas Gohr <a href="http://www.php.net"><img src="lib/tpl/default/images/button-php.gif" alt="powered by PHP" /></a> 129*47248316SAndreas Gohr</div> 130*47248316SAndreas Gohr</body> 131*47248316SAndreas Gohr</html> 132*47248316SAndreas Gohr<?php 133*47248316SAndreas Gohr 134*47248316SAndreas Gohr/** 135*47248316SAndreas Gohr * Print the input form 136*47248316SAndreas Gohr */ 137*47248316SAndreas Gohrfunction print_form($d){ 138*47248316SAndreas Gohr global $lang; 139*47248316SAndreas Gohr global $LC; 140*47248316SAndreas Gohr 141*47248316SAndreas Gohr if(!is_array($d)) $d = array(); 142*47248316SAndreas Gohr $d = array_map('htmlspecialchars',$d); 143*47248316SAndreas Gohr 144*47248316SAndreas Gohr if(!isset($d['acl'])) $d['acl']=1; 145*47248316SAndreas Gohr 146*47248316SAndreas Gohr ?> 147*47248316SAndreas Gohr <form action="" method="post"> 148*47248316SAndreas Gohr <input type="hidden" name="l" value="<?php echo $LC ?>" /> 149*47248316SAndreas Gohr <fieldset> 150*47248316SAndreas Gohr <label for="title"><?php echo $lang['i_wikiname']?> 151*47248316SAndreas Gohr <input type="text" name="d[title]" id="title" value="<?php echo $d['title'] ?>" style="width: 20em;" /> 152*47248316SAndreas Gohr </label> 153*47248316SAndreas Gohr 154*47248316SAndreas Gohr <fieldset style="margin-top: 1em;"> 155*47248316SAndreas Gohr <label for="acl"> 156*47248316SAndreas Gohr <input type="checkbox" name="d[acl]" id="acl" <?php echo(($d['acl'] ? 'checked="checked"' : ''));?> /> 157*47248316SAndreas Gohr <?php echo $lang['i_enableacl']?></label> 158*47248316SAndreas Gohr 159*47248316SAndreas Gohr <fieldset id="acldep"> 160*47248316SAndreas Gohr <label for="superuser"><?php echo $lang['i_superuser']?></label> 161*47248316SAndreas Gohr <input class="text" type="text" name="d[superuser]" id="superuser" value="<?php echo $d['superuser'] ?>" /> 162*47248316SAndreas Gohr 163*47248316SAndreas Gohr <label for="fullname"><?php echo $lang['fullname']?></label> 164*47248316SAndreas Gohr <input class="text" type="text" name="d[fullname]" id="fullname" value="<?php echo $d['fullname'] ?>" /> 165*47248316SAndreas Gohr 166*47248316SAndreas Gohr <label for="email"><?php echo $lang['email']?></label> 167*47248316SAndreas Gohr <input class="text" type="text" name="d[email]" id="email" value="<?php echo $d['email'] ?>" /> 168*47248316SAndreas Gohr 169*47248316SAndreas Gohr <label for="password"><?php echo $lang['pass']?></label> 170*47248316SAndreas Gohr <input class="text" type="password" name="d[password]" id="password" /> 171*47248316SAndreas Gohr 172*47248316SAndreas Gohr <label for="confirm"><?php echo $lang['passchk']?></label> 173*47248316SAndreas Gohr <input class="text" type="password" name="d[confirm]" id="confirm" /> 174*47248316SAndreas Gohr </fieldset> 175*47248316SAndreas Gohr </fieldset> 176*47248316SAndreas Gohr 177*47248316SAndreas Gohr </fieldset> 178*47248316SAndreas Gohr <fieldset id="process"> 179*47248316SAndreas Gohr <input class="button" type="submit" name="submit" value="<?php echo $lang['btn_save']?>" /> 180*47248316SAndreas Gohr </fieldset> 181*47248316SAndreas Gohr </form> 182*47248316SAndreas Gohr <?php 183*47248316SAndreas Gohr} 184*47248316SAndreas Gohr 185*47248316SAndreas Gohr/** 186*47248316SAndreas Gohr * Check validity of data 187*47248316SAndreas Gohr * 188*47248316SAndreas Gohr * @author Andreas Gohr 189*47248316SAndreas Gohr */ 190*47248316SAndreas Gohrfunction check_data($d){ 191*47248316SAndreas Gohr global $lang; 192*47248316SAndreas Gohr global $error; 193*47248316SAndreas Gohr 194*47248316SAndreas Gohr $ok = true; 195*47248316SAndreas Gohr 196*47248316SAndreas Gohr // check input 197*47248316SAndreas Gohr if(empty($d['title'])){ 198*47248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['i_wikiname']); 199*47248316SAndreas Gohr $ok = false; 200*47248316SAndreas Gohr } 201*47248316SAndreas Gohr if($d['acl']){ 202*47248316SAndreas Gohr if(!preg_match('/^[a-z1-9_]+$/',$d['superuser'])){ 203*47248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['i_superuser']); 204*47248316SAndreas Gohr $ok = false; 205*47248316SAndreas Gohr } 206*47248316SAndreas Gohr if(empty($d['password'])){ 207*47248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['pass']); 208*47248316SAndreas Gohr $ok = false; 209*47248316SAndreas Gohr } 210*47248316SAndreas Gohr if($d['confirm'] != $d['password']){ 211*47248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['passchk']); 212*47248316SAndreas Gohr $ok = false; 213*47248316SAndreas Gohr } 214*47248316SAndreas Gohr if(empty($d['fullname']) || strstr($d['fullname'],':')){ 215*47248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['fullname']); 216*47248316SAndreas Gohr $ok = false; 217*47248316SAndreas Gohr } 218*47248316SAndreas Gohr if(empty($d['email']) || strstr($d['fullname'],':')){ 219*47248316SAndreas Gohr $error[] = sprintf($lang['i_badval'],$lang['email']); 220*47248316SAndreas Gohr $ok = false; 221*47248316SAndreas Gohr } 222*47248316SAndreas Gohr } 223*47248316SAndreas Gohr return $ok; 224*47248316SAndreas Gohr} 225*47248316SAndreas Gohr 226*47248316SAndreas Gohr/** 227*47248316SAndreas Gohr * Writes the data to the config files 228*47248316SAndreas Gohr * 229*47248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 230*47248316SAndreas Gohr */ 231*47248316SAndreas Gohrfunction store_data($d){ 232*47248316SAndreas Gohr $ok = true; 233*47248316SAndreas Gohr 234*47248316SAndreas Gohr // create changes.log 235*47248316SAndreas Gohr if (!@file_exists(DOKU_INC.'data/changes.log')){ 236*47248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_INC.'data/changes.log',''); 237*47248316SAndreas Gohr } 238*47248316SAndreas Gohr 239*47248316SAndreas Gohr // create local.php 240*47248316SAndreas Gohr $now = date('r'); 241*47248316SAndreas Gohr $output = <<<EOT 242*47248316SAndreas Gohr<?php 243*47248316SAndreas Gohr/** 244*47248316SAndreas Gohr * Dokuwiki's Main Configuration File - Local Settings 245*47248316SAndreas Gohr * Auto-generated by install script 246*47248316SAndreas Gohr * Date: $now 247*47248316SAndreas Gohr */ 248*47248316SAndreas Gohr 249*47248316SAndreas GohrEOT; 250*47248316SAndreas Gohr $output .= '$conf[\'title\'] = \''.addslashes($d['title'])."';\n"; 251*47248316SAndreas Gohr if($d['acl']){ 252*47248316SAndreas Gohr $output .= '$conf[\'useacl\'] = 1'.";\n"; 253*47248316SAndreas Gohr $output .= '$conf[\'superuser\'] = \''.$d['superuser']."';\n"; 254*47248316SAndreas Gohr } 255*47248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'local.php',$output); 256*47248316SAndreas Gohr 257*47248316SAndreas Gohr 258*47248316SAndreas Gohr if ($d['acl']) { 259*47248316SAndreas Gohr // create users.auth.php 260*47248316SAndreas Gohr // --- user:MD5password:Real Name:email:groups,comma,seperated 261*47248316SAndreas Gohr $output = join(":",array($d['superuser'], md5($d['password']), $d['fullname'], $d['email'], 'users')); 262*47248316SAndreas Gohr $output = @file_get_contents(DOKU_CONF.'users.auth.php.dist')."\n$output\n"; 263*47248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'users.auth.php', $output); 264*47248316SAndreas Gohr 265*47248316SAndreas Gohr // create acl.auth.php 266*47248316SAndreas Gohr $output = @file_get_contents(DOKU_CONF.'acl.auth.php.dist'); 267*47248316SAndreas Gohr $ok = $ok && fileWrite(DOKU_LOCAL.'acl.auth.php', $output); 268*47248316SAndreas Gohr } 269*47248316SAndreas Gohr return $ok; 270*47248316SAndreas Gohr} 271*47248316SAndreas Gohr 272*47248316SAndreas Gohr/** 273*47248316SAndreas Gohr * Write the given content to a file 274*47248316SAndreas Gohr * 275*47248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 276*47248316SAndreas Gohr */ 277*47248316SAndreas Gohrfunction fileWrite($filename, $data) { 278*47248316SAndreas Gohr global $error; 279*47248316SAndreas Gohr global $lang; 280*47248316SAndreas Gohr 281*47248316SAndreas Gohr if (($fp = @fopen($filename, 'wb')) === false) { 282*47248316SAndreas Gohr $filename = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $filename); 283*47248316SAndreas Gohr $error[] = sprintf($lang['i_writeerr'],$filename); 284*47248316SAndreas Gohr return false; 285*47248316SAndreas Gohr } 286*47248316SAndreas Gohr 287*47248316SAndreas Gohr if (!empty($data)) { fwrite($fp, $data); } 288*47248316SAndreas Gohr fclose($fp); 289*47248316SAndreas Gohr return true; 290*47248316SAndreas Gohr} 291*47248316SAndreas Gohr 292*47248316SAndreas Gohr 293*47248316SAndreas Gohr/** 294*47248316SAndreas Gohr * check installation dependent local config files and tests for a known 295*47248316SAndreas Gohr * unmodified main config file 296*47248316SAndreas Gohr * 297*47248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 298*47248316SAndreas Gohr */ 299*47248316SAndreas Gohrfunction check_configs(){ 300*47248316SAndreas Gohr global $error; 301*47248316SAndreas Gohr global $lang; 302*47248316SAndreas Gohr global $dokuwiki_hash; 303*47248316SAndreas Gohr 304*47248316SAndreas Gohr $ok = true; 305*47248316SAndreas Gohr 3065cfb8815Schris $config_files = array( 3075cfb8815Schris 'local' => DOKU_LOCAL.'local.php', 3085cfb8815Schris 'users' => DOKU_LOCAL.'users.auth.php', 3095cfb8815Schris 'auth' => DOKU_LOCAL.'acl.auth.php' 3105cfb8815Schris ); 3115cfb8815Schris 3125cfb8815Schris 3135cfb8815Schris // main dokuwiki config file (conf/dokuwiki.php) must not have been modified 314*47248316SAndreas Gohr $installation_hash = md5(@file_get_contents(DOKU_CONF.'dokuwiki.php')); 3155cfb8815Schris if (!in_array($installation_hash, $dokuwiki_hash)) { 316*47248316SAndreas Gohr $error[] = sprintf($lang['i_badhash'],$installation_hash); 317*47248316SAndreas Gohr $ok = false; 3185cfb8815Schris } 3195cfb8815Schris 320*47248316SAndreas Gohr // configs shouldn't exist 321*47248316SAndreas Gohr foreach ($config_files as $file) { 322*47248316SAndreas Gohr if (@file_exists($file)) { 323*47248316SAndreas Gohr $file = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $file); 324*47248316SAndreas Gohr $error[] = sprintf($lang['i_confexists'],$file); 325*47248316SAndreas Gohr $ok = false; 326*47248316SAndreas Gohr } 327*47248316SAndreas Gohr } 328*47248316SAndreas Gohr return $ok; 329*47248316SAndreas Gohr} 330*47248316SAndreas Gohr 331*47248316SAndreas Gohr 332*47248316SAndreas Gohr/** 333*47248316SAndreas Gohr * Check other installation dir/file permission requirements 334*47248316SAndreas Gohr * 335*47248316SAndreas Gohr * @author Chris Smith <chris@jalakai.co.uk> 336*47248316SAndreas Gohr */ 337*47248316SAndreas Gohrfunction check_permissions(){ 338*47248316SAndreas Gohr global $error; 339*47248316SAndreas Gohr global $lang; 340*47248316SAndreas Gohr 341*47248316SAndreas Gohr $dirs = array( 342*47248316SAndreas Gohr 'conf' => DOKU_LOCAL, 343*47248316SAndreas Gohr 'data' => DOKU_INC.'data', 344*47248316SAndreas Gohr 'pages' => DOKU_INC.'data/pages', 345*47248316SAndreas Gohr 'attic' => DOKU_INC.'data/attic', 346*47248316SAndreas Gohr 'media' => DOKU_INC.'data/media', 347*47248316SAndreas Gohr 'meta' => DOKU_INC.'data/meta', 348*47248316SAndreas Gohr 'cache' => DOKU_INC.'data/cache', 349*47248316SAndreas Gohr 'locks' => DOKU_INC.'data/locks', 350*47248316SAndreas Gohr ); 351*47248316SAndreas Gohr 352*47248316SAndreas Gohr $ok = true; 353*47248316SAndreas Gohr foreach($dirs as $dir){ 354*47248316SAndreas Gohr if(!@file_exists("$dir/.") || !@is_writable($dir)){ 355*47248316SAndreas Gohr $dir = str_replace($_SERVER['DOCUMENT_ROOT'],'{DOCUMENT_ROOT}/', $dir); 356*47248316SAndreas Gohr $error[] = sprintf($lang['i_permfail'],$dir); 357*47248316SAndreas Gohr $ok = false; 358*47248316SAndreas Gohr } 359*47248316SAndreas Gohr } 360*47248316SAndreas Gohr return $ok; 361*47248316SAndreas Gohr} 362*47248316SAndreas Gohr 363*47248316SAndreas Gohr/** 364*47248316SAndreas Gohr * Check the availability of functions used in DokuWiki 365*47248316SAndreas Gohr * 366*47248316SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 367*47248316SAndreas Gohr */ 368*47248316SAndreas Gohrfunction check_functions(){ 369*47248316SAndreas Gohr global $error; 370*47248316SAndreas Gohr global $lang; 371*47248316SAndreas Gohr $funcs = explode(' ','addslashes basename call_user_func chmod copy fgets '. 372*47248316SAndreas Gohr 'file file_exists fseek flush filesize ftell fopen '. 373*47248316SAndreas Gohr 'glob header ignore_user_abort ini_get mail mkdir '. 374*47248316SAndreas Gohr 'ob_start opendir parse_ini_file readfile realpath '. 375*47248316SAndreas Gohr 'rename rmdir serialize session_start unlink usleep'); 376*47248316SAndreas Gohr 377*47248316SAndreas Gohr $ok = true; 378*47248316SAndreas Gohr foreach($funcs as $func){ 379*47248316SAndreas Gohr if(!function_exists($func)){ 380*47248316SAndreas Gohr $error[] = sprintf($lang['i_funcna'],$func); 381*47248316SAndreas Gohr $ok = false; 382*47248316SAndreas Gohr } 383*47248316SAndreas Gohr } 384*47248316SAndreas Gohr return $ok; 385*47248316SAndreas Gohr} 386*47248316SAndreas Gohr 387*47248316SAndreas Gohr/** 388*47248316SAndreas Gohr * Print language selection 389*47248316SAndreas Gohr * 390*47248316SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 391*47248316SAndreas Gohr */ 392*47248316SAndreas Gohrfunction langsel(){ 393*47248316SAndreas Gohr global $lang; 394*47248316SAndreas Gohr global $LC; 395*47248316SAndreas Gohr 396*47248316SAndreas Gohr $dir = DOKU_INC.'inc/lang'; 397*47248316SAndreas Gohr $dh = opendir($dir); 398*47248316SAndreas Gohr if(!$dh) return; 399*47248316SAndreas Gohr 400*47248316SAndreas Gohr $langs = array(); 401*47248316SAndreas Gohr while (($file = readdir($dh)) !== false) { 402*47248316SAndreas Gohr if(preg_match('/^[\._]/',$file)) continue; 403*47248316SAndreas Gohr if(is_dir($dir.'/'.$file) && @file_exists($dir.'/'.$file.'/lang.php')){ 404*47248316SAndreas Gohr $langs[] = $file; 405*47248316SAndreas Gohr } 406*47248316SAndreas Gohr } 407*47248316SAndreas Gohr closedir($dh); 408*47248316SAndreas Gohr sort($langs); 409*47248316SAndreas Gohr 410*47248316SAndreas Gohr 411*47248316SAndreas Gohr echo '<form action="">'; 412*47248316SAndreas Gohr echo $lang['i_chooselang']; 413*47248316SAndreas Gohr echo ': <select name="l" onchange="submit()">'; 414*47248316SAndreas Gohr foreach($langs as $l){ 415*47248316SAndreas Gohr $sel = ($l == $LC) ? 'selected="selected"' : ''; 416*47248316SAndreas Gohr echo '<option value="'.$l.'" '.$sel.'>'.$l.'</option>'; 417*47248316SAndreas Gohr } 418*47248316SAndreas Gohr echo '</select>'; 419*47248316SAndreas Gohr echo '<input type="submit" value="'.$lang['btn_update'].'" />'; 420*47248316SAndreas Gohr echo '</form>'; 421*47248316SAndreas Gohr} 422*47248316SAndreas Gohr 423*47248316SAndreas Gohr/** 424*47248316SAndreas Gohr * Print gloabl error array 425*47248316SAndreas Gohr * 426*47248316SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 427*47248316SAndreas Gohr */ 428*47248316SAndreas Gohrfunction print_errors(){ 429*47248316SAndreas Gohr global $error; 430*47248316SAndreas Gohr echo '<ul>'; 431*47248316SAndreas Gohr foreach ($error as $err){ 432*47248316SAndreas Gohr echo "<li>$err</li>"; 433*47248316SAndreas Gohr } 434*47248316SAndreas Gohr echo '</ul>'; 435*47248316SAndreas Gohr} 4365cfb8815Schris 4375cfb8815Schris/** 4385cfb8815Schris * remove magic quotes recursivly 4395cfb8815Schris * 4405cfb8815Schris * @author Andreas Gohr <andi@splitbrain.org> 4415cfb8815Schris */ 4425cfb8815Schrisfunction remove_magic_quotes(&$array) { 4435cfb8815Schris foreach (array_keys($array) as $key) { 4445cfb8815Schris if (is_array($array[$key])) { 4455cfb8815Schris remove_magic_quotes($array[$key]); 4465cfb8815Schris }else { 4475cfb8815Schris $array[$key] = stripslashes($array[$key]); 4485cfb8815Schris } 4495cfb8815Schris } 4505cfb8815Schris} 4515cfb8815Schris 452