/var/www/c-c.com.hk/webadmin/project_image_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
<?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_createthumb.php");
 
$pdid                 $_POST["pdid"];
$pimgid             $_POST["pimgid"];
$nowdate             date("Y-m-d H:i:s");
//print_r($_POST);

if ($_FILES['pimgfile']['name'] <> '')
{
    if ((
$_FILES["pimgfile"]["type"] == "image/bmp") || ($_FILES["pimgfile"]["type"] == "image/BMP") || ($_FILES["pimgfile"]["type"] == "image/gif") || ($_FILES["pimgfile"]["type"] == "image/GIF") || ($_FILES["pimgfile"]["type"] == "image/jpg") || ($_FILES["pimgfile"]["type"] == "image/JPG") || ($_FILES["pimgfile"]["type"] == "image/jpeg") || ($_FILES["pimgfile"]["type"] == "image/JPEG") || ($_FILES["pimgfile"]["type"] == "image/pjpeg") || ($_FILES["pimgfile"]["type"] == "image/PJEG") || ($_FILES["pimgfile"]["type"] == "image/png") || ($_FILES["pimgfile"]["type"] == "image/x-png") || ($_FILES["pimgfile"]["type"] == "image/PNG") || ($_FILES["pimgfile"]["type"] == "image/X-PNG"))
    {
        
$filename=$_FILES['pimgfile']['name'];
        
preg_match("/\.([^\.]+)$/"$filename$file_ext);
        
        
copy ($_FILES['pimgfile']['tmp_name'], "../project/".$pdid."_id_".$pimgid.".".$file_ext[1]) 
            or die (
"Could not copy the file: Project Photo");
        
        
$image "../project/".$pdid."_id_".$pimgid.".".$file_ext[1];
        
createthumb($image$image800800);
        
        
copy ($_FILES['pimgfile']['tmp_name'], "../project/large/".$pdid."_id_".$pimgid.".".$file_ext[1]) 
            or die (
"Could not copy the file: Project Photo(large)");
        
        
$imagelarge "../project/large/".$pdid."_id_".$pimgid.".".$file_ext[1];
        
createthumb($imagelarge$imagelarge280280);
        
        
copy ($_FILES['pimgfile']['tmp_name'], "../project/thumb/".$pdid."_id_".$pimgid.".".$file_ext[1]) 
            or die (
"Could not copy the file: Project Photo(thumb)"); 
        
        
$imagethumb "../project/thumb/".$pdid."_id_".$pimgid.".".$file_ext[1];
        
createthumb($imagethumb$imagethumb140140);
        
        
$pimgfile $pdid."_id_".$pimgid.".".$file_ext[1];
        
$pimgfile htmlspecialchars($pimgfile,ENT_QUOTES);
        
      }
    else
      {
      
// upload error
      
?>
        <script language="javascript">
        alert("Files must be BMP, JPEG, GIF, or PNG");
        history.back();
        </script>
     <?php
     
exit;
     }

}
else
{
    
$pimgfile "";
}

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

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

mysql_close($dbh);

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