mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Code optimization and cleaning
This commit is contained in:
@@ -381,7 +381,7 @@ class usersettings_shortcodes extends e_shortcode
|
||||
|
||||
foreach($catList as $cat)
|
||||
{
|
||||
cachevars("extendedcat_{$cat['user_extended_struct_id']}", $cat);
|
||||
e107::setRegistry("extendedcat_{$cat['user_extended_struct_id']}", $cat);
|
||||
$text = $this->sc_userextended_cat($cat['user_extended_struct_id']);
|
||||
$ret .= $text;
|
||||
$catName = vartrue($cat['user_extended_struct_text'], $cat['user_extended_struct_name']);
|
||||
@@ -425,7 +425,7 @@ class usersettings_shortcodes extends e_shortcode
|
||||
return "";
|
||||
}
|
||||
$ret = "";
|
||||
$catInfo = getcachedvars("extendedcat_{$parm}");
|
||||
$catInfo = e107::getRegistry("extendedcat_{$parm}");
|
||||
if(!$catInfo)
|
||||
{
|
||||
$qry = "
|
||||
@@ -456,7 +456,7 @@ class usersettings_shortcodes extends e_shortcode
|
||||
$fieldList = $sql->db_getList();
|
||||
foreach($fieldList as $field)
|
||||
{
|
||||
cachevars("extendedfield_{$field['user_extended_struct_name']}", $field);
|
||||
e107::setRegistry("extendedfield_{$field['user_extended_struct_name']}", $field);
|
||||
//TODO use $this instead of parseTemplate();
|
||||
$ret .= $this->sc_userextended_field($field['user_extended_struct_name']);
|
||||
// $ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes);
|
||||
@@ -509,7 +509,7 @@ class usersettings_shortcodes extends e_shortcode
|
||||
|
||||
$ret = "";
|
||||
|
||||
$fInfo = getcachedvars("extendeddata_{$parm}");
|
||||
$fInfo = e107::getRegistry("extendeddata_{$parm}");
|
||||
|
||||
if(!$fInfo)
|
||||
{
|
||||
|
@@ -584,7 +584,7 @@ function nextprev_shortcode($parm = '')
|
||||
|
||||
|
||||
|
||||
if($cached_parms = getcachedvars('nextprev'))
|
||||
if($cached_parms = e107::getRegistry('nextprev'))
|
||||
{
|
||||
$tmp = $cached_parms;
|
||||
foreach($tmp as $key => $val)
|
||||
|
@@ -1423,7 +1423,7 @@ class comment
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = getcachedvars('e_comment');
|
||||
$data = e107::getRegistry('e_comment');
|
||||
if ($data !== FALSE)
|
||||
{
|
||||
return $data;
|
||||
|
@@ -53,7 +53,7 @@ class db_table_admin
|
||||
}
|
||||
$row = $sql->db_Fetch('num');
|
||||
$tmp = str_replace("`", "", stripslashes($row[1])).';'; // Add semicolon to work with our parser
|
||||
$count = preg_match_all("#CREATE\s+?TABLE\s+?`{0,1}({$prefix}{$table_name})`{0,1}\s+?\((.*?)\)\s+?(?:TYPE|ENGINE)\s*\=\s*(.*?);#is", $tmp, $matches, PREG_SET_ORDER);
|
||||
$count = preg_match_all("#CREATE\s+?TABLE\s+?`?({$prefix}{$table_name})`?\s+?\((.*?)\)\s+?(?:TYPE|ENGINE)\s*\=\s*(.*?);#is", $tmp, $matches, PREG_SET_ORDER);
|
||||
if ($count === FALSE)
|
||||
{
|
||||
return "Error occurred";
|
||||
@@ -112,7 +112,7 @@ class db_table_admin
|
||||
$table_name = '\w+?';
|
||||
}
|
||||
// Regex should be identical to that in get_current_table (apart from the source text variable name)
|
||||
$count = preg_match_all("#CREATE\s+?TABLE\s+?`{0,1}({$table_name})`{0,1}\s+?\((.*?)\)\s+?(?:TYPE|ENGINE)\s*\=\s*(.*?);#is", $this->file_buffer, $matches, PREG_SET_ORDER);
|
||||
$count = preg_match_all("#CREATE\s+?TABLE\s+?`?({$table_name})`?\s+?\((.*?)\)\s+?(?:TYPE|ENGINE)\s*\=\s*(.*?);#is", $this->file_buffer, $matches, PREG_SET_ORDER);
|
||||
if ($count === false)
|
||||
{
|
||||
return "Error occurred";
|
||||
|
@@ -2383,7 +2383,7 @@ class e_db_pdo implements e_db
|
||||
$row = $this->fetch('num');
|
||||
$qry = $row[1];
|
||||
// $qry = str_replace($old, $new, $qry);
|
||||
$qry = preg_replace("#CREATE\sTABLE\s`{0,1}".$old."`{0,1}\s#", "CREATE TABLE {$new} ", $qry, 1); // More selective search
|
||||
$qry = preg_replace("#CREATE\sTABLE\s`?".$old."`?\s#", "CREATE TABLE {$new} ", $qry, 1); // More selective search
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -1061,7 +1061,7 @@ class e_parse extends e_parser
|
||||
if ($utf8)
|
||||
{
|
||||
// Pull out a piece of the maximum permissible length
|
||||
if (preg_match('#^((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$width.'})(.{0,1}).*#s',$sp,$matches) == 0)
|
||||
if (preg_match('#^((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$width.'})(.?).*#s',$sp,$matches) == 0)
|
||||
{
|
||||
// Make any problems obvious for now
|
||||
$value .= '[!<b>invalid utf-8: '.$sp.'<b>!]';
|
||||
|
@@ -346,7 +346,7 @@ class e_jshelper
|
||||
* @param string $errextended
|
||||
* @access public
|
||||
*/
|
||||
public function sendAjaxError($errcode, $errmessage, $errextended = '')
|
||||
public static function sendAjaxError($errcode, $errmessage, $errextended = '')
|
||||
{
|
||||
header('Content-type: text/html; charset='.CHARSET);
|
||||
header("HTTP/1.0 {$errcode} {$errmessage}");
|
||||
|
@@ -2159,7 +2159,7 @@ class e_db_mysql implements e_db
|
||||
*/
|
||||
public function resetTableList()
|
||||
{
|
||||
return $this->db_ResetTableList();
|
||||
$this->db_ResetTableList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1180,11 +1180,12 @@ class themeHandler
|
||||
if(isset($_POST['submit_adminstyle']))
|
||||
{
|
||||
$this->id = $this->curTheme;
|
||||
if($this->setAdminStyle())
|
||||
$this->setAdminStyle(); // this redirects.
|
||||
/*if($this->setAdminStyle())
|
||||
{
|
||||
eMessage::getInstance()->add(TPVLAN_43, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
e107::getConfig()->save(true);
|
||||
e107::getConfig()->save(true);*/
|
||||
}
|
||||
|
||||
if(isset($_POST['submit_style']))
|
||||
|
@@ -166,7 +166,7 @@ class alt_login
|
||||
$newUser['data'] = $db_vals;
|
||||
validatorClass::addFieldTypes($userMethods->userVettingInfo,$newUser);
|
||||
$newUser['WHERE'] = '`user_id`='.$row['user_id'];
|
||||
$aa_sql->db_Update('user',$newUser);
|
||||
$aa_sql->update('user',$newUser);
|
||||
if (AA_DEBUG1) $this->e107->admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User data update: ".print_r($newUser,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
}
|
||||
foreach ($xFields as $k => $v)
|
||||
@@ -184,14 +184,14 @@ class alt_login
|
||||
$ue->addFieldTypes($xArray); // Add in the data types for storage
|
||||
$xArray['WHERE'] = '`user_extended_id`='.intval($row['user_id']);
|
||||
if (AA_DEBUG) $this->e107->admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","User xtnd update: ".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
$aa_sql->db_Update('user_extended',$xArray );
|
||||
$aa_sql->update('user_extended',$xArray );
|
||||
}
|
||||
else
|
||||
{ // Never been an extended user fields record for this user
|
||||
$xArray['data']['user_extended_id'] = $row['user_id'];
|
||||
$ue->addDefaultFields($xArray); // Add in the data types for storage, plus any default values
|
||||
if (AA_DEBUG) $this->e107->admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Alt auth login","Write new extended record".print_r($xFields,TRUE),FALSE,LOG_TO_ROLLING);
|
||||
$aa_sql->db_Insert('user_extended',$xArray);
|
||||
$aa_sql->insert('user_extended',$xArray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -545,7 +545,7 @@ $columnInfo = array(
|
||||
$foundSome = false;
|
||||
foreach($files as $file)
|
||||
{
|
||||
if (0 == $sql->db_Count('download', '(*)', " WHERE download_url='".$file['fname']."'")) {
|
||||
if (0 == $sql->count('download', '(*)', " WHERE download_url='".$file['fname']."'")) {
|
||||
if (!$foundSome) {
|
||||
// $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform");
|
||||
$text .= '<form method="post" action="'.e_SELF.'?'.e_QUERY.'" id="myform">
|
||||
@@ -816,7 +816,7 @@ $columnInfo = array(
|
||||
$files = $efile->get_files(e_DOWNLOAD);
|
||||
$foundSome = false;
|
||||
foreach($files as $file) {
|
||||
if (0 == $sql->db_Count('download', '(*)', " WHERE download_url='".$file['fname']."'")) {
|
||||
if (0 == $sql->count('download', '(*)', " WHERE download_url='".$file['fname']."'")) {
|
||||
if (!$foundSome) {
|
||||
// $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform");
|
||||
$text .= '<form method="post" action="'.e_SELF.'?'.e_QUERY.'" id="myform">
|
||||
@@ -1877,7 +1877,7 @@ $columnInfo = array(
|
||||
$updateArray = array_merge($dlInfo,$dlMirrors);
|
||||
$updateArray['WHERE'] = 'download_id='.intval($id);
|
||||
|
||||
$mes->addAuto($sql->db_Update('download',$updateArray), 'update', DOWLAN_2." (<a href='".e_PLUGIN."download/download.php?view.".$id."'>".$_POST['download_name']."</a>)");
|
||||
$mes->addAuto($sql->update('download',$updateArray), 'update', DOWLAN_2." (<a href='".e_PLUGIN."download/download.php?view.".$id."'>".$_POST['download_name']."</a>)");
|
||||
|
||||
$dlInfo['download_id'] = $id;
|
||||
$this->downloadLog('DOWNL_06',$dlInfo,$dlMirrors);
|
||||
@@ -1909,7 +1909,7 @@ $columnInfo = array(
|
||||
|
||||
if ($_POST['remove_upload'])
|
||||
{
|
||||
$sql->db_Update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'");
|
||||
$sql->update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'");
|
||||
$mess = "<br/>".$_POST['download_name']." ".DOWLAN_104;
|
||||
$mess .= "<br/><br/><a href='".e_ADMIN."upload.php'>".DOWLAN_105."</a>";
|
||||
$this->show_message($mess);
|
||||
@@ -1956,7 +1956,7 @@ $columnInfo = array(
|
||||
|
||||
if ($delete == "mirror")
|
||||
{
|
||||
$mes->addAuto($sql -> db_Delete("download_mirror", "mirror_id=".$del_id), delete, DOWLAN_135);
|
||||
$mes->addAuto($sql ->delete("download_mirror", "mirror_id=".$del_id), delete, DOWLAN_135);
|
||||
e107::getLog()->add('DOWNL_14','ID: '.$del_id,E_LOG_INFORMATIVE,'');
|
||||
}
|
||||
|
||||
@@ -2107,12 +2107,12 @@ $columnInfo = array(
|
||||
|
||||
if (isset($_POST['id']))
|
||||
{
|
||||
$mes->addAuto($sql -> db_Update("download_mirror", "mirror_name='{$name}', mirror_url='{$url}', mirror_image='".$tp->toDB($_POST['mirror_image'])."', mirror_location='{$location}', mirror_description='{$description}' WHERE mirror_id=".intval($_POST['id'])), 'update', DOWLAN_133);
|
||||
$mes->addAuto($sql ->update("download_mirror", "mirror_name='{$name}', mirror_url='{$url}', mirror_image='".$tp->toDB($_POST['mirror_image'])."', mirror_location='{$location}', mirror_description='{$description}' WHERE mirror_id=".intval($_POST['id'])), 'update', DOWLAN_133);
|
||||
e107::getLog()->add('DOWNL_13','ID: '.intval($_POST['id']).'[!br!]'.$logString,E_LOG_INFORMATIVE,'');
|
||||
}
|
||||
else
|
||||
{
|
||||
$mes->addAuto($sql -> db_Insert("download_mirror", "0, '{$name}', '{$url}', '".$tp->toDB($_POST['mirror_image'])."', '{$location}', '{$description}', 0"), 'insert', DOWLAN_134);
|
||||
$mes->addAuto($sql ->insert("download_mirror", "0, '{$name}', '{$url}', '".$tp->toDB($_POST['mirror_image'])."', '{$location}', '{$description}', 0"), 'insert', DOWLAN_134);
|
||||
e107::getLog()->add('DOWNL_12',$logString,E_LOG_INFORMATIVE,'');
|
||||
}
|
||||
}
|
||||
|
@@ -82,7 +82,7 @@ if (isset($_POST['faq_submit']))
|
||||
{
|
||||
$faq_question = $tp->toDB($_POST['faq_question']);
|
||||
$data = $tp->toDB($_POST['data']);
|
||||
$count = ($sql->db_Count("faqs", "(*)", "WHERE faq_parent='".intval($_POST['faq_parent'])."' ") + 1);
|
||||
$count = ($sql->count("faqs", "(*)", "WHERE faq_parent='".intval($_POST['faq_parent'])."' ") + 1);
|
||||
|
||||
$sql->insert("faqs", " 0, '".$_POST['faq_parent']."', '$faq_question', '$data', '".filter_var($_POST['faq_comment'], FILTER_SANITIZE_STRING)."', '".time()."', '".USERID."', '".$count."' ");
|
||||
|
||||
|
@@ -550,11 +550,11 @@
|
||||
if($forum->prefs->get('sig_once'))
|
||||
{
|
||||
$_tmp = 'forum_sig_shown_' . $this->postInfo['post_user'];
|
||||
if(getcachedvars($_tmp))
|
||||
if(e107::getRegistry($_tmp))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
cachevars($_tmp, 1);
|
||||
e107::setRegistry($_tmp, 1);
|
||||
}
|
||||
|
||||
if($parm == 'clean')
|
||||
|
@@ -68,7 +68,7 @@ class pmbox_manager
|
||||
$pm_info[$which] = $this->pmDB->fetch();
|
||||
if ($which == 'inbox' && ($this->pmPrefs['animate'] == 1 || $this->pmPrefs['popup'] == 1))
|
||||
{
|
||||
if($new = $this->pmDB->db_Count('private_msg', '(*)', "WHERE pm_sent > '".USERLV."' AND pm_read = 0 AND pm_to = '".USERID."' AND pm_read_del != 1"))
|
||||
if($new = $this->pmDB->count('private_msg', '(*)', "WHERE pm_sent > '".USERLV."' AND pm_read = 0 AND pm_to = '".USERID."' AND pm_read_del != 1"))
|
||||
{
|
||||
$pm_info['inbox']['new'] = $new;
|
||||
}
|
||||
|
@@ -31,8 +31,8 @@ class pm_setup
|
||||
function uninstall_post()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$sql->db_Delete('core', "e107_name = 'pm_prefs'");
|
||||
$sql->db_Delete('menus', "menu_name = 'private_msg_menu'");
|
||||
$sql->delete('core', "e107_name = 'pm_prefs'");
|
||||
$sql->delete('menus', "menu_name = 'private_msg_menu'");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -490,7 +490,7 @@ class tinymce
|
||||
if($id)
|
||||
{
|
||||
$insert_array['WHERE'] = $this->primary." = ".$id;
|
||||
$status = $sql->db_Update($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED;
|
||||
$status = $sql->update($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED;
|
||||
$message = LAN_UPDATED;
|
||||
|
||||
|
||||
@@ -499,7 +499,7 @@ class tinymce
|
||||
}
|
||||
else
|
||||
{
|
||||
$status = $sql->db_Insert($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED;
|
||||
$status = $sql->insert($this->table,$insert_array) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED;
|
||||
$message = LAN_CREATED;
|
||||
}
|
||||
|
||||
@@ -518,7 +518,7 @@ class tinymce
|
||||
$sql = e107::getDb();
|
||||
|
||||
$query = $this->primary." = ".$id;
|
||||
$status = $sql->db_Delete($this->table,$query) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED;
|
||||
$status = $sql->delete($this->table,$query) ? E_MESSAGE_SUCCESS : E_MESSAGE_FAILED;
|
||||
$message = LAN_DELETED;
|
||||
$emessage->add($message, $status);
|
||||
}
|
||||
|
Reference in New Issue
Block a user