email regex check update, remove warning surpress in pgsql wrapper, l10n

- l10n class has better mo file load check
- fix email regex for last part is now only on minimum 2 char check
- remove all @ warning surpress in the pgsql wrapper
This commit is contained in:
Clemens Schwaighofer
2017-11-24 13:06:14 +09:00
parent 2e85bf5ee8
commit f0ba8c3c50
5 changed files with 25 additions and 21 deletions

View File

@@ -203,7 +203,7 @@
if (isset($GLOBALS['PRINT'])) if (isset($GLOBALS['PRINT']))
$this->print_output = $GLOBALS['PRINT']; $this->print_output = $GLOBALS['PRINT'];
// exclude these ones from output // exclude these ones from output
if (isset($GLOBALS['DEBUG_NOT'])) if (isset($GLOBALS['DEBUG_NOT']))
$this->debug_output_not = $GLOBALS['DEBUG_NOT']; $this->debug_output_not = $GLOBALS['DEBUG_NOT'];
if (isset($GLOBALS['ECHO_NOT'])) if (isset($GLOBALS['ECHO_NOT']))
@@ -232,12 +232,12 @@
$this->log_per_run = $GLOBALS['LOG_PER_RUN']; $this->log_per_run = $GLOBALS['LOG_PER_RUN'];
// set the regex for checking emails // set the regex for checking emails
$this->email_regex = "^[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+-\/=?^_`{|}~\.]{0,63}@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,6}){1}$"; $this->email_regex = "^[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+-\/=?^_`{|}~\.]{0,63}@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$";
// this is for error check parts in where the email regex failed // this is for error check parts in where the email regex failed
$this->email_regex_check = array ( $this->email_regex_check = array (
1 => "@(.*)@(.*)", // double @ 1 => "@(.*)@(.*)", // double @
2 => "^[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+-\/=?^_`{|}~\.]{0,63}@", // wrong part before @ 2 => "^[A-Za-z0-9!#$%&'*+-\/=?^_`{|}~][A-Za-z0-9!#$%:\(\)&'*+-\/=?^_`{|}~\.]{0,63}@", // wrong part before @
3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,6}){1}$", // wrong part after @ 3 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.([a-zA-Z]{2,}){1}$", // wrong part after @
4 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part 4 => "@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*\.", // wrong domain name part
5 => "\.([a-zA-Z]{2,6}){1}$", // wrong top level part 5 => "\.([a-zA-Z]{2,6}){1}$", // wrong top level part
6 => "@(.*)\.{2,}", // double .. in domain name part 6 => "@(.*)\.{2,}", // double .. in domain name part
@@ -1698,7 +1698,7 @@
// *** COLORS *** // *** COLORS ***
// METHOD: hex2rgb // METHOD: hex2rgb
// PARAMS: hexstring, flag to return as string (true/false), string seperator: default: , // PARAMS: hexstring, flag to return as string (true/false), string seperator: default: ,
// RETURN: array with RGB or a string with the seperator // RETURN: array with RGB or a string with the seperator
// DESC: converts a hex RGB color to the int numbers // DESC: converts a hex RGB color to the int numbers
public static function hex2rgb($hexStr, $returnAsString = false, $seperator = ',') public static function hex2rgb($hexStr, $returnAsString = false, $seperator = ',')

View File

@@ -763,7 +763,7 @@
$this->insert_id[] = $_insert_id; $this->insert_id[] = $_insert_id;
} }
// if we have only one, revert from array to single // if we have only one, revert from array to single
if (count($this->insert_id) >= 1) if (count($this->insert_id) == 1)
{ {
// echo "* SINGLE DATA CONVERT: ".count($this->insert_id[0])." => ".array_key_exists($this->pk_name, $this->insert_id[0])."<br>"; // echo "* SINGLE DATA CONVERT: ".count($this->insert_id[0])." => ".array_key_exists($this->pk_name, $this->insert_id[0])."<br>";
// echo "* PK DIRECT: ".$this->insert_id[0][$this->pk_name]."<Br>"; // echo "* PK DIRECT: ".$this->insert_id[0][$this->pk_name]."<Br>";
@@ -780,6 +780,7 @@
$this->insert_id = $this->insert_id[0][$this->pk_name]; $this->insert_id = $this->insert_id[0][$this->pk_name];
} }
} }
// if we have non -> error
elseif (count($this->insert_id) == 0) elseif (count($this->insert_id) == 0)
{ {
// failed to get insert id // failed to get insert id
@@ -787,6 +788,7 @@
$this->warning_id = 33; $this->warning_id = 33;
$this->_db_error($this->cursor, '[db_exec]'); $this->_db_error($this->cursor, '[db_exec]');
} }
// if we have multiple, do not set the insert_id different, keep as array
} }
// this warning handling is only for pgsql // this warning handling is only for pgsql
// we returned an array of PKs instread of a single one // we returned an array of PKs instread of a single one

View File

