SessionElement.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:2k
- <?php
- class SessionElement extends BaseObject {
- var $variable_name;
- /*
- --
- DOESNT CARE ABOUT TYPE ANYMORE EXCEPT FOR STORE / RETREIVES
- --
- */
- var $variable_type;
- Function SessionElement( $variable_name, $var_type = 'string' ) {
- $this->BaseObject( 'SessionElement' );
- $this->variable_name = $variable_name;
- $this->variable_type = $var_type;
- }
- Function Freeze() {
- return $this->StoreValue();
- }
- Function Thaw( $data ) {
- return $this->FetchValue( $data );
- }
- Function StoreValue() {
- $var_name = '$' . $this->variable_name;
- $sto_type = 'string';
- $sto_val = '';
- $code_seg = '';
- $code_seg .= 'global ' . $var_name . '; ';
- $code_seg .= 'if ( is_object( ' . $var_name . ' ) ) { ';
- $code_seg .= ' $sto_val = serialize( ' . $var_name . ' ); ';
- $code_seg .= ' $sto_type = ' . $var_name . '->Type(); ';
- $code_seg .= '} else if( is_array( ' . $var_name . ' ) ) {';
- $code_seg .= ' $sto_val = serialize( ' . $var_name . ' ); ';
- $code_seg .= ' $sto_type = "array"; ';
- $code_seg .= '} else {';
- $code_seg .= ' $sto_val = ' . $var_name . ' ; ';
- $code_seg .= ' $sto_type = "string"; ';
- $code_seg .= '}';
- eval( $code_seg );
- $this->variable_type = $sto_type;
- return $sto_val;
- }
- Function FetchValue( $value ) {
- $var_name = '$' . $this->variable_name;
- $code_seg = '';
- $code_seg .= 'global ' . $var_name . '; ';
- if ( $this->variable_type == 'string' ) {
- $code_seg .= $var_name . ' = '' . $value . '';' ;
- } else if ( $this->variable_type == 'array' ) {
- $code_seg .= $var_name . ' = Array(); ';
- $code_seg .= $var_name . ' = unserialize( '' . $value . '' ); ';
- } else {
- $code_seg .= $var_name . ' = new ' . $this->variable_type . '();';
- $code_seg .= $var_name . ' = unserialize( '' . $value . '' );';
- }
- eval( $code_seg );
- }
- }
- ?>