/var/www/hkosl.com/kelvin/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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?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");

$contactid                 check_input($_POST["contactid"]);
    
/*
$contacttitleen         = htmlspecialchars($_POST["contacttitleen"],ENT_QUOTES);
$contacttitletc         = htmlspecialchars($_POST["contacttitletc"],ENT_QUOTES);
    */
$contactdescsc            preg_replace("/'/","\'",$_POST["contactdescsc"]);
$contactdesctc            preg_replace("/'/","\'",$_POST["contactdesctc"]);
$nowdate                 date("Y-m-d H:i:s");

    
$sql2 "SELECT * FROM contactus WHERE contactid='$contactid' ";
    
$result2=mysql_query($sql2);
    
$row2 mysql_fetch_array($result2,MYSQL_ASSOC);
    if (
$_FILES['contactimg']['name'] <> '' or $_POST['delimage'] > )    {
        
unlink("../images/".$row2{'contactimg'});
        
$sql "update contactus set contactimg=''";
        
$sql .= "where contactid="$contactid ." ";
        
mysql_query($sql);
    }



    
$filelimit 1048576//Filelimit in 2MB
    
if ($_FILES['contactimg']['name'] <> '')
    {
        if (
$_FILES['contactimg']['size'] < $filelimit ){

            if ((
$_FILES["contactimg"]["type"] == "image/gif") || ($_FILES["contactimg"]["type"] == "image/GIF") || ($_FILES["contactimg"]["type"] == "image/jpg") || ($_FILES["contactimg"]["type"] == "image/JPG") || ($_FILES["contactimg"]["type"] == "image/jpeg") || ($_FILES["contactimg"]["type"] == "image/JPEG") || ($_FILES["contactimg"]["type"] == "image/pjpeg") || ($_FILES["contactimg"]["type"] == "image/PJEG") || ($_FILES["contactimg"]["type"] == "image/png") || ($_FILES["contactimg"]["type"] == "image/x-png") || ($_FILES["contactimg"]["type"] == "image/PNG") || ($_FILES["contactimg"]["type"] == "image/X-PNG"))
            {
                
$filename=$_FILES['contactimg']['name'];
                
preg_match("/\.([^\.]+)$/"$filename$file_ext);


                
copy ($_FILES['contactimg']['tmp_name'], "../images/contact_".$contactid.".".$file_ext[1])
                or die (
"Could not copy the file: Product Photo(thumb)");

                
$imagethumb "../images/contact_".$contactid.".".$file_ext[1];
                
//createthumb($imagethumb, $imagethumb, 220, 454);

                
$contactimg "contact_".$contactid.".".$file_ext[1];
                
$contactimg htmlspecialchars($contactimg,ENT_QUOTES);
            }

        }
        else
        {
            
// upload error
            
?>
            <script language="javascript">
                alert("Files must be JPEG, GIF, or PNG and under 2MB in size");
                history.back();
            </script>
            <?php
            
exit;
        }

    }
    else
    {
        
$contactimg ="";
    }


// Modify
//$sql = "update contactus set contacttitleen='$contacttitleen', contacttitletc='$contacttitletc', contactdescsc='$contactdescsc', contactdesctc='$contactdesctc', modifyday='$nowdate', cmsloginid='".$_SESSION['cmsloginid']."' ";

$sql "update contactus set contactdescsc='$contactdescsc', contactdesctc='$contactdesctc', lastupdate='$nowdate', lastupby='".$_SESSION['cmsloginid']."' ";

    if (
$contactimg <> '' or $_POST['delimagesc'] > )
        
$sql .= ", contactimg='$contactimg'";

$sql .= " where contactid="$contactid ." ";
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");
?>