This repository was archived by the owner on Nov 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsession.php
More file actions
175 lines (150 loc) · 4.76 KB
/
Copy pathsession.php
File metadata and controls
175 lines (150 loc) · 4.76 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!DOCTYPE html>
<?php
try
{
@$sessIdStr = $_GET['sess'];
if(!isset($sessIdStr))
{
@$sessIdStr = $_GET['id'];
}
if(!isset($sessIdStr))
{
header('content-type: text/html');
echo "Error: no 'sess' or 'id' URL parameter";
return;
}
# Perform database initialization
require_once("config.php");
$conn = new Mongo('mongodb://' . $server);
$sessColl = $conn->selectDB($database)->selectCollection("sessions");
# Perform the query to get session document, for name
$sessDoc = $sessColl->findOne( array("_id" => new MongoId($sessIdStr)) );
if (array_key_exists('label', $sessDoc))
{
$sessTitle = $sessDoc['label'];
}
else
{
$sessTitle = $sessDoc['name'];
}
}
# Error handling
catch (Exception $e)
{
header('content-type: text/plain');
echo 'Caught exception: ', $e->getMessage(), "\n";
return;
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Slide Atlas</title>
<script src="libs/jquery/jquery-1.7.2.min.js"></script>
<script src="libs/jquery.mobile/jquery.mobile-1.1.0.min.js"></script>
<link rel="stylesheet" href="libs/jquery.mobile/jquery.mobile-1.1.0.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" href="favicon.ico">
<link rel="stylesheet" href="css/common.css" type="text/css">
</head>
<body>
<div data-role="page">
<div data-role="header" data-position="fixed" data-tap-toggle="false">
<div class="ui-btn-left">
<a data-role="button" data-icon="arrow-u" data-iconpos="right" data-ajax="false" href="<?php echo(array_key_exists('facebook', $_SESSION) ? "access-groups.php" : "session-index.php"); ?>">Return</a>
</div>
<h1><?php echo($sessTitle) ?></h1>
<div class="ui-btn-right">
<a href="" data-role="button" data-icon="gear" class='ui-btn-right' data-theme="<?php echo(($_SESSION['auth'] == 'admin') ? "b" : "a"); ?>">Options</a>
</div>
</div>
<div data-role="content">
<?php
# Loop through images
$grid = $conn->selectDB($database)->getGridFS("attachments");
# build a PHP-style sorted array from 'images' array
$sessImgsSorted = array();
foreach ($sessDoc['attachments'] as $refListElem)
{
if($refListElem['hide'] === false)
{
$sessImgsSorted[$refListElem['pos']] = $refListElem['ref'];
}
}
ksort($sessImgsSorted);
if(count($sessImgsSorted) > 0)
{
?>
<div id="banner">
<h2>List of attached files</h2>
</div>
<ul data-role="listview">
<?php
#var_dump($sessImgsSorted);
foreach ($sessImgsSorted as $sessImgId)
{
$imgDoc = $grid->findOne( array("_id" => $sessImgId) );
$imgTitle = $imgDoc->getFilename();
$imgExtension = pathinfo($imgTitle, PATHINFO_EXTENSION);
if($imgExtension != 'ppt' && $imgExtension != 'pdf' && $imgExtension != 'wmv' && $imgExtension != 'mp4' && $imgExtension != 'm4v')
{
$imgExtension = 'file';
}
echo '<li><a data-ajax="false" rel="external" href="attachment.php?id=' , $sessImgId, '">';
echo '<img src="img/', $imgExtension , '.png">' , $imgTitle , '</a></li>' , "\n";
}
?>
</ul>
<br/>
<br/>
<?php
}
?>
<div id="banner">
<h2>List of images</h2>
</div>
<ul data-role="listview">
<?php
# Loop through images
# build a PHP-style sorted array from 'images' array
$sessImgsSorted = array();
foreach ($sessDoc['images'] as $refListElem)
{
if($refListElem['hide'] === false)
{
$sessImgsSorted[$refListElem['pos']] = $refListElem['ref'];
}
}
ksort($sessImgsSorted);
$imgsColl = $conn->selectDB($database)->selectCollection("images");
foreach ($sessImgsSorted as $sessImgId)
{
$imgDoc = $imgsColl->findOne( array("_id" => $sessImgId) );
if(array_key_exists('label', $imgDoc))
{
$imgTitle = $imgDoc['label'];
}
else
{
$imgTitle = $imgDoc['name'];
}
$thumbDoc = $conn->selectDB($database)->selectCollection(strval($sessImgId))->findOne( array("name" => "thumb.jpg"), array("file") );
if(!is_null($thumbDoc))
{
$thumbDocFile = 'thumb.jpg';
}
else
{
$thumbDocFile = 't.jpg';
}
echo '<li><a data-ajax="false" rel="external" href="image.php?sess=' , $sessDoc['_id'] , '&img=' , $imgDoc['_id'] , '#mappage">';
echo '<img src="/tile.php?image=' , $imgDoc['_id'] , '&name=' , $thumbDocFile , '" alt="">' , $imgTitle , '</a></li>' , "\n";
}
?>
</ul>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>