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, ''); $emessage->add(implode(', ', $message).' '.IMALAN_28, E_MESSAGE_SUCCESS); } } } /* * 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 (!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); if(!empty($dirlist)) { $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; $emessage->add($message, E_MESSAGE_SUCCESS); $admin_log->log_event('IMALAN_02', $message.$imgList,E_LOG_INFORMATIVE, ''); unset($imgList); } } /* * DELETE ALL CHECKED BAD IMAGES - VALIDATE SCREEN */ if (isset($_POST['submit_avdelete_multi'])) { require_once(e_HANDLER."avatar_handler.php"); $avList = array(); $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']).")")) { $search_users = $sql->db_getList('ALL', FALSE, FALSE, 'user_id'); foreach($_POST['multiaction'] as $uid) { 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 queries significant reduced if(!empty($uids)) { $sql->db_Update("user", "user_image='' WHERE user_id IN (".implode(',', $uids).")"); } $emessage->add(IMALAN_51.''.implode(', ', $tmp).' '.IMALAN_28, E_MESSAGE_SUCCESS); $admin_log->log_event('IMALAN_03', implode('[!br!]', $avList), E_LOG_INFORMATIVE, ''); unset($search_users); } unset($avList, $tmp, $uids); } /* * UPDATE IMAGE OPTIONS - MAIN SCREEN */ if (isset($_POST['update_options'])) { $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($tmp, $pref, 'IMALAN_04')) { save_prefs(); // Only save if changes $emessage->add(IMALAN_9, E_MESSAGE_SUCCESS); } else { $emessage->add(IMALAN_20, E_MESSAGE_INFO); } } /* * SHOW AVATARS SCREEN */ function show_avatars() { global $ns, $sql, $frm, $tp, $emessage, $e107, $pref; $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)) { $dirlist[] = $file; } } closedir($handle); $text = ''; if (empty($dirlist)) { $text .= IMALAN_29; } else { $text = "
"; $count = 0; while (list($key, $image_name) = each($dirlist)) { $users = IMALAN_21." | "; $row = array('user_id' => ''); $image_pre = ''; $disabled = false; if ($sql->db_Select("user", "*", "user_image='-upload-".$tp->toDB($image_name)."' OR user_sess='".$tp->toDB($image_name)."'")) { $row = $sql->db_Fetch(); if($row['user_image'] == '-upload-'.$image_name) $image_pre = '-upload-'; $users .= "{$row['user_name']} (".($row['user_sess'] == $image_name ? IMALAN_24 : IMALAN_23).")"; } else { $users = ''.IMALAN_22.''; } //directory? if(is_dir(e_FILE."public/avatars/".$image_name)) { //File info $users = "".IMALAN_66.": {$image_name} ".IMALAN_69.""; //Friendly UI - click text to select a form element $img_src = ''.IMALAN_70.''; $disabled = true; } else { //File info $users = "".IMALAN_66.": {$image_name} ".$users; // Control over the image size (design) $image_size = getimagesize(e_FILE."public/avatars/".$image_name); //Friendly UI - click text to select a form element $img_src = ""; if ($image_size[0] > $pref['im_width'] || $image_size[1] > $pref['im_height']) { $img_src = "".IMALAN_57.""; } } //style attribute allowed here - server side width/height control //autocheck class - used for JS selectors (see eCoreImage object) $text .= "
{$users}
{$img_src}
".$frm->checkbox('multiaction[]', "{$row['user_id']}#{$image_pre}{$image_name}", false, array('id' => false, 'disabled' => $disabled))."
"; $count++; } $text .= "
".$frm->admin_button('check_all', IMALAN_59, 'action')." ".$frm->admin_button('uncheck_all', IMALAN_60, 'action')." ".$frm->admin_button('submit_show_delete_multi', IMALAN_58, 'delete')." ".$frm->admin_button('submit_show_deleteall', IMALAN_25, 'delete')." ".$frm->admin_button('submit_cancel_show', IMALAN_68, 'cancel')."
"; } $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_18, $emessage->render().$text); } /* * CHECK AVATARS SCREEN */ if (isset($_POST['check_avatar_sizes'])) { // Set up to track what we've done // $iUserCount = 0; $iAVinternal = 0; $iAVexternal = 0; $iAVnotfound = 0; $iAVtoobig = 0; require_once(e_HANDLER."avatar_handler.php"); $text = "
".CACLAN_3." "; // // Loop through avatar field for every user // $iUserCount = $sql->db_Count("user"); $found = false; $allowedWidth = intval($pref['im_width']); $allowedHeight = intval($pref['im_width']); if ($sql->db_Select("user", "*", "user_image!=''")) { while ($row = $sql->db_Fetch()) { //Check size $avname=avatar($row['user_image']); if (strpos($avname,"http://")!==FALSE) { $iAVexternal++; $bAVext=TRUE; } else { $iAVinternal++; $bAVext=FALSE; } $image_stats = getimagesize($avname); $sBadImage=""; if (!$image_stats) { $iAVnotfound++; // allow delete $sBadImage=IMALAN_42; } else { $imageWidth = $image_stats[0]; $imageHeight = $image_stats[1]; if ( ($imageHeight > $allowedHeight) || ($imageWidth > $allowedWidth) ) { // Too tall or too wide $iAVtoobig++; if ($imageWidth > $allowedWidth) { $sBadImage = IMALAN_40." ($imageWidth)"; } if ($imageHeight > $allowedHeight) { if (strlen($sBadImage)) { $sBadImage .= ", "; } $sBadImage .= IMALAN_41." ($imageHeight)"; } } } //If not found or too large, allow delete if (strlen($sBadImage)) { $found = true; $text .= " "; } } } //Nothing found if(!$found) { $text .= " "; } $text .= "
".LAN_OPTIONS." ".IMALAN_64." ".IMALAN_62." ".IMALAN_63."
".$row['user_name']." ".$sBadImage." ".$avname."
".IMALAN_65."
".$frm->admin_button('check_all', IMALAN_59, 'action')." ".$frm->admin_button('uncheck_all', IMALAN_60, 'action')." ".$frm->admin_button('submit_avdelete_multi', IMALAN_58, 'delete')."
".IMALAN_38." {$allowedWidth}
".IMALAN_39." {$allowedHeight}
".IMALAN_45." {$iAVnotfound}
".IMALAN_46." {$iAVtoobig}
".IMALAN_47." {$iAVinternal}
".IMALAN_48." {$iAVexternal}
".IMALAN_49." ".($iAVexternal+$iAVinternal)." (".(int)(100.0*(($iAVexternal+$iAVinternal)/$iUserCount)).'%, '.$iUserCount." ".IMALAN_50.")
"; $ns->tablerender(IMALAN_37, $emessage->render().$text); } /* * MAIN CONFIG SCREEN */ function main_config() { global $pref, $frm, $tp, $sql, $ns, $emessage; if(function_exists('gd_info')) { $gd_info = gd_info(); $gd_version = $gd_info['GD Version']; } else { $gd_version = " ".IMALAN_55.""; } $IM_NOTE = ""; if($pref['im_path'] != "") { $im_file = $pref['im_path'].'convert'; if(!file_exists($im_file)) { $IM_NOTE = "".IMALAN_52.""; } else { $cmd = "{$im_file} -version"; $tmp = `$cmd`; if(strpos($tmp, "ImageMagick") === FALSE) { $IM_NOTE = "".IMALAN_53.""; } } } $text = "
".IMALAN_7."
".IMALAN_1."
".$frm->checkbox('image_post', 1, $pref['image_post'])."
".IMALAN_2."
".IMALAN_10." ".r_userclass('image_post_class',$pref['image_post_class'],"off","public,guest,nobody,member,admin,main,classes")."
".IMALAN_11."
".IMALAN_12." ".$frm->select_open('image_post_disabled_method')." ".$frm->option(IMALAN_14, '0', ($pref['image_post_disabled_method'] == "0"))." ".$frm->option(IMALAN_15, '1', ($pref['image_post_disabled_method'] == "1"))." ".$frm->select_close()."
".IMALAN_13."
".IMALAN_3."
".IMALAN_54." {$gd_version}
".$frm->select_open('resize_method')." ".$frm->option('gd1', 'gd1', ($pref['resize_method'] == "gd1"))." ".$frm->option('gd2', 'gd2', ($pref['resize_method'] == "gd2"))." ".$frm->option('ImageMagick', 'ImageMagick', ($pref['resize_method'] == "ImageMagick"))." ".$frm->select_close()."
".IMALAN_4."
".IMALAN_5."
{$IM_NOTE}
".$frm->text('im_path', $pref['im_path'])."
".IMALAN_6."
".IMALAN_34."
".$frm->checkbox('enable_png_image_fix', 1, ($pref['enable_png_image_fix']))."
".IMALAN_35."
".IMALAN_36." ".$frm->admin_button('check_avatar_sizes', IMALAN_17)."
".$frm->admin_button('update_options', IMALAN_8, 'update')."
"; $ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_7, $emessage->render().$text); } //Just in case... if(!e_AJAX_REQUEST) require_once("footer.php"); function icon_editor() { global $iconpool, $e107, $emessage, $frm, $tp; ksort($iconpool); $text = "
".DBLAN_20." "; $tmp = array(16, 32, 48, 64, 128); foreach($iconpool as $key => $val) { $tmp1 = array(); foreach($val as $icon) { $filepath = $icon; $filepath_abs = $tp->replaceConstants($icon); $icon_file = basename($filepath_abs); $str = "{$icon_file}"; foreach ($tmp as $isize) { if(strpos($icon_file, '_'.$isize.'.') !== false) { $tmp1[$isize] = varset($tmp1[$isize]).str_replace('%%size%%', ' S'.$isize, $str); continue 2; } } $tmp1['other'] = varset($tmp1['other']).$str;//other } $ptext = "
".str_replace('%%size%%', '', implode('
', $tmp1))."
"; // $ptext = (is_array($val)) ? "
".print_r($val, TRUE)."
" : htmlspecialchars($val, ENT_QUOTES, CHARSET); // $ptext = $e107->tp->textclean($ptext, 80); $text .= " "; } $text .= "
".LAN_DELETE." ".LAN_CATEGORY." ".IMALAN_72." ".LAN_OPTIONS."
".$frm->checkbox("delpref2[$key]", 1)." {$key} {$ptext} ".$frm->submit_image("delpref[$key]", LAN_DELETE, 'delete', LAN_CONFIRMDEL." [$key]")."
".$frm->admin_button('delpref_checked', LAN_DELCHECKED, 'delete')."
"; //$text .= "
".DBLAN_13."
\n"; $e107->ns->tablerender(LAN_IMAGEMANAGER." :: ".IMALAN_71, $emessage->render().$text); return $text; } function del_pref_val() { global $iconpool, $e107cache, $emessage; $del = array_keys($_POST['delpref']); $delpref = key($_POST['delpref']); if($delpref) { unset($iconpool[$delpref]); $deleted_list .= "
  • ".$delpref."
  • "; } if($_POST['delpref2']) { foreach($_POST['delpref2'] as $k => $v) { $deleted_list .= "
  • ".$k."
  • "; unset($iconpool[$k]); } } if(save_prefs('iconpool')) { $emessage->add(LAN_DELETED.""); $e107cache->clear(); } //$e107->ns->tablerender(LAN_DELETED,$message); } function image_adminmenu() { global $action; if($action == "") { $action = "main"; } $var['main']['text'] = IMALAN_7; $var['main']['link'] = e_SELF; $var['icons']['text'] = IMALAN_71; $var['icons']['link'] = e_SELF."?icons"; $var['avatars']['text'] = IMALAN_23; $var['avatars']['link'] = e_SELF."?avatars"; $var['editor']['text'] = "Image Manipulation (future release)"; $var['editor']['link'] = e_SELF."?editor"; e_admin_menu(LAN_IMAGEMANAGER, $action, $var); } /** * Handle page DOM within the page header * * @return string JS source */ function headerjs() { require_once(e_HANDLER.'js_helper.php'); //FIXME - how exactly to auto-call JS lan? This and more should be solved in Stage II. $ret = " "; return $ret; } ?>