@@ -21,7 +21,7 @@
public function __construct($lang) public function __construct($lang)
{ {
SmartyBC::__construct(); SmartyBC::__construct();
_spl_autoload('Class.l10.inc'); _spl_autoload('Class.l10n.inc');
$this->l10n = new l10n($lang); $this->l10n = new l10n($lang);
// variable variable register // variable variable register
$this->register_modifier('getvar', array(&$this, 'get_template_vars')); $this->register_modifier('getvar', array(&$this, 'get_template_vars'));

View File

@@ -35,7 +35,7 @@
private $input; private $input;
private $l10n; private $l10n;
public function __construct($lang = '', $path = '') public function __construct($lang = '', $path = DEFAULT_TEMPLATE)
{ {
foreach (array('streams.php', 'gettext.php') as $include_file) foreach (array('streams.php', 'gettext.php') as $include_file)
_spl_autoload($include_file); _spl_autoload($include_file);
@@ -45,12 +45,12 @@
else else
$this->lang = $lang; $this->lang = $lang;
if (!$path) if (is_dir(LAYOUT.$path.LANG))
$path = DEFAULT_TEMPLATE; $path = LAYOUT.$path.LANG;
if (!is_dir(LAYOUT.$path.LANG)) elseif (!is_dir($path))
$path = ''; $path = '';
$this->mofile = LAYOUT.$path.LANG.$this->lang.".mo"; $this->mofile = $path.$this->lang.".mo";
// check if get a readable mofile // check if get a readable mofile
if (is_readable($this->mofile)) if (is_readable($this->mofile))
@@ -69,10 +69,12 @@
$this->lang = $lang; $this->lang = $lang;
if (!is_dir(LAYOUT.$path.LANG)) if (is_dir(LAYOUT.$path.LANG))
$path = LAYOUT.$path.LANG;
elseif (!is_dir($path))
$path = ''; $path = '';
$this->mofile = LAYOUT.$path.LANG.$this->lang.".mo"; $this->mofile = $path.$this->lang.".mo";
// check if get a readable mofile // check if get a readable mofile
if (is_readable($this->mofile)) if (is_readable($this->mofile))

View File

@@ -67,7 +67,7 @@
{ {
$this->last_error_query = ''; $this->last_error_query = '';
// read out the query status and save the query if needed // read out the query status and save the query if needed
$result = @pg_query($this->dbh, $query); $result = pg_query($this->dbh, $query);
if (!$result) if (!$result)
$this->last_error_query = $query; $this->last_error_query = $query;
return $result; return $result;
@@ -79,7 +79,7 @@
// DESC : sends an async query to the server // DESC : sends an async query to the server
public function _db_send_query($query) public function _db_send_query($query)
{ {
return @pg_send_query($this->dbh, $query); return pg_send_query($this->dbh, $query);
} }
// METHOD: _db_get_result // METHOD: _db_get_result
@@ -102,8 +102,8 @@
public function _db_close() public function _db_close()
{ {
if (is_resource($this->dbh)) if (is_resource($this->dbh))
if (@pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK) if (pg_connection_status($this->dbh) === PGSQL_CONNECTION_OK)
@pg_close($this->dbh); pg_close($this->dbh);
} }
// METHOD: _db_prepare // METHOD: _db_prepare
@@ -112,7 +112,7 @@
// DESC : wrapper for pg_prepare // DESC : wrapper for pg_prepare
public function _db_prepare($name, $query) public function _db_prepare($name, $query)
{ {
$result = @pg_prepare($this->dbh, $name, $query); $result = pg_prepare($this->dbh, $name, $query);
if (!$result) if (!$result)
$this->last_error_query = $query; $this->last_error_query = $query;
return $result; return $result;
@@ -124,7 +124,7 @@
// DESC : wrapper for pg_execute for running a prepared statement // DESC : wrapper for pg_execute for running a prepared statement
public function _db_execute($name, $data) public function _db_execute($name, $data)
{ {
$result = @pg_execute($this->dbh, $name, $data); $result = pg_execute($this->dbh, $name, $data);
if (!$result) if (!$result)
$this->last_error_query = $query; $this->last_error_query = $query;
return $result; return $result;
@@ -295,7 +295,7 @@
{ {
$db_port = 5432; $db_port = 5432;
} }
$this->dbh = @pg_connect("host=".$db_host." port=".$db_port." user=".$db_user." password=".$db_pass." dbname=".$db_name." sslmode=".$db_ssl); $this->dbh = pg_connect("host=".$db_host." port=".$db_port." user=".$db_user." password=".$db_pass." dbname=".$db_name." sslmode=".$db_ssl);
if (!$this->dbh) if (!$this->dbh)
{ {
die("<!-- Can't connect [host=".$db_host." port=".$db_port." user=".$db_user." password=XXXX dbname=".$db_name." sslmode=".$db_ssl."] //-->"); die("<!-- Can't connect [host=".$db_host." port=".$db_port." user=".$db_user." password=XXXX dbname=".$db_name." sslmode=".$db_ssl."] //-->");
@@ -326,7 +326,7 @@
// DESC : wrapper for pg_emta_data // DESC : wrapper for pg_emta_data
public function _db_meta_data($table) public function _db_meta_data($table)
{ {
return @pg_meta_data($this->dbh, $table); return pg_meta_data($this->dbh, $table);
} }
// METHOD: _db_escape_string // METHOD: _db_escape_string