/var/www/(Del)tsolpv.com/2013/webadmin/h_slideshow_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"); 

$hssort            $_POST["hssort"];
$hslinken        htmlspecialchars($_POST["hslinken"],ENT_QUOTES);
$hslinksc        htmlspecialchars($_POST["hslinksc"],ENT_QUOTES);
$nowdate        date("Y-m-d H:i:s");
//print_r($_POST); 

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

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

}
else
{
    
$hsimgen "";
}

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

}
else
{
    
$hsimgsc "";
}

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

$sql "insert into h_slideshow (hsid, hsimgen, hsimgsc, hslinken, hslinksc, hssort, hsstatus, creationday, modifyday, cmsloginid) values ('$hsid', '$hsimgen', '$hsimgsc', '$hslinken', '$hslinksc', '$hssort', '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_slideshow_index.php?msg=建立成功");
?>