From 2bdcceab9ca29109c8f023527e9fee43f48ce99c Mon Sep 17 00:00:00 2001 From: SecretR Date: Mon, 14 Oct 2013 15:38:57 +0300 Subject: [PATCH] Various bug fixes --- e107_handlers/application.php | 2 +- e107_handlers/date_handler.php | 2 +- e107_handlers/e_parse_class.php | 4 ++-- e107_handlers/form_handler.php | 24 ++++---------------- e107_handlers/model_class.php | 13 +++++------ e107_handlers/mysql_class.php | 2 +- e107_handlers/redirection_class.php | 12 +++------- e107_handlers/user_handler.php | 2 +- e107_plugins/login_menu/login_menu_class.php | 2 +- 9 files changed, 20 insertions(+), 43 deletions(-) diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 2356ff327..99915b0ca 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -3949,7 +3949,7 @@ class eResponse $attrData .= ' $v) { - $attrData .= ' '.preg_replace('/[^\w\pL\-]/u', '', $p).'="'.str_replace(array('"', '<'), '', $v).'"'; + $attrData .= ' '.preg_replace('/[^\w\-]/', '', $p).'="'.str_replace(array('"', '<'), '', $v).'"'; } $attrData .= ' />'."\n"; } diff --git a/e107_handlers/date_handler.php b/e107_handlers/date_handler.php index e298c598c..fc8646ce7 100644 --- a/e107_handlers/date_handler.php +++ b/e107_handlers/date_handler.php @@ -251,7 +251,7 @@ class convert $tdata['tm_hour'], $tdata['tm_min'], $tdata['tm_sec'], - $tdata['tm_mon'] + 1, + $tdata['tm_mon'], $tdata['tm_mday'], ($tdata['tm_year'] + 1900) ); diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 81ecd1129..fe5e9e41b 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1207,10 +1207,10 @@ class e_parse extends e_parser // it should work for any characters encoding // FIXME - INVESTIGATE this one, switch to utf8 aware methods - $leftAmp = $this->ustrrpos($this->usubstr($ret, -8), '&'); + $leftAmp = strrpos(substr($ret, -8), '&'); if($leftAmp) { - $ret = $this->usubstr($ret, 0, $this->ustrlen($ret) - 8 + $leftAmp); + $ret = substr($ret, 0, strlen($ret) - 8 + $leftAmp); } return $ret.$more; diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 9809888a4..149c27e17 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -687,30 +687,14 @@ class e_form { if(!is_array($options)) parse_str($options, $options); - $default_name = vartrue($default_name, ''); - $default_id = vartrue($default_id, 0); + $default_name = vartrue($default_name,USERNAME); + $default_id = vartrue($default_id,USERID); //TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ? - $fldid = $this->name2id($name_fld); - $hidden_fldid = $this->name2id($id_fld); - - $ret = $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly'])) - .$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# ".$default_id.''; - $ret .= " reset"; + return $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly'])) + .$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# ".$default_id; - e107::getJs()->footerInline(" - \$('#{$fldid}').blur(function () { - \$('#{$fldid}-id').html(\$('#{$hidden_fldid}').val()); - }); - \$('#{$fldid}-reset').click(function () { - \$('#{$fldid}-id').html('0'); - \$('#{$hidden_fldid}').val(0); - \$('#{$fldid}').val(''); - }); - "); - - return $ret; /* $label_fld = str_replace('_', '-', $name_fld).'-upicker-lable'; diff --git a/e107_handlers/model_class.php b/e107_handlers/model_class.php index f22cb8bbc..e59ac2dd2 100644 --- a/e107_handlers/model_class.php +++ b/e107_handlers/model_class.php @@ -1453,11 +1453,10 @@ class e_model extends e_object /** * Generic load data from DB - * @param mixed $id * @param boolean $force * @return e_model */ - public function load($id = null, $force = false) + public function load($id, $force = false) { if(!$force && $this->getId()) { @@ -1469,8 +1468,8 @@ class e_model extends e_object $this->setData(array()) ->_clearCacheData(); } - if($id) $id = e107::getParser()->toDB($id); - if(!$id && !$this->getParam('db_query')) + $id = e107::getParser()->toDB($id); + if(!$id) { return $this; } @@ -2659,7 +2658,7 @@ class e_front_model extends e_model return 0; } $sql = e107::getDb(); - $res = $sql->db_Update($this->getModelTable(), $this->toSqlQuery('update'), $this->getParam('db_debug', false)); + $res = $sql->db_Update($this->getModelTable(), $this->toSqlQuery('update')); if(!$res) { $this->_db_errno = $sql->getLastErrorNumber(); @@ -2846,7 +2845,7 @@ class e_admin_model extends e_front_model return false; } $sql = e107::getDb(); - $res = $sql->db_Insert($this->getModelTable(), $this->toSqlQuery('create'), $this->getParam('db_debug', false)); + $res = $sql->db_Insert($this->getModelTable(), $this->toSqlQuery('create')); if(!$res) { $this->_db_errno = $sql->getLastErrorNumber(); @@ -3422,7 +3421,7 @@ class e_front_tree_model extends e_tree_model } $idstr = implode(', ', $ids); - $res = $sql->db_Update($this->getModelTable(), "{$field}={$value} WHERE ".$this->getFieldIdName().' IN ('.$idstr.')', $this->getParam('db_debug', false)); + $res = $sql->db_Update($this->getModelTable(), "{$field}={$value} WHERE ".$this->getFieldIdName().' IN ('.$idstr.')'); $this->_db_errno = $sql->getLastErrorNumber(); $this->_db_errmsg = $sql->getLastErrorText(); if(!$res) diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index 75f525351..346d9e9cf 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -393,7 +393,7 @@ class e_db_mysql if ($debug == 'now') { - echo "
** $query

