Source for file class.Input.inc

Documentation is available at class.Input.inc

  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. * Get default values
  32. */
  33. require_once(POC_BASE.'/config.inc.php');
  34. // require_once(POC_INCLUDE_PATH.'/class.Logger.inc');
  35.  
  36.  
  37. /**
  38. * Class Input holds everything posted by chatters
  39. * which *might* be valid
  40. *
  41. * @package phpopenchat
  42. * @author Juergen Jaeschke <jjaeschke@educat.hu-berlin.de>
  43. * @access public
  44. * @version $Id: class.Input.inc,v 1.2 2003/10/15 22:16:42 jjaeschke Exp $
  45. */
  46.  
  47. class Input {
  48. var $errorcode=0;
  49. var $line = '';
  50. var $channel = CHANNEL_SELECTED;
  51. // var $recipient = '###EVERYBODY###';
  52. var $recipient = '';
  53. var $PHPSESSID = '';
  54. var $whispered = 'off';
  55. // var $unknown = array();
  56.  
  57.  
  58. /**
  59. * Constructor for class Input
  60. *
  61. * @param array $post HTTP POST
  62. */
  63. function Input ( $post ) {
  64. deb("entering input");
  65. if ( ! is_array ($post) ) {
  66. deb("post is not an array, help!");
  67. die ("post MUST be an array");
  68. }
  69.  
  70. # set variables which are posted and remove from array
  71. # replace with get_class_vars later...
  72. reset($post);
  73. while ( !is_null($key = key($post)) ) {
  74. if ( isset ($this->$key) ) {
  75. $this->$key = $post[$key];
  76. // deb($key.":".$post[$key]."::".$this->$key );
  77. unset($post[$key]);
  78. reset($post);
  79. }
  80. else {
  81. // deb($key.":".$post[$key]."::".$this->$key );
  82. next($post);
  83. }
  84. }
  85.  
  86. # anything left ?
  87. reset($post);
  88. while ( !is_null($key = key($post)) ) {
  89. $_SESSION['logger']->warning("unknown key in POST:$key=".$post[$key]);
  90. $errorcode|=1;
  91. next($post);
  92. }
  93.  
  94. // $_SESSION['logger']->history_raw( $this );
  95.  
  96. }
  97.  
  98. function is_valid () {
  99. return ($errorcode & 1) ? false : true ;
  100. }
  101.  
  102. function get_line () {
  103. return($this->line);
  104. }
  105.  
  106. function get_channel () {
  107. return($this->channel);
  108. }
  109. function get_recipient() {
  110. return($this->recipient);
  111. }
  112. function get_PHPSESSID() {
  113. return($this->PHPSESSID);
  114. }
  115. function get_whispered() {
  116. return($this->whispered);
  117. }
  118.  
  119. function get ( $key ) {
  120. $ret = '';
  121. if ( isset ( $this->post[$key] ) ) {
  122. return ( $this->post[$key] );
  123. }
  124. else {
  125. return (undef);
  126. }
  127. }
  128.  
  129. // function _log () {
  130. // $_SESSION['logger']->history_raw("test");
  131. // }
  132.  
  133.  
  134.  
  135. }
  136.  
  137. ?>

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