This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
photoupload2.php
executable file
·132 lines (102 loc) · 3.17 KB
/
photoupload2.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
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
session_start();
require("include/functions.php");
$config_file = 'config.php';
if (file_exists($config_file)) {
require("config.php");
} else {
header("Location: error.php?e=config");
die();
}
require("include/apply_config.php");
$force_loggedin = TRUE;
require("include/check_login.php");
$SiteID=filter_var($_POST["SiteID"], FILTER_SANITIZE_NUMBER_INT);
$photodir=filter_var($_POST["photodir"], FILTER_SANITIZE_STRING);
$photonotes=filter_var($_POST["photonotes"], FILTER_SANITIZE_STRING);
if ($photodir==""){
$photodir="NULL";
}
if ($photonotes==""){
$photonotes="NULL";
}
$random_cookie=mt_rand();
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
<html>
<head>
<title>$app_custom_name - Upload photograph</title>";
require("include/get_css.php");
require("include/get_jqueryui.php");
if ($use_googleanalytics) {
echo $googleanalytics_code;
}
#Execute custom code for head, if set
if (is_file("$absolute_dir/customhead.php")) {
include("customhead.php");
}
?>
</head>
<body>
<!--Blueprint container-->
<div class="container">
<?php
require("include/topbar.php");
?>
<div class="span-24 last">
<hr noshade>
</div>
<div class="span-24 last">
<?php
if (($_FILES['userfile']['type'] == "image/jpeg") || ($_FILES['userfile']['type'] == "image/pjpeg")) {
$target_path = "sitephotos/$SiteID/";
if (!is_dir($target_path)) {
mkdir($target_path, 0777);
}
$filename=basename( $_FILES['userfile']['name']);
if (is_file($target_path)) {
$filename=str_ireplace(".jpg",$random_cookie . ".jpg",$filename);
}
$target_path = $target_path . $filename;
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
$exif_data = exif_read_data($target_path, 0, true);
if ($exif_data===false) {
echo "<div class=\"error\">The file could not be processed because it does not have the EXIF headers.</div>";
}
else {
$exif_date = $exif_data['EXIF']['DateTimeOriginal'];
$photo_date=convertExifToTimestamp($exif_date, "Y-m-d H:i:s");
#Get username
$username = $_COOKIE["username"];
$result = mysqli_query($connection, "SELECT * FROM Users WHERE UserName='$username' LIMIT 1")
or die (mysqli_error($connection));
$row = mysqli_fetch_array($result);
if (mysqli_num_rows($result) == 1) {
extract($row);
}
$query_file = "INSERT INTO SitesPhotos
(SiteID,PhotoFilename,ViewDegrees,PhotoDate,UserID,PhotoNotes)
VALUES
('$SiteID','$filename','$photodir','$photo_date','$UserID','$PhotoNotes')";
$result_file = mysqli_query($connection, $query_file)
or die (mysqli_error($connection));
echo "<div class=\"success\">The photograph was uploaded successfuly.</div>";
}
}
else {
echo "<div class=\"error\">The file could not be processed.</div>";
}
}
else {
echo "<div class=\"error\">The file is not a recognized jpg file.</div>";
}
?>
<p><a href="photoupload.php">Upload another photograph.</a>
</div>
<div class="span-24 last">
<?php
require("include/bottom.php");
?>
</div>
</div>
</body>
</html>