⬆️ ⬇️

PHP: Implementing Formal Grammar

Recently, I needed to write a parser for the search string that lists the strings

(aa & bb) ^ (! cc ^! (dd ^ ee)) in a SQL slice type string: (? f LIKE "% aa%" AND? f LIKE "% bb%") OR (? f NOT LIKE "% cc% "OR! ((? F LIKE"% dd% "OR? F LIKE"% ee% "))). I wrote like and SQL for the management, in fact there was SPHINX, and it wasn’t finally required, but talk about how I achieved this by writing formal grammars and implementing them in PHP.



Kohl already went to the post, then I will open before you: in spite of the higher mathematical education I did it for the first time, and before that I heard, but I did not see how it was done. Therefore, I ask all highbrow mathematicians and gurus to shower me with the right decisions and correct them in every way, but for now I’ll tell you about my results and how I came to them.



There were several options to achieve the goal:

the first is to write a recursive (remember "? R") regular, but I discarded such an option as “not sporty”, oh yes, lemmings will punish me for it =)

the second is to write the construction of the tree manually, but somehow it would be too painful to write a lot and it would somehow hurt clumsy.

the third is to recall the words "formal grammar." Yes, they seem scary at first glance, but in practice everything is much better and more useful - I chose him. I repeat that this is my first implementation of this concept, so boldly point out my mistakes to me!



So let's get started:

Compose the alphabet

Alphabet = {(,),!, &, ^, (,), AZ, space here, -, _, -}

we will create a meta-alphabet for our task, taking into account the priorities of operations (! priority over & and ^, and the latter are of the same priority)

')

F -> T | T & F | T ^ F

T * -> I |! I |! S

I -> (F) | S

S -> C | SC

C -> [a-Z_ a-Ya-]



These are the rules by which meta-alphabet elements are formed from bottom to top.

F is a formula, T is a term, I is an item, S is a string, C is a symbol. Called as liked.



* in T is entered! S to "interpret the ball of the ball of the blah"? f NOT LIKE "% of the ball of the ball of the bla%", but not how! (? f LIKE "% of the ball of the ball of the bla%");



As you can see, the grammar containing negative parsing (!) Is below the grammar containing the parsing of other operations (& and ^), and the grammar containing brackets parsing is even lower - thus the priority of operations is formed.



I got a context-independent G 2 grammar according to Chomsky’s hierarchy for this task - simple, shorter, but not as simple as a finite state machine (therefore, such problems are not solved by pure “regulars”, without recursions).



Now it remains to implement all this. I don’t think it’s interesting how I coded, so without tormenting the reader I’ll post the final code, I’ll just note that it doesn’t search for syntax errors (Although my soul is sick and I have added a couple of the most glaring errors to the code).

Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  1. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  2. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  3. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  4. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  5. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  6. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  7. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  8. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  9. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  10. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  11. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  12. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  13. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  14. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  15. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  16. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  17. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  18. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  19. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  20. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  21. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  22. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  23. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  24. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  25. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  26. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  27. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  28. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  29. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  30. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  31. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  32. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  33. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  34. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  35. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  36. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  37. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  38. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  39. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  40. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  41. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  42. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  43. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  44. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  45. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  46. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  47. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  48. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  49. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  50. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  51. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  52. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  53. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  54. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  55. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  56. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  57. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  58. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  59. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  60. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  61. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  62. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  63. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  64. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  65. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  66. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  67. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  68. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  69. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  70. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  71. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  72. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  73. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  74. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  75. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  76. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  77. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  78. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  79. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  80. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  81. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  82. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  83. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  84. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  85. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  86. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  87. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  88. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  89. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  90. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  91. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  92. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  93. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }
  94. Copy Source | Copy HTML class GrammarParcer2SQLToken{ private $string = '' ; private $index = 0 ; private $sql_token = '' ; private $error = null ; public function __construct( $s = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; } public function parce( $s = null , $e = null ){ if (! empty ( $s )) $this ->string = $s ; $this ->index = 0 ; $this ->error = null ; $this ->F(); $e = $this ->error; return $this ->sql_token; } public function getError(){ return $this ->error; } protected function setError( $mes ){ $this ->error = $mes ; } protected function isEnd(){ if (! empty ( $this ->error) or $this ->index >= strlen( $this ->string)) return true ; return false ; } protected function F(){ $this ->T(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '&' ){ $this ->sql_token.= ' AND ' ; } elseif ( $this ->string{ $this ->index} == '^' or $this ->string{ $this ->index} == '|' ){ $this ->sql_token.= ' OR ' ; } else { return ; } $this ->index++; $this ->F(); } protected function T(){ $this ->I(); if ( $this ->isEnd()) return ; if ( $this ->string{ $this ->index} == '!' ){ $this ->index++; if (! $this ->S( 'invert' )){ $this ->sql_token.= '!(' ; $this ->I(); $this ->sql_token.= ')' ; } } } protected function I(){ if ( $this ->string{ $this ->index} == '(' ){ $this ->sql_token.= '(' ; $this ->index++; $this ->F(); if ( $this ->string{ $this ->index} !== ')' ){ $this ->setError( 'parse error, expected ")" on offset: ' . $this ->index); // . } $this ->sql_token.= ')' ; $this ->index++; } else { $this ->S(); } } protected function S( $invert = false ){ if ( $this ->isEnd()) return false ; $string = '' ; while (! $this ->isEnd()){ if (preg_match( '~[0-9a-z-_ -]~i' , $this ->string{ $this ->index})){ $string .= $this ->string{ $this ->index}; $this ->index++; continue ; } elseif (!preg_match( '~[&)(!|^]~i' , $this ->string{ $this ->index})){ $this ->setError( 'parse error, unexpected "' . $this ->string{ $this ->index}. '" on offset: ' . $this ->index); // =) } break ; } if ( empty ( $string )) return false ; $this ->sql_token.= '?f ' .( $invert ? 'NOT ' : '' ). 'LIKE "%' .mysql_escape_string( $string ). '%"' ; return true ; } }




see an example:



Copy Source | Copy HTML
  1. $ input = '(aa & bb) ^ (! cc ^! (dd ^ ee))' ;
  2. $ parcer = new GrammarParcer2SQLToken ();
  3. echo $ parcer -> parce ( $ input );
  4. echo "\ n" . $ parcer -> getError ();




UPD did code coloring - thanks to sc.me

Source: https://habr.com/ru/post/73665/



All Articles