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
|
<?php include 'config.php';
// Check if the user is logged in
if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1')) { header("Location: login.php"); exit; }
require_once("function_cropimg.php"); require_once("mime_type_lib.php");
$slideid = (int)$_POST["slideid"]; $nowdate = date("Y-m-d H:i:s");
foreach ($arraylangcode as $langcode => $langname) { $slidelink[$langcode] = "";
// Upload File
if ($_FILES["slideimg_" . $langcode]['name'] <> '') {
//check if image type is valid or not $mime = get_file_mime_type($_FILES["slideimg_" . $langcode]['name']);
if ((!strpos($mime,"image/gif") || !strpos($mime,"image/jpeg") || !strpos($mime,"image/png"))) {
$filename = $_FILES["slideimg_" . $langcode]['name']; preg_match("/\.([^\.]+)$/", $filename, $file_ext); $newfilename = random_string() . "_slideid_" . $slideid . "." . $file_ext[1]; // default length 8
move_uploaded_file($_FILES["slideimg_" . $langcode]['tmp_name'], "../images/slideshow/" . $newfilename) or die ("Could not copy the file");
//$slideimg_path = "../images/slideshow/".$newfilename;
//createthumb($slideimg_path, $slideimg_path, 680, 350);
$slideimg[$langcode] = $newfilename;
} else { echo '<script language="javascript"> alert("Image format must be JPEG, GIF, or PNG"); history.back(); </script>';
exit; }
} else { $slideimg[$langcode] = ""; }
}
// Modify
$sql = "update slideshow set slidelink_en=?,slidelink_tc=?, lastupdate=?, lastupby=?"; $parameters = array($slidelink["en"], $slidelink["tc"], $nowdate, $_SESSION['cmsloginid']);
if ($slideimg["tc"] <> '' or $_POST['delimage_tc'] > 0){ $sql .= ", slideimg_tc=? "; $parameters[] = $slideimg["tc"]; }
if ($slideimg["en"] <> '' or $_POST['delimage_en'] > 0){ $sql .= ", slideimg_en=? "; $parameters[] = $slideimg["en"]; }
$sql .= "where slideid=?"; $parameters[] = $slideid;
if (!($sth2 = $dbh->prepare($sql))) { throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
if (!$sth2->execute($parameters)) { throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
$dbh = null;
header("Location: slideshow_index.php?msg=Update Successfully");
|