mirror of
https://github.com/e107inc/e107.git
synced 2025-08-28 16:50:07 +02:00
Code cleanup and optimization
This commit is contained in:
@@ -1717,7 +1717,7 @@ if(isset($page_title[$action]))
|
||||
}
|
||||
// Now put up the events
|
||||
$delete_button = FALSE;
|
||||
while($row = $sql->db_Fetch())
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
$text .= '<tr>';
|
||||
foreach($col_fields[$action] as $cf)
|
||||
|
@@ -64,8 +64,8 @@ if (isset($_POST['edit_admin']) || $action == "edit")
|
||||
{
|
||||
$edid = array_keys($_POST['edit_admin']);
|
||||
$theid = intval(($sub_action < 0) ? $edid[0] : $sub_action);
|
||||
if ((!$sql->db_Select("user", "*", "user_id=".$theid))
|
||||
|| !($row = $sql->db_Fetch()))
|
||||
if ((!$sql->select("user", "*", "user_id=".$theid))
|
||||
|| !($row = $sql->fetch()))
|
||||
{
|
||||
$mes->addDebug("Couldn't find user ID: {$theid}, {$sub_action}, {$edid[0]}"); // Debug code - shouldn't be executed
|
||||
}
|
||||
@@ -76,8 +76,8 @@ if (isset($_POST['del_admin']) && count($_POST['del_admin']))
|
||||
{
|
||||
$delid = array_keys($_POST['del_admin']);
|
||||
$aID = intval($delid[0]);
|
||||
$sql->db_Select("user", "*", "user_id= ".$aID);
|
||||
$row = $sql->db_Fetch();
|
||||
$sql->select("user", "*", "user_id= ".$aID);
|
||||
$row = $sql->fetch();
|
||||
|
||||
if ($row['user_id'] == 1)
|
||||
{ // Can't delete main admin
|
||||
@@ -92,7 +92,7 @@ if (isset($_POST['del_admin']) && count($_POST['del_admin']))
|
||||
exit;
|
||||
}
|
||||
|
||||
$mes->addAuto($sql -> db_Update("user", "user_admin=0, user_perms='' WHERE user_id= ".$aID), 'update', ADMSLAN_61, LAN_DELETED_FAILED, false);
|
||||
$mes->addAuto($sql->update("user", "user_admin=0, user_perms='' WHERE user_id= ".$aID), 'update', ADMSLAN_61, LAN_DELETED_FAILED, false);
|
||||
$logMsg = str_replace(array('[x]', '[y]'),array($aID, $row['user_name']),ADMSLAN_73);
|
||||
e107::getLog()->add('ADMIN_02',$logMsg,E_LOG_INFORMATIVE,'');
|
||||
}
|
||||
|
@@ -186,7 +186,7 @@ else
|
||||
|
||||
if (in_array(varset($pref['user_audit_class'], ''), $class_list))
|
||||
{
|
||||
e107::getAdminLog()->user_audit(USER_AUDIT_LOGIN, 'Login via admin page', $row['user_id'], $row['user_name']);
|
||||
e107::getAdminLog()->user_audit(USER_AUDIT_LOGIN, ['Login via admin page'], $row['user_id'], $row['user_name']);
|
||||
}
|
||||
|
||||
$edata_li = array("user_id"=>$row['user_id'], "user_name"=>$row['user_name'], 'class_list'=>implode(',', $class_list), 'user_admin'=> $row['user_admin']);
|
||||
@@ -412,7 +412,8 @@ class auth
|
||||
* @param string $authname, entered name
|
||||
* @param string $authpass, entered pass
|
||||
* @param object $authresponse [optional]
|
||||
* @return boolean if fail, else result array
|
||||
* @return array if fail, 'authfail' will contain a message.
|
||||
*
|
||||
*/
|
||||
public function authcheck($authname, $authpass, $authresponse = '')
|
||||
{
|
||||
|
@@ -1138,7 +1138,7 @@ if ($writeBanFile)
|
||||
if ($action == 'edit' || $action == 'whedit')
|
||||
{
|
||||
$sql->db_Select('banlist', '*', "banlist_ip='{$sub_action}'");
|
||||
$row = $sql->db_Fetch();
|
||||
$row = $sql->fetch();
|
||||
extract($row); //FIXME - kill extract()
|
||||
}
|
||||
else
|
||||
@@ -1726,7 +1726,7 @@ switch ($action)
|
||||
$text .= "</tr>
|
||||
</thead>
|
||||
<tbody>";
|
||||
while($row = $sql->db_Fetch())
|
||||
while($row = $sql->fetch())
|
||||
{
|
||||
//extract($row);//FIXME - kill extract()
|
||||
$row['banlist_reason'] = str_replace('LAN_LOGIN_18', BANLAN_11, $row['banlist_reason']);
|
||||
@@ -1863,7 +1863,7 @@ function process_csv($filename, $override_imports, $override_expiry, $separator
|
||||
// echo "Read CSV: {$filename} separator: {$separator}, quote: {$quote} override imports: {$override_imports} override expiry: {$override_expiry}<br />";
|
||||
// Renumber imported bans
|
||||
if ($override_imports)
|
||||
$sql->db_Update('banlist', "`banlist_bantype`=".eIPHandler::BAN_TYPE_TEMPORARY." WHERE `banlist_bantype` = ".eIPHandler::BAN_TYPE_IMPORTED);
|
||||
$sql->update('banlist', "`banlist_bantype`=".eIPHandler::BAN_TYPE_TEMPORARY." WHERE `banlist_bantype` = ".eIPHandler::BAN_TYPE_IMPORTED);
|
||||
$temp = file($filename);
|
||||
$line_num = 0;
|
||||
foreach ($temp as $line)
|
||||
@@ -1932,7 +1932,7 @@ function process_csv($filename, $override_imports, $override_expiry, $separator
|
||||
}
|
||||
// Success here - may need to delete old imported bans
|
||||
if ($override_imports)
|
||||
$sql->db_Delete('banlist', "`banlist_bantype` = ".eIPHandler::BAN_TYPE_TEMPORARY);
|
||||
$sql->delete('banlist', "`banlist_bantype` = ".eIPHandler::BAN_TYPE_TEMPORARY);
|
||||
@unlink($filename); // Delete file once done
|
||||
$mes->addSuccess(str_replace('[y]', $line_num, BANLAN_51).$filename);
|
||||
return str_replace('[y]', $line_num, BANLAN_51).$filename;
|
||||
|
@@ -79,7 +79,7 @@ function do_export($filename, $type_list='',$format_array=array(), $sep = ',', $
|
||||
$qry = "SELECT * FROM `#banlist` ";
|
||||
if ($type_list != '') $qry .= " WHERE`banlist_bantype` IN ({$type_list})";
|
||||
if (!$sql->gen($qry)) return 'No data: '.$qry;
|
||||
while ($row = $sql->db_Fetch())
|
||||
while ($row = $sql->fetch())
|
||||
{
|
||||
$line = '';
|
||||
$spacer = '';
|
||||
|
@@ -507,7 +507,7 @@ class media_form_ui extends e_admin_form_ui
|
||||
if($this->resizeImage($path,$img_import_w,$img_import_h))
|
||||
{
|
||||
|
||||
$info = $fl->get_file_info($path);
|
||||
$info = $fl->getFileInfo($path);
|
||||
$mes->addSuccess(LAN_IMA_004.": ".basename($path));
|
||||
$mes->addSuccess(print_a($info,true));
|
||||
$dim = intval($info['img-width'])." x ".intval($info['img-height']);
|
||||
@@ -3045,7 +3045,7 @@ class media_admin_ui extends e_admin_ui
|
||||
$f = e107::getFile()->get_file_info($oldpath,TRUE);
|
||||
|
||||
$mes->addDebug("checkDupe(): newpath=".$newpath."<br />oldpath=".$oldpath."<br />".print_r($newpath,TRUE));
|
||||
if(file_exists($newpath) || e107::getDb()->db_Select("core_media","*","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") )
|
||||
if(file_exists($newpath) || e107::getDb()->select("core_media","*","media_url = '".$tp->createConstants($newpath,'rel')."' LIMIT 1") )
|
||||
{
|
||||
$mes->addWarning($newpath." already exists.");
|
||||
$file = $f['pathinfo']['filename']."_.".$f['pathinfo']['extension'];
|
||||
@@ -3594,7 +3594,7 @@ if (isset($_POST['submit_show_deleteall']))
|
||||
{
|
||||
$image_name = basename($image_name);
|
||||
$image_todb = $tp->toDB($image_name);
|
||||
if (!$sql->db_Count('user', '(*)', "WHERE user_image='-upload-{$image_todb}' OR user_sess='{$image_todb}'")) {
|
||||
if (!$sql->count('user', '(*)', "WHERE user_image='-upload-{$image_todb}' OR user_sess='{$image_todb}'")) {
|
||||
unlink(e_AVATAR_UPLOAD.$image_name);
|
||||
$imgList .= '[!br!]'.$image_name;
|
||||
$count++;
|
||||
@@ -3626,7 +3626,7 @@ if (isset($_POST['submit_avdelete_multi']))
|
||||
$multiaction = $tp->filter($_POST['multiaction'], 'int');
|
||||
|
||||
//sql queries significant reduced
|
||||
if(!empty($multiaction) && $sql->db_Select("user", 'user_id, user_name, user_image', "user_id IN (".implode(',', $multiaction).")"))
|
||||
if(!empty($multiaction) && $sql->select("user", 'user_id, user_name, user_image', "user_id IN (".implode(',', $multiaction).")"))
|
||||
{
|
||||
$search_users = $sql->db_getList('ALL', FALSE, FALSE, 'user_id');
|
||||
foreach($multiaction as $uid)
|
||||
@@ -3648,7 +3648,7 @@ if (isset($_POST['submit_avdelete_multi']))
|
||||
//sql queries significant reduced
|
||||
if(!empty($uids))
|
||||
{
|
||||
$sql->db_Update("user", "user_image='' WHERE user_id IN (".implode(',', $uids).")");
|
||||
$sql->update("user", "user_image='' WHERE user_id IN (".implode(',', $uids).")");
|
||||
}
|
||||
|
||||
$mes->addSuccess(IMALAN_51.'<strong>'.implode(', ', $tmp).'</strong> '.IMALAN_28);
|
||||
@@ -3703,13 +3703,13 @@ if (isset($_POST['check_avatar_sizes']))
|
||||
//
|
||||
// Loop through avatar field for every user
|
||||
//
|
||||
$iUserCount = $sql->db_Count("user");
|
||||
$iUserCount = $sql->count("user");
|
||||
$found = false;
|
||||
$allowedWidth = intval($pref['im_width']);
|
||||
$allowedHeight = intval($pref['im_width']);
|
||||
if ($sql->db_Select("user", "*", "user_image!=''")) {
|
||||
if ($sql->select("user", "*", "user_image!=''")) {
|
||||
|
||||
while ($row = $sql->db_Fetch())
|
||||
while ($row = $sql->fetch())
|
||||
{
|
||||
//Check size
|
||||
$avname=avatar($row['user_image']);
|
||||
|
@@ -692,7 +692,7 @@ class adminstyle_infopanel
|
||||
|
||||
if (e107::getDb()->gen($menu_qry))
|
||||
{
|
||||
while ($row = e107::getDb()->db_Fetch())
|
||||
while ($row = e107::getDb()->fetch())
|
||||
{
|
||||
// Custom menu (core).
|
||||
if(is_numeric($row['menu_path']))
|
||||
|
@@ -661,9 +661,9 @@ class links_admin_form_ui extends e_admin_form_ui
|
||||
{
|
||||
if(null === $this->current_parent)
|
||||
{
|
||||
if(e107::getDb()->db_Select('links', 'link_name', 'link_id='.$current))
|
||||
if(e107::getDb()->select('links', 'link_name', 'link_id='.$current))
|
||||
{
|
||||
$tmp = e107::getDb()->db_Fetch();
|
||||
$tmp = e107::getDb()->fetch();
|
||||
$this->current_parent = $tmp['link_name'];
|
||||
}
|
||||
}
|
||||
|
@@ -1337,7 +1337,7 @@ class news_admin_ui extends e_admin_ui
|
||||
$_POST['cat_id'] = $row['news_category'];
|
||||
$_POST['news_start'] = $row['news_start'];
|
||||
$_POST['news_end'] = $row['news_end'];
|
||||
$_POST['comment_total'] = e107::getDb()->db_Count("comments", "(*)", " WHERE comment_item_id={$row['news_id']} AND comment_type='0'");
|
||||
$_POST['comment_total'] = e107::getDb()->count("comments", "(*)", " WHERE comment_item_id={$row['news_id']} AND comment_type='0'");
|
||||
$_POST['news_render_type'] = $row['news_render_type'];
|
||||
$_POST['news_thumbnail'] = $row['news_thumbnail'];
|
||||
$_POST['news_meta_keywords'] = $row['news_meta_keywords'];
|
||||
|
@@ -136,9 +136,9 @@ if (isset($_POST['update_handler']))
|
||||
$search_prefs[$handler_type][$query[2]]['pre_title_alt'] = $tp -> toDB($_POST['pre_title_alt']);
|
||||
|
||||
// $tmp = addslashes(serialize($search_prefs));
|
||||
$tmp = e107::getArrayStorage()->writeArray($search_prefs, true);
|
||||
$tmp = e107::serialize($search_prefs, true);
|
||||
|
||||
$check = $sql -> db_Update("core", "e107_value='".$tmp."' WHERE e107_name='search_prefs'");
|
||||
$check = $sql ->update("core", "e107_value='".$tmp."' WHERE e107_name='search_prefs'");
|
||||
if($check)
|
||||
{
|
||||
$mes->addSuccess(LAN_UPDATED);
|
||||
|
@@ -1006,11 +1006,11 @@ function update_706_to_800($type='')
|
||||
|
||||
// Leave this one here.. just in case..
|
||||
//delete record for online_extended_menu (now only using one online menu)
|
||||
if($sql->db_Select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'"))
|
||||
if($sql->select('menus', '*', "menu_path='online_extended_menu' || menu_path='online_extended_menu/'"))
|
||||
{
|
||||
if ($just_check) return update_needed("The Menu table needs to have some paths corrected in its data.");
|
||||
|
||||
$row=$sql->db_Fetch();
|
||||
$row=$sql->fetch();
|
||||
|
||||
//if online_extended is activated, we need to activate the new 'online' menu, and delete this record
|
||||
if($row['menu_location']!=0)
|
||||
@@ -1028,7 +1028,7 @@ function update_706_to_800($type='')
|
||||
}
|
||||
|
||||
//change menu_path for online_menu (if it still exists)
|
||||
if($sql->db_Select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'"))
|
||||
if($sql->select('menus', 'menu_path', "menu_path='online_menu' || menu_path='online_menu/'"))
|
||||
{
|
||||
if ($just_check) return update_needed('change menu_path for online menu');
|
||||
|
||||
@@ -1961,7 +1961,7 @@ function update_70x_to_706($type='')
|
||||
|
||||
if ($sql -> db_Query("SHOW INDEX FROM ".MPREFIX."tmp"))
|
||||
{
|
||||
$row = $sql -> db_Fetch();
|
||||
$row = $sql ->fetch();
|
||||
if (!in_array('tmp_ip', $row))
|
||||
{
|
||||
if ($just_check) return update_needed();
|
||||
@@ -2027,9 +2027,9 @@ function copy_user_timezone()
|
||||
|
||||
e107::getMessage()->addDebug("Line:".__LINE__);
|
||||
// Created the field - now copy existing data
|
||||
if ($sql->db_Select('user','user_id, user_timezone'))
|
||||
if ($sql->select('user','user_id, user_timezone'))
|
||||
{
|
||||
while ($row = $sql->db_Fetch())
|
||||
while ($row = $sql->fetch())
|
||||
{
|
||||
$sql2->update('user_extended',"`user_timezone`='{$row['user_timezone']}' WHERE `user_extended_id`={$row['user_id']}");
|
||||
}
|
||||
@@ -2075,7 +2075,7 @@ function addIndexToTable($target, $indexSpec, $just_check, &$updateMessages, $op
|
||||
if ($sql->gen("SHOW INDEX FROM ".MPREFIX.$target))
|
||||
{
|
||||
$found = FALSE;
|
||||
while ($row = $sql -> db_Fetch())
|
||||
while ($row = $sql ->fetch())
|
||||
{ // One index per field
|
||||
if (in_array($indexSpec, $row))
|
||||
{
|
||||
|
@@ -523,8 +523,8 @@ if (e_QUERY)
|
||||
|
||||
if ($action == "dis" && isset($_POST['updelete']['upload_'.$id]) )
|
||||
{
|
||||
$res = $sql -> db_Select("upload", "*", "upload_id='".intval($id)."'");
|
||||
$row = $sql -> db_Fetch();
|
||||
$res = $sql ->select("upload", "*", "upload_id='".intval($id)."'");
|
||||
$row = $sql ->fetch();
|
||||
if (preg_match("#Binary (.*?)/#", $row['upload_file'], $match))
|
||||
{
|
||||
$sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
|
||||
@@ -535,7 +535,7 @@ if ($action == "dis" && isset($_POST['updelete']['upload_'.$id]) )
|
||||
}
|
||||
if (preg_match("#Binary (.*?)/#", $row['upload_ss'], $match))
|
||||
{
|
||||
$sql -> db_Delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
|
||||
$sql ->delete("rbinary", "binary_id='".$tp -> toDB($match[1])."'");
|
||||
}
|
||||
else if ($row['upload_ss'] && file_exists(e_FILE."public/".$row['upload_ss']))
|
||||
{
|
||||
|
@@ -1951,7 +1951,7 @@ class users_admin_ui extends e_admin_ui
|
||||
}
|
||||
// TODO - move to e_userinfo.php
|
||||
$obj = new convert;
|
||||
$sql->db_Select("chatbox", "*", "cb_ip='$ipd' LIMIT 0,20");
|
||||
$sql->select("chatbox", "*", "cb_ip='$ipd' LIMIT 0,20");
|
||||
$host = $e107->get_host_name($ipd);
|
||||
$text = USFLAN_3." <b>".$ipd."</b> [ ".USFLAN_4.": $host ]<br />
|
||||
<i><a href=\"banlist.php?".$ipd."\">".USFLAN_5."</a></i>
|
||||
@@ -1974,7 +1974,7 @@ class users_admin_ui extends e_admin_ui
|
||||
|
||||
$text .= "<hr />";
|
||||
|
||||
$sql->db_Select("comments", "*", "comment_ip='$ipd' LIMIT 0,20");
|
||||
$sql->select("comments", "*", "comment_ip='$ipd' LIMIT 0,20");
|
||||
while (list($comment_id, $comment_item_id, $comment_author, $comment_author_email, $comment_datestamp, $comment_comment, $comment_blocked, $comment_ip) = $sql->fetch())
|
||||
{
|
||||
$datestamp = $obj->convert_date($comment_datestamp, "short");
|
||||
|
Reference in New Issue
Block a user