[ PHPXref.com ] [ Generated: Sun Jul 20 16:25:17 2008 ] [ ActionApps 2.8.1b ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> test.php3 (source)

   1  <?php
   2  /** This script has been stolen from old version of Horde.
   3    * We keep it here to remind us that we shoudl indeed have
   4    * something like this for installation and troubleshooting
   5    * purposes. The installation docs refers to it. Maybe the first
   6    * thing AA user will see after the installation :-|
   7    *
   8    * @version $Id: test.php3,v 1.4 2005/06/26 16:39:27 honzam Exp $
   9    * @author Marek Tichy, Econnect
  10    * @copyright (c) 2002-3 Association for Progressive Communications
  11  */
  12  
  13  define('APC_AA_VERSION','2.8.1-stable');
  14  
  15  @session_start();
  16  /* Register a session. */
  17  if (!isset($HTTP_SESSION_VARS['apcaa_test_count'])) {
  18      $apcaa_test_count = 0;
  19      session_register('apcaa_test_count');
  20  }
  21  
  22  $apcaa_test_count = &$HTTP_SESSION_VARS['apcaa_test_count'];
  23  
  24  /* We want to be as verbose as possible here. */
  25  error_reporting(E_ALL);
  26  function testErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {
  27      global $pear, $pearmail, $pearlog, $peardb;
  28      if (preg_match("/PEAR\.php/", $errmsg)) {
  29          $pear = false;
  30      } elseif (preg_match("/RFC822\.php/", $errmsg)) {
  31          $pearmail = false;
  32      } elseif (preg_match("/Log\.php/", $errmsg)) {
  33          $pearlog = false;
  34      } elseif (preg_match("/DB\.php/", $errmsg)) {
  35          $peardb = false;
  36      }
  37  }
  38  
  39  function status($foo) {
  40      if ($foo) {
  41          echo '<font color="green"><b>Yes</b></font>';
  42      } else {
  43          echo '<font color="red"><b>No</b></font>';
  44      }
  45  }
  46  
  47  /* apcaa versions */
  48  //todo - this should be located somewhere clever
  49  $versions['apcaa'] = APC_AA_VERSION;
  50  
  51  
  52  
  53  /* Parse PHP version */
  54  function split_php_version($version)
  55  {
  56      // First pick off major version, and lower-case the rest.
  57      if (strlen($version) >= 3 && $version[1] == '.') {
  58          $phpver['major'] = substr($version, 0, 3);
  59          $version = substr(strtolower($version), 3);
  60      } else {
  61          $phpver['major'] = $version;
  62          $phpver['class'] = 'unknown';
  63          return $phpver;
  64      }
  65      if ($version[0] == '.') {
  66          $version = substr($version, 1);
  67      }
  68      // Next, determine if this is 4.0b or 4.0rc; if so, there is no minor,
  69      // the rest is the subminor, and class is set to beta.
  70      $s = strspn($version, '0123456789');
  71      if ($s == 0) {
  72          $phpver['subminor'] = $version;
  73          $phpver['class'] = 'beta';
  74          return $phpver;
  75      }
  76      // Otherwise, this is non-beta;  the numeric part is the minor,
  77      // the rest is either a classification (dev, cvs) or a subminor
  78      // version (rc<x>, pl<x>).
  79      $phpver['minor'] = substr($version, 0, $s);
  80      if ((strlen($version) > $s) && ($version[$s] == '.' || $version[$s] == '-')) {
  81          $s++;
  82      }
  83      $phpver['subminor'] = substr($version, $s);
  84      if ($phpver['subminor'] == 'cvs' || $phpver['subminor'] == 'dev' || substr($phpver['subminor'], 0, 2) == 'rc') {
  85          unset($phpver['subminor']);
  86          $phpver['class'] = 'dev';
  87      } else {
  88          if (!$phpver['subminor']) {
  89              unset($phpver['subminor']);
  90          }
  91          $phpver['class'] = 'release';
  92      }
  93      return $phpver;
  94  }
  95  
  96  /* Display PHP version bullets */
  97  function show_php_version($phpver)
  98  {
  99      echo '    <li>PHP Major Version: ' . $phpver['major'] . "</li>\n";
 100      if (isset($phpver['minor'])) {
 101          echo '    <li>PHP Minor Version: ' . $phpver['minor'] . "</li>\n";
 102      }
 103      if (isset($phpver['subminor'])) {
 104          echo '    <li>PHP Subminor Version: ' . $phpver['subminor'] . "</li>\n";
 105      }
 106      echo '    <li>PHP Version Classification: ' . $phpver['class'] . "</li>\n";
 107  }
 108  
 109  /* PHP version-parsing regression test; PHP version format is only roughly */
 110  /* consistent, thus the need to test a wide range. */
 111  if (false) {
 112      $phpversions = array('4.0B1', '4.0B2-1', '4.0B2', '4.0B3-RC2', '4.0b3-RC3', '4.0b3-RC4', '4.0b3-RC5', '4.0b3', '4.0b4-rc1', '4.0b4', '4.0b4pl1', '4.0RC1', '4.0RC2', '4.0.0', '4.0.1', '4.0.2-dev', '4.0.2', '4.0.3RC1', '4.0.3RC2', '4.0.3', '4.0.3pl1', '4.0.4RC3', '4.0.4RC5', '4.0.4RC6', '4.0.4', '4.0.4pl1-RC1', '4.0.4pl1', '4.0.5RC1', '4.0.5-dev');
 113      foreach ($phpversions as $version) {
 114          echo "    <li>PHP Version: $version</li>\n";
 115          $phpver = split_php_version($version);
 116          show_php_version($phpver);
 117          echo '<br/>';
 118      }
 119  }
 120  
 121  /* PHP Version */
 122  $phpver = split_php_version(phpversion());
 123  
 124  /* PHP module capabilities */
 125  $ftp = extension_loaded('ftp');
 126  $gettext = extension_loaded('gettext');
 127  $imap = extension_loaded('imap');
 128  $ldap = extension_loaded('ldap');
 129  $mcal = extension_loaded('mcal');
 130  $mcrypt = extension_loaded('mcrypt');
 131  $mysql = extension_loaded('mysql');
 132  $pgsql = extension_loaded('pgsql');
 133  $xml = extension_loaded('xml');
 134  
 135  /* PHP Settings */
 136  $magic_quotes_runtime = !get_magic_quotes_runtime();
 137  
 138  /* PEAR */
 139  $pear = true;
 140  $pearmail = true;
 141  $pearlog = true;
 142  $peardb = true;
 143  set_error_handler('testErrorHandler');
 144  include 'PEAR.php';
 145  include 'Mail/RFC822.php';
 146  include 'Log.php';
 147  include 'DB.php';
 148  restore_error_handler();
 149  
 150  /* Check the version of the pear database API. */
 151  if ($peardb) {
 152      $peardbversion = '0';
 153      $peardbversion = @DB::apiVersion();
 154      if ($peardbversion < 2) {
 155          $peardb = false;
 156      }
 157  }
 158  
 159  echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">';
 160  
 161  /* Handle special modes */
 162  if (isset($HTTP_GET_VARS['mode'])) {
 163      switch ($HTTP_GET_VARS['mode']) {
 164      case 'phpinfo':
 165          phpinfo();
 166          exit;
 167          break;
 168  
 169      case 'unregister':
 170          $HTTP_SESSION_VARS['apcaa_test_count'] = null;
 171          session_unregister('apcaa_test_count');
 172          ?>
 173          <html>
 174          <body bgcolor="white" text="black">
 175          <font face="Helvetica, Arial, sans-serif" size="2">
 176          The test session has been unregistered.<br>
 177          <a href="test.php">Go back</a> to the test.php page.<br>
 178          <?php
 179          exit;
 180          break;
 181  
 182      default:
 183          break;
 184      }
 185  } else {
 186  ?>
 187  
 188  <html>
 189  <head>
 190  <title>apcaa: System Capabilities Test</title>
 191  <style type="text/css">
 192  <!--
 193  body { font-family: Geneva,Arial,Helvetica,sans-serif; font-size: 10pt; }
 194  td { font-family: Geneva,Arial,Helvetica,sans-serif; font-size: 10pt; }
 195  h1 { font-size: 12pt; color: black; font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; }
 196  -->
 197  </style>
 198  </head>
 199  
 200  <body bgcolor="#ffffff" text="#000000">
 201  
 202  <table border="0" cellpadding="2" cellspacing="0" width="100%">
 203  <tr><td>
 204  
 205  <h1>APC-AA Version</h1>
 206  <ul>
 207  <?php
 208  echo "<li>".APC_AA_VERSION;
 209  ?>
 210  </ul>
 211  
 212  <h1>PHP Version</h1>
 213  <ul>
 214      <li><a href="test.php?mode=phpinfo">View phpinfo() screen</a></li>
 215      <li>PHP Version: <?php echo phpversion(); ?></li>
 216  <?php
 217      show_php_version($phpver);
 218      if ($phpver['major'] < '4.0') {
 219          echo '        <li><font color="red">You need to upgrade to PHP4. PHP3 will not work.</font></li>';
 220          $requires = 1;
 221      } elseif ($phpver['major'] == '4.0') {
 222          if ($phpver['class'] == 'beta' || $phpver['class'] == 'unknown') {
 223              echo '        <li><font color="red">This is a beta/prerelease version of PHP4. You need to upgrade to a release version.</font></li>';
 224              $requires = 1;
 225          } elseif ($phpver['minor'] < '5' || ($phpver['minor'] == 4 && (empty($phpver['subminor']) || $phpver['subminor'][0] != 'p'))) {
 226              echo '        <li><font color="red">This version of PHP is not supported. You need to upgrade to a more recent version.</font></li>';
 227              $requires = 1;
 228          } elseif ($phpver['minor'] < '7') {
 229              echo '        <li><font color="orange">This version of PHP is supported but the PEAR library that comes with this version is not recent enough. See <a href="http://apcaa.org/pear/">http://apcaa.org/pear/</a> for details.</font></li>';
 230              $requires = 1;
 231          } else {
 232              echo '        <li><font color="green">You are running a supported version of PHP.</font></li>';
 233          }
 234      } elseif ($phpver['major'] == '4.1' || $phpver['major'] == '4.2'|| $phpver['major'] == '4.3'|| $phpver['major'] == '4.4') {
 235          echo '        <li><font color="green">You are running a supported version of PHP.</font></li>';
 236      } else {
 237          echo '        <li><font color="orange">Wow, a mystical version of PHP from the future. Let <a href="mailto:dev@lists.apcaa.org">dev@lists.apcaa.org</a> know what version you have so we can fix this script.</font></li>';
 238      }
 239      if (!empty($requires)) {
 240          echo '        <li>apcaa requires at least PHP 4.0.5 and PEAR 4.0.7.</li>';
 241      }
 242      echo '</ul>';
 243  ?>
 244  
 245  <h1>PHP Module Capabilities</h1>
 246  <ul>
 247      <li>FTP Support: <?php status($ftp); ?></li>
 248      <li>Gettext Support: <?php status($gettext); ?></li>
 249      <li>IMAP Support: <?php status($imap) ?></li>
 250      <li>LDAP Support: <?php status($ldap); ?></li>
 251      <li>MCAL Support: <?php status($mcal); ?></li>
 252      <li>Mcrypt Support: <?php status($mcrypt); ?></li>
 253      <li>MySQL Support: <?php status($mysql); ?></li>
 254      <li>PostgreSQL Support: <?php status($pgsql); ?></li>
 255      <li>XML Support: <?php status($xml); ?></li>
 256  </ul>
 257  
 258  <h1>Miscellaneous PHP Settings</h1>
 259  <ul>
 260      <li>magic_quotes_runtime set to Off: <?php echo status($magic_quotes_runtime); ?></li>
 261      <?php if (!$magic_quotes_runtime) { ?>
 262      <li><font color="red"><b>magic_quotes_runtime may cause problems with database inserts, etc. Turn it off.</b></font></li>
 263      <?php } ?>
 264  </ul>
 265  
 266  <h1>PHP Sessions</h1>
 267  <?php $apcaa_test_count++; ?>
 268  <ul>
 269      <li>Session counter: <?php echo $apcaa_test_count; ?></li>
 270      <li>To unregister the session: <a href="test.php?mode=unregister">click here</a></li>
 271  </ul>
 272  
 273  <h1>PEAR</h1>
 274  <ul>
 275      <li>PEAR - <?php status($pear); ?></li>
 276      <?php if (!$pear) { ?>
 277          <li><font color="red">Check your PHP include_path setting to make sure it has the PEAR library directory.</font></li>
 278      <?php } ?>
 279      <li>Mail::RFC822 - <?php status($pearmail); ?></li>
 280      <?php if ($pear && !$pearmail) { ?>
 281          <li><font color="red">Make sure you're using a recent version of PEAR which includes the Mail class.</font></li>
 282      <?php } ?>
 283      <li>Log - <?php status($pearlog); ?></li>
 284      <?php if ($pear && !$pearlog) { ?>
 285          <li><font color="red">Make sure you have installed the latest PEAR from PHP-cvs.</font></li>
 286      <?php } ?>
 287      <li>DB - <?php status($peardb); ?></li>
 288      <?php if ($pear && !$peardb) {
 289                if ($peardbversion) { ?>
 290                    <li><font color="red">Your version of DB is not recent enough.</font></li>
 291                <?php } else { ?>
 292                    <li><font color="red">You will need DB if you're using SQL drivers for preferences, contacts (Turba), etc.</font></li>
 293                <?php }
 294            } ?>
 295  </ul>
 296  
 297  <p align="left">
 298  <a href="http://validator.w3.org/check/referer"><img src="http://validator.w3.org/images/vxhtml10" alt="Valid XHTML 1.0!" height="31" width="88" border="0" hspace="5" /></a>
 299  </p>
 300  
 301  </td></tr>
 302  </table>
 303  
 304  <?php } ?>
 305  
 306  </body>
 307  </html>


[ Powered by PHPXref - Served by Debian GNU/Linux ]