Support » Plugins » Image/File Manager

  • The following code allows a user to manage the files they have uploaded via the upload feature. It modifies one file, and creates another. There is an “image preview” option that is currently only available for Internet Explorer users. If you wish to implement it, uncomment line 46 and comment line 44 in filemanage.php (below). Note that any ASCII escape strings should be corrected before implementing the code. If someone knows how to correctly post backslashes, PLEASE let me know.
    Add file: /wordpress_directory/wp-admin/filemanage.php
    <?php
    require_once('../wp-includes/wp-l10n.php');
    $title = 'Manage Images or Files';
    require_once('admin-header.php');
    if ($user_level == 0) //Checks to see if user has logged in
    die (__("Cheatin' uh ?"));
    if (!get_settings('use_fileupload')) //Checks if file upload is enabled in the config
    die (__("The admin disabled this function"));
    //$allowed_types = explode(' ', trim(strtolower(get_settings('fileupload_allowedtypes'))));
    echo("<div id=\"imagePreview\" style=\"position: absolute; border: 1px solid #000000; width: 100px; visibility: hidden; overflow: hidden; height: 100px\"></div>");
    echo("<div class=\"wrap\">");
    echo("Below is a list of uploaded files. Right click the file you wish to use in your post and click \"Copy Link to Clipboard\", then paste the link into your post.<br/>");
    $dir = get_settings('fileupload_realpath');
    // Deletes the file if asked
    if($_REQUEST['action'] == "delete" && file_exists("$dir/". $_REQUEST['file']))
    {
    $result = mysql_query("SELECT ID FROM " . $table_prefix . "posts WHERE post_content LIKE '%" . $_REQUEST['file'] . "%' ");
    if(!mysql_fetch_assoc($result))
    {
    unlink("$dir/". $_REQUEST['file']);
    }
    }
    echo("<table border=\"0\">\n<tr>\n<td>File</td>\n<td>Size</td>\n<td>Delete</td>\n</tr>");
    if (is_dir($dir)) {
    if($dh = opendir($dir)) {
    $i = 1;
    while (($file = readdir($dh)) !== false) {
    if($file != "." && $file != "..")
    {
    echo("<tr>\n<td>\n");
    $result = mysql_query("SELECT ID FROM " . $table_prefix . "posts WHERE post_content LIKE '%" . $file . "%' ");
    $files[] = $i;
    list($width,$height,$type,$attr) = getimagesize("$dir/$file");
    $thumbHeight = 100;
    $thumbWidth = round(( $thumbHeight * $width ) / $height);
    echo("" . get_settings('fileupload_url') . $file . "</td><td>$width x $height</td><td><span id=\"cell$i\"/>");
    // Comment the above line and uncomment the line below for Image Previews.
    //echo("'\" onMouseout=\"imagePreview.innerHTML='';imagePreview.style.visibility='hidden'\">" . get_settings('fileupload_url') . $file . "</td><td>$width x $height</td><td><span id=\"cell$i\"/>");
    if(mysql_fetch_assoc($result))
    echo("File in use");
    else
    echo("Delete");
    echo("</td>\n</tr>\n");
    $i++;
    }
    }
    closedir($dh);
    }
    }
    echo("</table>");
    if (!is_writable(get_settings('fileupload_realpath')))
    $action = 'not-writable';
    echo("</div>");
    include('admin-footer.php');
    ?>

    Modify the file /wordpress_directory/wp-admin/menu.php
    Add a new line, after 19, roughly:
    array(__('Files'), get_settings('fileupload_minlevel'), 'filemanage.php'),

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Image/File Manager’ is closed to new replies.