Lautaro
👽 Chevereto Freak
Hey guys,
Here's a very simple file manager i just coded. This will get all the images from your images and thumbs folder and you'll be able to delete any with a single click.
When you delete an image it will also delete the thumb. If the image or the thumb doesn't exist, it will delete whatever exists (the image or the thumb) if none exist, well, you will get a message telling you that none exist and could not delete them.
First, create a new php file where your index.php is. I called mine admin.php
Add the following code inside the newly created php file:
Make sure you edit the settings:
you will only be able to access the file through the IP you set in the settings.
Here's a preview:
If you purchased my login/database MOD this will not remove the images from the database, if you want this to also remove images from the database you need to:
1.- include my db connection file.
2.- add the following query below the "/* it worked */" comment:
happy valentine's day !
Here's a very simple file manager i just coded. This will get all the images from your images and thumbs folder and you'll be able to delete any with a single click.
When you delete an image it will also delete the thumb. If the image or the thumb doesn't exist, it will delete whatever exists (the image or the thumb) if none exist, well, you will get a message telling you that none exist and could not delete them.
First, create a new php file where your index.php is. I called mine admin.php
Add the following code inside the newly created php file:
PHP:
<?php
// SETTINGS
$config['admin_ip'] = '111.111.111.111';
$config['images_dir'] = 'images/';
$config['thumbs_dir'] = 'images/thumbs/';
$config['image_formats'] = 'png,jpg,gif,bmp';
$config['images_per_row'] = '8';
/* check admin ip */
if($_SERVER['REMOTE_ADDR'] != $config['admin_ip']) { die('you do not have access to this file.'); }
// ========== DELETE IMAGE START ========== //
if(isset($_REQUEST['delete'])) {
/* check if image exists */
if(!file_exists($config['images_dir'].$_REQUEST['delete'])) {
echo '<span style="color:red;">image does not exist ('.$config['images_dir'].$_REQUEST['delete'].')</span><br />';
$chk_image = 1;
}
/* check if image's thumb exists */
if(!file_exists($config['thumbs_dir'].$_REQUEST['delete'])) {
echo '<span style="color:red;">thumb does not exist ('.$config['thumbs_dir'].$_REQUEST['delete'].')</span><br />';
$chk_thumb = 1;
}
/* delete image */
if($chk_image != 1) {
if(!@unlink($config['images_dir'].$_REQUEST['delete'])) {
/* it worked */
echo 'could not delete image ('.$config['images_dir'].$_REQUEST['delete'].')<br />';
} else {
/* could not delete, display error */
echo '<span style="color:green;">image deleted successfully !</span><br />';
}
}
/* delete thumb */
if($chk_thumb != 1) {
if(!@unlink($config['thumbs_dir'].$_REQUEST['delete'])) {
/* it worked */
echo 'could not delete thumb ('.$config['images_dir'].$_REQUEST['delete'].')<br />';
} else {
/* could not delete, display error */
echo '<span style="color:green;">thumb deleted successfully !</span><br />';
}
}
}
// ========== DELETE IMAGE END ========== //
echo '<table cellspacing="3" cellpadding="0">';
echo '<tr>';
$cnt = 0;
foreach (glob("".$config['images_dir']."*.{".$config['image_formats']."}", GLOB_BRACE) as $filename)
{
$image_name = explode($config['images_dir'],$filename);
$cnt++;
if($cnt % $config['images_per_row'] == 1) { echo '</tr><td></td><tr>'; }
echo '<td align="center" style="border:1px solid #cccccc;background:#eeeeee;padding:3px;">';
echo '<a href="./?v='.$image_name[1].'" target="_blank">';
echo '<img src="'.$config['thumbs_dir'].$image_name[1].'" style="margin-bottom:2px;border:0px;"></a><br />';
echo '<a style="font-size:11px;font-family:Arial;text-decoration:none;" href="?delete='.$image_name[1].'">delete</a>';
echo '</td>';
}
echo '</tr>';
echo '</table>';
?>
Make sure you edit the settings:
PHP:
// SETTINGS
$config['admin_ip'] = '111.111.111.111';
$config['images_dir'] = 'images/';
$config['thumbs_dir'] = 'images/thumbs/';
$config['image_formats'] = 'png,jpg,gif,bmp';
$config['images_per_row'] = '8';
you will only be able to access the file through the IP you set in the settings.
Here's a preview:
If you purchased my login/database MOD this will not remove the images from the database, if you want this to also remove images from the database you need to:
1.- include my db connection file.
PHP:
include('includes/dmx.sql.php');
2.- add the following query below the "/* it worked */" comment:
PHP:
@mysql_query("DELETE FROM uploaded_images WHERE file = '".mysql_real_escape_string($_REQUEST['delete'])."'");
happy valentine's day !