diff --git a/e107_admin/auth.php b/e107_admin/auth.php
index d8b61161e..e4b06022c 100644
--- a/e107_admin/auth.php
+++ b/e107_admin/auth.php
@@ -1,20 +1,17 @@
authcheck($_POST['authname'], $_POST['authpass'], varset($_POST['hashchallenge'],''));
- if ($row[0] == "authfail")
+ if ($row[0] == "authfail")
{
$admin_log->e_log_event(4,__FILE__."|".__FUNCTION__."@".__LINE__,"LOGIN",LAN_ROLL_LOG_11,"U: ".$tp->toDB($_POST['authname']),FALSE,LOG_TO_ROLLING);
echo "\n";
header("location: ../index.php");
exit;
- }
- else
+ }
+ else
{
$cookieval = $row['user_id'].".".md5($row['user_password']);
@@ -88,11 +93,11 @@ else
$edata_li = array("user_id" => $row['user_id'], "user_name" => $row['user_name'], 'class_list' => implode(',',$class_list));
$e_event->trigger("login", $edata_li);
- if ($pref['user_tracking'] == "session")
+ if ($pref['user_tracking'] == "session")
{
$_SESSION[$pref['cookie_name']] = $cookieval;
- }
- else
+ }
+ else
{
cookie($pref['cookie_name'], $cookieval, (time()+3600 * 24 * 30));
}
@@ -101,13 +106,13 @@ else
}
$e_sub_cat = 'logout';
- require_once(e_ADMIN."header.php");
+ if(!defset('NO_HEADER')) require_once(e_ADMIN."header.php");
- if (ADMIN == FALSE)
+ if (ADMIN == FALSE)
{
$obj = new auth;
$obj->authform();
- require_once(e_ADMIN."footer.php");
+ if(!defset('NO_HEADER')) require_once(e_ADMIN."footer.php");
exit;
}
}
@@ -149,7 +154,7 @@ class auth
";
- if ($use_imagecode)
+ if ($use_imagecode)
{
$text .= "
diff --git a/e107_admin/image.php b/e107_admin/image.php
index fabd90521..555df8702 100644
--- a/e107_admin/image.php
+++ b/e107_admin/image.php
@@ -1,104 +1,202 @@
toDB($_POST['filename']);
- @unlink(e_FILE."public/avatars/".$image);
- $sql->db_Update("user", "user_image='' WHERE user_image='-upload-{$image}'");
- $sql->db_Update("user", "user_sess='' WHERE user_sess='{$image}'");
- $admin_log->log_event('IMALAN_01',$image,E_LOG_INFORMATIVE,'');
- $message = $image." ".IMALAN_28;
+ header('Location: '.e_SELF);
+ exit();
}
+/*
+ * DELETE CHECKED AVATARS - SHOW AVATAR SCREEN
+ */
+if (isset($_POST['submit_show_delete_multi']))
+{
+ if(varset($_POST['multiaction']))
+ {
+ $tmp = array(); $tmp1 = array(); $message = array();
-if (isset($_POST['deleteall']))
+ foreach ($_POST['multiaction'] as $todel)
+ {
+ $todel = explode('#', $todel);
+ $todel[1] = basename($todel[1]);
+
+ $image_type = 2;
+ if(strpos($todel[1], '-upload-') === 0)
+ {
+ $image_type = 1;
+ $todel[1] = substr($todel[1], strlen('-upload-'));
+ }
+
+ //delete it from server
+ @unlink(e_FILE."public/avatars/".$todel[1]);
+
+ //admin log & sysmessage
+ $message[] = $todel[1];
+
+ //It's owned by an user
+ if($todel[0])
+ {
+ switch ($image_type)
+ {
+ case 1: //avatar
+ $tmp[] = intval($todel[0]);
+ break;
+
+ case 2: //photo
+ $tmp1[] = intval($todel[0]);
+ break;
+ }
+ }
+ }
+
+ //Reset all deleted user avatars with one query
+ if(!empty($tmp))
+ {
+ $sql->db_Update("user", "user_image='' WHERE user_id IN (".implode(',', $tmp).")");
+ }
+ //Reset all deleted user photos with one query
+ if(!empty($tmp1))
+ {
+ $sql->db_Update("user", "user_sess='' WHERE user_id IN (".implode(',', $tmp1).")");
+ }
+ unset($tmp, $tmp1);
+
+ //Format system message
+ if(!empty($message))
+ {
+ $admin_log->log_event('IMALAN_01', implode('[!br!]', $message), E_LOG_INFORMATIVE, '');
+ $message = implode(', ', $message).' '.IMALAN_28;
+ }
+ else $message = '';
+ }
+}
+
+/*
+ * DELETE ALL UNUSED IMAGES - SHOW AVATAR SCREEN
+ */
+if (isset($_POST['submit_show_deleteall']))
{
$handle = opendir(e_FILE."public/avatars/");
+ $dirlist = array();
while ($file = readdir($handle)) {
- if ($file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db') {
+ if (!is_dir(e_FILE."public/avatars/{$file}") && $file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db') {
$dirlist[] = $file;
}
}
closedir($handle);
- $imgList = '';
- $count = 0;
- while (list($key, $image_name) = each($dirlist))
+
+ if(!empty($dirlist))
{
- if (!$sql->db_Select("user", "*", "user_image='-upload-$image_name' OR user_sess='$image_name'")) {
- unlink(e_FILE."public/avatars/".$image_name);
- $count++;
- $imgList .= '[!br!]'.$image_name;
+ $imgList = '';
+ $count = 0;
+ foreach ($dirlist as $image_name)
+ {
+ $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}'")) {
+ unlink(e_FILE."public/avatars/".$image_name);
+ $imgList .= '[!br!]'.$image_name;
+ $count++;
+ }
}
+
+ $message = $count." ".IMALAN_26;
+ $admin_log->log_event('IMALAN_02', $message.$imgList,E_LOG_INFORMATIVE, '');
+ unset($imgList);
}
- $message = $count." ".IMALAN_26;
- $admin_log->log_event('IMALAN_02',$message.$imgList,E_LOG_INFORMATIVE,'');
- unset($imgList);
}
-if (isset($_POST['avdelete']))
+/*
+ * DELETE ALL CHECKED BAD IMAGES - VALIDATE SCREEN
+ */
+if (isset($_POST['submit_avdelete_multi']))
{
require_once(e_HANDLER."avatar_handler.php");
$avList = array();
- foreach($_POST['avdelete'] as $key => $val)
+ $tmp = array();
+ $uids = array();
+ //Sanitize
+ $_POST['multiaction'] = $tp->toDB($_POST['multiaction']);
+
+ //sql queries significant reduced
+ if(!empty($_POST['multiaction']) && $sql->db_Select("user", 'user_id, user_name, user_image', "user_id IN (".implode(',', $_POST['multiaction']).")"))
{
- $key = intval($key); // We only need the key
- if ($sql->db_Select("user", 'user_id, user_name, user_image', "user_id='{$key}'"))
+ $search_users = $sql->db_getList('ALL', FALSE, FALSE, 'user_id');
+ foreach($_POST['multiaction'] as $uid)
{
- $row = $sql->db_Fetch();
- $avname=avatar($row['user_image']);
- if (strpos($avname,"http://")===FALSE)
- { // Internal file, so unlink it
- @unlink($avname);
+ if (varsettrue($search_users[$uid]))
+ {
+ $avname = avatar($search_users[$uid]['user_image']);
+ if (strpos($avname, "http://") === FALSE)
+ { // Internal file, so unlink it
+ @unlink($avname);
+ }
+
+ $uids[] = $uid;
+ $tmp[] = $search_users[$uid]['user_name'];
+ $avList[] = $uid.':'.$search_users[$uid]['user_name'].':'.$search_users[$uid]['user_image'];
}
- $sql->db_Update("user","user_image='' WHERE user_id='{$key}'");
- $message = IMALAN_51.$row['user_name']." ".IMALAN_28;
- $avList[] = $key.':'.$row['user_name'].':'.$row['user_image'];
}
+
+ //sql queries significant reduced
+ if(!empty($uids))
+ {
+ $sql->db_Update("user", "user_image='' WHERE user_id IN (".implode(',', $uids).")");
+ }
+
+ $message = IMALAN_51.''.implode(', ', $tmp).' '.IMALAN_28;
+ $admin_log->log_event('IMALAN_03', implode('[!br!]', $avList), E_LOG_INFORMATIVE, '');
+ unset($search_users);
}
- $admin_log->log_event('IMALAN_03',implode('[!br!]',$avList),E_LOG_INFORMATIVE,'');
- unset($avList);
- $_POST['check_avatar_sizes'] = TRUE; // Force size recheck after doing one or more deletes
+ unset($avList, $tmp, $uids);
+
}
+/*
+ * UPDATE IMAGE OPTIONS - MAIN SCREEN
+ */
if (isset($_POST['update_options']))
{
- unset($temp);
- $temp['image_post'] = intval($_POST['image_post']);
- $temp['resize_method'] = $_POST['resize_method'];
- $temp['im_path'] = trim($tp->toDB($_POST['im_path']));
- $temp['image_post_class'] = intval($_POST['image_post_class']);
- $temp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']);
- $temp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']);
+ $tmp = array();
+ $tmp['image_post'] = intval($_POST['image_post']);
+ $tmp['resize_method'] = $tp->toDB($_POST['resize_method']);
+ $tmp['im_path'] = trim($tp->toDB($_POST['im_path']));
+ $tmp['image_post_class'] = intval($_POST['image_post_class']);
+ $tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']);
+ $tmp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']);
- if ($admin_log->logArrayDiffs($temp, $pref, 'IMALAN_04'))
+ if ($admin_log->logArrayDiffs($tmp, $pref, 'IMALAN_04'))
{
save_prefs(); // Only save if changes
$message = IMALAN_9;
@@ -109,16 +207,29 @@ if (isset($_POST['update_options']))
}
}
-//FIXME - better message handler, no tablerender for sys-messages anymore
-if (isset($message))
+/*
+ * SYSTEM MESSAGE
+ */
+//FIXME - better message handler, sysmessages CSS rules
+if (varsettrue($message))
{
- $ns->tablerender("", "".$message."
");
+ //no tablerender for sys-messages anymore
+ $message = "
+ ".$message."
+ ";
+}
+else
+{
+ $message = '';
}
-
+/*
+ * SHOW AVATARS SCREEN
+ */
if (isset($_POST['show_avatars']))
{
$handle = opendir(e_FILE."public/avatars/");
+ $dirlist = array();
while ($file = readdir($handle))
{
if ($file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db' && !is_dir($file))
@@ -130,55 +241,77 @@ if (isset($_POST['show_avatars']))
$text = '';
- if (!is_array($dirlist))
+ if (empty($dirlist))
{
$text .= IMALAN_29;
}
else
{
$text = "
-