1 php
2 # ============================
3 # Filename: string.class.php
4 # Note : 字符串管理
5 # Update : 2008-5-8
6 # Cool!!
7 # ============================
8 class QG_C_STRING
9 {
10 var $script = false ;
11 var $iframe = false ;
12 var $style = false ;
13
14 function __construct( $script = false , $iframe = false , $style = false )
15 {
16 $this -> script = $script ;
17 $this -> iframe = $iframe ;
18 $this -> style = $style ;
19 }
20
21 # [兼容PHP4]
22 function QG_C_STRING( $script = false , $iframe = false , $style = false )
23 {
24 $this -> __construct( $script , $iframe , $style );
25 }
26
27 function __destruct()
28 {
29 return true ;
30 }
31
32 # [设置状态属性]
33 function set( $var , $status )
34 {
35 $this -> $var = $status ;
36 }
37
38 function safe( $msg )
39 {
40 if ( ! $msg )
41 {
42 return false ;
43 }
44 if ( is_array ( $msg ))
45 {
46 foreach ( $msg AS $key => $value )
47 {
48 $msg [ $key ] = $this -> safe( $value );
49 }
50 }
51 else
52 {
53 $msg = trim ( $msg );
54 $old = array ( " & " , " " , " ' " , ' " ' , " < " , " > " , " \t " , " \r " );
55 $new = array ( " & " , " " , " ' " , " " " , " < " , " > " , " " , "" );
56 $msg = str_replace ( $old , $new , $msg );
57 $msg = str_replace ( " " , " " , $msg );
58 $old = array ( " //isU " , "" 、 $msg );
81
82 if ( ! $this -> iframe)
83 {
84 $msg = preg_replace ( " //isU " , "" , $msg );
85 $msg = preg_replace ( " //isU " , "" , $msg );
86 $msg = preg_replace ( " /