/var/www/(Del)hsiaust.com.au/webadmin/contactus_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
74
75
76
77
78
<?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"); 

$contactusid             $_POST["contactusid"];
$contactusdistricten    htmlspecialchars($_POST["contactusdistricten"],ENT_QUOTES);
$contactusdistricttc    htmlspecialchars($_POST["contactusdistricttc"],ENT_QUOTES);
$contactusdistrictsc    htmlspecialchars($_POST["contactusdistrictsc"],ENT_QUOTES);
$contactuscontenten        preg_replace("/'/","\'",$_POST["contactuscontenten"]);
$contactuscontenttc        preg_replace("/'/","\'",$_POST["contactuscontenttc"]);
$contactuscontentsc        preg_replace("/'/","\'",$_POST["contactuscontentsc"]);
$nowdate                 date("Y-m-d H:i:s");
//print_r($_POST);

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

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

        
$contactusimageimg "../images/contactus_".$contactusid."_".$_FILES['contactusimage']['name'];
        
createthumb($contactusimageimg$contactusimageimg336190);

        
        
$contactusimage "contactus_".$contactusid."_".$_FILES['contactusimage']['name'];
      }
    else
      {
      
// upload error
      
?>
        <script language="javascript">
        alert("Files must be JPEG, GIF, or PNG");
        history.back();
        </script>
     <?php
     
exit;
     }

}
else
{
    
$contactusimage "";
}

// Modify 
$sql "update contactus set contactusdistricten='$contactusdistricten', contactusdistricttc='$contactusdistricttc', contactusdistrictsc='$contactusdistrictsc', contactuscontenten='$contactuscontenten', contactuscontenttc='$contactuscontenttc', contactuscontentsc='$contactuscontentsc', modifyday='$nowdate', cmsloginid='".$_SESSION['cmsloginid']."' ";
if (
$contactusimage <> '')
    
$sql .= ", contactusimage='$contactusimage' ";
$sql .= " where contactusid="$contactusid ." ";
mysql_query($sql);

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

mysql_close($dbh);

header("Location: contactus_index.php?msg=Modify Successful");
?>