home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / scripts / check_lang.php next >
Encoding:
PHP Script  |  2008-06-23  |  1.8 KB  |  62 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * This test script checks all the language files to ensure there is no errors
  5.  * inside and nothing is displayed on screen (eg no extra no blank line).
  6.  *
  7.  * @version $Id: check_lang.php 10239 2007-04-01 09:51:41Z cybot_tm $
  8.  * @package phpMyAdmin-test
  9.  */
  10.  
  11. /**
  12.  *
  13.  */
  14. $failed = array();
  15. $passed = array();
  16.  
  17. // 1. Do check
  18. $languageDirectory = dir('../lang');
  19. while ($name = $languageDirectory->read()) {
  20.     if (strpos($name, '.inc.php')) {
  21.         // 1.1 Checks parse errors and extra blank line
  22.         include '../lang/' . $name;
  23.         header('X-Ping: pong');
  24.         // 1.1 Checks "^M"
  25.         $content = fread(fopen('../lang/' . $name, 'r'), filesize('../lang/' . $name));
  26.         if ($pos = strpos(' ' . $content, "\015")) {
  27.             $failed[] = $name;
  28.         } else {
  29.             $passed[] = $name;
  30.         }
  31.     } // end if
  32. } // end while
  33. $languageDirectory->close();
  34.  
  35. // 2. Checking results
  36. $start      = '';
  37. $failed_cnt = count($failed);
  38. sort($failed);
  39. $passed_cnt = count($passed);
  40. sort($passed);
  41. echo ($failed_cnt + $passed_cnt) . ' language files were checked.<br /><br />' . "\n";
  42. if ($failed_cnt) {
  43.     echo '  1. ' . $failed_cnt . ' contain(s) some "^M":<br />' . "\n";
  44.     for ($i = 0; $i < $failed_cnt; $i++) {
  45.         echo '    - ' . $failed[$i] . '<br />' . "\n";
  46.     } // end for
  47.     if ($passed_cnt) {
  48.         echo '<br />' . "\n";
  49.         echo '  2. ' . $passed_cnt . ' seems right:<br />' . "\n";
  50.         $start = '  ';
  51.     }
  52. } // end if
  53. if ($passed_cnt) {
  54.     if (!$failed_cnt) {
  55.         echo 'They all passed checkings:<br />' . "\n";
  56.     }
  57.     for ($i = 0; $i < $passed_cnt; $i++) {
  58.         echo $start . '  - ' . $passed[$i] . '<br />' . "\n";
  59.     } // end for
  60. } // end if
  61. ?>
  62.