| [ PHPXref.com ] | [ Generated: Sun Jul 20 21:04:18 2008 ] | [ WikyBlog 0.9.2 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <? 2 define('WikyBlog_Installing',true); 3 4 $autoStart = false; 5 require_once ('../wiki.php'); 6 require_once ('wiki2.php'); 7 8 error_reporting(E_ALL);//development 9 @ini_set( "display_errors", true ); //overwrite 10 // error_reporting(E_ALL ^ E_NOTICE); //the $lang variable won't be available.. and don't need to worry users with NOTICEs 11 restore_error_handler(); 12 13 14 $step = 0; 15 $functions = array(); 16 $desc = array(); 17 18 $functions[] = 'checkEnvironment'; 19 $desc[] = 'Environment Check'; 20 21 $functions[] = 'dbConfig'; 22 $desc[] = 'Database > Connection Values'; 23 24 $functions[] = 'dbConfig2'; 25 $desc[] = 'Database > Select Database'; 26 27 $functions[] = 'createTables'; 28 $desc[] = 'Database > Create Tables'; 29 30 $functions[] = 'copyTemporary1'; 31 $desc[] = 'Save Data > Files'; 32 33 $functions[] = 'setDefaultConfig'; 34 $desc[] = 'Save Data > Default Configuration'; 35 36 $functions[] = 'registerAdminUser'; 37 $desc[] = 'Save Data > Admin User'; 38 39 $functions[] = 'saveDefaultTemplate'; 40 $desc[] = 'Save Data > Default Template'; 41 42 $functions[] = 'createWikiFile'; 43 $desc[] = 'Finalize Installation'; 44 45 46 $_POST += array('step'=>array()); 47 $step = key($_POST['step']); 48 49 ?> 50 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 51 <html xmlns="http://www.w3.org/1999/xhtml"> 52 <head> 53 <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 54 <title>WikyBlog Software Installation</title> 55 56 <style type="text/css" > 57 58 li{margin-bottom:1em} 59 body{margin:1em;} 60 </style> 61 62 63 </head> 64 <body> 65 <form action="install.php" method="POST"> 66 <table cellpadding="5" style="float:right;margin-left:2em;margin-bottom:3em"> 67 <tr><th colspan="2" style="text-align:left">Installation Summary</th></tr> 68 <? 69 70 71 foreach($desc as $i => $text){ 72 $i++; 73 if( $i == $step){ 74 echo '<tr><td style="font-size:85%"> > </td><td style="font-size:85%"><b>Step '.$i.' > '; 75 echo $text.'<b></td></tr>'; 76 }else{ 77 echo '<tr><td style="font-size:85%"> </td><td style="font-size:85%">Step '.$i.' > '; 78 echo $text.'</td></tr>'; 79 } 80 } 81 echo '<tr><td colspan="2" style="font-size:85%">While the list is somewhat long, the process is fast.<br/> Each step only takes a minute or two.</td></tr>'; 82 echo '</table>'; 83 84 ?> 85 <h1 style="margin:0">WikyBlog Installation</h1> 86 <div style="font-size:80%"> See /_install.txt for more information about installation</div> 87 <br/> 88 <? 89 90 if ( defined('WikyBlog_Installed') ){ 91 die(finishedNotice()); 92 } 93 94 95 // ConfigData 96 // 97 $configData = array(); 98 if( isset($_POST['configData']) ){ 99 $temp = unHtmlspecialchars($_POST['configData']); 100 $configData = unserialize($temp); 101 102 //not saved in wiki.php yet 103 $rootDir =& $configData['rootDir']; 104 $includeDir =& $configData['includeDir']; 105 $hostname =& $configData['hostname']; 106 $dbname =& $configData['dbname']; 107 $dbpword =& $configData['dbpword']; 108 $dbuname =& $configData['dbuname']; 109 $wbTablePrefix =& $configData['wbTablePrefix']; 110 111 112 } 113 114 if( empty($_POST['step']) && !isset($_GET['cmd']) ){ 115 echo '<p> <br/> </p>'; 116 echo '<input type="submit" name="step[1]" value="Start Installation" />'; 117 }else{ 118 runInstall($step); 119 } 120 121 echo '<input type="hidden" name="configData" value="'.htmlspecialchars(serialize($configData), ENT_QUOTES).'" />'; 122 echo "\n\n</form></body></html>"; 123 124 125 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 126 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 127 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 128 // 129 // runInstall 130 // 131 /// 132 133 function runInstall($step){ 134 global $functions, $desc; 135 136 $function = $functions[$step-1]; 137 $action = current($_POST['step']); 138 //echo '<h3>Step '.$step.' > '.$desc[$step-1].'</h3>'; 139 echo '<h3>Step '.$step.'</h3>'; 140 ob_start(); 141 $bool = call_user_func($function,$action); 142 $text = ob_get_clean(); 143 144 echo returnMessages(); 145 echo $text; 146 147 // if the function returns true, show the <input> for the next function 148 // or show finished if function doesn't exist 149 if( $bool === true ){ 150 echo '<p> - Step '.$step.' done.</p>'; 151 echo ' <p> </p>'; 152 153 if( isset($functions[$step]) ){ 154 echo '<input type="submit" name="step['.htmlspecialchars($step+1).']" value="Step '.htmlspecialchars($step+1).'" /> '; 155 }else{ 156 echo finishedNotice(); 157 } 158 159 160 if( $step > 1 && isset($functions[$step])){ 161 echo '<input type="submit" name="step['.htmlspecialchars($step).']" value="Back" /> '; 162 } 163 164 }else{ 165 echo '<p> </p> '; 166 echo '<input type="submit" name="step['.htmlspecialchars($step).']" value="Continue" /> '; 167 if( $step > 1){ 168 echo '<input type="submit" name="step['.htmlspecialchars($step-1).']" value="Back" /> '; 169 } 170 } 171 } 172 173 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 174 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 175 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 176 // 177 // dbConfig 178 // I would like to do this, because 179 /// 180 function dbConfig($action){ 181 $done = false; 182 //database select 183 // $hostname = "localhost"; 184 // $dbuname = "root"; 185 // $dbpword = ""; 186 //mysql_connect($hostname,$dbuname,$dbpword); 187 188 // $dbname = "wikyblog3"; 189 190 $_POST += array('hostname'=>'','dbuname'=>'','dbpword'=>'','dbname'=>''); 191 192 if($action == 'Continue'){ 193 $done = true; 194 if( empty($_POST['hostname']) ){ 195 $done = false; 196 message('Missing hostname'); 197 } 198 if( empty($_POST['dbuname']) ){ 199 $done = false; 200 message('Missing username'); 201 } 202 if( empty($_POST['dbpword']) ){ 203 //$done = false; 204 $mess = 'Missing password'; 205 if( $done ){ 206 $mess .= '... <br/> ... we will still attempt to connect to the database...'; 207 } 208 message($mess); 209 } 210 211 } 212 213 if( $done ){ 214 $done = @mysql_connect($_POST['hostname'],$_POST['dbuname'],$_POST['dbpword']); 215 if(!$done){ 216 message('Could not connect to the database using the suppliled values'); 217 }else{ 218 global $configData; 219 $configData['hostname'] = $_POST['hostname']; 220 $configData['dbuname'] = $_POST['dbuname']; 221 $configData['dbpword'] = $_POST['dbpword']; 222 message('Connection made using the supplied values'); 223 return true; 224 } 225 } 226 227 ?> 228 These values will be used to connect to MySQL 229 <table> 230 231 <tr> 232 <td align="left"><b>Hostname:</b></td><td> 233 <input type="text" size="20" name="hostname" value="<?=$_POST['hostname'] ?>"><br> 234 </td><td style='font-size:smaller'>Database Server Hostname</td> 235 </tr> 236 237 <tr> 238 <td align="left"><b>Username:</b></td><td> 239 <input type="text" size="20" name="dbuname" value="<?= $_POST['dbuname'] ?>"><br> 240 </td><td style='font-size:smaller'>Database Username</td> 241 </tr> 242 243 <tr> 244 <td align="left"><b>Password:</b></td><td> 245 <input type="password" size="20" name="dbpword" value="<?=$_POST['dbpword'] ?>"><br> 246 </td><td style='font-size:smaller'>Database Password</td> 247 </tr> 248 249 </table> 250 <? 251 return false; 252 } 253 254 function dbConfig2($action){ 255 global $configData; 256 $_POST += array('wbTablePrefix'=>'WB'); 257 258 if( $action !== 'Continue' && !empty($configData['wbDirPrefix']) ){ 259 $_POST['wbTablePrefix'] = trim($configData['wbDirPrefix'],'/'); 260 $_POST['wbTablePrefix'] = wbStr_replace('.','_',$_POST['wbTablePrefix']); 261 $_POST['wbTablePrefix'] = wbStr_replace('/','_',$_POST['wbTablePrefix']).'_'; 262 $_POST['wbTablePrefix'] = wbStrtolower($_POST['wbTablePrefix']); 263 } 264 265 266 if(empty($_POST['dbname'])){ 267 268 $connection = mysql_connect($configData['hostname'],$configData['dbuname'],$configData['dbpword']); 269 $query = 'SHOW DATABASES'; 270 $result = runQuery($query); 271 while($row = mysql_fetch_assoc($result)){ 272 $possible[$row['Database']] = $row['Database']; 273 } 274 echo '<table>'; 275 echo '<tr><td><b>Database Name:</b></td><td>'; 276 echo formSelect('dbname',$possible); 277 echo '</td><td>Select from an existing database.</td>'; 278 echo '</tr>'; 279 280 echo '<tr><td><b>Table Prefix:</b></td><td>'; 281 echo '<input type="text" name="wbTablePrefix" value="'.$_POST['wbTablePrefix'].'" />'; 282 echo '</td><td>This can be useful if the selected database is used for other database applications. It can be left blank.</td>'; 283 echo '</tr>'; 284 285 echo '</table>'; 286 return false; 287 }else{ 288 $configData['dbname'] = $_POST['dbname']; 289 $configData['wbTablePrefix'] = wbStrtolower($_POST['wbTablePrefix']); 290 return true; 291 } 292 293 message('need to save these values and select a dbname: '); 294 295 } 296 297 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 298 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 299 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 300 // 301 // checkEnvironment 302 // checkEnvironment and set some initial $configData values 303 // 304 305 function checkEnvironment($action){ 306 global $configData; 307 308 //Some of the following is from mediawiki's 309 echo 'Checking Environment:<ul>'; 310 $fatal = false; 311 312 if( !function_exists('version_compare') || (version_compare(phpversion(),"4.1") < 0)){ 313 $fatal = true; 314 315 ?><li><strong>Fatal: Minimum of PHP 4.1 Needed .</strong> 316 <? 317 } 318 319 if( !is_writable( "../" ) || !is_writable('../wiki.php') ){ 320 $fatal = true; 321 $which = array(); 322 if( !is_writable( "../" ) ){ 323 $which[] = 'the installation directory'; 324 } 325 if( !is_writable('../wiki.php') ){ 326 $which[] = 'the /wiki.php file.'; 327 } 328 $text = implode(' and ',$which); 329 330 ?><li><strong>Fatal: Files are not writable.</strong> 331 <p>WikyBlog cannot install correctly without being able to write to <?= $text ?>.</p> 332 <p>To make a directory writable, use your ftp client and set the mode to 777, or on a Unix/Linux system:</p> 333 334 <pre> 335 chmod a+w file 336 </pre> 337 338 <p>For security purposes, you should restore the modes once installation has completed.</p> 339 340 </li> 341 <? 342 } 343 344 if( ini_get( "magic_quotes_runtime" ) ) { 345 $fatal = true; 346 ?><li><strong>Fatal: <a href='http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-runtime'>magic_quotes_runtime</a> is active!</strong> 347 <p>This option corrupts data input unpredictably; you cannot install or use 348 WikyBlog unless this option is disabled.</p> 349 </li> 350 <?php 351 return; 352 } 353 if( ini_get( "magic_quotes_sybase" ) ) { 354 $fatal = true; 355 ?><li><strong>Fatal: <a href='http://www.php.net/manual/en/ref.sybase.php#ini.magic-quotes-sybase'>magic_quotes_sybase</a> is active!</strong> 356 <p>This option corrupts data input unpredictably; you cannot install or use 357 WikyBlog unless this option is disabled.</p> 358 </li> 359 <?php 360 } 361 362 if( ini_get("register_globals") ){ 363 ?> 364 <li><b>Warning:</b> <strong>PHP's 365 <tt><a href="http://php.net/register_globals">register_globals</a></tt> 366 option is enabled.</strong><p> WikyBlog will work correctly, but this setting 367 increases your exposure to potential security vulnerabilities in PHP-based 368 software running on your server. <strong>You should disable it if you are able.</strong></p> 369 </li> 370 <?php 371 } 372 373 if( !function_exists('mb_convert_case') ){ 374 ?><li><strong>Warning: <a href='http://www.php.net/manual/en/ref.mbstring.php'>Multibyte strings</a> are not supported.</strong> 375 <p>For multibyte character support, a minimum of PHP version 4.3 with the mbstring PHP extension is needed.</p> 376 <p>Without the mbstring extension WikyBlog is unable to split multibyte character set strings correctly. 377 If user input will include mulitbyte characters (like ç ö ü ý þ), you may see unexpected results.</p> 378 </li> 379 <? 380 } 381 382 if(@extension_loaded('mbstring') && @ini_get('mbstring.func_overload') == 1){ 383 ?><li><strong>Warning: <a href='http://www.php.net/manual/en/ref.mbstring.php'>mbstring.func_overload</a> is activated.</strong> 384 <p>mbstring.func_overload is enabled in your PHP configuration. 385 This option may result in the corruption of user data 386 <? 387 } 388 389 390 391 392 //replace \ with / because windows will give both sometimes 393 $configData['rootDir'] = str_replace('\\','/',dirname(dirname(__FILE__))); 394 $configData['includeDir'] = str_replace('\\','/',$configData['rootDir'].'/include'); 395 $configData['wbUniq'] = uniqid(''); 396 397 if( str_replace('\\','/',dirname(__FILE__)) !== $configData['includeDir']){ 398 $fatal = true; 399 ?><li><strong>Fatal: Incorrect File Paths</strong> 400 <p>Software folders must not be rearranged/renamed when they are uploaded to your server<p> 401 </li> 402 <? 403 } 404 405 $configData['rootDir'] = $configData['rootDir']; 406 $docRoot = str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']); 407 if( strpos($configData['rootDir'],$docRoot) !== 0){ 408 $fatal = true; 409 ?><li><strong>Fatal: File Path Error</strong> 410 <p>The software folders do not appear to be in the server's root directory</p> 411 <ul> 412 <li>Server Root: <?= str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']); ?></li> 413 <li>Sofware Folders In: <?= $configData['rootDir'] ?></li> 414 </ul> 415 </li> 416 <? 417 418 }elseif( $docRoot !== $configData['rootDir'] ){ 419 $configData['wbDirPrefix'] = str_replace($docRoot,'',$configData['rootDir']); 420 ?> 421 <li><b>Installation in SubDirectory: <?= $configData['wbDirPrefix'] ?></b> 422 <p> 423 It appears this software is not being installed on the server document root. 424 Links will automatically be prepended with this value to make them valid. 425 </p> 426 </li> 427 <? 428 429 }else{ 430 $configData['wbDirPrefix'] = ''; 431 } 432 433 if( $fatal ) { 434 echo '</ul>'; 435 return false; 436 } 437 echo '<li>Environment ok... </li>'; 438 echo '</ul>'; 439 440 return true; 441 } 442 443 444 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 445 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 446 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 447 // 448 // createWikiFile 449 // 450 function createWikiFile($action){ 451 global $configData,$packageVersion; 452 $done = false; 453 454 $text[] = '<'.'?'.'php'; 455 $text[] = "//"; 456 $text[] = "//\tWikyBlog Generated File"; 457 $text[] = "//\t***********************************"; 458 $text[] = "//\tDon't change anything in this file!"; 459 $text[] = "//\tThis file was created "; 460 $text[] = "//\t\t on ".date("l, F j, Y"); 461 $text[] = "//\t\t by WikyBlog Package ".$packageVersion; 462 $text[] = "//"; 463 $text[] = ''; 464 $text[] = ''; 465 $text[] = 'define(\'WikyBlog_Installed\', true);'; 466 $text[] = '$wbUniq = \''. addcslashes($configData['wbUniq'],"'") .'\';'; 467 $text[] = ''; 468 $text[] = ''; 469 $text[] = '$hostname = \''. addcslashes($configData['hostname'],"'") .'\';'; 470 $text[] = '$dbuname = \''. addcslashes($configData['dbuname'],"'") .'\';'; 471 $text[] = '$dbpword = \''. addcslashes($configData['dbpword'],"'") .'\';'; 472 $text[] = '$dbname = \''. addcslashes($configData['dbname'],"'") .'\';'; 473 $text[] = ''; 474 $text[] = ''; 475 $text[] = '$wbTablePrefix = \''. addcslashes($configData['wbTablePrefix'],"'") .'\';'; 476 $text[] = ''; 477 $text[] = ''; 478 $text[] = '$rootDir = \''. addcslashes($configData['rootDir'],"'") .'\';'; 479 $text[] = '$includeDir = \''. addcslashes($configData['includeDir'],"'") .'\';'; 480 $text[] = '$wbDirPrefix = \''. addcslashes($configData['wbDirPrefix'],"'") .'\';'; 481 $text[] = ''; 482 $text[] = ''; 483 $text[] = 'if( $autoStart !== false){'; 484 $text[] = "\trequire(\$includeDir.'/wiki2.php');"; 485 $text[] = "\tdoWikiThing();"; 486 $text[] = '}'; 487 488 $fileContents = implode("\n",$text); 489 //message('<pre>'.htmlspecialchars($fileContents).'</pre>'); 490 491 $wikiLocation = $configData['rootDir'].'/wiki.php'; 492 493 if( is_writable($configData['rootDir']) ){ 494 if($fp = @fopen($wikiLocation,'w')){ 495 if( @fwrite($fp,$fileContents) ){ 496 $done = true; 497 } 498 fclose($fp); 499 } 500 } 501 502 if( !$done ){ 503 //this shouldn't happen because we check for is_writable() in the checkEnvironment function 504 ?> 505 <p> 506 <b>Warning:</b>The WikyBlog installation was not successfully completed. 507 <p>A problem occured while trying to write to the /wiki.php file. 508 You can complete the installation by manually editing this file.</p> 509 <ol><li> Open the "<tt>wiki.php</tt>" in your "<tt><?= $configData['rootDir'] ?></tt>" directory.</li> 510 <li>Then, paste in the following text: 511 <br/> <textarea rows="15" cols="60"><?= htmlspecialchars($fileContents) ?></textarea></li> 512 </ol> 513 </p> 514 <? 515 } 516 517 $modes = true; 518 $modes = $modes && @chmod($configData['rootDir'],0755); 519 $modes = $modes && @chmod($wikiLocation,0644); 520 if( $modes ){ 521 ?> 522 <p>This script was able to restore the modes of the installation directory and the /wiki.php file.</p> 523 <p>These files are no longer world-writable and now have the modes 755 and 644 respectively.</p> 524 <? 525 }else{ 526 ?> 527 <p><b>Warning:</b>This script was unable to change the modes of the installation directory and the /wiki.php file.</p> 528 529 <p>For security reasons, you should restore the modes of these files manually. 530 Normally, modes of 755 and 644 respectively are used.</p> 531 <? 532 } 533 534 return true; 535 } 536 537 538 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 539 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 540 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 541 // 542 // createTables 543 // 544 545 function createTables($action){ 546 global $dbname,$configData; 547 require_once ('installSQL.php'); 548 549 550 $connection = mysql_connect($configData['hostname'],$configData['dbuname'],$configData['dbpword']); 551 if( !$connection ){ 552 die('The database configuration data no longer valid, please try again'); 553 } 554 if(!mysql_select_db($configData['dbname'],$connection)){ 555 die('The database configuration data no longer valid, please try again'); 556 } 557 558 559 ob_start(); 560 echo '<p></p>This script will run the following queries on the database "' .$configData['dbname'].'".'; 561 562 563 // Existing Tables 564 $query = 'SHOW TABLES'; 565 if( !empty($configData['wbTablePrefix']) ){ 566 $query .= ' LIKE "'.sqlLike($configData['wbTablePrefix']).'%"'; 567 } 568 //message($query); 569 $result = runQuery($query); 570 while($row = mysql_fetch_assoc($result)){ 571 $tables[array_pop($row)] = 1; 572 } 573 574 $newDB = unserialize($dbData); 575 //echo showArray($newDB); 576 echo '<blockquote style="font-size:smaller">'; 577 foreach( $newDB as $tableName => $info){ 578 if( isset($tables[$configData['wbTablePrefix'].$tableName]) ){ 579 echo '<p><b>Table "'.$configData['wbTablePrefix'].$tableName.'" already exists</b></p>'; 580 echo 'Continuing will modify the table and could result in loss of data.'; 581 }else{ 582 echo '<p><b>Query for table "'.$configData['wbTablePrefix'].$tableName.'"</b></p>'; 583 echo str_replace('CREATE TABLE `&tablePrefix&','CREATE TABLE `'.$configData['wbTablePrefix'],$info['create']); 584 } 585 } 586 587 if( $action === 'Continue'){ 588 $done = true; 589 }else{ 590 $done = false; 591 } 592 593 if( $action === 'Continue'){ 594 require_once ('installDB.php'); 595 $alterDb = new dbAlter(); 596 $alterDb->go($configData['wbTablePrefix']); 597 $messages = returnMessages(false); 598 message('Queries and Results: '.$messages); 599 } 600 601 echo '</blockquote>'; 602 603 604 if( $done ){ 605 ob_get_clean(); 606 return true; 607 } 608 echo ob_get_clean(); 609 return false; 610 } 611 612 613 614 615 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 616 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 617 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 618 // 619 // registerAdminUser 620 // 621 // Insert Database Information 622 // - default template 623 624 function registerAdminUser($action){ 625 global $wbTablePrefix; 626 ob_start(); 627 628 connect(); 629 getConfig(); 630 631 632 $query = 'SELECT username FROM `'.$wbTablePrefix.'users` WHERE username = "main"'; 633 $result = runQuery($query); 634 $num = mysql_num_rows($result); 635 $newUser = false; 636 637 638 if( $num !== 0 ){ 639 $newUser = true; 640 641 }elseif( ($num === 0) && ($action==='Continue') ){ 642 echo 'Registering "Main"'; 643 $_POST['username'] = 'Main'; 644 $reservedWords = array(); 645 646 getLangFile('SPEC'); 647 require_once ('sessionRegister.php'); 648 $newUser = register(true); 649 650 if(!$newUser){ 651 echo returnMessages(false); 652 } 653 } 654 655 if(!$newUser){ 656 $_POST = $_POST + array('email'=>''); 657 ?> 658 This will create the "Main" user account using the following information. 659 All of the administrative features are by default accessible to this user account. 660 <table><tr> 661 <td align="left"><b> Password:</b></td><td> 662 <input type="password" size="20" name="password" value=""><br> 663 </td><td style='font-size:smaller'> Must be between 5 and 8 characters long. 664 </td> 665 666 </tr><tr> 667 668 <td align="left"><b> 669 Confirm Password:</b></td><td> 670 <input type="password" size="20" name="password2" value=""><br> 671 </td><td style='font-size:smaller'> 672 Must be the same as above. 673 </td> 674 675 </tr><tr> 676 677 <td align="left"><b> 678 Email:</b></td><td> 679 <input type="text" size="20" name="email" value="<?= htmlspecialchars($_POST['email']) ?>"><br> 680 </td><td style='font-size:smaller'>Optional but useful if you forget your password.</td> 681 </tr> 682 683 </table> 684 685 <? 686 }else{ 687 ob_get_clean(); 688 return true; 689 } 690 echo ob_get_clean(); 691 return false; 692 } 693 694 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 695 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 696 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 697 // 698 // setDefaultConfig 699 // insert into the config table 700 701 function setDefaultConfig($action){ 702 global $packageVersion,$wbTablePrefix,$configData; 703 704 connect(); 705 $query = 'SELECT `data`, `version` FROM `'.$wbTablePrefix.'config` ORDER BY revision DESC LIMIT 1'; 706 //message($query); 707 $result = runQuery($query); 708 $num = mysql_num_rows($result); 709 if( $num !== 0 ){ 710 $row = mysql_fetch_assoc($result); 711 if( !empty($row['version']) ){ 712 message('Configuration exists.'); 713 return true; 714 } 715 // 716 $query = 'DELETE FROM `'.$wbTablePrefix.'config` '; 717 $result = runQuery($query); 718 } 719 720 $array = array(); 721 $array['wbConfig']['version'] = $packageVersion; 722 $array['wbConfig']['floodInterval'] = '30'; 723 $array['serverName1'] = 'WikyBlog'; 724 $array['serverName2'] = 'www.wikyblog.com'; 725 $array['serverName3'] = 'http://'.$array['serverName2']; 726 $array['googleMapsKey'] = ''; 727 $array['userLanguage'] = 'en'; 728 $array['reservedWords'] = "'webmaster', 'master', 'BillyJoe'"; 729 730 $array['defaultUser']['homeTitle'] = 'Home'; 731 $array['defaultUser']['template'] = 'Main/Home'; 732 $array['defaultUser']['textareaY'] = '20'; 733 $array['defaultUser']['isBlog'] = 'On'; 734 $array['defaultUser']['timezone'] = '0:00'; 735 $array['defaultUser']['ajax'] = 'On'; 736 $array['defaultUser']['maxHistory'] = '100'; 737 $array['defaultUser']['lang'] = 'en'; 738 739 $array['maxUserDiskUsage'] = '3000000'; 740 $array['maxHistory'] = '100'; 741 $array['max_upload'] = '180000'; 742 743 $array['maxErrorFileSize'] = ''; 744 $array['errorEmail'] = ''; 745 746 $array['dbInfo']['page']['class'] = 'CLASSpage'; 747 $array['dbInfo']['page']['dbTable'] = "`{$wbTablePrefix}pages`"; 748 $array['dbInfo']['page']['dbHistoryTable'] = "`{$wbTablePrefix}pagehistory`"; 749 $array['dbInfo']['page']['querySelect'] = ' * '; 750 $array['dbInfo']['page']['queryFrom'] = " `{$wbTablePrefix}pages` "; 751 $array['dbInfo']['page']['uniqLink'] = ' CONCAT("/", `'.$wbTablePrefix.'pages`.owner, "/", `'.$wbTablePrefix.'pages`.title) '; 752 $array['dbInfo']['page']['displayTitle'] = ' `'.$wbTablePrefix.'pages`.title as displayTitle '; 753 $array['dbInfo']['page']['xmlHTTP'] = 1; 754 $array['dbInfo']['page']['keys'] = array('owner'=>1,'title'=>1); 755 756 $array['dbInfo']['comment']['class'] = 'CLASScomment'; 757 $array['dbInfo']['comment']['dbTable'] = "`{$wbTablePrefix}comments`"; 758 $array['dbInfo']['comment']['dbHistoryTable'] = "`{$wbTablePrefix}commenthistory`"; 759 $array['dbInfo']['comment']['querySelect'] = ' * '; 760 $array['dbInfo']['comment']['queryFrom'] = " `{$wbTablePrefix}comments` "; 761 $array['dbInfo']['comment']['uniqLink'] = ' CONCAT("/Comment/", `'.$wbTablePrefix.'comments`.prefix, `'.$wbTablePrefix.'comments`.owner,"/", `'.$wbTablePrefix.'comments`.title,"/", `'.$wbTablePrefix.'comments`.subject) '; 762 $array['dbInfo']['comment']['displayTitle'] = ' CONCAT( `'.$wbTablePrefix.'comments`.prefix , `'.$wbTablePrefix.'comments`.title, " > Talk > ", `'.$wbTablePrefix.'comments`.subject) as displayTitle '; 763 $array['dbInfo']['comment']['xmlHTTP'] = 1; 764 $array['dbInfo']['comment']['keys'] = array('prefix'=>1,'owner'=>1,'title'=>1,'subject'=>1); 765 766 $array['dbInfo']['map']['class'] = 'CLASSmap'; 767 $array['dbInfo']['map']['dbTable'] = "`{$wbTablePrefix}maps`"; 768 $array['dbInfo']['map']['dbHistoryTable'] = "`{$wbTablePrefix}maphistory`"; 769 $array['dbInfo']['map']['querySelect'] = ' * '; 770 $array['dbInfo']['map']['queryFrom'] = " `{$wbTablePrefix}maps` "; 771 $array['dbInfo']['map']['uniqLink'] = ' CONCAT("/Map/", `'.$wbTablePrefix.'maps`.owner, "/", `'.$wbTablePrefix.'maps`.title) '; 772 $array['dbInfo']['map']['displayTitle'] = ' CONCAT("Map > ", `'.$wbTablePrefix.'maps`.title) as displayTitle '; 773 $array['dbInfo']['map']['xmlHTTP'] = 1; 774 $array['dbInfo']['map']['keys'] = array('owner'=>1,'title'=>1); 775 776 $array['dbInfo']['template']['class'] = 'CLASStemplate'; 777 $array['dbInfo']['template']['dbTable'] = "`{$wbTablePrefix}templates`"; 778 $array['dbInfo']['template']['dbHistoryTable'] = "`{$wbTablePrefix}templatehistory`"; 779 $array['dbInfo']['template']['querySelect'] = ' * '; 780 $array['dbInfo']['template']['queryFrom'] = " `{$wbTablePrefix}templates` "; 781 $array['dbInfo']['template']['uniqLink'] = ' CONCAT("/Template/", `'.$wbTablePrefix.'templates`.owner, "/", `'.$wbTablePrefix.'templates`.title) '; 782 $array['dbInfo']['template']['displayTitle'] = ' CONCAT("Template > ", `'.$wbTablePrefix.'templates`.title) as displayTitle '; 783 $array['dbInfo']['template']['xmlHTTP'] = 0; 784 $array['dbInfo']['template']['keys'] = array('owner'=>1,'title'=>1); 785 786 //specialized datatypes 787 // scripts will check for ['dbTable'] to verify which datatype is being handled 788 $array['dbInfo']['talk']['class'] = 'searchTalk'; 789 $array['dbInfo']['special']['class'] = 'SPEC'; 790 $array['dbInfo']['admin']['class'] = 'ADMIN'; 791 792 793 ///RESET some values differently 794 if( isset($_SERVER['SERVER_NAME']) ){ 795 $array['serverName2'] = $_SERVER['SERVER_NAME']; 796 $array['serverName1'] = $_SERVER['SERVER_NAME']; 797 }else{ 798 $array['serverName2'] = $_SERVER['HTTP_HOST']; 799 $array['serverName1'] = $_SERVER['HTTP_HOST']; 800 } 801 $array['serverName3'] = 'http://'.$array['serverName2']; 802 //make a little effort to make serverName1 a little cleaner 803 if( strpos($array['serverName1'],'www.') === 0){ 804 $array['serverName1'] = wbSubstr($array['serverName1'],4,0); 805 } 806 $array['serverName3'] .= $configData['wbDirPrefix']; 807 808 $insert['data'] = serialize($array); 809 $insert['summary'] = 'Created during software installation.'; 810 $insert['username'] = ''; 811 $insert['version'] = $packageVersion; 812 813 $query = 'INSERT INTO `'.$wbTablePrefix.'config` SET '; 814 $query .= dbToSet($insert,true); 815 816 runQuery($query); 817 $num = mysql_affected_rows(); 818 if( $num < 1){ 819 message('<b>Warning</b> The default configuration was not saved.'); 820 return false; 821 } 822 message('The default configuration has been saved.'); 823 return true; 824 } 825 826 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 827 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 828 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 829 // 830 // saveDefaultTemplate 831 // 832 // Insert Database Information 833 // - default template 834 835 function saveDefaultTemplate($action){ 836 global $rootDir,$wbTablePrefix; 837 838 connect(); 839 $query = 'SELECT owner FROM `'.$wbTablePrefix.'templates` WHERE owner = "main" AND title = "home"'; 840 $result = runQuery($query); 841 $num = mysql_num_rows($result); 842 if( $num !== 0 ){ 843 message('Default Template exists.'); 844 return true; 845 } 846 847 ob_start(); 848 849 $warn = false; 850 $templates = array(); 851 $templDir = $rootDir.'/templates/main'; 852 if ($dh = @opendir($templDir)) { 853 while (($file = readdir($dh)) !== false) { 854 if( ($file == '.') || ($file == '..') ){ 855 continue; 856 } 857 858 $newTempl = $templDir.'/'.$file; 859 if( is_dir($newTempl) ){ 860 $templates[] = $file; 861 862 $query = 'INSERT INTO `'.$wbTablePrefix.'templates` SET owner = "Main", title = "'.$file.'", username="Main", posted=NOW(), created=NOW(), summary="Created during software installation" '; 863 864 if($file == 'home'){ 865 $query .= ',flags="locked"'; 866 } 867 $query .= ';'; 868 869 $result = runQuery($query); 870 $num = mysql_affected_rows(); 871 if( $num !== 1){ 872 echo '<br/>Could not install the template "'.$file.'".'; 873 } 874 875 } 876 } 877 }else{ 878 echo 'Could not open the template directory: '.$templDir; 879 } 880 881 if( ob_get_length() == 0 ){ 882 return true; 883 } 884 echo ob_get_clean(); 885 return false; 886 } 887 888 889 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 890 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 891 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 892 // 893 // copyTemporary1 894 // 895 // File System Setup 896 897 function copyTemporary1($action){ 898 global $rootDir,$files,$configData; 899 900 require_once ('install-files.php'); 901 902 if( $action !== 'Continue'){ 903 echo 'This will make sure necessary files can be found and have the correct mode.'; 904 return false; 905 } 906 907 ////////////////////////////////////////////////////////////////////////////////////////// 908 // 909 // Copy Temporary to rootDir 910 // 911 912 $tempRoot = $rootDir.'/temporary'; 913 $array = copyTemporary($tempRoot,$rootDir); 914 if( $array[0] === false){ 915 return false; 916 } 917 // if( $array[1] === false){ 918 // message('This script could not remove the /Temporary directory.'); 919 // } 920 return true; 921 } 922 923 //function copyTemporary($from,$to,$mode=0755){ 924 function copyTemporary($from,$to){ 925 global $rootDir,$files; 926 $temp['.'] = true; 927 $temp['..'] = true; 928 929 $done[0] = true; //were the files copied 930 $done[1] = true; //were the files moved (deleted from source) 931 932 $tempRoot = $rootDir.'/temporary/'; 933 934 if( $to !== $rootDir ){ 935 message('Create Directory: <tt>'.$to.'</tt>'); 936 937 if( !is_dir($to) && !mkDir($to,0777) ){ 938 message('<b>Error:</b> Could not create the directory: <tt>'.$to.'</tt>.'); 939 return false; 940 } 941 if( !is_writable($to) ){ 942 if( !@chmod($to,0777) ){ 943 message('<b>Error:</b> Could not change the mode for directory: <tt>'.$to.'</tt>.'); 944 return false; 945 } 946 } 947 } 948 949 950 if ($dh = @opendir($from)) { 951 while (($file = readdir($dh)) !== false) { 952 if( isset($temp[$file]) ){ 953 continue; 954 } 955 $fromNew = $from.'/'.$file; 956 $toNew = $to.'/'.$file; 957 958 if( is_dir($fromNew) ){ 959 960 $result = copyTemporary($fromNew,$toNew); 961 $done[0] = $done[0] && $result[0]; 962 963 //$result2 = @rmdir($fromNew); 964 //$done[1] = $done[1] && $result2; 965 966 }else{ 967 message('Copy file to <tt>'.$toNew.'</tt>'); 968 if( !copy($fromNew,$toNew) ){ //will overwrite existing files! 969 $done[0] = false; 970 message('<b>Error:</b> Could not copy <tt>'.$fromNew.'</tt> to <tt>'.$toNew.'</tt>'); 971 }else{ 972 //$done[1] = $done[1] && @unlink($fromNew); 973 } 974 if( strpos($fromNew,$tempRoot) === false){ 975 continue; 976 } 977 $test = str_replace($tempRoot,'',$fromNew); 978 if( isset($files[$test]) && isset($files[$test]['mode']) && $files[$test]['mode']){ 979 message('Change mode for file: <tt>'.$toNew.'</tt>'); 980 if(!@chmod($toNew,0666) ){ 981 $done[0] = false; 982 message('<b>Error:</b> Could not change the mode for file: <tt>'.$toNew.'</tt>.'); 983 } 984 } 985 } 986 } 987 closedir($dh); 988 }else{ 989 $done[0] = false; 990 message('Could not open the temporary directory: <tt>'.$from.'</tt>.'); 991 } 992 return $done; 993 } 994 995 996 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 997 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 998 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 999 // 1000 // Misc Functions 1001 // 1002 1003 function finishedNotice(){ 1004 ob_start(); 1005 ?> 1006 <h2>The Installation Script Has Finished...</h2> 1007 <ul> 1008 <li> <em>Don't forget to restore file modes if this script was unable to.</em></li> 1009 <li> The /Temporary directory is no longer needed and may be safely removed from the server. It's presence will not alter the performance of the software. 1010 <li> For more configurable options and information, login as the user "Main" and look at the "Configuration" page, accessible via the "Control Panel"</li> 1011 <li> Now, all that's left to do is to <a href="../">add some content</a>.</li> 1012 </ul> 1013 <br/> <p> Thanks for using wikyblog software. I hope it proves useful!</p> 1014 - Josh Schmidt 1015 <? 1016 1017 return ob_get_clean(); 1018 } 1019 1020 // this function is in multiple files 1021 // similar to functions in searchSearch.php, specPreferences.php 1022 function formSelect($name,$possible,$value=null){ 1023 $result = '<select name="'.$name.'">'; 1024 foreach($possible as $optionKey => $optionValue){ 1025 if($optionKey == $value){ 1026 $focus = ' selected '; 1027 }else{ 1028 $focus = ''; 1029 } 1030 if( is_numeric($optionKey) ){ 1031 $optionKey = ''; 1032 } 1033 $result .= '<option value="'.htmlspecialchars($optionKey).'" '.$focus.'>'.$optionValue.'</option>'; 1034 } 1035 $result .= '</select>'; 1036 return $result; 1037 } 1038 1039 function unHtmlspecialchars($text){ 1040 $search = array('"', '>', '<', ''', '&'); 1041 $repl = array('"', '>', '<', "'", '&'); 1042 return str_replace($search,$repl,$text); 1043 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |