'.htmlspecialchars($output).''."\n".''."\n".'';}ob_start('DBSR_CLI_output');}$cli=new DBSR_CLI();$cli->parseArguments($_SERVER['argv']);$cli->exec();exit; \ No newline at end of file +class DBSR{const VERSION='2.2.0';const OPTION_CASE_INSENSITIVE=0;const OPTION_EXTENSIVE_SEARCH=1;const OPTION_SEARCH_PAGE_SIZE=2;const OPTION_VAR_MATCH_STRICT=3;const OPTION_FLOATS_PRECISION=4;const OPTION_CONVERT_CHARSETS=5;const OPTION_VAR_CAST_REPLACE=6;const OPTION_DB_WRITE_CHANGES=7;const OPTION_HANDLE_SERIALIZE=8;const OPTION_REVERSED_FILTERS=9;const OPTION_LOCK_TABLES=10;public static function createClass($className){if(!class_exists($className,false)){$classArray=explode('\\',$className);if(count($classArray)>1){$className=array_pop($classArray);$namespace=implode('\\',$classArray);eval('namespace '.$namespace.' { class '.$className.' {} }');}else{eval('class '.$className.' {}');}}}public static function getPHPType($mysql_type){$types=array('/^\s*BOOL(EAN)?\s*$/i'=>'boolean','/^\s*TINYINT\s*(?:\(\s*\d+\s*\)\s*)?$/i'=>'integer','/^\s*SMALLINT\s*(?:\(\s*\d+\s*\)\s*)?$/i'=>'integer','/^\s*MEDIUMINT\s*(?:\(\s*\d+\s*\)\s*)?$/i'=>'integer','/^\s*INT(EGER)?\s*(?:\(\s*\d+\s*\)\s*)?$/i'=>'integer','/^\s*BIGINT\s*(?:\(\s*\d+\s*\)\s*)?$/i'=>'integer','/^\s*FLOAT\s*(?:\(\s*\d+\s*(?:,\s*\d+\s*)?\)\s*)?$/i'=>'float','/^\s*DOUBLE(\s+PRECISION)?\s*(?:\(\s*\d+\s*(?:,\s*\d+\s*)?\)\s*)?$/i'=>'float','/^\s*REAL\s*(?:\(\s*\d+\s*(?:,\s*\d+\s*)?\)\s*)?$/i'=>'float','/^\s*DEC(IMAL)?\s*(?:\(\s*\d+\s*(?:,\s*\d+\s*)?\)\s*)?$/i'=>'float','/^\s*NUMERIC\s*(?:\(\s*\d+\s*(?:,\s*\d+\s*)?\)\s*)?$/i'=>'float','/^\s*FIXED\s*(?:\(\s*\d+\s*(?:,\s*\d+\s*)?\)\s*)?$/i'=>'float',);foreach($types as $regex=>$type){if(preg_match($regex,$mysql_type)){return $type;}}return 'string';}protected $pdo;private $_pdo_charset;private $_pdo_collation;private $_dbr_callback;protected $options=array(self::OPTION_CASE_INSENSITIVE=>false,self::OPTION_EXTENSIVE_SEARCH=>false,self::OPTION_SEARCH_PAGE_SIZE=>10000,self::OPTION_VAR_MATCH_STRICT=>true,self::OPTION_FLOATS_PRECISION=>5,self::OPTION_CONVERT_CHARSETS=>true,self::OPTION_VAR_CAST_REPLACE=>true,self::OPTION_DB_WRITE_CHANGES=>true,self::OPTION_HANDLE_SERIALIZE=>true,self::OPTION_REVERSED_FILTERS=>false,self::OPTION_LOCK_TABLES=>true,);protected $filters=array();protected $search=array();protected $replace=array();protected $search_converted=array();public function __construct(PDO$pdo){if(!extension_loaded('pcre')){throw new RuntimeException('The pcre (Perl-compatible regular expressions) extension is required for DBSR to work!');}if($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)!='mysql'){throw new InvalidArgumentException('The given PDO instance is not representing an MySQL database!');}$this->pdo=$pdo;}public function getOption($option){return isset($this->options[$option])?$this->options[$option]:null;}public function setOption($option,$value){if(!isset($this->options[$option])){return false;}switch($option){case static ::OPTION_SEARCH_PAGE_SIZE:if(is_int($value)&&$value>0){$this->options[$option]=$value;return true;}else{return false;}case static ::OPTION_FLOATS_PRECISION:if(is_int($value)&&$value>=0){$this->options[$option]=$value;return true;}else{return false;}default:if(gettype($this->options[$option])==gettype($value)){$this->options[$option]=$value;return true;}else{return false;}}}public function setFilters(array$filters){$filters_parsed=array();foreach($filters as $key=>$value){if(is_int($key)){if(is_string($value)){$filters_parsed[$value]=true;}elseif(is_array($value)){if(!count($value)){continue;}foreach($value as $v){if(!is_string($v)){throw new InvalidArgumentException('Only strings qualify as column names!');}}if(isset($filters_parsed['.'])){$filters_parsed['.']=array_values(array_unique(array_merge($filters_parsed['.'],array_values($value))));}else{$filters_parsed['.']=array_values(array_unique($value));}}else{throw new InvalidArgumentException('The filter array can only contain strings or arrays!');}}else{if(is_string($value)){if(isset($filters_parsed[$key])){$filters_parsed[$key]=array_values(array_unique(array_merge($filters_parsed[$key],array($value))));}else{$filters_parsed[$key]=array($value);}}elseif(is_array($value)){if(!count($value)){continue;}foreach($value as $v){if(!is_string($v)){throw new InvalidArgumentException('Only strings qualify as column names!');}}if(isset($filters_parsed[$key])){$filters_parsed[$key]=array_values(array_unique(array_merge($filters_parsed[$key],array_values($value))));}else{$filters_parsed[$key]=array_values(array_unique($value));}}else{throw new InvalidArgumentException('The filter array can only contain strings or arrays!');}}}$this->filters=$filters_parsed;}public function resetFilters(){$this->filters=array();}public function isFiltered($table,$column=null){if($this->getOption(static ::OPTION_REVERSED_FILTERS)){if($column==null){return false;}else{return!(isset($this->filters[$table])&&$this->filters[$table]===true||isset($this->filters[$table])&&in_array($column,$this->filters[$table],true)||isset($this->filters['.'])&&in_array($column,$this->filters['.'],true));}}else{if($column==null){return isset($this->filters[$table])&&$this->filters[$table]===true;}else{return isset($this->filters[$table])&&$this->filters[$table]===true||isset($this->filters[$table])&&in_array($column,$this->filters[$table],true)||isset($this->filters['.'])&&in_array($column,$this->filters['.'],true);}}}public function setValues(array$search,array$replace){if(count($search)==0||count($replace)==0||count($search)!=count($replace)){throw new InvalidArgumentException('The number of search- and replace-values is invalid!');}$search=array_values($search);$replace=array_values($replace);for($i=0;$i
'.htmlspecialchars($output).''."\n".''."\n".'';}ob_start('DBSR_CLI_output');}$cli=new DBSR_CLI();$cli->parseArguments($_SERVER['argv']);$cli->exec();exit; \ No newline at end of file diff --git a/compiled/DBSearchReplace-GUI.php b/compiled/DBSearchReplace-GUI.php index 41cd73e..8a69cfe 100644 --- a/compiled/DBSearchReplace-GUI.php +++ b/compiled/DBSearchReplace-GUI.php @@ -14,4 +14,4 @@ * You should have received a copy of the GNU General Public License * along with DBSR. If not, see
DBSR version VERSION GUI