\n"; + echo "** $query
\n"; } if ($debug !== FALSE || strstr($_SERVER['QUERY_STRING'], 'showsql')) { diff --git a/e107_handlers/redirection_class.php b/e107_handlers/redirection_class.php index aa479d5c8..cf5c3b35e 100644 --- a/e107_handlers/redirection_class.php +++ b/e107_handlers/redirection_class.php @@ -306,9 +306,9 @@ class redirection } - public function redirect($url, $replace = TRUE, $http_response_code = NULL, $preventCache) + public function redirect($url, $replace = TRUE, $http_response_code = NULL) { - return $this->go($url, $replace, $http_response_code, $preventCache); + return $this->go($url, $replace, $http_response_code); } @@ -318,20 +318,14 @@ class redirection * @param string $url * @param boolean $replace - default TRUE * @param integer|null $http_response_code - default NULL - * @param boolean $preventCache * @return void */ - public function go($url, $replace = TRUE, $http_response_code = NULL, $preventCache = true) + public function go($url, $replace = TRUE, $http_response_code = NULL) { if(session_id()) { e107::getSession()->end(); } - if($preventCache) - { - header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true); - header('Expires: Sat, 26 Jul 1997 05:00:00 GMT', true); - } if(null === $http_response_code) { header('Location: '.$url, $replace); diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index 3729b3cc6..975536c7d 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -338,7 +338,7 @@ class UserHandler */ public function generateRandomString($pattern, $seed = '') { - if (empty($pattern)) + if (strlen($pattern) < 6) $pattern = '##....'; $newname = ''; diff --git a/e107_plugins/login_menu/login_menu_class.php b/e107_plugins/login_menu/login_menu_class.php index 58c32cd6e..24117ca59 100644 --- a/e107_plugins/login_menu/login_menu_class.php +++ b/e107_plugins/login_menu/login_menu_class.php @@ -119,7 +119,7 @@ class login_menu_class if(($tmp = getcachedvars('loginbox_elist')) !== FALSE) return $tmp; $ret = array(); - //$lbox_admin = varsettrue($eplug_admin, false); + $lbox_admin = varsettrue($eplug_admin, false); $coreplugs = $this->get_coreplugs(); $lprefs = varsettrue($this->loginPrefs['external_links']) ? explode(',', $this->loginPrefs['external_links']) : array();