diff --git a/e107_admin/image.php b/e107_admin/image.php index 554a7feda..e16b9b287 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -1767,9 +1767,252 @@ class media_admin_ui extends e_admin_ui // $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_7, $mes->render().$text); } + + function avatarPageDeleteChecked() + { + + + $sql = e107::getDb(); + $mes = e107::getMessage(); + + if(!empty($_POST['multiaction'])) + { + $tmp = array(); $tmp1 = array(); $message = array(); + + foreach ($_POST['multiaction'] as $todel) + { + list($usr,$path) = explode('#', $todel); + + // $path = basename($path); + + $path = str_replace("../","",$path); // clean the path. + + $mes->addDebug('usr: '.intval($usr).' path: '.$path); + + $image_type = 2; + if(strpos($path, '-upload-') === 0) + { + $image_type = 1; + $path = substr($path, strlen('-upload-')); + } + + //delete it from server + $deletePath = e_AVATAR.$path; + if(@unlink($deletePath)) + { + $mes->addDebug('Deleted: '.$deletePath); + $message[] = basename($path); //admin log & sysmessage + } + else + { + $mes->addError('Unable to delete: '.$deletePath); // Do not translate, temporary during beta stage. + } + + //It's owned by an user + if(!empty($usr)) + { + switch ($image_type) + { + case 1: //avatar + $tmp[] = intval($usr); + break; + + case 2: //photo + $tmp1[] = intval($usr); + break; + } + } + + } + + //Reset all deleted user avatars with one query + if(!empty($tmp)) + { + $sql->update("user", "user_image='' WHERE user_id IN (".implode(',', $tmp).")"); + $mes->addDebug("user_image='' WHERE user_id IN (".implode(',', $tmp).")"); + } + //Reset all deleted user photos with one query + if(!empty($tmp1)) + { + $sql->update("user", "user_sess='' WHERE user_id IN (".implode(',', $tmp1).")"); + $mes->addDebug("user_sess='' WHERE user_id IN (".implode(',', $tmp1).")"); + } + unset($tmp, $tmp1); + + //Format system message + if(!empty($message)) + { + e107::getLog()->add('IMALAN_01', implode('[!br!]', $message), E_LOG_INFORMATIVE, ''); + $mes->addSuccess(implode(', ', $message).' '.IMALAN_28); + } + } + + + + } + + + + + + function avatarPage() { - show_avatars(); + global $pref; + + if (isset($_POST['submit_show_delete_multi'])) + { + $this->avatarPageDeleteChecked(); + } + + + $sql = e107::getDb(); + $frm = e107::getForm(); + $tp = e107::getParser(); + $mes = e107::getMessage(); + + $avFiles = e107::getFile()->get_files(e_MEDIA."avatars/",".jpg|.png|.gif|.jpeg|.JPG|.GIF|.PNG",null,2); + + $dirlist = array(); + + foreach($avFiles as $f) + { + $dirlist[] = str_replace(e_MEDIA."avatars/","",$f['path']). $f['fname']; + } + + $text = ''; + + if (empty($dirlist)) + { + $text .= IMALAN_29; + } + else + { + + $tmp = $sql->retrieve('user','user_id,user_image','user_image !="" ', true); + $imageUsed = array(); + + foreach($tmp as $val) + { + $id = $val['user_id']; + $imageUsed[$id] = $val['user_image']; + } + + $userImages = array_flip($imageUsed); + + $text = $frm->open('core-image-avatars'); + + $text .= "
+ + "; + // $frm->admin_button('submit_cancel_show', IMALAN_68, 'cancel') + } + + return $mes->render().$text; + + // $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_18, $mes->render().$text); } function iconsPage() @@ -2440,66 +2683,7 @@ if(varset($_GET['action']) == 'settings') -if (isset($_POST['submit_show_delete_multi'])) -{ - if(varset($_POST['multiaction'])) - { - $tmp = array(); $tmp1 = array(); $message = array(); - 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_UPLOAD."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)) - { - e107::getLog()->add('IMALAN_01', implode('[!br!]', $message), E_LOG_INFORMATIVE, ''); - $mes->addSuccess(implode(', ', $message).' '.IMALAN_28); - } - } -} /* * DELETE ALL UNUSED IMAGES - SHOW AVATAR SCREEN @@ -2588,162 +2772,6 @@ if (isset($_POST['submit_avdelete_multi'])) -/* - * SHOW AVATARS SCREEN - */ -function show_avatars() -{ - global $e107, $pref; - - $ns = e107::getRender(); - $sql = e107::getDb(); - $frm = e107::getForm(); - $tp = e107::getParser(); - $mes = e107::getMessage(); - - - $avFiles = e107::getFile()->get_files(e_MEDIA."avatars/",".jpg|.png|.gif|.jpeg|.JPG|.GIF|.PNG",null,2); - - $dirlist = array(); - - foreach($avFiles as $f) - { - $dirlist[] = str_replace(e_MEDIA."avatars/","",$f['path']). $f['fname']; - } - - $text = ''; - - if (empty($dirlist)) - { - $text .= IMALAN_29; - } - else - { - - $tmp = $sql->retrieve('user','user_image','user_image !="" ', true); - $imageUsed = array(); - - foreach($tmp as $val) - { - $imageUsed[] = $val['user_image']; - } - $text = " - - "; - // $frm->admin_button('submit_cancel_show', IMALAN_68, 'cancel') - } - - echo $mes->render().$text; - return; - // $ns->tablerender(LAN_MEDIAMANAGER." :: ".IMALAN_18, $mes->render().$text); -} /* * CHECK AVATARS SCREEN diff --git a/index.php b/index.php index c690e80ab..082e74912 100644 --- a/index.php +++ b/index.php @@ -103,7 +103,7 @@ if(!empty($v['alias'])) { $alias = (!empty($pref['e_url_alias'][e_LAN][$plug][$k])) ? $pref['e_url_alias'][e_LAN][$plug][$k] : $v['alias']; - e107::getMessage()->addDebug("e_url alias found: ".$alias.""); + // e107::getMessage()->addDebug("e_url alias found: ".$alias.""); $v['regex'] = str_replace('{alias}', $alias, $v['regex']); }