include_once "../common/includes/settings.php";
//include_once ('../common/common_includes.php');
//include_once ('../common/settings.php');
include_once ($GLOBAL_ABSOLUTE_PATH.'/showroom/config.php');
include_once ($GLOBAL_ABSOLUTE_PATH.'/showroom/functions/func_showrooms.php'); // for getPath($srid)
//include_once ('../showroom/settings/showroom_includes.php');
//include_once('../showroom/settings/showroom_settings.php');
include_once ($GLOBAL_ABSOLUTE_PATH.'/articles/settings/articles_includes.php');
include_once ($GLOBAL_ABSOLUTE_PATH.'/articles/settings/articles_config.php');
include_once ($GLOBAL_ABSOLUTE_PATH.'/articles/settings/articles_settings.php');
include_once ($GLOBAL_ABSOLUTE_PATH.'/articles/classes/srfile.class.php');
$srid=6;
$artid=0;
if(!isset($_REQUEST['artid']) || !is_numeric($_REQUEST['artid']) || $_REQUEST['artid']<1) {
header ("Location: $ARTICLE_INDEX_URL");
exit;
}
else {
$artid = $_REQUEST['artid'];
}
$action = $_REQUEST['action'];
$fileid = $_REQUEST['fileid']; //does not have '.jpg' at the back
//deleting file
if($action=='delete') {
//$srFilesDao = new SR_FILES_DAO();
/*$
fileid = substr($_REQUEST['file'], 0, -4);
$file = $_REQUEST['file'];
*/
$file = $fileid.'.jpg';
$category = getPath($srid);
$UPLOADIMAGES_PATH = $GALLERY_PATH."/".$category;
/*
echo('fileid='.$fileid.'
');
echo('$file='.$file.'
');
echo('$UPLOADIMAGES_PATH='.$UPLOADIMAGES_PATH.'
');
echo('UI = '.$UPLOADIMAGES_PATH."/thumb-".$file.'
');
exit;
*/
//echo('='..'
');
$fileRemoved = true;
if (file_exists($UPLOADIMAGES_PATH."/thumb-".$file)) {
system ("rm -f ".$UPLOADIMAGES_PATH."/thumb-".$file);
}
else {
logSRerror("delete.php - cannot find file " . $UPLOADIMAGES_PATH."/thumb-".$file);
$fileRemoved = false;
}
if (file_exists($UPLOADIMAGES_PATH."/resized-".$file)) {
system ("rm -f ".$UPLOADIMAGES_PATH."/resized-".$file);
logSRdeletes("delete.php: Deleted - " . $UPLOADIMAGES_PATH."/resized-".$file);
}
else {
logSRerror("delete.php - cannot find file " . $UPLOADIMAGES_PATH."/resized-".$file);
$fileRemoved = false;
}
if($fileRemoved) {
$db = new DB();
$link = $db->connect();
$uid = getSessionUserid();
$e_fileid = mysql_escape($fileid);
$sql = "DELETE FROM sr_files WHERE fileuniqueid = '$e_fileid'";
mysql_query($sql, $link);
}
//$sql = "DELETE FROM sr_msgs WHERE fileid = '$fileid'";
//mysql_query($sql, $link);
header("Location: ".$PHP_SELF."?artid=".$artid);
exit;
//echo('$fileRemoved='.$fileRemoved.'
');
}
$article = new Article($artid);
//used for site takeover to detect the car only
//$related_cars = getRelationshipCars($article->getArtId(), $link);
if ($article->getArtId() == 0 || (!isArticlesAdmin() && $article->isHidden())) {
//echo('a1');
header ("Location: $ARTICLE_INDEX_URL");
exit;
}
if($article->getTypeId()==12){
header ("Location: photo-story.php?artid=".$article->getArtId());
exit;
}
$section = new Section ($article->getTypeId());
$SUB_APP_ID = $section->getSubAppId();
$images = getArticleImages($article->getArtId());
if(count($images) <= 0) {
//echo('a2');
header ("Location: article.php?artid=".$article->getArtId());
exit;
}
if($fileid) {
$index = 0;
foreach ($images as $image) {
if ($image->getfileid() == $fileid) {
//echo('a3');
header ("Location: $PHP_SELF"."?artid=".$artid."&type=".$type."#".$index);
exit;
}
$index++;
}
}
$showroom_category = getPath($srid);
$WEBPAGE_TITLE = $article->getArticleTitle().' Photo Gallery | '.$section->getSectionName().' | '.$GLOBAL_PORTAL_NAME;
?>