Source for file test.php

Documentation is available at test.php

  1. <?php //-*-php-*-
  2. /* ******************************************************************** **
  3. ** Copyright notice **
  4. ** **
  5. ** (c) 1995-2003 PHPOpenChat Development Team **
  6. ** http://phpopenchat.sourceforge.net/ **
  7. ** **
  8. ** All rights reserved **
  9. ** **
  10. ** This script is part of the PHPOpenChat project. The PHPOpenChat **
  11. ** project is free software; you can redistribute it and/or modify **
  12. ** it under the terms of the GNU General Public License as published by **
  13. ** the Free Software Foundation; either version 2 of the License, or **
  14. ** (at your option) any later version. **
  15. ** **
  16. ** The GNU General Public License can be found at **
  17. ** http://www.gnu.org/copyleft/gpl.html. **
  18. ** A copy is found in the textfile GPL and important notices to the **
  19. ** license from the team is found in the textfile LICENSE distributed **
  20. ** with these scripts. **
  21. ** **
  22. ** This script is distributed in the hope that it will be useful, **
  23. ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
  24. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
  25. ** GNU General Public License for more details. **
  26. ** **
  27. ** This copyright notice MUST APPEAR in all copies of the script! **
  28. ** ******************************************************************** */
  29.  
  30. /*
  31. $Author: letreo $
  32. $Date: 2003/10/05 09:02:31 $
  33. $Source: /cvsroot/phpopenchat/chat3/test.php,v $
  34. $Revision: 1.33 $
  35. */
  36.  
  37. //Get default values
  38. require_once('config.inc.php');
  39.  
  40. require_once(POC_INCLUDE_PATH.'/adodb/adodb.inc.php');
  41. require_once(POC_INCLUDE_PATH.'/class.Chatter.inc');
  42. require_once(POC_INCLUDE_PATH.'/class.Recipient.inc');//extents Chatter
  43. require_once(POC_INCLUDE_PATH.'/class.Line.inc');
  44. require_once(POC_INCLUDE_PATH.'/class.Template.inc');
  45. require_once(POC_INCLUDE_PATH.'/class.Channel_Buffer_'.CHANNEL_BUFFER_TYPE.'.inc');
  46.  
  47. $myTemplate = new Template();
  48.  
  49. //create a database object
  50. $db = &NewADOConnection( DATABASE_DRIVER );
  51. $db_col = (@$db->Connect( DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD, DATABASE_TABLESPACE ))? 'green':'red';
  52. $schema_col = (@$db->Execute( 'SELECT AWAY FROM poc_user_data' ) && $db_col!='red')? 'green':'red';
  53.  
  54. /* $rs = $db->Execute( 'SELECT * FROM poc_user_data' );
  55. print_r($rs);echo 'xxx';exit;
  56. */
  57.  
  58.  
  59.  
  60. $separator = (POC_OS=='win')? '\\':'/';
  61. $tmp_col = (@fopen( TMPDIR.$separator.'poc_testfile', 'w' ))? 'green':'red';
  62. $tmpl_col = (file_exists($myTemplate->get_template('index',true)) )? 'green':'red';
  63. $chatter_icon_upload_dir = $myTemplate->get_tmpl_sys_path().$separator.'images'.$separator.'icons'.$separator.'chatter';
  64. $chatter_icon_col = (@fopen( $chatter_icon_upload_dir.$separator.'poc_testfile', 'w' ))? 'green':'red';
  65. if(isset($_GET['phpinfo'])){echo phpinfo();exit;}
  66. echo '
  67. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  68. <html>
  69. <head>
  70. <title></title>
  71. </head>
  72. <body>
  73.  
  74. ';
  75. if(isset($_GET['error'])) echo '<span style="color:#f00">'.$_GET['error'].'</span>';
  76. echo'
  77. <table>
  78. <thead>
  79. <tr>
  80. <th>Check</th>
  81. <th>Status</th>
  82. </tr>
  83. </thead>
  84. <tbody>
  85. <tr>
  86. <td>POC-Database: </td>
  87. <td bgcolor="'.$db_col.'">&nbsp;&nbsp;&nbsp;</td>
  88. <td></td>
  89. </tr>
  90. <tr>
  91. <td>POC-Tables: </td>
  92. <td bgcolor="'.$schema_col.'">&nbsp;&nbsp;&nbsp;</td>
  93. <td>POC database schema checked</td>
  94. </tr>
  95. <tr>
  96. <td>POC-Templates: </td>
  97. <td bgcolor="'.$tmpl_col.'">&nbsp;&nbsp;&nbsp;</td>
  98. <td>tried to open templates in \'<em>'.$myTemplate->get_theme_path().'</em>\'</td>
  99. </tr>
  100. <tr>
  101. <td>Webserver write access in <em>'.TMPDIR.'</em>: </td>
  102. <td bgcolor="'.$tmp_col.'">&nbsp;&nbsp;&nbsp;</td>
  103. <td>The temporary directory, where the webserver MUST have write access, is defined as \'TMPDIR\' in config.inc.php<br />If you have setup the rights for \'TMPDIR\' to full read and write access (Unix \'chmod 777\') but the test shows even so red, your ISP has switched on \'safe_mode\' or has defined \'open_basedir\' within the PHP configuration file (php.ini). open_basedir, if set, limits all file operations to the defined directory.</td>
  104. </tr>
  105. <tr>
  106. <td>Webserver write access in <em>'.$chatter_icon_upload_dir.'</em>: </td>
  107. <td bgcolor="'.$chatter_icon_col.'">&nbsp;&nbsp;&nbsp;</td>
  108. <td>Each chatter has the possibility to upload a private icon, which he can use within the chat. So, the webserver needs write access to this directory to store private images.</td>
  109. </tr>
  110. </tbody>
  111. </table>
  112. <p>
  113. If you see always green, all is fine, <a href="index.php">login</a>.<br>If you see red, please:';
  114. if( $db_col == 'red' )
  115. echo '
  116. <ul>
  117. <li>Edit the file config.inc.php and setup your database connection. Change:
  118. <ul>
  119. <li>DATABASE_HOST</li>
  120. <li>DATABASE_USER</li>
  121. <li>DATABASE_PASSWORD</li>
  122. <li>DATABASE_TABLESPACE</li>
  123. </ul>
  124. to your values. (Hint: DATABASE_TABLESPACE contains your SQL-tables and hopefully the POC-SQL-tables.)
  125. </li>
  126. </ul>';
  127. if( $schema_col == 'red' )
  128. echo '
  129. <ul>
  130. <li>
  131. Import the POC database tables<br />
  132. Open a command-shell and do a:<ol>
  133. <li># mysqladmin create poc</li>
  134. <li># mysql poc &lt; /path/to/poc/db.schema</li>
  135. </ol>
  136. First point only, if you want to have the POC-SQL-tables in a separat tablespace. In the most cases, user have already such a tablespace and there are no problems to import POC-SQL-tables into this tablespace.
  137. </li>
  138. </ul>';
  139.  
  140. if( $tmp_col == 'red' )
  141. echo '<p>If you have enabled safe_mode, or open_basedir further restrictions may apply.<br />
  142. In case you have no write access to <em>'.TMPDIR.'</em>
  143. <ul>
  144. <li>Create a director \'tmp\' for example in '.realpath('../..').'</li>
  145. <li>Give webserver write access to this directory. (chmod 666)</li>
  146. </ul></p>
  147. ';
  148. echo'
  149. <ul>
  150. <li>
  151. Please read the <a href="INSTALL">INSTALL</a> instructions!
  152. </li>
  153. </ul>
  154. </p>
  155. </body>
  156. </html>';
  157. exit;
  158.  
  159. // Unit tests on classes
  160. // Line::test();
  161. // Channel_Buffer::test();
  162. // Chatter::test();
  163.  
  164. ?>

Documentation generated on Tue, 29 Jun 2004 14:42:46 +0200 by phpDocumentor 1.3.0RC3