| 1 | 2 | Manuela | <?php
 | 
      
        | 2 |  |  | /**
 | 
      
        | 3 |  |  |  *
 | 
      
        | 4 |  |  |  * @category        backend
 | 
      
        | 5 |  |  |  * @package         install
 | 
      
        | 6 |  |  |  * @author          WebsiteBaker Project
 | 
      
        | 7 |  |  |  * @copyright       WebsiteBaker Org. e.V.
 | 
      
        | 8 |  |  |  * @link            http://websitebaker.org/
 | 
      
        | 9 |  |  |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
      
        | 10 |  |  |  * @platform        WebsiteBaker 2.8.3
 | 
      
        | 11 |  |  |  * @requirements    PHP 5.3.6 and higher
 | 
      
        | 12 |  |  |  * @version         $Id$
 | 
      
        | 13 |  |  |  * @filesource      $HeadURL$
 | 
      
        | 14 |  |  |  * @lastmodified    $Date$
 | 
      
        | 15 |  |  |  *
 | 
      
        | 16 |  |  |  */
 | 
      
        | 17 |  |  | 
 | 
      
        | 18 | 4 | Manuela | //    $aNumber = str_split(strrev('ZZZZ'));
 | 
      
        | 19 |  |  | //    $aToBase = str_split('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
 | 
      
        | 20 |  |  | //    $iResult = 0;
 | 
      
        | 21 |  |  | //    for ($i = 0; $i < sizeof($aNumber); $i++) {
 | 
      
        | 22 |  |  | //        $iResult += array_search($aNumber[$i], $aToBase) * (sizeof($aToBase) ** $i);
 | 
      
        | 23 |  |  | //    }
 | 
      
        | 24 |  |  | 
 | 
      
        | 25 |  |  | /**
 | 
      
        | 26 |  |  |  * create a new 4-digit secure token
 | 
      
        | 27 |  |  |  * @return string
 | 
      
        | 28 |  |  |  */
 | 
      
        | 29 |  |  |     function getNewToken()
 | 
      
        | 30 |  |  |     {
 | 
      
        | 31 |  |  |         $aToBase = str_split('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
 | 
      
        | 32 |  |  |         $iToBaseLen = sizeof($aToBase);
 | 
      
        | 33 |  |  |         shuffle($aToBase);
 | 
      
        | 34 |  |  |         $iNumber = rand(238328, 14776335);
 | 
      
        | 35 |  |  |         $sRetval = '';
 | 
      
        | 36 |  |  |         while ($iNumber != 0) {
 | 
      
        | 37 |  |  |             $sRetval = $aToBase[($iNumber % $iToBaseLen)].$sRetval;
 | 
      
        | 38 |  |  |             $iNumber = intval($iNumber / $iToBaseLen);
 | 
      
        | 39 |  |  |         }
 | 
      
        | 40 |  |  |         return $sRetval;
 | 
      
        | 41 |  |  |     }
 | 
      
        | 42 |  |  | 
 | 
      
        | 43 |  |  | /**
 | 
      
        | 44 |  |  |  * highlight input fields which contain wrong/missing data
 | 
      
        | 45 |  |  |  * @param string $field_name
 | 
      
        | 46 |  |  |  * @return string
 | 
      
        | 47 |  |  |  */
 | 
      
        | 48 |  |  |     function field_error($field_name='') {
 | 
      
        | 49 |  |  |         if(!defined('SESSION_STARTED') || $field_name == '') return;
 | 
      
        | 50 |  |  |         if(isset($_SESSION['ERROR_FIELD']) && $_SESSION['ERROR_FIELD'] == $field_name) {
 | 
      
        | 51 |  |  |             return ' class="wrong"';
 | 
      
        | 52 |  |  |         }
 | 
      
        | 53 |  |  |     }
 | 
      
        | 54 |  |  | 
 | 
      
        | 55 | 2 | Manuela | // Start a session
 | 
      
        | 56 |  |  | if (version_compare(PHP_VERSION, '5.6', '<')) { die('Sorry, at last PHP-5.6 required !!'); }
 | 
      
        | 57 |  |  | if(!defined('SESSION_STARTED')) {
 | 
      
        | 58 |  |  |     session_name('wb-installer');
 | 
      
        | 59 |  |  |     session_start();
 | 
      
        | 60 |  |  |     define('SESSION_STARTED', true);
 | 
      
        | 61 |  |  | }
 | 
      
        | 62 |  |  | 
 | 
      
        | 63 |  |  | $mod_path = dirname(str_replace('\\', '/', __FILE__));
 | 
      
        | 64 |  |  | $doc_root = str_replace('\\','/',rtrim(realpath($_SERVER['DOCUMENT_ROOT']),'/'));
 | 
      
        | 65 |  |  | $mod_name = basename($mod_path);
 | 
      
        | 66 |  |  | $wb_path = str_replace('\\','/',dirname(dirname(realpath( __FILE__))));
 | 
      
        | 67 |  |  | if (!defined('WB_PATH')) { define('WB_PATH', $wb_path); }
 | 
      
        | 68 |  |  | $wb_root = str_replace($doc_root,'',$wb_path);
 | 
      
        | 69 |  |  | 
 | 
      
        | 70 |  |  | // begin new routine
 | 
      
        | 71 |  |  |     $sInstallFolderRel = dirname(dirname($_SERVER['SCRIPT_NAME']));
 | 
      
        | 72 |  |  |     $sProtokol = ((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off' ) ? 'http' : 'https') . '://';
 | 
      
        | 73 |  |  |     $sUrl = $sProtokol.$_SERVER['HTTP_HOST'].($_SERVER['SERVER_PORT'] == 80 ? '' : $_SERVER['SERVER_PORT'].':').$sInstallFolderRel;// end new routine
 | 
      
        | 74 |  |  |     $sScriptPath = str_replace('\\', '/', ($_SERVER['SCRIPT_FILENAME']));
 | 
      
        | 75 |  |  |     $sScriptUrl = $sUrl.str_replace($wb_path, '', $sScriptPath);
 | 
      
        | 76 |  |  | 
 | 
      
        | 77 |  |  | 
 | 
      
        | 78 |  |  | $installFlag = true;
 | 
      
        | 79 |  |  | // Check if the page has been reloaded
 | 
      
        | 80 |  |  | if(!isset($_GET['sessions_checked']) OR $_GET['sessions_checked'] != 'true') {
 | 
      
        | 81 |  |  |     // Set session variable
 | 
      
        | 82 |  |  |     $_SESSION['session_support'] = '<span class="good">Enabled</span>';
 | 
      
        | 83 |  |  |     // Reload page
 | 
      
        | 84 |  |  |     header('Location: index.php?sessions_checked=true');
 | 
      
        | 85 |  |  |     exit(0);
 | 
      
        | 86 |  |  | } else {
 | 
      
        | 87 |  |  |     // Check if session variable has been saved after reload
 | 
      
        | 88 |  |  |     if(isset($_SESSION['session_support'])) {
 | 
      
        | 89 |  |  |         $session_support = $_SESSION['session_support'];
 | 
      
        | 90 |  |  |     } else {
 | 
      
        | 91 |  |  |         $installFlag = false;
 | 
      
        | 92 |  |  |         $session_support = '<span class="bad">Disabled</span>';
 | 
      
        | 93 |  |  |     }
 | 
      
        | 94 |  |  | }
 | 
      
        | 95 | 4 | Manuela | // create security tokens
 | 
      
        | 96 |  |  |     $aToken = [getNewToken(), getNewToken()];
 | 
      
        | 97 |  |  |     $_SESSION['token'] = ['name' => $aToken[0], 'value' => $aToken[1]];
 | 
      
        | 98 | 2 | Manuela | // Check if AddDefaultCharset is set
 | 
      
        | 99 |  |  | $e_adc=false;
 | 
      
        | 100 |  |  | $sapi=php_sapi_name();
 | 
      
        | 101 |  |  | if(strpos($sapi, 'apache')!==FALSE || strpos($sapi, 'nsapi')!==FALSE) {
 | 
      
        | 102 |  |  |     flush();
 | 
      
        | 103 |  |  |     $apache_rheaders=apache_response_headers();
 | 
      
        | 104 |  |  |     foreach($apache_rheaders AS $h) {
 | 
      
        | 105 |  |  |         if(strpos($h, 'html; charset')!==FALSE) {
 | 
      
        | 106 |  |  |             preg_match('/charset\s*=\s*([a-zA-Z0-9- _]+)/', $h, $match);
 | 
      
        | 107 |  |  |             $apache_charset=$match[1];
 | 
      
        | 108 |  |  |             $e_adc=$apache_charset;
 | 
      
        | 109 |  |  |         }
 | 
      
        | 110 |  |  |     }
 | 
      
        | 111 |  |  | }
 | 
      
        | 112 |  |  | 
 | 
      
        | 113 |  |  | ?><!DOCTYPE HTML>
 | 
      
        | 114 |  |  | <html lang="de">
 | 
      
        | 115 |  |  | <head>
 | 
      
        | 116 |  |  | <meta charset="utf-8" />
 | 
      
        | 117 |  |  | <title>WebsiteBaker Installation Wizard</title>
 | 
      
        | 118 |  |  | <link href="stylesheet.css" rel="stylesheet" type="text/css" />
 | 
      
        | 119 |  |  | <script>
 | 
      
        | 120 | 4 | Manuela |     function confirm_link(message, url) {
 | 
      
        | 121 |  |  |         if(confirm(message)) location.href = url;
 | 
      
        | 122 | 2 | Manuela |     }
 | 
      
        | 123 | 4 | Manuela |     function change_os(type) {
 | 
      
        | 124 |  |  |         if(type == 'linux') {
 | 
      
        | 125 |  |  |             document.getElementById('operating_system_linux').checked = true;
 | 
      
        | 126 |  |  |             document.getElementById('operating_system_windows').checked = false;
 | 
      
        | 127 |  |  |             document.getElementById('file_perms_box').style.display = 'none';
 | 
      
        | 128 |  |  |         } else if(type == 'windows') {
 | 
      
        | 129 |  |  |             document.getElementById('operating_system_linux').checked = false;
 | 
      
        | 130 |  |  |             document.getElementById('operating_system_windows').checked = true;
 | 
      
        | 131 |  |  |             document.getElementById('file_perms_box').style.display = 'none';
 | 
      
        | 132 |  |  |         }
 | 
      
        | 133 |  |  |     }
 | 
      
        | 134 | 2 | Manuela | </script>
 | 
      
        | 135 |  |  | </head>
 | 
      
        | 136 |  |  | <body>
 | 
      
        | 137 |  |  | <div class="body">
 | 
      
        | 138 |  |  | <table>
 | 
      
        | 139 |  |  | <tbody>
 | 
      
        | 140 |  |  | <tr style="background: #a9c9ea;">
 | 
      
        | 141 |  |  |     <td valign="top">
 | 
      
        | 142 |  |  |         <img src="../templates/DefaultTheme/images/logo.png" alt="Logo" />
 | 
      
        | 143 |  |  |     </td>
 | 
      
        | 144 |  |  |     <td>
 | 
      
        | 145 |  |  |         <h1 style="border:none; margin-top:1em;font-size:150%;">Installation Wizard</h1>
 | 
      
        | 146 |  |  |     </td>
 | 
      
        | 147 |  |  | </tr>
 | 
      
        | 148 |  |  | </tbody>
 | 
      
        | 149 |  |  | </table>
 | 
      
        | 150 |  |  | 
 | 
      
        | 151 |  |  | <form name="website_baker_installation_wizard" action="save.php" method="post">
 | 
      
        | 152 |  |  |     <input type="hidden" name="url" value="" />
 | 
      
        | 153 |  |  |     <input type="hidden" name="username_fieldname" value="admin_username" />
 | 
      
        | 154 |  |  |     <input type="hidden" name="password_fieldname" value="admin_password" />
 | 
      
        | 155 |  |  |     <input type="hidden" name="remember" id="remember" value="true" />
 | 
      
        | 156 | 4 | Manuela |     <input type="hidden" name="<?php echo $aToken[0]; ?>" value="<?php echo $aToken[1]; ?>" />
 | 
      
        | 157 | 2 | Manuela |         <div class="welcome">
 | 
      
        | 158 |  |  |             Welcome to the WebsiteBaker Installation Wizard.
 | 
      
        | 159 |  |  |         </div>
 | 
      
        | 160 |  |  |         <?php
 | 
      
        | 161 |  |  |         if(isset($_SESSION['message']) AND $_SESSION['message'] != '') {
 | 
      
        | 162 |  |  |             ?><div  style="width: 700px; padding: 10px; margin-bottom: 5px; border: 1px solid #FF0000; background-color: #FFDBDB;"><b>Error:</b> <?php echo $_SESSION['message']; ?></div><?php
 | 
      
        | 163 |  |  |         }
 | 
      
        | 164 |  |  |         ?>
 | 
      
        | 165 |  |  |         <table>
 | 
      
        | 166 |  |  |         <thead>
 | 
      
        | 167 |  |  |         <tr>
 | 
      
        | 168 |  |  |             <th colspan="4" class="step-row"><h1 class="step-row">Step 1
 | 
      
        | 169 |  |  |             </h1> Please check the following requirements are met before continuing...
 | 
      
        | 170 |  |  |             </th>
 | 
      
        | 171 |  |  |         </tr>
 | 
      
        | 172 |  |  |         </thead>
 | 
      
        | 173 |  |  |         <tbody>
 | 
      
        | 174 |  |  |         <?php if($session_support != '<span class="good">Enabled</span>') { ?>
 | 
      
        | 175 |  |  |         <tr>
 | 
      
        | 176 |  |  |             <td colspan="6" class="error">Please note: PHP Session Support may appear disabled if your browser does not support cookies.</td>
 | 
      
        | 177 |  |  |         </tr>
 | 
      
        | 178 |  |  |         <?php } ?>
 | 
      
        | 179 |  |  |         <tr>
 | 
      
        | 180 |  |  |             <td style="color: #666666;">PHP Version >= 5.3.6</td>
 | 
      
        | 181 |  |  |             <td>
 | 
      
        | 182 |  |  |                 <?php
 | 
      
        | 183 |  |  |                if (version_compare(PHP_VERSION, '5.3.6', '>='))
 | 
      
        | 184 |  |  |                {
 | 
      
        | 185 |  |  |                     ?><span class="good"><?php echo PHP_VERSION;?></span><?php
 | 
      
        | 186 |  |  |                 } else {
 | 
      
        | 187 |  |  |                     $installFlag = false;
 | 
      
        | 188 |  |  |                     ?><span class="bad"><?php echo PHP_VERSION;?></span><?php
 | 
      
        | 189 |  |  |                 }
 | 
      
        | 190 |  |  |                 ?>
 | 
      
        | 191 |  |  |             </td>
 | 
      
        | 192 |  |  |             <td style="color: #666666;">PHP Session Support</td>
 | 
      
        | 193 |  |  |             <td><?php echo $session_support; ?></td>
 | 
      
        | 194 |  |  |         </tr>
 | 
      
        | 195 |  |  |     <tr>
 | 
      
        | 196 |  |  |         <td style="color: #666666;">Server DefaultCharset</td>
 | 
      
        | 197 |  |  |             <td>
 | 
      
        | 198 |  |  |                 <?php
 | 
      
        | 199 |  |  |                     $chrval = (($e_adc != '') && (strtolower($e_adc) != 'utf-8') ? true : false);
 | 
      
        | 200 |  |  |                     if($chrval == false) {
 | 
      
        | 201 |  |  |                         ?><span class="good">
 | 
      
        | 202 |  |  |                         <?php echo (($e_adc=='') ? 'OK' : $e_adc) ?>
 | 
      
        | 203 |  |  |                         </span>
 | 
      
        | 204 |  |  |                         <?php
 | 
      
        | 205 |  |  |                     } else {
 | 
      
        | 206 |  |  |                         ?><span class="bad"><?php echo $e_adc ?></span><?php
 | 
      
        | 207 |  |  |                     }
 | 
      
        | 208 |  |  | 
 | 
      
        | 209 |  |  |                 ?>
 | 
      
        | 210 |  |  |             </td>
 | 
      
        | 211 |  |  |             <td style="color: #666666;">PHP Safe Mode</td>
 | 
      
        | 212 |  |  |             <td>
 | 
      
        | 213 |  |  |                 <?php
 | 
      
        | 214 |  |  |                 if(ini_get('safe_mode')=='' || strpos(strtolower(ini_get('safe_mode')), 'off')!==FALSE || ini_get('safe_mode')==0) {
 | 
      
        | 215 |  |  |                     ?><span class="good">Disabled</span><?php
 | 
      
        | 216 |  |  |                 } else {
 | 
      
        | 217 |  |  |                     $installFlag = false;
 | 
      
        | 218 |  |  |                     ?><span class="bad">Enabled</span><?php
 | 
      
        | 219 |  |  |                 }
 | 
      
        | 220 |  |  |                 ?>
 | 
      
        | 221 |  |  |             </td>
 | 
      
        | 222 |  |  |         </tr>
 | 
      
        | 223 |  |  |         <?php if($chrval == true) {
 | 
      
        | 224 |  |  |         ?>
 | 
      
        | 225 |  |  |         <tr>
 | 
      
        | 226 |  |  |             <td colspan="6" style="font-size: 10px;" class="bad">
 | 
      
        | 227 |  |  | <p class="warning">
 | 
      
        | 228 |  |  | <b>Please note:</b> Yor webserver is configured to deliver <b><?php echo $e_adc;?></b> charset only.<br />
 | 
      
        | 229 |  |  | To display national special characters (e.g.: ä á) in clear manner, switch off this preset please(or let it do by your hosting provider).<br />
 | 
      
        | 230 |  |  | In any case you can choose <b><?php echo $e_adc;?></b> in the settings of WebsiteBaker.<br />
 | 
      
        | 231 |  |  | But this solution does not guarranty a correct displaying of the content from all modules!
 | 
      
        | 232 |  |  | </p>
 | 
      
        | 233 |  |  | </td>
 | 
      
        | 234 |  |  | </tr>
 | 
      
        | 235 |  |  | <?php } ?>
 | 
      
        | 236 |  |  | </tbody>
 | 
      
        | 237 |  |  | </table>
 | 
      
        | 238 |  |  | <table>
 | 
      
        | 239 |  |  | <thead>
 | 
      
        | 240 |  |  | <tr>
 | 
      
        | 241 |  |  |     <th colspan="4" class="step-row">
 | 
      
        | 242 |  |  |     <h1 class="step-row">Step 2</h1> Please check the following files/folders are writeable before continuing...
 | 
      
        | 243 |  |  |     </th>
 | 
      
        | 244 |  |  | </tr>
 | 
      
        | 245 |  |  | </thead>
 | 
      
        | 246 |  |  | <tbody>
 | 
      
        | 247 |  |  | <?php
 | 
      
        | 248 |  |  |     $config = '<span class="good">Writeable</span>';
 | 
      
        | 249 |  |  |     $config_content = "<?php\n";
 | 
      
        | 250 |  |  |     $configFile = '/config.php';
 | 
      
        | 251 |  |  |     if(!isset($_SESSION['config_rename']) )
 | 
      
        | 252 |  |  |     {
 | 
      
        | 253 |  |  | // cnfig.php or config.php.new
 | 
      
        | 254 |  |  |         if( (file_exists($wb_path.$configFile)==true))
 | 
      
        | 255 |  |  |         {
 | 
      
        | 256 |  |  | // next operation only if file is writeable
 | 
      
        | 257 |  |  |             if(is_writeable($wb_path.$configFile))
 | 
      
        | 258 |  |  |             {
 | 
      
        | 259 |  |  | // already installed? it's not empty
 | 
      
        | 260 |  |  |                 if ( filesize($wb_path.$configFile) > 128)
 | 
      
        | 261 |  |  |                 {
 | 
      
        | 262 |  |  |                     $installFlag = false;
 | 
      
        | 263 |  |  |                     $config = '<span class="bad">Not empty! WebsiteBaker already installed?</span>';
 | 
      
        | 264 |  |  | // try to open and to write
 | 
      
        | 265 |  |  |                 } elseif( !$handle = fopen($wb_path.$configFile, 'w') )
 | 
      
        | 266 |  |  |                 {
 | 
      
        | 267 |  |  |                     $installFlag = false;
 | 
      
        | 268 |  |  |                     $config = '<span class="bad">Not Writeable</span>';
 | 
      
        | 269 |  |  |                 } else {
 | 
      
        | 270 |  |  |                     if (fwrite($handle, $config_content) === FALSE) {
 | 
      
        | 271 |  |  |                         $installFlag = false;
 | 
      
        | 272 |  |  |                         $config = '<span class="bad">Not Writeable</span>';
 | 
      
        | 273 |  |  |                     } else {
 | 
      
        | 274 |  |  |                         $config = '<span class="good">Writeable</span>';
 | 
      
        | 275 |  |  |                         $_SESSION['config_rename'] = true;
 | 
      
        | 276 |  |  |                     }
 | 
      
        | 277 |  |  |                     // Close file
 | 
      
        | 278 |  |  |                     fclose($handle);
 | 
      
        | 279 |  |  |                     }
 | 
      
        | 280 |  |  |             } else {
 | 
      
        | 281 |  |  |                 $installFlag = false;
 | 
      
        | 282 |  |  |                 $config = '<span class="bad">Not Writeable</span>';
 | 
      
        | 283 |  |  |             }
 | 
      
        | 284 |  |  | // it's config.php.new
 | 
      
        | 285 |  |  |         } elseif((file_exists($wb_path.'/config.php.new')==true))
 | 
      
        | 286 |  |  |         {
 | 
      
        | 287 |  |  |             $configFile = '/config.php.new';
 | 
      
        | 288 |  |  |             $installFlag = false;
 | 
      
        | 289 |  |  |             $config = '<span class="bad">Please rename to config.php</span>';
 | 
      
        | 290 |  |  |         } else
 | 
      
        | 291 |  |  |         {
 | 
      
        | 292 |  |  |             $installFlag = false;
 | 
      
        | 293 |  |  |             $config = '<span class="bad">Missing!!?</span>';
 | 
      
        | 294 |  |  |         }
 | 
      
        | 295 |  |  |     }
 | 
      
        | 296 |  |  | ?>
 | 
      
        | 297 |  |  |         <tr>
 | 
      
        | 298 |  |  |             <td style="color: #666666;"><?php print $wb_root.$configFile ?></td>
 | 
      
        | 299 |  |  |             <td colspan="3"  ><?php echo $config ?></td>
 | 
      
        | 300 |  |  |         </tr>
 | 
      
        | 301 |  |  |         <tr>
 | 
      
        | 302 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/pages/</td>
 | 
      
        | 303 |  |  |             <td><?php if(is_writable('../pages/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../pages/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 304 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/media/</td>
 | 
      
        | 305 |  |  |             <td><?php if(is_writable('../media/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../media/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 306 |  |  |         </tr>
 | 
      
        | 307 |  |  |         <tr>
 | 
      
        | 308 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/templates/</td>
 | 
      
        | 309 |  |  |             <td><?php if(is_writable('../templates/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../templates/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 310 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/modules/</td>
 | 
      
        | 311 |  |  |             <td><?php if(is_writable('../modules/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../modules/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 312 |  |  |         </tr>
 | 
      
        | 313 |  |  |         <tr>
 | 
      
        | 314 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/languages/</td>
 | 
      
        | 315 |  |  |             <td><?php if(is_writable('../languages/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../languages/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 316 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/temp/</td>
 | 
      
        | 317 |  |  |             <td><?php if(is_writable('../temp/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../temp/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 318 |  |  |         </tr>
 | 
      
        | 319 |  |  |         <tr>
 | 
      
        | 320 |  |  |             <td style="color: #666666;"><?php print $wb_root ?>/var/</td>
 | 
      
        | 321 |  |  |             <td><?php if(is_writable('../var/')) { echo '<span class="good">Writeable</span>'; } elseif(!file_exists('../languages/')) {$installFlag = false; echo '<span class="bad">Directory Not Found</span>'; } else { echo '<span class="bad">Unwriteable</span>'; } ?></td>
 | 
      
        | 322 |  |  |             <td colspan="2"> </td>
 | 
      
        | 323 |  |  |         </tr>
 | 
      
        | 324 |  |  |         </tbody>
 | 
      
        | 325 |  |  |         </table>
 | 
      
        | 326 |  |  | <?php  if($installFlag == true) {     ?>
 | 
      
        | 327 |  |  |         <table>
 | 
      
        | 328 |  |  |             <thead>
 | 
      
        | 329 |  |  |         <tr>
 | 
      
        | 330 |  |  |             <th colspan="4" class="step-row">
 | 
      
        | 331 |  |  |             <h1 class="step-row">Step 3</h1> Please check URL settings, and select a default timezone and a default backend language...
 | 
      
        | 332 |  |  |             </th>
 | 
      
        | 333 |  |  |         </tr>
 | 
      
        | 334 |  |  |             </thead>
 | 
      
        | 335 |  |  |         <tbody>
 | 
      
        | 336 |  |  |         <tr>
 | 
      
        | 337 |  |  |             <td class="name">Absolute URL:</td>
 | 
      
        | 338 |  |  |             <td class="value">
 | 
      
        | 339 |  |  |                 <input <?php echo field_error('wb_url');?> type="text" tabindex="1" name="wb_url" style="width: 99%;" value="<?php if(isset($_SESSION['wb_url'])) { echo $_SESSION['wb_url']; } else { echo $sUrl; } ?>" />
 | 
      
        | 340 |  |  |             </td>
 | 
      
        | 341 |  |  |             <td colspan="4"> </td>
 | 
      
        | 342 |  |  |         </tr>
 | 
      
        | 343 |  |  |         <tr>
 | 
      
        | 344 |  |  |             <td class="name">Default Timezone:</td>
 | 
      
        | 345 |  |  |             <td class="value"><select <?php echo field_error('default_timezone');?> tabindex="3" name="default_timezone" style="width: 100%;">
 | 
      
        | 346 |  |  | <?php
 | 
      
        | 347 |  |  | /*
 | 
      
        | 348 |  |  |  build list of TimeZone options
 | 
      
        | 349 |  |  | */
 | 
      
        | 350 |  |  |     $aZones = array(-12,-11,-10,-9,-8,-7,-6,-5,-4,-3.5,-3,-2,-1,0,1,2,3,3.5,4,4.5,5,5.5,6,6.5,7,8,9,9.5,10,11,12,13);
 | 
      
        | 351 |  |  |     $sOutput = PHP_EOL;
 | 
      
        | 352 |  |  |     foreach($aZones as $fOffset) {
 | 
      
        | 353 |  |  |         $sItemTitle = 'GMT '.(($fOffset>0)?'+':'').(($fOffset==0)?'':(string)$fOffset.' Hours');
 | 
      
        | 354 |  |  |         $sOutput .= '<option value="'.(string)$fOffset.'"';
 | 
      
        | 355 |  |  |         if (
 | 
      
        | 356 |  |  |             (isset($_SESSION['default_timezone']) AND $_SESSION['default_timezone'] == (string)$fOffset) ||
 | 
      
        | 357 |  |  |             (!isset($_SESSION['default_timezone']) AND $fOffset == 0)
 | 
      
        | 358 |  |  |         ) {
 | 
      
        | 359 |  |  |             $sOutput .= ' selected="selected"';
 | 
      
        | 360 |  |  |         }
 | 
      
        | 361 |  |  |         $sOutput .= '>'.$sItemTitle.'</option>'.PHP_EOL;
 | 
      
        | 362 |  |  |     }
 | 
      
        | 363 |  |  | // output Timezone options
 | 
      
        | 364 |  |  |     echo $sOutput;
 | 
      
        | 365 |  |  | ?>
 | 
      
        | 366 |  |  |                 </select>
 | 
      
        | 367 |  |  |             </td>
 | 
      
        | 368 |  |  |         </tr>
 | 
      
        | 369 |  |  |         <tr>
 | 
      
        | 370 |  |  |             <td class="name">Default Language: </td>
 | 
      
        | 371 |  |  |             <td class="value">
 | 
      
        | 372 |  |  | <?php
 | 
      
        | 373 |  |  | /*
 | 
      
        | 374 |  |  |  Find all available languages in /language/ folder and build option list from
 | 
      
        | 375 |  |  | */
 | 
      
        | 376 |  |  | // -----
 | 
      
        | 377 |  |  |     $getLanguage = function($sFile) {
 | 
      
        | 378 |  |  |         $aRetval = null;
 | 
      
        | 379 |  |  |         $language_code = $language_name = '';
 | 
      
        | 380 |  |  |         include $sFile;
 | 
      
        | 381 |  |  |         if ($language_code && $language_name) {
 | 
      
        | 382 |  |  |             $aRetval = ['code' => $language_code, 'name' => $language_name];
 | 
      
        | 383 |  |  |         }
 | 
      
        | 384 |  |  |         return $aRetval;
 | 
      
        | 385 |  |  |     };
 | 
      
        | 386 |  |  | // -----
 | 
      
        | 387 |  |  |     $aMatches = [];
 | 
      
        | 388 |  |  |     $sDefaultLang = isset($_SESSION['default_language']) ? $_SESSION['default_language'] : 'EN';
 | 
      
        | 389 |  |  |     $sLangDir = str_replace('\\', '/', dirname(__DIR__).'/languages/');
 | 
      
        | 390 |  |  |     $sOldWorkingDir = getcwd();
 | 
      
        | 391 |  |  |     chdir($sLangDir);
 | 
      
        | 392 |  |  |     foreach(glob('??.php') as $sFilename) {
 | 
      
        | 393 |  |  |         if (preg_match('/[A-Z]{2}\.php$/s', $sFilename) && is_readable($sLangDir.$sFilename)) {
 | 
      
        | 394 |  |  |             if (!($aMatch = $getLanguage($sLangDir.$sFilename))) {
 | 
      
        | 395 |  |  |                 continue;
 | 
      
        | 396 |  |  |             }
 | 
      
        | 397 |  |  |             $aMatch['status'] = ($aMatch['code'] == $sDefaultLang);
 | 
      
        | 398 |  |  |             $aMatches[] = $aMatch;
 | 
      
        | 399 |  |  |         }
 | 
      
        | 400 |  |  |     }
 | 
      
        | 401 |  |  |     chdir($sOldWorkingDir);
 | 
      
        | 402 |  |  | // create HTML-output
 | 
      
        | 403 |  |  |     if (sizeof($aMatches) > 0) {
 | 
      
        | 404 |  |  |         $sOutput = '<select '.field_error('default_language').' tabindex="3" name="default_language" style="width: 100%;">'.PHP_EOL;
 | 
      
        | 405 |  |  |         foreach ($aMatches as $aMatch) {
 | 
      
        | 406 |  |  |             $sOutput .= '<option value="'.$aMatch['code'].'" '
 | 
      
        | 407 |  |  |                       . ($aMatch['status'] ? 'selected="selected"' : '').'>'
 | 
      
        | 408 |  |  |                       . $aMatch['name'].'</option>'.PHP_EOL;
 | 
      
        | 409 |  |  |         }
 | 
      
        | 410 |  |  |         $sOutput .= '</select>'.PHP_EOL;
 | 
      
        | 411 |  |  | // output HTML
 | 
      
        | 412 |  |  |         echo $sOutput;
 | 
      
        | 413 |  |  |         unset($sOutput);
 | 
      
        | 414 |  |  |     } else {
 | 
      
        | 415 |  |  |         echo 'WARNING: No language definition files available!!!';
 | 
      
        | 416 |  |  |         $installFlag = false;
 | 
      
        | 417 |  |  |     }
 | 
      
        | 418 |  |  |     unset($aMatches, $aMatch, $getLanguage);
 | 
      
        | 419 |  |  | ?>
 | 
      
        | 420 |  |  |             </td>
 | 
      
        | 421 |  |  |             <td colspan="4"> </td>
 | 
      
        | 422 |  |  |         </tr>
 | 
      
        | 423 |  |  |       </tbody>
 | 
      
        | 424 |  |  |         </table>
 | 
      
        | 425 |  |  | 
 | 
      
        | 426 |  |  |         <table>
 | 
      
        | 427 |  |  |             <thead>
 | 
      
        | 428 |  |  |         <tr>
 | 
      
        | 429 |  |  |             <th class="step-row" colspan="4">
 | 
      
        | 430 |  |  |             <h1 class="step-row">Step 4</h1> Please specify your operating system information below...
 | 
      
        | 431 |  |  |             </th>
 | 
      
        | 432 |  |  |         </tr>
 | 
      
        | 433 |  |  |             </thead>
 | 
      
        | 434 |  |  |       <tbody>
 | 
      
        | 435 |  |  |         <tr>
 | 
      
        | 436 |  |  |             <td class="name">Server Operating System: </td>
 | 
      
        | 437 |  |  |             <td style="">
 | 
      
        | 438 |  |  |                 <input type="radio" tabindex="4" name="operating_system" id="operating_system_linux" onclick="document.getElementById('file_perms_box').style.display = 'none';" value="linux"<?php if(!isset($_SESSION['operating_system']) OR $_SESSION['operating_system'] == 'linux') { echo ' checked="checked"'; } ?> />
 | 
      
        | 439 |  |  |                 <span style="cursor: pointer;" onclick="javascript: change_os('linux');">Linux/Unix based</span>
 | 
      
        | 440 |  |  |                 <br />
 | 
      
        | 441 |  |  |                 <input type="radio" tabindex="5" name="operating_system" id="operating_system_windows" onclick="document.getElementById('file_perms_box').style.display = 'none';" value="windows"<?php if(isset($_SESSION['operating_system']) AND $_SESSION['operating_system'] == 'windows') { echo ' checked="checked"'; } ?> />
 | 
      
        | 442 |  |  |                 <span style="cursor: pointer;" onclick="javascript: change_os('windows');">Windows</span>
 | 
      
        | 443 |  |  |             </td>
 | 
      
        | 444 |  |  |         </tr>
 | 
      
        | 445 |  |  |         <tr>
 | 
      
        | 446 |  |  |             <td class="name"> </td>
 | 
      
        | 447 |  |  |             <td class="value">
 | 
      
        | 448 |  |  |                 <div id="file_perms_box" style="line-height:2em; position: relative; width: 100%;float:left; margin: 0; padding: 0; display: <?php if(isset($_SESSION['operating_system']) AND $_SESSION['operating_system'] == 'windows') { echo 'none'; } else { echo 'none'; } ?>;">
 | 
      
        | 449 |  |  |                     <input type="checkbox" tabindex="6" name="world_writeable" id="world_writeable" value="true"<?php if(isset($_SESSION['world_writeable']) AND $_SESSION['world_writeable'] == true) { echo ' checked="checked'; } ?> />
 | 
      
        | 450 |  |  |                      <label style=" margin: 0;  " for="world_writeable">
 | 
      
        | 451 |  |  |                         World-writeable file permissions (777)
 | 
      
        | 452 |  |  |                     </label>
 | 
      
        | 453 |  |  |                 <br />
 | 
      
        | 454 |  |  |                     <p class="warning">(Please note: only recommended for testing environments)</p>
 | 
      
        | 455 |  |  |                 </div>
 | 
      
        | 456 |  |  |             </td>
 | 
      
        | 457 |  |  |         </tr>
 | 
      
        | 458 |  |  |         </tbody>
 | 
      
        | 459 |  |  |         </table>
 | 
      
        | 460 |  |  |         <table>
 | 
      
        | 461 |  |  |             <thead>
 | 
      
        | 462 |  |  |             <tr>
 | 
      
        | 463 |  |  |                 <th colspan="4" class="step-row">
 | 
      
        | 464 |  |  |                 <h1 class="step-row">Step 5</h1> Please enter your MySQL database server details below...
 | 
      
        | 465 |  |  |                 </th>
 | 
      
        | 466 |  |  |             </tr>
 | 
      
        | 467 |  |  |             </thead>
 | 
      
        | 468 |  |  |           <tbody>
 | 
      
        | 469 |  |  |             <tr>
 | 
      
        | 470 |  |  |                 <td class="name">Host Name</td>
 | 
      
        | 471 |  |  |                 <td class="value">
 | 
      
        | 472 |  |  |                     <input <?php echo field_error('database_host');?> type="text" tabindex="7" name="database_host" value="<?php if(isset($_SESSION['database_host'])) { echo $_SESSION['database_host']; } else { echo 'localhost'; } ?>" />
 | 
      
        | 473 |  |  |                 </td>
 | 
      
        | 474 |  |  |             </tr>
 | 
      
        | 475 |  |  |             <tr>
 | 
      
        | 476 |  |  |                 <td class="name">Database Name: </td>
 | 
      
        | 477 |  |  |                 <td class="value" style="white-space: nowrap;">
 | 
      
        | 478 |  |  |                     <input <?php echo field_error('database_name')?> type="text" tabindex="8" name="database_name" value="<?php if(isset($_SESSION['database_name'])) { echo $_SESSION['database_name']; } else { echo 'DatabaseName'; } ?>" />
 | 
      
        | 479 |  |  |                 <span style="display: inline;"> ([a-zA-Z0-9_-])</span>
 | 
      
        | 480 |  |  |                 </td>
 | 
      
        | 481 |  |  |             </tr>
 | 
      
        | 482 |  |  |         <tr>
 | 
      
        | 483 |  |  |             <td class="name">Table Prefix: </td>
 | 
      
        | 484 |  |  |             <td class="value" style="white-space: nowrap;">
 | 
      
        | 485 |  |  |                 <input <?php echo field_error('table_prefix')?> type="text" tabindex="9" name="table_prefix" value="<?php if(isset($_SESSION['table_prefix'])) { echo $_SESSION['table_prefix']; } else { echo 'wb_'; } ?>" />
 | 
      
        | 486 |  |  |                 <span style="display: inline;"> ([a-zA-Z0-9_])</span>
 | 
      
        | 487 |  |  |             </td>
 | 
      
        | 488 |  |  |         </tr>
 | 
      
        | 489 |  |  |         <tr>
 | 
      
        | 490 |  |  |                 <td class="name">Username:</td>
 | 
      
        | 491 |  |  |                 <td class="value">
 | 
      
        | 492 |  |  |                     <input <?php echo field_error('database_username');?> type="text" tabindex="10" name="database_username" value="<?php if(isset($_SESSION['database_username'])) { echo $_SESSION['database_username']; } else { echo 'root'; } ?>" />
 | 
      
        | 493 |  |  |                 </td>
 | 
      
        | 494 |  |  |         </tr>
 | 
      
        | 495 |  |  |         <tr>
 | 
      
        | 496 |  |  |                 <td class="name">Password:</td>
 | 
      
        | 497 |  |  |                 <td class="value">
 | 
      
        | 498 |  |  |                     <input type="password" tabindex="11" name="database_password" value="<?php if(isset($_SESSION['database_password'])) { echo $_SESSION['database_password']; } ?>" />
 | 
      
        | 499 |  |  |                 </td>
 | 
      
        | 500 |  |  |         </tr>
 | 
      
        | 501 |  |  |         <tr>
 | 
      
        | 502 |  |  |             <td class="name hide" colspan="2">
 | 
      
        | 503 |  |  |                 <input type="checkbox" tabindex="12" name="install_tables" id="install_tables" value="true"<?php if(!isset($_SESSION['install_tables'])) { echo ' checked="checked"'; } elseif($_SESSION['install_tables'] == 'true') { echo ' checked="checked"'; } ?> />
 | 
      
        | 504 |  |  |                 <label for="install_tables" style="color: #666666;">Install Tables</label>
 | 
      
        | 505 |  |  |                 <br />
 | 
      
        | 506 |  |  |                 <span style="font-size: 1px; color: #666666;">(Please note: May remove existing tables and data)</span>
 | 
      
        | 507 |  |  |             </td>
 | 
      
        | 508 |  |  |         </tr>
 | 
      
        | 509 |  |  |         </tbody>
 | 
      
        | 510 |  |  |         </table>
 | 
      
        | 511 |  |  |         <table>
 | 
      
        | 512 |  |  |         <thead>
 | 
      
        | 513 |  |  |         <tr>
 | 
      
        | 514 |  |  |             <th colspan="4" class="step-row">
 | 
      
        | 515 |  |  |             <h1 class="step-row">Step 6</h1> Please enter your website title below...
 | 
      
        | 516 |  |  |             </th>
 | 
      
        | 517 |  |  |         </tr>
 | 
      
        | 518 |  |  |         </thead>
 | 
      
        | 519 |  |  |         <tbody>
 | 
      
        | 520 |  |  |         <tr>
 | 
      
        | 521 |  |  |             <td class="name">Website Title:</td>
 | 
      
        | 522 |  |  |             <td class="value">
 | 
      
        | 523 |  |  |                 <input <?php echo field_error('website_title');?> type="text" tabindex="13" name="website_title" value="<?php if(isset($_SESSION['website_title'])) { echo $_SESSION['website_title']; } else { echo 'Enter your website title'; } ?>" />
 | 
      
        | 524 |  |  |             </td>
 | 
      
        | 525 |  |  |         </tr>
 | 
      
        | 526 |  |  |         </tbody>
 | 
      
        | 527 |  |  |         </table>
 | 
      
        | 528 |  |  |         <table>
 | 
      
        | 529 |  |  |         <thead>
 | 
      
        | 530 |  |  |         <tr>
 | 
      
        | 531 |  |  |             <th colspan="4" class="step-row">
 | 
      
        | 532 |  |  |             <h1 class="step-row">Step 7</h1> Please enter your Administrator account details below...
 | 
      
        | 533 |  |  |             </th>
 | 
      
        | 534 |  |  |         </tr>
 | 
      
        | 535 |  |  |         </thead>
 | 
      
        | 536 |  |  |         <tbody>
 | 
      
        | 537 |  |  |         <tr>
 | 
      
        | 538 |  |  |             <td class="name">Loginname:</td>
 | 
      
        | 539 |  |  |             <td class="value">
 | 
      
        | 540 |  |  |                 <input <?php echo field_error('admin_username');?> type="text" tabindex="14" name="admin_username" value="<?php if(isset($_SESSION['admin_username'])) { echo $_SESSION['admin_username']; } else { echo 'admin'; } ?>" />
 | 
      
        | 541 |  |  |             </td>
 | 
      
        | 542 |  |  |         </tr>
 | 
      
        | 543 |  |  |         <tr>
 | 
      
        | 544 |  |  |             <td class="name">Email:</td>
 | 
      
        | 545 |  |  |             <td class="value">
 | 
      
        | 546 |  |  |                 <input <?php echo field_error('admin_email');?> type="text" tabindex="15" name="admin_email" value="<?php if(isset($_SESSION['admin_email'])) { echo $_SESSION['admin_email']; } ?>" />
 | 
      
        | 547 |  |  |             </td>
 | 
      
        | 548 |  |  |         </tr>
 | 
      
        | 549 |  |  |         <tr>
 | 
      
        | 550 |  |  |             <td class="name">Password:</td>
 | 
      
        | 551 |  |  |             <td class="value">
 | 
      
        | 552 |  |  |                 <input <?php echo field_error('admin_password');?> type="password" tabindex="16" name="admin_password" value="" />
 | 
      
        | 553 |  |  |             </td>
 | 
      
        | 554 |  |  |         </tr>
 | 
      
        | 555 |  |  |         <tr>
 | 
      
        | 556 |  |  |             <td class="name">Re-Password:</td>
 | 
      
        | 557 |  |  |             <td class="value">
 | 
      
        | 558 |  |  |                 <input <?php echo field_error('admin_repassword');?> type="password" tabindex="17" name="admin_repassword" value=""  />
 | 
      
        | 559 |  |  |             </td>
 | 
      
        | 560 |  |  |         </tr>
 | 
      
        | 561 |  |  |         </tbody>
 | 
      
        | 562 |  |  |         </table>
 | 
      
        | 563 |  |  | <?php  }    ?>
 | 
      
        | 564 |  |  |         <table>
 | 
      
        | 565 |  |  |         <tbody>
 | 
      
        | 566 |  |  |                 <tr valign="top">
 | 
      
        | 567 |  |  |                     <td><strong>Please note:  </strong></td>
 | 
      
        | 568 |  |  |                 </tr>
 | 
      
        | 569 |  |  |                 <tr valign="top">
 | 
      
        | 570 |  |  |                     <td>
 | 
      
        | 571 |  |  |                         <p class="warning">
 | 
      
        | 572 |  |  |                         WebsiteBaker is released under the
 | 
      
        | 573 |  |  |                         <a href="http://www.gnu.org/licenses/gpl.html" target="_blank" tabindex="19">GNU General Public License</a>
 | 
      
        | 574 |  |  |                         <br />
 | 
      
        | 575 |  |  |                         By clicking install, you are accepting the license.
 | 
      
        | 576 |  |  |                         </p>
 | 
      
        | 577 |  |  |                     </td>
 | 
      
        | 578 |  |  |                 </tr>
 | 
      
        | 579 |  |  |                 <tr valign="top">
 | 
      
        | 580 |  |  |             <td>
 | 
      
        | 581 |  |  |             <p class="center">
 | 
      
        | 582 |  |  |                 <?php if($installFlag == true) { ?>
 | 
      
        | 583 |  |  |                 <input type="submit" tabindex="20" name="install" value="Install WebsiteBaker" />
 | 
      
        | 584 |  |  |                 <?php } else { ?>
 | 
      
        | 585 |  |  |                 <input type="button" tabindex="20" name="restart" value="Check your Settings in Step1 or Step2" class="submit" onclick="window.location = '<?php print $sScriptUrl ?>';" />
 | 
      
        | 586 |  |  |                 <?php } ?>
 | 
      
        | 587 |  |  |             </p>
 | 
      
        | 588 |  |  |             </td>
 | 
      
        | 589 |  |  |         </tr>
 | 
      
        | 590 |  |  |         </tbody>
 | 
      
        | 591 |  |  |         </table>
 | 
      
        | 592 |  |  | 
 | 
      
        | 593 |  |  | </form>
 | 
      
        | 594 |  |  | </div>
 | 
      
        | 595 |  |  | 
 | 
      
        | 596 |  |  | <div style="margin: 0 0 3em; padding: 0; text-align:center;">
 | 
      
        | 597 |  |  |     <!-- Please note: the below reference to the GNU GPL should not be removed, as it provides a link for users to read about warranty, etc. -->
 | 
      
        | 598 |  |  |     <a href="http://www.websitebaker.org/" style="color: #000000;" target="_blank">WebsiteBaker</a>
 | 
      
        | 599 |  |  |     is    released under the
 | 
      
        | 600 |  |  |     <a href="http://www.gnu.org/licenses/gpl.html" style="color: #000000;" target="_blank">GNU General Public License</a>
 | 
      
        | 601 |  |  |     <!-- Please note: the above reference to the GNU GPL should not be removed, as it provides a link for users to read about warranty, etc. -->
 | 
      
        | 602 |  |  | </div >
 | 
      
        | 603 |  |  | 
 | 
      
        | 604 |  |  | </body>
 | 
      
        | 605 |  |  | </html>
 |