Installer sysreqs: Merged all the crypto extensions into one check; altered warnings. Strings are hopefully cleaned up.
authorDan
Tue, 01 Dec 2009 00:35:04 -0500
changeset 1144 fcb2be1428e7
parent 1143 e271ae801c62
child 1145 21ef2f8feb59
Installer sysreqs: Merged all the crypto extensions into one check; altered warnings. Strings are hopefully cleaned up.
ajax.php
install/includes/cli-core.php
install/includes/libenanoinstall.php
install/includes/stages/sysreqs.php
language/english/install.json
--- a/install/includes/cli-core.php	Tue Dec 01 00:27:26 2009 -0500
+++ b/install/includes/cli-core.php	Tue Dec 01 00:35:04 2009 -0500
@@ -29,6 +29,8 @@
   exit;
 }
 
+require_once( ENANO_ROOT . '/install/includes/libenanoinstall.php' );
+
 if ( defined('ENANO_INSTALLED') )
 {
   // start up the API to let it error out if something's wrong
@@ -108,7 +110,7 @@
     case '--url-scheme':
     case '-r':
       $urlscheme_temp = @$argv[++$i];
-      if ( in_array($urlscheme_temp, array('standard', 'short', 'rewrite')) )
+      if ( in_array($urlscheme_temp, array('standard', 'short', 'rewrite', 'tiny')) )
         $urlscheme = $urlscheme_temp;
       break;
     case '--language':
@@ -441,6 +443,27 @@
   $failed = true;
 }
 
+// Test: crypto
+$crypto_backend = install_get_crypto_backend();
+if ( !$silent )
+{
+  echo '  ' . $lang->get('sysreqs_req_crypto') . ': ';
+  switch($crypto_backend)
+  {
+    case 'bcmath':
+      echo parse_shellcolor_string($lang->get('cli_test_warn') . " [<c 0;33>" . $lang->get("sysreqs_req_{$crypto_backend}") . "</c>]") . "\n";
+      $warnings[] = $lang->get('sysreqs_req_help_crypto_bcmath');
+      break;
+    case 'none':
+      echo parse_shellcolor_string($lang->get('cli_test_warn') . " [<c 0;31>" . $lang->get("sysreqs_req_notfound") . "</c>]") . "\n";
+      $warnings[] = $lang->get('sysreqs_req_help_crypto_none');
+      break;
+    default:
+      echo parse_shellcolor_string($lang->get('cli_test_pass') . " [<c 0;32>" . $lang->get("sysreqs_req_{$crypto_backend}") . "</c>]") . "\n";
+      break;
+  }
+}
+
 // Write tests
 $req_config_w = write_test('config.new.php');
 $req_htaccess_w = write_test('.htaccess.new');
@@ -472,27 +495,6 @@
 
 if ( !$silent ) echo '  ' . $lang->get('sysreqs_req_imagemagick') . ': ' . parse_shellcolor_string($lang->get($req_imagick ? 'cli_test_pass' : 'cli_test_warn')) . "\n";
 
-// Extension test: GMP
-$req_gmp = function_exists('gmp_init');
-if ( !$req_gmp )
-  $warnings[] = $lang->get('sysreqs_req_help_gmp');
-
-if ( !$silent ) echo '  ' . $lang->get('sysreqs_req_gmp') . ': ' . parse_shellcolor_string($lang->get($req_gmp ? 'cli_test_pass' : 'cli_test_warn')) . "\n";
-
-// Extension test: Big_Int
-$req_bigint = function_exists('bi_from_str');
-if ( !$req_bigint && !$req_gmp )
-  $warnings[] = $lang->get('sysreqs_req_help_bigint');
-
-if ( !$silent ) echo '  ' . $lang->get('sysreqs_req_bigint') . ': ' . parse_shellcolor_string($lang->get($req_bigint ? 'cli_test_pass' : 'cli_test_warn')) . "\n";
-
-// Extension test: BCMath
-$req_bcmath = function_exists('bcadd');
-if ( !$req_bcmath && !$req_bigint && !$req_gmp )
-  $warnings[] = $lang->get('sysreqs_req_help_bcmath');
-
-if ( !$silent ) echo '  ' . $lang->get('sysreqs_req_bcmath') . ': ' . parse_shellcolor_string($lang->get($req_bcmath ? 'cli_test_pass' : 'cli_test_warn')) . "\n";
-
 if ( !empty($warnings) && !$silent )
 {
   echo parse_shellcolor_string($lang->get('cli_msg_test_warnings')) . "\n";
--- a/install/includes/libenanoinstall.php	Tue Dec 01 00:27:26 2009 -0500
+++ b/install/includes/libenanoinstall.php	Tue Dec 01 00:35:04 2009 -0500
@@ -116,6 +116,25 @@
   exit;
 }
 
