[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/install/ -> setup_check.php (source)

   1  <?php // $Id: vw_idx_check.php,v 1.8.8.2 2007/02/26 21:04:48 merlinyoda Exp $
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  global $cfgDir, $cfgFile, $failedImg, $filesDir, $locEnDir, $okImg, $tblwidth, $tmpDir;
   7  
   8  $failedImg = str_replace('./style/', '../style/', w2PshowImage('stock_cancel-16.png', 16, 16, 'Failed'));
   9  $okImg = str_replace('./style/', '../style/', w2PshowImage('stock_ok-16.png', 16, 16, 'OK'));
  10  $cfgDir = W2P_BASE_DIR . '/includes';
  11  $cfgFile = W2P_BASE_DIR . '/includes/config.php';
  12  $filesDir = W2P_BASE_DIR . '/files';
  13  $locEnDir = W2P_BASE_DIR . '/locales/en';
  14  $tmpDir = W2P_BASE_DIR . '/files/temp';
  15  $tblwidth = '75%';
  16  $chmod = 0777;
  17  
  18  $maxfileuploadsize = min(w2PgetIniSize(ini_get('upload_max_filesize')), w2PgetIniSize(ini_get('post_max_size')));
  19  $memory_limit = w2PgetIniSize(ini_get('memory_limit'));
  20  if ($memory_limit > 0 && $memory_limit < $maxfileuploadsize) {
  21      $maxfileuploadsize = $memory_limit;
  22  }
  23  // Convert back to human readable numbers
  24  if ($maxfileuploadsize > 1048576) {
  25      $maxfileuploadsize = (int)($maxfileuploadsize / 1048576) . 'M';
  26  } elseif ($maxfileuploadsize > 1024) {
  27      $maxfileuploadsize = (int)($maxfileuploadsize / 1024) . 'K';
  28  }
  29  
  30  $info = array();
  31  $fatal = array();
  32  $warnings = array();
  33  if (version_compare(phpversion(), '4.1', '<')) {
  34      $info['phpversion'] = '<b class="error">' . $failedImg . ' (' . phpversion() . '): webProject will not work. Please upgrade PHP!</b>';
  35      $fatal[] = '<b class="error">' . $failedImg . ' PHP Version (' . phpversion() . '): webProject will not work. Please upgrade PHP!</b>';
  36  } else {
  37      $info['phpversion'] = '<b class="ok">' . $okImg . '</b><span class="item"> (' . phpversion() . ')</span>';
  38  }
  39  
  40  if (php_sapi_name() != 'cgi') {
  41      $info['cgi'] = '<b class="ok">' . $okImg . '</b><span class="item"> (' . php_sapi_name() . ')</span>';
  42  } else {
  43      $info['cgi'] = '<b class="error">' . $failedImg . ' CGI mode is likely to have problems</b>';
  44      $warnings[] = 'CGI mode is likely to have problems';
  45  }
  46  
  47  if (extension_loaded('gd')) {
  48      $info['gd'] = '<b class="ok">' . $okImg . '</b>';
  49  } else {
  50      $info['gd'] = '<b class="error">' . $failedImg . '</b> GANTT Chart functionality may not work correctly.';
  51      $warnings[] = 'GD library is missing. GANTT Chart functionality may not work correctly.';
  52  }
  53  
  54  if (extension_loaded('zlib')) {
  55      $info['zlib'] = '<b class="ok">' . $okImg . '</b>';
  56  } else { 
  57      $info['zlib'] = '<b class="error">' . $failedImg . '</b> Some non-core modules such as Backup may have restricted operation.';
  58      $warnings[] = 'No Zlib support. Some non-core modules such as Backup may have restricted operation.';
  59  }
  60  
  61  if (ini_get('file_uploads')) {
  62      $info['uploads'] = '<b class="ok">' . $okImg . '</b><span class="item"> (Max File Upload Size: ' . $maxfileuploadsize . ')</span>';
  63  } else {
  64      $info['uploads'] = '<b class="error">' . $failedImg . '</b><span class="warning"> Upload functionality will not be available</span>';
  65      $warnings[] = 'File Upload functionality will not be available';
  66  }
  67  
  68  if (!function_exists('mysql_connect')) {
  69      $fatal[] = '<b class="error">' . $failedImg . ' Mysql is not available!</b>';
  70  }
  71  if (!is_writable($cfgFile) || !is_writable($cfgDir)) {
  72      $fatal[] = '<b class="error">' . $failedImg . ' It is not possible to write to /includes or includes/config.php is not writeable!</b>';
  73  }
  74  if (!is_writable($filesDir)) {
  75      $warnings[] = 'File Upload may not work because the Files folder is not writeable!';
  76  }
  77  if (!is_writable($tmpDir)) {
  78      $warnings[] = 'PDFs may not render because the Files Temp folder is not writeable!';
  79  }
  80  if (!is_writable($locEnDir)) {
  81      $warnings[] = 'Translation Management service may not work properly because the Locales en folder is not writeable!';
  82  }
  83  if (ini_get('safe_mode')) {
  84      $warnings[] = 'PHP Safe Mode is on. You may have problems with File Uploads and Gantt Charts!';
  85  }
  86  if (ini_get('register_globals')) {
  87      $warnings[] = 'Though web2Project is protected against PHP Register Globals attacks you may want to turn it off for extra safety.';
  88  }
  89  if (ini_get('session.use_trans_sid')) {
  90      $warnings[] = 'PHP Use Trans Sid is ON. You should turn it off to avoid session hijacking!';
  91  }
  92  ?>
  93  
  94  <table class="text" style="background-color:#FFFFFF;" cellspacing="0" cellpadding="3" border="0" width="<?php echo $tblwidth; ?>" align="center">
  95  <tr>
  96      <td width="18"><?php echo str_replace('./style/', '../style/', w2PshowImage('log-info.gif', 16, 16, 'System Information')); ?></td> 
  97      <td width="100%"><a onclick="expand_collapse('sysinfo')" style="display: block;" name="fp" href="javascript: void(0);">
  98          <b>System Information</b>&nbsp;<font size="1">(show|hide)</font></a>
  99      </td>
 100      <td width="12" align="right" colspan="1">
 101  <?php
 102      echo '<a href="javascript: void(0);" name="fbt" style="display:block" onclick="expand_collapse(\'sysinfo\');">';
 103      echo '<img id="sysinfo_expand" src="' . str_replace('./style/', '../style/', w2PfindImage('icons/expand.gif')) . '" width="12" height="12" border="0" style="display:"><img id="sysinfo_collapse" src="' . str_replace('./style/', '../style/', w2PfindImage('icons/collapse.gif')) . '" width="12" height="12" border="0" style="display:none"></a>';
 104  ?>
 105      </td>
 106  </tr>
 107  <tr id="sysinfo" style="visibility: collapse; display: none;">
 108      <td colspan="3">
 109          <table width="100%" cellspacing="0" cellpadding="0" border="0" class="tbl" width="<?php echo $tblwidth; ?>" align="left">
 110          <tr>
 111              <td class="title" colspan="2">PHP Requirements</td>
 112          </tr>
 113          <tr>
 114              <td>PHP Version &gt;= 4.1</td>
 115              <td align="left"><?php echo $info['phpversion']; ?></td>
 116          </tr>
 117          <tr>
 118              <td>Server API</td>
 119              <td align="left"><?php echo $info['cgi']; ?></td>
 120          </tr>
 121          <tr>
 122              <td nowrap="nowrap">GD Support (for GANTT Charts)</td>
 123              <td align="left"><?php echo $info['gd']; ?></td>
 124          </tr>
 125          <tr>
 126              <td>Zlib compression Support</td>
 127              <td align="left"><?php echo $info['zlib']; ?></td>
 128          </tr>
 129          <tr>
 130              <td>File Uploads</td>
 131              <td align="left"><?php echo $info['uploads']; ?></td>
 132          </tr>
 133          <tr>
 134              <td>Session Save Path writable?</td>
 135              <td align="left">
 136          <?php
 137          $sspath = ini_get('session.save_path');
 138          if (!$sspath) {
 139              echo "<b class='error'>$failedImg Fatal:</b> <span class='item'>session.save_path</span> <b class='error'> is not set</b>";
 140          } elseif (is_dir($sspath) && is_writable($sspath)) {
 141              echo "<b class='ok'>$okImg</b> <span class='item'>($sspath)</span>";
 142          } else {
 143              echo "<b class='error'>$failedImg Fatal:</b> <span class='item'>$sspath</span><b class='error'> not existing or not writable</b>";
 144          }
 145          ?>
 146              </td>
 147          </tr>
 148          <tr>
 149              <td colspan="2">&nbsp;</td>
 150          </tr>
 151          <tr>
 152              <td class="title" colspan="2">Database Connectors</td>
 153          </tr>
 154          <tr>
 155              <td class="item" colspan="2">The next tests check for database support compiled with php. We use the ADODB database abstraction layer which comes with drivers for
 156              many databases. Consult the ADODB documentation for details.<br />For the moment only MySQL is fully supported, so you need to make sure it
 157              is available.</td>
 158          </tr>
 159          <tr>
 160              <td>iBase Support</td>
 161              <td align="left"><?php echo (function_exists('ibase_connect') && function_exists('ibase_server_info')) ? '<b class="ok">' . $okImg . '</b><span class="item"> (' . @ibase_server_info() . ')</span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 162          </tr>
 163          <tr>
 164              <td>LDAP Support</td>
 165              <td align="left"><?php echo function_exists('ldap_connect') ? '<b class="ok">' . $okImg . '</b><span class="item"> </span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 166          </tr>
 167          <tr>
 168              <td>MSSQL Server Support</td>
 169              <td align="left"><?php echo function_exists('mssql_connect') ? '<b class="ok">' . $okImg . '</b><span class="item"></span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 170          </tr>
 171          <tr>
 172              <td>MySQL Support</td>
 173              <td align="left"><?php echo function_exists('mysql_connect') ? '<b class="ok">' . $okImg . '</b><span class="item"> (' . @mysql_get_server_info() . ')</span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 174          </tr>
 175          <tr>
 176              <td>ODBC Support</td>
 177              <td align="left"><?php echo function_exists('odbc_connect') ? '<b class="ok">' . $okImg . '</b><span class="item"></span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 178          </tr>
 179          <tr>
 180              <td>Oracle Support</td>
 181              <td align="left"><?php echo function_exists('oci_connect') ? '<b class="ok">' . $okImg . '</b><span class="item"> (' . @ociserverversion() . ')</span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 182          </tr>
 183          <tr>
 184              <td>PostgreSQL Support</td>
 185              <td align="left"><?php echo function_exists('pg_connect') ? '<b class="ok">' . $okImg . '</b><span class="item"></span>' : '<span class="warning">' . $failedImg . ' Not available</span>'; ?></td>
 186          </tr>
 187          <tr>
 188              <td colspan="2">&nbsp;</td>
 189          </tr>
 190          <tr>
 191              <td class="title" colspan="2">Check for Directory and File Permissions</td>
 192          </tr>
 193          <tr>
 194              <td class="item" colspan="2">If the message 'World Writable' appears after a file/directory, then Permissions for this File have been set to allow all users to write to this file/directory.
 195              Consider changing this to a more restrictive setting to improve security. You will need to do this manually.</td>
 196          </tr>
 197          <?php
 198          $okMessage = '';
 199          if ((file_exists($cfgFile) && !is_writable($cfgFile)) || (!file_exists($cfgFile) && !(is_writable($cfgDir)))) {
 200          
 201              @chmod($cfgFile, $chmod);
 202              @chmod($cfgDir, $chmod);
 203              $filemode = @fileperms($cfgFile);
 204              if ($filemode & 2) {
 205                  $okMessage = '<span class="error"> World Writable</span>';
 206              }
 207          
 208          }
 209          ?>
 210          <tr>
 211              <td>./includes/config.php writable?</td>
 212              <td align="left"><?php echo (is_writable($cfgFile) || is_writable($cfgDir)) ? '<b class="ok">' . $okImg . '</b>' . $okMessage : '<b class="error">' . $failedImg . '</b><span class="warning"> Configuration process can still be continued. Configuration file will be displayed at the end, just copy & paste this and upload.</span>'; ?></td>
 213          </tr>
 214          <?php
 215          $okMessage = "";
 216          if (!is_writable($filesDir)) {
 217              @chmod($filesDir, $chmod);
 218          }
 219          $filemode = @fileperms($filesDir);
 220          if ($filemode & 2) {
 221              $okMessage = '<span class="error"> World Writable</span>';
 222          }
 223          ?>
 224          <tr>
 225              <td>./files writable?</td>
 226              <td align="left"><?php echo is_writable($filesDir) ? '<b class="ok">' . $okImg . '</b>' . $okMessage : '<b class="error">' . $failedImg . '</b><span class="warning"> File upload functionality will be disabled</span>'; ?></td>
 227          </tr>
 228          <?php
 229          $okMessage = "";
 230          if (!is_writable($tmpDir))
 231              @chmod($tmpDir, $chmod);
 232          
 233          $filemode = @fileperms($tmpDir);
 234          if ($filemode & 2) {
 235              $okMessage = '<span class="error"> World Writable</span>';
 236          }
 237          ?>
 238          <tr>
 239              <td>./files/temp writable?</td>
 240              <td align="left"><?php echo is_writable($tmpDir) ? '<b class="ok">' . $okImg . '</b>' . $okMessage : '<b class="error">' . $failedImg . '</b><span class="warning"> PDF report generation will be disabled</span>'; ?></td>
 241          </tr>
 242          <?php
 243          $okMessage = "";
 244          if (!is_writable($locEnDir)) {
 245              @chmod($locEnDir, $chmod);
 246          }
 247          $filemode = @fileperms($locEnDir);
 248          if ($filemode & 2) {
 249              $okMessage = '<span class="error"> World Writable</span>';
 250          }
 251          ?>
 252          <tr>
 253              <td>./locales/en writable?</td>
 254              <td align="left"><?php echo is_writable($locEnDir) ? '<b class="ok">' . $okImg . '</b>' . $okMessage : '<b class="error">' . $failedImg . '</b><span class="warning"> Translation files cannot be saved. Check /locales and subdirectories for permissions.</span>'; ?></td>
 255          </tr>
 256          <tr>
 257              <td colspan="2">&nbsp;</td>
 258          </tr>
 259          <tr>
 260              <td class="title" colspan="2">Recommended PHP Settings</td>
 261          </tr>
 262          <tr>
 263              <td>Safe Mode = OFF?</td>
 264              <td align="left"><?php echo !ini_get('safe_mode') ? '<b class="ok">' . $okImg . '</b>' : '<b class="error">' . $failedImg . '</b><span class="warning"></span>'; ?></td>
 265          </tr>
 266          <tr>
 267              <td>Register Globals = OFF?</td>
 268              <td align="left"><?php echo !ini_get('register_globals') ? '<b class="ok">' . $okImg . '</b>' : '<b class="error">' . $failedImg . '</b><span class="warning"> There are security risks with this turned ON</span>'; ?></td>
 269          </tr>
 270          <tr>
 271              <td>Session AutoStart = ON?</td>
 272              <td align="left"><?php echo ini_get('session.auto_start') ? '<b class="ok">' . $okImg . '</b>' : '<b class="error">' . $failedImg . '</b><span class="warning"> Try setting to ON if you are experiencing a WhiteScreenOfDeath</span>'; ?></td>
 273          </tr>
 274          <tr>
 275              <td>Session Use Cookies = ON?</td>
 276              <td align="left"><?php echo ini_get('session.use_cookies') ? '<b class="ok">' . $okImg . '</b>' : '<b class="error">' . $failedImg . '</b><span class="warning"> Try setting to ON if you are experiencing problems logging in</span>'; ?></td>
 277          </tr>
 278          <tr>
 279              <td>Session Use Trans Sid = OFF?</td>
 280              <td align="left"><?php echo (!ini_get('session.use_only_cookies') && !ini_get('session.use_trans_sid')) ? '<b class="ok">' . $okImg . '</b>' : '<b class="error">' . $failedImg . '</b><span class="warning"> There are security risks with this turned ON</span>'; ?></td>
 281          </tr>
 282          </table>
 283      </td>
 284  </tr>
 285  </table>
 286  <table class="text" style="background-color:#FFFFFF;" cellspacing="0" cellpadding="3" border="0" class="tbl" width="<?php echo $tblwidth; ?>" align="center">
 287  <tr>
 288      <td width="18"><?php echo str_replace('./style/', '../style/', w2PshowImage('log-error.gif', 16, 16, 'Fatal Errors')); ?></td> 
 289      <td width="100%"><a onclick="expand_collapse('fatal')" style="display: block;" name="fp" href="javascript: void(0);">
 290          <b>Fatal Errors</b>&nbsp;<font size="1">(show|hide)</font></a>
 291      </td>
 292      <td width="12" align="right" colspan="1">
 293  <?php
 294      echo '<a href="javascript: void(0);" name="ft" style="display:block" onclick="expand_collapse(\'fatal\');">';
 295      echo '<img id="fatal_expand" src="' . str_replace('./style/', '../style/', w2PfindImage('icons/expand.gif')) . '" width="12" height="12" border="0" style="display:none"><img id="fatal_collapse" src="' . str_replace('./style/', '../style/', w2PfindImage('icons/collapse.gif')) . '" width="12" height="12" border="0" style="display:"></a>';
 296  ?>
 297      </td>
 298  </tr>
 299  <tr id="fatal" style="visibility:visible;display:;">
 300      <td colspan="3">
 301          <table width="100%" cellspacing="0" cellpadding="0" border="0" class="tbl" width="<?php echo $tblwidth; ?>" align="left">
 302          <?php
 303          if (count($fatal)) {
 304              foreach ($fatal as $frec) {
 305          ?>
 306              <tr>
 307                  <td align="left"><?php echo $frec; ?></td>
 308              </tr>
 309          <?php
 310              }
 311          } else {
 312          ?>
 313              <tr>
 314                  <td align="left"><?php echo $okImg; ?>&nbsp;There are no Fatal Errors.</td>
 315              </tr>
 316          <?php
 317          }
 318          ?>
 319          </table>
 320      </td>
 321  </tr>
 322  </table>
 323  <table class="text" style="background-color:#FFFFFF;" cellspacing="0" cellpadding="3" border="0" class="tbl" width="<?php echo $tblwidth; ?>" align="center">
 324  <tr>
 325      <td width="18"><?php echo str_replace('./style/', '../style/', w2PshowImage('alert.gif', 16, 16, 'Warnings')); ?></td> 
 326      <td width="100%"><a onclick="expand_collapse('warnings')" style="display: block;" name="fp" href="javascript: void(0);">
 327          <b>Warnings</b>&nbsp;<font size="1">(show|hide)</font></a>
 328      </td>
 329      <td width="12" align="right" colspan="1">
 330  <?php
 331      echo '<a href="javascript: void(0);" name="ft" style="display:block" onclick="expand_collapse(\'warnings\');">';
 332      echo '<img id="warnings_expand" src="' . str_replace('./style/', '../style/', w2PfindImage('icons/expand.gif')) . '" width="12" height="12" border="0" style="display:none"><img id="warnings_collapse" src="' . str_replace('./style/', '../style/', w2PfindImage('icons/collapse.gif')) . '" width="12" height="12" border="0" style="display:"></a>';
 333  ?>
 334      </td>
 335  </tr>
 336  <tr id="warnings" style="visibility:visible; display:;">
 337      <td colspan="3">
 338          <table width="100%" cellspacing="0" cellpadding="0" border="0" class="tbl" width="<?php echo $tblwidth; ?>" align="left">
 339          <?php
 340          if (count($warnings)) {
 341              foreach ($warnings as $wrec) {
 342          ?>
 343              <tr>
 344                  <td align="left">&bull;&nbsp;<?php echo $wrec; ?></td>
 345              </tr>
 346          <?php
 347              }
 348          } else {
 349          ?>
 350              <tr>
 351                  <td align="left"><?php echo $okImg; ?>&nbsp; There are no Warnings.</td>
 352              </tr>
 353          <?php
 354          }
 355          ?>
 356          </table>
 357      </td>
 358  </tr>
 359  </table>
 360  </form>


Generated: Sat Jul 17 03:00:04 2010 Cross-referenced by PHPXref 0.7