install/includes/stages/sysreqs.php
changeset 348 87e08a6e4fec
child 404 fb4f9e6f378f
equal deleted inserted replaced
347:299a90e28abc 348:87e08a6e4fec
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
       
     5  * Version 1.1.1
       
     6  * Copyright (C) 2006-2007 Dan Fuhry
       
     7  * Installation package
       
     8  * sysreqs.php - Installer system-requirements page
       
     9  *
       
    10  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
       
    11  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
       
    12  *
       
    13  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
       
    14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
       
    15  */
       
    16 
       
    17 if ( !defined('IN_ENANO_INSTALL') )
       
    18   die();
       
    19 
       
    20 global $failed, $warned;
       
    21 
       
    22 $failed = false;
       
    23 $warned = false;
       
    24 
       
    25 function not($var)
       
    26 {
       
    27   if($var)
       
    28   {
       
    29     return false;
       
    30   } 
       
    31   else
       
    32   {
       
    33     return true;
       
    34   }
       
    35 }
       
    36 
       
    37 function run_test($code, $desc, $extended_desc, $warn = false)
       
    38 {
       
    39   global $failed, $warned;
       
    40   static $cv = true;
       
    41   $cv = not($cv);
       
    42   $val = eval($code);
       
    43   if($val)
       
    44   {
       
    45     if($cv) $color='CCFFCC'; else $color='AAFFAA';
       
    46     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc</td><td style='padding-left: 10px;'><img alt='Test passed' src='../images/good.gif' /></td></tr>";
       
    47   } elseif(!$val && $warn) {
       
    48     if($cv) $color='FFFFCC'; else $color='FFFFAA';
       
    49     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test passed with warning' src='../images/unknown.gif' /></td></tr>";
       
    50     $warned = true;
       
    51   } else {
       
    52     if($cv) $color='FFCCCC'; else $color='FFAAAA';
       
    53     echo "<tr><td style='background-color: #$color; width: 500px; padding: 5px;'>$desc<br /><b>$extended_desc</b></td><td style='padding-left: 10px;'><img alt='Test failed' src='../images/bad.gif' /></td></tr>";
       
    54     $failed = true;
       
    55   }
       
    56 }
       
    57 function is_apache()
       
    58 {
       
    59   $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false;
       
    60   return $r;
       
    61 }
       
    62 
       
    63 function config_write_test()
       
    64 {
       
    65   if ( !is_writable(ENANO_ROOT.'/config.new.php') )
       
    66     return false;
       
    67   // We need to actually _open_ the file to make sure it can be written, because sometimes this fails even when is_writable() returns
       
    68   // true on Windows/IIS servers. Don't ask me why.
       
    69   $h = @fopen( ENANO_ROOT . '/config.new.php', 'a+' );
       
    70   if ( !$h )
       
    71     return false;
       
    72   fclose($h);
       
    73   return true;
       
    74 }
       
    75 
       
    76 ?>
       
    77 <h3><?php echo $lang->get('sysreqs_heading'); ?></h3>
       
    78  <p><?php echo $lang->get('sysreqs_blurb'); ?></p>
       
    79  
       
    80 <table border="0" cellspacing="0" cellpadding="0">
       
    81 
       
    82 <?php
       
    83 run_test('return version_compare(\'5.2.0\', PHP_VERSION, \'<=\');', $lang->get('sysreqs_req_php5'), $lang->get('sysreqs_req_desc_php5'), true);
       
    84 run_test('return function_exists(\'mysql_connect\');', $lang->get('sysreqs_req_mysql'), $lang->get('sysreqs_req_desc_mysql') );
       
    85 run_test('return function_exists(\'pg_connect\');', $lang->get('sysreqs_req_postgres'), $lang->get('sysreqs_req_desc_postgres'), true);
       
    86 run_test('return @ini_get(\'file_uploads\');', $lang->get('sysreqs_req_uploads'), $lang->get('sysreqs_req_desc_uploads') );
       
    87 run_test('return is_apache();', $lang->get('sysreqs_req_apache'), $lang->get('sysreqs_req_desc_apache'), true);
       
    88 run_test('return config_write_test();', $lang->get('sysreqs_req_config'), $lang->get('sysreqs_req_desc_config') );
       
    89 run_test('return file_exists(\'/usr/bin/convert\');', $lang->get('sysreqs_req_magick'), $lang->get('sysreqs_req_desc_magick'), true);
       
    90 run_test('return is_writable(ENANO_ROOT.\'/cache/\');', $lang->get('sysreqs_req_cachewriteable'), $lang->get('sysreqs_req_desc_cachewriteable'), true);
       
    91 run_test('return is_writable(ENANO_ROOT.\'/files/\');', $lang->get('sysreqs_req_fileswriteable'), $lang->get('sysreqs_req_desc_fileswriteable'), true);
       
    92 if ( !function_exists('mysql_connect') && !function_exists('pg_connect') )
       
    93 {
       
    94   // FIXME: l10n
       
    95   run_test('return false;', 'No database drivers are available.', 'You need to have at least one database driver working to install Enano. See the warnings on MySQL and PostgreSQL above for more information on installing these database drivers.', false);
       
    96 }
       
    97 echo '</table>';
       
    98 echo '<br />';
       
    99 if(!$failed)
       
   100 {
       
   101   ?>
       
   102   
       
   103   <div class="pagenav">
       
   104   <?php
       
   105   if($warned) {
       
   106     echo '<table border="0" cellspacing="0" cellpadding="0">';
       
   107     run_test('return false;', $lang->get('sysreqs_summary_warn_title'), $lang->get('sysreqs_summary_warn_body'), true);
       
   108     echo '</table>';
       
   109   } else {
       
   110     echo '<table border="0" cellspacing="0" cellpadding="0">';
       
   111     run_test('return true;', '<b>' . $lang->get('sysreqs_summary_success_title') . '</b><br />' . $lang->get('sysreqs_summary_success_body'), 'You should never see this text. Congratulations for being an Enano hacker!');
       
   112     echo '</table>';
       
   113   }
       
   114   ?>
       
   115   <form action="install.php?stage=database" method="post">
       
   116     <?php
       
   117       echo '<input type="hidden" name="language" value="' . $lang_id . '" />';
       
   118     ?>
       
   119     <table border="0">
       
   120     <tr>
       
   121       <td>
       
   122         <input type="submit" value="<?php echo $lang->get('meta_btn_continue'); ?>" />
       
   123       </td>
       
   124       <td>
       
   125         <p>
       
   126           <span style="font-weight: bold;"><?php echo $lang->get('meta_lbl_before_continue'); ?></span><br />
       
   127           &bull; <?php echo $lang->get('sysreqs_objective_scalebacks'); ?><br />
       
   128           &bull; <?php echo $lang->get('license_objective_have_db_info'); ?>
       
   129         </p>
       
   130       </td>
       
   131     </tr>
       
   132     </table>
       
   133   </form>
       
   134   </div>
       
   135 <?php
       
   136 }
       
   137 else
       
   138 {
       
   139   if ( $failed )
       
   140   {
       
   141     echo '<div class="pagenav"><table border="0" cellspacing="0" cellpadding="0">';
       
   142     run_test('return false;', $lang->get('sysreqs_summary_fail_title'), $lang->get('sysreqs_summary_fail_body'));
       
   143     echo '</table></div>';
       
   144   }
       
   145 }
       
   146     
       
   147 ?>