forked from seanlebeck/site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editimg.php
77 lines (55 loc) · 1.55 KB
/
editimg.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
require_once("initvars.inc.php");
require_once("config.inc.php");
?>
<div align="center">
<?php
if ($_REQUEST['imgid'] && $_REQUEST['codemd5'])
{
$sql = "SELECT imgid, imgtitle, imgfilename FROM $t_imgs WHERE imgid = $_REQUEST[imgid] AND MD5(code) = '{$_REQUEST[codemd5]}'";
list($imgid, $imgtitle, $imgfilename) = mysql_fetch_row(mysql_query($sql));
if ($imgid)
{
$auth = TRUE;
$codemd5 = $_REQUEST['codemd5'];
}
else
{
$auth = FALSE;
}
}
if ($auth)
{
if ($_POST['do'] == "del")
{
$sql = "SELECT imgfilename FROM $t_imgs WHERE imgid = $imgid";
list($imgfilename) = mysql_fetch_row(mysql_query($sql));
if ($imgfilename) unlink("{$datadir[userimgs]}/$imgfilename");
$sql = "DELETE FROM $t_imgs WHERE imgid = $imgid";
mysql_query($sql);
?>
<?php echo $lang['MESSAGE_IMAGE_DELETED']; ?><br>
<a href="index.php?cityid=<?php echo $xcityid; ?>"><?php echo $lang['BACK_TO_HOME']; ?></a>
<?php
}
else
{
?>
<form method="post" action="">
<h2><?php echo $lang['EDIT_IMAGE']; ?></h2>
<h3><?php echo $imgtitle; ?></h3>
<img src="<?php echo "{$datadir[userimgs]}/$imgfilename"; ?>" border="1"><br><br>
<input type="hidden" name="imgid" value="<?php echo $imgid; ?>">
<input type="hidden" name="codemd5" value="<?php echo $codemd5; ?>">
<input type="hidden" name="do" value="del">
<button type="submit" value="Delete" onclick="return(confirm('<?php echo $lang['EDIT_AD_CONFIRM_DELETE']; ?>'));">Delete</button>
</form>
<?php
}
}
else
{
echo "<div class=\"err\">{$lang[ERROR_INVALID_EDIT_LINK]}</div>";
}
?>
</div>