/var/www/(Del)hsiaust.com.au/webadmin/background_modify.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
<?php
include 'config.php';

// Check if the user is logged in

if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1'))
{
header("Location: login.php");
exit;
}
require(
"configure.php");
require(
"function_resizethumb.php"); 
 
$backgroundid         htmlspecialchars($_POST["backgroundid"],ENT_QUOTES);
$menuid             htmlspecialchars($_POST["menuid"],ENT_QUOTES);
$nowdate         date("Y-m-d H:i:s");
//print_r($_POST);

//Delete execiting file
$result            mysql_query("SELECT * FROM background WHERE backgroundid=".$backgroundid." ");
$row            mysql_fetch_array($result,MYSQL_ASSOC);
if(
$row['backgroundimage'] <> ''){
    
unlink("../images/background/".$row['backgroundimage']);
}

// Upload File
if ($_FILES['backgroundimage']['name'] <> '')
{
    if ((
$_FILES["backgroundimage"]["type"] == "image/bmp") || ($_FILES["backgroundimage"]["type"] == "image/BMP") || ($_FILES["backgroundimage"]["type"] == "image/gif") || ($_FILES["backgroundimage"]["type"] == "image/GIF") || ($_FILES["backgroundimage"]["type"] == "image/jpg") || ($_FILES["backgroundimage"]["type"] == "image/JPG") || ($_FILES["backgroundimage"]["type"] == "image/jpeg") || ($_FILES["backgroundimage"]["type"] == "image/JPEG") || ($_FILES["backgroundimage"]["type"] == "image/pjpeg") || ($_FILES["backgroundimage"]["type"] == "image/PJEG") || ($_FILES["backgroundimage"]["type"] == "image/png") || ($_FILES["backgroundimage"]["type"] == "image/x-png") || ($_FILES["backgroundimage"]["type"] == "image/PNG") || ($_FILES["backgroundimage"]["type"] == "image/X-PNG"))
    {
        
move_uploaded_file ($_FILES['backgroundimage']['tmp_name'], "../images/background/id_".$backgroundid."_".$_FILES['backgroundimage']['name']) 
            or die (
"Could not copy the file: background");

        
$backgroundimageimg "../images/background/id_".$backgroundid."_".$_FILES['backgroundimage']['name'];
        
createthumb($backgroundimageimg$backgroundimageimg1430592);
        
        
$backgroundimage "id_".$backgroundid."_".$_FILES['backgroundimage']['name'];
      }
    else
      {
      
// upload error
      
?>
        <script language="javascript">
        alert("Files must be JPEG, GIF, or PNG");
        history.back();
        </script>
     <?php
     
exit;
     }

}
else
{
    
$backgroundimage "";
}


// Modify 
$sql "update background set modifyday='$nowdate', cmsloginid='".$_SESSION['cmsloginid']."' ";
if (
$backgroundimage <> '')
    
$sql .= ", backgroundimage='$backgroundimage' ";
$sql .= " where backgroundid="$backgroundid ." ";
mysql_query($sql);

if( 
mysql_errno() > ){
    echo 
'Modify background Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}

mysql_close($dbh);

header("Location: background_index.php?menuid=".$menuid."&msg=Modify Successful");
?>