value = $value; $this->default_value = $default_value; $this->valid_values = false; $this->valid_tags = false; } function integer() { $intval = $this->value; settype( $intval, 'integer' ); if ( is_array( $this->valid_values ) ) { for ( $i = 0; $i < count( $this->valid_values ); $i++ ) { if ( $this->valid_values[ $i ] == $intval ) break; } if ( $i == count( $this->valid_values ) ) $intval = $this->default_value ? $this->default_value : $intval; } return $intval; } function string() { $strval = $this->value; settype( $intval, 'string' ); if ( is_array( $this->valid_values ) ) { for ( $i = 0; $i < count( $this->valid_values ); $i++ ) { if ( $this->valid_values[ $i ] == $strval ) break; } if ( $i == count( $this->valid_values ) ) $strval = $this->default_value ? $this->default_value : $strval; } if ( $this->valid_tags ) { $strval = strip_tags( $strval, $this->valid_tags ); } return $strval; } function valid_values( $values ) { if ( ! is_array( $values ) ) { die( 'valid_values: parameter is not an array!' ); } $this->valid_values = $values; } function valid_tags( $valid_tags ) { $this->valid_tags = $valid_tags; } }; /* Die Post Variablen sind nur zum testen */ $_POST[ 'user_id' ] = '42d'; $_POST[ 'user_limit' ] = '1'; $_POST[ 'user_game1' ] = 'rtcw'; $_POST[ 'user_signature' ] = 'muahahaha Fetter Text lalal'; $user_id = new px_var( $_POST[ 'user_id' ] ); $user_limit = new px_var( $_POST[ 'user_limit' ], 20 ); $user_game1 = new px_var( $_POST[ 'user_game1' ], 'et' ); $user_signature = new px_var( $_POST[ 'user_signature' ] ); $user_limit->valid_values( Array( '10', '20', '30', '40', '50' ) ); $user_game1->valid_values( Array( 'et', 'rtcw', 'cod' ) ); $user_signature->valid_tags( '' ); echo $user_id->integer().'
'; echo $user_limit->integer().'
'; echo $user_game1->string().'
'; echo $user_signature->string().'
'; ?>