/var/www/(Del)tsolpv.com/2013/webadmin/h_brand_add.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?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"); 

$hbrandsort            $_POST["hbrandsort"];
$hbrandlinken        htmlspecialchars($_POST["hbrandlinken"],ENT_QUOTES);
$hbrandlinksc        htmlspecialchars($_POST["hbrandlinksc"],ENT_QUOTES);
$nowdate        date("Y-m-d H:i:s");
//print_r($_POST); 

$sql "select max(hbrandid) as maxid ";
$sql .= "from h_brand ";
$result=mysql_query($sql);
$row mysql_fetch_array($result,MYSQL_ASSOC);
$hbrandid $row{maxid}+1;

if (
$_FILES['hbrandimgen']['name'] <> '')
{
    if ((
$_FILES["hbrandimgen"]["type"] == "image/bmp") || ($_FILES["hbrandimgen"]["type"] == "image/BMP") || ($_FILES["hbrandimgen"]["type"] == "image/gif") || ($_FILES["hbrandimgen"]["type"] == "image/GIF") || ($_FILES["hbrandimgen"]["type"] == "image/jpg") || ($_FILES["hbrandimgen"]["type"] == "image/JPG") || ($_FILES["hbrandimgen"]["type"] == "image/jpeg") || ($_FILES["hbrandimgen"]["type"] == "image/JPEG") || ($_FILES["hbrandimgen"]["type"] == "image/pjpeg") || ($_FILES["hbrandimgen"]["type"] == "image/PJEG") || ($_FILES["hbrandimgen"]["type"] == "image/png") || ($_FILES["hbrandimgen"]["type"] == "image/x-png") || ($_FILES["hbrandimgen"]["type"] == "image/PNG") || ($_FILES["hbrandimgen"]["type"] == "image/X-PNG"))
    {
        
$filename=$_FILES['hbrandimgen']['name'];
        
preg_match("/\.([^\.]+)$/"$filename$file_ext);
        
        
copy ($_FILES['hbrandimgen']['tmp_name'], "../brand/id_".$hbrandid."_en.".$file_ext[1]) 
                or die (
"Could not copy the file: 主页 商标(EN)"); 
        
        
$hbrandimgen     "id_".$hbrandid."_en.".$file_ext[1];
        
$hbrandimgen    htmlspecialchars($hbrandimgen,ENT_QUOTES);
      }
    else
      {
      
// upload error
      
?>
        <script language="javascript">
        alert("Files must be BMP, JPEG, GIF, or PNG");
        history.back();
        </script>
     <?php
     
exit;
     }

}
else
{
    
$hbrandimgen "";
}

if (
$_FILES['hbrandimgsc']['name'] <> '')
{
    if ((
$_FILES["hbrandimgsc"]["type"] == "image/bmp") || ($_FILES["hbrandimgsc"]["type"] == "image/BMP") || ($_FILES["hbrandimgsc"]["type"] == "image/gif") || ($_FILES["hbrandimgsc"]["type"] == "image/GIF") || ($_FILES["hbrandimgsc"]["type"] == "image/jpg") || ($_FILES["hbrandimgsc"]["type"] == "image/JPG") || ($_FILES["hbrandimgsc"]["type"] == "image/jpeg") || ($_FILES["hbrandimgsc"]["type"] == "image/JPEG") || ($_FILES["hbrandimgsc"]["type"] == "image/pjpeg") || ($_FILES["hbrandimgsc"]["type"] == "image/PJEG") || ($_FILES["hbrandimgsc"]["type"] == "image/png") || ($_FILES["hbrandimgsc"]["type"] == "image/x-png") || ($_FILES["hbrandimgsc"]["type"] == "image/PNG") || ($_FILES["hbrandimgsc"]["type"] == "image/X-PNG"))
    {
        
$filename=$_FILES['hbrandimgsc']['name'];
        
preg_match("/\.([^\.]+)$/"$filename$file_ext);
        
        
copy ($_FILES['hbrandimgsc']['tmp_name'], "../brand/id_".$hbrandid."_sc.".$file_ext[1]) 
                or die (
"Could not copy the file: 主页 商标(EN)"); 
        
        
$hbrandimgsc     "id_".$hbrandid."_sc.".$file_ext[1];
        
$hbrandimgsc    htmlspecialchars($hbrandimgsc,ENT_QUOTES);
      }
    else
      {
      
// upload error
      
?>
        <script language="javascript">
        alert("Files must be BMP, JPEG, GIF, or PNG");
        history.back();
        </script>
     <?php
     
exit;
     }

}
else
{
    
$hbrandimgsc "";
}

// Sort
if ($hbrandsort == '' || $hbrandsort == '0') {
    
$sql "select max(hbrandsort) as maxid ";
    
$sql .= "from h_brand ";
    
$result=mysql_query($sql);
    
$row mysql_fetch_array($result,MYSQL_ASSOC);
    
$hbrandsort $row{maxid}+1;
}
if( 
mysql_num_rows(mysql_query("SELECT hbrandid FROM h_brand WHERE hbrandsort=$hbrandsort ")) > 0){
    
mysql_query("UPDATE h_brand SET hbrandsort= hbrandsort+1 WHERE hbrandsort >=$hbrandsort ");
}

$sql "insert into h_brand (hbrandid, hbrandimgen, hbrandimgsc, hbrandlinken, hbrandlinksc, hbrandsort, hbrandstatus, creationday, modifyday, cmsloginid) values ('$hbrandid', '$hbrandimgen', '$hbrandimgsc', '$hbrandlinken', '$hbrandlinksc', '$hbrandsort', '1', '$nowdate', '$nowdate', '".$_SESSION['cmsloginid']."')";
mysql_query($sql);
if( 
mysql_errno() > ){
    echo 
'Add 主页 商标 Error:<br />'mysql_error() .'<br />SQL: '$sql;
    exit;
}

mysql_close($dbh);

header("Location: h_brand_index.php?msg=建立成功");
?>