-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofilePic.php
More file actions
51 lines (42 loc) · 1.33 KB
/
profilePic.php
File metadata and controls
51 lines (42 loc) · 1.33 KB
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
<?
require('config.php');
require('functionlib.php');
try {
if (!isset($_GET['id'])) {
throw new Exception('ID not specified');
}
$id = intval($_GET['id']);
if ($id <= 0) {
throw new Exception('Invalid ID specified');
}
if ($_GET["thumb"] == 0) {
$query = sprintf('select `profilePicture` from `student` where `studentKey` = %d', $id);
} else {
$query = sprintf('select `profilePictureThumb` as `profilePicture` from `student` where `studentKey` = %d', $id);
}
$result = myquery($query);
if (mysql_num_rows($result) == 0) $notfound = TRUE;
else {
$image = mysql_fetch_array($result);
if (strlen($image["profilePicture"]) == 0) $notfound = TRUE;
}
if ($notfound == TRUE) {
header('Content-type: image/jpeg');
//throw new Exception('Image with specified ID not found');
if ($_GET["thumb"] == 0) {
readfile('images/200pxQues.jpg');
} else {
readfile('images/50pxQues.jpg');
}
die();
}
}
catch (Exception $ex) {
header('HTTP/1.0 404 Not Found');
exit;
}
header('Content-type: image/jpeg'); // . $image['profilePictureMime']);
//header('Content-length: ' . $image['profilePictureSize']);
mysql_close();
echo $image['profilePicture'];
?>