Location: PHPKode > projects > SteelBot > steelbot/include/system.check.php
<?php

/**
 * @desc Проверяет систему на пригодность для использования бота, а также
 * важные конфигурационные переменные на корректность
 *
 */
function CheckSystem() {  
  global $cfg;
  echo "Testing bot and system ...\n";
  
  // system capabilities check
  
  // php version check
  echo "    PHP version: ".phpversion()."\n";
  if (phpversion() < 5) {
     exit("   Fatal error: PHP version must be 5 or higher\n");
  }
  
  $extensions = get_loaded_extensions();
  
  // iconv exetnsion check
  echo "    Checking for iconv extension... \n";
  if (!in_array('iconv', $extensions)) {
      if ( !function_exists('libiconv') ) {
          exit(   "[ Fatal error ] no iconv extension found");
      } else {
          function iconv($input_encoding, $output_encoding, $string) {
              return libiconv($input_encoding, $output_encoding, $string);
          }
          echo "    [ Warning ] iconv() replaced with libiconv()\n";
      }
  } else {
      echo "    iconv OK\n";
  }
  
  // mbstring extension check
  echo "    Checking for mbstring extension... \n";
  if ( !in_array('mbstring', $extensions) ) {
      exit("    [ Fatal error ] no mb_string extension found");
  } else {
      echo "    mbstring OK\n";
  }

  // script time limit check
  $time = ini_get('max_execution_time');
  set_time_limit(0);
  echo "    Bot time limit check... \n";
  if (ini_get('max_execution_time') > 0) {
     exit("[ Fatal error ] script time limit must be equal 0\n");
  } else {
     echo "    max_execution_time=0. OK\n";
  }

  // configuration check
  echo "    Configuration check...\n";
  if (empty($cfg)) {
     exit("[ Fatal error ] missing config file\n");
  } else {     
     if (empty($cfg['password'])) {
        exit("[ Fatal error ] password not specified - ['password']\n");
     }
     
     if (empty($cfg['plugin_dir'])) {
        echo "   [ Warning ] no plugins directory - ['plugin_dir'] (set to 'plugins')\n";
        $cfg['plugin_dir'] = dirname(__FILE__).'/plugins';
     }
       
     if (empty($cfg['delaylisten'])) {
        echo "   [ Warning ] socket listening delay set to 1 second - ['delaylisten']\n";
        $cfg['delaylisten'] = 1;
     }
     
     if (empty($cfg['connect_attempts'])) {
        echo "   [ Warning ] Connection attempts set to 20\n";
        $cfg['connect_attempts'] = 20;
     }
     echo "Test OK\n";
  }
}
 
Return current item: SteelBot