Merge lp:~dangarner/xibo/store-media-md5 into lp:~xibo-maintainers/xibo/encke
- store-media-md5
- Merge into encke
Proposed by
Dan Garner
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~dangarner/xibo/store-media-md5 |
Merge into: | lp:~xibo-maintainers/xibo/encke |
Diff against target: |
5108 lines 6 files modified
server/install/database/8.sql (+7/-0) server/modules/flash.module.php (+173/-164) server/modules/image.module.php (+176/-167) server/modules/powerpoint.module.php (+174/-165) server/modules/video.module.php (+172/-163) server/xmds.php (+346/-187) |
To merge this branch: | bzr merge lp:~dangarner/xibo/store-media-md5 |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Xibo Maintainters | Pending | ||
Review via email: mp+12623@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'server/install/database/8.sql' | |||
2 | --- server/install/database/8.sql 1970-01-01 00:00:00 +0000 | |||
3 | +++ server/install/database/8.sql 2009-09-29 22:15:22 +0000 | |||
4 | @@ -0,0 +1,7 @@ | |||
5 | 1 | /* Add the MD5 and FileSize as columns to the media table */ | ||
6 | 2 | ALTER TABLE `media` ADD `MD5` VARCHAR( 32 ) NULL AFTER `storedAs` , | ||
7 | 3 | ADD `FileSize` BIGINT NULL AFTER `MD5` ; | ||
8 | 4 | |||
9 | 5 | UPDATE `version` SET `app_ver` = '1.0.4'; | ||
10 | 6 | UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE'; | ||
11 | 7 | UPDATE `version` SET `DBVersion` = '8'; | ||
12 | 0 | 8 | ||
13 | === modified file 'server/modules/flash.module.php' | |||
14 | --- server/modules/flash.module.php 2009-06-28 10:47:06 +0000 | |||
15 | +++ server/modules/flash.module.php 2009-09-29 22:15:22 +0000 | |||
16 | @@ -8,7 +8,7 @@ | |||
17 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
18 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
19 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
21 | 11 | * any later version. | 11 | * any later version. |
22 | 12 | * | 12 | * |
23 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
24 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | @@ -17,31 +17,31 @@ | |||
26 | 17 | * | 17 | * |
27 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
28 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
30 | 20 | */ | 20 | */ |
31 | 21 | class flash extends Module | 21 | class flash extends Module |
32 | 22 | { | 22 | { |
33 | 23 | // Custom Media information | 23 | // Custom Media information |
34 | 24 | private $uri; | 24 | private $uri; |
35 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
36 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
38 | 27 | 27 | ||
39 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
40 | 29 | { | 29 | { |
41 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
42 | 31 | $this->type = 'flash'; | 31 | $this->type = 'flash'; |
44 | 32 | 32 | ||
45 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
46 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
47 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
50 | 36 | 36 | ||
51 | 37 | // Must call the parent class | 37 | // Must call the parent class |
52 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
53 | 39 | } | 39 | } |
55 | 40 | 40 | ||
56 | 41 | /** | 41 | /** |
57 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
58 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
60 | 44 | * @return | 44 | * @return |
61 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
62 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
63 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
64 | @@ -53,75 +53,75 @@ | |||
65 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
66 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
67 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
69 | 56 | 56 | ||
70 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
72 | 58 | 58 | ||
73 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
74 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
76 | 61 | 61 | ||
77 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
78 | 63 | { | 63 | { |
79 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
80 | 65 | return false; | 65 | return false; |
81 | 66 | } | 66 | } |
83 | 67 | 67 | ||
84 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
85 | 69 | { | 69 | { |
86 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
87 | 71 | return false; | 71 | return false; |
88 | 72 | } | 72 | } |
90 | 73 | 73 | ||
91 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
92 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
93 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
95 | 77 | 77 | ||
96 | 78 | // Required Attributes | 78 | // Required Attributes |
97 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
99 | 80 | 80 | ||
100 | 81 | // Any Options | 81 | // Any Options |
101 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
103 | 83 | 83 | ||
104 | 84 | return true; | 84 | return true; |
105 | 85 | } | 85 | } |
107 | 86 | 86 | ||
108 | 87 | /** | 87 | /** |
109 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
111 | 89 | * @return | 89 | * @return |
112 | 90 | */ | 90 | */ |
113 | 91 | public function AddForm() | 91 | public function AddForm() |
114 | 92 | { | 92 | { |
115 | 93 | global $session; | 93 | global $session; |
116 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
117 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
120 | 96 | 96 | ||
121 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
122 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
123 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
125 | 100 | 100 | ||
126 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
127 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
128 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
130 | 104 | 104 | ||
131 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
133 | 106 | 106 | ||
134 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
135 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
136 | 109 | 109 | ||
137 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
138 | 111 | 111 | ||
140 | 112 | if($default=="private") | 112 | if($default=="private") |
141 | 113 | { | 113 | { |
142 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
143 | 115 | } | 115 | } |
145 | 116 | 116 | ||
146 | 117 | //shared list | 117 | //shared list |
147 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
149 | 119 | 119 | ||
150 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
151 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
152 | 122 | { | 122 | { |
153 | 123 | setSession('content','mediatype','flash'); | 123 | setSession('content','mediatype','flash'); |
155 | 124 | 124 | ||
156 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
157 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
158 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
159 | @@ -135,7 +135,7 @@ | |||
160 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
161 | 136 | END; | 136 | END; |
162 | 137 | } | 137 | } |
164 | 138 | 138 | ||
165 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
166 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
167 | 141 | <div> | 141 | <div> |
168 | @@ -144,7 +144,7 @@ | |||
169 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
170 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
171 | 146 | <table> | 146 | <table> |
173 | 147 | <tr> | 147 | <tr> |
174 | 148 | <td><label for="file">Flash File<span class="required">*</span></label></td> | 148 | <td><label for="file">Flash File<span class="required">*</span></label></td> |
175 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
176 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
177 | @@ -172,7 +172,7 @@ | |||
178 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
179 | 173 | <td> | 173 | <td> |
180 | 174 | $shared_list | 174 | $shared_list |
182 | 175 | </td> | 175 | </td> |
183 | 176 | </tr> | 176 | </tr> |
184 | 177 | <tr> | 177 | <tr> |
185 | 178 | <td></td> | 178 | <td></td> |
186 | @@ -194,49 +194,49 @@ | |||
187 | 194 | 194 | ||
188 | 195 | return $this->response; | 195 | return $this->response; |
189 | 196 | } | 196 | } |
191 | 197 | 197 | ||
192 | 198 | /** | 198 | /** |
193 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
195 | 200 | * @return | 200 | * @return |
196 | 201 | */ | 201 | */ |
197 | 202 | public function EditForm() | 202 | public function EditForm() |
198 | 203 | { | 203 | { |
199 | 204 | global $session; | 204 | global $session; |
200 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
201 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
204 | 207 | 207 | ||
205 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
206 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
207 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
208 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
209 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
210 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
212 | 214 | 214 | ||
213 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
214 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
215 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
217 | 218 | 218 | ||
218 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
220 | 220 | 220 | ||
221 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
222 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
224 | 223 | 223 | ||
225 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
226 | 225 | { | 225 | { |
227 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
229 | 227 | 227 | ||
230 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
231 | 229 | return false; | 229 | return false; |
232 | 230 | } | 230 | } |
234 | 231 | 231 | ||
235 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
236 | 233 | { | 233 | { |
237 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
239 | 235 | 235 | ||
240 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
241 | 237 | return false; | 237 | return false; |
242 | 238 | } | 238 | } |
244 | 239 | 239 | ||
245 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
246 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
247 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
248 | @@ -246,23 +246,23 @@ | |||
249 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
250 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
251 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
253 | 249 | 249 | ||
254 | 250 | // derive the ext | 250 | // derive the ext |
255 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
257 | 252 | 252 | ||
258 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
259 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
261 | 255 | 255 | ||
262 | 256 | //shared list | 256 | //shared list |
263 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
265 | 258 | 258 | ||
266 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
267 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
268 | 261 | { | 261 | { |
269 | 262 | setSession('content','mediatype','flash'); | 262 | setSession('content','mediatype','flash'); |
271 | 263 | 263 | ||
272 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
274 | 265 | 265 | ||
275 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
276 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
277 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
278 | @@ -272,13 +272,13 @@ | |||
279 | 272 | else | 272 | else |
280 | 273 | { | 273 | { |
281 | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; |
283 | 275 | 275 | ||
284 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
285 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
286 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
287 | 279 | END; | 279 | END; |
288 | 280 | } | 280 | } |
290 | 281 | 281 | ||
291 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
292 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
293 | 284 | <div> | 284 | <div> |
294 | @@ -287,7 +287,7 @@ | |||
295 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
296 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
297 | 289 | <table> | 289 | <table> |
299 | 290 | <tr> | 290 | <tr> |
300 | 291 | <td><label for="file">New Flash File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Flash File<span class="required">*</span></label></td> |
301 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
302 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
303 | @@ -319,7 +319,7 @@ | |||
304 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
305 | 320 | <td> | 320 | <td> |
306 | 321 | $shared_list | 321 | $shared_list |
308 | 322 | </td> | 322 | </td> |
309 | 323 | </tr> | 323 | </tr> |
310 | 324 | <tr> | 324 | <tr> |
311 | 325 | <td></td> | 325 | <td></td> |
312 | @@ -343,50 +343,50 @@ | |||
313 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
314 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
315 | 345 | 345 | ||
317 | 346 | return $this->response; | 346 | return $this->response; |
318 | 347 | } | 347 | } |
320 | 348 | 348 | ||
321 | 349 | /** | 349 | /** |
322 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
324 | 351 | * @return | 351 | * @return |
325 | 352 | */ | 352 | */ |
326 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
327 | 354 | { | 354 | { |
328 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
329 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
332 | 357 | 357 | ||
333 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
334 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
335 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
336 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
337 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
338 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
340 | 364 | 364 | ||
341 | 365 | $options = ""; | 365 | $options = ""; |
342 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
343 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
345 | 368 | 368 | ||
346 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
347 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
349 | 371 | 371 | ||
350 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
351 | 373 | { | 373 | { |
352 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
354 | 375 | 375 | ||
355 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
356 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
357 | 378 | return $this->response; | 378 | return $this->response; |
358 | 379 | } | 379 | } |
360 | 380 | 380 | ||
361 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
362 | 382 | { | 382 | { |
363 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
365 | 384 | 384 | ||
366 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
367 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
368 | 387 | return $this->response; | 387 | return $this->response; |
369 | 388 | } | 388 | } |
371 | 389 | 389 | ||
372 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
373 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
374 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
375 | @@ -397,18 +397,18 @@ | |||
376 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
377 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
378 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
380 | 400 | 400 | ||
381 | 401 | // derive the ext | 401 | // derive the ext |
382 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
384 | 403 | 403 | ||
385 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
386 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
388 | 406 | 406 | ||
389 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
390 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
391 | 409 | { | 409 | { |
392 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
394 | 411 | 411 | ||
395 | 412 | //Is this media retired? | 412 | //Is this media retired? |
396 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
397 | 414 | { | 414 | { |
398 | @@ -418,7 +418,7 @@ | |||
399 | 418 | { | 418 | { |
400 | 419 | $revised = false; | 419 | $revised = false; |
401 | 420 | } | 420 | } |
403 | 421 | 421 | ||
404 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
405 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
406 | 424 | { | 424 | { |
407 | @@ -429,8 +429,8 @@ | |||
408 | 429 | { | 429 | { |
409 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
410 | 431 | } | 431 | } |
413 | 432 | 432 | ||
414 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
415 | 434 | { | 434 | { |
416 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
417 | 436 | 436 | ||
418 | @@ -457,9 +457,9 @@ | |||
419 | 457 | return $this->response; | 457 | return $this->response; |
420 | 458 | } | 458 | } |
421 | 459 | } | 459 | } |
423 | 460 | 460 | ||
424 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
426 | 462 | 462 | ||
427 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
428 | 464 | 464 | ||
429 | 465 | //we can delete | 465 | //we can delete |
430 | @@ -474,19 +474,19 @@ | |||
431 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
432 | 475 | </form> | 475 | </form> |
433 | 476 | END; | 476 | END; |
435 | 477 | 477 | ||
436 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
437 | 479 | $this->response->dialogTitle = 'Delete Flash'; | 479 | $this->response->dialogTitle = 'Delete Flash'; |
438 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
439 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
440 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
441 | 483 | 483 | ||
443 | 484 | return $this->response; | 484 | return $this->response; |
444 | 485 | } | 485 | } |
446 | 486 | 486 | ||
447 | 487 | /** | 487 | /** |
448 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
450 | 489 | * @return | 489 | * @return |
451 | 490 | */ | 490 | */ |
452 | 491 | public function AddMedia() | 491 | public function AddMedia() |
453 | 492 | { | 492 | { |
454 | @@ -495,29 +495,29 @@ | |||
455 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
456 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
457 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
459 | 498 | 498 | ||
460 | 499 | // File data | 499 | // File data |
461 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
463 | 501 | 501 | ||
464 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
465 | 503 | { | 503 | { |
466 | 504 | $this->response->SetError('Cannot save Flash details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Flash details. <br/> You must have picked a file.'); |
467 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
468 | 506 | return $this->response; | 506 | return $this->response; |
469 | 507 | } | 507 | } |
471 | 508 | 508 | ||
472 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
473 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
474 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
475 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
477 | 513 | 513 | ||
478 | 514 | // Other properties | 514 | // Other properties |
479 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
480 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
481 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
483 | 518 | 518 | ||
484 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
486 | 520 | 520 | ||
487 | 521 | // Validation | 521 | // Validation |
488 | 522 | if ($ext != "swf") | 522 | if ($ext != "swf") |
489 | 523 | { | 523 | { |
490 | @@ -525,32 +525,32 @@ | |||
491 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
492 | 526 | return $this->response; | 526 | return $this->response; |
493 | 527 | } | 527 | } |
495 | 528 | 528 | ||
496 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
498 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
499 | 531 | { | 531 | { |
500 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
501 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
502 | 534 | return $this->response; | 534 | return $this->response; |
503 | 535 | } | 535 | } |
505 | 536 | 536 | ||
506 | 537 | if ($duration == 0) | 537 | if ($duration == 0) |
507 | 538 | { | 538 | { |
508 | 539 | $this->response->SetError('You must enter a duration.'); | 539 | $this->response->SetError('You must enter a duration.'); |
509 | 540 | $this->response->keepOpen = true; | 540 | $this->response->keepOpen = true; |
510 | 541 | return $this->response; | 541 | return $this->response; |
511 | 542 | } | 542 | } |
513 | 543 | 543 | ||
514 | 544 | // Ensure the name is not already in the database | 544 | // Ensure the name is not already in the database |
515 | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
516 | 546 | 546 | ||
518 | 547 | if(!$result = $db->query($SQL)) | 547 | if(!$result = $db->query($SQL)) |
519 | 548 | { | 548 | { |
520 | 549 | trigger_error($db->error()); | 549 | trigger_error($db->error()); |
521 | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
522 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
523 | 552 | return $this->response; | 552 | return $this->response; |
525 | 553 | } | 553 | } |
526 | 554 | 554 | ||
527 | 555 | if ($db->num_rows($result) != 0) | 555 | if ($db->num_rows($result) != 0) |
528 | 556 | { | 556 | { |
529 | @@ -558,11 +558,11 @@ | |||
530 | 558 | $this->response->keepOpen = true; | 558 | $this->response->keepOpen = true; |
531 | 559 | return $this->response; | 559 | return $this->response; |
532 | 560 | } | 560 | } |
534 | 561 | 561 | ||
535 | 562 | // All OK to insert this record | 562 | // All OK to insert this record |
536 | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
537 | 564 | $SQL .= "VALUES ('%s', 'flash', '%s', '%s', %d, %d, 0) "; | 564 | $SQL .= "VALUES ('%s', 'flash', '%s', '%s', %d, %d, 0) "; |
539 | 565 | 565 | ||
540 | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
541 | 567 | 567 | ||
542 | 568 | if (!$mediaid = $db->insert_query($SQL)) | 568 | if (!$mediaid = $db->insert_query($SQL)) |
543 | @@ -572,19 +572,19 @@ | |||
544 | 572 | $this->response->keepOpen = true; | 572 | $this->response->keepOpen = true; |
545 | 573 | return $this->response; | 573 | return $this->response; |
546 | 574 | } | 574 | } |
548 | 575 | 575 | ||
549 | 576 | // File upload directory.. get this from the settings object | 576 | // File upload directory.. get this from the settings object |
550 | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
552 | 578 | 578 | ||
553 | 579 | // What are we going to store this media as... | 579 | // What are we going to store this media as... |
554 | 580 | $storedAs = $mediaid.".".$ext; | 580 | $storedAs = $mediaid.".".$ext; |
556 | 581 | 581 | ||
557 | 582 | // Now we need to move the file | 582 | // Now we need to move the file |
558 | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
559 | 584 | { | 584 | { |
560 | 585 | // If we couldnt move it - we need to delete the media record we just added | 585 | // If we couldnt move it - we need to delete the media record we just added |
561 | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
563 | 587 | 587 | ||
564 | 588 | if (!$db->query($SQL)) | 588 | if (!$db->query($SQL)) |
565 | 589 | { | 589 | { |
566 | 590 | trigger_error($db->error()); | 590 | trigger_error($db->error()); |
567 | @@ -593,23 +593,27 @@ | |||
568 | 593 | return $this->response; | 593 | return $this->response; |
569 | 594 | } | 594 | } |
570 | 595 | } | 595 | } |
572 | 596 | 596 | ||
573 | 597 | // Calculate the MD5 and the file size | ||
574 | 598 | $md5 = md5_file($databaseDir.$storedAs); | ||
575 | 599 | $fileSize = filesize($databaseDir.$storedAs); | ||
576 | 600 | |||
577 | 597 | // Update the media record to include this information | 601 | // Update the media record to include this information |
580 | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 602 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $mediaid); |
581 | 599 | 603 | ||
582 | 600 | if (!$db->query($SQL)) | 604 | if (!$db->query($SQL)) |
583 | 601 | { | 605 | { |
584 | 602 | trigger_error($db->error()); | 606 | trigger_error($db->error()); |
585 | 603 | return true; | 607 | return true; |
586 | 604 | } | 608 | } |
588 | 605 | 609 | ||
589 | 606 | // Required Attributes | 610 | // Required Attributes |
590 | 607 | $this->mediaid = $mediaid; | 611 | $this->mediaid = $mediaid; |
591 | 608 | $this->duration = $duration; | 612 | $this->duration = $duration; |
593 | 609 | 613 | ||
594 | 610 | // Any Options | 614 | // Any Options |
595 | 611 | $this->SetOption('uri', $storedAs); | 615 | $this->SetOption('uri', $storedAs); |
597 | 612 | 616 | ||
598 | 613 | // Should have built the media object entirely by this time | 617 | // Should have built the media object entirely by this time |
599 | 614 | if ($regionid != '') | 618 | if ($regionid != '') |
600 | 615 | { | 619 | { |
601 | @@ -619,18 +623,18 @@ | |||
602 | 619 | } | 623 | } |
603 | 620 | else | 624 | else |
604 | 621 | { | 625 | { |
606 | 622 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 626 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
607 | 623 | } | 627 | } |
609 | 624 | 628 | ||
610 | 625 | // We want to load a new form | 629 | // We want to load a new form |
611 | 626 | $this->response->loadForm = true; | 630 | $this->response->loadForm = true; |
613 | 627 | 631 | ||
614 | 628 | return $this->response; | 632 | return $this->response; |
615 | 629 | } | 633 | } |
617 | 630 | 634 | ||
618 | 631 | /** | 635 | /** |
619 | 632 | * Edit Media in the Database | 636 | * Edit Media in the Database |
621 | 633 | * @return | 637 | * @return |
622 | 634 | */ | 638 | */ |
623 | 635 | public function EditMedia() | 639 | public function EditMedia() |
624 | 636 | { | 640 | { |
625 | @@ -639,13 +643,13 @@ | |||
626 | 639 | $regionid = $this->regionid; | 643 | $regionid = $this->regionid; |
627 | 640 | $mediaid = $this->mediaid; | 644 | $mediaid = $this->mediaid; |
628 | 641 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 645 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
630 | 642 | 646 | ||
631 | 643 | // Stored As from the XML | 647 | // Stored As from the XML |
632 | 644 | $storedAs = $this->GetOption('uri'); | 648 | $storedAs = $this->GetOption('uri'); |
634 | 645 | 649 | ||
635 | 646 | // File data | 650 | // File data |
636 | 647 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 651 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
638 | 648 | 652 | ||
639 | 649 | if ($tmpName == '') | 653 | if ($tmpName == '') |
640 | 650 | { | 654 | { |
641 | 651 | $fileRevision = false; | 655 | $fileRevision = false; |
642 | @@ -653,12 +657,12 @@ | |||
643 | 653 | else | 657 | else |
644 | 654 | { | 658 | { |
645 | 655 | $fileRevision = true; | 659 | $fileRevision = true; |
647 | 656 | 660 | ||
648 | 657 | // File name and extension (orignial name) | 661 | // File name and extension (orignial name) |
649 | 658 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 662 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
650 | 659 | $fileName = basename($fileName); | 663 | $fileName = basename($fileName); |
651 | 660 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 664 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
653 | 661 | 665 | ||
654 | 662 | if ($ext != "swf") | 666 | if ($ext != "swf") |
655 | 663 | { | 667 | { |
656 | 664 | $this->response->SetError('Only SWF files are accepted - Are you sure this is an flash?'); | 668 | $this->response->SetError('Only SWF files are accepted - Are you sure this is an flash?'); |
657 | @@ -666,17 +670,17 @@ | |||
658 | 666 | return $this->response; | 670 | return $this->response; |
659 | 667 | } | 671 | } |
660 | 668 | } | 672 | } |
662 | 669 | 673 | ||
663 | 670 | // Other properties | 674 | // Other properties |
664 | 671 | $name = Kit::GetParam('name', _POST, _STRING); | 675 | $name = Kit::GetParam('name', _POST, _STRING); |
665 | 672 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 676 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
666 | 673 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 677 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
668 | 674 | 678 | ||
669 | 675 | if ($name == '') | 679 | if ($name == '') |
670 | 676 | { | 680 | { |
671 | 677 | if ($fileRevision) | 681 | if ($fileRevision) |
672 | 678 | { | 682 | { |
674 | 679 | $name = Kit::ValidateParam($fileName, _FILENAME); | 683 | $name = Kit::ValidateParam($fileName, _FILENAME); |
675 | 680 | } | 684 | } |
676 | 681 | else | 685 | else |
677 | 682 | { | 686 | { |
678 | @@ -684,33 +688,33 @@ | |||
679 | 684 | $this->response->keepOpen = true; | 688 | $this->response->keepOpen = true; |
680 | 685 | return $this->response; | 689 | return $this->response; |
681 | 686 | } | 690 | } |
684 | 687 | } | 691 | } |
685 | 688 | 692 | ||
686 | 689 | // Make sure the name isnt too long | 693 | // Make sure the name isnt too long |
688 | 690 | if (strlen($name) > 100) | 694 | if (strlen($name) > 100) |
689 | 691 | { | 695 | { |
690 | 692 | $this->response->SetError('The name cannot be longer than 100 characters'); | 696 | $this->response->SetError('The name cannot be longer than 100 characters'); |
691 | 693 | $this->response->keepOpen = true; | 697 | $this->response->keepOpen = true; |
692 | 694 | return $this->response; | 698 | return $this->response; |
693 | 695 | } | 699 | } |
695 | 696 | 700 | ||
696 | 697 | if ($duration == 0) | 701 | if ($duration == 0) |
697 | 698 | { | 702 | { |
698 | 699 | $this->response->SetError('You must enter a duration.'); | 703 | $this->response->SetError('You must enter a duration.'); |
699 | 700 | $this->response->keepOpen = true; | 704 | $this->response->keepOpen = true; |
700 | 701 | return $this->response; | 705 | return $this->response; |
701 | 702 | } | 706 | } |
703 | 703 | 707 | ||
704 | 704 | // Ensure the name is not already in the database | 708 | // Ensure the name is not already in the database |
705 | 705 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 709 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
706 | 706 | 710 | ||
708 | 707 | if(!$result = $db->query($SQL)) | 711 | if(!$result = $db->query($SQL)) |
709 | 708 | { | 712 | { |
710 | 709 | trigger_error($db->error()); | 713 | trigger_error($db->error()); |
711 | 710 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 714 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
712 | 711 | $this->response->keepOpen = true; | 715 | $this->response->keepOpen = true; |
713 | 712 | return $this->response; | 716 | return $this->response; |
715 | 713 | } | 717 | } |
716 | 714 | 718 | ||
717 | 715 | if ($db->num_rows($result) != 0) | 719 | if ($db->num_rows($result) != 0) |
718 | 716 | { | 720 | { |
719 | @@ -718,34 +722,34 @@ | |||
720 | 718 | $this->response->keepOpen = true; | 722 | $this->response->keepOpen = true; |
721 | 719 | return $this->response; | 723 | return $this->response; |
722 | 720 | } | 724 | } |
724 | 721 | 725 | ||
725 | 722 | //Are we revising this media - or just plain editing | 726 | //Are we revising this media - or just plain editing |
726 | 723 | if ($fileRevision) | 727 | if ($fileRevision) |
727 | 724 | { | 728 | { |
728 | 725 | // All OK to insert this record | 729 | // All OK to insert this record |
729 | 726 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 730 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
730 | 727 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; | 731 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; |
732 | 728 | 732 | ||
733 | 729 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 733 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
735 | 730 | 734 | ||
736 | 731 | if (!$new_mediaid = $db->insert_query($SQL)) | 735 | if (!$new_mediaid = $db->insert_query($SQL)) |
737 | 732 | { | 736 | { |
738 | 733 | trigger_error($db->error()); | 737 | trigger_error($db->error()); |
739 | 734 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 738 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
740 | 735 | } | 739 | } |
742 | 736 | 740 | ||
743 | 737 | //What are we going to store this media as... | 741 | //What are we going to store this media as... |
744 | 738 | $storedAs = $new_mediaid.".".$ext; | 742 | $storedAs = $new_mediaid.".".$ext; |
746 | 739 | 743 | ||
747 | 740 | // File upload directory.. get this from the settings object | 744 | // File upload directory.. get this from the settings object |
748 | 741 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 745 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
750 | 742 | 746 | ||
751 | 743 | //Now we need to move the file | 747 | //Now we need to move the file |
752 | 744 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 748 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
753 | 745 | { | 749 | { |
754 | 746 | //If we couldnt move it - we need to delete the media record we just added | 750 | //If we couldnt move it - we need to delete the media record we just added |
755 | 747 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 751 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
757 | 748 | 752 | ||
758 | 749 | if (!$db->insert_query($SQL)) | 753 | if (!$db->insert_query($SQL)) |
759 | 750 | { | 754 | { |
760 | 751 | $this->response->SetError('Error rolling back transcation.'); | 755 | $this->response->SetError('Error rolling back transcation.'); |
761 | @@ -753,9 +757,14 @@ | |||
762 | 753 | return $this->response; | 757 | return $this->response; |
763 | 754 | } | 758 | } |
764 | 755 | } | 759 | } |
768 | 756 | 760 | ||
769 | 757 | //Update the media record to include this information | 761 | // Calculate the MD5 and the file size |
770 | 758 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 762 | $md5 = md5_file($databaseDir.$storedAs); |
771 | 763 | $fileSize = filesize($databaseDir.$storedAs); | ||
772 | 764 | |||
773 | 765 | // Update the media record to include this information | ||
774 | 766 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $new_mediaid); | ||
775 | 767 | |||
776 | 759 | if (!$db->query($SQL)) | 768 | if (!$db->query($SQL)) |
777 | 760 | { | 769 | { |
778 | 761 | trigger_error($db->error()); | 770 | trigger_error($db->error()); |
779 | @@ -763,13 +772,13 @@ | |||
780 | 763 | $this->response->keepOpen = true; | 772 | $this->response->keepOpen = true; |
781 | 764 | return $this->response; | 773 | return $this->response; |
782 | 765 | } | 774 | } |
784 | 766 | 775 | ||
785 | 767 | // Update the existing record with the new record's id | 776 | // Update the existing record with the new record's id |
786 | 768 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 777 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
787 | 769 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 778 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
789 | 770 | 779 | ||
790 | 771 | Debug::LogEntry($db, 'audit', $SQL); | 780 | Debug::LogEntry($db, 'audit', $SQL); |
792 | 772 | 781 | ||
793 | 773 | if (!$db->query($SQL)) | 782 | if (!$db->query($SQL)) |
794 | 774 | { | 783 | { |
795 | 775 | trigger_error($db->error()); | 784 | trigger_error($db->error()); |
796 | @@ -783,54 +792,54 @@ | |||
797 | 783 | { | 792 | { |
798 | 784 | // Editing the existing record | 793 | // Editing the existing record |
799 | 785 | $new_mediaid = $mediaid; | 794 | $new_mediaid = $mediaid; |
801 | 786 | 795 | ||
802 | 787 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 796 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
803 | 788 | $SQL .= " WHERE mediaID = %d "; | 797 | $SQL .= " WHERE mediaID = %d "; |
804 | 789 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 798 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
806 | 790 | 799 | ||
807 | 791 | Debug::LogEntry($db, 'audit', $SQL); | 800 | Debug::LogEntry($db, 'audit', $SQL); |
809 | 792 | 801 | ||
810 | 793 | if (!$db->query($SQL)) | 802 | if (!$db->query($SQL)) |
811 | 794 | { | 803 | { |
812 | 795 | trigger_error($db->error()); | 804 | trigger_error($db->error()); |
814 | 796 | 805 | ||
815 | 797 | $this->response->SetError('Database error editing this media record.'); | 806 | $this->response->SetError('Database error editing this media record.'); |
816 | 798 | $this->response->keepOpen = true; | 807 | $this->response->keepOpen = true; |
817 | 799 | return $this->response; | 808 | return $this->response; |
818 | 800 | } | 809 | } |
819 | 801 | } | 810 | } |
821 | 802 | 811 | ||
822 | 803 | // Required Attributes | 812 | // Required Attributes |
823 | 804 | $this->mediaid = $new_mediaid; | 813 | $this->mediaid = $new_mediaid; |
824 | 805 | $this->duration = $duration; | 814 | $this->duration = $duration; |
826 | 806 | 815 | ||
827 | 807 | // Any Options | 816 | // Any Options |
828 | 808 | $this->SetOption('uri', $storedAs); | 817 | $this->SetOption('uri', $storedAs); |
830 | 809 | 818 | ||
831 | 810 | // Should have built the media object entirely by this time | 819 | // Should have built the media object entirely by this time |
832 | 811 | if ($regionid != '') | 820 | if ($regionid != '') |
833 | 812 | { | 821 | { |
834 | 813 | // This saves the Media Object to the Region | 822 | // This saves the Media Object to the Region |
835 | 814 | $this->UpdateRegion(); | 823 | $this->UpdateRegion(); |
837 | 815 | 824 | ||
838 | 816 | $this->response->loadForm = true; | 825 | $this->response->loadForm = true; |
839 | 817 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 826 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
840 | 818 | } | 827 | } |
841 | 819 | else | 828 | else |
842 | 820 | { | 829 | { |
844 | 821 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 830 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
845 | 822 | $this->response->message = 'Edited the Flash.'; | 831 | $this->response->message = 'Edited the Flash.'; |
847 | 823 | 832 | ||
848 | 824 | } | 833 | } |
850 | 825 | 834 | ||
851 | 826 | return $this->response; | 835 | return $this->response; |
852 | 827 | } | 836 | } |
854 | 828 | 837 | ||
855 | 829 | /** | 838 | /** |
856 | 830 | * Delete Media from the Database | 839 | * Delete Media from the Database |
858 | 831 | * @return | 840 | * @return |
859 | 832 | */ | 841 | */ |
861 | 833 | public function DeleteMedia() | 842 | public function DeleteMedia() |
862 | 834 | { | 843 | { |
863 | 835 | $db =& $this->db; | 844 | $db =& $this->db; |
864 | 836 | $layoutid = $this->layoutid; | 845 | $layoutid = $this->layoutid; |
865 | @@ -838,10 +847,10 @@ | |||
866 | 838 | $mediaid = $this->mediaid; | 847 | $mediaid = $this->mediaid; |
867 | 839 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 848 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
868 | 840 | $options = Kit::GetParam('options', _POST, _WORD); | 849 | $options = Kit::GetParam('options', _POST, _WORD); |
870 | 841 | 850 | ||
871 | 842 | // Stored As from the XML | 851 | // Stored As from the XML |
872 | 843 | $this->uri = $this->GetOption('uri'); | 852 | $this->uri = $this->GetOption('uri'); |
874 | 844 | 853 | ||
875 | 845 | // Do we need to remove this from a layout? | 854 | // Do we need to remove this from a layout? |
876 | 846 | if ($layoutid != '') | 855 | if ($layoutid != '') |
877 | 847 | { | 856 | { |
878 | @@ -853,72 +862,72 @@ | |||
879 | 853 | // Set this message now in preparation | 862 | // Set this message now in preparation |
880 | 854 | $this->response->message = 'Deleted the Media.'; | 863 | $this->response->message = 'Deleted the Media.'; |
881 | 855 | } | 864 | } |
883 | 856 | 865 | ||
884 | 857 | // If we are set to retire we retire | 866 | // If we are set to retire we retire |
885 | 858 | if ($options == "retire") | 867 | if ($options == "retire") |
886 | 859 | { | 868 | { |
887 | 860 | //Update the media record to say it is retired | 869 | //Update the media record to say it is retired |
888 | 861 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 870 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
890 | 862 | 871 | ||
891 | 863 | if (!$db->query($SQL)) | 872 | if (!$db->query($SQL)) |
892 | 864 | { | 873 | { |
893 | 865 | trigger_error($db->error()); | 874 | trigger_error($db->error()); |
895 | 866 | 875 | ||
896 | 867 | $this->response->SetError('Database error retiring this media record.'); | 876 | $this->response->SetError('Database error retiring this media record.'); |
897 | 868 | $this->response->keepOpen = true; | 877 | $this->response->keepOpen = true; |
898 | 869 | return $this->response; | 878 | return $this->response; |
899 | 870 | } | 879 | } |
900 | 871 | } | 880 | } |
902 | 872 | 881 | ||
903 | 873 | //If we are set to delete, we delete | 882 | //If we are set to delete, we delete |
904 | 874 | if ($options == "delete") | 883 | if ($options == "delete") |
905 | 875 | { | 884 | { |
906 | 876 | //Update the media record to say it is retired | 885 | //Update the media record to say it is retired |
907 | 877 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 886 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
909 | 878 | 887 | ||
910 | 879 | if (!$db->query($SQL)) | 888 | if (!$db->query($SQL)) |
911 | 880 | { | 889 | { |
912 | 881 | trigger_error($db->error()); | 890 | trigger_error($db->error()); |
914 | 882 | 891 | ||
915 | 883 | $this->response->SetError('Database error deleting this media record.'); | 892 | $this->response->SetError('Database error deleting this media record.'); |
916 | 884 | $this->response->keepOpen = true; | 893 | $this->response->keepOpen = true; |
917 | 885 | return $this->response; | 894 | return $this->response; |
918 | 886 | } | 895 | } |
920 | 887 | 896 | ||
921 | 888 | $this->DeleteMediaFiles(); | 897 | $this->DeleteMediaFiles(); |
922 | 889 | } | 898 | } |
923 | 890 | 899 | ||
924 | 891 | return $this->response; | 900 | return $this->response; |
925 | 892 | } | 901 | } |
927 | 893 | 902 | ||
928 | 894 | /** | 903 | /** |
929 | 895 | * Deletes the media files associated with this record | 904 | * Deletes the media files associated with this record |
931 | 896 | * @return | 905 | * @return |
932 | 897 | */ | 906 | */ |
933 | 898 | private function DeleteMediaFiles() | 907 | private function DeleteMediaFiles() |
934 | 899 | { | 908 | { |
935 | 900 | $db =& $this->db; | 909 | $db =& $this->db; |
937 | 901 | 910 | ||
938 | 902 | //Library location | 911 | //Library location |
939 | 903 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 912 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
941 | 904 | 913 | ||
942 | 905 | //3 things to check for.. | 914 | //3 things to check for.. |
943 | 906 | //the actual file, the thumbnail, the background | 915 | //the actual file, the thumbnail, the background |
944 | 907 | if (file_exists($databaseDir.$this->uri)) | 916 | if (file_exists($databaseDir.$this->uri)) |
945 | 908 | { | 917 | { |
946 | 909 | unlink($databaseDir.$this->uri); | 918 | unlink($databaseDir.$this->uri); |
947 | 910 | } | 919 | } |
949 | 911 | 920 | ||
950 | 912 | if (file_exists($databaseDir."tn_".$this->uri)) | 921 | if (file_exists($databaseDir."tn_".$this->uri)) |
951 | 913 | { | 922 | { |
952 | 914 | unlink($databaseDir."tn_".$this->uri); | 923 | unlink($databaseDir."tn_".$this->uri); |
953 | 915 | } | 924 | } |
955 | 916 | 925 | ||
956 | 917 | if (file_exists($databaseDir."bg_".$this->uri)) | 926 | if (file_exists($databaseDir."bg_".$this->uri)) |
957 | 918 | { | 927 | { |
958 | 919 | unlink($databaseDir."bg_".$this->uri); | 928 | unlink($databaseDir."bg_".$this->uri); |
959 | 920 | } | 929 | } |
961 | 921 | 930 | ||
962 | 922 | return true; | 931 | return true; |
963 | 923 | } | 932 | } |
964 | 924 | } | 933 | } |
965 | 925 | 934 | ||
966 | === modified file 'server/modules/image.module.php' | |||
967 | --- server/modules/image.module.php 2009-06-28 10:47:06 +0000 | |||
968 | +++ server/modules/image.module.php 2009-09-29 22:15:22 +0000 | |||
969 | @@ -8,7 +8,7 @@ | |||
970 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
971 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
972 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
974 | 11 | * any later version. | 11 | * any later version. |
975 | 12 | * | 12 | * |
976 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
977 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
978 | @@ -17,31 +17,31 @@ | |||
979 | 17 | * | 17 | * |
980 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
981 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
983 | 20 | */ | 20 | */ |
984 | 21 | class image extends Module | 21 | class image extends Module |
985 | 22 | { | 22 | { |
986 | 23 | // Custom Media information | 23 | // Custom Media information |
987 | 24 | private $uri; | 24 | private $uri; |
988 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
989 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
991 | 27 | 27 | ||
992 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
993 | 29 | { | 29 | { |
994 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
995 | 31 | $this->type = 'image'; | 31 | $this->type = 'image'; |
997 | 32 | 32 | ||
998 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
999 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
1000 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
1003 | 36 | 36 | ||
1004 | 37 | // Must call the parent class | 37 | // Must call the parent class |
1005 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
1006 | 39 | } | 39 | } |
1008 | 40 | 40 | ||
1009 | 41 | /** | 41 | /** |
1010 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
1011 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
1013 | 44 | * @return | 44 | * @return |
1014 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
1015 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
1016 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
1017 | @@ -53,75 +53,75 @@ | |||
1018 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
1019 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
1020 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
1022 | 56 | 56 | ||
1023 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
1025 | 58 | 58 | ||
1026 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
1027 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1029 | 61 | 61 | ||
1030 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
1031 | 63 | { | 63 | { |
1032 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
1033 | 65 | return false; | 65 | return false; |
1034 | 66 | } | 66 | } |
1036 | 67 | 67 | ||
1037 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
1038 | 69 | { | 69 | { |
1039 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1040 | 71 | return false; | 71 | return false; |
1041 | 72 | } | 72 | } |
1043 | 73 | 73 | ||
1044 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
1045 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
1046 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
1048 | 77 | 77 | ||
1049 | 78 | // Required Attributes | 78 | // Required Attributes |
1050 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
1052 | 80 | 80 | ||
1053 | 81 | // Any Options | 81 | // Any Options |
1054 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
1056 | 83 | 83 | ||
1057 | 84 | return true; | 84 | return true; |
1058 | 85 | } | 85 | } |
1060 | 86 | 86 | ||
1061 | 87 | /** | 87 | /** |
1062 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
1064 | 89 | * @return | 89 | * @return |
1065 | 90 | */ | 90 | */ |
1066 | 91 | public function AddForm() | 91 | public function AddForm() |
1067 | 92 | { | 92 | { |
1068 | 93 | global $session; | 93 | global $session; |
1069 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
1070 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
1073 | 96 | 96 | ||
1074 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
1075 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
1076 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
1078 | 100 | 100 | ||
1079 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
1080 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
1081 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
1083 | 104 | 104 | ||
1084 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
1086 | 106 | 106 | ||
1087 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
1088 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
1089 | 109 | 109 | ||
1090 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
1091 | 111 | 111 | ||
1093 | 112 | if($default=="private") | 112 | if($default=="private") |
1094 | 113 | { | 113 | { |
1095 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
1096 | 115 | } | 115 | } |
1098 | 116 | 116 | ||
1099 | 117 | //shared list | 117 | //shared list |
1100 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
1102 | 119 | 119 | ||
1103 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
1104 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
1105 | 122 | { | 122 | { |
1106 | 123 | setSession('content','mediatype','image'); | 123 | setSession('content','mediatype','image'); |
1108 | 124 | 124 | ||
1109 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
1110 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
1111 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
1112 | @@ -135,7 +135,7 @@ | |||
1113 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
1114 | 136 | END; | 136 | END; |
1115 | 137 | } | 137 | } |
1117 | 138 | 138 | ||
1118 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
1119 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
1120 | 141 | <div> | 141 | <div> |
1121 | @@ -144,7 +144,7 @@ | |||
1122 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
1123 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
1124 | 146 | <table> | 146 | <table> |
1126 | 147 | <tr> | 147 | <tr> |
1127 | 148 | <td><label for="file">Image File<span class="required">*</span></label></td> | 148 | <td><label for="file">Image File<span class="required">*</span></label></td> |
1128 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
1129 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
1130 | @@ -172,7 +172,7 @@ | |||
1131 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
1132 | 173 | <td> | 173 | <td> |
1133 | 174 | $shared_list | 174 | $shared_list |
1135 | 175 | </td> | 175 | </td> |
1136 | 176 | </tr> | 176 | </tr> |
1137 | 177 | <tr> | 177 | <tr> |
1138 | 178 | <td></td> | 178 | <td></td> |
1139 | @@ -194,49 +194,49 @@ | |||
1140 | 194 | 194 | ||
1141 | 195 | return $this->response; | 195 | return $this->response; |
1142 | 196 | } | 196 | } |
1144 | 197 | 197 | ||
1145 | 198 | /** | 198 | /** |
1146 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
1148 | 200 | * @return | 200 | * @return |
1149 | 201 | */ | 201 | */ |
1150 | 202 | public function EditForm() | 202 | public function EditForm() |
1151 | 203 | { | 203 | { |
1152 | 204 | global $session; | 204 | global $session; |
1153 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
1154 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
1157 | 207 | 207 | ||
1158 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
1159 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
1160 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
1161 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
1162 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
1163 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1165 | 214 | 214 | ||
1166 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
1167 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
1168 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
1170 | 218 | 218 | ||
1171 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
1173 | 220 | 220 | ||
1174 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
1175 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1177 | 223 | 223 | ||
1178 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
1179 | 225 | { | 225 | { |
1180 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
1182 | 227 | 227 | ||
1183 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
1184 | 229 | return false; | 229 | return false; |
1185 | 230 | } | 230 | } |
1187 | 231 | 231 | ||
1188 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
1189 | 233 | { | 233 | { |
1190 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1192 | 235 | 235 | ||
1193 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
1194 | 237 | return false; | 237 | return false; |
1195 | 238 | } | 238 | } |
1197 | 239 | 239 | ||
1198 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
1199 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
1200 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
1201 | @@ -246,23 +246,23 @@ | |||
1202 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
1203 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
1204 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
1206 | 249 | 249 | ||
1207 | 250 | // derive the ext | 250 | // derive the ext |
1208 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
1210 | 252 | 252 | ||
1211 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
1212 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
1214 | 255 | 255 | ||
1215 | 256 | //shared list | 256 | //shared list |
1216 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
1218 | 258 | 258 | ||
1219 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
1220 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
1221 | 261 | { | 261 | { |
1222 | 262 | setSession('content','mediatype','image'); | 262 | setSession('content','mediatype','image'); |
1224 | 263 | 263 | ||
1225 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
1227 | 265 | 265 | ||
1228 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
1229 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
1230 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
1231 | @@ -272,13 +272,13 @@ | |||
1232 | 272 | else | 272 | else |
1233 | 273 | { | 273 | { |
1234 | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; |
1236 | 275 | 275 | ||
1237 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
1238 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
1239 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
1240 | 279 | END; | 279 | END; |
1241 | 280 | } | 280 | } |
1243 | 281 | 281 | ||
1244 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
1245 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
1246 | 284 | <div> | 284 | <div> |
1247 | @@ -287,7 +287,7 @@ | |||
1248 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
1249 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
1250 | 289 | <table> | 289 | <table> |
1252 | 290 | <tr> | 290 | <tr> |
1253 | 291 | <td><label for="file">New Image File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Image File<span class="required">*</span></label></td> |
1254 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
1255 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
1256 | @@ -319,7 +319,7 @@ | |||
1257 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
1258 | 320 | <td> | 320 | <td> |
1259 | 321 | $shared_list | 321 | $shared_list |
1261 | 322 | </td> | 322 | </td> |
1262 | 323 | </tr> | 323 | </tr> |
1263 | 324 | <tr> | 324 | <tr> |
1264 | 325 | <td></td> | 325 | <td></td> |
1265 | @@ -343,50 +343,50 @@ | |||
1266 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
1267 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
1268 | 345 | 345 | ||
1270 | 346 | return $this->response; | 346 | return $this->response; |
1271 | 347 | } | 347 | } |
1273 | 348 | 348 | ||
1274 | 349 | /** | 349 | /** |
1275 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
1277 | 351 | * @return | 351 | * @return |
1278 | 352 | */ | 352 | */ |
1279 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
1280 | 354 | { | 354 | { |
1281 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
1282 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
1285 | 357 | 357 | ||
1286 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
1287 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
1288 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
1289 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
1290 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
1291 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1293 | 364 | 364 | ||
1294 | 365 | $options = ""; | 365 | $options = ""; |
1295 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
1296 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
1298 | 368 | 368 | ||
1299 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
1300 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1302 | 371 | 371 | ||
1303 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
1304 | 373 | { | 373 | { |
1305 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
1307 | 375 | 375 | ||
1308 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
1309 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
1310 | 378 | return $this->response; | 378 | return $this->response; |
1311 | 379 | } | 379 | } |
1313 | 380 | 380 | ||
1314 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
1315 | 382 | { | 382 | { |
1316 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
1318 | 384 | 384 | ||
1319 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
1320 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
1321 | 387 | return $this->response; | 387 | return $this->response; |
1322 | 388 | } | 388 | } |
1324 | 389 | 389 | ||
1325 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
1326 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
1327 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
1328 | @@ -397,18 +397,18 @@ | |||
1329 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
1330 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
1331 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
1333 | 400 | 400 | ||
1334 | 401 | // derive the ext | 401 | // derive the ext |
1335 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
1337 | 403 | 403 | ||
1338 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
1339 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
1341 | 406 | 406 | ||
1342 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
1343 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
1344 | 409 | { | 409 | { |
1345 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
1347 | 411 | 411 | ||
1348 | 412 | //Is this media retired? | 412 | //Is this media retired? |
1349 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
1350 | 414 | { | 414 | { |
1351 | @@ -418,7 +418,7 @@ | |||
1352 | 418 | { | 418 | { |
1353 | 419 | $revised = false; | 419 | $revised = false; |
1354 | 420 | } | 420 | } |
1356 | 421 | 421 | ||
1357 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
1358 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
1359 | 424 | { | 424 | { |
1360 | @@ -429,8 +429,8 @@ | |||
1361 | 429 | { | 429 | { |
1362 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
1363 | 431 | } | 431 | } |
1366 | 432 | 432 | ||
1367 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
1368 | 434 | { | 434 | { |
1369 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
1370 | 436 | 436 | ||
1371 | @@ -457,9 +457,9 @@ | |||
1372 | 457 | return $this->response; | 457 | return $this->response; |
1373 | 458 | } | 458 | } |
1374 | 459 | } | 459 | } |
1376 | 460 | 460 | ||
1377 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
1379 | 462 | 462 | ||
1380 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
1381 | 464 | 464 | ||
1382 | 465 | //we can delete | 465 | //we can delete |
1383 | @@ -474,19 +474,19 @@ | |||
1384 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
1385 | 475 | </form> | 475 | </form> |
1386 | 476 | END; | 476 | END; |
1388 | 477 | 477 | ||
1389 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
1390 | 479 | $this->response->dialogTitle = 'Delete Image'; | 479 | $this->response->dialogTitle = 'Delete Image'; |
1391 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
1392 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
1393 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
1394 | 483 | 483 | ||
1396 | 484 | return $this->response; | 484 | return $this->response; |
1397 | 485 | } | 485 | } |
1399 | 486 | 486 | ||
1400 | 487 | /** | 487 | /** |
1401 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
1403 | 489 | * @return | 489 | * @return |
1404 | 490 | */ | 490 | */ |
1405 | 491 | public function AddMedia() | 491 | public function AddMedia() |
1406 | 492 | { | 492 | { |
1407 | @@ -495,29 +495,29 @@ | |||
1408 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
1409 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
1410 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1412 | 498 | 498 | ||
1413 | 499 | // File data | 499 | // File data |
1414 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
1416 | 501 | 501 | ||
1417 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
1418 | 503 | { | 503 | { |
1419 | 504 | $this->response->SetError('Cannot save Image details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Image details. <br/> You must have picked a file.'); |
1420 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
1421 | 506 | return $this->response; | 506 | return $this->response; |
1422 | 507 | } | 507 | } |
1424 | 508 | 508 | ||
1425 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
1426 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
1427 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
1428 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
1430 | 513 | 513 | ||
1431 | 514 | // Other properties | 514 | // Other properties |
1432 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
1433 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
1434 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
1436 | 518 | 518 | ||
1437 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
1439 | 520 | 520 | ||
1440 | 521 | // Validation | 521 | // Validation |
1441 | 522 | if ($ext != "jpeg" && $ext != "jpg" && $ext != "png" && $ext != "gif") | 522 | if ($ext != "jpeg" && $ext != "jpg" && $ext != "png" && $ext != "gif") |
1442 | 523 | { | 523 | { |
1443 | @@ -525,32 +525,32 @@ | |||
1444 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
1445 | 526 | return $this->response; | 526 | return $this->response; |
1446 | 527 | } | 527 | } |
1448 | 528 | 528 | ||
1449 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
1451 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
1452 | 531 | { | 531 | { |
1453 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
1454 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
1455 | 534 | return $this->response; | 534 | return $this->response; |
1456 | 535 | } | 535 | } |
1458 | 536 | 536 | ||
1459 | 537 | if ($duration == 0) | 537 | if ($duration == 0) |
1460 | 538 | { | 538 | { |
1461 | 539 | $this->response->SetError('You must enter a duration.'); | 539 | $this->response->SetError('You must enter a duration.'); |
1462 | 540 | $this->response->keepOpen = true; | 540 | $this->response->keepOpen = true; |
1463 | 541 | return $this->response; | 541 | return $this->response; |
1464 | 542 | } | 542 | } |
1466 | 543 | 543 | ||
1467 | 544 | // Ensure the name is not already in the database | 544 | // Ensure the name is not already in the database |
1468 | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
1469 | 546 | 546 | ||
1471 | 547 | if(!$result = $db->query($SQL)) | 547 | if(!$result = $db->query($SQL)) |
1472 | 548 | { | 548 | { |
1473 | 549 | trigger_error($db->error()); | 549 | trigger_error($db->error()); |
1474 | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
1475 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
1476 | 552 | return $this->response; | 552 | return $this->response; |
1478 | 553 | } | 553 | } |
1479 | 554 | 554 | ||
1480 | 555 | if ($db->num_rows($result) != 0) | 555 | if ($db->num_rows($result) != 0) |
1481 | 556 | { | 556 | { |
1482 | @@ -558,11 +558,11 @@ | |||
1483 | 558 | $this->response->keepOpen = true; | 558 | $this->response->keepOpen = true; |
1484 | 559 | return $this->response; | 559 | return $this->response; |
1485 | 560 | } | 560 | } |
1487 | 561 | 561 | ||
1488 | 562 | // All OK to insert this record | 562 | // All OK to insert this record |
1489 | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
1490 | 564 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; | 564 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; |
1492 | 565 | 565 | ||
1493 | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
1494 | 567 | 567 | ||
1495 | 568 | if (!$mediaid = $db->insert_query($SQL)) | 568 | if (!$mediaid = $db->insert_query($SQL)) |
1496 | @@ -572,19 +572,19 @@ | |||
1497 | 572 | $this->response->keepOpen = true; | 572 | $this->response->keepOpen = true; |
1498 | 573 | return $this->response; | 573 | return $this->response; |
1499 | 574 | } | 574 | } |
1501 | 575 | 575 | ||
1502 | 576 | // File upload directory.. get this from the settings object | 576 | // File upload directory.. get this from the settings object |
1503 | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
1505 | 578 | 578 | ||
1506 | 579 | // What are we going to store this media as... | 579 | // What are we going to store this media as... |
1507 | 580 | $storedAs = $mediaid.".".$ext; | 580 | $storedAs = $mediaid.".".$ext; |
1509 | 581 | 581 | ||
1510 | 582 | // Now we need to move the file | 582 | // Now we need to move the file |
1511 | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
1512 | 584 | { | 584 | { |
1513 | 585 | // If we couldnt move it - we need to delete the media record we just added | 585 | // If we couldnt move it - we need to delete the media record we just added |
1514 | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
1516 | 587 | 587 | ||
1517 | 588 | if (!$db->query($SQL)) | 588 | if (!$db->query($SQL)) |
1518 | 589 | { | 589 | { |
1519 | 590 | trigger_error($db->error()); | 590 | trigger_error($db->error()); |
1520 | @@ -593,26 +593,30 @@ | |||
1521 | 593 | return $this->response; | 593 | return $this->response; |
1522 | 594 | } | 594 | } |
1523 | 595 | } | 595 | } |
1525 | 596 | 596 | ||
1526 | 597 | // Calculate the MD5 and the file size | ||
1527 | 598 | $md5 = md5_file($databaseDir.$storedAs); | ||
1528 | 599 | $fileSize = filesize($databaseDir.$storedAs); | ||
1529 | 600 | |||
1530 | 597 | // Update the media record to include this information | 601 | // Update the media record to include this information |
1533 | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 602 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $mediaid); |
1534 | 599 | 603 | ||
1535 | 600 | if (!$db->query($SQL)) | 604 | if (!$db->query($SQL)) |
1536 | 601 | { | 605 | { |
1537 | 602 | trigger_error($db->error()); | 606 | trigger_error($db->error()); |
1538 | 603 | return true; | 607 | return true; |
1539 | 604 | } | 608 | } |
1541 | 605 | 609 | ||
1542 | 606 | // Create the thumb nail | 610 | // Create the thumb nail |
1543 | 607 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); | 611 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); |
1545 | 608 | 612 | ||
1546 | 609 | // Required Attributes | 613 | // Required Attributes |
1547 | 610 | $this->mediaid = $mediaid; | 614 | $this->mediaid = $mediaid; |
1548 | 611 | $this->duration = $duration; | 615 | $this->duration = $duration; |
1550 | 612 | 616 | ||
1551 | 613 | // Any Options | 617 | // Any Options |
1552 | 614 | $this->SetOption('uri', $storedAs); | 618 | $this->SetOption('uri', $storedAs); |
1554 | 615 | 619 | ||
1555 | 616 | // Should have built the media object entirely by this time | 620 | // Should have built the media object entirely by this time |
1556 | 617 | if ($regionid != '') | 621 | if ($regionid != '') |
1557 | 618 | { | 622 | { |
1558 | @@ -622,18 +626,18 @@ | |||
1559 | 622 | } | 626 | } |
1560 | 623 | else | 627 | else |
1561 | 624 | { | 628 | { |
1563 | 625 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 629 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
1564 | 626 | } | 630 | } |
1566 | 627 | 631 | ||
1567 | 628 | // We want to load a new form | 632 | // We want to load a new form |
1568 | 629 | $this->response->loadForm = true; | 633 | $this->response->loadForm = true; |
1570 | 630 | 634 | ||
1571 | 631 | return $this->response; | 635 | return $this->response; |
1572 | 632 | } | 636 | } |
1574 | 633 | 637 | ||
1575 | 634 | /** | 638 | /** |
1576 | 635 | * Edit Media in the Database | 639 | * Edit Media in the Database |
1578 | 636 | * @return | 640 | * @return |
1579 | 637 | */ | 641 | */ |
1580 | 638 | public function EditMedia() | 642 | public function EditMedia() |
1581 | 639 | { | 643 | { |
1582 | @@ -642,13 +646,13 @@ | |||
1583 | 642 | $regionid = $this->regionid; | 646 | $regionid = $this->regionid; |
1584 | 643 | $mediaid = $this->mediaid; | 647 | $mediaid = $this->mediaid; |
1585 | 644 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 648 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1587 | 645 | 649 | ||
1588 | 646 | // Stored As from the XML | 650 | // Stored As from the XML |
1589 | 647 | $storedAs = $this->GetOption('uri'); | 651 | $storedAs = $this->GetOption('uri'); |
1591 | 648 | 652 | ||
1592 | 649 | // File data | 653 | // File data |
1593 | 650 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 654 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
1595 | 651 | 655 | ||
1596 | 652 | if ($tmpName == '') | 656 | if ($tmpName == '') |
1597 | 653 | { | 657 | { |
1598 | 654 | $fileRevision = false; | 658 | $fileRevision = false; |
1599 | @@ -656,12 +660,12 @@ | |||
1600 | 656 | else | 660 | else |
1601 | 657 | { | 661 | { |
1602 | 658 | $fileRevision = true; | 662 | $fileRevision = true; |
1604 | 659 | 663 | ||
1605 | 660 | // File name and extension (orignial name) | 664 | // File name and extension (orignial name) |
1606 | 661 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 665 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
1607 | 662 | $fileName = basename($fileName); | 666 | $fileName = basename($fileName); |
1608 | 663 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 667 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
1610 | 664 | 668 | ||
1611 | 665 | if ($ext != "jpeg" && $ext != "jpg" && $ext != "png" && $ext != "gif") | 669 | if ($ext != "jpeg" && $ext != "jpg" && $ext != "png" && $ext != "gif") |
1612 | 666 | { | 670 | { |
1613 | 667 | $this->response->SetError('Only images are accepted - Are you sure this is an image?'); | 671 | $this->response->SetError('Only images are accepted - Are you sure this is an image?'); |
1614 | @@ -669,17 +673,17 @@ | |||
1615 | 669 | return $this->response; | 673 | return $this->response; |
1616 | 670 | } | 674 | } |
1617 | 671 | } | 675 | } |
1619 | 672 | 676 | ||
1620 | 673 | // Other properties | 677 | // Other properties |
1621 | 674 | $name = Kit::GetParam('name', _POST, _STRING); | 678 | $name = Kit::GetParam('name', _POST, _STRING); |
1622 | 675 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 679 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
1623 | 676 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 680 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
1625 | 677 | 681 | ||
1626 | 678 | if ($name == '') | 682 | if ($name == '') |
1627 | 679 | { | 683 | { |
1628 | 680 | if ($fileRevision) | 684 | if ($fileRevision) |
1629 | 681 | { | 685 | { |
1631 | 682 | $name = Kit::ValidateParam($fileName, _FILENAME); | 686 | $name = Kit::ValidateParam($fileName, _FILENAME); |
1632 | 683 | } | 687 | } |
1633 | 684 | else | 688 | else |
1634 | 685 | { | 689 | { |
1635 | @@ -687,33 +691,33 @@ | |||
1636 | 687 | $this->response->keepOpen = true; | 691 | $this->response->keepOpen = true; |
1637 | 688 | return $this->response; | 692 | return $this->response; |
1638 | 689 | } | 693 | } |
1641 | 690 | } | 694 | } |
1642 | 691 | 695 | ||
1643 | 692 | // Make sure the name isnt too long | 696 | // Make sure the name isnt too long |
1645 | 693 | if (strlen($name) > 100) | 697 | if (strlen($name) > 100) |
1646 | 694 | { | 698 | { |
1647 | 695 | $this->response->SetError('The name cannot be longer than 100 characters'); | 699 | $this->response->SetError('The name cannot be longer than 100 characters'); |
1648 | 696 | $this->response->keepOpen = true; | 700 | $this->response->keepOpen = true; |
1649 | 697 | return $this->response; | 701 | return $this->response; |
1650 | 698 | } | 702 | } |
1652 | 699 | 703 | ||
1653 | 700 | if ($duration == 0) | 704 | if ($duration == 0) |
1654 | 701 | { | 705 | { |
1655 | 702 | $this->response->SetError('You must enter a duration.'); | 706 | $this->response->SetError('You must enter a duration.'); |
1656 | 703 | $this->response->keepOpen = true; | 707 | $this->response->keepOpen = true; |
1657 | 704 | return $this->response; | 708 | return $this->response; |
1658 | 705 | } | 709 | } |
1660 | 706 | 710 | ||
1661 | 707 | // Ensure the name is not already in the database | 711 | // Ensure the name is not already in the database |
1662 | 708 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 712 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
1663 | 709 | 713 | ||
1665 | 710 | if(!$result = $db->query($SQL)) | 714 | if(!$result = $db->query($SQL)) |
1666 | 711 | { | 715 | { |
1667 | 712 | trigger_error($db->error()); | 716 | trigger_error($db->error()); |
1668 | 713 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 717 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
1669 | 714 | $this->response->keepOpen = true; | 718 | $this->response->keepOpen = true; |
1670 | 715 | return $this->response; | 719 | return $this->response; |
1672 | 716 | } | 720 | } |
1673 | 717 | 721 | ||
1674 | 718 | if ($db->num_rows($result) != 0) | 722 | if ($db->num_rows($result) != 0) |
1675 | 719 | { | 723 | { |
1676 | @@ -721,34 +725,34 @@ | |||
1677 | 721 | $this->response->keepOpen = true; | 725 | $this->response->keepOpen = true; |
1678 | 722 | return $this->response; | 726 | return $this->response; |
1679 | 723 | } | 727 | } |
1681 | 724 | 728 | ||
1682 | 725 | //Are we revising this media - or just plain editing | 729 | //Are we revising this media - or just plain editing |
1683 | 726 | if ($fileRevision) | 730 | if ($fileRevision) |
1684 | 727 | { | 731 | { |
1685 | 728 | // All OK to insert this record | 732 | // All OK to insert this record |
1686 | 729 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 733 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
1687 | 730 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; | 734 | $SQL .= "VALUES ('%s', 'image', '%s', '%s', %d, %d, 0) "; |
1689 | 731 | 735 | ||
1690 | 732 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 736 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
1692 | 733 | 737 | ||
1693 | 734 | if (!$new_mediaid = $db->insert_query($SQL)) | 738 | if (!$new_mediaid = $db->insert_query($SQL)) |
1694 | 735 | { | 739 | { |
1695 | 736 | trigger_error($db->error()); | 740 | trigger_error($db->error()); |
1696 | 737 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 741 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
1697 | 738 | } | 742 | } |
1699 | 739 | 743 | ||
1700 | 740 | //What are we going to store this media as... | 744 | //What are we going to store this media as... |
1701 | 741 | $storedAs = $new_mediaid.".".$ext; | 745 | $storedAs = $new_mediaid.".".$ext; |
1703 | 742 | 746 | ||
1704 | 743 | // File upload directory.. get this from the settings object | 747 | // File upload directory.. get this from the settings object |
1705 | 744 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 748 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
1707 | 745 | 749 | ||
1708 | 746 | //Now we need to move the file | 750 | //Now we need to move the file |
1709 | 747 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 751 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
1710 | 748 | { | 752 | { |
1711 | 749 | //If we couldnt move it - we need to delete the media record we just added | 753 | //If we couldnt move it - we need to delete the media record we just added |
1712 | 750 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 754 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
1714 | 751 | 755 | ||
1715 | 752 | if (!$db->insert_query($SQL)) | 756 | if (!$db->insert_query($SQL)) |
1716 | 753 | { | 757 | { |
1717 | 754 | $this->response->SetError('Error rolling back transcation.'); | 758 | $this->response->SetError('Error rolling back transcation.'); |
1718 | @@ -756,9 +760,14 @@ | |||
1719 | 756 | return $this->response; | 760 | return $this->response; |
1720 | 757 | } | 761 | } |
1721 | 758 | } | 762 | } |
1725 | 759 | 763 | ||
1726 | 760 | //Update the media record to include this information | 764 | // Calculate the MD5 and the file size |
1727 | 761 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 765 | $md5 = md5_file($databaseDir.$storedAs); |
1728 | 766 | $fileSize = filesize($databaseDir.$storedAs); | ||
1729 | 767 | |||
1730 | 768 | // Update the media record to include this information | ||
1731 | 769 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $new_mediaid); | ||
1732 | 770 | |||
1733 | 762 | if (!$db->query($SQL)) | 771 | if (!$db->query($SQL)) |
1734 | 763 | { | 772 | { |
1735 | 764 | trigger_error($db->error()); | 773 | trigger_error($db->error()); |
1736 | @@ -766,20 +775,20 @@ | |||
1737 | 766 | $this->response->keepOpen = true; | 775 | $this->response->keepOpen = true; |
1738 | 767 | return $this->response; | 776 | return $this->response; |
1739 | 768 | } | 777 | } |
1741 | 769 | 778 | ||
1742 | 770 | //Thumb | 779 | //Thumb |
1743 | 771 | if ($ext == "jpeg" || $ext == "jpg" || $ext == "png") | 780 | if ($ext == "jpeg" || $ext == "jpg" || $ext == "png") |
1744 | 772 | { | 781 | { |
1745 | 773 | //Create the thumbnail | 782 | //Create the thumbnail |
1746 | 774 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); | 783 | ResizeImage($databaseDir.$storedAs, $databaseDir."tn_".$storedAs, 80, 80); |
1747 | 775 | } | 784 | } |
1749 | 776 | 785 | ||
1750 | 777 | // Update the existing record with the new record's id | 786 | // Update the existing record with the new record's id |
1751 | 778 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 787 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
1752 | 779 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 788 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
1754 | 780 | 789 | ||
1755 | 781 | Debug::LogEntry($db, 'audit', $SQL); | 790 | Debug::LogEntry($db, 'audit', $SQL); |
1757 | 782 | 791 | ||
1758 | 783 | if (!$db->query($SQL)) | 792 | if (!$db->query($SQL)) |
1759 | 784 | { | 793 | { |
1760 | 785 | trigger_error($db->error()); | 794 | trigger_error($db->error()); |
1761 | @@ -793,54 +802,54 @@ | |||
1762 | 793 | { | 802 | { |
1763 | 794 | // Editing the existing record | 803 | // Editing the existing record |
1764 | 795 | $new_mediaid = $mediaid; | 804 | $new_mediaid = $mediaid; |
1766 | 796 | 805 | ||
1767 | 797 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 806 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
1768 | 798 | $SQL .= " WHERE mediaID = %d "; | 807 | $SQL .= " WHERE mediaID = %d "; |
1769 | 799 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 808 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
1771 | 800 | 809 | ||
1772 | 801 | Debug::LogEntry($db, 'audit', $SQL); | 810 | Debug::LogEntry($db, 'audit', $SQL); |
1774 | 802 | 811 | ||
1775 | 803 | if (!$db->query($SQL)) | 812 | if (!$db->query($SQL)) |
1776 | 804 | { | 813 | { |
1777 | 805 | trigger_error($db->error()); | 814 | trigger_error($db->error()); |
1779 | 806 | 815 | ||
1780 | 807 | $this->response->SetError('Database error editing this media record.'); | 816 | $this->response->SetError('Database error editing this media record.'); |
1781 | 808 | $this->response->keepOpen = true; | 817 | $this->response->keepOpen = true; |
1782 | 809 | return $this->response; | 818 | return $this->response; |
1783 | 810 | } | 819 | } |
1784 | 811 | } | 820 | } |
1786 | 812 | 821 | ||
1787 | 813 | // Required Attributes | 822 | // Required Attributes |
1788 | 814 | $this->mediaid = $new_mediaid; | 823 | $this->mediaid = $new_mediaid; |
1789 | 815 | $this->duration = $duration; | 824 | $this->duration = $duration; |
1791 | 816 | 825 | ||
1792 | 817 | // Any Options | 826 | // Any Options |
1793 | 818 | $this->SetOption('uri', $storedAs); | 827 | $this->SetOption('uri', $storedAs); |
1795 | 819 | 828 | ||
1796 | 820 | // Should have built the media object entirely by this time | 829 | // Should have built the media object entirely by this time |
1797 | 821 | if ($regionid != '') | 830 | if ($regionid != '') |
1798 | 822 | { | 831 | { |
1799 | 823 | // This saves the Media Object to the Region | 832 | // This saves the Media Object to the Region |
1800 | 824 | $this->UpdateRegion(); | 833 | $this->UpdateRegion(); |
1802 | 825 | 834 | ||
1803 | 826 | $this->response->loadForm = true; | 835 | $this->response->loadForm = true; |
1804 | 827 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 836 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
1805 | 828 | } | 837 | } |
1806 | 829 | else | 838 | else |
1807 | 830 | { | 839 | { |
1809 | 831 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 840 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
1810 | 832 | $this->response->message = 'Edited the Image.'; | 841 | $this->response->message = 'Edited the Image.'; |
1812 | 833 | 842 | ||
1813 | 834 | } | 843 | } |
1815 | 835 | 844 | ||
1816 | 836 | return $this->response; | 845 | return $this->response; |
1817 | 837 | } | 846 | } |
1819 | 838 | 847 | ||
1820 | 839 | /** | 848 | /** |
1821 | 840 | * Delete Media from the Database | 849 | * Delete Media from the Database |
1823 | 841 | * @return | 850 | * @return |
1824 | 842 | */ | 851 | */ |
1826 | 843 | public function DeleteMedia() | 852 | public function DeleteMedia() |
1827 | 844 | { | 853 | { |
1828 | 845 | $db =& $this->db; | 854 | $db =& $this->db; |
1829 | 846 | $layoutid = $this->layoutid; | 855 | $layoutid = $this->layoutid; |
1830 | @@ -848,10 +857,10 @@ | |||
1831 | 848 | $mediaid = $this->mediaid; | 857 | $mediaid = $this->mediaid; |
1832 | 849 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 858 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
1833 | 850 | $options = Kit::GetParam('options', _POST, _WORD); | 859 | $options = Kit::GetParam('options', _POST, _WORD); |
1835 | 851 | 860 | ||
1836 | 852 | // Stored As from the XML | 861 | // Stored As from the XML |
1837 | 853 | $this->uri = $this->GetOption('uri'); | 862 | $this->uri = $this->GetOption('uri'); |
1839 | 854 | 863 | ||
1840 | 855 | // Do we need to remove this from a layout? | 864 | // Do we need to remove this from a layout? |
1841 | 856 | if ($layoutid != '') | 865 | if ($layoutid != '') |
1842 | 857 | { | 866 | { |
1843 | @@ -863,72 +872,72 @@ | |||
1844 | 863 | // Set this message now in preparation | 872 | // Set this message now in preparation |
1845 | 864 | $this->response->message = 'Deleted the Media.'; | 873 | $this->response->message = 'Deleted the Media.'; |
1846 | 865 | } | 874 | } |
1848 | 866 | 875 | ||
1849 | 867 | // If we are set to retire we retire | 876 | // If we are set to retire we retire |
1850 | 868 | if ($options == "retire") | 877 | if ($options == "retire") |
1851 | 869 | { | 878 | { |
1852 | 870 | //Update the media record to say it is retired | 879 | //Update the media record to say it is retired |
1853 | 871 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 880 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
1855 | 872 | 881 | ||
1856 | 873 | if (!$db->query($SQL)) | 882 | if (!$db->query($SQL)) |
1857 | 874 | { | 883 | { |
1858 | 875 | trigger_error($db->error()); | 884 | trigger_error($db->error()); |
1860 | 876 | 885 | ||
1861 | 877 | $this->response->SetError('Database error retiring this media record.'); | 886 | $this->response->SetError('Database error retiring this media record.'); |
1862 | 878 | $this->response->keepOpen = true; | 887 | $this->response->keepOpen = true; |
1863 | 879 | return $this->response; | 888 | return $this->response; |
1864 | 880 | } | 889 | } |
1865 | 881 | } | 890 | } |
1867 | 882 | 891 | ||
1868 | 883 | //If we are set to delete, we delete | 892 | //If we are set to delete, we delete |
1869 | 884 | if ($options == "delete") | 893 | if ($options == "delete") |
1870 | 885 | { | 894 | { |
1871 | 886 | //Update the media record to say it is retired | 895 | //Update the media record to say it is retired |
1872 | 887 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 896 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
1874 | 888 | 897 | ||
1875 | 889 | if (!$db->query($SQL)) | 898 | if (!$db->query($SQL)) |
1876 | 890 | { | 899 | { |
1877 | 891 | trigger_error($db->error()); | 900 | trigger_error($db->error()); |
1879 | 892 | 901 | ||
1880 | 893 | $this->response->SetError('Database error deleting this media record.'); | 902 | $this->response->SetError('Database error deleting this media record.'); |
1881 | 894 | $this->response->keepOpen = true; | 903 | $this->response->keepOpen = true; |
1882 | 895 | return $this->response; | 904 | return $this->response; |
1883 | 896 | } | 905 | } |
1885 | 897 | 906 | ||
1886 | 898 | $this->DeleteMediaFiles(); | 907 | $this->DeleteMediaFiles(); |
1887 | 899 | } | 908 | } |
1889 | 900 | 909 | ||
1890 | 901 | return $this->response; | 910 | return $this->response; |
1891 | 902 | } | 911 | } |
1893 | 903 | 912 | ||
1894 | 904 | /** | 913 | /** |
1895 | 905 | * Deletes the media files associated with this record | 914 | * Deletes the media files associated with this record |
1897 | 906 | * @return | 915 | * @return |
1898 | 907 | */ | 916 | */ |
1899 | 908 | private function DeleteMediaFiles() | 917 | private function DeleteMediaFiles() |
1900 | 909 | { | 918 | { |
1901 | 910 | $db =& $this->db; | 919 | $db =& $this->db; |
1903 | 911 | 920 | ||
1904 | 912 | //Library location | 921 | //Library location |
1905 | 913 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 922 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
1907 | 914 | 923 | ||
1908 | 915 | //3 things to check for.. | 924 | //3 things to check for.. |
1909 | 916 | //the actual file, the thumbnail, the background | 925 | //the actual file, the thumbnail, the background |
1910 | 917 | if (file_exists($databaseDir.$this->uri)) | 926 | if (file_exists($databaseDir.$this->uri)) |
1911 | 918 | { | 927 | { |
1912 | 919 | unlink($databaseDir.$this->uri); | 928 | unlink($databaseDir.$this->uri); |
1913 | 920 | } | 929 | } |
1915 | 921 | 930 | ||
1916 | 922 | if (file_exists($databaseDir."tn_".$this->uri)) | 931 | if (file_exists($databaseDir."tn_".$this->uri)) |
1917 | 923 | { | 932 | { |
1918 | 924 | unlink($databaseDir."tn_".$this->uri); | 933 | unlink($databaseDir."tn_".$this->uri); |
1919 | 925 | } | 934 | } |
1921 | 926 | 935 | ||
1922 | 927 | if (file_exists($databaseDir."bg_".$this->uri)) | 936 | if (file_exists($databaseDir."bg_".$this->uri)) |
1923 | 928 | { | 937 | { |
1924 | 929 | unlink($databaseDir."bg_".$this->uri); | 938 | unlink($databaseDir."bg_".$this->uri); |
1925 | 930 | } | 939 | } |
1927 | 931 | 940 | ||
1928 | 932 | return true; | 941 | return true; |
1929 | 933 | } | 942 | } |
1930 | 934 | } | 943 | } |
1931 | 935 | 944 | ||
1932 | === modified file 'server/modules/powerpoint.module.php' | |||
1933 | --- server/modules/powerpoint.module.php 2009-06-28 10:47:06 +0000 | |||
1934 | +++ server/modules/powerpoint.module.php 2009-09-29 22:15:22 +0000 | |||
1935 | @@ -8,7 +8,7 @@ | |||
1936 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
1937 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
1938 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
1940 | 11 | * any later version. | 11 | * any later version. |
1941 | 12 | * | 12 | * |
1942 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
1943 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1944 | @@ -17,31 +17,31 @@ | |||
1945 | 17 | * | 17 | * |
1946 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
1947 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
1949 | 20 | */ | 20 | */ |
1950 | 21 | class powerpoint extends Module | 21 | class powerpoint extends Module |
1951 | 22 | { | 22 | { |
1952 | 23 | // Custom Media information | 23 | // Custom Media information |
1953 | 24 | private $uri; | 24 | private $uri; |
1954 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
1955 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
1957 | 27 | 27 | ||
1958 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
1959 | 29 | { | 29 | { |
1960 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
1961 | 31 | $this->type = 'powerpoint'; | 31 | $this->type = 'powerpoint'; |
1963 | 32 | 32 | ||
1964 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
1965 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
1966 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
1969 | 36 | 36 | ||
1970 | 37 | // Must call the parent class | 37 | // Must call the parent class |
1971 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
1972 | 39 | } | 39 | } |
1974 | 40 | 40 | ||
1975 | 41 | /** | 41 | /** |
1976 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
1977 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
1979 | 44 | * @return | 44 | * @return |
1980 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
1981 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
1982 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
1983 | @@ -53,75 +53,75 @@ | |||
1984 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
1985 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
1986 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
1988 | 56 | 56 | ||
1989 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
1991 | 58 | 58 | ||
1992 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
1993 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
1995 | 61 | 61 | ||
1996 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
1997 | 63 | { | 63 | { |
1998 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
1999 | 65 | return false; | 65 | return false; |
2000 | 66 | } | 66 | } |
2002 | 67 | 67 | ||
2003 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
2004 | 69 | { | 69 | { |
2005 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2006 | 71 | return false; | 71 | return false; |
2007 | 72 | } | 72 | } |
2009 | 73 | 73 | ||
2010 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
2011 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
2012 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
2014 | 77 | 77 | ||
2015 | 78 | // Required Attributes | 78 | // Required Attributes |
2016 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
2018 | 80 | 80 | ||
2019 | 81 | // Any Options | 81 | // Any Options |
2020 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
2022 | 83 | 83 | ||
2023 | 84 | return true; | 84 | return true; |
2024 | 85 | } | 85 | } |
2026 | 86 | 86 | ||
2027 | 87 | /** | 87 | /** |
2028 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
2030 | 89 | * @return | 89 | * @return |
2031 | 90 | */ | 90 | */ |
2032 | 91 | public function AddForm() | 91 | public function AddForm() |
2033 | 92 | { | 92 | { |
2034 | 93 | global $session; | 93 | global $session; |
2035 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
2036 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
2039 | 96 | 96 | ||
2040 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
2041 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
2042 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
2044 | 100 | 100 | ||
2045 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
2046 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
2047 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
2049 | 104 | 104 | ||
2050 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
2052 | 106 | 106 | ||
2053 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
2054 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
2055 | 109 | 109 | ||
2056 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
2057 | 111 | 111 | ||
2059 | 112 | if($default=="private") | 112 | if($default=="private") |
2060 | 113 | { | 113 | { |
2061 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
2062 | 115 | } | 115 | } |
2064 | 116 | 116 | ||
2065 | 117 | //shared list | 117 | //shared list |
2066 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
2068 | 119 | 119 | ||
2069 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
2070 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
2071 | 122 | { | 122 | { |
2072 | 123 | setSession('content','mediatype','powerpoint'); | 123 | setSession('content','mediatype','powerpoint'); |
2074 | 124 | 124 | ||
2075 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
2076 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
2077 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
2078 | @@ -135,7 +135,7 @@ | |||
2079 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
2080 | 136 | END; | 136 | END; |
2081 | 137 | } | 137 | } |
2083 | 138 | 138 | ||
2084 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
2085 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
2086 | 141 | <div> | 141 | <div> |
2087 | @@ -144,7 +144,7 @@ | |||
2088 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
2089 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
2090 | 146 | <table> | 146 | <table> |
2092 | 147 | <tr> | 147 | <tr> |
2093 | 148 | <td><label for="file">Powerpoint File<span class="required">*</span></label></td> | 148 | <td><label for="file">Powerpoint File<span class="required">*</span></label></td> |
2094 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
2095 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
2096 | @@ -172,7 +172,7 @@ | |||
2097 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
2098 | 173 | <td> | 173 | <td> |
2099 | 174 | $shared_list | 174 | $shared_list |
2101 | 175 | </td> | 175 | </td> |
2102 | 176 | </tr> | 176 | </tr> |
2103 | 177 | <tr> | 177 | <tr> |
2104 | 178 | <td></td> | 178 | <td></td> |
2105 | @@ -194,49 +194,49 @@ | |||
2106 | 194 | 194 | ||
2107 | 195 | return $this->response; | 195 | return $this->response; |
2108 | 196 | } | 196 | } |
2110 | 197 | 197 | ||
2111 | 198 | /** | 198 | /** |
2112 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
2114 | 200 | * @return | 200 | * @return |
2115 | 201 | */ | 201 | */ |
2116 | 202 | public function EditForm() | 202 | public function EditForm() |
2117 | 203 | { | 203 | { |
2118 | 204 | global $session; | 204 | global $session; |
2119 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
2120 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
2123 | 207 | 207 | ||
2124 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
2125 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
2126 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
2127 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
2128 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
2129 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2131 | 214 | 214 | ||
2132 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
2133 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
2134 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
2136 | 218 | 218 | ||
2137 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
2139 | 220 | 220 | ||
2140 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
2141 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
2143 | 223 | 223 | ||
2144 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
2145 | 225 | { | 225 | { |
2146 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
2148 | 227 | 227 | ||
2149 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
2150 | 229 | return false; | 229 | return false; |
2151 | 230 | } | 230 | } |
2153 | 231 | 231 | ||
2154 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
2155 | 233 | { | 233 | { |
2156 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2158 | 235 | 235 | ||
2159 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
2160 | 237 | return false; | 237 | return false; |
2161 | 238 | } | 238 | } |
2163 | 239 | 239 | ||
2164 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
2165 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
2166 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
2167 | @@ -246,23 +246,23 @@ | |||
2168 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
2169 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
2170 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
2172 | 249 | 249 | ||
2173 | 250 | // derive the ext | 250 | // derive the ext |
2174 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
2176 | 252 | 252 | ||
2177 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
2178 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
2180 | 255 | 255 | ||
2181 | 256 | //shared list | 256 | //shared list |
2182 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
2184 | 258 | 258 | ||
2185 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
2186 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
2187 | 261 | { | 261 | { |
2188 | 262 | setSession('content','mediatype','powerpoint'); | 262 | setSession('content','mediatype','powerpoint'); |
2190 | 263 | 263 | ||
2191 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
2193 | 265 | 265 | ||
2194 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
2195 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
2196 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
2197 | @@ -272,13 +272,13 @@ | |||
2198 | 272 | else | 272 | else |
2199 | 273 | { | 273 | { |
2200 | 274 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 274 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
2202 | 275 | 275 | ||
2203 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
2204 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
2205 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
2206 | 279 | END; | 279 | END; |
2207 | 280 | } | 280 | } |
2209 | 281 | 281 | ||
2210 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
2211 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
2212 | 284 | <div> | 284 | <div> |
2213 | @@ -287,7 +287,7 @@ | |||
2214 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
2215 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
2216 | 289 | <table> | 289 | <table> |
2218 | 290 | <tr> | 290 | <tr> |
2219 | 291 | <td><label for="file">New Powerpoint File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Powerpoint File<span class="required">*</span></label></td> |
2220 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
2221 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
2222 | @@ -319,7 +319,7 @@ | |||
2223 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
2224 | 320 | <td> | 320 | <td> |
2225 | 321 | $shared_list | 321 | $shared_list |
2227 | 322 | </td> | 322 | </td> |
2228 | 323 | </tr> | 323 | </tr> |
2229 | 324 | <tr> | 324 | <tr> |
2230 | 325 | <td></td> | 325 | <td></td> |
2231 | @@ -343,50 +343,50 @@ | |||
2232 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
2233 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
2234 | 345 | 345 | ||
2236 | 346 | return $this->response; | 346 | return $this->response; |
2237 | 347 | } | 347 | } |
2239 | 348 | 348 | ||
2240 | 349 | /** | 349 | /** |
2241 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
2243 | 351 | * @return | 351 | * @return |
2244 | 352 | */ | 352 | */ |
2245 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
2246 | 354 | { | 354 | { |
2247 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
2248 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
2251 | 357 | 357 | ||
2252 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
2253 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
2254 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
2255 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
2256 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
2257 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2259 | 364 | 364 | ||
2260 | 365 | $options = ""; | 365 | $options = ""; |
2261 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
2262 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
2264 | 368 | 368 | ||
2265 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
2266 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
2268 | 371 | 371 | ||
2269 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
2270 | 373 | { | 373 | { |
2271 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
2273 | 375 | 375 | ||
2274 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
2275 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
2276 | 378 | return $this->response; | 378 | return $this->response; |
2277 | 379 | } | 379 | } |
2279 | 380 | 380 | ||
2280 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
2281 | 382 | { | 382 | { |
2282 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2284 | 384 | 384 | ||
2285 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
2286 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
2287 | 387 | return $this->response; | 387 | return $this->response; |
2288 | 388 | } | 388 | } |
2290 | 389 | 389 | ||
2291 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
2292 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
2293 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
2294 | @@ -397,18 +397,18 @@ | |||
2295 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
2296 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
2297 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
2299 | 400 | 400 | ||
2300 | 401 | // derive the ext | 401 | // derive the ext |
2301 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
2303 | 403 | 403 | ||
2304 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
2305 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
2307 | 406 | 406 | ||
2308 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
2309 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
2310 | 409 | { | 409 | { |
2311 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
2313 | 411 | 411 | ||
2314 | 412 | //Is this media retired? | 412 | //Is this media retired? |
2315 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
2316 | 414 | { | 414 | { |
2317 | @@ -418,7 +418,7 @@ | |||
2318 | 418 | { | 418 | { |
2319 | 419 | $revised = false; | 419 | $revised = false; |
2320 | 420 | } | 420 | } |
2322 | 421 | 421 | ||
2323 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
2324 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
2325 | 424 | { | 424 | { |
2326 | @@ -429,8 +429,8 @@ | |||
2327 | 429 | { | 429 | { |
2328 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
2329 | 431 | } | 431 | } |
2332 | 432 | 432 | ||
2333 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
2334 | 434 | { | 434 | { |
2335 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
2336 | 436 | 436 | ||
2337 | @@ -457,9 +457,9 @@ | |||
2338 | 457 | return $this->response; | 457 | return $this->response; |
2339 | 458 | } | 458 | } |
2340 | 459 | } | 459 | } |
2342 | 460 | 460 | ||
2343 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
2345 | 462 | 462 | ||
2346 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
2347 | 464 | 464 | ||
2348 | 465 | //we can delete | 465 | //we can delete |
2349 | @@ -474,19 +474,19 @@ | |||
2350 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
2351 | 475 | </form> | 475 | </form> |
2352 | 476 | END; | 476 | END; |
2354 | 477 | 477 | ||
2355 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
2356 | 479 | $this->response->dialogTitle = 'Delete Powerpoint'; | 479 | $this->response->dialogTitle = 'Delete Powerpoint'; |
2357 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
2358 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
2359 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
2360 | 483 | 483 | ||
2362 | 484 | return $this->response; | 484 | return $this->response; |
2363 | 485 | } | 485 | } |
2365 | 486 | 486 | ||
2366 | 487 | /** | 487 | /** |
2367 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
2369 | 489 | * @return | 489 | * @return |
2370 | 490 | */ | 490 | */ |
2371 | 491 | public function AddMedia() | 491 | public function AddMedia() |
2372 | 492 | { | 492 | { |
2373 | @@ -495,29 +495,29 @@ | |||
2374 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
2375 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
2376 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2378 | 498 | 498 | ||
2379 | 499 | // File data | 499 | // File data |
2380 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
2382 | 501 | 501 | ||
2383 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
2384 | 503 | { | 503 | { |
2385 | 504 | $this->response->SetError('Cannot save Powerpoint details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Powerpoint details. <br/> You must have picked a file.'); |
2386 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
2387 | 506 | return $this->response; | 506 | return $this->response; |
2388 | 507 | } | 507 | } |
2390 | 508 | 508 | ||
2391 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
2392 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
2393 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
2394 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
2396 | 513 | 513 | ||
2397 | 514 | // Other properties | 514 | // Other properties |
2398 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
2399 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
2400 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
2402 | 518 | 518 | ||
2403 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
2405 | 520 | 520 | ||
2406 | 521 | // Validation | 521 | // Validation |
2407 | 522 | if ($ext != "ppt") | 522 | if ($ext != "ppt") |
2408 | 523 | { | 523 | { |
2409 | @@ -525,32 +525,32 @@ | |||
2410 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
2411 | 526 | return $this->response; | 526 | return $this->response; |
2412 | 527 | } | 527 | } |
2414 | 528 | 528 | ||
2415 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
2417 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
2418 | 531 | { | 531 | { |
2419 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
2420 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
2421 | 534 | return $this->response; | 534 | return $this->response; |
2422 | 535 | } | 535 | } |
2424 | 536 | 536 | ||
2425 | 537 | if ($duration == 0) | 537 | if ($duration == 0) |
2426 | 538 | { | 538 | { |
2427 | 539 | $this->response->SetError('You must enter a duration.'); | 539 | $this->response->SetError('You must enter a duration.'); |
2428 | 540 | $this->response->keepOpen = true; | 540 | $this->response->keepOpen = true; |
2429 | 541 | return $this->response; | 541 | return $this->response; |
2430 | 542 | } | 542 | } |
2432 | 543 | 543 | ||
2433 | 544 | // Ensure the name is not already in the database | 544 | // Ensure the name is not already in the database |
2434 | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 545 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
2435 | 546 | 546 | ||
2437 | 547 | if(!$result = $db->query($SQL)) | 547 | if(!$result = $db->query($SQL)) |
2438 | 548 | { | 548 | { |
2439 | 549 | trigger_error($db->error()); | 549 | trigger_error($db->error()); |
2440 | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 550 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
2441 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
2442 | 552 | return $this->response; | 552 | return $this->response; |
2444 | 553 | } | 553 | } |
2445 | 554 | 554 | ||
2446 | 555 | if ($db->num_rows($result) != 0) | 555 | if ($db->num_rows($result) != 0) |
2447 | 556 | { | 556 | { |
2448 | @@ -558,11 +558,11 @@ | |||
2449 | 558 | $this->response->keepOpen = true; | 558 | $this->response->keepOpen = true; |
2450 | 559 | return $this->response; | 559 | return $this->response; |
2451 | 560 | } | 560 | } |
2453 | 561 | 561 | ||
2454 | 562 | // All OK to insert this record | 562 | // All OK to insert this record |
2455 | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 563 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
2456 | 564 | $SQL .= "VALUES ('%s', 'powerpoint', '%s', '%s', %d, %d, 0) "; | 564 | $SQL .= "VALUES ('%s', 'powerpoint', '%s', '%s', %d, %d, 0) "; |
2458 | 565 | 565 | ||
2459 | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 566 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
2460 | 567 | 567 | ||
2461 | 568 | if (!$mediaid = $db->insert_query($SQL)) | 568 | if (!$mediaid = $db->insert_query($SQL)) |
2462 | @@ -572,19 +572,19 @@ | |||
2463 | 572 | $this->response->keepOpen = true; | 572 | $this->response->keepOpen = true; |
2464 | 573 | return $this->response; | 573 | return $this->response; |
2465 | 574 | } | 574 | } |
2467 | 575 | 575 | ||
2468 | 576 | // File upload directory.. get this from the settings object | 576 | // File upload directory.. get this from the settings object |
2469 | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 577 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
2471 | 578 | 578 | ||
2472 | 579 | // What are we going to store this media as... | 579 | // What are we going to store this media as... |
2473 | 580 | $storedAs = $mediaid.".".$ext; | 580 | $storedAs = $mediaid.".".$ext; |
2475 | 581 | 581 | ||
2476 | 582 | // Now we need to move the file | 582 | // Now we need to move the file |
2477 | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 583 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
2478 | 584 | { | 584 | { |
2479 | 585 | // If we couldnt move it - we need to delete the media record we just added | 585 | // If we couldnt move it - we need to delete the media record we just added |
2480 | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 586 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
2482 | 587 | 587 | ||
2483 | 588 | if (!$db->query($SQL)) | 588 | if (!$db->query($SQL)) |
2484 | 589 | { | 589 | { |
2485 | 590 | trigger_error($db->error()); | 590 | trigger_error($db->error()); |
2486 | @@ -593,23 +593,27 @@ | |||
2487 | 593 | return $this->response; | 593 | return $this->response; |
2488 | 594 | } | 594 | } |
2489 | 595 | } | 595 | } |
2491 | 596 | 596 | ||
2492 | 597 | // Calculate the MD5 and the file size | ||
2493 | 598 | $md5 = md5_file($databaseDir.$storedAs); | ||
2494 | 599 | $fileSize = filesize($databaseDir.$storedAs); | ||
2495 | 600 | |||
2496 | 597 | // Update the media record to include this information | 601 | // Update the media record to include this information |
2499 | 598 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 602 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $mediaid); |
2500 | 599 | 603 | ||
2501 | 600 | if (!$db->query($SQL)) | 604 | if (!$db->query($SQL)) |
2502 | 601 | { | 605 | { |
2503 | 602 | trigger_error($db->error()); | 606 | trigger_error($db->error()); |
2504 | 603 | return true; | 607 | return true; |
2505 | 604 | } | 608 | } |
2507 | 605 | 609 | ||
2508 | 606 | // Required Attributes | 610 | // Required Attributes |
2509 | 607 | $this->mediaid = $mediaid; | 611 | $this->mediaid = $mediaid; |
2510 | 608 | $this->duration = $duration; | 612 | $this->duration = $duration; |
2512 | 609 | 613 | ||
2513 | 610 | // Any Options | 614 | // Any Options |
2514 | 611 | $this->SetOption('uri', $storedAs); | 615 | $this->SetOption('uri', $storedAs); |
2516 | 612 | 616 | ||
2517 | 613 | // Should have built the media object entirely by this time | 617 | // Should have built the media object entirely by this time |
2518 | 614 | if ($regionid != '') | 618 | if ($regionid != '') |
2519 | 615 | { | 619 | { |
2520 | @@ -619,18 +623,18 @@ | |||
2521 | 619 | } | 623 | } |
2522 | 620 | else | 624 | else |
2523 | 621 | { | 625 | { |
2525 | 622 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 626 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
2526 | 623 | } | 627 | } |
2528 | 624 | 628 | ||
2529 | 625 | // We want to load a new form | 629 | // We want to load a new form |
2530 | 626 | $this->response->loadForm = true; | 630 | $this->response->loadForm = true; |
2532 | 627 | 631 | ||
2533 | 628 | return $this->response; | 632 | return $this->response; |
2534 | 629 | } | 633 | } |
2536 | 630 | 634 | ||
2537 | 631 | /** | 635 | /** |
2538 | 632 | * Edit Media in the Database | 636 | * Edit Media in the Database |
2540 | 633 | * @return | 637 | * @return |
2541 | 634 | */ | 638 | */ |
2542 | 635 | public function EditMedia() | 639 | public function EditMedia() |
2543 | 636 | { | 640 | { |
2544 | @@ -639,13 +643,13 @@ | |||
2545 | 639 | $regionid = $this->regionid; | 643 | $regionid = $this->regionid; |
2546 | 640 | $mediaid = $this->mediaid; | 644 | $mediaid = $this->mediaid; |
2547 | 641 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 645 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2549 | 642 | 646 | ||
2550 | 643 | // Stored As from the XML | 647 | // Stored As from the XML |
2551 | 644 | $storedAs = $this->GetOption('uri'); | 648 | $storedAs = $this->GetOption('uri'); |
2553 | 645 | 649 | ||
2554 | 646 | // File data | 650 | // File data |
2555 | 647 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 651 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
2557 | 648 | 652 | ||
2558 | 649 | if ($tmpName == '') | 653 | if ($tmpName == '') |
2559 | 650 | { | 654 | { |
2560 | 651 | $fileRevision = false; | 655 | $fileRevision = false; |
2561 | @@ -653,12 +657,12 @@ | |||
2562 | 653 | else | 657 | else |
2563 | 654 | { | 658 | { |
2564 | 655 | $fileRevision = true; | 659 | $fileRevision = true; |
2566 | 656 | 660 | ||
2567 | 657 | // File name and extension (orignial name) | 661 | // File name and extension (orignial name) |
2568 | 658 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 662 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
2569 | 659 | $fileName = basename($fileName); | 663 | $fileName = basename($fileName); |
2570 | 660 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 664 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
2572 | 661 | 665 | ||
2573 | 662 | if ($ext != "ppt") | 666 | if ($ext != "ppt") |
2574 | 663 | { | 667 | { |
2575 | 664 | $this->response->SetError('Only PPT files are accepted - Are you sure this is a powerpoint?'); | 668 | $this->response->SetError('Only PPT files are accepted - Are you sure this is a powerpoint?'); |
2576 | @@ -666,17 +670,17 @@ | |||
2577 | 666 | return $this->response; | 670 | return $this->response; |
2578 | 667 | } | 671 | } |
2579 | 668 | } | 672 | } |
2581 | 669 | 673 | ||
2582 | 670 | // Other properties | 674 | // Other properties |
2583 | 671 | $name = Kit::GetParam('name', _POST, _STRING); | 675 | $name = Kit::GetParam('name', _POST, _STRING); |
2584 | 672 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 676 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
2585 | 673 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 677 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
2587 | 674 | 678 | ||
2588 | 675 | if ($name == '') | 679 | if ($name == '') |
2589 | 676 | { | 680 | { |
2590 | 677 | if ($fileRevision) | 681 | if ($fileRevision) |
2591 | 678 | { | 682 | { |
2593 | 679 | $name = Kit::ValidateParam($fileName, _FILENAME); | 683 | $name = Kit::ValidateParam($fileName, _FILENAME); |
2594 | 680 | } | 684 | } |
2595 | 681 | else | 685 | else |
2596 | 682 | { | 686 | { |
2597 | @@ -684,33 +688,33 @@ | |||
2598 | 684 | $this->response->keepOpen = true; | 688 | $this->response->keepOpen = true; |
2599 | 685 | return $this->response; | 689 | return $this->response; |
2600 | 686 | } | 690 | } |
2603 | 687 | } | 691 | } |
2604 | 688 | 692 | ||
2605 | 689 | // Make sure the name isnt too long | 693 | // Make sure the name isnt too long |
2607 | 690 | if (strlen($name) > 100) | 694 | if (strlen($name) > 100) |
2608 | 691 | { | 695 | { |
2609 | 692 | $this->response->SetError('The name cannot be longer than 100 characters'); | 696 | $this->response->SetError('The name cannot be longer than 100 characters'); |
2610 | 693 | $this->response->keepOpen = true; | 697 | $this->response->keepOpen = true; |
2611 | 694 | return $this->response; | 698 | return $this->response; |
2612 | 695 | } | 699 | } |
2614 | 696 | 700 | ||
2615 | 697 | if ($duration == 0) | 701 | if ($duration == 0) |
2616 | 698 | { | 702 | { |
2617 | 699 | $this->response->SetError('You must enter a duration.'); | 703 | $this->response->SetError('You must enter a duration.'); |
2618 | 700 | $this->response->keepOpen = true; | 704 | $this->response->keepOpen = true; |
2619 | 701 | return $this->response; | 705 | return $this->response; |
2620 | 702 | } | 706 | } |
2622 | 703 | 707 | ||
2623 | 704 | // Ensure the name is not already in the database | 708 | // Ensure the name is not already in the database |
2624 | 705 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 709 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
2625 | 706 | 710 | ||
2627 | 707 | if(!$result = $db->query($SQL)) | 711 | if(!$result = $db->query($SQL)) |
2628 | 708 | { | 712 | { |
2629 | 709 | trigger_error($db->error()); | 713 | trigger_error($db->error()); |
2630 | 710 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 714 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
2631 | 711 | $this->response->keepOpen = true; | 715 | $this->response->keepOpen = true; |
2632 | 712 | return $this->response; | 716 | return $this->response; |
2634 | 713 | } | 717 | } |
2635 | 714 | 718 | ||
2636 | 715 | if ($db->num_rows($result) != 0) | 719 | if ($db->num_rows($result) != 0) |
2637 | 716 | { | 720 | { |
2638 | @@ -718,34 +722,34 @@ | |||
2639 | 718 | $this->response->keepOpen = true; | 722 | $this->response->keepOpen = true; |
2640 | 719 | return $this->response; | 723 | return $this->response; |
2641 | 720 | } | 724 | } |
2643 | 721 | 725 | ||
2644 | 722 | //Are we revising this media - or just plain editing | 726 | //Are we revising this media - or just plain editing |
2645 | 723 | if ($fileRevision) | 727 | if ($fileRevision) |
2646 | 724 | { | 728 | { |
2647 | 725 | // All OK to insert this record | 729 | // All OK to insert this record |
2648 | 726 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 730 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
2649 | 727 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; | 731 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; |
2651 | 728 | 732 | ||
2652 | 729 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 733 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
2654 | 730 | 734 | ||
2655 | 731 | if (!$new_mediaid = $db->insert_query($SQL)) | 735 | if (!$new_mediaid = $db->insert_query($SQL)) |
2656 | 732 | { | 736 | { |
2657 | 733 | trigger_error($db->error()); | 737 | trigger_error($db->error()); |
2658 | 734 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 738 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
2659 | 735 | } | 739 | } |
2661 | 736 | 740 | ||
2662 | 737 | //What are we going to store this media as... | 741 | //What are we going to store this media as... |
2663 | 738 | $storedAs = $new_mediaid.".".$ext; | 742 | $storedAs = $new_mediaid.".".$ext; |
2665 | 739 | 743 | ||
2666 | 740 | // File upload directory.. get this from the settings object | 744 | // File upload directory.. get this from the settings object |
2667 | 741 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 745 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
2669 | 742 | 746 | ||
2670 | 743 | //Now we need to move the file | 747 | //Now we need to move the file |
2671 | 744 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 748 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
2672 | 745 | { | 749 | { |
2673 | 746 | //If we couldnt move it - we need to delete the media record we just added | 750 | //If we couldnt move it - we need to delete the media record we just added |
2674 | 747 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 751 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
2676 | 748 | 752 | ||
2677 | 749 | if (!$db->insert_query($SQL)) | 753 | if (!$db->insert_query($SQL)) |
2678 | 750 | { | 754 | { |
2679 | 751 | $this->response->SetError('Error rolling back transcation.'); | 755 | $this->response->SetError('Error rolling back transcation.'); |
2680 | @@ -753,9 +757,14 @@ | |||
2681 | 753 | return $this->response; | 757 | return $this->response; |
2682 | 754 | } | 758 | } |
2683 | 755 | } | 759 | } |
2687 | 756 | 760 | ||
2688 | 757 | //Update the media record to include this information | 761 | // Calculate the MD5 and the file size |
2689 | 758 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 762 | $md5 = md5_file($databaseDir.$storedAs); |
2690 | 763 | $fileSize = filesize($databaseDir.$storedAs); | ||
2691 | 764 | |||
2692 | 765 | // Update the media record to include this information | ||
2693 | 766 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $new_mediaid); | ||
2694 | 767 | |||
2695 | 759 | if (!$db->query($SQL)) | 768 | if (!$db->query($SQL)) |
2696 | 760 | { | 769 | { |
2697 | 761 | trigger_error($db->error()); | 770 | trigger_error($db->error()); |
2698 | @@ -763,13 +772,13 @@ | |||
2699 | 763 | $this->response->keepOpen = true; | 772 | $this->response->keepOpen = true; |
2700 | 764 | return $this->response; | 773 | return $this->response; |
2701 | 765 | } | 774 | } |
2703 | 766 | 775 | ||
2704 | 767 | // Update the existing record with the new record's id | 776 | // Update the existing record with the new record's id |
2705 | 768 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 777 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
2706 | 769 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 778 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
2708 | 770 | 779 | ||
2709 | 771 | Debug::LogEntry($db, 'audit', $SQL); | 780 | Debug::LogEntry($db, 'audit', $SQL); |
2711 | 772 | 781 | ||
2712 | 773 | if (!$db->query($SQL)) | 782 | if (!$db->query($SQL)) |
2713 | 774 | { | 783 | { |
2714 | 775 | trigger_error($db->error()); | 784 | trigger_error($db->error()); |
2715 | @@ -783,54 +792,54 @@ | |||
2716 | 783 | { | 792 | { |
2717 | 784 | // Editing the existing record | 793 | // Editing the existing record |
2718 | 785 | $new_mediaid = $mediaid; | 794 | $new_mediaid = $mediaid; |
2720 | 786 | 795 | ||
2721 | 787 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 796 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
2722 | 788 | $SQL .= " WHERE mediaID = %d "; | 797 | $SQL .= " WHERE mediaID = %d "; |
2723 | 789 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 798 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
2725 | 790 | 799 | ||
2726 | 791 | Debug::LogEntry($db, 'audit', $SQL); | 800 | Debug::LogEntry($db, 'audit', $SQL); |
2728 | 792 | 801 | ||
2729 | 793 | if (!$db->query($SQL)) | 802 | if (!$db->query($SQL)) |
2730 | 794 | { | 803 | { |
2731 | 795 | trigger_error($db->error()); | 804 | trigger_error($db->error()); |
2733 | 796 | 805 | ||
2734 | 797 | $this->response->SetError('Database error editing this media record.'); | 806 | $this->response->SetError('Database error editing this media record.'); |
2735 | 798 | $this->response->keepOpen = true; | 807 | $this->response->keepOpen = true; |
2736 | 799 | return $this->response; | 808 | return $this->response; |
2737 | 800 | } | 809 | } |
2738 | 801 | } | 810 | } |
2740 | 802 | 811 | ||
2741 | 803 | // Required Attributes | 812 | // Required Attributes |
2742 | 804 | $this->mediaid = $new_mediaid; | 813 | $this->mediaid = $new_mediaid; |
2743 | 805 | $this->duration = $duration; | 814 | $this->duration = $duration; |
2745 | 806 | 815 | ||
2746 | 807 | // Any Options | 816 | // Any Options |
2747 | 808 | $this->SetOption('uri', $storedAs); | 817 | $this->SetOption('uri', $storedAs); |
2749 | 809 | 818 | ||
2750 | 810 | // Should have built the media object entirely by this time | 819 | // Should have built the media object entirely by this time |
2751 | 811 | if ($regionid != '') | 820 | if ($regionid != '') |
2752 | 812 | { | 821 | { |
2753 | 813 | // This saves the Media Object to the Region | 822 | // This saves the Media Object to the Region |
2754 | 814 | $this->UpdateRegion(); | 823 | $this->UpdateRegion(); |
2756 | 815 | 824 | ||
2757 | 816 | $this->response->loadForm = true; | 825 | $this->response->loadForm = true; |
2758 | 817 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 826 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
2759 | 818 | } | 827 | } |
2760 | 819 | else | 828 | else |
2761 | 820 | { | 829 | { |
2763 | 821 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 830 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
2764 | 822 | $this->response->message = 'Edited the Powerpoint.'; | 831 | $this->response->message = 'Edited the Powerpoint.'; |
2766 | 823 | 832 | ||
2767 | 824 | } | 833 | } |
2769 | 825 | 834 | ||
2770 | 826 | return $this->response; | 835 | return $this->response; |
2771 | 827 | } | 836 | } |
2773 | 828 | 837 | ||
2774 | 829 | /** | 838 | /** |
2775 | 830 | * Delete Media from the Database | 839 | * Delete Media from the Database |
2777 | 831 | * @return | 840 | * @return |
2778 | 832 | */ | 841 | */ |
2780 | 833 | public function DeleteMedia() | 842 | public function DeleteMedia() |
2781 | 834 | { | 843 | { |
2782 | 835 | $db =& $this->db; | 844 | $db =& $this->db; |
2783 | 836 | $layoutid = $this->layoutid; | 845 | $layoutid = $this->layoutid; |
2784 | @@ -838,10 +847,10 @@ | |||
2785 | 838 | $mediaid = $this->mediaid; | 847 | $mediaid = $this->mediaid; |
2786 | 839 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 848 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
2787 | 840 | $options = Kit::GetParam('options', _POST, _WORD); | 849 | $options = Kit::GetParam('options', _POST, _WORD); |
2789 | 841 | 850 | ||
2790 | 842 | // Stored As from the XML | 851 | // Stored As from the XML |
2791 | 843 | $this->uri = $this->GetOption('uri'); | 852 | $this->uri = $this->GetOption('uri'); |
2793 | 844 | 853 | ||
2794 | 845 | // Do we need to remove this from a layout? | 854 | // Do we need to remove this from a layout? |
2795 | 846 | if ($layoutid != '') | 855 | if ($layoutid != '') |
2796 | 847 | { | 856 | { |
2797 | @@ -853,72 +862,72 @@ | |||
2798 | 853 | // Set this message now in preparation | 862 | // Set this message now in preparation |
2799 | 854 | $this->response->message = 'Deleted the Media.'; | 863 | $this->response->message = 'Deleted the Media.'; |
2800 | 855 | } | 864 | } |
2802 | 856 | 865 | ||
2803 | 857 | // If we are set to retire we retire | 866 | // If we are set to retire we retire |
2804 | 858 | if ($options == "retire") | 867 | if ($options == "retire") |
2805 | 859 | { | 868 | { |
2806 | 860 | //Update the media record to say it is retired | 869 | //Update the media record to say it is retired |
2807 | 861 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 870 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
2809 | 862 | 871 | ||
2810 | 863 | if (!$db->query($SQL)) | 872 | if (!$db->query($SQL)) |
2811 | 864 | { | 873 | { |
2812 | 865 | trigger_error($db->error()); | 874 | trigger_error($db->error()); |
2814 | 866 | 875 | ||
2815 | 867 | $this->response->SetError('Database error retiring this media record.'); | 876 | $this->response->SetError('Database error retiring this media record.'); |
2816 | 868 | $this->response->keepOpen = true; | 877 | $this->response->keepOpen = true; |
2817 | 869 | return $this->response; | 878 | return $this->response; |
2818 | 870 | } | 879 | } |
2819 | 871 | } | 880 | } |
2821 | 872 | 881 | ||
2822 | 873 | //If we are set to delete, we delete | 882 | //If we are set to delete, we delete |
2823 | 874 | if ($options == "delete") | 883 | if ($options == "delete") |
2824 | 875 | { | 884 | { |
2825 | 876 | //Update the media record to say it is retired | 885 | //Update the media record to say it is retired |
2826 | 877 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 886 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
2828 | 878 | 887 | ||
2829 | 879 | if (!$db->query($SQL)) | 888 | if (!$db->query($SQL)) |
2830 | 880 | { | 889 | { |
2831 | 881 | trigger_error($db->error()); | 890 | trigger_error($db->error()); |
2833 | 882 | 891 | ||
2834 | 883 | $this->response->SetError('Database error deleting this media record.'); | 892 | $this->response->SetError('Database error deleting this media record.'); |
2835 | 884 | $this->response->keepOpen = true; | 893 | $this->response->keepOpen = true; |
2836 | 885 | return $this->response; | 894 | return $this->response; |
2837 | 886 | } | 895 | } |
2839 | 887 | 896 | ||
2840 | 888 | $this->DeleteMediaFiles(); | 897 | $this->DeleteMediaFiles(); |
2841 | 889 | } | 898 | } |
2843 | 890 | 899 | ||
2844 | 891 | return $this->response; | 900 | return $this->response; |
2845 | 892 | } | 901 | } |
2847 | 893 | 902 | ||
2848 | 894 | /** | 903 | /** |
2849 | 895 | * Deletes the media files associated with this record | 904 | * Deletes the media files associated with this record |
2851 | 896 | * @return | 905 | * @return |
2852 | 897 | */ | 906 | */ |
2853 | 898 | private function DeleteMediaFiles() | 907 | private function DeleteMediaFiles() |
2854 | 899 | { | 908 | { |
2855 | 900 | $db =& $this->db; | 909 | $db =& $this->db; |
2857 | 901 | 910 | ||
2858 | 902 | //Library location | 911 | //Library location |
2859 | 903 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 912 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
2861 | 904 | 913 | ||
2862 | 905 | //3 things to check for.. | 914 | //3 things to check for.. |
2863 | 906 | //the actual file, the thumbnail, the background | 915 | //the actual file, the thumbnail, the background |
2864 | 907 | if (file_exists($databaseDir.$this->uri)) | 916 | if (file_exists($databaseDir.$this->uri)) |
2865 | 908 | { | 917 | { |
2866 | 909 | unlink($databaseDir.$this->uri); | 918 | unlink($databaseDir.$this->uri); |
2867 | 910 | } | 919 | } |
2869 | 911 | 920 | ||
2870 | 912 | if (file_exists($databaseDir."tn_".$this->uri)) | 921 | if (file_exists($databaseDir."tn_".$this->uri)) |
2871 | 913 | { | 922 | { |
2872 | 914 | unlink($databaseDir."tn_".$this->uri); | 923 | unlink($databaseDir."tn_".$this->uri); |
2873 | 915 | } | 924 | } |
2875 | 916 | 925 | ||
2876 | 917 | if (file_exists($databaseDir."bg_".$this->uri)) | 926 | if (file_exists($databaseDir."bg_".$this->uri)) |
2877 | 918 | { | 927 | { |
2878 | 919 | unlink($databaseDir."bg_".$this->uri); | 928 | unlink($databaseDir."bg_".$this->uri); |
2879 | 920 | } | 929 | } |
2881 | 921 | 930 | ||
2882 | 922 | return true; | 931 | return true; |
2883 | 923 | } | 932 | } |
2884 | 924 | } | 933 | } |
2885 | 925 | 934 | ||
2886 | === modified file 'server/modules/video.module.php' | |||
2887 | --- server/modules/video.module.php 2009-06-28 10:47:06 +0000 | |||
2888 | +++ server/modules/video.module.php 2009-09-29 22:15:22 +0000 | |||
2889 | @@ -8,7 +8,7 @@ | |||
2890 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
2891 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
2892 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
2894 | 11 | * any later version. | 11 | * any later version. |
2895 | 12 | * | 12 | * |
2896 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
2897 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2898 | @@ -17,31 +17,31 @@ | |||
2899 | 17 | * | 17 | * |
2900 | 18 | * You should have received a copy of the GNU Affero General Public License | 18 | * You should have received a copy of the GNU Affero General Public License |
2901 | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with Xibo. If not, see <http://www.gnu.org/licenses/>. |
2903 | 20 | */ | 20 | */ |
2904 | 21 | class video extends Module | 21 | class video extends Module |
2905 | 22 | { | 22 | { |
2906 | 23 | // Custom Media information | 23 | // Custom Media information |
2907 | 24 | private $uri; | 24 | private $uri; |
2908 | 25 | private $maxFileSize; | 25 | private $maxFileSize; |
2909 | 26 | private $maxFileSizeBytes; | 26 | private $maxFileSizeBytes; |
2911 | 27 | 27 | ||
2912 | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') | 28 | public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '') |
2913 | 29 | { | 29 | { |
2914 | 30 | // Must set the type of the class | 30 | // Must set the type of the class |
2915 | 31 | $this->type = 'video'; | 31 | $this->type = 'video'; |
2917 | 32 | 32 | ||
2918 | 33 | // Get the max upload size from PHP | 33 | // Get the max upload size from PHP |
2919 | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); | 34 | $this->maxFileSize = ini_get('upload_max_filesize'); |
2920 | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); | 35 | $this->maxFileSizeBytes = convertBytes($this->maxFileSize); |
2923 | 36 | 36 | ||
2924 | 37 | // Must call the parent class | 37 | // Must call the parent class |
2925 | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); | 38 | parent::__construct($db, $user, $mediaid, $layoutid, $regionid); |
2926 | 39 | } | 39 | } |
2928 | 40 | 40 | ||
2929 | 41 | /** | 41 | /** |
2930 | 42 | * Sets the Layout and Region Information | 42 | * Sets the Layout and Region Information |
2931 | 43 | * it will then fill in any blanks it has about this media if it can | 43 | * it will then fill in any blanks it has about this media if it can |
2933 | 44 | * @return | 44 | * @return |
2934 | 45 | * @param $layoutid Object | 45 | * @param $layoutid Object |
2935 | 46 | * @param $regionid Object | 46 | * @param $regionid Object |
2936 | 47 | * @param $mediaid Object | 47 | * @param $mediaid Object |
2937 | @@ -53,75 +53,75 @@ | |||
2938 | 53 | $this->regionid = $regionid; | 53 | $this->regionid = $regionid; |
2939 | 54 | $mediaid = $this->mediaid; | 54 | $mediaid = $this->mediaid; |
2940 | 55 | $this->existingMedia = false; | 55 | $this->existingMedia = false; |
2942 | 56 | 56 | ||
2943 | 57 | if ($this->regionSpecific == 1) return; | 57 | if ($this->regionSpecific == 1) return; |
2945 | 58 | 58 | ||
2946 | 59 | // Load what we know about this media into the object | 59 | // Load what we know about this media into the object |
2947 | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 60 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
2949 | 61 | 61 | ||
2950 | 62 | if (!$result = $db->query($SQL)) | 62 | if (!$result = $db->query($SQL)) |
2951 | 63 | { | 63 | { |
2952 | 64 | trigger_error($db->error()); //log the error | 64 | trigger_error($db->error()); //log the error |
2953 | 65 | return false; | 65 | return false; |
2954 | 66 | } | 66 | } |
2956 | 67 | 67 | ||
2957 | 68 | if ($db->num_rows($result) != 1) | 68 | if ($db->num_rows($result) != 1) |
2958 | 69 | { | 69 | { |
2959 | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 70 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
2960 | 71 | return false; | 71 | return false; |
2961 | 72 | } | 72 | } |
2963 | 73 | 73 | ||
2964 | 74 | $row = $db->get_row($result); | 74 | $row = $db->get_row($result); |
2965 | 75 | $duration = $row[2]; | 75 | $duration = $row[2]; |
2966 | 76 | $storedAs = $row[7]; | 76 | $storedAs = $row[7]; |
2968 | 77 | 77 | ||
2969 | 78 | // Required Attributes | 78 | // Required Attributes |
2970 | 79 | $this->duration = $duration; | 79 | $this->duration = $duration; |
2972 | 80 | 80 | ||
2973 | 81 | // Any Options | 81 | // Any Options |
2974 | 82 | $this->SetOption('uri', $storedAs); | 82 | $this->SetOption('uri', $storedAs); |
2976 | 83 | 83 | ||
2977 | 84 | return true; | 84 | return true; |
2978 | 85 | } | 85 | } |
2980 | 86 | 86 | ||
2981 | 87 | /** | 87 | /** |
2982 | 88 | * Return the Add Form as HTML | 88 | * Return the Add Form as HTML |
2984 | 89 | * @return | 89 | * @return |
2985 | 90 | */ | 90 | */ |
2986 | 91 | public function AddForm() | 91 | public function AddForm() |
2987 | 92 | { | 92 | { |
2988 | 93 | global $session; | 93 | global $session; |
2989 | 94 | $db =& $this->db; | 94 | $db =& $this->db; |
2990 | 95 | $user =& $this->user; | 95 | $user =& $this->user; |
2993 | 96 | 96 | ||
2994 | 97 | // Would like to get the regions width / height | 97 | // Would like to get the regions width / height |
2995 | 98 | $layoutid = $this->layoutid; | 98 | $layoutid = $this->layoutid; |
2996 | 99 | $regionid = $this->regionid; | 99 | $regionid = $this->regionid; |
2998 | 100 | 100 | ||
2999 | 101 | // Set the Session / Security information | 101 | // Set the Session / Security information |
3000 | 102 | $sessionId = session_id(); | 102 | $sessionId = session_id(); |
3001 | 103 | $securityToken = CreateFormToken(); | 103 | $securityToken = CreateFormToken(); |
3003 | 104 | 104 | ||
3004 | 105 | $session->setSecurityToken($securityToken); | 105 | $session->setSecurityToken($securityToken); |
3006 | 106 | 106 | ||
3007 | 107 | //Get the default value for the shared list | 107 | //Get the default value for the shared list |
3008 | 108 | $default = Config::GetSetting($db,"defaultMedia"); | 108 | $default = Config::GetSetting($db,"defaultMedia"); |
3009 | 109 | 109 | ||
3010 | 110 | $permissionid = 0; | 110 | $permissionid = 0; |
3011 | 111 | 111 | ||
3013 | 112 | if($default=="private") | 112 | if($default=="private") |
3014 | 113 | { | 113 | { |
3015 | 114 | $permissionid = 1; | 114 | $permissionid = 1; |
3016 | 115 | } | 115 | } |
3018 | 116 | 116 | ||
3019 | 117 | //shared list | 117 | //shared list |
3020 | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 118 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
3022 | 119 | 119 | ||
3023 | 120 | //Save button is different depending on if we are on a region or not | 120 | //Save button is different depending on if we are on a region or not |
3024 | 121 | if ($regionid != "") | 121 | if ($regionid != "") |
3025 | 122 | { | 122 | { |
3026 | 123 | setSession('content','mediatype','video'); | 123 | setSession('content','mediatype','video'); |
3028 | 124 | 124 | ||
3029 | 125 | $save_button = <<<END | 125 | $save_button = <<<END |
3030 | 126 | <input id="btnSave" type="submit" value="Save" disabled /> | 126 | <input id="btnSave" type="submit" value="Save" disabled /> |
3031 | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 127 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
3032 | @@ -135,7 +135,7 @@ | |||
3033 | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> | 135 | <input class="XiboFormButton" id="btnCancel" type="button" title="Close" href="index.php?p=content&q=displayForms&sp=add" value="Cancel" /> |
3034 | 136 | END; | 136 | END; |
3035 | 137 | } | 137 | } |
3037 | 138 | 138 | ||
3038 | 139 | $form = <<<FORM | 139 | $form = <<<FORM |
3039 | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 140 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
3040 | 141 | <div> | 141 | <div> |
3041 | @@ -144,7 +144,7 @@ | |||
3042 | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 144 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
3043 | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 145 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
3044 | 146 | <table> | 146 | <table> |
3046 | 147 | <tr> | 147 | <tr> |
3047 | 148 | <td><label for="file">Video File<span class="required">*</span></label></td> | 148 | <td><label for="file">Video File<span class="required">*</span></label></td> |
3048 | 149 | <td colspan="3"> | 149 | <td colspan="3"> |
3049 | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 150 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
3050 | @@ -172,7 +172,7 @@ | |||
3051 | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 172 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
3052 | 173 | <td> | 173 | <td> |
3053 | 174 | $shared_list | 174 | $shared_list |
3055 | 175 | </td> | 175 | </td> |
3056 | 176 | </tr> | 176 | </tr> |
3057 | 177 | <tr> | 177 | <tr> |
3058 | 178 | <td></td> | 178 | <td></td> |
3059 | @@ -194,49 +194,49 @@ | |||
3060 | 194 | 194 | ||
3061 | 195 | return $this->response; | 195 | return $this->response; |
3062 | 196 | } | 196 | } |
3064 | 197 | 197 | ||
3065 | 198 | /** | 198 | /** |
3066 | 199 | * Return the Edit Form as HTML | 199 | * Return the Edit Form as HTML |
3068 | 200 | * @return | 200 | * @return |
3069 | 201 | */ | 201 | */ |
3070 | 202 | public function EditForm() | 202 | public function EditForm() |
3071 | 203 | { | 203 | { |
3072 | 204 | global $session; | 204 | global $session; |
3073 | 205 | $db =& $this->db; | 205 | $db =& $this->db; |
3074 | 206 | $user =& $this->user; | 206 | $user =& $this->user; |
3077 | 207 | 207 | ||
3078 | 208 | // Would like to get the regions width / height | 208 | // Would like to get the regions width / height |
3079 | 209 | $layoutid = $this->layoutid; | 209 | $layoutid = $this->layoutid; |
3080 | 210 | $regionid = $this->regionid; | 210 | $regionid = $this->regionid; |
3081 | 211 | $mediaid = $this->mediaid; | 211 | $mediaid = $this->mediaid; |
3082 | 212 | $lkid = $this->lkid; | 212 | $lkid = $this->lkid; |
3083 | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 213 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3085 | 214 | 214 | ||
3086 | 215 | // Set the Session / Security information | 215 | // Set the Session / Security information |
3087 | 216 | $sessionId = session_id(); | 216 | $sessionId = session_id(); |
3088 | 217 | $securityToken = CreateFormToken(); | 217 | $securityToken = CreateFormToken(); |
3090 | 218 | 218 | ||
3091 | 219 | $session->setSecurityToken($securityToken); | 219 | $session->setSecurityToken($securityToken); |
3093 | 220 | 220 | ||
3094 | 221 | // Load what we know about this media into the object | 221 | // Load what we know about this media into the object |
3095 | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 222 | $SQL = "SELECT name, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
3097 | 223 | 223 | ||
3098 | 224 | if (!$result = $db->query($SQL)) | 224 | if (!$result = $db->query($SQL)) |
3099 | 225 | { | 225 | { |
3100 | 226 | trigger_error($db->error()); //log the error | 226 | trigger_error($db->error()); //log the error |
3102 | 227 | 227 | ||
3103 | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 228 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
3104 | 229 | return false; | 229 | return false; |
3105 | 230 | } | 230 | } |
3107 | 231 | 231 | ||
3108 | 232 | if ($db->num_rows($result) != 1) | 232 | if ($db->num_rows($result) != 1) |
3109 | 233 | { | 233 | { |
3110 | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 234 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
3112 | 235 | 235 | ||
3113 | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; | 236 | $this->message = "Error querying for the Media information with media ID [$mediaid] "; |
3114 | 237 | return false; | 237 | return false; |
3115 | 238 | } | 238 | } |
3117 | 239 | 239 | ||
3118 | 240 | $row = $db->get_row($result); | 240 | $row = $db->get_row($result); |
3119 | 241 | $name = $row[0]; | 241 | $name = $row[0]; |
3120 | 242 | $originalFilename = $row[1]; | 242 | $originalFilename = $row[1]; |
3121 | @@ -246,23 +246,23 @@ | |||
3122 | 246 | $storedAs = $row[5]; | 246 | $storedAs = $row[5]; |
3123 | 247 | $isEdited = $row[6]; | 247 | $isEdited = $row[6]; |
3124 | 248 | $editedMediaID = $row[7]; | 248 | $editedMediaID = $row[7]; |
3126 | 249 | 249 | ||
3127 | 250 | // derive the ext | 250 | // derive the ext |
3128 | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 251 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
3130 | 252 | 252 | ||
3131 | 253 | //Calc the permissions on it aswell | 253 | //Calc the permissions on it aswell |
3132 | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 254 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
3134 | 255 | 255 | ||
3135 | 256 | //shared list | 256 | //shared list |
3136 | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); | 257 | $shared_list = dropdownlist("SELECT permissionID, permission FROM permission", "permissionid", $permissionid); |
3138 | 258 | 258 | ||
3139 | 259 | //Save button is different depending on if we are on a region or not | 259 | //Save button is different depending on if we are on a region or not |
3140 | 260 | if ($regionid != "") | 260 | if ($regionid != "") |
3141 | 261 | { | 261 | { |
3142 | 262 | setSession('content','mediatype','image'); | 262 | setSession('content','mediatype','image'); |
3144 | 263 | 263 | ||
3145 | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; | 264 | $extraNotes = '<em>Note: Uploading a new media item here will replace it on this layout only.</em>'; |
3147 | 265 | 265 | ||
3148 | 266 | $save_button = <<<END | 266 | $save_button = <<<END |
3149 | 267 | <input id="btnSave" type="submit" value="Save" /> | 267 | <input id="btnSave" type="submit" value="Save" /> |
3150 | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> | 268 | <input class="XiboFormButton" id="btnCancel" type="button" title="Return to the Region Options" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" value="Cancel" /> |
3151 | @@ -272,13 +272,13 @@ | |||
3152 | 272 | else | 272 | else |
3153 | 273 | { | 273 | { |
3154 | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; | 274 | $extraNotes = '<em>Note: As you editing from the library uploading a new media item will not replace the old one from any layouts. To do this nagivate to the layout and edit the media from there.</em>'; |
3156 | 275 | 275 | ||
3157 | 276 | $save_button = <<<END | 276 | $save_button = <<<END |
3158 | 277 | <input id="btnSave" type="submit" value="Save" /> | 277 | <input id="btnSave" type="submit" value="Save" /> |
3159 | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> | 278 | <input id="btnCancel" type="button" title="Close" onclick="$('#div_dialog').dialog('close')" value="Cancel" /> |
3160 | 279 | END; | 279 | END; |
3161 | 280 | } | 280 | } |
3163 | 281 | 281 | ||
3164 | 282 | $form = <<<FORM | 282 | $form = <<<FORM |
3165 | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> | 283 | <div style="display:none"><iframe name="fileupload" width="1px" height="1px"></iframe></div> |
3166 | 284 | <div> | 284 | <div> |
3167 | @@ -287,7 +287,7 @@ | |||
3168 | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> | 287 | <input type="hidden" id="SecurityToken" value="$securityToken" /> |
3169 | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> | 288 | <input type="hidden" name="MAX_FILE_SIZE" value="$this->maxFileSizeBytes" /> |
3170 | 289 | <table> | 289 | <table> |
3172 | 290 | <tr> | 290 | <tr> |
3173 | 291 | <td><label for="file">New Video File<span class="required">*</span></label></td> | 291 | <td><label for="file">New Video File<span class="required">*</span></label></td> |
3174 | 292 | <td colspan="3"> | 292 | <td colspan="3"> |
3175 | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> | 293 | <input type="file" name="media_file" onchange="fileFormSubmit();this.form.submit();" /> |
3176 | @@ -319,7 +319,7 @@ | |||
3177 | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> | 319 | <td><label for="permissionid">Sharing<span class="required">*</span></label></td> |
3178 | 320 | <td> | 320 | <td> |
3179 | 321 | $shared_list | 321 | $shared_list |
3181 | 322 | </td> | 322 | </td> |
3182 | 323 | </tr> | 323 | </tr> |
3183 | 324 | <tr> | 324 | <tr> |
3184 | 325 | <td></td> | 325 | <td></td> |
3185 | @@ -343,50 +343,50 @@ | |||
3186 | 343 | $this->response->dialogWidth = '450px'; | 343 | $this->response->dialogWidth = '450px'; |
3187 | 344 | $this->response->dialogHeight = '280px'; | 344 | $this->response->dialogHeight = '280px'; |
3188 | 345 | 345 | ||
3190 | 346 | return $this->response; | 346 | return $this->response; |
3191 | 347 | } | 347 | } |
3193 | 348 | 348 | ||
3194 | 349 | /** | 349 | /** |
3195 | 350 | * Return the Delete Form as HTML | 350 | * Return the Delete Form as HTML |
3197 | 351 | * @return | 351 | * @return |
3198 | 352 | */ | 352 | */ |
3199 | 353 | public function DeleteForm() | 353 | public function DeleteForm() |
3200 | 354 | { | 354 | { |
3201 | 355 | $db =& $this->db; | 355 | $db =& $this->db; |
3202 | 356 | $user =& $this->user; | 356 | $user =& $this->user; |
3205 | 357 | 357 | ||
3206 | 358 | // Would like to get the regions width / height | 358 | // Would like to get the regions width / height |
3207 | 359 | $layoutid = $this->layoutid; | 359 | $layoutid = $this->layoutid; |
3208 | 360 | $regionid = $this->regionid; | 360 | $regionid = $this->regionid; |
3209 | 361 | $mediaid = $this->mediaid; | 361 | $mediaid = $this->mediaid; |
3210 | 362 | $lkid = $this->lkid; | 362 | $lkid = $this->lkid; |
3211 | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 363 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3213 | 364 | 364 | ||
3214 | 365 | $options = ""; | 365 | $options = ""; |
3215 | 366 | //Always have the abilty to unassign from the region | 366 | //Always have the abilty to unassign from the region |
3216 | 367 | $options .= "unassign|Unassign from this region only"; | 367 | $options .= "unassign|Unassign from this region only"; |
3218 | 368 | 368 | ||
3219 | 369 | // Load what we know about this media into the object | 369 | // Load what we know about this media into the object |
3220 | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; | 370 | $SQL = "SELECT name, type, duration, originalFilename, userID, permissionID, retired, storedAs, isEdited, editedMediaID FROM media WHERE mediaID = $mediaid "; |
3222 | 371 | 371 | ||
3223 | 372 | if (!$result = $db->query($SQL)) | 372 | if (!$result = $db->query($SQL)) |
3224 | 373 | { | 373 | { |
3225 | 374 | trigger_error($db->error()); //log the error | 374 | trigger_error($db->error()); //log the error |
3227 | 375 | 375 | ||
3228 | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 376 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
3229 | 377 | $this->response->keepOpen = true; | 377 | $this->response->keepOpen = true; |
3230 | 378 | return $this->response; | 378 | return $this->response; |
3231 | 379 | } | 379 | } |
3233 | 380 | 380 | ||
3234 | 381 | if ($db->num_rows($result) != 1) | 381 | if ($db->num_rows($result) != 1) |
3235 | 382 | { | 382 | { |
3236 | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); | 383 | trigger_error("More than one row for mediaId [$mediaid] How can this be?"); |
3238 | 384 | 384 | ||
3239 | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); | 385 | $this->response->SetError('Error querying for the Media information with media ID [$mediaid]'); |
3240 | 386 | $this->response->keepOpen = true; | 386 | $this->response->keepOpen = true; |
3241 | 387 | return $this->response; | 387 | return $this->response; |
3242 | 388 | } | 388 | } |
3244 | 389 | 389 | ||
3245 | 390 | $row = $db->get_row($result); | 390 | $row = $db->get_row($result); |
3246 | 391 | $name = $row[0]; | 391 | $name = $row[0]; |
3247 | 392 | $duration = $row[2]; | 392 | $duration = $row[2]; |
3248 | @@ -397,18 +397,18 @@ | |||
3249 | 397 | $storedAs = $row[7]; | 397 | $storedAs = $row[7]; |
3250 | 398 | $isEdited = $row[8]; | 398 | $isEdited = $row[8]; |
3251 | 399 | $editedMediaID = $row[9]; | 399 | $editedMediaID = $row[9]; |
3253 | 400 | 400 | ||
3254 | 401 | // derive the ext | 401 | // derive the ext |
3255 | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); | 402 | $ext = strtolower(substr(strrchr($originalFilename, "."), 1)); |
3257 | 403 | 403 | ||
3258 | 404 | //Calc the permissions on it aswell | 404 | //Calc the permissions on it aswell |
3259 | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); | 405 | list($see_permissions , $edit_permissions) = $user->eval_permission($userid, $permissionid); |
3261 | 406 | 406 | ||
3262 | 407 | //Is this user allowed to edit this media? | 407 | //Is this user allowed to edit this media? |
3263 | 408 | if ($edit_permissions) | 408 | if ($edit_permissions) |
3264 | 409 | { | 409 | { |
3265 | 410 | $options .= ",retire|Unassign from this region and retire"; | 410 | $options .= ",retire|Unassign from this region and retire"; |
3267 | 411 | 411 | ||
3268 | 412 | //Is this media retired? | 412 | //Is this media retired? |
3269 | 413 | if ($editedMediaID != "") | 413 | if ($editedMediaID != "") |
3270 | 414 | { | 414 | { |
3271 | @@ -418,7 +418,7 @@ | |||
3272 | 418 | { | 418 | { |
3273 | 419 | $revised = false; | 419 | $revised = false; |
3274 | 420 | } | 420 | } |
3276 | 421 | 421 | ||
3277 | 422 | //Is this media being used anywhere else? | 422 | //Is this media being used anywhere else? |
3278 | 423 | if ($layoutid == "") | 423 | if ($layoutid == "") |
3279 | 424 | { | 424 | { |
3280 | @@ -429,8 +429,8 @@ | |||
3281 | 429 | { | 429 | { |
3282 | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; | 430 | $SQL = "SELECT layoutID FROM lklayoutmedia WHERE mediaID = $mediaid AND layoutid <> $layoutid AND regionID <> '$regionid' "; |
3283 | 431 | } | 431 | } |
3286 | 432 | 432 | ||
3287 | 433 | if (!$results = $db->query($SQL)) | 433 | if (!$results = $db->query($SQL)) |
3288 | 434 | { | 434 | { |
3289 | 435 | trigger_error($db->error()); | 435 | trigger_error($db->error()); |
3290 | 436 | 436 | ||
3291 | @@ -457,9 +457,9 @@ | |||
3292 | 457 | return $this->response; | 457 | return $this->response; |
3293 | 458 | } | 458 | } |
3294 | 459 | } | 459 | } |
3296 | 460 | 460 | ||
3297 | 461 | $options = ltrim($options, ","); | 461 | $options = ltrim($options, ","); |
3299 | 462 | 462 | ||
3300 | 463 | $deleteOptions = listcontent($options,"options"); | 463 | $deleteOptions = listcontent($options,"options"); |
3301 | 464 | 464 | ||
3302 | 465 | //we can delete | 465 | //we can delete |
3303 | @@ -474,19 +474,19 @@ | |||
3304 | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> | 474 | <input id="btnCancel" type="button" title="No / Cancel" href="index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions" onclick="$('#div_dialog').dialog('close');return false; " value="No" /> |
3305 | 475 | </form> | 475 | </form> |
3306 | 476 | END; | 476 | END; |
3308 | 477 | 477 | ||
3309 | 478 | $this->response->html = $form; | 478 | $this->response->html = $form; |
3310 | 479 | $this->response->dialogTitle = 'Delete Video'; | 479 | $this->response->dialogTitle = 'Delete Video'; |
3311 | 480 | $this->response->dialogSize = true; | 480 | $this->response->dialogSize = true; |
3312 | 481 | $this->response->dialogWidth = '450px'; | 481 | $this->response->dialogWidth = '450px'; |
3313 | 482 | $this->response->dialogHeight = '280px'; | 482 | $this->response->dialogHeight = '280px'; |
3314 | 483 | 483 | ||
3316 | 484 | return $this->response; | 484 | return $this->response; |
3317 | 485 | } | 485 | } |
3319 | 486 | 486 | ||
3320 | 487 | /** | 487 | /** |
3321 | 488 | * Add Media to the Database | 488 | * Add Media to the Database |
3323 | 489 | * @return | 489 | * @return |
3324 | 490 | */ | 490 | */ |
3325 | 491 | public function AddMedia() | 491 | public function AddMedia() |
3326 | 492 | { | 492 | { |
3327 | @@ -495,29 +495,29 @@ | |||
3328 | 495 | $regionid = $this->regionid; | 495 | $regionid = $this->regionid; |
3329 | 496 | $mediaid = $this->mediaid; | 496 | $mediaid = $this->mediaid; |
3330 | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 497 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3332 | 498 | 498 | ||
3333 | 499 | // File data | 499 | // File data |
3334 | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 500 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
3336 | 501 | 501 | ||
3337 | 502 | if ($tmpName == '') | 502 | if ($tmpName == '') |
3338 | 503 | { | 503 | { |
3339 | 504 | $this->response->SetError('Cannot save Video details. <br/> You must have picked a file.'); | 504 | $this->response->SetError('Cannot save Video details. <br/> You must have picked a file.'); |
3340 | 505 | $this->response->keepOpen = true; | 505 | $this->response->keepOpen = true; |
3341 | 506 | return $this->response; | 506 | return $this->response; |
3342 | 507 | } | 507 | } |
3344 | 508 | 508 | ||
3345 | 509 | // File name and extension (orignial name) | 509 | // File name and extension (orignial name) |
3346 | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 510 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
3347 | 511 | $fileName = basename($fileName); | 511 | $fileName = basename($fileName); |
3348 | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 512 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
3350 | 513 | 513 | ||
3351 | 514 | // Other properties | 514 | // Other properties |
3352 | 515 | $name = Kit::GetParam('name', _POST, _STRING); | 515 | $name = Kit::GetParam('name', _POST, _STRING); |
3353 | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 516 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
3354 | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 517 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
3356 | 518 | 518 | ||
3357 | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); | 519 | if ($name == '') $name = Kit::ValidateParam($fileName, _FILENAME); |
3359 | 520 | 520 | ||
3360 | 521 | // Validation | 521 | // Validation |
3361 | 522 | if ($ext != "wmv" && $ext != "mpeg" && $ext != "mpg") | 522 | if ($ext != "wmv" && $ext != "mpeg" && $ext != "mpg") |
3362 | 523 | { | 523 | { |
3363 | @@ -525,25 +525,25 @@ | |||
3364 | 525 | $this->response->keepOpen = true; | 525 | $this->response->keepOpen = true; |
3365 | 526 | return $this->response; | 526 | return $this->response; |
3366 | 527 | } | 527 | } |
3368 | 528 | 528 | ||
3369 | 529 | // Make sure the name isnt too long | 529 | // Make sure the name isnt too long |
3371 | 530 | if (strlen($name) > 100) | 530 | if (strlen($name) > 100) |
3372 | 531 | { | 531 | { |
3373 | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); | 532 | $this->response->SetError('The name cannot be longer than 100 characters'); |
3374 | 533 | $this->response->keepOpen = true; | 533 | $this->response->keepOpen = true; |
3375 | 534 | return $this->response; | 534 | return $this->response; |
3376 | 535 | } | 535 | } |
3378 | 536 | 536 | ||
3379 | 537 | // Ensure the name is not already in the database | 537 | // Ensure the name is not already in the database |
3380 | 538 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); | 538 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d", $db->escape_string($name), $userid); |
3381 | 539 | 539 | ||
3383 | 540 | if(!$result = $db->query($SQL)) | 540 | if(!$result = $db->query($SQL)) |
3384 | 541 | { | 541 | { |
3385 | 542 | trigger_error($db->error()); | 542 | trigger_error($db->error()); |
3386 | 543 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 543 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
3387 | 544 | $this->response->keepOpen = true; | 544 | $this->response->keepOpen = true; |
3388 | 545 | return $this->response; | 545 | return $this->response; |
3390 | 546 | } | 546 | } |
3391 | 547 | 547 | ||
3392 | 548 | if ($db->num_rows($result) != 0) | 548 | if ($db->num_rows($result) != 0) |
3393 | 549 | { | 549 | { |
3394 | @@ -551,11 +551,11 @@ | |||
3395 | 551 | $this->response->keepOpen = true; | 551 | $this->response->keepOpen = true; |
3396 | 552 | return $this->response; | 552 | return $this->response; |
3397 | 553 | } | 553 | } |
3399 | 554 | 554 | ||
3400 | 555 | // All OK to insert this record | 555 | // All OK to insert this record |
3401 | 556 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 556 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
3402 | 557 | $SQL .= "VALUES ('%s', 'video', '%s', '%s', %d, %d, 0) "; | 557 | $SQL .= "VALUES ('%s', 'video', '%s', '%s', %d, %d, 0) "; |
3404 | 558 | 558 | ||
3405 | 559 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 559 | $SQL = sprintf($SQL, $db->escape_string($name), $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
3406 | 560 | 560 | ||
3407 | 561 | if (!$mediaid = $db->insert_query($SQL)) | 561 | if (!$mediaid = $db->insert_query($SQL)) |
3408 | @@ -565,19 +565,19 @@ | |||
3409 | 565 | $this->response->keepOpen = true; | 565 | $this->response->keepOpen = true; |
3410 | 566 | return $this->response; | 566 | return $this->response; |
3411 | 567 | } | 567 | } |
3413 | 568 | 568 | ||
3414 | 569 | // File upload directory.. get this from the settings object | 569 | // File upload directory.. get this from the settings object |
3415 | 570 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 570 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
3417 | 571 | 571 | ||
3418 | 572 | // What are we going to store this media as... | 572 | // What are we going to store this media as... |
3419 | 573 | $storedAs = $mediaid.".".$ext; | 573 | $storedAs = $mediaid.".".$ext; |
3421 | 574 | 574 | ||
3422 | 575 | // Now we need to move the file | 575 | // Now we need to move the file |
3423 | 576 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) | 576 | if (!$result = rename($databaseDir."temp/".$tmpName, $databaseDir.$storedAs)) |
3424 | 577 | { | 577 | { |
3425 | 578 | // If we couldnt move it - we need to delete the media record we just added | 578 | // If we couldnt move it - we need to delete the media record we just added |
3426 | 579 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); | 579 | $SQL = sprintf("DELETE FROM media WHERE mediaID = %d ", $mediaid); |
3428 | 580 | 580 | ||
3429 | 581 | if (!$db->query($SQL)) | 581 | if (!$db->query($SQL)) |
3430 | 582 | { | 582 | { |
3431 | 583 | trigger_error($db->error()); | 583 | trigger_error($db->error()); |
3432 | @@ -586,23 +586,27 @@ | |||
3433 | 586 | return $this->response; | 586 | return $this->response; |
3434 | 587 | } | 587 | } |
3435 | 588 | } | 588 | } |
3437 | 589 | 589 | ||
3438 | 590 | // Calculate the MD5 and the file size | ||
3439 | 591 | $md5 = md5_file($databaseDir.$storedAs); | ||
3440 | 592 | $fileSize = filesize($databaseDir.$storedAs); | ||
3441 | 593 | |||
3442 | 590 | // Update the media record to include this information | 594 | // Update the media record to include this information |
3445 | 591 | $SQL = sprintf("UPDATE media SET storedAs = '%s' WHERE mediaid = %d", $storedAs, $mediaid); | 595 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $mediaid); |
3446 | 592 | 596 | ||
3447 | 593 | if (!$db->query($SQL)) | 597 | if (!$db->query($SQL)) |
3448 | 594 | { | 598 | { |
3449 | 595 | trigger_error($db->error()); | 599 | trigger_error($db->error()); |
3450 | 596 | return true; | 600 | return true; |
3451 | 597 | } | 601 | } |
3453 | 598 | 602 | ||
3454 | 599 | // Required Attributes | 603 | // Required Attributes |
3455 | 600 | $this->mediaid = $mediaid; | 604 | $this->mediaid = $mediaid; |
3456 | 601 | $this->duration = $duration; | 605 | $this->duration = $duration; |
3458 | 602 | 606 | ||
3459 | 603 | // Any Options | 607 | // Any Options |
3460 | 604 | $this->SetOption('uri', $storedAs); | 608 | $this->SetOption('uri', $storedAs); |
3462 | 605 | 609 | ||
3463 | 606 | // Should have built the media object entirely by this time | 610 | // Should have built the media object entirely by this time |
3464 | 607 | if ($regionid != '') | 611 | if ($regionid != '') |
3465 | 608 | { | 612 | { |
3466 | @@ -612,18 +616,18 @@ | |||
3467 | 612 | } | 616 | } |
3468 | 613 | else | 617 | else |
3469 | 614 | { | 618 | { |
3471 | 615 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 619 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
3472 | 616 | } | 620 | } |
3474 | 617 | 621 | ||
3475 | 618 | // We want to load a new form | 622 | // We want to load a new form |
3476 | 619 | $this->response->loadForm = true; | 623 | $this->response->loadForm = true; |
3478 | 620 | 624 | ||
3479 | 621 | return $this->response; | 625 | return $this->response; |
3480 | 622 | } | 626 | } |
3482 | 623 | 627 | ||
3483 | 624 | /** | 628 | /** |
3484 | 625 | * Edit Media in the Database | 629 | * Edit Media in the Database |
3486 | 626 | * @return | 630 | * @return |
3487 | 627 | */ | 631 | */ |
3488 | 628 | public function EditMedia() | 632 | public function EditMedia() |
3489 | 629 | { | 633 | { |
3490 | @@ -632,13 +636,13 @@ | |||
3491 | 632 | $regionid = $this->regionid; | 636 | $regionid = $this->regionid; |
3492 | 633 | $mediaid = $this->mediaid; | 637 | $mediaid = $this->mediaid; |
3493 | 634 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 638 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3495 | 635 | 639 | ||
3496 | 636 | // Stored As from the XML | 640 | // Stored As from the XML |
3497 | 637 | $storedAs = $this->GetOption('uri'); | 641 | $storedAs = $this->GetOption('uri'); |
3499 | 638 | 642 | ||
3500 | 639 | // File data | 643 | // File data |
3501 | 640 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); | 644 | $tmpName = Kit::GetParam('hidFileID', _POST, _STRING); |
3503 | 641 | 645 | ||
3504 | 642 | if ($tmpName == '') | 646 | if ($tmpName == '') |
3505 | 643 | { | 647 | { |
3506 | 644 | $fileRevision = false; | 648 | $fileRevision = false; |
3507 | @@ -646,12 +650,12 @@ | |||
3508 | 646 | else | 650 | else |
3509 | 647 | { | 651 | { |
3510 | 648 | $fileRevision = true; | 652 | $fileRevision = true; |
3512 | 649 | 653 | ||
3513 | 650 | // File name and extension (orignial name) | 654 | // File name and extension (orignial name) |
3514 | 651 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); | 655 | $fileName = Kit::GetParam('txtFileName', _POST, _STRING); |
3515 | 652 | $fileName = basename($fileName); | 656 | $fileName = basename($fileName); |
3516 | 653 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); | 657 | $ext = strtolower(substr(strrchr($fileName, "."), 1)); |
3518 | 654 | 658 | ||
3519 | 655 | // Validation | 659 | // Validation |
3520 | 656 | if ($ext != "wmv" && $ext != "mpeg" && $ext != "mpg") | 660 | if ($ext != "wmv" && $ext != "mpeg" && $ext != "mpg") |
3521 | 657 | { | 661 | { |
3522 | @@ -660,17 +664,17 @@ | |||
3523 | 660 | return $this->response; | 664 | return $this->response; |
3524 | 661 | } | 665 | } |
3525 | 662 | } | 666 | } |
3527 | 663 | 667 | ||
3528 | 664 | // Other properties | 668 | // Other properties |
3529 | 665 | $name = Kit::GetParam('name', _POST, _STRING); | 669 | $name = Kit::GetParam('name', _POST, _STRING); |
3530 | 666 | $duration = Kit::GetParam('duration', _POST, _INT, 0); | 670 | $duration = Kit::GetParam('duration', _POST, _INT, 0); |
3531 | 667 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); | 671 | $permissionid = Kit::GetParam('permissionid', _POST, _INT, 1); |
3533 | 668 | 672 | ||
3534 | 669 | if ($name == '') | 673 | if ($name == '') |
3535 | 670 | { | 674 | { |
3536 | 671 | if ($fileRevision) | 675 | if ($fileRevision) |
3537 | 672 | { | 676 | { |
3539 | 673 | $name = Kit::ValidateParam($fileName, _FILENAME); | 677 | $name = Kit::ValidateParam($fileName, _FILENAME); |
3540 | 674 | } | 678 | } |
3541 | 675 | else | 679 | else |
3542 | 676 | { | 680 | { |
3543 | @@ -678,26 +682,26 @@ | |||
3544 | 678 | $this->response->keepOpen = true; | 682 | $this->response->keepOpen = true; |
3545 | 679 | return $this->response; | 683 | return $this->response; |
3546 | 680 | } | 684 | } |
3549 | 681 | } | 685 | } |
3550 | 682 | 686 | ||
3551 | 683 | // Make sure the name isnt too long | 687 | // Make sure the name isnt too long |
3553 | 684 | if (strlen($name) > 100) | 688 | if (strlen($name) > 100) |
3554 | 685 | { | 689 | { |
3555 | 686 | $this->response->SetError('The name cannot be longer than 100 characters'); | 690 | $this->response->SetError('The name cannot be longer than 100 characters'); |
3556 | 687 | $this->response->keepOpen = true; | 691 | $this->response->keepOpen = true; |
3557 | 688 | return $this->response; | 692 | return $this->response; |
3558 | 689 | } | 693 | } |
3560 | 690 | 694 | ||
3561 | 691 | // Ensure the name is not already in the database | 695 | // Ensure the name is not already in the database |
3562 | 692 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); | 696 | $SQL = sprintf("SELECT name FROM media WHERE name = '%s' AND userid = %d AND mediaid <> %d ", $db->escape_string($name), $userid, $mediaid); |
3563 | 693 | 697 | ||
3565 | 694 | if(!$result = $db->query($SQL)) | 698 | if(!$result = $db->query($SQL)) |
3566 | 695 | { | 699 | { |
3567 | 696 | trigger_error($db->error()); | 700 | trigger_error($db->error()); |
3568 | 697 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); | 701 | $this->response->SetError('Error checking whether the media name is ok. Try choosing a different name.'); |
3569 | 698 | $this->response->keepOpen = true; | 702 | $this->response->keepOpen = true; |
3570 | 699 | return $this->response; | 703 | return $this->response; |
3572 | 700 | } | 704 | } |
3573 | 701 | 705 | ||
3574 | 702 | if ($db->num_rows($result) != 0) | 706 | if ($db->num_rows($result) != 0) |
3575 | 703 | { | 707 | { |
3576 | @@ -705,34 +709,34 @@ | |||
3577 | 705 | $this->response->keepOpen = true; | 709 | $this->response->keepOpen = true; |
3578 | 706 | return $this->response; | 710 | return $this->response; |
3579 | 707 | } | 711 | } |
3581 | 708 | 712 | ||
3582 | 709 | //Are we revising this media - or just plain editing | 713 | //Are we revising this media - or just plain editing |
3583 | 710 | if ($fileRevision) | 714 | if ($fileRevision) |
3584 | 711 | { | 715 | { |
3585 | 712 | // All OK to insert this record | 716 | // All OK to insert this record |
3586 | 713 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; | 717 | $SQL = "INSERT INTO media (name, type, duration, originalFilename, permissionID, userID, retired ) "; |
3587 | 714 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; | 718 | $SQL .= "VALUES ('%s', '%s', '%s', '%s', %d, %d, 0) "; |
3589 | 715 | 719 | ||
3590 | 716 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); | 720 | $SQL = sprintf($SQL, $db->escape_string($name), $this->type, $db->escape_string($duration), $db->escape_string($fileName), $permissionid, $userid); |
3592 | 717 | 721 | ||
3593 | 718 | if (!$new_mediaid = $db->insert_query($SQL)) | 722 | if (!$new_mediaid = $db->insert_query($SQL)) |
3594 | 719 | { | 723 | { |
3595 | 720 | trigger_error($db->error()); | 724 | trigger_error($db->error()); |
3596 | 721 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); | 725 | trigger_error('Error inserting replacement media record.', E_USER_ERROR); |
3597 | 722 | } | 726 | } |
3599 | 723 | 727 | ||
3600 | 724 | //What are we going to store this media as... | 728 | //What are we going to store this media as... |
3601 | 725 | $storedAs = $new_mediaid.".".$ext; | 729 | $storedAs = $new_mediaid.".".$ext; |
3603 | 726 | 730 | ||
3604 | 727 | // File upload directory.. get this from the settings object | 731 | // File upload directory.. get this from the settings object |
3605 | 728 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 732 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
3607 | 729 | 733 | ||
3608 | 730 | //Now we need to move the file | 734 | //Now we need to move the file |
3609 | 731 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) | 735 | if (!$result = rename($databaseDir."/temp/".$tmpName, $databaseDir.$storedAs)) |
3610 | 732 | { | 736 | { |
3611 | 733 | //If we couldnt move it - we need to delete the media record we just added | 737 | //If we couldnt move it - we need to delete the media record we just added |
3612 | 734 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; | 738 | $SQL = "DELETE FROM media WHERE mediaID = $new_mediaid "; |
3614 | 735 | 739 | ||
3615 | 736 | if (!$db->insert_query($SQL)) | 740 | if (!$db->insert_query($SQL)) |
3616 | 737 | { | 741 | { |
3617 | 738 | $this->response->SetError('Error rolling back transcation.'); | 742 | $this->response->SetError('Error rolling back transcation.'); |
3618 | @@ -740,23 +744,28 @@ | |||
3619 | 740 | return $this->response; | 744 | return $this->response; |
3620 | 741 | } | 745 | } |
3621 | 742 | } | 746 | } |
3623 | 743 | 747 | ||
3624 | 748 | // Calculate the MD5 and the file size | ||
3625 | 749 | $md5 = md5_file($databaseDir.$storedAs); | ||
3626 | 750 | $fileSize = filesize($databaseDir.$storedAs); | ||
3627 | 751 | |||
3628 | 744 | // Update the media record to include this information | 752 | // Update the media record to include this information |
3630 | 745 | $SQL = "UPDATE media SET storedAs = '$storedAs' WHERE mediaid = $new_mediaid"; | 753 | $SQL = sprintf("UPDATE media SET storedAs = '%s', `MD5` = '%s', FileSize = %d WHERE mediaid = %d", $storedAs, $md5, $fileSize, $new_mediaid); |
3631 | 754 | |||
3632 | 746 | if (!$db->query($SQL)) | 755 | if (!$db->query($SQL)) |
3633 | 747 | { | 756 | { |
3634 | 748 | trigger_error($db->error()); | 757 | trigger_error($db->error()); |
3636 | 749 | $this->response->SetError('Error updating media with Library location.'); | 758 | $this->response->SetError('Database error editing this media record.'); |
3637 | 750 | $this->response->keepOpen = true; | 759 | $this->response->keepOpen = true; |
3638 | 751 | return $this->response; | 760 | return $this->response; |
3639 | 752 | } | 761 | } |
3641 | 753 | 762 | ||
3642 | 754 | // Update the existing record with the new record's id | 763 | // Update the existing record with the new record's id |
3643 | 755 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; | 764 | $SQL = "UPDATE media SET isEdited = 1, editedMediaID = $new_mediaid "; |
3644 | 756 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; | 765 | $SQL .= " WHERE IFNULL(editedMediaID,0) <> $new_mediaid AND mediaID = $mediaid "; |
3646 | 757 | 766 | ||
3647 | 758 | Debug::LogEntry($db, 'audit', $SQL); | 767 | Debug::LogEntry($db, 'audit', $SQL); |
3649 | 759 | 768 | ||
3650 | 760 | if (!$db->query($SQL)) | 769 | if (!$db->query($SQL)) |
3651 | 761 | { | 770 | { |
3652 | 762 | trigger_error($db->error()); | 771 | trigger_error($db->error()); |
3653 | @@ -770,54 +779,54 @@ | |||
3654 | 770 | { | 779 | { |
3655 | 771 | // Editing the existing record | 780 | // Editing the existing record |
3656 | 772 | $new_mediaid = $mediaid; | 781 | $new_mediaid = $mediaid; |
3658 | 773 | 782 | ||
3659 | 774 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; | 783 | $SQL = "UPDATE media SET name = '%s', duration = %d, permissionID = %d"; |
3660 | 775 | $SQL .= " WHERE mediaID = %d "; | 784 | $SQL .= " WHERE mediaID = %d "; |
3661 | 776 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); | 785 | $SQL = sprintf($SQL, $db->escape_string($name), $duration, $permissionid, $mediaid); |
3663 | 777 | 786 | ||
3664 | 778 | Debug::LogEntry($db, 'audit', $SQL); | 787 | Debug::LogEntry($db, 'audit', $SQL); |
3666 | 779 | 788 | ||
3667 | 780 | if (!$db->query($SQL)) | 789 | if (!$db->query($SQL)) |
3668 | 781 | { | 790 | { |
3669 | 782 | trigger_error($db->error()); | 791 | trigger_error($db->error()); |
3671 | 783 | 792 | ||
3672 | 784 | $this->response->SetError('Database error editing this media record.'); | 793 | $this->response->SetError('Database error editing this media record.'); |
3673 | 785 | $this->response->keepOpen = true; | 794 | $this->response->keepOpen = true; |
3674 | 786 | return $this->response; | 795 | return $this->response; |
3675 | 787 | } | 796 | } |
3676 | 788 | } | 797 | } |
3678 | 789 | 798 | ||
3679 | 790 | // Required Attributes | 799 | // Required Attributes |
3680 | 791 | $this->mediaid = $new_mediaid; | 800 | $this->mediaid = $new_mediaid; |
3681 | 792 | $this->duration = $duration; | 801 | $this->duration = $duration; |
3683 | 793 | 802 | ||
3684 | 794 | // Any Options | 803 | // Any Options |
3685 | 795 | $this->SetOption('uri', $storedAs); | 804 | $this->SetOption('uri', $storedAs); |
3687 | 796 | 805 | ||
3688 | 797 | // Should have built the media object entirely by this time | 806 | // Should have built the media object entirely by this time |
3689 | 798 | if ($regionid != '') | 807 | if ($regionid != '') |
3690 | 799 | { | 808 | { |
3691 | 800 | // This saves the Media Object to the Region | 809 | // This saves the Media Object to the Region |
3692 | 801 | $this->UpdateRegion(); | 810 | $this->UpdateRegion(); |
3694 | 802 | 811 | ||
3695 | 803 | $this->response->loadForm = true; | 812 | $this->response->loadForm = true; |
3696 | 804 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; | 813 | $this->response->loadFormUri = "index.php?p=layout&layoutid=$layoutid®ionid=$regionid&q=RegionOptions";; |
3697 | 805 | } | 814 | } |
3698 | 806 | else | 815 | else |
3699 | 807 | { | 816 | { |
3701 | 808 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; | 817 | $this->response->loadFormUri = "index.php?p=content&q=displayForms&sp=add"; |
3702 | 809 | $this->response->message = 'Edited the Video.'; | 818 | $this->response->message = 'Edited the Video.'; |
3704 | 810 | 819 | ||
3705 | 811 | } | 820 | } |
3707 | 812 | 821 | ||
3708 | 813 | return $this->response; | 822 | return $this->response; |
3709 | 814 | } | 823 | } |
3711 | 815 | 824 | ||
3712 | 816 | /** | 825 | /** |
3713 | 817 | * Delete Media from the Database | 826 | * Delete Media from the Database |
3715 | 818 | * @return | 827 | * @return |
3716 | 819 | */ | 828 | */ |
3718 | 820 | public function DeleteMedia() | 829 | public function DeleteMedia() |
3719 | 821 | { | 830 | { |
3720 | 822 | $db =& $this->db; | 831 | $db =& $this->db; |
3721 | 823 | $layoutid = $this->layoutid; | 832 | $layoutid = $this->layoutid; |
3722 | @@ -825,10 +834,10 @@ | |||
3723 | 825 | $mediaid = $this->mediaid; | 834 | $mediaid = $this->mediaid; |
3724 | 826 | $userid = Kit::GetParam('userid', _SESSION, _INT); | 835 | $userid = Kit::GetParam('userid', _SESSION, _INT); |
3725 | 827 | $options = Kit::GetParam('options', _POST, _WORD); | 836 | $options = Kit::GetParam('options', _POST, _WORD); |
3727 | 828 | 837 | ||
3728 | 829 | // Stored As from the XML | 838 | // Stored As from the XML |
3729 | 830 | $this->uri = $this->GetOption('uri'); | 839 | $this->uri = $this->GetOption('uri'); |
3731 | 831 | 840 | ||
3732 | 832 | // Do we need to remove this from a layout? | 841 | // Do we need to remove this from a layout? |
3733 | 833 | if ($layoutid != '') | 842 | if ($layoutid != '') |
3734 | 834 | { | 843 | { |
3735 | @@ -840,72 +849,72 @@ | |||
3736 | 840 | // Set this message now in preparation | 849 | // Set this message now in preparation |
3737 | 841 | $this->response->message = 'Deleted the Media.'; | 850 | $this->response->message = 'Deleted the Media.'; |
3738 | 842 | } | 851 | } |
3740 | 843 | 852 | ||
3741 | 844 | // If we are set to retire we retire | 853 | // If we are set to retire we retire |
3742 | 845 | if ($options == "retire") | 854 | if ($options == "retire") |
3743 | 846 | { | 855 | { |
3744 | 847 | //Update the media record to say it is retired | 856 | //Update the media record to say it is retired |
3745 | 848 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; | 857 | $SQL = "UPDATE media SET retired = 1 WHERE mediaid = $mediaid "; |
3747 | 849 | 858 | ||
3748 | 850 | if (!$db->query($SQL)) | 859 | if (!$db->query($SQL)) |
3749 | 851 | { | 860 | { |
3750 | 852 | trigger_error($db->error()); | 861 | trigger_error($db->error()); |
3752 | 853 | 862 | ||
3753 | 854 | $this->response->SetError('Database error retiring this media record.'); | 863 | $this->response->SetError('Database error retiring this media record.'); |
3754 | 855 | $this->response->keepOpen = true; | 864 | $this->response->keepOpen = true; |
3755 | 856 | return $this->response; | 865 | return $this->response; |
3756 | 857 | } | 866 | } |
3757 | 858 | } | 867 | } |
3759 | 859 | 868 | ||
3760 | 860 | //If we are set to delete, we delete | 869 | //If we are set to delete, we delete |
3761 | 861 | if ($options == "delete") | 870 | if ($options == "delete") |
3762 | 862 | { | 871 | { |
3763 | 863 | //Update the media record to say it is retired | 872 | //Update the media record to say it is retired |
3764 | 864 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; | 873 | $SQL = "DELETE FROM media WHERE mediaid = $mediaid "; |
3766 | 865 | 874 | ||
3767 | 866 | if (!$db->query($SQL)) | 875 | if (!$db->query($SQL)) |
3768 | 867 | { | 876 | { |
3769 | 868 | trigger_error($db->error()); | 877 | trigger_error($db->error()); |
3771 | 869 | 878 | ||
3772 | 870 | $this->response->SetError('Database error deleting this media record.'); | 879 | $this->response->SetError('Database error deleting this media record.'); |
3773 | 871 | $this->response->keepOpen = true; | 880 | $this->response->keepOpen = true; |
3774 | 872 | return $this->response; | 881 | return $this->response; |
3775 | 873 | } | 882 | } |
3777 | 874 | 883 | ||
3778 | 875 | $this->DeleteMediaFiles(); | 884 | $this->DeleteMediaFiles(); |
3779 | 876 | } | 885 | } |
3781 | 877 | 886 | ||
3782 | 878 | return $this->response; | 887 | return $this->response; |
3783 | 879 | } | 888 | } |
3785 | 880 | 889 | ||
3786 | 881 | /** | 890 | /** |
3787 | 882 | * Deletes the media files associated with this record | 891 | * Deletes the media files associated with this record |
3789 | 883 | * @return | 892 | * @return |
3790 | 884 | */ | 893 | */ |
3791 | 885 | private function DeleteMediaFiles() | 894 | private function DeleteMediaFiles() |
3792 | 886 | { | 895 | { |
3793 | 887 | $db =& $this->db; | 896 | $db =& $this->db; |
3795 | 888 | 897 | ||
3796 | 889 | //Library location | 898 | //Library location |
3797 | 890 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); | 899 | $databaseDir = Config::GetSetting($db, "LIBRARY_LOCATION"); |
3799 | 891 | 900 | ||
3800 | 892 | //3 things to check for.. | 901 | //3 things to check for.. |
3801 | 893 | //the actual file, the thumbnail, the background | 902 | //the actual file, the thumbnail, the background |
3802 | 894 | if (file_exists($databaseDir.$this->uri)) | 903 | if (file_exists($databaseDir.$this->uri)) |
3803 | 895 | { | 904 | { |
3804 | 896 | unlink($databaseDir.$this->uri); | 905 | unlink($databaseDir.$this->uri); |
3805 | 897 | } | 906 | } |
3807 | 898 | 907 | ||
3808 | 899 | if (file_exists($databaseDir."tn_".$this->uri)) | 908 | if (file_exists($databaseDir."tn_".$this->uri)) |
3809 | 900 | { | 909 | { |
3810 | 901 | unlink($databaseDir."tn_".$this->uri); | 910 | unlink($databaseDir."tn_".$this->uri); |
3811 | 902 | } | 911 | } |
3813 | 903 | 912 | ||
3814 | 904 | if (file_exists($databaseDir."bg_".$this->uri)) | 913 | if (file_exists($databaseDir."bg_".$this->uri)) |
3815 | 905 | { | 914 | { |
3816 | 906 | unlink($databaseDir."bg_".$this->uri); | 915 | unlink($databaseDir."bg_".$this->uri); |
3817 | 907 | } | 916 | } |
3819 | 908 | 917 | ||
3820 | 909 | return true; | 918 | return true; |
3821 | 910 | } | 919 | } |
3822 | 911 | } | 920 | } |
3823 | 912 | 921 | ||
3824 | === modified file 'server/xmds.php' | |||
3825 | --- server/xmds.php 2009-09-27 11:25:04 +0000 | |||
3826 | +++ server/xmds.php 2009-09-29 22:15:22 +0000 | |||
3827 | @@ -8,7 +8,7 @@ | |||
3828 | 8 | * Xibo is free software: you can redistribute it and/or modify | 8 | * Xibo is free software: you can redistribute it and/or modify |
3829 | 9 | * it under the terms of the GNU Affero General Public License as published by | 9 | * it under the terms of the GNU Affero General Public License as published by |
3830 | 10 | * the Free Software Foundation, either version 3 of the License, or | 10 | * the Free Software Foundation, either version 3 of the License, or |
3832 | 11 | * any later version. | 11 | * any later version. |
3833 | 12 | * | 12 | * |
3834 | 13 | * Xibo is distributed in the hope that it will be useful, | 13 | * Xibo is distributed in the hope that it will be useful, |
3835 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3836 | @@ -29,66 +29,78 @@ | |||
3837 | 29 | function Auth($hardwareKey) | 29 | function Auth($hardwareKey) |
3838 | 30 | { | 30 | { |
3839 | 31 | global $db; | 31 | global $db; |
3841 | 32 | 32 | ||
3842 | 33 | //check in the database for this hardwareKey | 33 | //check in the database for this hardwareKey |
3843 | 34 | $SQL = "SELECT licensed, inc_schedule, isAuditing, displayID FROM display WHERE license = '$hardwareKey'"; | 34 | $SQL = "SELECT licensed, inc_schedule, isAuditing, displayID FROM display WHERE license = '$hardwareKey'"; |
3845 | 35 | if (!$result = $db->query($SQL)) | 35 | if (!$result = $db->query($SQL)) |
3846 | 36 | { | 36 | { |
3847 | 37 | trigger_error("License key query failed:" .$db->error()); | 37 | trigger_error("License key query failed:" .$db->error()); |
3848 | 38 | return false; | 38 | return false; |
3849 | 39 | } | 39 | } |
3851 | 40 | 40 | ||
3852 | 41 | //Is it there? | 41 | //Is it there? |
3854 | 42 | if ($db->num_rows($result) == 0) | 42 | if ($db->num_rows($result) == 0) |
3855 | 43 | { | 43 | { |
3856 | 44 | return false; | 44 | return false; |
3857 | 45 | } | 45 | } |
3859 | 46 | else | 46 | else |
3860 | 47 | { | 47 | { |
3861 | 48 | //we have seen this display before, so check the licensed value | 48 | //we have seen this display before, so check the licensed value |
3862 | 49 | $row = $db->get_row($result); | 49 | $row = $db->get_row($result); |
3864 | 50 | if ($row[0] == 0) | 50 | if ($row[0] == 0) |
3865 | 51 | { | 51 | { |
3866 | 52 | return false; | 52 | return false; |
3867 | 53 | } | 53 | } |
3869 | 54 | else | 54 | else |
3870 | 55 | { | 55 | { |
3871 | 56 | <<<<<<< TREE | ||
3872 | 56 | $displayObject = new Display($db); | 57 | $displayObject = new Display($db); |
3873 | 57 | 58 | ||
3874 | 58 | $displayObject->Touch($hardwareKey); | 59 | $displayObject->Touch($hardwareKey); |
3875 | 59 | 60 | ||
3876 | 61 | ======= | ||
3877 | 62 | $time = date("Y-m-d H:i:s", time()); | ||
3878 | 63 | |||
3879 | 64 | //Set the last accessed flag on the display | ||
3880 | 65 | $SQL = "UPDATE display SET lastaccessed = '$time', loggedin = 1 WHERE license = '$hardwareKey' "; | ||
3881 | 66 | if (!$result = $db->query($SQL)) | ||
3882 | 67 | { | ||
3883 | 68 | trigger_error("Display update access failure: " .$db->error()); | ||
3884 | 69 | } | ||
3885 | 70 | |||
3886 | 71 | >>>>>>> MERGE-SOURCE | ||
3887 | 60 | //It is licensed | 72 | //It is licensed |
3888 | 61 | return array("licensed" => true, "inc_schedule" => $row[1], "isAuditing" => $row[2], "displayid" => $row[3]); | 73 | return array("licensed" => true, "inc_schedule" => $row[1], "isAuditing" => $row[2], "displayid" => $row[3]); |
3889 | 62 | } | 74 | } |
3890 | 63 | } | 75 | } |
3892 | 64 | 76 | ||
3893 | 65 | return false; | 77 | return false; |
3894 | 66 | } | 78 | } |
3895 | 67 | 79 | ||
3896 | 68 | /** | 80 | /** |
3897 | 69 | * Checks that the calling service is talking the correct version | 81 | * Checks that the calling service is talking the correct version |
3899 | 70 | * @return | 82 | * @return |
3900 | 71 | * @param $version Object | 83 | * @param $version Object |
3901 | 72 | */ | 84 | */ |
3902 | 73 | function CheckVersion($version) | 85 | function CheckVersion($version) |
3903 | 74 | { | 86 | { |
3904 | 75 | global $db; | 87 | global $db; |
3906 | 76 | 88 | ||
3907 | 77 | // Look up the Service XMDS version from the Version table | 89 | // Look up the Service XMDS version from the Version table |
3908 | 78 | $serverVersion = Config::Version($db, 'XmdsVersion'); | 90 | $serverVersion = Config::Version($db, 'XmdsVersion'); |
3910 | 79 | 91 | ||
3911 | 80 | if ($version != $serverVersion) | 92 | if ($version != $serverVersion) |
3912 | 81 | { | 93 | { |
3913 | 82 | Debug::LogEntry($db, 'audit', sprintf('A Client with an incorrect version connected. Client Version: [%s] Server Version [%s]', $version, $serverVersion)); | 94 | Debug::LogEntry($db, 'audit', sprintf('A Client with an incorrect version connected. Client Version: [%s] Server Version [%s]', $version, $serverVersion)); |
3914 | 83 | return false; | 95 | return false; |
3915 | 84 | } | 96 | } |
3917 | 85 | 97 | ||
3918 | 86 | return true; | 98 | return true; |
3919 | 87 | } | 99 | } |
3920 | 88 | 100 | ||
3921 | 89 | /** | 101 | /** |
3922 | 90 | * Registers the Display with the server - if there is an available slot | 102 | * Registers the Display with the server - if there is an available slot |
3924 | 91 | * @return | 103 | * @return |
3925 | 92 | * @param $serverKey Object | 104 | * @param $serverKey Object |
3926 | 93 | * @param $hardwareKey Object | 105 | * @param $hardwareKey Object |
3927 | 94 | * @param $displayName Object | 106 | * @param $displayName Object |
3928 | @@ -96,70 +108,99 @@ | |||
3929 | 96 | function RegisterDisplay($serverKey, $hardwareKey, $displayName, $version) | 108 | function RegisterDisplay($serverKey, $hardwareKey, $displayName, $version) |
3930 | 97 | { | 109 | { |
3931 | 98 | global $db; | 110 | global $db; |
3933 | 99 | 111 | ||
3934 | 100 | // Sanitize | 112 | // Sanitize |
3935 | 101 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 113 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
3936 | 102 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 114 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
3937 | 103 | $displayName = Kit::ValidateParam($displayName, _STRING); | 115 | $displayName = Kit::ValidateParam($displayName, _STRING); |
3938 | 104 | $version = Kit::ValidateParam($version, _STRING); | 116 | $version = Kit::ValidateParam($version, _STRING); |
3940 | 105 | 117 | ||
3941 | 106 | // Make sure we are talking the same language | 118 | // Make sure we are talking the same language |
3942 | 107 | if (!CheckVersion($version)) | 119 | if (!CheckVersion($version)) |
3943 | 108 | { | 120 | { |
3944 | 109 | return new soap_fault("SOAP-ENV:Client", "", "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk", $serverKey); | 121 | return new soap_fault("SOAP-ENV:Client", "", "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk", $serverKey); |
3945 | 110 | } | 122 | } |
3947 | 111 | 123 | ||
3948 | 112 | define('SERVER_KEY', Config::GetSetting($db, 'SERVER_KEY')); | 124 | define('SERVER_KEY', Config::GetSetting($db, 'SERVER_KEY')); |
3950 | 113 | 125 | ||
3951 | 114 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RegisterDisplay"); | 126 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RegisterDisplay"); |
3952 | 115 | Debug::LogEntry($db, "audit", "serverKey [$serverKey], hardwareKey [$hardwareKey], displayName [$displayName]", "xmds", "RegisterDisplay"); | 127 | Debug::LogEntry($db, "audit", "serverKey [$serverKey], hardwareKey [$hardwareKey], displayName [$displayName]", "xmds", "RegisterDisplay"); |
3954 | 116 | 128 | ||
3955 | 117 | //Check the serverKey matches the one we have stored in this servers lic.txt file | 129 | //Check the serverKey matches the one we have stored in this servers lic.txt file |
3956 | 118 | if ($serverKey != SERVER_KEY) | 130 | if ($serverKey != SERVER_KEY) |
3957 | 119 | { | 131 | { |
3958 | 120 | return new soap_fault("SOAP-ENV:Client", "", "The Server key you entered does not match with the server key at this address", $serverKey); | 132 | return new soap_fault("SOAP-ENV:Client", "", "The Server key you entered does not match with the server key at this address", $serverKey); |
3959 | 121 | } | 133 | } |
3961 | 122 | 134 | ||
3962 | 123 | // Check the Length of the hardwareKey | 135 | // Check the Length of the hardwareKey |
3963 | 124 | if (strlen($hardwareKey) > 40) | 136 | if (strlen($hardwareKey) > 40) |
3964 | 125 | { | 137 | { |
3965 | 126 | return new soap_fault("SOAP-ENV:Client", "", "The Hardware Key you sent was too long. Only 40 characters are allowed (SHA1).", $hardwareKey); | 138 | return new soap_fault("SOAP-ENV:Client", "", "The Hardware Key you sent was too long. Only 40 characters are allowed (SHA1).", $hardwareKey); |
3966 | 127 | } | 139 | } |
3967 | 140 | <<<<<<< TREE | ||
3968 | 128 | 141 | ||
3969 | 129 | // Check in the database for this hardwareKey | 142 | // Check in the database for this hardwareKey |
3970 | 143 | ======= | ||
3971 | 144 | |||
3972 | 145 | //check in the database for this hardwareKey | ||
3973 | 146 | >>>>>>> MERGE-SOURCE | ||
3974 | 130 | $SQL = "SELECT licensed, display FROM display WHERE license = '$hardwareKey'"; | 147 | $SQL = "SELECT licensed, display FROM display WHERE license = '$hardwareKey'"; |
3975 | 148 | <<<<<<< TREE | ||
3976 | 131 | 149 | ||
3977 | 132 | if (!$result = $db->query($SQL)) | 150 | if (!$result = $db->query($SQL)) |
3978 | 151 | ======= | ||
3979 | 152 | if (!$result = $db->query($SQL)) | ||
3980 | 153 | >>>>>>> MERGE-SOURCE | ||
3981 | 133 | { | 154 | { |
3982 | 134 | trigger_error("License key query failed:" .$db->error()); | 155 | trigger_error("License key query failed:" .$db->error()); |
3983 | 135 | return new soap_fault("SOAP-ENV:Server", "", "License Key Query Failed, see server errorlog", $db->error()); | 156 | return new soap_fault("SOAP-ENV:Server", "", "License Key Query Failed, see server errorlog", $db->error()); |
3984 | 136 | } | 157 | } |
3985 | 158 | <<<<<<< TREE | ||
3986 | 137 | 159 | ||
3987 | 138 | // Use a display object to Add or Edit the display | 160 | // Use a display object to Add or Edit the display |
3988 | 139 | $displayObject = new Display($db); | 161 | $displayObject = new Display($db); |
3989 | 140 | 162 | ||
3990 | 141 | // Is it there? | 163 | // Is it there? |
3991 | 142 | if ($db->num_rows($result) == 0) | 164 | if ($db->num_rows($result) == 0) |
3992 | 165 | ======= | ||
3993 | 166 | |||
3994 | 167 | //Is it there? | ||
3995 | 168 | if ($db->num_rows($result) == 0) | ||
3996 | 169 | >>>>>>> MERGE-SOURCE | ||
3997 | 143 | { | 170 | { |
3998 | 171 | <<<<<<< TREE | ||
3999 | 144 | // Get the default layout id | 172 | // Get the default layout id |
4000 | 145 | $defaultLayoutId = 4; | 173 | $defaultLayoutId = 4; |
4001 | 146 | 174 | ||
4002 | 147 | // Add this display record | 175 | // Add this display record |
4003 | 148 | if (!$displayid = $displayObject->Add($displayName, 0, $defaultLayoutId, $hardwareKey, 0, 0)) return new soap_fault("SOAP-ENV:Server", "", "Error adding display"); | 176 | if (!$displayid = $displayObject->Add($displayName, 0, $defaultLayoutId, $hardwareKey, 0, 0)) return new soap_fault("SOAP-ENV:Server", "", "Error adding display"); |
4004 | 149 | 177 | ||
4005 | 178 | ======= | ||
4006 | 179 | //Add this display record | ||
4007 | 180 | $SQL = sprintf("INSERT INTO display (display, defaultlayoutid, license, licensed) VALUES ('%s', 1, '%s', 0)", $displayName, $hardwareKey); | ||
4008 | 181 | if (!$displayid = $db->insert_query($SQL)) | ||
4009 | 182 | { | ||
4010 | 183 | trigger_error($db->error()); | ||
4011 | 184 | return new soap_fault("SOAP-ENV:Server", "", "Error adding display"); | ||
4012 | 185 | } | ||
4013 | 186 | >>>>>>> MERGE-SOURCE | ||
4014 | 150 | $active = "Display added and is awaiting licensing approval from an Administrator"; | 187 | $active = "Display added and is awaiting licensing approval from an Administrator"; |
4015 | 151 | } | 188 | } |
4017 | 152 | else | 189 | else |
4018 | 153 | { | 190 | { |
4019 | 154 | //we have seen this display before, so check the licensed value | 191 | //we have seen this display before, so check the licensed value |
4020 | 155 | $row = $db->get_row($result); | 192 | $row = $db->get_row($result); |
4021 | 193 | <<<<<<< TREE | ||
4022 | 156 | 194 | ||
4023 | 157 | if ($row[0] == 0) | 195 | if ($row[0] == 0) |
4024 | 196 | ======= | ||
4025 | 197 | if ($row[0] == 0) | ||
4026 | 198 | >>>>>>> MERGE-SOURCE | ||
4027 | 158 | { | 199 | { |
4028 | 159 | //Its Not licensed | 200 | //Its Not licensed |
4029 | 160 | $active = "Display is awaiting licensing approval from an Administrator."; | 201 | $active = "Display is awaiting licensing approval from an Administrator."; |
4030 | 161 | } | 202 | } |
4032 | 162 | else | 203 | else |
4033 | 163 | { | 204 | { |
4034 | 164 | //It is licensed | 205 | //It is licensed |
4035 | 165 | //Now check the names | 206 | //Now check the names |
4036 | @@ -169,20 +210,27 @@ | |||
4037 | 169 | } | 210 | } |
4038 | 170 | else | 211 | else |
4039 | 171 | { | 212 | { |
4040 | 213 | <<<<<<< TREE | ||
4041 | 172 | // Update the name | 214 | // Update the name |
4042 | 173 | if (!$displayObject->EditDisplayName($hardwareKey, $displayName)) | 215 | if (!$displayObject->EditDisplayName($hardwareKey, $displayName)) |
4043 | 216 | ======= | ||
4044 | 217 | //Update the name | ||
4045 | 218 | $SQL = sprintf("UPDATE display SET display = '%s' WHERE license = '%s' ", $displayName, $hardwareKey); | ||
4046 | 219 | |||
4047 | 220 | if (!$db->query($SQL)) | ||
4048 | 221 | >>>>>>> MERGE-SOURCE | ||
4049 | 174 | { | 222 | { |
4050 | 175 | return new soap_fault("SOAP-ENV:Server", "", "Error editing the display name"); | 223 | return new soap_fault("SOAP-ENV:Server", "", "Error editing the display name"); |
4051 | 176 | } | 224 | } |
4053 | 177 | 225 | ||
4054 | 178 | $active = "Changed display name from '{$row[1]}' to '$displayName' Display is active and ready to start."; | 226 | $active = "Changed display name from '{$row[1]}' to '$displayName' Display is active and ready to start."; |
4055 | 179 | } | 227 | } |
4056 | 180 | } | 228 | } |
4057 | 181 | } | 229 | } |
4062 | 182 | 230 | ||
4063 | 183 | Debug::LogEntry($db, "audit", "$active", "xmds", "RegisterDisplay"); | 231 | Debug::LogEntry($db, "audit", "$active", "xmds", "RegisterDisplay"); |
4064 | 184 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RegisterDisplay"); | 232 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RegisterDisplay"); |
4065 | 185 | 233 | ||
4066 | 186 | return $active; | 234 | return $active; |
4067 | 187 | } | 235 | } |
4068 | 188 | 236 | ||
4069 | @@ -194,12 +242,12 @@ | |||
4070 | 194 | function RequiredFiles($serverKey, $hardwareKey, $version) | 242 | function RequiredFiles($serverKey, $hardwareKey, $version) |
4071 | 195 | { | 243 | { |
4072 | 196 | global $db; | 244 | global $db; |
4074 | 197 | 245 | ||
4075 | 198 | // Sanitize | 246 | // Sanitize |
4076 | 199 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 247 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4077 | 200 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 248 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4078 | 201 | $version = Kit::ValidateParam($version, _STRING); | 249 | $version = Kit::ValidateParam($version, _STRING); |
4080 | 202 | 250 | ||
4081 | 203 | // Make sure we are talking the same language | 251 | // Make sure we are talking the same language |
4082 | 204 | if (!CheckVersion($version)) | 252 | if (!CheckVersion($version)) |
4083 | 205 | { | 253 | { |
4084 | @@ -207,30 +255,43 @@ | |||
4085 | 207 | } | 255 | } |
4086 | 208 | 256 | ||
4087 | 209 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); | 257 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4089 | 210 | 258 | ||
4090 | 211 | //auth this request... | 259 | //auth this request... |
4091 | 212 | if (!$displayInfo = Auth($hardwareKey)) | 260 | if (!$displayInfo = Auth($hardwareKey)) |
4092 | 213 | { | 261 | { |
4093 | 214 | trigger_error("This display is not licensed [$hardwareKey]"); | 262 | trigger_error("This display is not licensed [$hardwareKey]"); |
4094 | 215 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); | 263 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); |
4095 | 216 | } | 264 | } |
4098 | 217 | 265 | ||
4099 | 218 | if ($displayInfo['isAuditing'] == 1) | 266 | if ($displayInfo['isAuditing'] == 1) |
4100 | 219 | { | 267 | { |
4103 | 220 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RequiredFiles"); | 268 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RequiredFiles"); |
4104 | 221 | Debug::LogEntry($db, "audit", "$hardwareKey", "xmds", "RequiredFiles"); | 269 | Debug::LogEntry($db, "audit", "$hardwareKey", "xmds", "RequiredFiles"); |
4105 | 222 | } | 270 | } |
4107 | 223 | 271 | ||
4108 | 224 | $requiredFilesXml = new DOMDocument("1.0"); | 272 | $requiredFilesXml = new DOMDocument("1.0"); |
4109 | 273 | <<<<<<< TREE | ||
4110 | 225 | $fileElements = $requiredFilesXml->createElement("files"); | 274 | $fileElements = $requiredFilesXml->createElement("files"); |
4111 | 226 | 275 | ||
4112 | 276 | ======= | ||
4113 | 277 | $fileElements = $requiredFilesXml->createElement("files"); | ||
4114 | 278 | |||
4115 | 279 | >>>>>>> MERGE-SOURCE | ||
4116 | 227 | $requiredFilesXml->appendChild($fileElements); | 280 | $requiredFilesXml->appendChild($fileElements); |
4117 | 281 | <<<<<<< TREE | ||
4118 | 228 | 282 | ||
4119 | 229 | $currentdate = time(); | 283 | $currentdate = time(); |
4120 | 230 | $infinityFromDT = mktime(0,0,0,1,1,2000); | 284 | $infinityFromDT = mktime(0,0,0,1,1,2000); |
4121 | 231 | $infinityToDT = mktime(0,0,0,12,31,2050); | 285 | $infinityToDT = mktime(0,0,0,12,31,2050); |
4122 | 232 | $plus4hours = $currentdate + 86400; | 286 | $plus4hours = $currentdate + 86400; |
4123 | 233 | 287 | ||
4124 | 288 | ======= | ||
4125 | 289 | |||
4126 | 290 | $currentdate = date("Y-m-d H:i:s"); | ||
4127 | 291 | $time = time(); | ||
4128 | 292 | $plus4hours = date("Y-m-d H:i:s",$time + 86400); | ||
4129 | 293 | |||
4130 | 294 | >>>>>>> MERGE-SOURCE | ||
4131 | 234 | //Add file nodes to the $fileElements | 295 | //Add file nodes to the $fileElements |
4132 | 235 | //Firstly get all the scheduled layouts | 296 | //Firstly get all the scheduled layouts |
4133 | 236 | $SQL = " SELECT DISTINCT layout.layoutID, layout.xml, layout.background "; | 297 | $SQL = " SELECT DISTINCT layout.layoutID, layout.xml, layout.background "; |
4134 | @@ -239,9 +300,9 @@ | |||
4135 | 239 | $SQL .= " INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = schedule_detail.DisplayGroupID "; | 300 | $SQL .= " INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = schedule_detail.DisplayGroupID "; |
4136 | 240 | $SQL .= " INNER JOIN display ON lkdisplaydg.DisplayID = display.displayID "; | 301 | $SQL .= " INNER JOIN display ON lkdisplaydg.DisplayID = display.displayID "; |
4137 | 241 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); | 302 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); |
4139 | 242 | 303 | ||
4140 | 243 | $SQLBase = $SQL; | 304 | $SQLBase = $SQL; |
4142 | 244 | 305 | ||
4143 | 245 | //Do we include the default display | 306 | //Do we include the default display |
4144 | 246 | if ($displayInfo['inc_schedule'] == 1) | 307 | if ($displayInfo['inc_schedule'] == 1) |
4145 | 247 | { | 308 | { |
4146 | @@ -252,129 +313,167 @@ | |||
4147 | 252 | { | 313 | { |
4148 | 253 | $SQL .= sprintf(" AND (schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d )", $plus4hours, $currentdate); | 314 | $SQL .= sprintf(" AND (schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d )", $plus4hours, $currentdate); |
4149 | 254 | } | 315 | } |
4152 | 255 | 316 | ||
4153 | 256 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "RequiredFiles"); | 317 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "RequiredFiles"); |
4154 | 257 | 318 | ||
4155 | 258 | if (!$results = $db->query($SQL)) | 319 | if (!$results = $db->query($SQL)) |
4156 | 259 | { | 320 | { |
4157 | 260 | trigger_error($db->error()); | 321 | trigger_error($db->error()); |
4158 | 261 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); | 322 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); |
4159 | 262 | } | 323 | } |
4161 | 263 | 324 | ||
4162 | 264 | // Was there anything? | 325 | // Was there anything? |
4163 | 265 | if ($db->num_rows($results) == 0) | 326 | if ($db->num_rows($results) == 0) |
4164 | 266 | { | 327 | { |
4165 | 267 | // No rows, run the query for default layout | 328 | // No rows, run the query for default layout |
4166 | 268 | $SQL = $SQLBase; | 329 | $SQL = $SQLBase; |
4167 | 330 | <<<<<<< TREE | ||
4168 | 269 | $SQL .= sprintf(" AND ((schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d )", $plus4hours, $currentdate); | 331 | $SQL .= sprintf(" AND ((schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d )", $plus4hours, $currentdate); |
4169 | 270 | $SQL .= sprintf(" OR (schedule_detail.FromDT = %d AND schedule_detail.ToDT = %d ))", $infinityFromDT, $infinityToDT); | 332 | $SQL .= sprintf(" OR (schedule_detail.FromDT = %d AND schedule_detail.ToDT = %d ))", $infinityFromDT, $infinityToDT); |
4170 | 271 | 333 | ||
4171 | 334 | ======= | ||
4172 | 335 | $SQL .= sprintf(" AND ((schedule_detail.starttime < '%s' AND schedule_detail.endtime > '%s' )", $plus4hours, $currentdate); | ||
4173 | 336 | $SQL .= " OR (schedule_detail.starttime = '2050-12-31 00:00:00' AND schedule_detail.endtime = '2050-12-31 00:00:00' ))"; | ||
4174 | 337 | |||
4175 | 338 | >>>>>>> MERGE-SOURCE | ||
4176 | 272 | if (!$results = $db->query($SQL)) | 339 | if (!$results = $db->query($SQL)) |
4177 | 273 | { | 340 | { |
4178 | 274 | trigger_error($db->error()); | 341 | trigger_error($db->error()); |
4179 | 275 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); | 342 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); |
4180 | 276 | } | 343 | } |
4181 | 277 | } | 344 | } |
4183 | 278 | 345 | ||
4184 | 279 | while ($row = $db->get_row($results)) | 346 | while ($row = $db->get_row($results)) |
4185 | 280 | { | 347 | { |
4186 | 281 | $layoutid = $row[0]; | 348 | $layoutid = $row[0]; |
4187 | 349 | <<<<<<< TREE | ||
4188 | 282 | $layoutXml = $row[1]; | 350 | $layoutXml = $row[1]; |
4189 | 283 | $background = $row[2]; | 351 | $background = $row[2]; |
4190 | 284 | 352 | ||
4191 | 353 | ======= | ||
4192 | 354 | $layoutXml = $row[3]; | ||
4193 | 355 | $background = $row[4]; | ||
4194 | 356 | |||
4195 | 357 | >>>>>>> MERGE-SOURCE | ||
4196 | 285 | // Add all the associated media first | 358 | // Add all the associated media first |
4201 | 286 | $SQL = "SELECT storedAs, media.mediaID | 359 | $SQL = "SELECT storedAs, media.mediaID, media.`MD5`, media.FileSize |
4202 | 287 | FROM media | 360 | FROM media |
4203 | 288 | INNER JOIN lklayoutmedia ON lklayoutmedia.mediaID = media.mediaID | 361 | INNER JOIN lklayoutmedia ON lklayoutmedia.mediaID = media.mediaID |
4204 | 289 | WHERE storedAs IS NOT NULL | 362 | WHERE storedAs IS NOT NULL |
4205 | 290 | AND lklayoutmedia.layoutID = $layoutid | 363 | AND lklayoutmedia.layoutID = $layoutid |
4209 | 291 | AND media.mediaID NOT IN (SELECT MediaID | 364 | AND media.mediaID NOT IN (SELECT MediaID |
4210 | 292 | FROM blacklist | 365 | FROM blacklist |
4211 | 293 | WHERE DisplayID = " . $displayInfo['displayid'] . " | 366 | WHERE DisplayID = " . $displayInfo['displayid'] . " |
4212 | 294 | AND isIgnored = 0 )"; | 367 | AND isIgnored = 0 )"; |
4214 | 295 | 368 | ||
4215 | 296 | if (!$mediaResults = $db->query($SQL)) | 369 | if (!$mediaResults = $db->query($SQL)) |
4216 | 297 | { | 370 | { |
4217 | 298 | trigger_error($db->error()); | 371 | trigger_error($db->error()); |
4218 | 299 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of media for the layout [$layoutid]"); | 372 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of media for the layout [$layoutid]"); |
4219 | 300 | } | 373 | } |
4221 | 301 | 374 | ||
4222 | 302 | while ($row = $db->get_row($mediaResults)) | 375 | while ($row = $db->get_row($mediaResults)) |
4223 | 303 | { | 376 | { |
4224 | 377 | $storedAs = Kit::ValidateParam($row[0], _STRING); | ||
4225 | 378 | $mediaId = Kit::ValidateParam($row[1], _INT); | ||
4226 | 379 | $md5 = Kit::ValidateParam($row[2], _STRING); | ||
4227 | 380 | $fileSize = Kit::ValidateParam($row[3], _INT); | ||
4228 | 381 | |||
4229 | 382 | // If they are empty calculate them and save them back to the media. | ||
4230 | 383 | if ($md5 == '' || $fileSize == 0) | ||
4231 | 384 | { | ||
4232 | 385 | |||
4233 | 386 | $md5 = md5_file($libraryLocation.$row[0]); | ||
4234 | 387 | $fileSize = filesize($libraryLocation.$row[0]); | ||
4235 | 388 | |||
4236 | 389 | // Update the media record with this information | ||
4237 | 390 | $SQL = sprintf("UPDATE media SET `MD5` = '%s', FileSize = %d WHERE MediaID = %d", $md5, $fileSize, $mediaId); | ||
4238 | 391 | |||
4239 | 392 | if (!$db->query($SQL)) | ||
4240 | 393 | trigger_error($db->error()); | ||
4241 | 394 | } | ||
4242 | 395 | |||
4243 | 304 | //Add the file node | 396 | //Add the file node |
4244 | 305 | $file = $requiredFilesXml->createElement("file"); | 397 | $file = $requiredFilesXml->createElement("file"); |
4246 | 306 | 398 | ||
4247 | 307 | $file->setAttribute("type", "media"); | 399 | $file->setAttribute("type", "media"); |
4253 | 308 | $file->setAttribute("path", $row[0]); | 400 | $file->setAttribute("path", $storedAs); |
4254 | 309 | $file->setAttribute("id", $row[1]); | 401 | $file->setAttribute("id", $mediaId); |
4255 | 310 | $file->setAttribute("size", filesize($libraryLocation.$row[0])); | 402 | $file->setAttribute("size", $fileSize); |
4256 | 311 | $file->setAttribute("md5", md5_file($libraryLocation.$row[0])); | 403 | $file->setAttribute("md5", $md5); |
4257 | 312 | 404 | ||
4258 | 313 | $fileElements->appendChild($file); | 405 | $fileElements->appendChild($file); |
4259 | 314 | } | 406 | } |
4261 | 315 | 407 | ||
4262 | 316 | //Also append another file node for the background image (if there is one) | 408 | //Also append another file node for the background image (if there is one) |
4263 | 317 | if ($background != "") | 409 | if ($background != "") |
4264 | 318 | { | 410 | { |
4265 | 319 | //firstly add this as a node | 411 | //firstly add this as a node |
4266 | 320 | $file = $requiredFilesXml->createElement("file"); | 412 | $file = $requiredFilesXml->createElement("file"); |
4268 | 321 | 413 | ||
4269 | 322 | $file->setAttribute("type", "media"); | 414 | $file->setAttribute("type", "media"); |
4270 | 323 | $file->setAttribute("path", $background); | 415 | $file->setAttribute("path", $background); |
4271 | 324 | $file->setAttribute("md5", md5_file($libraryLocation.$background)); | 416 | $file->setAttribute("md5", md5_file($libraryLocation.$background)); |
4272 | 325 | $file->setAttribute("size", filesize($libraryLocation.$background)); | 417 | $file->setAttribute("size", filesize($libraryLocation.$background)); |
4274 | 326 | 418 | ||
4275 | 327 | $fileElements->appendChild($file); | 419 | $fileElements->appendChild($file); |
4276 | 328 | } | 420 | } |
4278 | 329 | 421 | ||
4279 | 330 | // Add this layout as node | 422 | // Add this layout as node |
4280 | 331 | $file = $requiredFilesXml->createElement("file"); | 423 | $file = $requiredFilesXml->createElement("file"); |
4282 | 332 | 424 | ||
4283 | 333 | $file->setAttribute("type", "layout"); | 425 | $file->setAttribute("type", "layout"); |
4284 | 334 | $file->setAttribute("path", $layoutid); | 426 | $file->setAttribute("path", $layoutid); |
4285 | 335 | $file->setAttribute("md5", md5($layoutXml . "\n")); | 427 | $file->setAttribute("md5", md5($layoutXml . "\n")); |
4287 | 336 | 428 | ||
4288 | 337 | $fileElements->appendChild($file); | 429 | $fileElements->appendChild($file); |
4289 | 338 | } | 430 | } |
4291 | 339 | 431 | ||
4292 | 340 | // | 432 | // |
4293 | 341 | // Add a blacklist node | 433 | // Add a blacklist node |
4294 | 342 | // | 434 | // |
4295 | 343 | $blackList = $requiredFilesXml->createElement("file"); | 435 | $blackList = $requiredFilesXml->createElement("file"); |
4296 | 344 | $blackList->setAttribute("type", "blacklist"); | 436 | $blackList->setAttribute("type", "blacklist"); |
4298 | 345 | 437 | ||
4299 | 346 | $fileElements->appendChild($blackList); | 438 | $fileElements->appendChild($blackList); |
4301 | 347 | 439 | ||
4302 | 348 | // Populate | 440 | // Populate |
4306 | 349 | $SQL = "SELECT MediaID | 441 | $SQL = "SELECT MediaID |
4307 | 350 | FROM blacklist | 442 | FROM blacklist |
4308 | 351 | WHERE DisplayID = " . $displayInfo['displayid'] . " | 443 | WHERE DisplayID = " . $displayInfo['displayid'] . " |
4309 | 352 | AND isIgnored = 0"; | 444 | AND isIgnored = 0"; |
4311 | 353 | 445 | ||
4312 | 354 | if (!$results = $db->query($SQL)) | 446 | if (!$results = $db->query($SQL)) |
4313 | 355 | { | 447 | { |
4314 | 356 | trigger_error($db->error()); | 448 | trigger_error($db->error()); |
4315 | 357 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of blacklisted files", $db->error()); | 449 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of blacklisted files", $db->error()); |
4316 | 358 | } | 450 | } |
4318 | 359 | 451 | ||
4319 | 360 | // Add a black list element for each file | 452 | // Add a black list element for each file |
4320 | 361 | while ($row = $db->get_row($results)) | 453 | while ($row = $db->get_row($results)) |
4321 | 362 | { | 454 | { |
4322 | 363 | $file = $requiredFilesXml->createElement("file"); | 455 | $file = $requiredFilesXml->createElement("file"); |
4323 | 364 | $file->setAttribute("id", $row[0]); | 456 | $file->setAttribute("id", $row[0]); |
4325 | 365 | 457 | ||
4326 | 366 | $blackList->appendChild($file); | 458 | $blackList->appendChild($file); |
4327 | 367 | } | 459 | } |
4328 | 368 | 460 | ||
4329 | 369 | // PHONE_HOME if required. | 461 | // PHONE_HOME if required. |
4330 | 462 | <<<<<<< TREE | ||
4331 | 370 | if (Config::GetSetting($db,'PHONE_HOME') == 'On') { | 463 | if (Config::GetSetting($db,'PHONE_HOME') == 'On') { |
4332 | 371 | // Find out when we last PHONED_HOME :D | 464 | // Find out when we last PHONED_HOME :D |
4333 | 372 | // If it's been > 28 days since last PHONE_HOME then | 465 | // If it's been > 28 days since last PHONE_HOME then |
4334 | 373 | 466 | ||
4335 | 467 | ======= | ||
4336 | 468 | if (Config::GetSetting($db,'PHONE_HOME') == 'On') { | ||
4337 | 469 | // Find out when we last PHONED_HOME :D | ||
4338 | 470 | // If it's been > 28 days since last PHONE_HOME then | ||
4339 | 471 | >>>>>>> MERGE-SOURCE | ||
4340 | 374 | if (Config::GetSetting($db,'PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28))) { | 472 | if (Config::GetSetting($db,'PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28))) { |
4341 | 375 | 473 | ||
4343 | 376 | if ($displayInfo['isAuditing'] == 1) | 474 | if ($displayInfo['isAuditing'] == 1) |
4344 | 377 | { | 475 | { |
4345 | 476 | <<<<<<< TREE | ||
4346 | 378 | Debug::LogEntry($db, "audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); | 477 | Debug::LogEntry($db, "audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); |
4347 | 379 | } | 478 | } |
4348 | 380 | 479 | ||
4349 | @@ -383,6 +482,15 @@ | |||
4350 | 383 | FROM `display` | 482 | FROM `display` |
4351 | 384 | WHERE `licensed` = '1'"; | 483 | WHERE `licensed` = '1'"; |
4352 | 385 | 484 | ||
4353 | 485 | ======= | ||
4354 | 486 | Debug::LogEntry($db, "audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); | ||
4355 | 487 | } | ||
4356 | 488 | |||
4357 | 489 | // Retrieve number of displays | ||
4358 | 490 | $SQL = "SELECT COUNT(*) | ||
4359 | 491 | FROM `display` | ||
4360 | 492 | WHERE `licensed` = '1'"; | ||
4361 | 493 | >>>>>>> MERGE-SOURCE | ||
4362 | 386 | if (!$results = $db->query($SQL)) | 494 | if (!$results = $db->query($SQL)) |
4363 | 387 | { | 495 | { |
4364 | 388 | trigger_error($db->error()); | 496 | trigger_error($db->error()); |
4365 | @@ -390,6 +498,7 @@ | |||
4366 | 390 | while ($row = $db->get_row($results)) | 498 | while ($row = $db->get_row($results)) |
4367 | 391 | { | 499 | { |
4368 | 392 | $PHONE_HOME_CLIENTS = Kit::ValidateParam($row[0],_INT); | 500 | $PHONE_HOME_CLIENTS = Kit::ValidateParam($row[0],_INT); |
4369 | 501 | <<<<<<< TREE | ||
4370 | 393 | } | 502 | } |
4371 | 394 | 503 | ||
4372 | 395 | // Retrieve version number | 504 | // Retrieve version number |
4373 | @@ -398,9 +507,20 @@ | |||
4374 | 398 | $PHONE_HOME_URL = Config::GetSetting($db,'PHONE_HOME_URL') . "?id=" . urlencode(Config::GetSetting($db,'PHONE_HOME_KEY')) . "&version=" . urlencode($PHONE_HOME_VERSION) . "&numClients=" . urlencode($PHONE_HOME_CLIENTS); | 507 | $PHONE_HOME_URL = Config::GetSetting($db,'PHONE_HOME_URL') . "?id=" . urlencode(Config::GetSetting($db,'PHONE_HOME_KEY')) . "&version=" . urlencode($PHONE_HOME_VERSION) . "&numClients=" . urlencode($PHONE_HOME_CLIENTS); |
4375 | 399 | 508 | ||
4376 | 400 | if ($displayInfo['isAuditing'] == 1) | 509 | if ($displayInfo['isAuditing'] == 1) |
4377 | 510 | ======= | ||
4378 | 511 | } | ||
4379 | 512 | |||
4380 | 513 | // Retrieve version number | ||
4381 | 514 | $PHONE_HOME_VERSION = Config::Version($db, 'app_ver'); | ||
4382 | 515 | |||
4383 | 516 | $PHONE_HOME_URL = Config::GetSetting($db,'PHONE_HOME_URL') . "?id=" . urlencode(Config::GetSetting($db,'PHONE_HOME_KEY')) . "&version=" . urlencode($PHONE_HOME_VERSION) . "&numClients=" . urlencode($PHONE_HOME_CLIENTS); | ||
4384 | 517 | |||
4385 | 518 | if ($displayInfo['isAuditing'] == 1) | ||
4386 | 519 | >>>>>>> MERGE-SOURCE | ||
4387 | 401 | { | 520 | { |
4389 | 402 | Debug::LogEntry($db, "audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles"); | 521 | Debug::LogEntry($db, "audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles"); |
4390 | 403 | } | 522 | } |
4391 | 523 | <<<<<<< TREE | ||
4392 | 404 | 524 | ||
4393 | 405 | 525 | ||
4394 | 406 | // Set PHONE_HOME_TIME to NOW. | 526 | // Set PHONE_HOME_TIME to NOW. |
4395 | @@ -408,28 +528,42 @@ | |||
4396 | 408 | SET `value` = '" . time() . "' | 528 | SET `value` = '" . time() . "' |
4397 | 409 | WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1"; | 529 | WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1"; |
4398 | 410 | 530 | ||
4399 | 531 | ======= | ||
4400 | 532 | |||
4401 | 533 | // Set PHONE_HOME_TIME to NOW. | ||
4402 | 534 | $SQL = "UPDATE `setting` | ||
4403 | 535 | SET `value` = '" . time() . "' | ||
4404 | 536 | WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1"; | ||
4405 | 537 | |||
4406 | 538 | >>>>>>> MERGE-SOURCE | ||
4407 | 411 | if (!$results = $db->query($SQL)) | 539 | if (!$results = $db->query($SQL)) |
4408 | 412 | { | 540 | { |
4409 | 413 | trigger_error($db->error()); | 541 | trigger_error($db->error()); |
4410 | 414 | } | 542 | } |
4412 | 415 | 543 | ||
4413 | 416 | @file_get_contents($PHONE_HOME_URL); | 544 | @file_get_contents($PHONE_HOME_URL); |
4414 | 417 | 545 | ||
4416 | 418 | if ($displayInfo['isAuditing'] == 1) | 546 | if ($displayInfo['isAuditing'] == 1) |
4417 | 419 | { | 547 | { |
4419 | 420 | Debug::LogEntry($db, "audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles"); | 548 | Debug::LogEntry($db, "audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles"); |
4420 | 421 | } | 549 | } |
4421 | 422 | //endif | 550 | //endif |
4422 | 423 | } | 551 | } |
4423 | 424 | } | 552 | } |
4424 | 553 | <<<<<<< TREE | ||
4425 | 425 | // END OF PHONE_HOME CODE | 554 | // END OF PHONE_HOME CODE |
4426 | 426 | 555 | ||
4427 | 427 | if ($displayInfo['isAuditing'] == 1) | 556 | if ($displayInfo['isAuditing'] == 1) |
4428 | 557 | ======= | ||
4429 | 558 | // END OF PHONE_HOME CODE | ||
4430 | 559 | |||
4431 | 560 | if ($displayInfo['isAuditing'] == 1) | ||
4432 | 561 | >>>>>>> MERGE-SOURCE | ||
4433 | 428 | { | 562 | { |
4436 | 429 | Debug::LogEntry($db, "audit", $requiredFilesXml->saveXML(), "xmds", "RequiredFiles"); | 563 | Debug::LogEntry($db, "audit", $requiredFilesXml->saveXML(), "xmds", "RequiredFiles"); |
4437 | 430 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RequiredFiles"); | 564 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RequiredFiles"); |
4438 | 431 | } | 565 | } |
4440 | 432 | 566 | ||
4441 | 433 | // Return the results of requiredFiles() | 567 | // Return the results of requiredFiles() |
4442 | 434 | $requiredFilesXml->formatOutput = true; | 568 | $requiredFilesXml->formatOutput = true; |
4443 | 435 | 569 | ||
4444 | @@ -438,7 +572,7 @@ | |||
4445 | 438 | 572 | ||
4446 | 439 | /** | 573 | /** |
4447 | 440 | * Gets the specified file | 574 | * Gets the specified file |
4449 | 441 | * @return | 575 | * @return |
4450 | 442 | * @param $hardwareKey Object | 576 | * @param $hardwareKey Object |
4451 | 443 | * @param $filePath Object | 577 | * @param $filePath Object |
4452 | 444 | * @param $fileType Object | 578 | * @param $fileType Object |
4453 | @@ -446,7 +580,7 @@ | |||
4454 | 446 | function GetFile($serverKey, $hardwareKey, $filePath, $fileType, $chunkOffset, $chunkSize, $version) | 580 | function GetFile($serverKey, $hardwareKey, $filePath, $fileType, $chunkOffset, $chunkSize, $version) |
4455 | 447 | { | 581 | { |
4456 | 448 | global $db; | 582 | global $db; |
4458 | 449 | 583 | ||
4459 | 450 | // Sanitize | 584 | // Sanitize |
4460 | 451 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 585 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4461 | 452 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 586 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4462 | @@ -454,83 +588,83 @@ | |||
4463 | 454 | $chunkOffset = Kit::ValidateParam($chunkOffset, _INT); | 588 | $chunkOffset = Kit::ValidateParam($chunkOffset, _INT); |
4464 | 455 | $chunkSize = Kit::ValidateParam($chunkSize, _INT); | 589 | $chunkSize = Kit::ValidateParam($chunkSize, _INT); |
4465 | 456 | $version = Kit::ValidateParam($version, _STRING); | 590 | $version = Kit::ValidateParam($version, _STRING); |
4467 | 457 | 591 | ||
4468 | 458 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); | 592 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4470 | 459 | 593 | ||
4471 | 460 | // Make sure we are talking the same language | 594 | // Make sure we are talking the same language |
4472 | 461 | if (!CheckVersion($version)) | 595 | if (!CheckVersion($version)) |
4473 | 462 | { | 596 | { |
4474 | 463 | return new soap_fault("SOAP-ENV:Client", "", "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk", $serverKey); | 597 | return new soap_fault("SOAP-ENV:Client", "", "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk", $serverKey); |
4475 | 464 | } | 598 | } |
4477 | 465 | 599 | ||
4478 | 466 | //auth this request... | 600 | //auth this request... |
4479 | 467 | if (!$displayInfo = Auth($hardwareKey)) | 601 | if (!$displayInfo = Auth($hardwareKey)) |
4480 | 468 | { | 602 | { |
4481 | 469 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); | 603 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); |
4482 | 470 | } | 604 | } |
4485 | 471 | 605 | ||
4486 | 472 | if ($displayInfo['isAuditing'] == 1) | 606 | if ($displayInfo['isAuditing'] == 1) |
4487 | 473 | { | 607 | { |
4490 | 474 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "GetFile"); | 608 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "GetFile"); |
4491 | 475 | Debug::LogEntry($db, "audit", "Params: [$hardwareKey] [$filePath] [$fileType] [$chunkOffset] [$chunkSize]", "xmds", "GetFile"); | 609 | Debug::LogEntry($db, "audit", "Params: [$hardwareKey] [$filePath] [$fileType] [$chunkOffset] [$chunkSize]", "xmds", "GetFile"); |
4492 | 476 | } | 610 | } |
4493 | 477 | 611 | ||
4494 | 478 | if ($fileType == "layout") | 612 | if ($fileType == "layout") |
4495 | 479 | { | 613 | { |
4496 | 480 | $filePath = Kit::ValidateParam($filePath, _INT); | 614 | $filePath = Kit::ValidateParam($filePath, _INT); |
4498 | 481 | 615 | ||
4499 | 482 | $SQL = sprintf("SELECT xml FROM layout WHERE layoutid = %d", $filePath); | 616 | $SQL = sprintf("SELECT xml FROM layout WHERE layoutid = %d", $filePath); |
4500 | 483 | if (!$results = $db->query($SQL)) | 617 | if (!$results = $db->query($SQL)) |
4501 | 484 | { | 618 | { |
4502 | 485 | trigger_error($db->error()); | 619 | trigger_error($db->error()); |
4503 | 486 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); | 620 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); |
4504 | 487 | } | 621 | } |
4506 | 488 | 622 | ||
4507 | 489 | $row = $db->get_row($results); | 623 | $row = $db->get_row($results); |
4509 | 490 | 624 | ||
4510 | 491 | $file = $row[0]; | 625 | $file = $row[0]; |
4511 | 492 | } | 626 | } |
4512 | 493 | elseif ($fileType == "media") | 627 | elseif ($fileType == "media") |
4513 | 494 | { | 628 | { |
4514 | 495 | $filePath = Kit::ValidateParam($filePath, _STRING); | 629 | $filePath = Kit::ValidateParam($filePath, _STRING); |
4516 | 496 | 630 | ||
4517 | 497 | //Return the Chunk size specified | 631 | //Return the Chunk size specified |
4518 | 498 | $f = fopen($libraryLocation.$filePath,"r"); | 632 | $f = fopen($libraryLocation.$filePath,"r"); |
4520 | 499 | 633 | ||
4521 | 500 | fseek($f, $chunkOffset); | 634 | fseek($f, $chunkOffset); |
4523 | 501 | 635 | ||
4524 | 502 | $file = fread($f, $chunkSize); | 636 | $file = fread($f, $chunkSize); |
4525 | 503 | } | 637 | } |
4527 | 504 | else | 638 | else |
4528 | 505 | { | 639 | { |
4529 | 506 | return new soap_fault("SOAP-ENV:Client", "", "Unknown FileType Requested."); | 640 | return new soap_fault("SOAP-ENV:Client", "", "Unknown FileType Requested."); |
4530 | 507 | } | 641 | } |
4534 | 508 | 642 | ||
4535 | 509 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "GetFile"); | 643 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "GetFile"); |
4536 | 510 | 644 | ||
4537 | 511 | return base64_encode($file); | 645 | return base64_encode($file); |
4538 | 512 | } | 646 | } |
4539 | 513 | 647 | ||
4540 | 514 | /** | 648 | /** |
4541 | 515 | * Returns the schedule for the hardware key specified | 649 | * Returns the schedule for the hardware key specified |
4543 | 516 | * @return | 650 | * @return |
4544 | 517 | * @param $hardwareKey Object | 651 | * @param $hardwareKey Object |
4545 | 518 | */ | 652 | */ |
4546 | 519 | function Schedule($serverKey, $hardwareKey, $version) | 653 | function Schedule($serverKey, $hardwareKey, $version) |
4547 | 520 | { | 654 | { |
4548 | 521 | global $db; | 655 | global $db; |
4550 | 522 | 656 | ||
4551 | 523 | // Sanitize | 657 | // Sanitize |
4552 | 524 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 658 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4553 | 525 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 659 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4554 | 526 | $version = Kit::ValidateParam($version, _STRING); | 660 | $version = Kit::ValidateParam($version, _STRING); |
4556 | 527 | 661 | ||
4557 | 528 | // Make sure we are talking the same language | 662 | // Make sure we are talking the same language |
4558 | 529 | if (!CheckVersion($version)) | 663 | if (!CheckVersion($version)) |
4559 | 530 | { | 664 | { |
4560 | 531 | return new soap_fault("SOAP-ENV:Client", "", "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk", $serverKey); | 665 | return new soap_fault("SOAP-ENV:Client", "", "Your client is not of the correct version for communication with this server. You can get the latest from http://www.xibo.org.uk", $serverKey); |
4561 | 532 | } | 666 | } |
4563 | 533 | 667 | ||
4564 | 534 | //auth this request... | 668 | //auth this request... |
4565 | 535 | if (!$displayInfo = Auth($hardwareKey)) | 669 | if (!$displayInfo = Auth($hardwareKey)) |
4566 | 536 | { | 670 | { |
4567 | @@ -538,34 +672,49 @@ | |||
4568 | 538 | } | 672 | } |
4569 | 539 | 673 | ||
4570 | 540 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[IN] $hardwareKey", "xmds", "Schedule"); | 674 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[IN] $hardwareKey", "xmds", "Schedule"); |
4572 | 541 | 675 | ||
4573 | 542 | $scheduleXml = new DOMDocument("1.0"); | 676 | $scheduleXml = new DOMDocument("1.0"); |
4574 | 543 | $layoutElements = $scheduleXml->createElement("schedule"); | 677 | $layoutElements = $scheduleXml->createElement("schedule"); |
4576 | 544 | 678 | ||
4577 | 545 | $scheduleXml->appendChild($layoutElements); | 679 | $scheduleXml->appendChild($layoutElements); |
4578 | 680 | <<<<<<< TREE | ||
4579 | 546 | 681 | ||
4580 | 547 | $currentdate = time(); | 682 | $currentdate = time(); |
4581 | 548 | $infinityFromDT = mktime(0,0,0,1,1,2000); | 683 | $infinityFromDT = mktime(0,0,0,1,1,2000); |
4582 | 549 | $infinityToDT = mktime(0,0,0,12,31,2050); | 684 | $infinityToDT = mktime(0,0,0,12,31,2050); |
4583 | 550 | $plus4hours = $currentdate + 86400; | 685 | $plus4hours = $currentdate + 86400; |
4584 | 551 | 686 | ||
4585 | 687 | ======= | ||
4586 | 688 | |||
4587 | 689 | $currentdate = date("Y-m-d H:i:s"); | ||
4588 | 690 | $time = time(); | ||
4589 | 691 | $plus4hours = date("Y-m-d H:i:s",$time + 86400); | ||
4590 | 692 | |||
4591 | 693 | >>>>>>> MERGE-SOURCE | ||
4592 | 552 | //Add file nodes to the $fileElements | 694 | //Add file nodes to the $fileElements |
4593 | 553 | //Firstly get all the scheduled layouts | 695 | //Firstly get all the scheduled layouts |
4594 | 554 | $SQL = " SELECT layout.layoutID, schedule_detail.FromDT, schedule_detail.ToDT, schedule_detail.eventID "; | 696 | $SQL = " SELECT layout.layoutID, schedule_detail.FromDT, schedule_detail.ToDT, schedule_detail.eventID "; |
4595 | 555 | $SQL .= " FROM layout "; | 697 | $SQL .= " FROM layout "; |
4596 | 556 | $SQL .= " INNER JOIN schedule_detail ON schedule_detail.layoutID = layout.layoutID "; | 698 | $SQL .= " INNER JOIN schedule_detail ON schedule_detail.layoutID = layout.layoutID "; |
4597 | 699 | <<<<<<< TREE | ||
4598 | 557 | $SQL .= " INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = schedule_detail.DisplayGroupID "; | 700 | $SQL .= " INNER JOIN lkdisplaydg ON lkdisplaydg.DisplayGroupID = schedule_detail.DisplayGroupID "; |
4599 | 558 | $SQL .= " INNER JOIN display ON lkdisplaydg.DisplayID = display.displayID "; | 701 | $SQL .= " INNER JOIN display ON lkdisplaydg.DisplayID = display.displayID "; |
4600 | 559 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); | 702 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); |
4601 | 560 | 703 | ||
4602 | 704 | ======= | ||
4603 | 705 | $SQL .= " INNER JOIN display ON schedule_detail.displayID = display.displayID "; | ||
4604 | 706 | $SQL .= " WHERE display.license = '$hardwareKey' "; | ||
4605 | 707 | $SQL .= " AND layout.retired = 0 "; | ||
4606 | 708 | |||
4607 | 709 | >>>>>>> MERGE-SOURCE | ||
4608 | 561 | // Store the Base SQL for this display | 710 | // Store the Base SQL for this display |
4609 | 562 | $SQLBase = $SQL; | 711 | $SQLBase = $SQL; |
4611 | 563 | 712 | ||
4612 | 564 | // Run the query | 713 | // Run the query |
4613 | 565 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); | 714 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); |
4617 | 566 | 715 | ||
4618 | 567 | 716 | ||
4619 | 568 | 717 | ||
4620 | 569 | // Do we include the default display | 718 | // Do we include the default display |
4621 | 570 | if ($displayInfo['inc_schedule'] == 1) | 719 | if ($displayInfo['inc_schedule'] == 1) |
4622 | 571 | { | 720 | { |
4623 | @@ -576,20 +725,20 @@ | |||
4624 | 576 | { | 725 | { |
4625 | 577 | $SQL .= sprintf(" AND (schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d )", $currentdate, $currentdate); | 726 | $SQL .= sprintf(" AND (schedule_detail.FromDT < %d AND schedule_detail.ToDT > %d )", $currentdate, $currentdate); |
4626 | 578 | } | 727 | } |
4628 | 579 | 728 | ||
4629 | 580 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); | 729 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); |
4632 | 581 | 730 | ||
4633 | 582 | 731 | ||
4634 | 583 | // Before we run the main query we should check to see if there are any priority layouts to deal with | 732 | // Before we run the main query we should check to see if there are any priority layouts to deal with |
4635 | 584 | $SQLp = " AND schedule_detail.is_priority = 1 "; | 733 | $SQLp = " AND schedule_detail.is_priority = 1 "; |
4637 | 585 | 734 | ||
4638 | 586 | // Run the query | 735 | // Run the query |
4639 | 587 | if (!$results = $db->query($SQL . $SQLp)) | 736 | if (!$results = $db->query($SQL . $SQLp)) |
4640 | 588 | { | 737 | { |
4641 | 589 | trigger_error($db->error()); | 738 | trigger_error($db->error()); |
4642 | 590 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); | 739 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); |
4643 | 591 | } | 740 | } |
4645 | 592 | 741 | ||
4646 | 593 | // If there were no results then continue to get the full schedule | 742 | // If there were no results then continue to get the full schedule |
4647 | 594 | if ($db->num_rows($results) == 0) | 743 | if ($db->num_rows($results) == 0) |
4648 | 595 | { | 744 | { |
4649 | @@ -599,15 +748,21 @@ | |||
4650 | 599 | trigger_error($db->error()); | 748 | trigger_error($db->error()); |
4651 | 600 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); | 749 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); |
4652 | 601 | } | 750 | } |
4654 | 602 | 751 | ||
4655 | 603 | // Was there anything? | 752 | // Was there anything? |
4656 | 604 | if ($db->num_rows($results) == 0) | 753 | if ($db->num_rows($results) == 0) |
4657 | 605 | { | 754 | { |
4658 | 606 | // No rows, run the query for default layout | 755 | // No rows, run the query for default layout |
4659 | 607 | $SQL = $SQLBase; | 756 | $SQL = $SQLBase; |
4660 | 757 | <<<<<<< TREE | ||
4661 | 608 | $SQL .= " AND ((schedule_detail.FromDT < $currentdate AND schedule_detail.ToDT > $currentdate )"; | 758 | $SQL .= " AND ((schedule_detail.FromDT < $currentdate AND schedule_detail.ToDT > $currentdate )"; |
4662 | 609 | $SQL .= " OR (schedule_detail.FromDT = $infinityFromDT AND schedule_detail.ToDT = $infinityToDT ))"; | 759 | $SQL .= " OR (schedule_detail.FromDT = $infinityFromDT AND schedule_detail.ToDT = $infinityToDT ))"; |
4663 | 610 | 760 | ||
4664 | 761 | ======= | ||
4665 | 762 | $SQL .= " AND ((schedule_detail.starttime < '$currentdate' AND schedule_detail.endtime > '$currentdate' )"; | ||
4666 | 763 | $SQL .= " OR (schedule_detail.starttime = '2050-12-31 00:00:00' AND schedule_detail.endtime = '2050-12-31 00:00:00' ))"; | ||
4667 | 764 | |||
4668 | 765 | >>>>>>> MERGE-SOURCE | ||
4669 | 611 | if (!$results = $db->query($SQL)) | 766 | if (!$results = $db->query($SQL)) |
4670 | 612 | { | 767 | { |
4671 | 613 | trigger_error($db->error()); | 768 | trigger_error($db->error()); |
4672 | @@ -615,7 +770,7 @@ | |||
4673 | 615 | } | 770 | } |
4674 | 616 | } | 771 | } |
4675 | 617 | } | 772 | } |
4677 | 618 | 773 | ||
4678 | 619 | // We must have some results in here by this point | 774 | // We must have some results in here by this point |
4679 | 620 | while ($row = $db->get_row($results)) | 775 | while ($row = $db->get_row($results)) |
4680 | 621 | { | 776 | { |
4681 | @@ -623,44 +778,48 @@ | |||
4682 | 623 | $fromdt = date('Y-m-d h:i:s', $row[1]); | 778 | $fromdt = date('Y-m-d h:i:s', $row[1]); |
4683 | 624 | $todt = date('Y-m-d h:i:s', $row[2]); | 779 | $todt = date('Y-m-d h:i:s', $row[2]); |
4684 | 625 | $scheduleid = $row[3]; | 780 | $scheduleid = $row[3]; |
4686 | 626 | 781 | ||
4687 | 627 | //firstly add this as a node | 782 | //firstly add this as a node |
4688 | 628 | $layout = $scheduleXml->createElement("layout"); | 783 | $layout = $scheduleXml->createElement("layout"); |
4690 | 629 | 784 | ||
4691 | 630 | $layout->setAttribute("file", $layoutid); | 785 | $layout->setAttribute("file", $layoutid); |
4692 | 631 | $layout->setAttribute("fromdt", $fromdt); | 786 | $layout->setAttribute("fromdt", $fromdt); |
4693 | 632 | $layout->setAttribute("todt", $todt); | 787 | $layout->setAttribute("todt", $todt); |
4694 | 633 | $layout->setAttribute("scheduleid", $scheduleid); | 788 | $layout->setAttribute("scheduleid", $scheduleid); |
4696 | 634 | 789 | ||
4697 | 635 | $layoutElements->appendChild($layout); | 790 | $layoutElements->appendChild($layout); |
4698 | 636 | } | 791 | } |
4700 | 637 | 792 | ||
4701 | 638 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", $scheduleXml->saveXML(), "xmds", "Schedule"); | 793 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", $scheduleXml->saveXML(), "xmds", "Schedule"); |
4702 | 639 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "Schedule"); | 794 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "Schedule"); |
4703 | 795 | <<<<<<< TREE | ||
4704 | 640 | 796 | ||
4705 | 641 | $scheduleXml->formatOutput = true; | 797 | $scheduleXml->formatOutput = true; |
4706 | 642 | 798 | ||
4707 | 799 | ======= | ||
4708 | 800 | |||
4709 | 801 | >>>>>>> MERGE-SOURCE | ||
4710 | 643 | return $scheduleXml->saveXML(); | 802 | return $scheduleXml->saveXML(); |
4711 | 644 | } | 803 | } |
4712 | 645 | 804 | ||
4713 | 646 | /** | 805 | /** |
4714 | 647 | * Recieves the XmlLog from the display | 806 | * Recieves the XmlLog from the display |
4716 | 648 | * @return | 807 | * @return |
4717 | 649 | * @param $hardwareKey String | 808 | * @param $hardwareKey String |
4718 | 650 | * @param $xml String | 809 | * @param $xml String |
4719 | 651 | */ | 810 | */ |
4720 | 652 | function RecieveXmlLog($serverKey, $hardwareKey, $xml, $version) | 811 | function RecieveXmlLog($serverKey, $hardwareKey, $xml, $version) |
4721 | 653 | { | 812 | { |
4722 | 654 | global $db; | 813 | global $db; |
4724 | 655 | 814 | ||
4725 | 656 | return new soap_fault("SOAP-ENV:Client", "", "This is a depricated service call. You should instead call either SubmitLog or SubmitStats", $serverKey); | 815 | return new soap_fault("SOAP-ENV:Client", "", "This is a depricated service call. You should instead call either SubmitLog or SubmitStats", $serverKey); |
4726 | 657 | } | 816 | } |
4727 | 658 | 817 | ||
4728 | 659 | define('BLACKLIST_ALL', "All"); | 818 | define('BLACKLIST_ALL', "All"); |
4729 | 660 | define('BLACKLIST_SINGLE', "Single"); | 819 | define('BLACKLIST_SINGLE', "Single"); |
4730 | 661 | /** | 820 | /** |
4733 | 662 | * | 821 | * |
4734 | 663 | * @return | 822 | * @return |
4735 | 664 | * @param $hardwareKey Object | 823 | * @param $hardwareKey Object |
4736 | 665 | * @param $mediaId Object | 824 | * @param $mediaId Object |
4737 | 666 | * @param $type Object | 825 | * @param $type Object |
4738 | @@ -668,7 +827,7 @@ | |||
4739 | 668 | function BlackList($serverKey, $hardwareKey, $mediaId, $type, $reason, $version) | 827 | function BlackList($serverKey, $hardwareKey, $mediaId, $type, $reason, $version) |
4740 | 669 | { | 828 | { |
4741 | 670 | global $db; | 829 | global $db; |
4743 | 671 | 830 | ||
4744 | 672 | // Sanitize | 831 | // Sanitize |
4745 | 673 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 832 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4746 | 674 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 833 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4747 | @@ -676,7 +835,7 @@ | |||
4748 | 676 | $type = Kit::ValidateParam($type, _STRING); | 835 | $type = Kit::ValidateParam($type, _STRING); |
4749 | 677 | $reason = Kit::ValidateParam($reason, _STRING); | 836 | $reason = Kit::ValidateParam($reason, _STRING); |
4750 | 678 | $version = Kit::ValidateParam($version, _STRING); | 837 | $version = Kit::ValidateParam($version, _STRING); |
4752 | 679 | 838 | ||
4753 | 680 | // Make sure we are talking the same language | 839 | // Make sure we are talking the same language |
4754 | 681 | if (!CheckVersion($version)) | 840 | if (!CheckVersion($version)) |
4755 | 682 | { | 841 | { |
4756 | @@ -688,19 +847,19 @@ | |||
4757 | 688 | { | 847 | { |
4758 | 689 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); | 848 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); |
4759 | 690 | } | 849 | } |
4761 | 691 | 850 | ||
4762 | 692 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[IN]", "xmds", "BlackList", "", $displayInfo['displayid']); | 851 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[IN]", "xmds", "BlackList", "", $displayInfo['displayid']); |
4763 | 693 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "$xml", "xmds", "BlackList", "", $displayInfo['displayid']); | 852 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "$xml", "xmds", "BlackList", "", $displayInfo['displayid']); |
4765 | 694 | 853 | ||
4766 | 695 | // Check to see if this media/display is already blacklisted (and not ignored) | 854 | // Check to see if this media/display is already blacklisted (and not ignored) |
4767 | 696 | $SQL = "SELECT BlackListID FROM blacklist WHERE MediaID = $mediaId AND isIgnored = 0 AND DisplayID = " . $displayInfo['displayid']; | 855 | $SQL = "SELECT BlackListID FROM blacklist WHERE MediaID = $mediaId AND isIgnored = 0 AND DisplayID = " . $displayInfo['displayid']; |
4769 | 697 | 856 | ||
4770 | 698 | if (!$results = $db->query($SQL)) | 857 | if (!$results = $db->query($SQL)) |
4771 | 699 | { | 858 | { |
4772 | 700 | trigger_error($db->error()); | 859 | trigger_error($db->error()); |
4773 | 701 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList records.", $db->error()); | 860 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList records.", $db->error()); |
4774 | 702 | } | 861 | } |
4776 | 703 | 862 | ||
4777 | 704 | if ($db->num_rows($results) == 0) | 863 | if ($db->num_rows($results) == 0) |
4778 | 705 | { | 864 | { |
4779 | 706 | // Insert the black list record | 865 | // Insert the black list record |
4780 | @@ -711,20 +870,20 @@ | |||
4781 | 711 | // Only the current display | 870 | // Only the current display |
4782 | 712 | $SQL .= " WHERE displayID = " . $displayInfo['displayid']; | 871 | $SQL .= " WHERE displayID = " . $displayInfo['displayid']; |
4783 | 713 | } | 872 | } |
4785 | 714 | 873 | ||
4786 | 715 | if (!$displays = $db->query($SQL)) | 874 | if (!$displays = $db->query($SQL)) |
4787 | 716 | { | 875 | { |
4788 | 717 | trigger_error($db->error()); | 876 | trigger_error($db->error()); |
4789 | 718 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList Displays.", $db->error()); | 877 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList Displays.", $db->error()); |
4790 | 719 | } | 878 | } |
4792 | 720 | 879 | ||
4793 | 721 | while ($row = $db->get_row($displays)) | 880 | while ($row = $db->get_row($displays)) |
4794 | 722 | { | 881 | { |
4795 | 723 | $displayId = $row[0]; | 882 | $displayId = $row[0]; |
4797 | 724 | 883 | ||
4798 | 725 | $SQL = "INSERT INTO blacklist (MediaID, DisplayID, ReportingDisplayID, Reason) | 884 | $SQL = "INSERT INTO blacklist (MediaID, DisplayID, ReportingDisplayID, Reason) |
4799 | 726 | VALUES ($mediaId, $displayId, " . $displayInfo['displayid'] . ", '$reason') "; | 885 | VALUES ($mediaId, $displayId, " . $displayInfo['displayid'] . ", '$reason') "; |
4801 | 727 | 886 | ||
4802 | 728 | if (!$db->query($SQL)) | 887 | if (!$db->query($SQL)) |
4803 | 729 | { | 888 | { |
4804 | 730 | trigger_error($db->error()); | 889 | trigger_error($db->error()); |
4805 | @@ -736,15 +895,15 @@ | |||
4806 | 736 | { | 895 | { |
4807 | 737 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "Media Already BlackListed [$mediaId]", "xmds", "BlackList", "", $displayInfo['displayid']); | 896 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "Media Already BlackListed [$mediaId]", "xmds", "BlackList", "", $displayInfo['displayid']); |
4808 | 738 | } | 897 | } |
4810 | 739 | 898 | ||
4811 | 740 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[OUT]", "xmds", "BlackList", "", $displayInfo['displayid']); | 899 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[OUT]", "xmds", "BlackList", "", $displayInfo['displayid']); |
4813 | 741 | 900 | ||
4814 | 742 | return true; | 901 | return true; |
4815 | 743 | } | 902 | } |
4816 | 744 | 903 | ||
4817 | 745 | /** | 904 | /** |
4818 | 746 | * Submit client logging | 905 | * Submit client logging |
4820 | 747 | * @return | 906 | * @return |
4821 | 748 | * @param $version Object | 907 | * @param $version Object |
4822 | 749 | * @param $serverKey Object | 908 | * @param $serverKey Object |
4823 | 750 | * @param $hardwareKey Object | 909 | * @param $hardwareKey Object |
4824 | @@ -753,13 +912,13 @@ | |||
4825 | 753 | function SubmitLog($version, $serverKey, $hardwareKey, $logXml) | 912 | function SubmitLog($version, $serverKey, $hardwareKey, $logXml) |
4826 | 754 | { | 913 | { |
4827 | 755 | global $db; | 914 | global $db; |
4829 | 756 | 915 | ||
4830 | 757 | // Sanitize | 916 | // Sanitize |
4831 | 758 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 917 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4832 | 759 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 918 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4833 | 760 | $version = Kit::ValidateParam($version, _STRING); | 919 | $version = Kit::ValidateParam($version, _STRING); |
4834 | 761 | $logXml = Kit::ValidateParam($logXml, _HTMLSTRING); | 920 | $logXml = Kit::ValidateParam($logXml, _HTMLSTRING); |
4836 | 762 | 921 | ||
4837 | 763 | // Make sure we are talking the same language | 922 | // Make sure we are talking the same language |
4838 | 764 | if (!CheckVersion($version)) | 923 | if (!CheckVersion($version)) |
4839 | 765 | { | 924 | { |
4840 | @@ -771,20 +930,20 @@ | |||
4841 | 771 | { | 930 | { |
4842 | 772 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); | 931 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); |
4843 | 773 | } | 932 | } |
4845 | 774 | 933 | ||
4846 | 775 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitLog", "", $displayInfo['displayid']); | 934 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitLog", "", $displayInfo['displayid']); |
4847 | 776 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", 'XML [' . $logXml . ']', "xmds", "SubmitLog", "", $displayInfo['displayid']); | 935 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", 'XML [' . $logXml . ']', "xmds", "SubmitLog", "", $displayInfo['displayid']); |
4849 | 777 | 936 | ||
4850 | 778 | // Load the XML into a DOMDocument | 937 | // Load the XML into a DOMDocument |
4851 | 779 | $document = new DOMDocument("1.0"); | 938 | $document = new DOMDocument("1.0"); |
4853 | 780 | 939 | ||
4854 | 781 | if (!$document->loadXML($logXml)) | 940 | if (!$document->loadXML($logXml)) |
4855 | 782 | { | 941 | { |
4856 | 783 | return new soap_fault("SOAP-ENV:Client", "", "XML Cannot be loaded into DOM Document.", $hardwareKey); | 942 | return new soap_fault("SOAP-ENV:Client", "", "XML Cannot be loaded into DOM Document.", $hardwareKey); |
4857 | 784 | } | 943 | } |
4859 | 785 | 944 | ||
4860 | 786 | foreach ($document->documentElement->childNodes as $node) | 945 | foreach ($document->documentElement->childNodes as $node) |
4862 | 787 | { | 946 | { |
4863 | 788 | //Zero out the common vars | 947 | //Zero out the common vars |
4864 | 789 | $date = ""; | 948 | $date = ""; |
4865 | 790 | $message = ""; | 949 | $message = ""; |
4866 | @@ -793,23 +952,23 @@ | |||
4867 | 793 | $mediaID = ""; | 952 | $mediaID = ""; |
4868 | 794 | $cat = ''; | 953 | $cat = ''; |
4869 | 795 | $method = ''; | 954 | $method = ''; |
4871 | 796 | 955 | ||
4872 | 797 | // This will be a bunch of trace nodes | 956 | // This will be a bunch of trace nodes |
4873 | 798 | $message = $node->textContent; | 957 | $message = $node->textContent; |
4876 | 799 | 958 | ||
4877 | 800 | // Each element should have a category and a date | 959 | // Each element should have a category and a date |
4878 | 801 | $date = $node->getAttribute('date'); | 960 | $date = $node->getAttribute('date'); |
4879 | 802 | $cat = $node->getAttribute('category'); | 961 | $cat = $node->getAttribute('category'); |
4882 | 803 | 962 | ||
4883 | 804 | if ($date == '' || $cat == '') | 963 | if ($date == '' || $cat == '') |
4884 | 805 | { | 964 | { |
4885 | 806 | trigger_error('Log submitted without a date or category attribute'); | 965 | trigger_error('Log submitted without a date or category attribute'); |
4886 | 807 | continue; | 966 | continue; |
4887 | 808 | } | 967 | } |
4889 | 809 | 968 | ||
4890 | 810 | // Get the date and the message (all log types have these) | 969 | // Get the date and the message (all log types have these) |
4891 | 811 | foreach ($node->childNodes as $nodeElements) | 970 | foreach ($node->childNodes as $nodeElements) |
4893 | 812 | { | 971 | { |
4894 | 813 | if ($nodeElements->nodeName == "scheduleID") | 972 | if ($nodeElements->nodeName == "scheduleID") |
4895 | 814 | { | 973 | { |
4896 | 815 | $scheduleID = $nodeElements->textContent; | 974 | $scheduleID = $nodeElements->textContent; |
4897 | @@ -831,26 +990,26 @@ | |||
4898 | 831 | $method = $nodeElements->textContent; | 990 | $method = $nodeElements->textContent; |
4899 | 832 | } | 991 | } |
4900 | 833 | } | 992 | } |
4902 | 834 | 993 | ||
4903 | 835 | // We should have enough information to log this now. | 994 | // We should have enough information to log this now. |
4904 | 836 | if ($cat == 'error' || $cat == 'Error') | 995 | if ($cat == 'error' || $cat == 'Error') |
4905 | 837 | { | 996 | { |
4907 | 838 | Debug::LogEntry($db, $cat, $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); | 997 | Debug::LogEntry($db, $cat, $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); |
4908 | 839 | } | 998 | } |
4909 | 840 | else | 999 | else |
4910 | 841 | { | 1000 | { |
4912 | 842 | Debug::LogEntry($db, 'audit', $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); | 1001 | Debug::LogEntry($db, 'audit', $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); |
4913 | 843 | } | 1002 | } |
4914 | 844 | } | 1003 | } |
4915 | 845 | 1004 | ||
4916 | 846 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "OUT", "xmds", "SubmitLog", "", $displayInfo['displayid']); | 1005 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "OUT", "xmds", "SubmitLog", "", $displayInfo['displayid']); |
4918 | 847 | 1006 | ||
4919 | 848 | return true; | 1007 | return true; |
4920 | 849 | } | 1008 | } |
4921 | 850 | 1009 | ||
4922 | 851 | /** | 1010 | /** |
4923 | 852 | * Submit display statistics to the server | 1011 | * Submit display statistics to the server |
4925 | 853 | * @return | 1012 | * @return |
4926 | 854 | * @param $version Object | 1013 | * @param $version Object |
4927 | 855 | * @param $serverKey Object | 1014 | * @param $serverKey Object |
4928 | 856 | * @param $hardwareKey Object | 1015 | * @param $hardwareKey Object |
4929 | @@ -859,13 +1018,13 @@ | |||
4930 | 859 | function SubmitStats($version, $serverKey, $hardwareKey, $statXml) | 1018 | function SubmitStats($version, $serverKey, $hardwareKey, $statXml) |
4931 | 860 | { | 1019 | { |
4932 | 861 | global $db; | 1020 | global $db; |
4934 | 862 | 1021 | ||
4935 | 863 | // Sanitize | 1022 | // Sanitize |
4936 | 864 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 1023 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4937 | 865 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 1024 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4938 | 866 | $version = Kit::ValidateParam($version, _STRING); | 1025 | $version = Kit::ValidateParam($version, _STRING); |
4939 | 867 | $statXml = Kit::ValidateParam($statXml, _HTMLSTRING); | 1026 | $statXml = Kit::ValidateParam($statXml, _HTMLSTRING); |
4941 | 868 | 1027 | ||
4942 | 869 | // Make sure we are talking the same language | 1028 | // Make sure we are talking the same language |
4943 | 870 | if (!CheckVersion($version)) | 1029 | if (!CheckVersion($version)) |
4944 | 871 | { | 1030 | { |
4945 | @@ -877,55 +1036,55 @@ | |||
4946 | 877 | { | 1036 | { |
4947 | 878 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); | 1037 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); |
4948 | 879 | } | 1038 | } |
4950 | 880 | 1039 | ||
4951 | 881 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 1040 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4952 | 882 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "StatXml: [" . $statXml . "]", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 1041 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "StatXml: [" . $statXml . "]", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4954 | 883 | 1042 | ||
4955 | 884 | if ($statXml == "") | 1043 | if ($statXml == "") |
4956 | 885 | { | 1044 | { |
4957 | 886 | return new soap_fault("SOAP-ENV:Client", "", "Stat XML is empty.", $hardwareKey); | 1045 | return new soap_fault("SOAP-ENV:Client", "", "Stat XML is empty.", $hardwareKey); |
4958 | 887 | } | 1046 | } |
4960 | 888 | 1047 | ||
4961 | 889 | // Log | 1048 | // Log |
4962 | 890 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to create Stat Object.", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 1049 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to create Stat Object.", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4964 | 891 | 1050 | ||
4965 | 892 | $statObject = new Stat($db); | 1051 | $statObject = new Stat($db); |
4967 | 893 | 1052 | ||
4968 | 894 | // Log | 1053 | // Log |
4969 | 895 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to Create DOMDocument.", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 1054 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to Create DOMDocument.", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4971 | 896 | 1055 | ||
4972 | 897 | // Load the XML into a DOMDocument | 1056 | // Load the XML into a DOMDocument |
4973 | 898 | $document = new DOMDocument("1.0"); | 1057 | $document = new DOMDocument("1.0"); |
4974 | 899 | $document->loadXML($statXml); | 1058 | $document->loadXML($statXml); |
4976 | 900 | 1059 | ||
4977 | 901 | foreach ($document->documentElement->childNodes as $node) | 1060 | foreach ($document->documentElement->childNodes as $node) |
4979 | 902 | { | 1061 | { |
4980 | 903 | //Zero out the common vars | 1062 | //Zero out the common vars |
4981 | 904 | $fromdt = ''; | 1063 | $fromdt = ''; |
4982 | 905 | $todt = ''; | 1064 | $todt = ''; |
4983 | 906 | $type = ''; | 1065 | $type = ''; |
4985 | 907 | 1066 | ||
4986 | 908 | $scheduleID = 0; | 1067 | $scheduleID = 0; |
4987 | 909 | $layoutID = 0; | 1068 | $layoutID = 0; |
4988 | 910 | $mediaID = ''; | 1069 | $mediaID = ''; |
4989 | 911 | $tag = ''; | 1070 | $tag = ''; |
4991 | 912 | 1071 | ||
4992 | 913 | // Each element should have these attributes | 1072 | // Each element should have these attributes |
4993 | 914 | $fromdt = $node->getAttribute('fromdt'); | 1073 | $fromdt = $node->getAttribute('fromdt'); |
4994 | 915 | $todt = $node->getAttribute('todt'); | 1074 | $todt = $node->getAttribute('todt'); |
4995 | 916 | $type = $node->getAttribute('type'); | 1075 | $type = $node->getAttribute('type'); |
4998 | 917 | 1076 | ||
4999 | 918 | if ($fromdt == '' || $todt == '' || $type == '') | 1077 | if ($fromdt == '' || $todt == '' || $type == '') |
5000 | 919 | { | 1078 | { |
The diff has been truncated for viewing.