+function install_get_crypto_backend()
+{
+  $crypto_backend = 'none';
+
+  // Extension test: BCMath
+  if ( function_exists('bcadd') )
+    $crypto_backend = 'bcmath';
+  
+  // Extension test: Big_Int
+  if ( function_exists('bi_from_str') )
+    $crypto_backend = 'bigint';
+  
+  // Extension test: GMP
+  if ( function_exists('gmp_init') )
+    $crypto_backend = 'gmp';
+  
+  return $crypto_backend;
+}
+
 function enano_perform_upgrade($target_branch)
 {
   global $db, $session, $paths, $template, $plugins; // Common objects
--- a/install/includes/stages/sysreqs.php	Tue Dec 01 00:27:26 2009 -0500
+++ b/install/includes/stages/sysreqs.php	Tue Dec 01 00:35:04 2009 -0500
@@ -16,6 +16,8 @@
 if ( !defined('IN_ENANO_INSTALL') )
   die();
 
+require_once(ENANO_ROOT . '/install/includes/libenanoinstall.php');
+
 global $failed, $warned;
 
 $failed = false;
@@ -127,20 +129,12 @@
 if ( !$req_imagick )
   $warnings[] = $lang->get('sysreqs_req_help_imagemagick');
 
-// Extension test: GMP
-$req_gmp = function_exists('gmp_init');
-if ( !$req_gmp )
-  $warnings[] = $lang->get('sysreqs_req_help_gmp');
+$crypto_backend = install_get_crypto_backend();
 
-// Extension test: Big_Int
-$req_bigint = function_exists('bi_from_str');
-if ( !$req_bigint && !$req_gmp )
-  $warnings[] = $lang->get('sysreqs_req_help_bigint');
-
-// Extension test: BCMath
-$req_bcmath = function_exists('bcadd');
-if ( !$req_bcmath && !$req_bigint && !$req_gmp )
-  $warnings[] = $lang->get('sysreqs_req_help_bcmath');
+if ( $crypto_backend == 'none' )
+  $warnings[] = $lang->get('sysreqs_req_help_crypto_none');
+else if ( $crypto_backend == 'bcmath' )
+  $warnings[] = $lang->get('sysreqs_req_help_crypto_bcmath');
 
 ?>
 
@@ -265,6 +259,24 @@
 </tr>
 
 <tr>
+  <td>
+    <?php echo $lang->get('sysreqs_req_crypto'); ?>
+  </td>
+  <?php
+  if ( in_array($crypto_backend, array('bcmath', 'bigint', 'gmp')) )
+  {
+    echo '<td class="good">' . $lang->get("sysreqs_req_{$crypto_backend}") . '</td>';
+  }
+  else
+  {
+    echo '<td class="bad">' . $lang->get("sysreqs_req_notfound") . '</td>';
+  }
+  ?>
+</tr>
+
+<!-- Database -->
+
+<tr>
   <th colspan="2"><?php echo $lang->get('sysreqs_heading_dbms'); ?></th>
 </tr>
 
@@ -379,52 +391,6 @@
   ?>
 </tr>
 
-<tr>
-  <th colspan="2"><?php echo $lang->get('sysreqs_heading_crypto'); ?></th>
-</tr>
-
-<tr>
-  <td>
-    <?php echo $lang->get('sysreqs_req_gmp'); ?><br />
-    <small><?php echo $lang->get('sysreqs_req_hint_gmp'); ?></small>
-  </td>
-  <?php
-  if ( $req_gmp ):
-    echo '<td class="good">' . $lang->get('sysreqs_req_supported') . '</td>';
-  else:
-    echo '<td class="bad">' . $lang->get('sysreqs_req_notfound') . '</td>';
-  endif;
-  ?>
-</tr>
-
-<tr>
-  <td>
-    <?php echo $lang->get('sysreqs_req_bigint'); ?><br />
-    <small><?php echo $lang->get('sysreqs_req_hint_bigint'); ?></small>
-  </td>
-  <?php
-  if ( $req_bigint ):
-    echo '<td class="good">' . $lang->get('sysreqs_req_supported') . '</td>';
-  else:
-    echo '<td class="bad">' . $lang->get('sysreqs_req_notfound') . '</td>';
-  endif;
-  ?>
-</tr>
-
-<tr>
-  <td>
-    <?php echo $lang->get('sysreqs_req_bcmath'); ?><br />
-    <small><?php echo $lang->get('sysreqs_req_hint_bcmath'); ?></small>
-  </td>
-  <?php
-  if ( $req_bcmath ):
-    echo '<td class="good">' . $lang->get('sysreqs_req_supported') . '</td>';
-  else:
-    echo '<td class="bad">' . $lang->get('sysreqs_req_notfound') . '</td>';
-  endif;
-  ?>
-</tr>
-
 </table>
 
 <?php
--- a/language/english/install.json	Tue Dec 01 00:27:26 2009 -0500
+++ b/language/english/install.json	Tue Dec 01 00:35:04 2009 -0500
@@ -75,12 +75,14 @@
       req_disabled: 'Disabled',
       req_writable: 'Writable',
       req_unwritable: 'Unwritable',
+      req_gmp: 'GNU Multi-Precision (GMP)',
+      req_bigint: 'Big_Int',
+      req_bcmath: 'BCMath',
       
       heading_serverenv: 'Server environment',
       heading_dbms: 'Database servers',
       heading_files: 'Writable files',
       heading_images: 'Image manipulation',
-      heading_crypto: 'Cryptographic features',
       
       req_apache: 'Apache web server',
       req_php: 'PHP version',
@@ -89,22 +91,17 @@
       req_safemode: 'Safe Mode',
       req_uploads: 'PHP file upload support',
       req_ctype: 'PHP ctype_* validation functions',
+      req_crypto: 'Arbitrary precision (cryptographic) math',
       req_config_writable: 'Configuration file: config.new.php',
       req_htaccess_writable: 'Apache rewrite rules: .htaccess.new',
       req_files_writable: 'File storage directory: files/',
       req_cache_writable: 'Cache directory: cache/',
       req_gd2: 'GD2 library',
       req_imagemagick: 'ImageMagick',
-      req_gmp: 'GMP arbitrary-precision math',
-      req_bigint: 'Big_Int arbitrary-precision math',
-      req_bcmath: 'BCMath arbitrary-precision math',
       
       req_hint_htaccess_writable: 'Only needs to be writable if you plan to use Rewritten URLs.',
       req_hint_gd2: 'Used for generating visual confirmation and resizing uploaded images',
       req_hint_imagemagick: 'Faster alternative for resizing uploaded images',
-      req_hint_gmp: 'Fastest backend for Diffie-Hellman cryptographic math',
-      req_hint_bigint: 'Relatively fast backend for Diffie-Hellman cryptographic math',
-      req_hint_bcmath: 'Allows Diffie-Hellman cryptographic math but slower',
       
       req_help_apache: 'Apache is the best server for Enano because it provides features that Enano can use, primarily support for Rewritten URLs.',
       req_help_php: 'Enano requires PHP version 5.0.0 or later, and runs best under PHP 5.2.0 or later. (You are running PHP %php_version%).',
@@ -113,9 +110,8 @@
       req_help_writable: 'Certain files need to be writable for installation and certain features to work properly. Use your FTP client\'s "CHMOD" feature to set numeric permissions on the items listed above: 666 for files, and 777 for directories. It\'s safest to CHMOD config.php to 444 once installation is complete.',
       req_help_gd2: 'Without GD, Enano has to use a visual confirmation engine that generates weaker images that are easier to break.',
       req_help_imagemagick: 'Without ImageMagick, Enano will use GD (if it is available) to scale images down. This is slightly slower.',
-      req_help_gmp: 'GMP is the fastest backend for Enano\'s cryptographic math. If you don\'t have GMP or Big_Int, logging in might be slower.',
-      req_help_bigint: 'Big_Int is a faster backend for Enano\'s cryptographic math. If you don\'t have GMP or Big_Int, logging in might be slower.',
-      req_help_bcmath: 'BCMath is a fallback backend for Enano\'s cryptographic math. If you don\'t have GMP, BCMath or Big_Int, Enano will have to use an insecure method to transmit your login information.',
+      req_help_crypto_none: 'Your server has no support for arbitrary-precision math, which is required for encrypted logon. Your username and password will not be transmitted securely until one of the following PHP extensions is installed: GMP, Big_Int, or BCMath.',
+      req_help_crypto_bcmath: 'Your server supports arbitrary-precision math, but only through PHP\'s BCMath extension which is extremely slow. Expect the process of logging in to take 6-10 seconds.',
       
       err_no_dbms_title: 'No database backends are available.',
       err_no_dbms_body: 'Enano requires at least one database backend to install. Please consult with your hosting provider to obtain help with this situation. If you are running a VPS or dedicated server, install the php-mysql or php-pgsql (on Red Hat&reg;-based distributions) or php5-mysql or php5-pgsql (on Debian-based distributions) packages. For Windows servers, ensure that the php_mysql or php_pgsql extension is enabled in php.ini.',