1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-22 14:13:03 +02:00

Administration Area changes - work in progress

This commit is contained in:
secretr
2008-12-09 15:19:03 +00:00
parent bacdbdf181
commit 9b1917f2fa
25 changed files with 1127 additions and 191 deletions

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $
| $Revision: 1.7 $
| $Date: 2008-12-06 23:00:19 $
| $Author: e107steved $
| $Revision: 1.8 $
| $Date: 2008-12-09 15:19:02 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
@@ -27,7 +27,7 @@ require_once(e_HANDLER."form_handler.php");
require_once(e_HANDLER."userclass_class.php");
$rs = new form;
if (isset($_POST['delete']))
if (isset($_POST['delete']))
{
$image = $tp->toDB($_POST['filename']);
@unlink(e_FILE."public/avatars/".$image);
@@ -38,25 +38,22 @@ if (isset($_POST['delete']))
}
if (isset($_POST['deleteall']))
if (isset($_POST['deleteall']))
{
$handle = opendir(e_FILE."public/avatars/");
while ($file = readdir($handle))
{
if ($file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db')
{
while ($file = readdir($handle)) {
if ($file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db') {
$dirlist[] = $file;
}
}
closedir($handle);
$count = 0;
$imgList = '';
while (list($key, $image_name) = each($dirlist))
$count = 0;
while (list($key, $image_name) = each($dirlist))
{
if (!$sql->db_Select("user", "*", "user_image='-upload-{$image_name}' OR user_sess='{$image_name}'"))
{
if (!$sql->db_Select("user", "*", "user_image='-upload-$image_name' OR user_sess='$image_name'")) {
unlink(e_FILE."public/avatars/".$image_name);
$count ++;
$count++;
$imgList .= '[!br!]'.$image_name;
}
}
@@ -66,18 +63,18 @@ if (isset($_POST['deleteall']))
}
if (isset($_POST['avdelete']))
if (isset($_POST['avdelete']))
{
require_once(e_HANDLER."avatar_handler.php");
$avList = array();
foreach($_POST['avdelete'] as $key => $val)
{
$key = intval($key); // We only need the key
if ($sql->db_Select("user", 'user_id, user_name, user_image', "user_id='{$key}'"))
if ($sql->db_Select("user", 'user_id, user_name, user_image', "user_id='{$key}'"))
{
$row = $sql->db_Fetch();
$avname=avatar($row['user_image']);
if (strpos($avname,"http://")===FALSE)
if (strpos($avname,"http://")===FALSE)
{ // Internal file, so unlink it
@unlink($avname);
}
@@ -91,7 +88,7 @@ if (isset($_POST['avdelete']))
$_POST['check_avatar_sizes'] = TRUE; // Force size recheck after doing one or more deletes
}
if (isset($_POST['update_options']))
if (isset($_POST['update_options']))
{
unset($temp);
$temp['image_post'] = intval($_POST['image_post']);
@@ -112,84 +109,102 @@ if (isset($_POST['update_options']))
}
}
if (isset($message))
//FIXME - better message handler, no tablerender for sys-messages anymore
if (isset($message))
{
$ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>");
}
if (isset($_POST['show_avatars']))
if (isset($_POST['show_avatars']))
{
$handle = opendir(e_FILE."public/avatars/");
while ($file = readdir($handle)) {
if ($file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db' && !is_dir($file))
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 = "<div style='text-align:center'>\n";
$text = '';
if (!is_array($dirlist))
if (!is_array($dirlist))
{
$text .= IMALAN_29;
}
else
}
else
{
while (list($key, $image_name) = each($dirlist))
$count = 0;
while (list($key, $image_name) = each($dirlist))
{
$users = IMALAN_21." | ";
if ($sql->db_Select("user", "*", "user_image='-upload-$image_name' OR user_sess='$image_name'")) {
while ($row = $sql->db_Fetch()) {
extract($row);
if ($sql->db_Select("user", "*", "user_image='-upload-$image_name' OR user_sess='$image_name'"))
{
/*
//Is it possible?! I don't think so
while ($row = $sql->db_Fetch())
{
extract($row); //FIXME - kill this!!!
$users .= "<a href='".e_BASE."user.php?id.$user_id'>$user_name</a> <span class='smalltext'>(".($user_sess == $image_name ? IMALAN_24 : IMALAN_23).")</span> | ";
}
}*/
$row = $sql->db_Fetch();
$users .= "<a href='".e_BASE."user.php?id.{$row['user_id']}'>{$row['user_name']}</a> <span class='smalltext'>(".($row['user_sess'] == $image_name ? IMALAN_24 : IMALAN_23).")</span>";
} else {
$users = IMALAN_22;
$users = '<span class="warning">'.IMALAN_22.'</span>';
}
$text .= "<div class='spacer'>
//File info
$users = "<a class='e-tooltip' href='#' alt='".IMALAN_66.": {$image_name}' title='".IMALAN_66.": {$image_name}'><img src='".e_IMAGE_ABS."admin_images/docs_16.png' /></a> ".$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 = "<label for='image-action-{$count}' title='".IMALAN_56."'><img src='".e_FILE_ABS."public/avatars/{$image_name}' alt='{$image_name}' /></label>";
if ($image_size[0] > $pref['im_width'] || $image_size[1] > $pref['im_height'])
{
$img_src = "<a class='image-preview' href='".e_FILE_ABS."public/avatars/{$image_name}'>".IMALAN_57."</a>";
}
$text .= "
<div class='image-box f-left center' style='width: ".(intval($pref['im_width'])+40)."px; height: ".(intval($pref['im_height'])+100)."px;'>
<div class='spacer'>
<form method='post' action='".e_SELF."'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td class='fcaption'>$image_name</td>
</tr>
<tr>
<td class='forumheader3'><img src='".e_FILE."public/avatars/".$image_name."' alt='' /><br />
<input type='hidden' name='filename' value='".$image_name."' />
<input class='button' type='submit' name='delete' value='".LAN_DELETE."' />
</td>
</tr>
<tr>
<td class='forumheader3'>$users</td>
</tr>
</table>
<div class='image-users'>{$users}</div>
<div class='image-preview'>{$img_src}</div>
<div class='image-delete'>
<input type='checkbox' class='checkbox' id='image-action-{$count}' name='filename[]' value='{$image_name}' />
</div>
</form>
</div>";
</div>
</div>
";
$count++;
}
$text .= "<div class='spacer'>
//FIXME add multi delete for better user experience (not working yet), make check/uncheck-all work
$text .= "
<div class='spacer clear'>
<form method='post' action='".e_SELF."'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td class='forumheader'>
<input class='button' type='submit' name='deleteall' value='".IMALAN_25."' />
</td>
</tr>
</table>
<div class='buttons-bar'>
<button class='delete' type='submit' name='deleteall'><span>".IMALAN_25."</span></button>
<button class='delete' type='submit' name='delete_multi'><span>".IMALAN_58."</span></button>
<button class='action' type='button' name='check_all'><span>".IMALAN_59."</span></button>
<button class='action' type='button' name='uncheck_all'><span>".IMALAN_60."</span></button>
</div>
</form>
</div>";
}
$text .= "</div>";
$ns->tablerender(IMALAN_18, $text);
}
if (isset($_POST['check_avatar_sizes']))
if (isset($_POST['check_avatar_sizes']))
{
// Set up to track what we've done
//
@@ -199,32 +214,44 @@ if (isset($_POST['check_avatar_sizes']))
$iAVnotfound = 0;
$iAVtoobig = 0;
require_once(e_HANDLER."avatar_handler.php");
$text = "<div style='text-align:center'>\n";
$text .= "<div class='spacer'>
<form method='post' action='".e_SELF."'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td class='forumheader3'>".$pref['im_width']."</td>
<td class='forumheader3'>".IMALAN_38."</td>
</tr>
<tr>
<td class='forumheader3'>".$pref['im_height']."</td>
<td class='forumheader3'>".IMALAN_39."</td>
</tr>";
$text = "
<form method='post' action='".e_SELF."'>
<fieldset id='bad-avatar-table'>
<legend class='e-hideme'>".CACLAN_3."</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='3'>
<col style='width:10%'></col>
<col style='width:20%'></col>
<col style='width:25%'></col>
<col style='width:45%'></col>
</colgroup>
<thead>
<tr>
<th class='center'>".IMALAN_61."</th>
<th class='center'>".IMALAN_64."</th>
<th class='center'>".IMALAN_62."</th>
<th class='center last'>".IMALAN_63."</th>
</tr>
</thead>
<tbody>
";
//
// Loop through avatar field for every user
//
$iUserCount = $sql->db_Count("user");
if ($sql->db_Select("user", "*", "user_image!=''")) {
while ($row = $sql->db_Fetch())
while ($row = $sql->db_Fetch())
{
extract($row);
extract($row); //FIXME - kill this!!!
//
// Check size
//
$avname=avatar($user_image);
if (strpos($avname,"http://")!==FALSE)
if (strpos($avname,"http://")!==FALSE)
{
$iAVexternal++;
$bAVext=TRUE;
@@ -242,7 +269,7 @@ if (isset($_POST['check_avatar_sizes']))
} else {
$imageWidth = $image_stats[0];
$imageHeight = $image_stats[1];
if ( ($imageHeight > $pref['im_height']) || ($imageWidth>$pref['im_width']) )
if ( ($imageHeight > $pref['im_height']) || ($imageWidth > $pref['im_width']) )
{ // Too tall or too wide
$iAVtoobig++;
if ($imageWidth > $pref['im_width']) {
@@ -257,52 +284,89 @@ if (isset($_POST['check_avatar_sizes']))
}
}
}
//
//
// If not found or too big, allow delete
//
if (strlen($sBadImage))
{
$sBadImage .=" [".$avname."]"; // Show all files that have a problem
//$sBadImage .=" [".$avname."]"; // Show all files that have a problem
//FIXME <button class='delete' type='submit' name='avdelete[$user_id]'><span>".($bAVext ? IMALAN_44 : IMALAN_43)."</span></button>
$text .= "
<tr>
<td class='forumheader3'>
<input class='button' type='submit' name='avdelete[$user_id]' value='".($bAVext ? IMALAN_44 : IMALAN_43)."' />
</td>
<td class='forumheader3'>".IMALAN_51."<a href='".e_BASE."user.php?id.".$user_id."'>".$user_name."</a> ".$sBadImage."</td>
<td class='options center'>
<input class='checkbox' type='checkbox' name='avdelete[]' id='avdelete-{$user_id}' value='{$user_id}' />
</td>
<td>
<label for='avdelete-{$user_id}' title='".IMALAN_56."'>".IMALAN_51."</label><a href='".e_BASE."user.php?id.".$user_id."'>".$user_name."</a>
</td>
<td>".$sBadImage."</td>
<td>".$avname."</td>
</tr>";
}
else
{
//Nothing found
$text .="
<tr>
<td colspan='4' class='center'>".IMALAN_65."</td>
</tr>";
}
}
}
//
// Done, so show stats
//
$text .= "
<tr>
<td class='forumheader3'>".$iAVnotfound."</td>
<td class='forumheader3'>".IMALAN_45."</td>
</tr>
<tr>
<td class='forumheader3'>".$iAVtoobig."</td>
<td class='forumheader3'>".IMALAN_46."</td>
</tr>
<tr>
<td class='forumheader3'>".$iAVinternal."</td>
<td class='forumheader3'>".IMALAN_47."</td>
</tr>
<tr>
<td class='forumheader3'>".$iAVexternal."</td>
<td class='forumheader3'>".IMALAN_48."</td>
</tr>
<tr>
<td class='forumheader3'>".($iAVexternal+$iAVinternal)." (".(int)(100.0*(($iAVexternal+$iAVinternal)/$iUserCount)).'%, '.$iUserCount." ".IMALAN_50.")</td>
<td class='forumheader3'>".IMALAN_49."</td>
</tr>
</table>
</form>
</div>";
</tbody>
</table>
<div class='buttons-bar'>
<button class='action' type='button' name='check_all'><span>".IMALAN_59."</span></button>
<button class='action' type='button' name='uncheck_all'><span>".IMALAN_60."</span></button>
<button class='delete' type='submit' name='delete'><span>".IMALAN_58."</span></button>
</div>
</fieldset>
</form>
$text .= "</div>";
<table cellpadding='0' cellspacing='0' class='admininfo'>
<colgroup span='2'>
<col style='width:20%'></col>
<col style='width:80%'></col>
</colgroup>
<tbody>
<tr>
<td class='label'>".IMALAN_38."</td>
<td class='control'>".$pref['im_width']."</td>
</tr>
<tr>
<td class='label'>".IMALAN_39."</td>
<td class='control'>".$pref['im_height']."</td>
</tr>
<tr>
<td class='label'>".IMALAN_45."</td>
<td class='control'>".$iAVnotfound."</td>
</tr>
<tr>
<td class='label'>".IMALAN_46."</td>
<td>".$iAVtoobig."</td>
</tr>
<tr class='control'>
<td class='label'>".IMALAN_47."</td>
<td>".$iAVinternal."</td>
</tr>
<tr>
<td class='label'>".IMALAN_48."</td>
<td class='control'>".$iAVexternal."</td>
</tr>
<tr>
<td class='label'>".IMALAN_49."</td>
<td class='control'>".($iAVexternal+$iAVinternal)." (".(int)(100.0*(($iAVexternal+$iAVinternal)/$iUserCount)).'%, '.$iUserCount." ".IMALAN_50.")</td>
</tr>
</tbody>
</table>
";
$ns->tablerender(IMALAN_37, $text);
}
@@ -314,7 +378,7 @@ if(function_exists('gd_info'))
}
else
{
$gd_version = "<span style='color:red'> ".IMALAN_55."</span>";
$gd_version = "<span class='error'> ".IMALAN_55."</span>";
}
$IM_NOTE = "";
@@ -323,7 +387,7 @@ if($pref['im_path'] != "")
$im_file = $pref['im_path'].'convert';
if(!file_exists($im_file))
{
$IM_NOTE = "<br /><span style='color:red'>".IMALAN_52."</span>";
$IM_NOTE = "<span class='error'>".IMALAN_52."</span>";
}
else
{
@@ -331,100 +395,103 @@ if($pref['im_path'] != "")
$tmp = `$cmd`;
if(strpos($tmp, "ImageMagick") === FALSE)
{
$IM_NOTE = "<br /><span style='color:red'>".IMALAN_53."</span>";
$IM_NOTE = "<span class='error'>".IMALAN_53."</span>";
}
}
}
$text = "<div style='text-align:center'>
$text = "
<form method='post' action='".e_SELF."'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<fieldset id='image-settings-form'>
<legend class='e-hideme'>".IMALAN_7."</legend>
<table cellpadding='0' cellspacing='0' class='adminform'>
<colgroup span='2'>
<col style='width:250px'></col>
<col></col>
</colgroup>
<tbody>
<tr>
<td class='label'>
".IMALAN_1."
</td>
<td class='control'>". ($pref['image_post'] ? "<input class='checkbox' type='checkbox' name='image_post' value='1' checked='checked' />" : "<input type='checkbox' name='image_post' value='1' />")."
<div class='smalltext field-help'>".IMALAN_2."</div>
</td>
</tr>
<tr>
<td class='label'>
".IMALAN_10."
</td>
<td class='control'>".r_userclass('image_post_class',$pref['image_post_class'],"off","public,guest,nobody,member,admin,main,classes")."
<div class='smalltext field-help'>".IMALAN_11."</div>
</td>
</tr>
<tr>
<td style='width:75%' class='forumheader3'>
".IMALAN_1."<br />
<span class='smalltext'>".IMALAN_2."</span>
</td>
<td style='width:25%;text-align:center' class='forumheader3' >". ($pref['image_post'] ? "<input type='checkbox' name='image_post' value='1' checked='checked' />" : "<input type='checkbox' name='image_post' value='1' />")."
</td>
</tr>
<tr>
<td class='label'>
".IMALAN_12."
</td>
<td class='control'>
<select name='image_post_disabled_method' class='tbox select'>". ($pref['image_post_disabled_method'] == "0" ? "<option value='1' selected='selected'>".IMALAN_14."</option>" : "<option value='0'>".IMALAN_14."</option>"). ($pref['image_post_disabled_method'] == "1" ? "<option value='1' selected='selected'>".IMALAN_15."</option>" : "<option value='1'>".IMALAN_15."</option>")."
</select>
<div class='smalltext field-help'>".IMALAN_13."</div>
</td>
</tr>
<tr>
<td class='label'>".IMALAN_3."<br/><em>".IMALAN_54." {$gd_version}</em></td>
<td class='control'>
<select name='resize_method' class='tbox'>". ($pref['resize_method'] == "gd1" ? "<option selected='selected'>gd1</option>" : "<option>gd1</option>"). ($pref['resize_method'] == "gd2" ? "<option selected='selected'>gd2</option>" : "<option>gd2</option>"). ($pref['resize_method'] == "ImageMagick" ? "<option selected='selected'>ImageMagick</option>" : "<option>ImageMagick</option>")."
</select>
<div class='smalltext field-help'>".IMALAN_4."</div>
</td>
</tr>
<tr>
<td style='width:75%' class='forumheader3'>
".IMALAN_10."<br />
<span class='smalltext'>".IMALAN_11."</span>
</td>
<td style='width:25%;text-align:center' class='forumheader3' >".r_userclass('image_post_class',$pref['image_post_class'],"off","public,guest,nobody,member,admin,main,classes")."</td>
</tr>
<tr>
<td class='label'>".IMALAN_5."<div class='label-note'>{$IM_NOTE}</em></td>
<td class='control'>
<input class='tbox input-text' type='text' name='im_path' size='40' value=\"".$pref['im_path']."\" maxlength='200' />
<div class='smalltext field-help'>".IMALAN_6."</div>
</td>
</tr>
<tr>
<td style='width:75%' class='forumheader3'>
".IMALAN_12."<br />
<span class='smalltext'>".IMALAN_13."</span>
</td>
<td style='width:25%;text-align:center' class='forumheader3' >
<select name='image_post_disabled_method' class='tbox'>".
($pref['image_post_disabled_method'] == "0" ? "<option value='0' selected='selected'>".IMALAN_14."</option>" : "<option value='0'>".IMALAN_14."</option>").
($pref['image_post_disabled_method'] == "1" ? "<option value='1' selected='selected'>".IMALAN_19."</option>" : "<option value='1'>".IMALAN_19."</option>").
($pref['image_post_disabled_method'] == "2" ? "<option value='2' selected='selected'>".IMALAN_15."</option>" : "<option value='2'>".IMALAN_15."</option>")."
</select></td>
</tr>
<tr>
<td class='label'>".IMALAN_34."
</td>
<td class='control'>".($pref['enable_png_image_fix'] ? "<input type='checkbox' name='enable_png_image_fix' value='1' checked='checked' />" : "<input type='checkbox' name='enable_png_image_fix' value='1' />")."
<div class='smalltext field-help'>".IMALAN_35."</div>
</td>
</tr>
<tr>
<td style='width:75%' class='forumheader3'>".IMALAN_3."<br /><span class='smalltext'>".IMALAN_4."</span><br />".IMALAN_54." {$gd_version}</td>
<td style='width:25%;text-align:center' class='forumheader3' >
<select name='resize_method' class='tbox'>". ($pref['resize_method'] == "gd1" ? "<option selected='selected'>gd1</option>" : "<option>gd1</option>"). ($pref['resize_method'] == "gd2" ? "<option selected='selected'>gd2</option>" : "<option>gd2</option>"). ($pref['resize_method'] == "ImageMagick" ? "<option selected='selected'>ImageMagick</option>" : "<option>ImageMagick</option>")."
</select>
</td>
</tr>
<tr>
<td class='label'>".IMALAN_16."</td>
<td class='control'>
<button class='action' type='submit' name='show_avatars'><span>".IMALAN_17."</span></button>
</td>
</tr>
<tr>
<td style='width:75%' class='forumheader3'>".IMALAN_5."<br /><span class='smalltext'>".IMALAN_6."</span></td>
<td style='width:25%;text-align:center' class='forumheader3' >
<input class='tbox' type='text' name='im_path' size='40' value=\"".$pref['im_path']."\" maxlength='200' />
{$IM_NOTE}
</td></tr>
<tr>
<td style='width:75%' class='forumheader3'>".IMALAN_34."<br />
<span class='smalltext'>".IMALAN_35."</span>
</td>
<td style='width:25%;text-align:center' class='forumheader3' >".($pref['enable_png_image_fix'] ? "<input type='checkbox' name='enable_png_image_fix' value='1' checked='checked' />" : "<input type='checkbox' name='enable_png_image_fix' value='1' />")."
</td>
</tr>
<tr>
<td style='width:75%' class='forumheader3'>".IMALAN_16."</td>
<td style='width:25%;text-align:center' class='forumheader3' >
<input class='button' type='submit' name='show_avatars' value='".IMALAN_17."' />
</td></tr>
<tr>
<td style='width:75%' class='forumheader3'>".IMALAN_36."</td>
<td style='width:25%;text-align:center' class='forumheader3' >
<input class='button' type='submit' name='check_avatar_sizes' value='".IMALAN_17."' />
</td></tr>
<tr>
<td colspan='2' style='text-align:center' class='forumheader'>
<input class='button' type='submit' name='update_options' value='".IMALAN_8."' />
</td>
</tr>
</table></form></div>";
<tr>
<td class='label'>".IMALAN_36."</td>
<td class='control'>
<button class='action' type='submit' name='check_avatar_sizes'><span>".IMALAN_17."</span></button>
</td>
</tr>
</tbody>
</table>
<div class='buttons-bar center'>
<button class='update' type='submit' name='update_options'><span>".IMALAN_8."</span></button>
</div>
</fieldset>
</form>";
$ns->tablerender(IMALAN_7, $text);
require_once("footer.php");
/*
XXX - remove this odd thing?!
$pref['resize_method'] = $_POST['resize_method'];
$pref['im_path'] = $_POST['im_path'];
?>
*/
?>