Merge lp:~dangarner/xibo/store-media-md5 into lp:xibo/1.0
- store-media-md5
- Merge into halley
Proposed by
Dan Garner
Status: | Merged |
---|---|
Approved by: | Dan Garner |
Approved revision: | 68 |
Merged at revision: | not available |
Proposed branch: | lp:~dangarner/xibo/store-media-md5 |
Merge into: | lp:xibo/1.0 |
Diff against target: |
5012 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 (+255/-236) |
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+12624@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:24 +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:24 +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:24 +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:24 +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:24 +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-08-08 11:04:39 +0000 | |||
3826 | +++ server/xmds.php 2009-09-29 22:15:24 +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,71 +29,71 @@ | |||
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 | $time = date("Y-m-d H:i:s", time()); | 56 | $time = date("Y-m-d H:i:s", time()); |
3873 | 57 | 57 | ||
3874 | 58 | //Set the last accessed flag on the display | 58 | //Set the last accessed flag on the display |
3875 | 59 | $SQL = "UPDATE display SET lastaccessed = '$time', loggedin = 1 WHERE license = '$hardwareKey' "; | 59 | $SQL = "UPDATE display SET lastaccessed = '$time', loggedin = 1 WHERE license = '$hardwareKey' "; |
3877 | 60 | if (!$result = $db->query($SQL)) | 60 | if (!$result = $db->query($SQL)) |
3878 | 61 | { | 61 | { |
3879 | 62 | trigger_error("Display update access failure: " .$db->error()); | 62 | trigger_error("Display update access failure: " .$db->error()); |
3880 | 63 | } | 63 | } |
3882 | 64 | 64 | ||
3883 | 65 | //It is licensed | 65 | //It is licensed |
3884 | 66 | return array("licensed" => true, "inc_schedule" => $row[1], "isAuditing" => $row[2], "displayid" => $row[3]); | 66 | return array("licensed" => true, "inc_schedule" => $row[1], "isAuditing" => $row[2], "displayid" => $row[3]); |
3885 | 67 | } | 67 | } |
3886 | 68 | } | 68 | } |
3888 | 69 | 69 | ||
3889 | 70 | return false; | 70 | return false; |
3890 | 71 | } | 71 | } |
3891 | 72 | 72 | ||
3892 | 73 | /** | 73 | /** |
3893 | 74 | * Checks that the calling service is talking the correct version | 74 | * Checks that the calling service is talking the correct version |
3895 | 75 | * @return | 75 | * @return |
3896 | 76 | * @param $version Object | 76 | * @param $version Object |
3897 | 77 | */ | 77 | */ |
3898 | 78 | function CheckVersion($version) | 78 | function CheckVersion($version) |
3899 | 79 | { | 79 | { |
3900 | 80 | global $db; | 80 | global $db; |
3902 | 81 | 81 | ||
3903 | 82 | // Look up the Service XMDS version from the Version table | 82 | // Look up the Service XMDS version from the Version table |
3904 | 83 | $serverVersion = Config::Version($db, 'XmdsVersion'); | 83 | $serverVersion = Config::Version($db, 'XmdsVersion'); |
3906 | 84 | 84 | ||
3907 | 85 | if ($version != $serverVersion) | 85 | if ($version != $serverVersion) |
3908 | 86 | { | 86 | { |
3909 | 87 | Debug::LogEntry($db, 'audit', sprintf('A Client with an incorrect version connected. Client Version: [%s] Server Version [%s]', $version, $serverVersion)); | 87 | Debug::LogEntry($db, 'audit', sprintf('A Client with an incorrect version connected. Client Version: [%s] Server Version [%s]', $version, $serverVersion)); |
3910 | 88 | return false; | 88 | return false; |
3911 | 89 | } | 89 | } |
3913 | 90 | 90 | ||
3914 | 91 | return true; | 91 | return true; |
3915 | 92 | } | 92 | } |
3916 | 93 | 93 | ||
3917 | 94 | /** | 94 | /** |
3918 | 95 | * Registers the Display with the server - if there is an available slot | 95 | * Registers the Display with the server - if there is an available slot |
3920 | 96 | * @return | 96 | * @return |
3921 | 97 | * @param $serverKey Object | 97 | * @param $serverKey Object |
3922 | 98 | * @param $hardwareKey Object | 98 | * @param $hardwareKey Object |
3923 | 99 | * @param $displayName Object | 99 | * @param $displayName Object |
3924 | @@ -101,66 +101,66 @@ | |||
3925 | 101 | function RegisterDisplay($serverKey, $hardwareKey, $displayName, $version) | 101 | function RegisterDisplay($serverKey, $hardwareKey, $displayName, $version) |
3926 | 102 | { | 102 | { |
3927 | 103 | global $db; | 103 | global $db; |
3929 | 104 | 104 | ||
3930 | 105 | // Sanitize | 105 | // Sanitize |
3931 | 106 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 106 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
3932 | 107 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 107 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
3933 | 108 | $displayName = Kit::ValidateParam($displayName, _STRING); | 108 | $displayName = Kit::ValidateParam($displayName, _STRING); |
3934 | 109 | $version = Kit::ValidateParam($version, _STRING); | 109 | $version = Kit::ValidateParam($version, _STRING); |
3936 | 110 | 110 | ||
3937 | 111 | // Make sure we are talking the same language | 111 | // Make sure we are talking the same language |
3938 | 112 | if (!CheckVersion($version)) | 112 | if (!CheckVersion($version)) |
3939 | 113 | { | 113 | { |
3940 | 114 | 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); | 114 | 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); |
3941 | 115 | } | 115 | } |
3943 | 116 | 116 | ||
3944 | 117 | define('SERVER_KEY', Config::GetSetting($db, 'SERVER_KEY')); | 117 | define('SERVER_KEY', Config::GetSetting($db, 'SERVER_KEY')); |
3946 | 118 | 118 | ||
3947 | 119 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RegisterDisplay"); | 119 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RegisterDisplay"); |
3948 | 120 | Debug::LogEntry($db, "audit", "serverKey [$serverKey], hardwareKey [$hardwareKey], displayName [$displayName]", "xmds", "RegisterDisplay"); | 120 | Debug::LogEntry($db, "audit", "serverKey [$serverKey], hardwareKey [$hardwareKey], displayName [$displayName]", "xmds", "RegisterDisplay"); |
3950 | 121 | 121 | ||
3951 | 122 | //Check the serverKey matches the one we have stored in this servers lic.txt file | 122 | //Check the serverKey matches the one we have stored in this servers lic.txt file |
3952 | 123 | if ($serverKey != SERVER_KEY) | 123 | if ($serverKey != SERVER_KEY) |
3953 | 124 | { | 124 | { |
3954 | 125 | return new soap_fault("SOAP-ENV:Client", "", "The Server key you entered does not match with the server key at this address", $serverKey); | 125 | return new soap_fault("SOAP-ENV:Client", "", "The Server key you entered does not match with the server key at this address", $serverKey); |
3955 | 126 | } | 126 | } |
3957 | 127 | 127 | ||
3958 | 128 | // Check the Length of the hardwareKey | 128 | // Check the Length of the hardwareKey |
3959 | 129 | if (strlen($hardwareKey) > 40) | 129 | if (strlen($hardwareKey) > 40) |
3960 | 130 | { | 130 | { |
3961 | 131 | return new soap_fault("SOAP-ENV:Client", "", "The Hardware Key you sent was too long. Only 40 characters are allowed (SHA1).", $hardwareKey); | 131 | return new soap_fault("SOAP-ENV:Client", "", "The Hardware Key you sent was too long. Only 40 characters are allowed (SHA1).", $hardwareKey); |
3962 | 132 | } | 132 | } |
3964 | 133 | 133 | ||
3965 | 134 | //check in the database for this hardwareKey | 134 | //check in the database for this hardwareKey |
3966 | 135 | $SQL = "SELECT licensed, display FROM display WHERE license = '$hardwareKey'"; | 135 | $SQL = "SELECT licensed, display FROM display WHERE license = '$hardwareKey'"; |
3968 | 136 | if (!$result = $db->query($SQL)) | 136 | if (!$result = $db->query($SQL)) |
3969 | 137 | { | 137 | { |
3970 | 138 | trigger_error("License key query failed:" .$db->error()); | 138 | trigger_error("License key query failed:" .$db->error()); |
3971 | 139 | return new soap_fault("SOAP-ENV:Server", "", "License Key Query Failed, see server errorlog", $db->error()); | 139 | return new soap_fault("SOAP-ENV:Server", "", "License Key Query Failed, see server errorlog", $db->error()); |
3972 | 140 | } | 140 | } |
3974 | 141 | 141 | ||
3975 | 142 | //Is it there? | 142 | //Is it there? |
3977 | 143 | if ($db->num_rows($result) == 0) | 143 | if ($db->num_rows($result) == 0) |
3978 | 144 | { | 144 | { |
3979 | 145 | //Add this display record | 145 | //Add this display record |
3980 | 146 | $SQL = sprintf("INSERT INTO display (display, defaultlayoutid, license, licensed) VALUES ('%s', 1, '%s', 0)", $displayName, $hardwareKey); | 146 | $SQL = sprintf("INSERT INTO display (display, defaultlayoutid, license, licensed) VALUES ('%s', 1, '%s', 0)", $displayName, $hardwareKey); |
3982 | 147 | if (!$displayid = $db->insert_query($SQL)) | 147 | if (!$displayid = $db->insert_query($SQL)) |
3983 | 148 | { | 148 | { |
3984 | 149 | trigger_error($db->error()); | 149 | trigger_error($db->error()); |
3985 | 150 | return new soap_fault("SOAP-ENV:Server", "", "Error adding display"); | 150 | return new soap_fault("SOAP-ENV:Server", "", "Error adding display"); |
3986 | 151 | } | 151 | } |
3987 | 152 | $active = "Display added and is awaiting licensing approval from an Administrator"; | 152 | $active = "Display added and is awaiting licensing approval from an Administrator"; |
3988 | 153 | } | 153 | } |
3990 | 154 | else | 154 | else |
3991 | 155 | { | 155 | { |
3992 | 156 | //we have seen this display before, so check the licensed value | 156 | //we have seen this display before, so check the licensed value |
3993 | 157 | $row = $db->get_row($result); | 157 | $row = $db->get_row($result); |
3995 | 158 | if ($row[0] == 0) | 158 | if ($row[0] == 0) |
3996 | 159 | { | 159 | { |
3997 | 160 | //Its Not licensed | 160 | //Its Not licensed |
3998 | 161 | $active = "Display is awaiting licensing approval from an Administrator."; | 161 | $active = "Display is awaiting licensing approval from an Administrator."; |
3999 | 162 | } | 162 | } |
4001 | 163 | else | 163 | else |
4002 | 164 | { | 164 | { |
4003 | 165 | //It is licensed | 165 | //It is licensed |
4004 | 166 | //Now check the names | 166 | //Now check the names |
4005 | @@ -172,21 +172,21 @@ | |||
4006 | 172 | { | 172 | { |
4007 | 173 | //Update the name | 173 | //Update the name |
4008 | 174 | $SQL = sprintf("UPDATE display SET display = '%s' WHERE license = '%s' ", $displayName, $hardwareKey); | 174 | $SQL = sprintf("UPDATE display SET display = '%s' WHERE license = '%s' ", $displayName, $hardwareKey); |
4011 | 175 | 175 | ||
4012 | 176 | if (!$db->query($SQL)) | 176 | if (!$db->query($SQL)) |
4013 | 177 | { | 177 | { |
4014 | 178 | trigger_error($db->error()); | 178 | trigger_error($db->error()); |
4015 | 179 | return new soap_fault("SOAP-ENV:Server", "", "Error editing the display name"); | 179 | return new soap_fault("SOAP-ENV:Server", "", "Error editing the display name"); |
4016 | 180 | } | 180 | } |
4018 | 181 | 181 | ||
4019 | 182 | $active = "Changed display name from '{$row[1]}' to '$displayName' Display is active and ready to start."; | 182 | $active = "Changed display name from '{$row[1]}' to '$displayName' Display is active and ready to start."; |
4020 | 183 | } | 183 | } |
4021 | 184 | } | 184 | } |
4022 | 185 | } | 185 | } |
4027 | 186 | 186 | ||
4028 | 187 | Debug::LogEntry($db, "audit", "$active", "xmds", "RegisterDisplay"); | 187 | Debug::LogEntry($db, "audit", "$active", "xmds", "RegisterDisplay"); |
4029 | 188 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RegisterDisplay"); | 188 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RegisterDisplay"); |
4030 | 189 | 189 | ||
4031 | 190 | return $active; | 190 | return $active; |
4032 | 191 | } | 191 | } |
4033 | 192 | 192 | ||
4034 | @@ -198,12 +198,12 @@ | |||
4035 | 198 | function RequiredFiles($serverKey, $hardwareKey, $version) | 198 | function RequiredFiles($serverKey, $hardwareKey, $version) |
4036 | 199 | { | 199 | { |
4037 | 200 | global $db; | 200 | global $db; |
4039 | 201 | 201 | ||
4040 | 202 | // Sanitize | 202 | // Sanitize |
4041 | 203 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 203 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4042 | 204 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 204 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4043 | 205 | $version = Kit::ValidateParam($version, _STRING); | 205 | $version = Kit::ValidateParam($version, _STRING); |
4045 | 206 | 206 | ||
4046 | 207 | // Make sure we are talking the same language | 207 | // Make sure we are talking the same language |
4047 | 208 | if (!CheckVersion($version)) | 208 | if (!CheckVersion($version)) |
4048 | 209 | { | 209 | { |
4049 | @@ -211,29 +211,29 @@ | |||
4050 | 211 | } | 211 | } |
4051 | 212 | 212 | ||
4052 | 213 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); | 213 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4054 | 214 | 214 | ||
4055 | 215 | //auth this request... | 215 | //auth this request... |
4056 | 216 | if (!$displayInfo = Auth($hardwareKey)) | 216 | if (!$displayInfo = Auth($hardwareKey)) |
4057 | 217 | { | 217 | { |
4058 | 218 | trigger_error("This display is not licensed [$hardwareKey]"); | 218 | trigger_error("This display is not licensed [$hardwareKey]"); |
4059 | 219 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); | 219 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); |
4060 | 220 | } | 220 | } |
4063 | 221 | 221 | ||
4064 | 222 | if ($displayInfo['isAuditing'] == 1) | 222 | if ($displayInfo['isAuditing'] == 1) |
4065 | 223 | { | 223 | { |
4068 | 224 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RequiredFiles"); | 224 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "RequiredFiles"); |
4069 | 225 | Debug::LogEntry($db, "audit", "$hardwareKey", "xmds", "RequiredFiles"); | 225 | Debug::LogEntry($db, "audit", "$hardwareKey", "xmds", "RequiredFiles"); |
4070 | 226 | } | 226 | } |
4072 | 227 | 227 | ||
4073 | 228 | $requiredFilesXml = new DOMDocument("1.0"); | 228 | $requiredFilesXml = new DOMDocument("1.0"); |
4074 | 229 | $fileElements = $requiredFilesXml->createElement("files"); | 229 | $fileElements = $requiredFilesXml->createElement("files"); |
4076 | 230 | 230 | ||
4077 | 231 | $requiredFilesXml->appendChild($fileElements); | 231 | $requiredFilesXml->appendChild($fileElements); |
4079 | 232 | 232 | ||
4080 | 233 | $currentdate = date("Y-m-d H:i:s"); | 233 | $currentdate = date("Y-m-d H:i:s"); |
4081 | 234 | $time = time(); | 234 | $time = time(); |
4082 | 235 | $plus4hours = date("Y-m-d H:i:s",$time + 86400); | 235 | $plus4hours = date("Y-m-d H:i:s",$time + 86400); |
4084 | 236 | 236 | ||
4085 | 237 | //Add file nodes to the $fileElements | 237 | //Add file nodes to the $fileElements |
4086 | 238 | //Firstly get all the scheduled layouts | 238 | //Firstly get all the scheduled layouts |
4087 | 239 | $SQL = " SELECT layout.layoutID, schedule_detail.starttime, schedule_detail.endtime, layout.xml, layout.background "; | 239 | $SQL = " SELECT layout.layoutID, schedule_detail.starttime, schedule_detail.endtime, layout.xml, layout.background "; |
4088 | @@ -241,9 +241,9 @@ | |||
4089 | 241 | $SQL .= " INNER JOIN schedule_detail ON schedule_detail.layoutID = layout.layoutID "; | 241 | $SQL .= " INNER JOIN schedule_detail ON schedule_detail.layoutID = layout.layoutID "; |
4090 | 242 | $SQL .= " INNER JOIN display ON schedule_detail.displayID = display.displayID "; | 242 | $SQL .= " INNER JOIN display ON schedule_detail.displayID = display.displayID "; |
4091 | 243 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); | 243 | $SQL .= sprintf(" WHERE display.license = '%s' ", $hardwareKey); |
4093 | 244 | 244 | ||
4094 | 245 | $SQLBase = $SQL; | 245 | $SQLBase = $SQL; |
4096 | 246 | 246 | ||
4097 | 247 | //Do we include the default display | 247 | //Do we include the default display |
4098 | 248 | if ($displayInfo['inc_schedule'] == 1) | 248 | if ($displayInfo['inc_schedule'] == 1) |
4099 | 249 | { | 249 | { |
4100 | @@ -254,15 +254,15 @@ | |||
4101 | 254 | { | 254 | { |
4102 | 255 | $SQL .= sprintf(" AND (schedule_detail.starttime < '%s' AND schedule_detail.endtime > '%s' )", $plus4hours, $currentdate); | 255 | $SQL .= sprintf(" AND (schedule_detail.starttime < '%s' AND schedule_detail.endtime > '%s' )", $plus4hours, $currentdate); |
4103 | 256 | } | 256 | } |
4106 | 257 | 257 | ||
4107 | 258 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "RequiredFiles"); | 258 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "RequiredFiles"); |
4108 | 259 | 259 | ||
4109 | 260 | if (!$results = $db->query($SQL)) | 260 | if (!$results = $db->query($SQL)) |
4110 | 261 | { | 261 | { |
4111 | 262 | trigger_error($db->error()); | 262 | trigger_error($db->error()); |
4112 | 263 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); | 263 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); |
4113 | 264 | } | 264 | } |
4115 | 265 | 265 | ||
4116 | 266 | // Was there anything? | 266 | // Was there anything? |
4117 | 267 | if ($db->num_rows($results) == 0) | 267 | if ($db->num_rows($results) == 0) |
4118 | 268 | { | 268 | { |
4119 | @@ -270,119 +270,138 @@ | |||
4120 | 270 | $SQL = $SQLBase; | 270 | $SQL = $SQLBase; |
4121 | 271 | $SQL .= sprintf(" AND ((schedule_detail.starttime < '%s' AND schedule_detail.endtime > '%s' )", $plus4hours, $currentdate); | 271 | $SQL .= sprintf(" AND ((schedule_detail.starttime < '%s' AND schedule_detail.endtime > '%s' )", $plus4hours, $currentdate); |
4122 | 272 | $SQL .= " OR (schedule_detail.starttime = '2050-12-31 00:00:00' AND schedule_detail.endtime = '2050-12-31 00:00:00' ))"; | 272 | $SQL .= " OR (schedule_detail.starttime = '2050-12-31 00:00:00' AND schedule_detail.endtime = '2050-12-31 00:00:00' ))"; |
4124 | 273 | 273 | ||
4125 | 274 | if (!$results = $db->query($SQL)) | 274 | if (!$results = $db->query($SQL)) |
4126 | 275 | { | 275 | { |
4127 | 276 | trigger_error($db->error()); | 276 | trigger_error($db->error()); |
4128 | 277 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); | 277 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); |
4129 | 278 | } | 278 | } |
4130 | 279 | } | 279 | } |
4132 | 280 | 280 | ||
4133 | 281 | while ($row = $db->get_row($results)) | 281 | while ($row = $db->get_row($results)) |
4134 | 282 | { | 282 | { |
4135 | 283 | $layoutid = $row[0]; | 283 | $layoutid = $row[0]; |
4136 | 284 | $layoutXml = $row[3]; | 284 | $layoutXml = $row[3]; |
4137 | 285 | $background = $row[4]; | 285 | $background = $row[4]; |
4139 | 286 | 286 | ||
4140 | 287 | // Add all the associated media first | 287 | // Add all the associated media first |
4145 | 288 | $SQL = "SELECT storedAs, media.mediaID | 288 | $SQL = "SELECT storedAs, media.mediaID, media.`MD5`, media.FileSize |
4146 | 289 | FROM media | 289 | FROM media |
4147 | 290 | INNER JOIN lklayoutmedia ON lklayoutmedia.mediaID = media.mediaID | 290 | INNER JOIN lklayoutmedia ON lklayoutmedia.mediaID = media.mediaID |
4148 | 291 | WHERE storedAs IS NOT NULL | 291 | WHERE storedAs IS NOT NULL |
4149 | 292 | AND lklayoutmedia.layoutID = $layoutid | 292 | AND lklayoutmedia.layoutID = $layoutid |
4153 | 293 | AND media.mediaID NOT IN (SELECT MediaID | 293 | AND media.mediaID NOT IN (SELECT MediaID |
4154 | 294 | FROM blacklist | 294 | FROM blacklist |
4155 | 295 | WHERE DisplayID = " . $displayInfo['displayid'] . " | 295 | WHERE DisplayID = " . $displayInfo['displayid'] . " |
4156 | 296 | AND isIgnored = 0 )"; | 296 | AND isIgnored = 0 )"; |
4158 | 297 | 297 | ||
4159 | 298 | if (!$mediaResults = $db->query($SQL)) | 298 | if (!$mediaResults = $db->query($SQL)) |
4160 | 299 | { | 299 | { |
4161 | 300 | trigger_error($db->error()); | 300 | trigger_error($db->error()); |
4162 | 301 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of media for the layout [$layoutid]"); | 301 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of media for the layout [$layoutid]"); |
4163 | 302 | } | 302 | } |
4165 | 303 | 303 | ||
4166 | 304 | while ($row = $db->get_row($mediaResults)) | 304 | while ($row = $db->get_row($mediaResults)) |
4167 | 305 | { | 305 | { |
4168 | 306 | $storedAs = Kit::ValidateParam($row[0], _STRING); | ||
4169 | 307 | $mediaId = Kit::ValidateParam($row[1], _INT); | ||
4170 | 308 | $md5 = Kit::ValidateParam($row[2], _STRING); | ||
4171 | 309 | $fileSize = Kit::ValidateParam($row[3], _INT); | ||
4172 | 310 | |||
4173 | 311 | // If they are empty calculate them and save them back to the media. | ||
4174 | 312 | if ($md5 == '' || $fileSize == 0) | ||
4175 | 313 | { | ||
4176 | 314 | |||
4177 | 315 | $md5 = md5_file($libraryLocation.$row[0]); | ||
4178 | 316 | $fileSize = filesize($libraryLocation.$row[0]); | ||
4179 | 317 | |||
4180 | 318 | // Update the media record with this information | ||
4181 | 319 | $SQL = sprintf("UPDATE media SET `MD5` = '%s', FileSize = %d WHERE MediaID = %d", $md5, $fileSize, $mediaId); | ||
4182 | 320 | |||
4183 | 321 | if (!$db->query($SQL)) | ||
4184 | 322 | trigger_error($db->error()); | ||
4185 | 323 | } | ||
4186 | 324 | |||
4187 | 306 | //Add the file node | 325 | //Add the file node |
4188 | 307 | $file = $requiredFilesXml->createElement("file"); | 326 | $file = $requiredFilesXml->createElement("file"); |
4190 | 308 | 327 | ||
4191 | 309 | $file->setAttribute("type", "media"); | 328 | $file->setAttribute("type", "media"); |
4197 | 310 | $file->setAttribute("path", $row[0]); | 329 | $file->setAttribute("path", $storedAs); |
4198 | 311 | $file->setAttribute("id", $row[1]); | 330 | $file->setAttribute("id", $mediaId); |
4199 | 312 | $file->setAttribute("size", filesize($libraryLocation.$row[0])); | 331 | $file->setAttribute("size", $fileSize); |
4200 | 313 | $file->setAttribute("md5", md5_file($libraryLocation.$row[0])); | 332 | $file->setAttribute("md5", $md5); |
4201 | 314 | 333 | ||
4202 | 315 | $fileElements->appendChild($file); | 334 | $fileElements->appendChild($file); |
4203 | 316 | } | 335 | } |
4205 | 317 | 336 | ||
4206 | 318 | //Also append another file node for the background image (if there is one) | 337 | //Also append another file node for the background image (if there is one) |
4207 | 319 | if ($background != "") | 338 | if ($background != "") |
4208 | 320 | { | 339 | { |
4209 | 321 | //firstly add this as a node | 340 | //firstly add this as a node |
4210 | 322 | $file = $requiredFilesXml->createElement("file"); | 341 | $file = $requiredFilesXml->createElement("file"); |
4212 | 323 | 342 | ||
4213 | 324 | $file->setAttribute("type", "media"); | 343 | $file->setAttribute("type", "media"); |
4214 | 325 | $file->setAttribute("path", $background); | 344 | $file->setAttribute("path", $background); |
4215 | 326 | $file->setAttribute("md5", md5_file($libraryLocation.$background)); | 345 | $file->setAttribute("md5", md5_file($libraryLocation.$background)); |
4216 | 327 | $file->setAttribute("size", filesize($libraryLocation.$background)); | 346 | $file->setAttribute("size", filesize($libraryLocation.$background)); |
4218 | 328 | 347 | ||
4219 | 329 | $fileElements->appendChild($file); | 348 | $fileElements->appendChild($file); |
4220 | 330 | } | 349 | } |
4222 | 331 | 350 | ||
4223 | 332 | // Add this layout as node | 351 | // Add this layout as node |
4224 | 333 | $file = $requiredFilesXml->createElement("file"); | 352 | $file = $requiredFilesXml->createElement("file"); |
4226 | 334 | 353 | ||
4227 | 335 | $file->setAttribute("type", "layout"); | 354 | $file->setAttribute("type", "layout"); |
4228 | 336 | $file->setAttribute("path", $layoutid); | 355 | $file->setAttribute("path", $layoutid); |
4229 | 337 | $file->setAttribute("md5", md5($layoutXml . "\n")); | 356 | $file->setAttribute("md5", md5($layoutXml . "\n")); |
4231 | 338 | 357 | ||
4232 | 339 | $fileElements->appendChild($file); | 358 | $fileElements->appendChild($file); |
4233 | 340 | } | 359 | } |
4235 | 341 | 360 | ||
4236 | 342 | // | 361 | // |
4237 | 343 | // Add a blacklist node | 362 | // Add a blacklist node |
4238 | 344 | // | 363 | // |
4239 | 345 | $blackList = $requiredFilesXml->createElement("file"); | 364 | $blackList = $requiredFilesXml->createElement("file"); |
4240 | 346 | $blackList->setAttribute("type", "blacklist"); | 365 | $blackList->setAttribute("type", "blacklist"); |
4242 | 347 | 366 | ||
4243 | 348 | $fileElements->appendChild($blackList); | 367 | $fileElements->appendChild($blackList); |
4245 | 349 | 368 | ||
4246 | 350 | // Populate | 369 | // Populate |
4250 | 351 | $SQL = "SELECT MediaID | 370 | $SQL = "SELECT MediaID |
4251 | 352 | FROM blacklist | 371 | FROM blacklist |
4252 | 353 | WHERE DisplayID = " . $displayInfo['displayid'] . " | 372 | WHERE DisplayID = " . $displayInfo['displayid'] . " |
4253 | 354 | AND isIgnored = 0"; | 373 | AND isIgnored = 0"; |
4255 | 355 | 374 | ||
4256 | 356 | if (!$results = $db->query($SQL)) | 375 | if (!$results = $db->query($SQL)) |
4257 | 357 | { | 376 | { |
4258 | 358 | trigger_error($db->error()); | 377 | trigger_error($db->error()); |
4259 | 359 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of blacklisted files", $db->error()); | 378 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of blacklisted files", $db->error()); |
4260 | 360 | } | 379 | } |
4262 | 361 | 380 | ||
4263 | 362 | // Add a black list element for each file | 381 | // Add a black list element for each file |
4264 | 363 | while ($row = $db->get_row($results)) | 382 | while ($row = $db->get_row($results)) |
4265 | 364 | { | 383 | { |
4266 | 365 | $file = $requiredFilesXml->createElement("file"); | 384 | $file = $requiredFilesXml->createElement("file"); |
4267 | 366 | $file->setAttribute("id", $row[0]); | 385 | $file->setAttribute("id", $row[0]); |
4269 | 367 | 386 | ||
4270 | 368 | $blackList->appendChild($file); | 387 | $blackList->appendChild($file); |
4271 | 369 | } | 388 | } |
4272 | 370 | 389 | ||
4273 | 371 | // PHONE_HOME if required. | 390 | // PHONE_HOME if required. |
4277 | 372 | if (Config::GetSetting($db,'PHONE_HOME') == 'On') { | 391 | if (Config::GetSetting($db,'PHONE_HOME') == 'On') { |
4278 | 373 | // Find out when we last PHONED_HOME :D | 392 | // Find out when we last PHONED_HOME :D |
4279 | 374 | // If it's been > 28 days since last PHONE_HOME then | 393 | // If it's been > 28 days since last PHONE_HOME then |
4280 | 375 | if (Config::GetSetting($db,'PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28))) { | 394 | if (Config::GetSetting($db,'PHONE_HOME_DATE') < (time() - (60 * 60 * 24 * 28))) { |
4281 | 376 | 395 | ||
4283 | 377 | if ($displayInfo['isAuditing'] == 1) | 396 | if ($displayInfo['isAuditing'] == 1) |
4284 | 378 | { | 397 | { |
4292 | 379 | Debug::LogEntry($db, "audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); | 398 | Debug::LogEntry($db, "audit", "PHONE_HOME [IN]", "xmds", "RequiredFiles"); |
4293 | 380 | } | 399 | } |
4294 | 381 | 400 | ||
4295 | 382 | // Retrieve number of displays | 401 | // Retrieve number of displays |
4296 | 383 | $SQL = "SELECT COUNT(*) | 402 | $SQL = "SELECT COUNT(*) |
4297 | 384 | FROM `display` | 403 | FROM `display` |
4298 | 385 | WHERE `licensed` = '1'"; | 404 | WHERE `licensed` = '1'"; |
4299 | 386 | if (!$results = $db->query($SQL)) | 405 | if (!$results = $db->query($SQL)) |
4300 | 387 | { | 406 | { |
4301 | 388 | trigger_error($db->error()); | 407 | trigger_error($db->error()); |
4302 | @@ -390,52 +409,52 @@ | |||
4303 | 390 | while ($row = $db->get_row($results)) | 409 | while ($row = $db->get_row($results)) |
4304 | 391 | { | 410 | { |
4305 | 392 | $PHONE_HOME_CLIENTS = Kit::ValidateParam($row[0],_INT); | 411 | $PHONE_HOME_CLIENTS = Kit::ValidateParam($row[0],_INT); |
4314 | 393 | } | 412 | } |
4315 | 394 | 413 | ||
4316 | 395 | // Retrieve version number | 414 | // Retrieve version number |
4317 | 396 | $PHONE_HOME_VERSION = Config::Version($db, 'app_ver'); | 415 | $PHONE_HOME_VERSION = Config::Version($db, 'app_ver'); |
4318 | 397 | 416 | ||
4319 | 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); | 417 | $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); |
4320 | 399 | 418 | ||
4321 | 400 | if ($displayInfo['isAuditing'] == 1) | 419 | if ($displayInfo['isAuditing'] == 1) |
4322 | 401 | { | 420 | { |
4324 | 402 | Debug::LogEntry($db, "audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles"); | 421 | Debug::LogEntry($db, "audit", "PHONE_HOME_URL " . $PHONE_HOME_URL , "xmds", "RequiredFiles"); |
4325 | 403 | } | 422 | } |
4332 | 404 | 423 | ||
4333 | 405 | // Set PHONE_HOME_TIME to NOW. | 424 | // Set PHONE_HOME_TIME to NOW. |
4334 | 406 | $SQL = "UPDATE `setting` | 425 | $SQL = "UPDATE `setting` |
4335 | 407 | SET `value` = '" . time() . "' | 426 | SET `value` = '" . time() . "' |
4336 | 408 | WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1"; | 427 | WHERE `setting`.`setting` = 'PHONE_HOME_DATE' LIMIT 1"; |
4337 | 409 | 428 | ||
4338 | 410 | if (!$results = $db->query($SQL)) | 429 | if (!$results = $db->query($SQL)) |
4339 | 411 | { | 430 | { |
4340 | 412 | trigger_error($db->error()); | 431 | trigger_error($db->error()); |
4341 | 413 | } | 432 | } |
4343 | 414 | 433 | ||
4344 | 415 | @file_get_contents($PHONE_HOME_URL); | 434 | @file_get_contents($PHONE_HOME_URL); |
4345 | 416 | 435 | ||
4347 | 417 | if ($displayInfo['isAuditing'] == 1) | 436 | if ($displayInfo['isAuditing'] == 1) |
4348 | 418 | { | 437 | { |
4350 | 419 | Debug::LogEntry($db, "audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles"); | 438 | Debug::LogEntry($db, "audit", "PHONE_HOME [OUT]", "xmds", "RequiredFiles"); |
4351 | 420 | } | 439 | } |
4353 | 421 | //endif | 440 | //endif |
4354 | 422 | } | 441 | } |
4355 | 423 | } | 442 | } |
4359 | 424 | // END OF PHONE_HOME CODE | 443 | // END OF PHONE_HOME CODE |
4360 | 425 | 444 | ||
4361 | 426 | if ($displayInfo['isAuditing'] == 1) | 445 | if ($displayInfo['isAuditing'] == 1) |
4362 | 427 | { | 446 | { |
4365 | 428 | Debug::LogEntry($db, "audit", $requiredFilesXml->saveXML(), "xmds", "RequiredFiles"); | 447 | Debug::LogEntry($db, "audit", $requiredFilesXml->saveXML(), "xmds", "RequiredFiles"); |
4366 | 429 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RequiredFiles"); | 448 | Debug::LogEntry($db, "audit", "[OUT]", "xmds", "RequiredFiles"); |
4367 | 430 | } | 449 | } |
4369 | 431 | 450 | ||
4370 | 432 | // Return the results of requiredFiles() | 451 | // Return the results of requiredFiles() |
4371 | 433 | return $requiredFilesXml->saveXML(); | 452 | return $requiredFilesXml->saveXML(); |
4372 | 434 | } | 453 | } |
4373 | 435 | 454 | ||
4374 | 436 | /** | 455 | /** |
4375 | 437 | * Gets the specified file | 456 | * Gets the specified file |
4377 | 438 | * @return | 457 | * @return |
4378 | 439 | * @param $hardwareKey Object | 458 | * @param $hardwareKey Object |
4379 | 440 | * @param $filePath Object | 459 | * @param $filePath Object |
4380 | 441 | * @param $fileType Object | 460 | * @param $fileType Object |
4381 | @@ -443,7 +462,7 @@ | |||
4382 | 443 | function GetFile($serverKey, $hardwareKey, $filePath, $fileType, $chunkOffset, $chunkSize, $version) | 462 | function GetFile($serverKey, $hardwareKey, $filePath, $fileType, $chunkOffset, $chunkSize, $version) |
4383 | 444 | { | 463 | { |
4384 | 445 | global $db; | 464 | global $db; |
4386 | 446 | 465 | ||
4387 | 447 | // Sanitize | 466 | // Sanitize |
4388 | 448 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 467 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4389 | 449 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 468 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4390 | @@ -451,83 +470,83 @@ | |||
4391 | 451 | $chunkOffset = Kit::ValidateParam($chunkOffset, _INT); | 470 | $chunkOffset = Kit::ValidateParam($chunkOffset, _INT); |
4392 | 452 | $chunkSize = Kit::ValidateParam($chunkSize, _INT); | 471 | $chunkSize = Kit::ValidateParam($chunkSize, _INT); |
4393 | 453 | $version = Kit::ValidateParam($version, _STRING); | 472 | $version = Kit::ValidateParam($version, _STRING); |
4395 | 454 | 473 | ||
4396 | 455 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); | 474 | $libraryLocation = Config::GetSetting($db, "LIBRARY_LOCATION"); |
4398 | 456 | 475 | ||
4399 | 457 | // Make sure we are talking the same language | 476 | // Make sure we are talking the same language |
4400 | 458 | if (!CheckVersion($version)) | 477 | if (!CheckVersion($version)) |
4401 | 459 | { | 478 | { |
4402 | 460 | 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); | 479 | 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); |
4403 | 461 | } | 480 | } |
4405 | 462 | 481 | ||
4406 | 463 | //auth this request... | 482 | //auth this request... |
4407 | 464 | if (!$displayInfo = Auth($hardwareKey)) | 483 | if (!$displayInfo = Auth($hardwareKey)) |
4408 | 465 | { | 484 | { |
4409 | 466 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); | 485 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed"); |
4410 | 467 | } | 486 | } |
4413 | 468 | 487 | ||
4414 | 469 | if ($displayInfo['isAuditing'] == 1) | 488 | if ($displayInfo['isAuditing'] == 1) |
4415 | 470 | { | 489 | { |
4418 | 471 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "GetFile"); | 490 | Debug::LogEntry($db, "audit", "[IN]", "xmds", "GetFile"); |
4419 | 472 | Debug::LogEntry($db, "audit", "Params: [$hardwareKey] [$filePath] [$fileType] [$chunkOffset] [$chunkSize]", "xmds", "GetFile"); | 491 | Debug::LogEntry($db, "audit", "Params: [$hardwareKey] [$filePath] [$fileType] [$chunkOffset] [$chunkSize]", "xmds", "GetFile"); |
4420 | 473 | } | 492 | } |
4421 | 474 | 493 | ||
4422 | 475 | if ($fileType == "layout") | 494 | if ($fileType == "layout") |
4423 | 476 | { | 495 | { |
4424 | 477 | $filePath = Kit::ValidateParam($filePath, _INT); | 496 | $filePath = Kit::ValidateParam($filePath, _INT); |
4426 | 478 | 497 | ||
4427 | 479 | $SQL = sprintf("SELECT xml FROM layout WHERE layoutid = %d", $filePath); | 498 | $SQL = sprintf("SELECT xml FROM layout WHERE layoutid = %d", $filePath); |
4428 | 480 | if (!$results = $db->query($SQL)) | 499 | if (!$results = $db->query($SQL)) |
4429 | 481 | { | 500 | { |
4430 | 482 | trigger_error($db->error()); | 501 | trigger_error($db->error()); |
4431 | 483 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); | 502 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get a list of files", $db->error()); |
4432 | 484 | } | 503 | } |
4434 | 485 | 504 | ||
4435 | 486 | $row = $db->get_row($results); | 505 | $row = $db->get_row($results); |
4437 | 487 | 506 | ||
4438 | 488 | $file = $row[0]; | 507 | $file = $row[0]; |
4439 | 489 | } | 508 | } |
4440 | 490 | elseif ($fileType == "media") | 509 | elseif ($fileType == "media") |
4441 | 491 | { | 510 | { |
4442 | 492 | $filePath = Kit::ValidateParam($filePath, _STRING); | 511 | $filePath = Kit::ValidateParam($filePath, _STRING); |
4444 | 493 | 512 | ||
4445 | 494 | //Return the Chunk size specified | 513 | //Return the Chunk size specified |
4446 | 495 | $f = fopen($libraryLocation.$filePath,"r"); | 514 | $f = fopen($libraryLocation.$filePath,"r"); |
4448 | 496 | 515 | ||
4449 | 497 | fseek($f, $chunkOffset); | 516 | fseek($f, $chunkOffset); |
4451 | 498 | 517 | ||
4452 | 499 | $file = fread($f, $chunkSize); | 518 | $file = fread($f, $chunkSize); |
4453 | 500 | } | 519 | } |
4455 | 501 | else | 520 | else |
4456 | 502 | { | 521 | { |
4457 | 503 | return new soap_fault("SOAP-ENV:Client", "", "Unknown FileType Requested."); | 522 | return new soap_fault("SOAP-ENV:Client", "", "Unknown FileType Requested."); |
4458 | 504 | } | 523 | } |
4462 | 505 | 524 | ||
4463 | 506 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "GetFile"); | 525 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "GetFile"); |
4464 | 507 | 526 | ||
4465 | 508 | return base64_encode($file); | 527 | return base64_encode($file); |
4466 | 509 | } | 528 | } |
4467 | 510 | 529 | ||
4468 | 511 | /** | 530 | /** |
4469 | 512 | * Returns the schedule for the hardware key specified | 531 | * Returns the schedule for the hardware key specified |
4471 | 513 | * @return | 532 | * @return |
4472 | 514 | * @param $hardwareKey Object | 533 | * @param $hardwareKey Object |
4473 | 515 | */ | 534 | */ |
4474 | 516 | function Schedule($serverKey, $hardwareKey, $version) | 535 | function Schedule($serverKey, $hardwareKey, $version) |
4475 | 517 | { | 536 | { |
4476 | 518 | global $db; | 537 | global $db; |
4478 | 519 | 538 | ||
4479 | 520 | // Sanitize | 539 | // Sanitize |
4480 | 521 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 540 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4481 | 522 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 541 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4482 | 523 | $version = Kit::ValidateParam($version, _STRING); | 542 | $version = Kit::ValidateParam($version, _STRING); |
4484 | 524 | 543 | ||
4485 | 525 | // Make sure we are talking the same language | 544 | // Make sure we are talking the same language |
4486 | 526 | if (!CheckVersion($version)) | 545 | if (!CheckVersion($version)) |
4487 | 527 | { | 546 | { |
4488 | 528 | 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); | 547 | 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); |
4489 | 529 | } | 548 | } |
4491 | 530 | 549 | ||
4492 | 531 | //auth this request... | 550 | //auth this request... |
4493 | 532 | if (!$displayInfo = Auth($hardwareKey)) | 551 | if (!$displayInfo = Auth($hardwareKey)) |
4494 | 533 | { | 552 | { |
4495 | @@ -535,16 +554,16 @@ | |||
4496 | 535 | } | 554 | } |
4497 | 536 | 555 | ||
4498 | 537 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[IN] $hardwareKey", "xmds", "Schedule"); | 556 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[IN] $hardwareKey", "xmds", "Schedule"); |
4500 | 538 | 557 | ||
4501 | 539 | $scheduleXml = new DOMDocument("1.0"); | 558 | $scheduleXml = new DOMDocument("1.0"); |
4502 | 540 | $layoutElements = $scheduleXml->createElement("schedule"); | 559 | $layoutElements = $scheduleXml->createElement("schedule"); |
4504 | 541 | 560 | ||
4505 | 542 | $scheduleXml->appendChild($layoutElements); | 561 | $scheduleXml->appendChild($layoutElements); |
4507 | 543 | 562 | ||
4508 | 544 | $currentdate = date("Y-m-d H:i:s"); | 563 | $currentdate = date("Y-m-d H:i:s"); |
4509 | 545 | $time = time(); | 564 | $time = time(); |
4510 | 546 | $plus4hours = date("Y-m-d H:i:s",$time + 86400); | 565 | $plus4hours = date("Y-m-d H:i:s",$time + 86400); |
4512 | 547 | 566 | ||
4513 | 548 | //Add file nodes to the $fileElements | 567 | //Add file nodes to the $fileElements |
4514 | 549 | //Firstly get all the scheduled layouts | 568 | //Firstly get all the scheduled layouts |
4515 | 550 | $SQL = " SELECT layout.layoutID, schedule_detail.starttime, schedule_detail.endtime, schedule_detail.eventID "; | 569 | $SQL = " SELECT layout.layoutID, schedule_detail.starttime, schedule_detail.endtime, schedule_detail.eventID "; |
4516 | @@ -553,15 +572,15 @@ | |||
4517 | 553 | $SQL .= " INNER JOIN display ON schedule_detail.displayID = display.displayID "; | 572 | $SQL .= " INNER JOIN display ON schedule_detail.displayID = display.displayID "; |
4518 | 554 | $SQL .= " WHERE display.license = '$hardwareKey' "; | 573 | $SQL .= " WHERE display.license = '$hardwareKey' "; |
4519 | 555 | $SQL .= " AND layout.retired = 0 "; | 574 | $SQL .= " AND layout.retired = 0 "; |
4521 | 556 | 575 | ||
4522 | 557 | // Store the Base SQL for this display | 576 | // Store the Base SQL for this display |
4523 | 558 | $SQLBase = $SQL; | 577 | $SQLBase = $SQL; |
4525 | 559 | 578 | ||
4526 | 560 | // Run the query | 579 | // Run the query |
4527 | 561 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); | 580 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); |
4531 | 562 | 581 | ||
4532 | 563 | 582 | ||
4533 | 564 | 583 | ||
4534 | 565 | // Do we include the default display | 584 | // Do we include the default display |
4535 | 566 | if ($displayInfo['inc_schedule'] == 1) | 585 | if ($displayInfo['inc_schedule'] == 1) |
4536 | 567 | { | 586 | { |
4537 | @@ -572,20 +591,20 @@ | |||
4538 | 572 | { | 591 | { |
4539 | 573 | $SQL .= " AND (schedule_detail.starttime < '$currentdate' AND schedule_detail.endtime > '$currentdate' )"; | 592 | $SQL .= " AND (schedule_detail.starttime < '$currentdate' AND schedule_detail.endtime > '$currentdate' )"; |
4540 | 574 | } | 593 | } |
4542 | 575 | 594 | ||
4543 | 576 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); | 595 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "$SQL", "xmds", "Schedule"); |
4546 | 577 | 596 | ||
4547 | 578 | 597 | ||
4548 | 579 | // Before we run the main query we should check to see if there are any priority layouts to deal with | 598 | // Before we run the main query we should check to see if there are any priority layouts to deal with |
4549 | 580 | $SQLp = " AND schedule_detail.is_priority = 1 "; | 599 | $SQLp = " AND schedule_detail.is_priority = 1 "; |
4551 | 581 | 600 | ||
4552 | 582 | // Run the query | 601 | // Run the query |
4553 | 583 | if (!$results = $db->query($SQL . $SQLp)) | 602 | if (!$results = $db->query($SQL . $SQLp)) |
4554 | 584 | { | 603 | { |
4555 | 585 | trigger_error($db->error()); | 604 | trigger_error($db->error()); |
4556 | 586 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); | 605 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); |
4557 | 587 | } | 606 | } |
4559 | 588 | 607 | ||
4560 | 589 | // If there were no results then continue to get the full schedule | 608 | // If there were no results then continue to get the full schedule |
4561 | 590 | if ($db->num_rows($results) == 0) | 609 | if ($db->num_rows($results) == 0) |
4562 | 591 | { | 610 | { |
4563 | @@ -595,7 +614,7 @@ | |||
4564 | 595 | trigger_error($db->error()); | 614 | trigger_error($db->error()); |
4565 | 596 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); | 615 | return new soap_fault("SOAP-ENV:Server", "", "Unable to get A list of layouts for the schedule", $db->error()); |
4566 | 597 | } | 616 | } |
4568 | 598 | 617 | ||
4569 | 599 | // Was there anything? | 618 | // Was there anything? |
4570 | 600 | if ($db->num_rows($results) == 0) | 619 | if ($db->num_rows($results) == 0) |
4571 | 601 | { | 620 | { |
4572 | @@ -603,7 +622,7 @@ | |||
4573 | 603 | $SQL = $SQLBase; | 622 | $SQL = $SQLBase; |
4574 | 604 | $SQL .= " AND ((schedule_detail.starttime < '$currentdate' AND schedule_detail.endtime > '$currentdate' )"; | 623 | $SQL .= " AND ((schedule_detail.starttime < '$currentdate' AND schedule_detail.endtime > '$currentdate' )"; |
4575 | 605 | $SQL .= " OR (schedule_detail.starttime = '2050-12-31 00:00:00' AND schedule_detail.endtime = '2050-12-31 00:00:00' ))"; | 624 | $SQL .= " OR (schedule_detail.starttime = '2050-12-31 00:00:00' AND schedule_detail.endtime = '2050-12-31 00:00:00' ))"; |
4577 | 606 | 625 | ||
4578 | 607 | if (!$results = $db->query($SQL)) | 626 | if (!$results = $db->query($SQL)) |
4579 | 608 | { | 627 | { |
4580 | 609 | trigger_error($db->error()); | 628 | trigger_error($db->error()); |
4581 | @@ -611,7 +630,7 @@ | |||
4582 | 611 | } | 630 | } |
4583 | 612 | } | 631 | } |
4584 | 613 | } | 632 | } |
4586 | 614 | 633 | ||
4587 | 615 | // We must have some results in here by this point | 634 | // We must have some results in here by this point |
4588 | 616 | while ($row = $db->get_row($results)) | 635 | while ($row = $db->get_row($results)) |
4589 | 617 | { | 636 | { |
4590 | @@ -619,42 +638,42 @@ | |||
4591 | 619 | $fromdt = $row[1]; | 638 | $fromdt = $row[1]; |
4592 | 620 | $todt = $row[2]; | 639 | $todt = $row[2]; |
4593 | 621 | $scheduleid = $row[3]; | 640 | $scheduleid = $row[3]; |
4595 | 622 | 641 | ||
4596 | 623 | //firstly add this as a node | 642 | //firstly add this as a node |
4597 | 624 | $layout = $scheduleXml->createElement("layout"); | 643 | $layout = $scheduleXml->createElement("layout"); |
4599 | 625 | 644 | ||
4600 | 626 | $layout->setAttribute("file", $layoutid); | 645 | $layout->setAttribute("file", $layoutid); |
4601 | 627 | $layout->setAttribute("fromdt", $fromdt); | 646 | $layout->setAttribute("fromdt", $fromdt); |
4602 | 628 | $layout->setAttribute("todt", $todt); | 647 | $layout->setAttribute("todt", $todt); |
4603 | 629 | $layout->setAttribute("scheduleid", $scheduleid); | 648 | $layout->setAttribute("scheduleid", $scheduleid); |
4605 | 630 | 649 | ||
4606 | 631 | $layoutElements->appendChild($layout); | 650 | $layoutElements->appendChild($layout); |
4607 | 632 | } | 651 | } |
4609 | 633 | 652 | ||
4610 | 634 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", $scheduleXml->saveXML(), "xmds", "Schedule"); | 653 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", $scheduleXml->saveXML(), "xmds", "Schedule"); |
4611 | 635 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "Schedule"); | 654 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry($db, "audit", "[OUT]", "xmds", "Schedule"); |
4613 | 636 | 655 | ||
4614 | 637 | return $scheduleXml->saveXML(); | 656 | return $scheduleXml->saveXML(); |
4615 | 638 | } | 657 | } |
4616 | 639 | 658 | ||
4617 | 640 | /** | 659 | /** |
4618 | 641 | * Recieves the XmlLog from the display | 660 | * Recieves the XmlLog from the display |
4620 | 642 | * @return | 661 | * @return |
4621 | 643 | * @param $hardwareKey String | 662 | * @param $hardwareKey String |
4622 | 644 | * @param $xml String | 663 | * @param $xml String |
4623 | 645 | */ | 664 | */ |
4624 | 646 | function RecieveXmlLog($serverKey, $hardwareKey, $xml, $version) | 665 | function RecieveXmlLog($serverKey, $hardwareKey, $xml, $version) |
4625 | 647 | { | 666 | { |
4626 | 648 | global $db; | 667 | global $db; |
4628 | 649 | 668 | ||
4629 | 650 | return new soap_fault("SOAP-ENV:Client", "", "This is a depricated service call. You should instead call either SubmitLog or SubmitStats", $serverKey); | 669 | return new soap_fault("SOAP-ENV:Client", "", "This is a depricated service call. You should instead call either SubmitLog or SubmitStats", $serverKey); |
4630 | 651 | } | 670 | } |
4631 | 652 | 671 | ||
4632 | 653 | define('BLACKLIST_ALL', "All"); | 672 | define('BLACKLIST_ALL', "All"); |
4633 | 654 | define('BLACKLIST_SINGLE', "Single"); | 673 | define('BLACKLIST_SINGLE', "Single"); |
4634 | 655 | /** | 674 | /** |
4637 | 656 | * | 675 | * |
4638 | 657 | * @return | 676 | * @return |
4639 | 658 | * @param $hardwareKey Object | 677 | * @param $hardwareKey Object |
4640 | 659 | * @param $mediaId Object | 678 | * @param $mediaId Object |
4641 | 660 | * @param $type Object | 679 | * @param $type Object |
4642 | @@ -662,7 +681,7 @@ | |||
4643 | 662 | function BlackList($serverKey, $hardwareKey, $mediaId, $type, $reason, $version) | 681 | function BlackList($serverKey, $hardwareKey, $mediaId, $type, $reason, $version) |
4644 | 663 | { | 682 | { |
4645 | 664 | global $db; | 683 | global $db; |
4647 | 665 | 684 | ||
4648 | 666 | // Sanitize | 685 | // Sanitize |
4649 | 667 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 686 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4650 | 668 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 687 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4651 | @@ -670,7 +689,7 @@ | |||
4652 | 670 | $type = Kit::ValidateParam($type, _STRING); | 689 | $type = Kit::ValidateParam($type, _STRING); |
4653 | 671 | $reason = Kit::ValidateParam($reason, _STRING); | 690 | $reason = Kit::ValidateParam($reason, _STRING); |
4654 | 672 | $version = Kit::ValidateParam($version, _STRING); | 691 | $version = Kit::ValidateParam($version, _STRING); |
4656 | 673 | 692 | ||
4657 | 674 | // Make sure we are talking the same language | 693 | // Make sure we are talking the same language |
4658 | 675 | if (!CheckVersion($version)) | 694 | if (!CheckVersion($version)) |
4659 | 676 | { | 695 | { |
4660 | @@ -682,19 +701,19 @@ | |||
4661 | 682 | { | 701 | { |
4662 | 683 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); | 702 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); |
4663 | 684 | } | 703 | } |
4665 | 685 | 704 | ||
4666 | 686 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[IN]", "xmds", "BlackList", "", $displayInfo['displayid']); | 705 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[IN]", "xmds", "BlackList", "", $displayInfo['displayid']); |
4667 | 687 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "$xml", "xmds", "BlackList", "", $displayInfo['displayid']); | 706 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "$xml", "xmds", "BlackList", "", $displayInfo['displayid']); |
4669 | 688 | 707 | ||
4670 | 689 | // Check to see if this media/display is already blacklisted (and not ignored) | 708 | // Check to see if this media/display is already blacklisted (and not ignored) |
4671 | 690 | $SQL = "SELECT BlackListID FROM blacklist WHERE MediaID = $mediaId AND isIgnored = 0 AND DisplayID = " . $displayInfo['displayid']; | 709 | $SQL = "SELECT BlackListID FROM blacklist WHERE MediaID = $mediaId AND isIgnored = 0 AND DisplayID = " . $displayInfo['displayid']; |
4673 | 691 | 710 | ||
4674 | 692 | if (!$results = $db->query($SQL)) | 711 | if (!$results = $db->query($SQL)) |
4675 | 693 | { | 712 | { |
4676 | 694 | trigger_error($db->error()); | 713 | trigger_error($db->error()); |
4677 | 695 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList records.", $db->error()); | 714 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList records.", $db->error()); |
4678 | 696 | } | 715 | } |
4680 | 697 | 716 | ||
4681 | 698 | if ($db->num_rows($results) == 0) | 717 | if ($db->num_rows($results) == 0) |
4682 | 699 | { | 718 | { |
4683 | 700 | // Insert the black list record | 719 | // Insert the black list record |
4684 | @@ -705,20 +724,20 @@ | |||
4685 | 705 | // Only the current display | 724 | // Only the current display |
4686 | 706 | $SQL .= " WHERE displayID = " . $displayInfo['displayid']; | 725 | $SQL .= " WHERE displayID = " . $displayInfo['displayid']; |
4687 | 707 | } | 726 | } |
4689 | 708 | 727 | ||
4690 | 709 | if (!$displays = $db->query($SQL)) | 728 | if (!$displays = $db->query($SQL)) |
4691 | 710 | { | 729 | { |
4692 | 711 | trigger_error($db->error()); | 730 | trigger_error($db->error()); |
4693 | 712 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList Displays.", $db->error()); | 731 | return new soap_fault("SOAP-ENV:Server", "", "Unable to query for BlackList Displays.", $db->error()); |
4694 | 713 | } | 732 | } |
4696 | 714 | 733 | ||
4697 | 715 | while ($row = $db->get_row($displays)) | 734 | while ($row = $db->get_row($displays)) |
4698 | 716 | { | 735 | { |
4699 | 717 | $displayId = $row[0]; | 736 | $displayId = $row[0]; |
4701 | 718 | 737 | ||
4702 | 719 | $SQL = "INSERT INTO blacklist (MediaID, DisplayID, ReportingDisplayID, Reason) | 738 | $SQL = "INSERT INTO blacklist (MediaID, DisplayID, ReportingDisplayID, Reason) |
4703 | 720 | VALUES ($mediaId, $displayId, " . $displayInfo['displayid'] . ", '$reason') "; | 739 | VALUES ($mediaId, $displayId, " . $displayInfo['displayid'] . ", '$reason') "; |
4705 | 721 | 740 | ||
4706 | 722 | if (!$db->query($SQL)) | 741 | if (!$db->query($SQL)) |
4707 | 723 | { | 742 | { |
4708 | 724 | trigger_error($db->error()); | 743 | trigger_error($db->error()); |
4709 | @@ -730,15 +749,15 @@ | |||
4710 | 730 | { | 749 | { |
4711 | 731 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "Media Already BlackListed [$mediaId]", "xmds", "BlackList", "", $displayInfo['displayid']); | 750 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "Media Already BlackListed [$mediaId]", "xmds", "BlackList", "", $displayInfo['displayid']); |
4712 | 732 | } | 751 | } |
4714 | 733 | 752 | ||
4715 | 734 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[OUT]", "xmds", "BlackList", "", $displayInfo['displayid']); | 753 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "[OUT]", "xmds", "BlackList", "", $displayInfo['displayid']); |
4717 | 735 | 754 | ||
4718 | 736 | return true; | 755 | return true; |
4719 | 737 | } | 756 | } |
4720 | 738 | 757 | ||
4721 | 739 | /** | 758 | /** |
4722 | 740 | * Submit client logging | 759 | * Submit client logging |
4724 | 741 | * @return | 760 | * @return |
4725 | 742 | * @param $version Object | 761 | * @param $version Object |
4726 | 743 | * @param $serverKey Object | 762 | * @param $serverKey Object |
4727 | 744 | * @param $hardwareKey Object | 763 | * @param $hardwareKey Object |
4728 | @@ -747,13 +766,13 @@ | |||
4729 | 747 | function SubmitLog($version, $serverKey, $hardwareKey, $logXml) | 766 | function SubmitLog($version, $serverKey, $hardwareKey, $logXml) |
4730 | 748 | { | 767 | { |
4731 | 749 | global $db; | 768 | global $db; |
4733 | 750 | 769 | ||
4734 | 751 | // Sanitize | 770 | // Sanitize |
4735 | 752 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 771 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4736 | 753 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 772 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4737 | 754 | $version = Kit::ValidateParam($version, _STRING); | 773 | $version = Kit::ValidateParam($version, _STRING); |
4738 | 755 | $logXml = Kit::ValidateParam($logXml, _HTMLSTRING); | 774 | $logXml = Kit::ValidateParam($logXml, _HTMLSTRING); |
4740 | 756 | 775 | ||
4741 | 757 | // Make sure we are talking the same language | 776 | // Make sure we are talking the same language |
4742 | 758 | if (!CheckVersion($version)) | 777 | if (!CheckVersion($version)) |
4743 | 759 | { | 778 | { |
4744 | @@ -765,20 +784,20 @@ | |||
4745 | 765 | { | 784 | { |
4746 | 766 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); | 785 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); |
4747 | 767 | } | 786 | } |
4749 | 768 | 787 | ||
4750 | 769 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitLog", "", $displayInfo['displayid']); | 788 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitLog", "", $displayInfo['displayid']); |
4751 | 770 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", 'XML [' . $logXml . ']', "xmds", "SubmitLog", "", $displayInfo['displayid']); | 789 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", 'XML [' . $logXml . ']', "xmds", "SubmitLog", "", $displayInfo['displayid']); |
4753 | 771 | 790 | ||
4754 | 772 | // Load the XML into a DOMDocument | 791 | // Load the XML into a DOMDocument |
4755 | 773 | $document = new DOMDocument("1.0"); | 792 | $document = new DOMDocument("1.0"); |
4757 | 774 | 793 | ||
4758 | 775 | if (!$document->loadXML($logXml)) | 794 | if (!$document->loadXML($logXml)) |
4759 | 776 | { | 795 | { |
4760 | 777 | return new soap_fault("SOAP-ENV:Client", "", "XML Cannot be loaded into DOM Document.", $hardwareKey); | 796 | return new soap_fault("SOAP-ENV:Client", "", "XML Cannot be loaded into DOM Document.", $hardwareKey); |
4761 | 778 | } | 797 | } |
4763 | 779 | 798 | ||
4764 | 780 | foreach ($document->documentElement->childNodes as $node) | 799 | foreach ($document->documentElement->childNodes as $node) |
4766 | 781 | { | 800 | { |
4767 | 782 | //Zero out the common vars | 801 | //Zero out the common vars |
4768 | 783 | $date = ""; | 802 | $date = ""; |
4769 | 784 | $message = ""; | 803 | $message = ""; |
4770 | @@ -787,23 +806,23 @@ | |||
4771 | 787 | $mediaID = ""; | 806 | $mediaID = ""; |
4772 | 788 | $cat = ''; | 807 | $cat = ''; |
4773 | 789 | $method = ''; | 808 | $method = ''; |
4775 | 790 | 809 | ||
4776 | 791 | // This will be a bunch of trace nodes | 810 | // This will be a bunch of trace nodes |
4777 | 792 | $message = $node->textContent; | 811 | $message = $node->textContent; |
4780 | 793 | 812 | ||
4781 | 794 | // Each element should have a category and a date | 813 | // Each element should have a category and a date |
4782 | 795 | $date = $node->getAttribute('date'); | 814 | $date = $node->getAttribute('date'); |
4783 | 796 | $cat = $node->getAttribute('category'); | 815 | $cat = $node->getAttribute('category'); |
4786 | 797 | 816 | ||
4787 | 798 | if ($date == '' || $cat == '') | 817 | if ($date == '' || $cat == '') |
4788 | 799 | { | 818 | { |
4789 | 800 | trigger_error('Log submitted without a date or category attribute'); | 819 | trigger_error('Log submitted without a date or category attribute'); |
4790 | 801 | continue; | 820 | continue; |
4791 | 802 | } | 821 | } |
4793 | 803 | 822 | ||
4794 | 804 | // Get the date and the message (all log types have these) | 823 | // Get the date and the message (all log types have these) |
4795 | 805 | foreach ($node->childNodes as $nodeElements) | 824 | foreach ($node->childNodes as $nodeElements) |
4797 | 806 | { | 825 | { |
4798 | 807 | if ($nodeElements->nodeName == "scheduleID") | 826 | if ($nodeElements->nodeName == "scheduleID") |
4799 | 808 | { | 827 | { |
4800 | 809 | $scheduleID = $nodeElements->textContent; | 828 | $scheduleID = $nodeElements->textContent; |
4801 | @@ -825,26 +844,26 @@ | |||
4802 | 825 | $method = $nodeElements->textContent; | 844 | $method = $nodeElements->textContent; |
4803 | 826 | } | 845 | } |
4804 | 827 | } | 846 | } |
4806 | 828 | 847 | ||
4807 | 829 | // We should have enough information to log this now. | 848 | // We should have enough information to log this now. |
4808 | 830 | if ($cat == 'error' || $cat == 'Error') | 849 | if ($cat == 'error' || $cat == 'Error') |
4809 | 831 | { | 850 | { |
4811 | 832 | Debug::LogEntry($db, $cat, $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); | 851 | Debug::LogEntry($db, $cat, $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); |
4812 | 833 | } | 852 | } |
4813 | 834 | else | 853 | else |
4814 | 835 | { | 854 | { |
4816 | 836 | Debug::LogEntry($db, 'audit', $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); | 855 | Debug::LogEntry($db, 'audit', $message, 'Client', $method, $date, $displayInfo['displayid'], $scheduleID, $layoutID, $mediaID); |
4817 | 837 | } | 856 | } |
4818 | 838 | } | 857 | } |
4819 | 839 | 858 | ||
4820 | 840 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "OUT", "xmds", "SubmitLog", "", $displayInfo['displayid']); | 859 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "OUT", "xmds", "SubmitLog", "", $displayInfo['displayid']); |
4822 | 841 | 860 | ||
4823 | 842 | return true; | 861 | return true; |
4824 | 843 | } | 862 | } |
4825 | 844 | 863 | ||
4826 | 845 | /** | 864 | /** |
4827 | 846 | * Submit display statistics to the server | 865 | * Submit display statistics to the server |
4829 | 847 | * @return | 866 | * @return |
4830 | 848 | * @param $version Object | 867 | * @param $version Object |
4831 | 849 | * @param $serverKey Object | 868 | * @param $serverKey Object |
4832 | 850 | * @param $hardwareKey Object | 869 | * @param $hardwareKey Object |
4833 | @@ -853,13 +872,13 @@ | |||
4834 | 853 | function SubmitStats($version, $serverKey, $hardwareKey, $statXml) | 872 | function SubmitStats($version, $serverKey, $hardwareKey, $statXml) |
4835 | 854 | { | 873 | { |
4836 | 855 | global $db; | 874 | global $db; |
4838 | 856 | 875 | ||
4839 | 857 | // Sanitize | 876 | // Sanitize |
4840 | 858 | $serverKey = Kit::ValidateParam($serverKey, _STRING); | 877 | $serverKey = Kit::ValidateParam($serverKey, _STRING); |
4841 | 859 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); | 878 | $hardwareKey = Kit::ValidateParam($hardwareKey, _STRING); |
4842 | 860 | $version = Kit::ValidateParam($version, _STRING); | 879 | $version = Kit::ValidateParam($version, _STRING); |
4843 | 861 | $statXml = Kit::ValidateParam($statXml, _HTMLSTRING); | 880 | $statXml = Kit::ValidateParam($statXml, _HTMLSTRING); |
4845 | 862 | 881 | ||
4846 | 863 | // Make sure we are talking the same language | 882 | // Make sure we are talking the same language |
4847 | 864 | if (!CheckVersion($version)) | 883 | if (!CheckVersion($version)) |
4848 | 865 | { | 884 | { |
4849 | @@ -871,55 +890,55 @@ | |||
4850 | 871 | { | 890 | { |
4851 | 872 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); | 891 | return new soap_fault("SOAP-ENV:Client", "", "This display client is not licensed", $hardwareKey); |
4852 | 873 | } | 892 | } |
4854 | 874 | 893 | ||
4855 | 875 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 894 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "IN", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4856 | 876 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "StatXml: [" . $statXml . "]", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 895 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "StatXml: [" . $statXml . "]", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4858 | 877 | 896 | ||
4859 | 878 | if ($statXml == "") | 897 | if ($statXml == "") |
4860 | 879 | { | 898 | { |
4861 | 880 | return new soap_fault("SOAP-ENV:Client", "", "Stat XML is empty.", $hardwareKey); | 899 | return new soap_fault("SOAP-ENV:Client", "", "Stat XML is empty.", $hardwareKey); |
4862 | 881 | } | 900 | } |
4864 | 882 | 901 | ||
4865 | 883 | // Log | 902 | // Log |
4866 | 884 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to create Stat Object.", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 903 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to create Stat Object.", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4868 | 885 | 904 | ||
4869 | 886 | $statObject = new Stat($db); | 905 | $statObject = new Stat($db); |
4871 | 887 | 906 | ||
4872 | 888 | // Log | 907 | // Log |
4873 | 889 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to Create DOMDocument.", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 908 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "About to Create DOMDocument.", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4875 | 890 | 909 | ||
4876 | 891 | // Load the XML into a DOMDocument | 910 | // Load the XML into a DOMDocument |
4877 | 892 | $document = new DOMDocument("1.0"); | 911 | $document = new DOMDocument("1.0"); |
4878 | 893 | $document->loadXML($statXml); | 912 | $document->loadXML($statXml); |
4880 | 894 | 913 | ||
4881 | 895 | foreach ($document->documentElement->childNodes as $node) | 914 | foreach ($document->documentElement->childNodes as $node) |
4883 | 896 | { | 915 | { |
4884 | 897 | //Zero out the common vars | 916 | //Zero out the common vars |
4885 | 898 | $fromdt = ''; | 917 | $fromdt = ''; |
4886 | 899 | $todt = ''; | 918 | $todt = ''; |
4887 | 900 | $type = ''; | 919 | $type = ''; |
4889 | 901 | 920 | ||
4890 | 902 | $scheduleID = 0; | 921 | $scheduleID = 0; |
4891 | 903 | $layoutID = 0; | 922 | $layoutID = 0; |
4892 | 904 | $mediaID = ''; | 923 | $mediaID = ''; |
4893 | 905 | $tag = ''; | 924 | $tag = ''; |
4895 | 906 | 925 | ||
4896 | 907 | // Each element should have these attributes | 926 | // Each element should have these attributes |
4897 | 908 | $fromdt = $node->getAttribute('fromdt'); | 927 | $fromdt = $node->getAttribute('fromdt'); |
4898 | 909 | $todt = $node->getAttribute('todt'); | 928 | $todt = $node->getAttribute('todt'); |
4899 | 910 | $type = $node->getAttribute('type'); | 929 | $type = $node->getAttribute('type'); |
4902 | 911 | 930 | ||
4903 | 912 | if ($fromdt == '' || $todt == '' || $type == '') | 931 | if ($fromdt == '' || $todt == '' || $type == '') |
4904 | 913 | { | 932 | { |
4905 | 914 | trigger_error('Stat submitted without the fromdt, todt or type attributes.'); | 933 | trigger_error('Stat submitted without the fromdt, todt or type attributes.'); |
4906 | 915 | continue; | 934 | continue; |
4907 | 916 | } | 935 | } |
4909 | 917 | 936 | ||
4910 | 918 | $scheduleID = $node->getAttribute('scheduleid'); | 937 | $scheduleID = $node->getAttribute('scheduleid'); |
4911 | 919 | $layoutID = $node->getAttribute('layoutid'); | 938 | $layoutID = $node->getAttribute('layoutid'); |
4912 | 920 | $mediaID = $node->getAttribute('mediaid'); | 939 | $mediaID = $node->getAttribute('mediaid'); |
4913 | 921 | $tag = $node->getAttribute('tag'); | 940 | $tag = $node->getAttribute('tag'); |
4915 | 922 | 941 | ||
4916 | 923 | // Write the stat record with the information we have available to us. | 942 | // Write the stat record with the information we have available to us. |
4917 | 924 | if (!$statObject->Add($type, $fromdt, $todt, $scheduleID, $displayInfo['displayid'], $layoutID, $mediaID, $tag)) | 943 | if (!$statObject->Add($type, $fromdt, $todt, $scheduleID, $displayInfo['displayid'], $layoutID, $mediaID, $tag)) |
4918 | 925 | { | 944 | { |
4919 | @@ -929,7 +948,7 @@ | |||
4920 | 929 | } | 948 | } |
4921 | 930 | 949 | ||
4922 | 931 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "OUT", "xmds", "SubmitStats", "", $displayInfo['displayid']); | 950 | if ($displayInfo['isAuditing'] == 1) Debug::LogEntry ($db, "audit", "OUT", "xmds", "SubmitStats", "", $displayInfo['displayid']); |
4924 | 932 | 951 | ||
4925 | 933 | return true; | 952 | return true; |
4926 | 934 | } | 953 | } |
4927 | 935 | 954 | ||
4928 | @@ -938,7 +957,7 @@ | |||
4929 | 938 | 957 | ||
4930 | 939 | $service->configureWSDL("xmds", "urn:xmds"); | 958 | $service->configureWSDL("xmds", "urn:xmds"); |
4931 | 940 | 959 | ||
4933 | 941 | $service->register("RegisterDisplay", | 960 | $service->register("RegisterDisplay", |
4934 | 942 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'displayName' => 'xsd:string', 'version' => 'xsd:string'), | 961 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'displayName' => 'xsd:string', 'version' => 'xsd:string'), |
4935 | 943 | array('ActivationMessage' => 'xsd:string'), | 962 | array('ActivationMessage' => 'xsd:string'), |
4936 | 944 | 'urn:xmds', | 963 | 'urn:xmds', |
4937 | @@ -947,8 +966,8 @@ | |||
4938 | 947 | 'encoded', | 966 | 'encoded', |
4939 | 948 | 'Registered the Display on the Xibo Network' | 967 | 'Registered the Display on the Xibo Network' |
4940 | 949 | ); | 968 | ); |
4943 | 950 | 969 | ||
4944 | 951 | $service->register("RequiredFiles", | 970 | $service->register("RequiredFiles", |
4945 | 952 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'version' => 'xsd:string'), | 971 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'version' => 'xsd:string'), |
4946 | 953 | array('RequiredFilesXml' => 'xsd:string'), | 972 | array('RequiredFilesXml' => 'xsd:string'), |
4947 | 954 | 'urn:xmds', | 973 | 'urn:xmds', |
4948 | @@ -957,8 +976,8 @@ | |||
4949 | 957 | 'encoded', | 976 | 'encoded', |
4950 | 958 | 'The files required by the requesting display' | 977 | 'The files required by the requesting display' |
4951 | 959 | ); | 978 | ); |
4954 | 960 | 979 | ||
4955 | 961 | $service->register("GetFile", | 980 | $service->register("GetFile", |
4956 | 962 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'filePath' => 'xsd:string', 'fileType' => 'xsd:string', 'chunkOffset' => 'xsd:int', 'chuckSize' => 'xsd:int', 'version' => 'xsd:string'), | 981 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'filePath' => 'xsd:string', 'fileType' => 'xsd:string', 'chunkOffset' => 'xsd:int', 'chuckSize' => 'xsd:int', 'version' => 'xsd:string'), |
4957 | 963 | array('file' => 'xsd:base64Binary'), | 982 | array('file' => 'xsd:base64Binary'), |
4958 | 964 | 'urn:xmds', | 983 | 'urn:xmds', |
4959 | @@ -966,9 +985,9 @@ | |||
4960 | 966 | 'rpc', | 985 | 'rpc', |
4961 | 967 | 'encoded', | 986 | 'encoded', |
4962 | 968 | 'Gets the file requested' | 987 | 'Gets the file requested' |
4966 | 969 | ); | 988 | ); |
4967 | 970 | 989 | ||
4968 | 971 | $service->register("Schedule", | 990 | $service->register("Schedule", |
4969 | 972 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'version' => 'xsd:string'), | 991 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'version' => 'xsd:string'), |
4970 | 973 | array('ScheduleXml' => 'xsd:string'), | 992 | array('ScheduleXml' => 'xsd:string'), |
4971 | 974 | 'urn:xmds', | 993 | 'urn:xmds', |
4972 | @@ -976,8 +995,8 @@ | |||
4973 | 976 | 'rpc', | 995 | 'rpc', |
4974 | 977 | 'encoded', | 996 | 'encoded', |
4975 | 978 | 'Gets the schedule' | 997 | 'Gets the schedule' |
4978 | 979 | ); | 998 | ); |
4979 | 980 | 999 | ||
4980 | 981 | $service->register("RecieveXmlLog", | 1000 | $service->register("RecieveXmlLog", |
4981 | 982 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'xml' => 'xsd:string', 'version' => 'xsd:string'), | 1001 | array('serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'xml' => 'xsd:string', 'version' => 'xsd:string'), |
4982 | 983 | array('success' => 'xsd:boolean'), | 1002 | array('success' => 'xsd:boolean'), |
4983 | @@ -997,7 +1016,7 @@ | |||
4984 | 997 | 'encoded', | 1016 | 'encoded', |
4985 | 998 | 'Set media to be blacklisted' | 1017 | 'Set media to be blacklisted' |
4986 | 999 | ); | 1018 | ); |
4988 | 1000 | 1019 | ||
4989 | 1001 | $service->register("SubmitLog", | 1020 | $service->register("SubmitLog", |
4990 | 1002 | array('version' => 'xsd:string', 'serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'logXml' => 'xsd:string'), | 1021 | array('version' => 'xsd:string', 'serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'logXml' => 'xsd:string'), |
4991 | 1003 | array('success' => 'xsd:boolean'), | 1022 | array('success' => 'xsd:boolean'), |
4992 | @@ -1007,7 +1026,7 @@ | |||
4993 | 1007 | 'encoded', | 1026 | 'encoded', |
4994 | 1008 | 'Submit Logging from the Client' | 1027 | 'Submit Logging from the Client' |
4995 | 1009 | ); | 1028 | ); |
4997 | 1010 | 1029 | ||
4998 | 1011 | $service->register("SubmitStats", | 1030 | $service->register("SubmitStats", |
4999 | 1012 | array('version' => 'xsd:string', 'serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'statXml' => 'xsd:string'), | 1031 | array('version' => 'xsd:string', 'serverKey' => 'xsd:string', 'hardwareKey' => 'xsd:string', 'statXml' => 'xsd:string'), |
5000 | 1013 | array('success' => 'xsd:boolean'), | 1032 | array('success' => 'xsd:boolean'), |
The diff has been truncated for viewing.