1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-07 19:35:47 +02:00

Various bug fixes

This commit is contained in:
SecretR 2013-10-14 15:38:57 +03:00
parent 37ee3f132a
commit 2bdcceab9c
9 changed files with 20 additions and 43 deletions

View File

@ -3949,7 +3949,7 @@ class eResponse
$attrData .= '<meta'; $attrData .= '<meta';
foreach ($attr as $p => $v) foreach ($attr as $p => $v)
{ {
$attrData .= ' '.preg_replace('/[^\w\pL\-]/u', '', $p).'="'.str_replace(array('"', '<'), '', $v).'"'; $attrData .= ' '.preg_replace('/[^\w\-]/', '', $p).'="'.str_replace(array('"', '<'), '', $v).'"';
} }
$attrData .= ' />'."\n"; $attrData .= ' />'."\n";
} }

View File

@ -251,7 +251,7 @@ class convert
$tdata['tm_hour'], $tdata['tm_hour'],
$tdata['tm_min'], $tdata['tm_min'],
$tdata['tm_sec'], $tdata['tm_sec'],
$tdata['tm_mon'] + 1, $tdata['tm_mon'],
$tdata['tm_mday'], $tdata['tm_mday'],
($tdata['tm_year'] + 1900) ($tdata['tm_year'] + 1900)
); );

View File

@ -1207,10 +1207,10 @@ class e_parse extends e_parser
// it should work for any characters encoding // it should work for any characters encoding
// FIXME - INVESTIGATE this one, switch to utf8 aware methods // FIXME - INVESTIGATE this one, switch to utf8 aware methods
$leftAmp = $this->ustrrpos($this->usubstr($ret, -8), '&'); $leftAmp = strrpos(substr($ret, -8), '&');
if($leftAmp) if($leftAmp)
{ {
$ret = $this->usubstr($ret, 0, $this->ustrlen($ret) - 8 + $leftAmp); $ret = substr($ret, 0, strlen($ret) - 8 + $leftAmp);
} }
return $ret.$more; return $ret.$more;

View File

@ -687,30 +687,14 @@ class e_form
{ {
if(!is_array($options)) parse_str($options, $options); if(!is_array($options)) parse_str($options, $options);
$default_name = vartrue($default_name, ''); $default_name = vartrue($default_name,USERNAME);
$default_id = vartrue($default_id, 0); $default_id = vartrue($default_id,USERID);
//TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ? //TODO Auto-calculate $name_fld from $id_fld ie. append "_usersearch" here ?
$fldid = $this->name2id($name_fld); return $this->text($name_fld,$default_name,20, "class=e-tip&title=Type name of user&typeahead=users&readonly=".vartrue($options['readonly']))
$hidden_fldid = $this->name2id($id_fld); .$this->hidden($id_fld,$default_id, array('id' => $this->name2id($id_fld)))." id# ".$default_id;
$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# <span id='{$fldid}-id'>".$default_id.'</span>';
$ret .= " <a href='#' id='{$fldid}-reset'>reset</a>";
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'; $label_fld = str_replace('_', '-', $name_fld).'-upicker-lable';

View File

@ -1453,11 +1453,10 @@ class e_model extends e_object
/** /**
* Generic load data from DB * Generic load data from DB
* @param mixed $id
* @param boolean $force * @param boolean $force
* @return e_model * @return e_model
*/ */
public function load($id = null, $force = false) public function load($id, $force = false)
{ {
if(!$force && $this->getId()) if(!$force && $this->getId())
{ {
@ -1469,8 +1468,8 @@ class e_model extends e_object
$this->setData(array()) $this->setData(array())
->_clearCacheData(); ->_clearCacheData();
} }
if($id) $id = e107::getParser()->toDB($id); $id = e107::getParser()->toDB($id);
if(!$id && !$this->getParam('db_query')) if(!$id)
{ {
return $this; return $this;
} }
@ -2659,7 +2658,7 @@ class e_front_model extends e_model
return 0; return 0;
} }
$sql = e107::getDb(); $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) if(!$res)
{ {
$this->_db_errno = $sql->getLastErrorNumber(); $this->_db_errno = $sql->getLastErrorNumber();
@ -2846,7 +2845,7 @@ class e_admin_model extends e_front_model
return false; return false;
} }
$sql = e107::getDb(); $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) if(!$res)
{ {
$this->_db_errno = $sql->getLastErrorNumber(); $this->_db_errno = $sql->getLastErrorNumber();
@ -3422,7 +3421,7 @@ class e_front_tree_model extends e_tree_model
} }
$idstr = implode(', ', $ids); $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_errno = $sql->getLastErrorNumber();
$this->_db_errmsg = $sql->getLastErrorText(); $this->_db_errmsg = $sql->getLastErrorText();
if(!$res) if(!$res)

View File

@ -393,7 +393,7 @@ class e_db_mysql
if ($debug == 'now') if ($debug == 'now')
{ {
echo "<pre>** $query</pre><br />\n"; echo "** $query<br />\n";
} }
if ($debug !== FALSE || strstr($_SERVER['QUERY_STRING'], 'showsql')) if ($debug !== FALSE || strstr($_SERVER['QUERY_STRING'], 'showsql'))
{ {

View File

@ -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 string $url
* @param boolean $replace - default TRUE * @param boolean $replace - default TRUE
* @param integer|null $http_response_code - default NULL * @param integer|null $http_response_code - default NULL
* @param boolean $preventCache
* @return void * @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()) if(session_id())
{ {
e107::getSession()->end(); 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) if(null === $http_response_code)
{ {
header('Location: '.$url, $replace); header('Location: '.$url, $replace);

View File

@ -338,7 +338,7 @@ class UserHandler
*/ */
public function generateRandomString($pattern, $seed = '') public function generateRandomString($pattern, $seed = '')
{ {
if (empty($pattern)) if (strlen($pattern) < 6)
$pattern = '##....'; $pattern = '##....';
$newname = ''; $newname = '';

View File

@ -119,7 +119,7 @@ class login_menu_class
if(($tmp = getcachedvars('loginbox_elist')) !== FALSE) return $tmp; if(($tmp = getcachedvars('loginbox_elist')) !== FALSE) return $tmp;
$ret = array(); $ret = array();
//$lbox_admin = varsettrue($eplug_admin, false); $lbox_admin = varsettrue($eplug_admin, false);
$coreplugs = $this->get_coreplugs(); $coreplugs = $this->get_coreplugs();
$lprefs = varsettrue($this->loginPrefs['external_links']) ? explode(',', $this->loginPrefs['external_links']) : array(); $lprefs = varsettrue($this->loginPrefs['external_links']) ? explode(',', $this->loginPrefs['external_links']) : array();