/var/www/(Del)tsolpv.com/2013/webadmin/productcat_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
110
111
112
113
114
115
116
117
118
119
<?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"); 

$pdcattitleen        htmlspecialchars($_POST["pdcattitleen"],ENT_QUOTES);
$pdcattitlesc        htmlspecialchars($_POST["pdcattitlesc"],ENT_QUOTES);
$parentid            $_POST["pid"];
$levelnum            $_POST["levelnum"];
$pdcatdescen        preg_replace("/'/","\'",$_POST["pdcatdescen"]);
$pdcatdescsc        preg_replace("/'/","\'",$_POST["pdcatdescsc"]);
$pdcatbannerlinken        htmlspecialchars($_POST["pdcatbannerlinken"],ENT_QUOTES);
$pdcatbannerlinksc        htmlspecialchars($_POST["pdcatbannerlinksc"],ENT_QUOTES);
$metatitleen        htmlspecialchars($_POST["metatitleen"],ENT_QUOTES);
$metakeyworden        htmlspecialchars($_POST["metakeyworden"],ENT_QUOTES);
$metadescen            htmlspecialchars($_POST["metadescen"],ENT_QUOTES);
$metatitlesc        htmlspecialchars($_POST["metatitlesc"],ENT_QUOTES);
$metakeywordsc        htmlspecialchars($_POST["metakeywordsc"],ENT_QUOTES);
$metadescsc            htmlspecialchars($_POST["metadescsc"],ENT_QUOTES);
$pdcatsort        $_POST["pdcatsort"];
$nowdate             date("Y-m-d H:i:s");
//print_r($_POST); 

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

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

}
else
{
    
$pdcatbanneren "";
}

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

}
else
{
    
$pdcatbannersc "";
}
// Sort
$sql "select max(pdcatsort) as maxid ";
$sql .= "from product_cat where parentid=$parentid ";
$result=mysql_query($sql);
$row mysql_fetch_array($result,MYSQL_ASSOC);
$pdcatsort $row{maxid}+1;

if( 
mysql_num_rows(mysql_query("SELECT pdcatid FROM product_cat WHERE pdcatsort=$pdcatsort ")) > 0){
    
mysql_query("UPDATE product_cat SET pdcatsort= pdcatsort+1 WHERE pdcatsort >=$pdcatsort ");
}

$sql "insert into product_cat (pdcatid, pdcattitleen, pdcattitlesc, parentid, levelnum, pdcatdescen, pdcatdescsc, pdcatbanneren, pdcatbannersc, pdcatbannerlinken, pdcatbannerlinksc, pdcatsort, pdcatstatus, metatitleen, metatitlesc, metakeyworden, metakeywordsc, metadescen, metadescsc, creationday, modifyday, cmsloginid) values ('$pdcatid', '$pdcattitleen', '$pdcattitlesc', '$parentid', '$levelnum', '$pdcatdescen', '$pdcatdescsc', '$pdcatbanneren', '$pdcatbannersc', '$pdcatbannerlinken', '$pdcatbannerlinksc', '$pdcatsort', '1', '$metatitleen', '$metatitlesc', '$metakeyworden', '$metakeywordsc', '$metadescen', '$metadescsc', '$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: productcat_index.php?pid=$parentid&msg=建立成功");
?>