<?php
/***********************************************************************
| 68 Classifieds developed by 68 Designs, LLC.
|-----------------------------------------------------------------------
| All source code & content (c) Copyright 2004, 68 Designs LLC
|   unless specifically noted otherwise.
|
|The contents of this file are protect under law as the intellectual property
| of 68 Designs, LLC. Any use, reproduction, disclosure or copying
| of any kind without the express and written permission of 68 Designs, LLC is forbidden.
|
|
| File: deleteimage.php
|
| Purpose: The deleteimage page, allows a member to delete an image
|
| Developers involved with this file:
|        Eric Barnes  http://www.68designs.com/contact-support.php [EB]
|
| ______________________________________________________________________
|    http://www.68classifieds.com      http://www.68designs.com/
***********************************************************************/
session_start();
if(!isset(
$_SESSION['username'])){
    
header("Location: login.php");
}
if(!isset(
$_COOKIE['id'])){
    
header("Location: login.php");
}
?>
<?php
require_once("../Connections/classifieds.php"); ?>
<?php
require_once("../includes/main.php"); ?>
<?php
include('../includes/topheader.php'); ?>
<?php
require_once("../$config[language_path]");  ?>
<?php
require_once("../includes/functions.php"); ?>
<?php
require_once('../ScriptLibrary/incAddOnDelete.php'); ?>
<?php
// Delete Before Record Addon 1.0.5
if ((isset($_GET['id'])) && ($_GET['id'] != "")) {
    
mysql_select_db($database_classifieds, $classifieds);
    
$dbr_result = mysql_query("SELECT image FROM prodimages WHERE id=".$_GET['id'], $classifieds) or die(mysql_error());
    
$dbr = new deleteFileBeforeRecord();
    
$dbr->sqldata = mysql_fetch_array($dbr_result);
    
$dbr->path = "../photos";
    
$dbr->pathThumb = "../thumbs";
    
$dbr->naming = "prefix";
    
$dbr->suffix = "small_";
    
$dbr->checkVersion("1.0.5");
    
$dbr->deleteFile();
}

function
GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case
"text":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case
"long":
    case
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case
"double":
      
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case
"date":
      
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return
$theValue;
}

if ((isset(
$_GET['id'])) && ($_GET['id'] != "")) {
  
$deleteSQL = sprintf("DELETE FROM prodimages WHERE id=%s",
                       
GetSQLValueString($_GET['id'], "int"));

  
mysql_select_db($database_classifieds, $classifieds);
  
$Result1 = mysql_query($deleteSQL, $classifieds) or die(mysql_error());
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="../administration/style.css" type="text/css" />
<script language="JavaScript">
// Set the following variable to the number of seconds the browser
// will wait before closing the window.
var gWindowCloseWait = 3;

function SetupWindowClose()
{
    window.setTimeout("window.close()",gWindowCloseWait*1000);
}

// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
    isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
    IEmac = ((document.all)&&(isMac)) ? true : false;
    IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
    if (IEmac && IE4)  // IE 4.5 blows out on testing window.onload
    {
        window.onload = SafeOnload;
        gSafeOnload[gSafeOnload.length] = f;
    }
    else if  (window.onload)
    {
        if (window.onload != SafeOnload)
        {
            gSafeOnload[0] = window.onload;
            window.onload = SafeOnload;
        }        
        gSafeOnload[gSafeOnload.length] = f;
    }
    else
        window.onload = f;
}
function SafeOnload()
{
    for (var i=0;i<gSafeOnload.length;i++)
        gSafeOnload[i]();
}

// Call the following with your function as the argument
SafeAddOnload(SetupWindowClose);
function leave() {
    onUnload = window.opener.location.reload();
    javascript:window.close();
}
</script>
</head>
<body onUnload="leave();">
<table width="100%" height="85%" align="center">
  <tr>
    <td valign="middle">
      <table align="center" cellpadding="4" class="tablefill">
      <tr>
          <td width="100%" align="center" nowrap="nowrap">
          <strong><?php echo $lang['deleteSuccess'] ; ?><br />
          </strong><br />
          <?php echo $lang['pleaseWaitClose']; ?><br />
          <br />
          (<a href="#" onClick="javascript:self.close();"><?php echo $lang['noWait']; ?></a>)          </td>
        </tr>
    </table>    </td>
  </tr>
</table>
</body>
</html>