<?php
/*
* ***********************************************************************************************
* Filename: admin_module_delimage.inc.php
* Module: Admin-Module
* Subcategory: Delete Images
* Description: Deletes images
* ***********************************************************************************************
*
*
* Project: yappa-ng : yet another php photo album - next generation
* Author: Fritz Berger <hide@address.com>
* Copyright: 2003 Fritz Berger
* $Header: /cvsroot/yappa-ng/yappa-ng/admin_modules/admin_module_delimage.inc.php,v 1.22 2005/04/25 18:02:06 zirkon13 Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* You may contact the author of yappa-ng by e-mail at:
* hide@address.com
*
* The latest version of yappa-ng can be obtained from:
* http://www.zirkon.at/zirkon/scripts/yappa-ng/yappa-ng_main_eng.html (german)
* http://www.zirkon.at/zirkon/scripts/yappa-ng/yappa-ng_main_eng.html (english)
*
* ***********************************************************************************************
* ***********************************************************************************************
* *** ***
* *** yappa-ng is based on "YAPPA v1.7 devel - 22.April 2002" ***
* *** released on http://sourceforge.net/projects/yappa/ ***
* *** YAPPA is Copyright Federico 'pix' Feroldi (hide@address.com) ***
* *** YAPPA is released under the GNU GPL ***
* *** ***
* ***********************************************************************************************
* ***********************************************************************************************
*/
?>
<?php
/*
* Standard Security Check
*/
if (!defined('SecCheck')) {
die("You Cannot Access This Script Directly - Have a Nice Day.");
}
include_once($config['path_src_include'] . "common.inc.php");
function SetPreviewNumber () {
global $config, $config_album;
global $selected_album;
$admin_form = $_POST['admin_form'];
$config_album['mini_images_per_page'] = $admin_form['mini_images_per_page'];
/* write album config */
$configfilename = singleslash($config["photo_root"] . "/" . $selected_album);
$returncode = write_albumconf($configfilename, $config_album);
return $returncode;
}
function HandleForm () {
global $config;
global $lang_akt;
global $page, $album;
global $selected_album;
// delete images hits counter
$log_file_destination = singleslash($config["photo_root"] . "/" . $selected_album . "/" . $config['data_dirname'] . "/" . $config["log_filename"]);
$hitcounter = new HitCounter($log_file_destination);
// remember the number of images before deletion
$msg["0"] = $page["album_images"];
// go through all images and check, if it should be deleted!
for($i = 0; $i < $page["album_images"]; $i++) {
$image_name = $album->get_imagename($i);
if(isset($_POST['admin_form'][$image_name])) {
if($_POST['admin_form'][$image_name] == "yes") {
$delimage = singleslash($config["photo_root"] . "/" . rawurldecode($_GET["album"]) ."/" . $image_name);
// delete image from album-hitcounter
$hitcounter->del_hit($image_name);
// delete real image
unlink ($delimage);
// delete all cached copies from image
delimage_cache (rawurldecode($_GET["album"]), $image_name);
// log level 1: Administration
if((int)"1" & (int)$config["loglevel"]) {
$log_msg = date("U") . "|Administration|" . "AlbumAdmin Delete Image: Image '$image_name' from Album '$selected_album' deleted (image, cache, hits)" . "|" . $_SERVER["REMOTE_ADDR"] . "|-|admin_module_deldir.inc.php|" . __LINE__ . "\n";
@error_log($log_msg, 3, "yappa-ng.log");
}
$msg[$i+1] = $image_name . $lang_akt["admin_delimage_status1"];
}
}
}
return $msg;
}
$uri_base = str_replace("&admintask=Delete","",$global_var['self_url']);
if(isset($_POST['BeenSubmitted'])) {
$msg = HandleForm();
}
if(isset($_POST['BeenSubmittedPreview'])) {
$msg = SetPreviewNumber();
}
/* if the preview_per_page is not initialized (eg after upgrade) set it to a default value of 25 */
if ($config_album['mini_images_per_page'] < 1 ) {
$config_album['mini_images_per_page'] = 25;
}
$album->read_dir();
$album->sort_dir();
$page["album_images"] = $album->count_images();
/* prepare all page-navigation links */
$prevnext = page_pn();
?>
<form action="<?php print $global_var['self_url']; ?>" method="post">
<table cellspacing="0" cellpadding="5" border="0" width="100%">
<tr valign="top">
<td class="thumbnailCell">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<tr><td colspan="4"> </td></tr>
<td width="75%"> </td>
<td width="20%" align="right" nowrap="nowrap"><input type="text" name="admin_form[mini_images_per_page]" size="5" value="<?php print $config_album['mini_images_per_page']; ?>"> <?php print $lang_akt["admin_main_perrowtext"]; ?></td>
<td width="5%" align="left">
<input type="hidden" name="BeenSubmittedPreview" value="true">
<input type="submit" name="submit" value="<?php print $lang_akt['submit']; ?>">
</td>
<td> </td>
</tr>
<tr><td colspan="4"><hr></td></tr>
</table>
</td>
</tr>
</table>
</form>
<form action="<?php print $global_var['self_url']; ?>" method="post">
<table cellspacing="0" cellpadding="5" border="0" width="100%">
<tr valign="top">
<td class="thumbnailCell">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr><td colspan=4 align="center" class="adminHeading"><?php print $lang_akt["admin_delimage_hmain"]; ?></td></tr>
<tr><td colspan="4" class="passwdAdminCancel" align="center" >
[ <b><a href="<?php echo $uri_base ?>"><?php echo $lang_akt["passwd_admin_cancel"]; ?></b></a> ]</td></tr>
<tr><td width="5%"> </td><td width="10%"> </td><td width="10%"> </td><td> </td></tr>
<tr><td colspan="4" align="center" class="adminStatus">
<?php if(isset($_POST['BeenSubmitted'])) {
$num_files = $msg["0"] + 1;
for ($i=1; $i<$num_files; $i++ ) {
if(isset($msg[$i])) {
print $msg[$i];
}
}
} ?>
</td></tr>
<tr><td colspan="4"> </td></tr>
<tr><td colspan=4 class="adminDescription"><?php print $lang_akt["admin_delimage_titleh"]; ?></td></tr>
<tr><td colspan=4 class="adminComments"><?php print $lang_akt["admin_delimage_titlefull"]; ?></td></tr>
<!-- next/prev page links - start -->
<tr><td colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="30%" align="left" nowrap><?php
if($prevnext["navlink_previous"] != "") {
?><font class="textNavlink"><a href="<?php print $prevnext["navlink_previous"]; ?>"><?php print $lang_akt["previousp"]; ?></a></font><?php
}
?></td>
<td width="40%" align="center">
<table border="0" cellspacing="1" cellpadding="1"><tr>
<td nowrap><?php if($prevnext["navlink_back"] != "") { ?>
<font class="textNavlink"><a href="<?php print $prevnext["navlink_back"]; ?>"><<</a> </font>
<?php } ?></td>
<?php
if (@count($prevnext["navlinks"]) > 0) {
foreach($prevnext["navlinks"] as $navlink) {
?><td><font class="textNavlink"><?php
if($navlink["selected"]) {
print "<b>" . $navlink["page"] . "</b> ";
} else {
?><a href="<?php print $navlink["link"]; ?>"><?php print $navlink["page"]; ?></a> <?php
}
?></font></td><?php
}
}
?>
<td nowrap><?php if($prevnext["navlink_forw"] != "") { ?>
<font class="textNavlink"><a href="<?php print $prevnext["navlink_forw"]; ?>">>></a></font>
<?php } ?></td>
</tr></table>
</td>
<td width="30%" align="right" nowrap><?php
if($prevnext["navlink_next"] != "") {
?><font class="textNavlink"><a href="<?php print $prevnext["navlink_next"]; ?>"><?php print $lang_akt["nextp"]; ?></a></font><?php
}
?></td>
</tr></table>
<td> </td></tr>
<!-- next/prev page links - end -->
<?php
if ($page["album_images"] == "0" ) { ?>
<tr><td colspan="4" align="center" class="adminStatus"><?php echo $lang_akt["admin_modules_noimage"]; ?></td></tr>
<?php } else { ?>
<tr>
<th> </th>
<th class="adminComments" align="center"><?php print $lang_akt["admin_picname"]; ?></th>
<th class="adminComments" align="center"><?php print $lang_akt["admin_image"]; ?></th>
<th class="adminComments" align="left"><?php print $lang_akt["admin_delimage_delete"]; ?></th>
</tr>
<?php
for($i = $prevnext['mini_start']; $i < $prevnext['mini_end']; $i++) {
$image_name = $album->get_imagename($i);
$nav_icon = nav_icons($selected_album, $image_name);
?>
<tr>
<td> </td>
<td class="adminComments" align="right"><?php print $image_name; ?></td>
<td align="center"><img src="<?php print $nav_icon['src']; ?>" name="<?php print $image_name; ?>" <?php print $nav_icon['size']; ?> alt="<?php print $image_name; ?>"></td>
<td class="adminSelection"><input type="checkbox" name="admin_form[<?php print $image_name; ?>]" value="yes"></td>
</tr>
<?php
}
}
?>
<!-- next/prev page links - start -->
<tr><td colspan="3">
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="30%" align="left" nowrap><?php
if($prevnext["navlink_previous"] != "") {
?><font class="textNavlink"><a href="<?php print $prevnext["navlink_previous"]; ?>"><?php print $lang_akt["previousp"]; ?></a></font><?php
}
?></td>
<td width="40%" align="center">
<table border="0" cellspacing="1" cellpadding="1"><tr>
<td nowrap><?php if($prevnext["navlink_back"] != "") { ?>
<font class="textNavlink"><a href="<?php print $prevnext["navlink_back"]; ?>"><<</a> </font>
<?php } ?></td>
<?php
if (@count($prevnext["navlinks"]) > 0) {
foreach($prevnext["navlinks"] as $navlink) {
?><td><font class="textNavlink"><?php
if($navlink["selected"]) {
print "<b>" . $navlink["page"] . "</b> ";
} else {
?><a href="<?php print $navlink["link"]; ?>"><?php print $navlink["page"]; ?></a> <?php
}
?></font></td><?php
}
}
?>
<td nowrap><?php if($prevnext["navlink_forw"] != "") { ?>
<font class="textNavlink"><a href="<?php print $prevnext["navlink_forw"]; ?>">>></a></font>
<?php } ?></td>
</tr></table></td>
<td width="30%" align="right" nowrap><?php
if($prevnext["navlink_next"] != "") {
?><font class="textNavlink"><a href="<?php print $prevnext["navlink_next"]; ?>"><?php print $lang_akt["nextp"]; ?></a></font><?php
}
?></td>
</tr></table>
<td> </td></tr>
<!-- next/prev page links - end -->
<tr><td colspan="4"> </td></tr>
<tr><td colspan="4" align="center">
<input type="hidden" name="BeenSubmitted" value="true">
<input type="submit" name="submit" value="<?php print $lang_akt['submit']; ?>">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
?>