-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeletarfoto.php
33 lines (28 loc) · 979 Bytes
/
deletarfoto.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include "key.inc.php";
$referer = $_SERVER['HTTP_REFERER'];
$referer_parse = parse_url($referer);
//The $referer_parse will give some more, let's say, security
//$wwwUrlHost = "www.".$urlHost;
//if($referer_parse['host'] == $urlHost || $referer_parse['host'] == $wwwUrlHost) {
if(!isset($_GET['id']) AND !isset($_POST['deletepic']) OR ($_GET['id'] == 0 OR is_null($_GET['id']))){
header('Location: '.$urlHost);
exit;
}else{
$id = $_GET['id'];
$idquery = $pdo->prepare("SELECT * FROM fotos WHERE id = ? AND iddocasal = ?");
$idquery->execute(array($_GET['id'], $row['id']));
$row3 = $idquery->fetch();
$fotoselecionada = $row3['nomediretorio'];
//$nullvalue = "";
unlink('fotos/album/'.$fotoselecionada);
$deletarfoto = $pdo->prepare("DELETE FROM fotos WHERE id = ?");
$deletarfoto->execute(array($id));
header('Location: '.$urlHost.'/site.php');
exit;
}
//} else {
//header('Location: '.$urlHost.'/site.php');
//exit;
//}
?>