Merge lp://staging/~dangarner/xibo/106-server into lp://staging/xibo/1.1

Proposed by Dan Garner
Status: Rejected
Rejected by: Dan Garner
Proposed branch: lp://staging/~dangarner/xibo/106-server
Merge into: lp://staging/xibo/1.1
Diff against target: 21123 lines (+18293/-1829) (has conflicts)
56 files modified
server/install.php (+613/-0)
server/install/database/1.sql (+715/-0)
server/install/database/10.sql (+30/-0)
server/install/database/5.sql.OTHER (+3/-0)
server/install/database/8.sql (+40/-20)
server/install/database/9.sql (+19/-0)
server/lib/app/app_functions.php (+642/-0)
server/lib/app/debug.class.php (+193/-0)
server/lib/app/formmanager.class.php (+155/-0)
server/lib/app/helpmanager.class.php (+97/-0)
server/lib/app/kit.class.php (+303/-1)
server/lib/app/menumanager.class.php (+115/-0)
server/lib/app/pagemanager.class.php (+144/-0)
server/lib/app/session.class.php (+30/-26)
server/lib/data/data.class.php (+82/-0)
server/lib/data/resolution.data.class.php (+99/-0)
server/lib/data/setting.data.class.php (+44/-0)
server/lib/include.php (+126/-0)
server/lib/js/core.js (+102/-0)
server/lib/js/display.js (+22/-1)
server/lib/js/layout.js (+358/-0)
server/lib/js/resolution.js (+19/-0)
server/lib/js/schedule.js (+145/-0)
server/lib/modules/module.class.php (+577/-0)
server/lib/pages/content.class.php (+14/-0)
server/lib/pages/fault.class.php (+315/-0)
server/lib/pages/layout.class.php (+219/-70)
server/lib/pages/module.class.php (+56/-0)
server/lib/pages/region.class.php (+521/-0)
server/lib/pages/resolution.class.php (+326/-0)
server/lib/pages/schedule.class.php (+10/-0)
server/lib/pages/user.class.php (+709/-0)
server/lib/xmds.inc.php (+88/-0)
server/modules/embedded.module.php (+282/-0)
server/modules/flash.module.php (+1871/-934)
server/modules/image.module.php (+967/-0)
server/modules/module_db_mysql.php (+314/-129)
server/modules/module_user_general.php (+619/-0)
server/modules/powerpoint.module.php (+938/-0)
server/modules/text.module.php (+599/-280)
server/modules/ticker.module.php (+689/-325)
server/modules/video.module.php (+924/-0)
server/modules/webpage.module.php (+248/-0)
server/template/css/forms.css (+295/-0)
server/template/css/ie8.css (+23/-0)
server/template/css/presentation.css (+1285/-0)
server/template/css/xibo.css (+39/-1)
server/template/footer.php (+43/-0)
server/template/header.php (+162/-0)
server/template/pages/fault_view.php (+87/-41)
server/template/pages/login_box.php (+107/-1)
server/template/pages/login_box_ajax.php (+25/-0)
server/template/pages/resolution_view.php (+45/-0)
server/template/pages/schedule_month_view.php.OTHER (+140/-0)
server/upgrade.php.OTHER (+598/-0)
server/xmds.php (+1062/-0)
Text conflict in server/install.php
Text conflict in server/install/database/1.sql
Contents conflict in server/install/database/5.sql
Text conflict in server/install/database/8.sql
Text conflict in server/install/database/9.sql
Text conflict in server/lib/app/app_functions.php
Text conflict in server/lib/app/debug.class.php
Text conflict in server/lib/app/formmanager.class.php
Text conflict in server/lib/app/helpmanager.class.php
Text conflict in server/lib/app/kit.class.php
Text conflict in server/lib/app/menumanager.class.php
Text conflict in server/lib/app/pagemanager.class.php
Text conflict in server/lib/data/data.class.php
Text conflict in server/lib/data/setting.data.class.php
Text conflict in server/lib/include.php
Text conflict in server/lib/js/core.js
Text conflict in server/lib/js/display.js
Text conflict in server/lib/js/layout.js
Text conflict in server/lib/js/schedule.js
Text conflict in server/lib/modules/module.class.php
Text conflict in server/lib/pages/content.class.php
Text conflict in server/lib/pages/fault.class.php
Text conflict in server/lib/pages/layout.class.php
Text conflict in server/lib/pages/module.class.php
Text conflict in server/lib/pages/region.class.php
Text conflict in server/lib/pages/schedule.class.php
Text conflict in server/lib/pages/user.class.php
Text conflict in server/lib/xmds.inc.php
Text conflict in server/modules/embedded.module.php
Text conflict in server/modules/flash.module.php
Text conflict in server/modules/image.module.php
Text conflict in server/modules/module_db_mysql.php
Text conflict in server/modules/module_user_general.php
Text conflict in server/modules/powerpoint.module.php
Text conflict in server/modules/text.module.php
Text conflict in server/modules/ticker.module.php
Text conflict in server/modules/video.module.php
Text conflict in server/modules/webpage.module.php
Text conflict in server/template/css/forms.css
Text conflict in server/template/css/presentation.css
Text conflict in server/template/css/xibo.css
Text conflict in server/template/footer.php
Text conflict in server/template/header.php
Text conflict in server/template/pages/fault_view.php
Text conflict in server/template/pages/login_box.php
Text conflict in server/template/pages/login_box_ajax.php
Contents conflict in server/template/pages/schedule_month_view.php
Contents conflict in server/upgrade.php
Text conflict in server/xmds.php
To merge this branch: bzr merge lp://staging/~dangarner/xibo/106-server
Reviewer Review Type Date Requested Status
Xibo Maintainters Pending
Review via email: mp+18471@code.staging.launchpad.net
To post a comment you must log in.

Unmerged revisions

109. By Dan Garner

[server] thumbnails and background images no longer created at upload/background edit point. They are generated dynamically each time they are requested. Means they can be requested by ID alone

108. By Dan Garner

[server] Added some new helper methods to the db object. Altered the GetImage method in modules to require an ID and then look up the image URI.

107. By Dan Garner

[server] Increased the size of the XML field on the layout table

106. By Dan Garner

[server] Fixed foreign key reference

105. By Dan Garner

[server] Can add a background directly from the layout designer in two steps.

104. By Dan Garner

[server] Attempt to get the font-family correct. Defaults to Times New Roman in the preview - the same as the client. And insists on a font size of 1em.

103. By Dan Garner

[server] Used sprintf for the session expiry

102. By Dan Garner

[server] Added code to clear up very old sessions (clogging up the table). Still unsure why sometimes sessions cannot be re-logged in

101. By Dan Garner

[server] Included an IE8 only css file which fixes the management menu

100. By Dan Garner

[server] Moved region size/coords over to the right... they were getting in the way of text items

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'server/install.php'
2--- server/install.php 2009-12-31 11:38:50 +0000
3+++ server/install.php 2010-02-02 19:49:09 +0000
4@@ -1,3 +1,4 @@
5+<<<<<<< TREE
6 <?php
7 /*
8 * Xibo - Digitial Signage - http://www.xibo.org.uk
9@@ -87,9 +88,76 @@
10 <div class="loginbutton"><button type="submit"><?php echo __("Retest"); ?></button></div>
11 </form>
12 <?php
13+=======
14+<?php
15+/*
16+ * Xibo - Digitial Signage - http://www.xibo.org.uk
17+ * Copyright (C) 2009 Alex Harrington
18+ *
19+ * This file is part of Xibo.
20+ *
21+ * Xibo is free software: you can redistribute it and/or modify
22+ * it under the terms of the GNU Affero General Public License as published by
23+ * the Free Software Foundation, either version 3 of the License, or
24+ * any later version.
25+ *
26+ * Xibo is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU Affero General Public License for more details.
30+ *
31+ * You should have received a copy of the GNU Affero General Public License
32+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
33+ */
34+
35+DEFINE('XIBO', true);
36+
37+if (! checkPHP()) {
38+ die('Xibo requires PHP 5.1.0 or later');
39+}
40+
41+include('lib/app/kit.class.php');
42+include('install/header.inc');
43+include('config/config.class.php');
44+include('config/db_config.php');
45+
46+$fault = false;
47+
48+$xibo_step = Kit::GetParam('xibo_step',_POST,_INT,'0');
49+
50+if (!isset($xibo_step) || $xibo_step == 0) {
51+ # First step of the process.
52+ # Show a welcome screen and next button
53+ ?>
54+ Welcome to the Xibo Installer!<br /><br />
55+ The installer will take you through setting up Xibo one step at a time.<br /><br />
56+ Lets get started!<br /><br />
57+ <form action="install.php" method="POST">
58+ <input type="hidden" name="xibo_step" value="1" />
59+ <div class="loginbutton"><button type="submit">Next ></button></div>
60+ </form>
61+ <?php
62+}
63+elseif ($xibo_step == 1) {
64+ # Check environment
65+ $db = new Database();
66+ $cObj = new Config($db);
67+ ?>
68+ <p>First we need to check if your server meets Xibo's requirements.</p>
69+ <?php
70+ echo $cObj->CheckEnvironment();
71+ if ($cObj->EnvironmentFault()) {
72+ ?>
73+ <form action="install.php" method="POST">
74+ <input type="hidden" name="xibo_step" value="1" />
75+ <div class="loginbutton"><button type="submit">Retest</button></div>
76+ </form>
77+ <?php
78+>>>>>>> MERGE-SOURCE
79 }
80 else if ($cObj->EnvironmentWarning()) {
81 ?>
82+<<<<<<< TREE
83 <form action="install.php" method="POST">
84 <input type="hidden" name="xibo_step" value="1" />
85 <div class="loginbutton"><button type="submit"><?php echo __("Retest"); ?></button></div>
86@@ -268,6 +336,192 @@
87 <?php
88 flush();
89
90+=======
91+ <form action="install.php" method="POST">
92+ <input type="hidden" name="xibo_step" value="1" />
93+ <div class="loginbutton"><button type="submit">Retest</button></div>
94+ </form>
95+ <form action="install.php" method="POST">
96+ <input type="hidden" name="xibo_step" value="2" />
97+ <div class="loginbutton"><button type="submit">Next ></button></div>
98+ </form>
99+ <?php
100+ }
101+ else {
102+ ?>
103+ <form action="install.php" method="POST">
104+ <input type="hidden" name="xibo_step" value="2" />
105+ <div class="loginbutton"><button type="submit">Next ></button></div>
106+ </form>
107+ <?php
108+ }
109+}
110+elseif ($xibo_step == 2) {
111+# Create database
112+## Does database exist already?
113+
114+ ?>
115+ <div class="info">
116+ <p>Xibo needs to setup a new database.</p>
117+ <p>If you have not yet created an empty database and database user for
118+ Xibo to use, and know the username/password of a MySQL administrator,
119+ click the "Create New" button, otherwise click "Use Existing".</p>
120+ <p><i>Note that any existing database must be empty</i></p>
121+ </div>
122+ <form action="install.php" method="POST">
123+ <input type="hidden" name="xibo_step" value="3" />
124+ <button type="submit">Create New</button>
125+ </form>
126+ <form action="install.php" method="POST">
127+ <input type="hidden" name="xibo_step" value="4" />
128+ <button type="submit">Use Existing</button>
129+ </form>
130+ <?php
131+}
132+elseif ($xibo_step == 3) {
133+## If not, gather admin password and use to create empty db and new user.
134+?>
135+<div class="info">
136+<p>Since no empty database has been created for Xibo to use, we need the username
137+and password of a MySQL administrator to create a new database, and database
138+user for Xibo.</p>
139+<p>Additionally, please give us a new username and password to create in MySQL
140+for Xibo to use. Xibo will create this automatically for you.</p>
141+<form action="install.php" method="POST">
142+<input type="hidden" name="xibo_step" value="5" />
143+<input type="hidden" name="db_create" value="On" />
144+<div class="install_table">
145+ <p><label for="host">Host: </label><input class="username" type="text" id="host" name="host" size="12" value="localhost" /></p>
146+ <p><label for="admin_username">Admin Username: </label><input class="username" type="text" id="admin_username" name="admin_username" size="12" /></p>
147+ <p><label for="admin_password">Admin Password: </label><input class="username" type="password" id="admin_password" name="admin_password" size="12" /></p>
148+ <p><label for="db_name">Xibo Database Name: </label><input class="username" type="text" id="db_name" name="db_name" size="12" value="xibo" /></p>
149+ <p><label for="db_username">Xibo Database Username: </label><input class="username" type="text" id="db_username" name="db_username" size="12" value="xibo" /></p>
150+ <p><label for="db_password">Xibo Database Password: </label><input class="username" type="password" id="db_password" name="db_password" size="12" /></p>
151+</div>
152+</div>
153+<button type="submit">Create</button>
154+</form>
155+<?php
156+}
157+elseif ($xibo_step == 4) {
158+## Get details of db that's been created already for us
159+?>
160+<div class="info">
161+<p>Please enter the details of the database and user you have
162+created for Xibo.</p>
163+<form action="install.php" method="POST">
164+<input type="hidden" name="xibo_step" value="5" />
165+<input type="hidden" name="db_create" value="Off" />
166+<div class="install_table">
167+ <p><label for="host">Host: </label><input class="username" type="text" id="host" name="host" size="12" value="localhost" /></p>
168+ <p><label for="db_name">Xibo Database Name: </label><input class="username" type="text" id="db_name" name="db_name" size="12" value="xibo" /></p>
169+ <p><label for="db_username">Xibo Database Username: </label><input class="username" type="text" id="db_username" name="db_username" size="12" value="xibo" /></p>
170+ <p><label for="db_password">Xibo Database Password: </label><input class="username" type="password" id="db_password" name="db_password" size="12" /></p>
171+</div>
172+</div>
173+<button type="submit">Create</button>
174+</form>
175+<?php
176+}
177+elseif ($xibo_step == 5) {
178+
179+ $db_create = Kit::GetParam('db_create',_POST,_STRING);
180+
181+ if (!isset($db_create)) {
182+ reportError("2","Something went wrong");
183+ }
184+ else {
185+ $db_host = Kit::GetParam('host',_POST,_STRING,'localhost');
186+ $db_user = Kit::GetParam('db_username',_POST,_USERNAME);
187+ $db_pass = Kit::GetParam('db_password',_POST,_PASSWORD);
188+ $db_name = Kit::GetParam('db_name',_POST,_USERNAME);
189+ ?>
190+ <div class="info">
191+ <?php
192+ if ($db_create == 'On') {
193+ $db_admin_user = Kit::GetParam('admin_username',_POST,_USERNAME);
194+ $db_admin_pass = Kit::GetParam('admin_password',_POST,_PASSWORD);
195+
196+ if (! ($db_host && $db_name && $db_user && $db_pass && $db_admin_user && $db_admin_pass)) {
197+ # Something was blank.
198+ # Throw an error.
199+ reportError("3", "A field was blank. Please fill in all fields.");
200+ }
201+
202+ $db = @mysql_connect($db_host,$db_admin_user,$db_admin_pass);
203+
204+ if (! $db) {
205+ reportError("3", "Could not connect to MySQL with the administrator details. Please check and try again.<br /><br />MySQL Error:<br />" . mysql_error());
206+ }
207+
208+ ?>
209+ <p>Creating new database.</p>
210+ <?php
211+ flush();
212+
213+ $SQL = sprintf("CREATE DATABASE `%s`",
214+ mysql_real_escape_string($db_name));
215+ if (! @mysql_query($SQL, $db)) {
216+ # Create database and user
217+ reportError("3", "Could not create a new database with the administrator details. Please check and try again.<br /><br />MySQL Error:<br />" . mysql_error());
218+ }
219+
220+ # Choose the MySQL DB to create a user
221+ @mysql_select_db("mysql", $db);
222+
223+ # Make $db_host lowercase so it matches "localhost" if required.
224+ $db_host = strtolower($db_host);
225+
226+ ?>
227+ <p>Creating new user</p>
228+ <?php
229+ flush();
230+
231+ if ($db_host == 'localhost') {
232+ $SQL = sprintf("GRANT ALL PRIVILEGES ON `%s`.* to '%s'@'%s' IDENTIFIED BY '%s'",
233+ mysql_real_escape_string($db_name),
234+ mysql_real_escape_string($db_user),
235+ mysql_real_escape_string($db_host),
236+ mysql_real_escape_string($db_pass));
237+ }
238+ else {
239+ $SQL = sprintf("GRANT ALL PRIVILEGES ON `%s`.* to '%s'@'%%' IDENTIFIED BY '%s'",
240+ mysql_real_escape_string($db_name),
241+ mysql_real_escape_string($db_user),
242+ mysql_real_escape_string($db_pass));
243+ }
244+ if (! @mysql_query($SQL, $db)) {
245+ reportError("3", "Could not create a new user with the administrator details. Please check and try again.<br /><br />MySQL Error:<br />" . mysql_error());
246+ }
247+
248+
249+ @mysql_query("FLUSH PRIVILEGES", $db);
250+ @mysql_close($db);
251+
252+ }
253+ else {
254+ if (! ($db_host && $db_name && $db_user && $db_pass)) {
255+ # Something was blank
256+ # Throw an error.
257+ reportError("4", "A field was blank. Please fill in all fields. " . $db_host . " " . $db_name . " " . $db_user . " " . $db_pass);
258+ }
259+ }
260+ ## Populate database
261+
262+ $db = @mysql_connect($db_host,$db_user,$db_pass);
263+
264+ if (! $db) {
265+ reportError("4", "Could not connect to MySQL with the Xibo User account details. Please check and try again.<br /><br />MySQL Error:<br />" . mysql_error());
266+ }
267+
268+ @mysql_select_db($db_name,$db);
269+
270+ ?>
271+ <p>Populating the database</p>
272+ <?php
273+ flush();
274+
275+>>>>>>> MERGE-SOURCE
276 # Load from sql files to db - HOW?
277 $sql_files = ls('*.sql','install/database',false,array('return_files'));
278
279@@ -301,13 +555,23 @@
280
281 foreach ($sql_file as $sql) {
282 print ".";
283+<<<<<<< TREE
284 $sqlStatementCount++;
285 flush();
286 if (! @mysql_query($sql,$db)) {
287 reportError("4", __("An error occured populating the database.") . "<br /><br />" . __("MySQL Error:") . "<br />" . mysql_error() . "<br /><br />SQL executed:<br />" . $sql . "<br /><br />Statement number: " . $sqlStatementCount);
288 }
289 }
290+=======
291+ $sqlStatementCount++;
292+ flush();
293+ if (! @mysql_query($sql,$db)) {
294+ reportError("4", "An error occured populating the database.<br /><br />MySQL Error:<br />" . mysql_error() . "<br /><br />SQL executed:<br />" . $sql . "<br /><br />Statement number: " . $sqlStatementCount);
295+ }
296+ }
297+>>>>>>> MERGE-SOURCE
298 print "</p>";
299+<<<<<<< TREE
300 }
301 @mysql_close($db);
302 }
303@@ -620,6 +884,296 @@
304 }
305 return $data;
306 }
307+=======
308+ }
309+ @mysql_close($db);
310+ }
311+ # Write out a new settings.php
312+ $fh = fopen("settings.php", 'wt');
313+
314+ if (! $fh) {
315+ reportError("0", "Unable to write to settings.php. We already checked this was possible earlier, so something changed.");
316+ }
317+
318+ settings_strings();
319+
320+ $settings_content = '$dbhost = \'' . $db_host . '\';' . "\n";
321+ $settings_content .= '$dbuser = \'' . $db_user . '\';' . "\n";
322+ $settings_content .= '$dbpass = \'' . $db_pass . '\';' . "\n";
323+ $settings_content .= '$dbname = \'' . $db_name . '\';' . "\n\n";
324+ $settings_content .= 'define(\'SECRET_KEY\',\'' . gen_secret() . '\');' . "\n";
325+
326+ if (! fwrite($fh, $settings_header . $settings_content . $settings_footer)) {
327+ reportError("0", "Unable to write to settings.php. We already checked this was possible earlier, so something changed.");
328+ }
329+
330+ fclose($fh);
331+
332+ ?>
333+ </div>
334+ <div class="install_table">
335+ <form action="install.php" method="POST">
336+ <input type="hidden" name="xibo_step" value="6" />
337+ </div>
338+ <button type="submit">Next ></button>
339+ </form>
340+ <?php
341+}
342+elseif ($xibo_step == 6) {
343+ # Form to get new admin password
344+ ?>
345+ <div class="info">
346+ <p>Xibo needs to set the "xibo_admin" user password. Please enter a password for this account below.</p>
347+ </div>
348+ <div class="install_table">
349+ <form action="install.php" method="POST">
350+ <input type="hidden" name="xibo_step" value="7" />
351+ <p><label for="password1">Password: </label><input type="password" name="password1" size="12" /></p>
352+ <p><label for="password2">Retype Password: </label><input type="password" name="password2" size="12" /></p>
353+ </div>
354+ <button type="submit">Next ></button>
355+ </form>
356+ <?php
357+}
358+elseif ($xibo_step == 7) {
359+ # Setup xibo_admin password
360+ $password1 = Kit::GetParam('password1',_POST,_PASSWORD);
361+ $password2 = Kit::GetParam('password2',_POST,_PASSWORD);
362+
363+ if (!(($password1 && $password2) && ($password1 == $password2))) {
364+ reportError("6", "Please input a new password. Ensure both password fields are identical.");
365+ }
366+
367+ include('settings.php');
368+
369+ $password_hash = md5($password1);
370+
371+ $db = @mysql_connect($dbhost,$dbuser,$dbpass);
372+
373+ if (! $db) {
374+ reportError("6", "Could not connect to MySQL with the Xibo User account details saved in settings.php. Please check and try again.<br /><br />MySQL Error:<br />" . mysql_error());
375+ }
376+
377+ @mysql_select_db($dbname,$db);
378+
379+ $SQL = sprintf("UPDATE `user` SET UserPassword = '%s' WHERE UserID = 1 LIMIT 1",
380+ mysql_real_escape_string($password_hash));
381+ if (! @mysql_query($SQL, $db)) {
382+ reportError("6", "An error occured changing the xibo_admin password.<br /><br />MySQL Error:<br />" . mysql_error());
383+ }
384+
385+ @mysql_close($db);
386+
387+ ?>
388+ <div class="info">
389+ Successfully changed the xibo_admin password. We're nearly there now. Just a couple more steps!
390+ </div>
391+ <form action="install.php" method="POST">
392+ <input type="hidden" name="xibo_step" value="8" />
393+ <button type="submit">Next ></button>
394+ </form>
395+ <?php
396+}
397+elseif ($xibo_step == 8) {
398+ # Configure paths and keys
399+ ## nuSoap
400+ ## libraries
401+ ## server_key
402+ ?>
403+ <div class="info">
404+ <p><b>Library Location</b></p>
405+ <p>Xibo needs somewhere to store the things you upload to be shown. Ideally, this should be somewhere outside the root of your webserver - that is such that is not accessible by a web browser. Please input the full path to this folder. If the folder does not already exist, Xibo will attempt to create it for you.</p>
406+ <form action="install.php" method="POST">
407+ <div class="install_table">
408+ <p><label for="library_location">Library Location: </label><input type="text" name="library_location" value="" /></p>
409+ </div>
410+ <p><b>Server Key</b></p>
411+ <p>Xibo needs you to choose a "key". This will be required each time you setup a new client. It should be complicated, and hard to remember. It is visible in the admin interface, so it need not be written down separately.</p>
412+ <div class="install_table">
413+ <p><label for="server_key">Server Key: </label><input type="text" name="server_key" value="" /></p>
414+ </div>
415+ <p><b>Statistics</b></p>
416+ <p>We'd love to know you're running Xibo. If you're happy for us to collect anonymous statistics (version number, number of displays) then please leave the box ticked. Please untick the box if your server does not have direct access to the internet.</p>
417+ <div class="install_table">
418+ <p><label for="stats">Anonymous Statistics: </label><input type="checkbox" name="stats" value="true" checked /></p>
419+ </div>
420+ <input type="hidden" name="xibo_step" value="9" />
421+ </div>
422+ <button type="submit">Next ></button>
423+ </form>
424+ <?php
425+}
426+elseif ($xibo_step == 9) {
427+
428+ $server_key = Kit::GetParam('server_key',_POST,_WORD);
429+ $library_location = Kit::GetParam('library_location',_POST,_STRING);
430+ $stats = Kit::GetParam('stats',_POST,_BOOL);
431+
432+ // Remove trailing whitespace from the path given.
433+ $library_location = trim($library_location);
434+
435+ // Check both fields were completed
436+ if (! ($server_key && $library_location)) {
437+ reportError("8","A field was blank. Please make sure you complete all fields");
438+ }
439+
440+ if ($stats) {
441+ $stats="On";
442+ }
443+ else {
444+ $stats="Off";
445+ }
446+
447+ // Does library_location exist already?
448+ if (! is_dir($library_location)) {
449+ if (is_file($library_location)) {
450+ reportError("8", "A file exists with the name you gave for the Library Location. Please choose another location");
451+ }
452+
453+ // Directory does not exist. Attempt to make it
454+ // Using mkdir recursively, so it will attempt to make any
455+ // intermediate folders required.
456+ if (! mkdir($library_location,0755,true)) {
457+ reportError("8", "Could not create the Library Location directory for you. Please ensure the webserver has permission to create a folder in this location, or create the folder manually and grant permission for the webserver to write to the folder.");
458+ }
459+
460+ }
461+
462+ // Is library_location writable?
463+ if (! is_writable($library_location)) {
464+ // Directory is not writable.
465+ reportError("8","The Library Location you gave is not writable by the webserver. Please fix the permissions and try again.");
466+ }
467+
468+ // Is library_location empty?
469+ if (count(ls("*",$library_location,true)) > 0) {
470+ reportError("8","The Library Location you gave is not empty. Please give the location of an empty folder");
471+ }
472+
473+ // Check if the user has added a trailing slash.
474+ // If not, add one.
475+ if (!((substr($library_location, -1) == '/') || (substr($library_location, -1) == '\\'))) {
476+ $library_location = $library_location . '/';
477+ }
478+
479+ include('settings.php');
480+
481+ $db = @mysql_connect($dbhost,$dbuser,$dbpass);
482+
483+ if (! $db) {
484+ reportError("8", "Could not connect to MySQL with the Xibo User account details saved in settings.php. Please check and try again.<br /><br />MySQL Error:<br />" . mysql_error());
485+ }
486+
487+ @mysql_select_db($dbname,$db);
488+
489+ $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'LIBRARY_LOCATION' LIMIT 1",
490+ mysql_real_escape_string($library_location));
491+ if (! @mysql_query($SQL, $db)) {
492+ reportError("8", "An error occured changing the library location.<br /><br />MySQL Error:<br />" . mysql_error());
493+ }
494+
495+ $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'SERVER_KEY' LIMIT 1",
496+ mysql_real_escape_string($server_key));
497+ if (! @mysql_query($SQL, $db)) {
498+ reportError("8", "An error occured changing the server key.<br /><br />MySQL Error:<br />" . mysql_error());
499+ }
500+
501+ $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'defaultTimezone' LIMIT 1",
502+ mysql_real_escape_string(date_default_timezone_get()));
503+ if (! @mysql_query($SQL, $db)) {
504+ reportError("8", "An error occured setting the default timezone.<br /><br />MySQL Error:<br />" . mysql_error());
505+ }
506+
507+ $SQL = sprintf("UPDATE `setting` SET `value` = '%s' WHERE `setting`.`setting` = 'PHONE_HOME' LIMIT 1",
508+ mysql_real_escape_string($stats));
509+ if (! @mysql_query($SQL, $db)) {
510+ reportError("8", "An error occured setting SEND_STATS.<br /><br />MySQL Error:<br />" . mysql_error());
511+ }
512+ $SQL = "UPDATE `setting` SET `value` = '" . md5(uniqid(rand(), true)) . "' WHERE `setting`.`setting` = 'PHONE_HOME_KEY' LIMIT 1";
513+ if (! @mysql_query($SQL, $db)) {
514+ reportError("8", "An error occured setting SEND_STATS.<br /><br />MySQL Error:<br />" . mysql_error());
515+ }
516+
517+ @mysql_close($db);
518+
519+ ?>
520+ <div class="info">
521+ <p>Successfully set LIBRARY_LOCATION and SERVER_KEY.</p>
522+ </div>
523+ <form action="install.php" method="POST">
524+ <input type="hidden" name="xibo_step" value="10" />
525+ <button type="submit">Next ></button>
526+ </form>
527+ <?php
528+}
529+elseif ($xibo_step == 10) {
530+# Delete install.php
531+# Redirect to login page.
532+ if (! unlink('install.php')) {
533+ reportError("10", "Unable to delete install.php. Please ensure the webserver has permission to unlink this file and retry", "Retry");
534+ }
535+ if (! unlink('upgrade.php')) {
536+ reportError("10", "Unable to delete upgrade.php. Please ensure the webserver has permission to unlink this file and retry", "Retry");
537+ }
538+ ?>
539+ <div class="info">
540+ <p><b>Xibo was successfully installed.</b></p>
541+ <p>Please click <a href="index.php">here</a> to logon to Xibo as "xibo_admin" with the password you chose earlier.</p>
542+ </div>
543+ <?php
544+}
545+else {
546+ reportError("0","A required parameter was missing. Please go through the installer sequentially!","Start Again");
547+}
548+
549+include('install/footer.inc');
550+
551+# Functions
552+
553+function reportError($step, $message, $button_text="&lt; Back") {
554+?>
555+ <div class="info">
556+ <?php print $message; ?>
557+ </div>
558+ <form action="install.php" method="POST">
559+ <input type="hidden" name="xibo_step" value="<?php print $step; ?>"/>
560+ <button type="submit"><?php print $button_text; ?></button>
561+ </form>
562+ <?php
563+ include('install/footer.inc');
564+ die();
565+}
566+
567+// Taken from http://forums.devshed.com/php-development-5/php-wont-load-sql-from-file-515902.html
568+// By Crackster
569+/**
570+ * remove_remarks will strip the sql comment lines out of an uploaded sql file
571+ */
572+function remove_remarks($sql){
573+ $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^[-].*$/m', "\n", $sql));
574+ $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
575+ return $sql;
576+}
577+
578+// Taken from http://forums.devshed.com/php-development-5/php-wont-load-sql-from-file-515902.html
579+// By Crackster
580+/**
581+ * split_sql_file will split an uploaded sql file into single sql statements.
582+ * Note: expects trim() to have already been run on $sql.
583+ */
584+function split_sql_file($sql, $delimiter){
585+ $sql = str_replace("\r" , '', $sql);
586+ $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
587+ $data = array_map('trim', $data);
588+ // The empty case
589+ $end_data = end($data);
590+ if (empty($end_data))
591+ {
592+ unset($data[key($data)]);
593+ }
594+ return $data;
595+}
596+>>>>>>> MERGE-SOURCE
597
598 /**
599 * This funtion will take a pattern and a folder as the argument and go thru it(recursivly if needed)and return the list of
600@@ -682,6 +1236,7 @@
601 if($folder) chdir($current_folder);
602 return $all;
603 }
604+<<<<<<< TREE
605
606 function gen_secret() {
607 # Generates a random 12 character alphanumeric string to use as a salt
608@@ -752,6 +1307,64 @@
609 END;
610
611 $settings_footer = <<<END
612+=======
613+
614+function gen_secret() {
615+ # Generates a random 12 character alphanumeric string to use as a salt
616+ mt_srand((double)microtime()*1000000);
617+ $key = "";
618+ for ($i=0; $i < 12; $i++) {
619+ $c = mt_rand(0,2);
620+ if ($c == 0) {
621+ $key .= chr(mt_rand(65,90));
622+ }
623+ elseif ($c == 1) {
624+ $key .= chr(mt_rand(97,122));
625+ }
626+ else {
627+ $key .= chr(mt_rand(48,57));
628+ }
629+ }
630+
631+ return $key;
632+}
633+
634+function settings_strings() {
635+global $settings_header;
636+global $settings_footer;
637+
638+ $settings_header = <<<END
639+<?php
640+
641+/*
642+ * Xibo - Digital Signage - http://www.xibo.org.uk
643+ *
644+ * This file is part of Xibo - and is automatically generated by the installer
645+ *
646+ * You should not need to edit this file, unless your SQL connection details have changed.
647+ */
648+
649+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
650+
651+global \$dbhost;
652+global \$dbuser;
653+global \$dbpass;
654+global \$dbname;
655+
656+
657+END;
658+
659+$settings_footer = <<<END
660+?>
661+END;
662+
663+ return;
664+}
665+
666+function checkPHP() {
667+ return (version_compare("5.1.0",phpversion(), "<="));
668+}
669+>>>>>>> MERGE-SOURCE
670 ?>
671 END;
672
673
674=== modified file 'server/install/database/1.sql'
675--- server/install/database/1.sql 2009-12-31 11:38:50 +0000
676+++ server/install/database/1.sql 2010-02-02 19:49:10 +0000
677@@ -1,3 +1,4 @@
678+<<<<<<< TREE
679 -- phpMyAdmin SQL Dump
680 -- version 2.11.7
681 -- http://www.phpmyadmin.net
682@@ -710,4 +711,718 @@
683 UPDATE `version` SET `XmdsVersion` = '1', `XlfVersion` = '1' LIMIT 1 ;
684
685 -- From ServerInstaller branch.
686+=======
687+-- phpMyAdmin SQL Dump
688+-- version 2.11.7
689+-- http://www.phpmyadmin.net
690+--
691+-- Host: localhost
692+-- Generation Time: Dec 10, 2008 at 10:57 PM
693+-- Server version: 5.0.45
694+-- PHP Version: 5.2.4
695+
696+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
697+
698+--
699+-- Database: `xsm`
700+--
701+
702+-- --------------------------------------------------------
703+
704+--
705+-- Table structure for table `blacklist`
706+--
707+
708+CREATE TABLE IF NOT EXISTS `blacklist` (
709+ `BlackListID` int(11) NOT NULL auto_increment,
710+ `MediaID` int(11) NOT NULL,
711+ `DisplayID` int(11) NOT NULL,
712+ `UserID` int(11) default NULL COMMENT 'Null if it came from a display',
713+ `ReportingDisplayID` int(11) default NULL COMMENT 'The display that reported the blacklist',
714+ `Reason` text NOT NULL,
715+ `isIgnored` tinyint(4) NOT NULL default '0' COMMENT 'Ignore this blacklist',
716+ PRIMARY KEY (`BlackListID`),
717+ KEY `MediaID` (`MediaID`),
718+ KEY `DisplayID` (`DisplayID`)
719+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Blacklisted media will not get sent to the Display' AUTO_INCREMENT=1 ;
720+
721+-- --------------------------------------------------------
722+
723+--
724+-- Table structure for table `display`
725+--
726+
727+CREATE TABLE IF NOT EXISTS `display` (
728+ `displayid` int(8) NOT NULL auto_increment,
729+ `isAuditing` tinyint(4) NOT NULL default '0' COMMENT 'Is this display auditing',
730+ `display` varchar(50) NOT NULL,
731+ `defaultlayoutid` int(8) NOT NULL,
732+ `license` varchar(32) character set latin1 default NULL,
733+ `licensed` tinyint(1) NOT NULL default '0' COMMENT 'Is the Requested License Key Allowed',
734+ `loggedin` tinyint(4) NOT NULL default '0',
735+ `lastaccessed` datetime default NULL,
736+ `inc_schedule` tinyint(1) NOT NULL default '0' COMMENT 'Will this default be used in the scheduling calcs',
737+ PRIMARY KEY (`displayid`),
738+ KEY `defaultplaylistid` (`defaultlayoutid`)
739+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
740+
741+-- --------------------------------------------------------
742+
743+--
744+-- Table structure for table `group`
745+--
746+
747+CREATE TABLE IF NOT EXISTS `group` (
748+ `groupID` int(11) NOT NULL auto_increment,
749+ `group` varchar(50) NOT NULL,
750+ PRIMARY KEY (`groupID`)
751+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Groups' AUTO_INCREMENT=2 ;
752+
753+-- --------------------------------------------------------
754+
755+--
756+-- Table structure for table `layout`
757+--
758+
759+CREATE TABLE IF NOT EXISTS `layout` (
760+ `layoutID` int(11) NOT NULL auto_increment,
761+ `layout` varchar(50) NOT NULL,
762+ `permissionID` int(11) NOT NULL default '0',
763+ `xml` text NOT NULL,
764+ `userID` int(11) NOT NULL COMMENT 'The UserID that created this layout',
765+ `createdDT` datetime NOT NULL,
766+ `modifiedDT` datetime NOT NULL,
767+ `description` varchar(254) default NULL,
768+ `tags` varchar(254) default NULL,
769+ `templateID` int(11) default NULL COMMENT 'The ID of the template',
770+ `retired` tinyint(4) NOT NULL default '0' COMMENT 'Is this layout retired',
771+ `duration` int(11) NOT NULL default '0' COMMENT 'The duration in seconds',
772+ `background` varchar(254) default NULL,
773+ PRIMARY KEY (`layoutID`)
774+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Layouts' AUTO_INCREMENT=4 ;
775+
776+-- --------------------------------------------------------
777+
778+--
779+-- Table structure for table `lklayoutmedia`
780+--
781+
782+CREATE TABLE IF NOT EXISTS `lklayoutmedia` (
783+ `lklayoutmediaID` int(11) NOT NULL auto_increment COMMENT 'The ID',
784+ `mediaID` int(11) NOT NULL,
785+ `layoutID` int(11) NOT NULL,
786+ `regionID` varchar(50) NOT NULL COMMENT 'Region ID in the XML',
787+ PRIMARY KEY (`lklayoutmediaID`),
788+ KEY `mediaID` (`mediaID`),
789+ KEY `layoutID` (`layoutID`)
790+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Creates a reference between Layout and Media' AUTO_INCREMENT=7 ;
791+
792+-- --------------------------------------------------------
793+
794+--
795+-- Table structure for table `lkpagegroup`
796+--
797+
798+CREATE TABLE IF NOT EXISTS `lkpagegroup` (
799+ `lkpagegroupID` int(11) NOT NULL auto_increment,
800+ `pageID` int(11) NOT NULL,
801+ `groupID` int(11) NOT NULL,
802+ PRIMARY KEY (`lkpagegroupID`),
803+ KEY `pageID` (`pageID`),
804+ KEY `groupID` (`groupID`)
805+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Pages available to groups' AUTO_INCREMENT=55 ;
806+
807+-- --------------------------------------------------------
808+
809+--
810+-- Table structure for table `log`
811+--
812+
813+CREATE TABLE IF NOT EXISTS `log` (
814+ `logid` bigint(20) NOT NULL auto_increment COMMENT 'The log ID',
815+ `logdate` datetime NOT NULL COMMENT 'The log date',
816+ `type` enum('error','audit') NOT NULL,
817+ `page` varchar(15) NOT NULL,
818+ `function` varchar(50) default NULL,
819+ `message` longtext NOT NULL,
820+ `RequestUri` varchar(254) default NULL,
821+ `RemoteAddr` varchar(254) default NULL,
822+ `userID` int(11) NOT NULL default '0',
823+ `UserAgent` varchar(254) default NULL,
824+ `scheduleID` int(11) default NULL,
825+ `displayID` int(11) default NULL,
826+ `layoutID` int(11) default NULL,
827+ `mediaID` int(11) default NULL,
828+ PRIMARY KEY (`logid`),
829+ KEY `logdate` (`logdate`)
830+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=372 ;
831+
832+-- --------------------------------------------------------
833+
834+--
835+-- Table structure for table `media`
836+--
837+
838+CREATE TABLE IF NOT EXISTS `media` (
839+ `mediaID` int(11) NOT NULL auto_increment,
840+ `name` varchar(100) NOT NULL,
841+ `type` varchar(10) NOT NULL,
842+ `duration` int(11) NOT NULL,
843+ `originalFilename` varchar(254) default NULL,
844+ `storedAs` varchar(254) default NULL COMMENT 'What has this media been stored as',
845+ `userID` int(11) NOT NULL,
846+ `permissionID` tinyint(1) NOT NULL default '1',
847+ `retired` tinyint(4) NOT NULL default '0' COMMENT 'Is retired?',
848+ `isEdited` tinyint(4) NOT NULL default '0' COMMENT 'Is this the current record',
849+ `editedMediaID` int(11) default NULL COMMENT 'The Parent ID',
850+ PRIMARY KEY (`mediaID`),
851+ KEY `permissionID` (`permissionID`)
852+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ;
853+
854+-- --------------------------------------------------------
855+
856+--
857+-- Table structure for table `module`
858+--
859+
860+CREATE TABLE IF NOT EXISTS `module` (
861+ `ModuleID` int(11) NOT NULL auto_increment,
862+ `Module` varchar(50) NOT NULL,
863+ `Enabled` tinyint(4) NOT NULL default '0',
864+ `Description` varchar(254) default NULL,
865+ PRIMARY KEY (`ModuleID`)
866+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Functional Modules' AUTO_INCREMENT=8 ;
867+
868+-- --------------------------------------------------------
869+
870+--
871+-- Table structure for table `pagegroup`
872+--
873+
874+CREATE TABLE IF NOT EXISTS `pagegroup` (
875+ `pagegroupID` int(11) NOT NULL auto_increment,
876+ `pagegroup` varchar(50) NOT NULL,
877+ PRIMARY KEY (`pagegroupID`)
878+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Page Groups' AUTO_INCREMENT=12 ;
879+
880+-- --------------------------------------------------------
881+
882+--
883+-- Table structure for table `pages`
884+--
885+
886+CREATE TABLE IF NOT EXISTS `pages` (
887+ `pageID` int(11) NOT NULL auto_increment,
888+ `name` varchar(50) NOT NULL,
889+ `pagegroupID` int(11) NOT NULL,
890+ PRIMARY KEY (`pageID`),
891+ KEY `pagegroupID` (`pagegroupID`)
892+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Available Pages' AUTO_INCREMENT=26 ;
893+
894+-- --------------------------------------------------------
895+
896+--
897+-- Table structure for table `permission`
898+--
899+
900+CREATE TABLE IF NOT EXISTS `permission` (
901+ `permissionID` tinyint(4) NOT NULL,
902+ `permission` varchar(50) NOT NULL,
903+ PRIMARY KEY (`permissionID`)
904+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Permission Settings';
905+
906+-- --------------------------------------------------------
907+
908+--
909+-- Table structure for table `resolution`
910+--
911+
912+CREATE TABLE IF NOT EXISTS `resolution` (
913+ `resolutionID` int(11) NOT NULL auto_increment,
914+ `resolution` varchar(20) NOT NULL,
915+ `width` smallint(6) NOT NULL,
916+ `height` smallint(6) NOT NULL,
917+ PRIMARY KEY (`resolutionID`)
918+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Supported Resolutions' AUTO_INCREMENT=5 ;
919+
920+-- --------------------------------------------------------
921+
922+--
923+-- Table structure for table `schedule`
924+--
925+
926+CREATE TABLE IF NOT EXISTS `schedule` (
927+ `eventID` int(11) NOT NULL auto_increment,
928+ `layoutID` int(11) NOT NULL,
929+ `displayID_list` varchar(50) NOT NULL,
930+ `recurrence_type` enum('Hour','Day','Week','Month','Year') default NULL,
931+ `recurrence_detail` varchar(100) default NULL,
932+ `recurrence_range` datetime default NULL,
933+ `start` datetime NOT NULL,
934+ `end` datetime NOT NULL,
935+ `userID` int(11) NOT NULL,
936+ `is_priority` tinyint(4) NOT NULL,
937+ PRIMARY KEY (`eventID`),
938+ KEY `layoutID` (`layoutID`)
939+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='High level schedule information' AUTO_INCREMENT=2 ;
940+
941+-- --------------------------------------------------------
942+
943+--
944+-- Table structure for table `schedule_detail`
945+--
946+
947+CREATE TABLE IF NOT EXISTS `schedule_detail` (
948+ `schedule_detailID` int(11) NOT NULL auto_increment,
949+ `displayID` int(11) NOT NULL,
950+ `layoutID` int(11) NOT NULL,
951+ `starttime` datetime NOT NULL,
952+ `endtime` datetime NOT NULL,
953+ `userID` int(8) NOT NULL default '1' COMMENT 'Owner of the Event',
954+ `is_priority` tinyint(4) NOT NULL default '0' COMMENT 'This scheduled event has priority and will take precidence over any others scheduled',
955+ `eventID` int(11) default NULL,
956+ PRIMARY KEY (`schedule_detailID`),
957+ KEY `displayid` (`displayID`),
958+ KEY `IM_SDT_DisplayID` (`starttime`,`displayID`),
959+ KEY `layoutID` (`layoutID`),
960+ KEY `scheduleID` (`eventID`),
961+ KEY `schedule_detail_ibfk_3` (`displayID`)
962+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Replicated schedule across displays and recurrence' AUTO_INCREMENT=6 ;
963+
964+-- --------------------------------------------------------
965+
966+--
967+-- Table structure for table `session`
968+--
969+
970+CREATE TABLE IF NOT EXISTS `session` (
971+ `session_id` varchar(32) NOT NULL,
972+ `session_data` longtext NOT NULL,
973+ `session_expiration` int(10) unsigned NOT NULL default '0',
974+ `LastAccessed` datetime default NULL,
975+ `LastPage` varchar(25) default NULL,
976+ `userID` int(11) default NULL,
977+ `IsExpired` tinyint(4) NOT NULL default '1',
978+ `UserAgent` varchar(254) default NULL,
979+ `RemoteAddr` varchar(50) default NULL,
980+ `SecurityToken` varchar(50) default NULL,
981+ PRIMARY KEY (`session_id`),
982+ KEY `userID` (`userID`)
983+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
984+
985+-- --------------------------------------------------------
986+
987+--
988+-- Table structure for table `setting`
989+--
990+
991+CREATE TABLE IF NOT EXISTS `setting` (
992+ `settingid` int(11) NOT NULL auto_increment,
993+ `setting` varchar(24) character set latin1 NOT NULL,
994+ `value` varchar(256) character set latin1 NOT NULL,
995+ `type` varchar(24) character set latin1 NOT NULL,
996+ `helptext` text character set latin1,
997+ `options` varchar(254) character set latin1 default NULL,
998+ `cat` varchar(24) character set latin1 NOT NULL default 'general',
999+ `userChange` tinyint(1) NOT NULL default '0' COMMENT 'Can the user change this setting',
1000+ PRIMARY KEY (`settingid`)
1001+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=35 ;
1002+
1003+-- --------------------------------------------------------
1004+
1005+--
1006+-- Table structure for table `stat`
1007+--
1008+
1009+CREATE TABLE IF NOT EXISTS `stat` (
1010+ `statID` bigint(20) NOT NULL auto_increment,
1011+ `statDate` datetime NOT NULL COMMENT 'State entry date',
1012+ `scheduleID` int(8) NOT NULL,
1013+ `displayID` int(4) NOT NULL,
1014+ `layoutID` int(8) NOT NULL,
1015+ `mediaID` varchar(50) NOT NULL,
1016+ `start` datetime NOT NULL,
1017+ `end` datetime NOT NULL,
1018+ PRIMARY KEY (`statID`)
1019+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
1020+
1021+-- --------------------------------------------------------
1022+
1023+--
1024+-- Table structure for table `template`
1025+--
1026+
1027+CREATE TABLE IF NOT EXISTS `template` (
1028+ `templateID` int(11) NOT NULL auto_increment,
1029+ `template` varchar(50) NOT NULL,
1030+ `xml` text NOT NULL,
1031+ `permissionID` tinyint(6) NOT NULL,
1032+ `userID` int(11) NOT NULL,
1033+ `createdDT` datetime NOT NULL,
1034+ `modifiedDT` datetime NOT NULL,
1035+ `description` varchar(254) default NULL,
1036+ `tags` varchar(254) default NULL,
1037+ `thumbnail` varchar(100) default NULL,
1038+ `isSystem` tinyint(4) NOT NULL default '0',
1039+ `retired` tinyint(4) NOT NULL default '0',
1040+ PRIMARY KEY (`templateID`),
1041+ KEY `userID` (`userID`),
1042+ KEY `permissionID` (`permissionID`)
1043+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Templates for use on Layouts' AUTO_INCREMENT=5 ;
1044+
1045+-- --------------------------------------------------------
1046+
1047+--
1048+-- Table structure for table `user`
1049+--
1050+
1051+CREATE TABLE IF NOT EXISTS `user` (
1052+ `UserID` int(11) NOT NULL auto_increment,
1053+ `usertypeid` int(8) NOT NULL,
1054+ `UserName` varchar(15) character set latin1 NOT NULL,
1055+ `UserPassword` varchar(32) character set latin1 NOT NULL,
1056+ `loggedin` tinyint(1) NOT NULL default '0',
1057+ `lastaccessed` datetime default NULL,
1058+ `email` varchar(50) character set latin1 default NULL COMMENT 'The users email address',
1059+ `groupID` int(11) NOT NULL,
1060+ `homepage` varchar(254) NOT NULL default 'dashboard.php' COMMENT 'The users homepage',
1061+ PRIMARY KEY (`UserID`),
1062+ KEY `usertypeid` (`usertypeid`),
1063+ KEY `groupID` (`groupID`)
1064+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
1065+
1066+-- --------------------------------------------------------
1067+
1068+--
1069+-- Table structure for table `usertype`
1070+--
1071+
1072+CREATE TABLE IF NOT EXISTS `usertype` (
1073+ `usertypeid` int(8) NOT NULL,
1074+ `usertype` varchar(16) character set latin1 NOT NULL,
1075+ PRIMARY KEY (`usertypeid`)
1076+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
1077+
1078+-- --------------------------------------------------------
1079+
1080+--
1081+-- Table structure for table `version`
1082+--
1083+
1084+CREATE TABLE IF NOT EXISTS `version` (
1085+ `app_ver` varchar(10) NOT NULL COMMENT 'The Application Version'
1086+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Version information';
1087+
1088+
1089+--
1090+-- Dumping data for table `group`
1091+--
1092+
1093+INSERT INTO `group` (`groupID`, `group`) VALUES
1094+(1, 'Users');
1095+
1096+--
1097+-- Dumping data for table `lkpagegroup`
1098+--
1099+
1100+INSERT INTO `lkpagegroup` (`lkpagegroupID`, `pageID`, `groupID`) VALUES
1101+(12, 2, 1),
1102+(36, 1, 1),
1103+(37, 3, 1),
1104+(38, 19, 1),
1105+(48, 5, 1),
1106+(51, 7, 1),
1107+(54, 24, 1);
1108+
1109+
1110+--
1111+-- Dumping data for table `pagegroup`
1112+--
1113+
1114+INSERT INTO `pagegroup` (`pagegroupID`, `pagegroup`) VALUES
1115+(1, 'Schedule'),
1116+(2, 'Homepage and Login'),
1117+(3, 'Layouts'),
1118+(4, 'Content'),
1119+(7, 'Displays'),
1120+(8, 'Users and Groups'),
1121+(9, 'Reports'),
1122+(10, 'License and Settings'),
1123+(11, 'Updates');
1124+
1125+--
1126+-- Dumping data for table `pages`
1127+--
1128+
1129+INSERT INTO `pages` (`pageID`, `name`, `pagegroupID`) VALUES
1130+(1, 'dashboard', 2),
1131+(2, 'schedule', 1),
1132+(3, 'mediamanager', 2),
1133+(5, 'layout', 3),
1134+(7, 'content', 4),
1135+(11, 'display', 7),
1136+(12, 'update', 11),
1137+(14, 'admin', 10),
1138+(15, 'group', 8),
1139+(16, 'report', 9),
1140+(17, 'user', 8),
1141+(18, 'license', 10),
1142+(19, 'index', 2),
1143+(24, 'module', 4),
1144+(25, 'template', 3);
1145+
1146+--
1147+-- Dumping data for table `permission`
1148+--
1149+
1150+INSERT INTO `permission` (`permissionID`, `permission`) VALUES
1151+(1, 'Private'),
1152+(2, 'Group'),
1153+(3, 'Public');
1154+
1155+--
1156+-- Dumping data for table `resolution`
1157+--
1158+
1159+INSERT INTO `resolution` (`resolutionID`, `resolution`, `width`, `height`) VALUES
1160+(1, '4:3 Monitor', 800, 600),
1161+(2, '3:2 Tv', 720, 480),
1162+(3, '16:10 Widescreen Mon', 800, 500),
1163+(4, '16:9 HD Widescreen', 800, 450);
1164+
1165+--
1166+-- Dumping data for table `setting`
1167+--
1168+
1169+INSERT INTO `setting` (`settingid`, `setting`, `value`, `type`, `helptext`, `options`, `cat`, `userChange`) VALUES
1170+(1, 'defaultMedia', 'private', 'dropdown', 'Sets whether media is set to public or private by default.\r\n<br />\r\nWe recommend a setting of "Private"', 'private|public', 'default', 1),
1171+(2, 'defaultPlaylist', 'private', 'dropdown', 'Sets whether playlists are set to public or private by default.\r\n<br />\r\nCurrently there is only a private option.', 'private|public', 'default', 1),
1172+(3, 'defaultUsertype', 'user', 'dropdown', 'Sets the default user type selected when creating a user.\r\n<br />\r\nWe recommend that this is set to "User"', 'user|admin', 'default', 1),
1173+(5, 'debug', 'Off', 'dropdown', 'Sets whether debug information is recorded when an error occurs.\r\n<br />\r\nThis should be set to "off" to ensure smaller log sizes', 'On|Off', 'error', 1),
1174+(7, 'userModule', 'module_user_general.php', 'dirselect', 'This sets which user authentication module is currently being used.', NULL, 'user', 0),
1175+(10, 'adminMessage', '', 'text', 'Sets the admin message to be displayed on the client page at all times', NULL, 'general', 0),
1176+(11, 'defaultTimezone', 'Europe/London', 'dropdown', 'Set the default timezone for the application', 'Europe/London', 'default', 1),
1177+(18, 'mail_to', 'support@xibo.org.uk', 'text', 'Errors will be mailed here', NULL, 'error', 0),
1178+(19, 'mail_from', 'mail@yoursite.com', 'text', 'Mail will be sent from this address', NULL, 'error', 0),
1179+(20, 'BASE_URL', 'http://localhost/xibo/', 'text', 'This is the fully qualified URI of the site. e.g http://www.xibo.co.uk/', NULL, 'general', 0),
1180+(23, 'jpg_length', '10', 'text', 'Default length for JPG files (in seconds)', NULL, 'content', 1),
1181+(24, 'ppt_width', '1024', 'text', 'Default length for PPT files', NULL, 'content', 0),
1182+(25, 'ppt_height', '768', 'text', 'Default height for PPT files', NULL, 'content', 0),
1183+(26, 'ppt_length', '120', 'text', 'Default length for PPT files (in seconds)', NULL, 'content', 1),
1184+(29, 'swf_length', '60', 'text', 'Default length for SWF files', NULL, 'content', 1),
1185+(30, 'audit', 'Off', 'dropdown', 'Turn on the auditing information. Warning this will quickly fill up the log', 'On|Off', 'error', 1),
1186+(32, 'NUSOAP_PATH', '3rdparty/nuSoap/nusoap.php', 'text', NULL, NULL, 'path', 1),
1187+(33, 'LIBRARY_LOCATION', '', 'text', NULL, NULL, 'path', 1),
1188+(34, 'SERVER_KEY', 'xsm', 'text', NULL, NULL, 'general', 1);
1189+
1190+--
1191+-- Dumping data for table `template`
1192+--
1193+
1194+INSERT INTO `template` (`templateID`, `template`, `xml`, `permissionID`, `userID`, `createdDT`, `modifiedDT`, `description`, `tags`, `thumbnail`, `isSystem`, `retired`) VALUES
1195+(1, 'Full Screen 16:9', '<?xml version="1.0"?>\n<layout schemaVersion="1" width="800" height="450" bgcolor="#000000"><region id="47ff29524ce1b" width="800" height="450" top="0" left="0"/></layout>\n', 3, 1, '2008-01-01 01:00:00', '2008-01-01 01:00:00', '', 'fullscreen', NULL, 1, 0),
1196+(2, 'Full Screen 16:10', '<?xml version="1.0"?>\n<layout schemaVersion="1" width="800" height="500" bgcolor="#000000"><region id="47ff29524ce1b" width="800" height="500" top="0" left="0"/></layout>\n', 3, 1, '2008-01-01 01:00:00', '2008-01-01 01:00:00', '', 'fullscreen', NULL, 1, 0),
1197+(3, 'Full Screen 4:3', '<?xml version="1.0"?>\n<layout schemaVersion="1" width="800" height="600" bgcolor="#000000"><region id="47ff29524ce1b" width="800" height="600" top="0" left="0"/></layout>\n', 3, 1, '2008-01-01 01:00:00', '2008-01-01 01:00:00', '', 'fullscreen', NULL, 1, 0),
1198+(4, 'Full Screen 3:2', '<?xml version="1.0"?>\n<layout schemaVersion="1" width="720" height="480" bgcolor="#000000"><region id="47ff29524ce1b" width="720" height="480" top="0" left="0"/></layout>\n', 3, 1, '2008-01-01 01:00:00', '2008-01-01 01:00:00', '', 'fullscreen', NULL, 1, 0);
1199+
1200+--
1201+-- Dumping data for table `user`
1202+--
1203+
1204+INSERT INTO `user` (`UserID`, `usertypeid`, `UserName`, `UserPassword`, `loggedin`, `lastaccessed`, `email`, `groupID`, `homepage`) VALUES
1205+(1, 1, 'xibo_admin', '21232f297a57a5a743894a0e4a801fc3', 0, '2008-04-29 09:34:43', 'info@xibo.org.uk', 1, 'dashboard');
1206+
1207+--
1208+-- Dumping data for table `usertype`
1209+--
1210+
1211+INSERT INTO `usertype` (`usertypeid`, `usertype`) VALUES
1212+(1, 'Super Admin'),
1213+(2, 'Group Admin'),
1214+(3, 'User');
1215+
1216+--
1217+-- Dumping data for table `version`
1218+--
1219+
1220+INSERT INTO `version` (`app_ver`) VALUES
1221+('0.1.0');
1222+
1223+
1224+
1225+
1226+--
1227+-- Constraints for dumped tables
1228+--
1229+
1230+--
1231+-- Constraints for table `blacklist`
1232+--
1233+ALTER TABLE `blacklist`
1234+ ADD CONSTRAINT `blacklist_ibfk_1` FOREIGN KEY (`MediaID`) REFERENCES `media` (`mediaID`),
1235+ ADD CONSTRAINT `blacklist_ibfk_2` FOREIGN KEY (`DisplayID`) REFERENCES `display` (`displayid`);
1236+
1237+--
1238+-- Constraints for table `lklayoutmedia`
1239+--
1240+ALTER TABLE `lklayoutmedia`
1241+ ADD CONSTRAINT `lklayoutmedia_ibfk_1` FOREIGN KEY (`mediaID`) REFERENCES `media` (`mediaID`),
1242+ ADD CONSTRAINT `lklayoutmedia_ibfk_2` FOREIGN KEY (`layoutID`) REFERENCES `layout` (`layoutID`);
1243+
1244+--
1245+-- Constraints for table `lkpagegroup`
1246+--
1247+ALTER TABLE `lkpagegroup`
1248+ ADD CONSTRAINT `lkpagegroup_ibfk_1` FOREIGN KEY (`pageID`) REFERENCES `pages` (`pageID`),
1249+ ADD CONSTRAINT `lkpagegroup_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `group` (`groupID`);
1250+
1251+--
1252+-- Constraints for table `media`
1253+--
1254+ALTER TABLE `media`
1255+ ADD CONSTRAINT `media_ibfk_1` FOREIGN KEY (`permissionID`) REFERENCES `permission` (`permissionID`);
1256+
1257+--
1258+-- Constraints for table `pages`
1259+--
1260+ALTER TABLE `pages`
1261+ ADD CONSTRAINT `pages_ibfk_1` FOREIGN KEY (`pagegroupID`) REFERENCES `pagegroup` (`pagegroupID`);
1262+
1263+--
1264+-- Constraints for table `schedule`
1265+--
1266+ALTER TABLE `schedule`
1267+ ADD CONSTRAINT `schedule_ibfk_1` FOREIGN KEY (`layoutID`) REFERENCES `layout` (`layoutID`);
1268+
1269+--
1270+-- Constraints for table `schedule_detail`
1271+--
1272+ALTER TABLE `schedule_detail`
1273+ ADD CONSTRAINT `schedule_detail_ibfk_3` FOREIGN KEY (`displayID`) REFERENCES `display` (`displayid`),
1274+ ADD CONSTRAINT `schedule_detail_ibfk_4` FOREIGN KEY (`layoutID`) REFERENCES `layout` (`layoutID`),
1275+ ADD CONSTRAINT `schedule_detail_ibfk_5` FOREIGN KEY (`eventID`) REFERENCES `schedule` (`eventID`);
1276+
1277+--
1278+-- Constraints for table `template`
1279+--
1280+ALTER TABLE `template`
1281+ ADD CONSTRAINT `template_ibfk_3` FOREIGN KEY (`userID`) REFERENCES `user` (`UserID`),
1282+ ADD CONSTRAINT `template_ibfk_2` FOREIGN KEY (`permissionID`) REFERENCES `permission` (`permissionID`);
1283+
1284+--
1285+-- Constraints for table `user`
1286+--
1287+ALTER TABLE `user`
1288+ ADD CONSTRAINT `user_ibfk_2` FOREIGN KEY (`usertypeid`) REFERENCES `usertype` (`usertypeid`),
1289+ ADD CONSTRAINT `user_ibfk_3` FOREIGN KEY (`groupID`) REFERENCES `group` (`groupID`);
1290+
1291+
1292+
1293+-- AS of R22
1294+
1295+CREATE TABLE IF NOT EXISTS `lkmenuitemgroup` (
1296+ `LkMenuItemGroupID` int(11) NOT NULL auto_increment,
1297+ `GroupID` int(11) NOT NULL,
1298+ `MenuItemID` int(11) NOT NULL,
1299+ PRIMARY KEY (`LkMenuItemGroupID`),
1300+ KEY `GroupID` (`GroupID`),
1301+ KEY `MenuItemID` (`MenuItemID`)
1302+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
1303+
1304+INSERT INTO `lkmenuitemgroup` (`LkMenuItemGroupID`, `GroupID`, `MenuItemID`) VALUES
1305+(1, 1, 1),
1306+(2, 1, 2),
1307+(3, 1, 3),
1308+(4, 1, 14),
1309+(5, 1, 15),
1310+(6, 1, 16);
1311+
1312+CREATE TABLE IF NOT EXISTS `menu` (
1313+ `MenuID` smallint(6) NOT NULL auto_increment,
1314+ `Menu` varchar(50) NOT NULL,
1315+ PRIMARY KEY (`MenuID`),
1316+ UNIQUE KEY `Menu` (`Menu`)
1317+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='A Menu (or collection of links)' AUTO_INCREMENT=5 ;
1318+
1319+INSERT INTO `menu` (`MenuID`, `Menu`) VALUES
1320+(2, 'Dashboard'),
1321+(4, 'Management'),
1322+(3, 'Region Manager'),
1323+(1, 'Top Nav');
1324+
1325+CREATE TABLE IF NOT EXISTS `menuitem` (
1326+ `MenuItemID` int(11) NOT NULL auto_increment,
1327+ `MenuID` smallint(6) NOT NULL,
1328+ `PageID` int(11) NOT NULL,
1329+ `Args` varchar(254) default NULL,
1330+ `Text` varchar(20) NOT NULL,
1331+ `Class` varchar(50) default NULL,
1332+ `Img` varchar(254) default NULL,
1333+ `Sequence` smallint(6) NOT NULL default '1',
1334+ PRIMARY KEY (`MenuItemID`),
1335+ KEY `PageID` (`PageID`),
1336+ KEY `MenuID` (`MenuID`)
1337+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
1338+
1339+INSERT INTO `menuitem` (`MenuItemID`, `MenuID`, `PageID`, `Args`, `Text`, `Class`, `Img`, `Sequence`) VALUES
1340+(1, 1, 2, NULL, 'Schedule', NULL, NULL, 1),
1341+(2, 1, 5, NULL, 'Layout', NULL, NULL, 2),
1342+(3, 1, 7, NULL, 'Library', NULL, NULL, 3),
1343+(4, 1, 17, NULL, 'Management', NULL, NULL, 4),
1344+(7, 4, 11, NULL, 'Displays', NULL, NULL, 1),
1345+(8, 4, 15, NULL, 'Groups', NULL, NULL, 2),
1346+(9, 4, 17, NULL, 'Users', NULL, NULL, 3),
1347+(10, 4, 16, 'sp=log', 'Log', NULL, NULL, 4),
1348+(11, 4, 18, NULL, 'License', NULL, NULL, 5),
1349+(12, 4, 16, 'sp=sessions', 'Sessions', NULL, NULL, 6),
1350+(13, 4, 14, NULL, 'Settings', NULL, NULL, 7),
1351+(14, 2, 2, 'sp=month', 'Schedule', 'schedule_button', 'img/dashboard/scheduleview.png', 1),
1352+(15, 2, 5, NULL, 'Layouts', 'playlist_button', 'img/dashboard/presentations.png', 2),
1353+(16, 2, 7, NULL, 'Library', 'content_button', 'img/dashboard/content.png', 3),
1354+(17, 2, 25, NULL, 'Templates', 'layout_button', 'img/dashboard/layouts.png', 4),
1355+(18, 2, 17, NULL, 'Users', 'user_button', 'img/dashboard/users.png', 5),
1356+(19, 2, 14, NULL, 'Settings', 'settings_button', 'img/dashboard/settings.png', 6),
1357+(20, 2, 18, NULL, 'License', 'license_button', 'img/dashboard/license.png', 7),
1358+(21, 3, 5, 'q=RegionOptions&[[layoutid]]&[[regionid]]', 'Edit your Display', 'playlist_button', 'img/dashboard/edit_content.png', 1);
1359+
1360+ALTER TABLE `lkmenuitemgroup`
1361+ ADD CONSTRAINT `lkmenuitemgroup_ibfk_1` FOREIGN KEY (`GroupID`) REFERENCES `group` (`groupID`),
1362+ ADD CONSTRAINT `lkmenuitemgroup_ibfk_2` FOREIGN KEY (`MenuItemID`) REFERENCES `menuitem` (`MenuItemID`);
1363+
1364+ALTER TABLE `menuitem`
1365+ ADD CONSTRAINT `menuitem_ibfk_1` FOREIGN KEY (`MenuID`) REFERENCES `menu` (`MenuID`),
1366+ ADD CONSTRAINT `menuitem_ibfk_2` FOREIGN KEY (`PageID`) REFERENCES `pages` (`pageID`);
1367+
1368+-- Run the Below for code greater than R30
1369+ALTER TABLE `module` ADD `RegionSpecific` TINYINT NOT NULL DEFAULT '1' AFTER `Enabled` ;
1370+ALTER TABLE `module` ADD `ImageUri` VARCHAR( 254 ) NOT NULL AFTER `Description` ;
1371+ALTER TABLE `module` ADD `SchemaVersion` INT NOT NULL DEFAULT '1' AFTER `ImageUri` ;
1372+
1373+
1374+-- AS of R32
1375+INSERT INTO `setting` (`settingid`,`setting` ,`value` ,`type` ,`helptext` ,`options` ,`cat` ,`userChange`)
1376+VALUES (NULL , 'HELP_BASE', 'http://www.xibo.org.uk/manual/', 'text', NULL , NULL , 'path', '0');
1377+
1378+DELETE FROM module;
1379+
1380+INSERT INTO `module` (`ModuleID`, `Module`, `Enabled`, `RegionSpecific`, `Description`, `ImageUri`, `SchemaVersion`) VALUES
1381+(1, 'Image', 1, 0, 'Images. PNG, JPG, BMP, GIF', 'img/forms/image.gif', 1),
1382+(2, 'Video', 1, 0, 'Videos. WMV.', 'img/forms/video.gif', 1),
1383+(3, 'Flash', 1, 0, 'Flash', 'img/forms/flash.gif', 1),
1384+(4, 'Powerpoint', 1, 0, 'Powerpoint. PPT, PPS', 'img/forms/powerpoint.gif', 1),
1385+(5, 'Webpage', 1, 1, 'Webpages.', 'img/forms/webpage.gif', 1),
1386+(6, 'Ticker', 1, 1, 'RSS Ticker.', 'img/forms/ticker.gif', 1),
1387+(7, 'Text', 1, 1, 'Text. With Directional Controls.', 'img/forms/text.gif', 1);
1388+
1389+-- As of R50 ish
1390+ALTER TABLE `display` CHANGE `license` `license` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;
1391+
1392+-- As of R55 ish
1393+ALTER TABLE `version` ADD `XmdsVersion` SMALLINT NOT NULL ,
1394+ADD `XlfVersion` SMALLINT NOT NULL ;
1395+
1396+UPDATE `version` SET `XmdsVersion` = '1', `XlfVersion` = '1' LIMIT 1 ;
1397+
1398+-- From ServerInstaller branch.
1399+>>>>>>> MERGE-SOURCE
1400 ALTER TABLE `version` ADD `DBVersion` INT NOT NULL DEFAULT '1';
1401\ No newline at end of file
1402
1403=== added file 'server/install/database/10.sql'
1404--- server/install/database/10.sql 1970-01-01 00:00:00 +0000
1405+++ server/install/database/10.sql 2010-02-02 19:49:10 +0000
1406@@ -0,0 +1,30 @@
1407+INSERT INTO `pagegroup` (
1408+`pagegroupID` ,
1409+`pagegroup`
1410+)
1411+VALUES (
1412+NULL , 'Templates'
1413+);
1414+
1415+ALTER TABLE `pages` DROP FOREIGN KEY `pages_ibfk_1` ;
1416+
1417+ALTER TABLE `pages` ADD FOREIGN KEY ( `pagegroupID` ) REFERENCES `pagegroup` (
1418+`pagegroupID`
1419+);
1420+
1421+INSERT INTO `pages` (name, pagegroupid)
1422+SELECT 'resolution', pagegroupid FROM `pagegroup` WHERE pagegroup = 'Templates';
1423+
1424+INSERT INTO `menuitem` (`MenuID`, `PageID`, `Args`, `Text`, `Class`, `Img`, `Sequence`)
1425+SELECT '4', pageID, NULL, 'Resolutions', NULL, NULL, '10' FROM pages WHERE name = 'resolution';
1426+
1427+INSERT INTO `menuitem` (`MenuID`, `PageID`, `Args`, `Text`, `Class`, `Img`, `Sequence`)
1428+SELECT '4', pageID, NULL, 'Templates', NULL, NULL, '10' FROM pages WHERE name = 'template';
1429+
1430+UPDATE `module` SET `Module` = 'PowerPoint' WHERE `module`.`ModuleID` = 4 LIMIT 1 ;
1431+
1432+ALTER TABLE `layout` CHANGE `xml` `xml` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
1433+
1434+UPDATE `version` SET `app_ver` = '1.0.6';
1435+UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1436+UPDATE `version` SET `DBVersion` = '10';
1437\ No newline at end of file
1438
1439=== added file 'server/install/database/5.sql.OTHER'
1440--- server/install/database/5.sql.OTHER 1970-01-01 00:00:00 +0000
1441+++ server/install/database/5.sql.OTHER 2010-02-02 19:49:10 +0000
1442@@ -0,0 +1,3 @@
1443+UPDATE `version` SET `app_ver` = '1.0.1';
1444+UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1445+UPDATE `version` SET `DBVersion` = '5';
1446
1447=== modified file 'server/install/database/8.sql'
1448--- server/install/database/8.sql 2009-12-31 11:38:50 +0000
1449+++ server/install/database/8.sql 2010-02-02 19:49:10 +0000
1450@@ -1,20 +1,40 @@
1451-
1452-ALTER TABLE `module` ADD `ValidExtensions` VARCHAR( 254 ) NULL ;
1453-
1454-UPDATE `module` SET `ValidExtensions` = 'jpg,jpeg,png,bmp,gif' WHERE `module`.`ModuleID` =1 LIMIT 1 ;
1455-
1456-UPDATE `module` SET `ValidExtensions` = 'wmv,avi,mpg,mpeg' WHERE `module`.`ModuleID` =2 LIMIT 1 ;
1457-
1458-UPDATE `module` SET `ValidExtensions` = 'swf' WHERE `module`.`ModuleID` =3 LIMIT 1 ;
1459-
1460-UPDATE `module` SET `ValidExtensions` = 'ppt,pps' WHERE `module`.`ModuleID` =4 LIMIT 1 ;
1461-
1462-
1463-/* Add the MD5 and FileSize as columns to the media table */
1464-ALTER TABLE `media` ADD `MD5` VARCHAR( 32 ) NULL AFTER `storedAs` ,
1465-ADD `FileSize` BIGINT NULL AFTER `MD5` ;
1466-
1467-
1468-UPDATE `version` SET `app_ver` = '1.0.4';
1469-UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1470-UPDATE `version` SET `DBVersion` = '8';
1471+<<<<<<< TREE
1472+
1473+ALTER TABLE `module` ADD `ValidExtensions` VARCHAR( 254 ) NULL ;
1474+
1475+UPDATE `module` SET `ValidExtensions` = 'jpg,jpeg,png,bmp,gif' WHERE `module`.`ModuleID` =1 LIMIT 1 ;
1476+
1477+UPDATE `module` SET `ValidExtensions` = 'wmv,avi,mpg,mpeg' WHERE `module`.`ModuleID` =2 LIMIT 1 ;
1478+
1479+UPDATE `module` SET `ValidExtensions` = 'swf' WHERE `module`.`ModuleID` =3 LIMIT 1 ;
1480+
1481+UPDATE `module` SET `ValidExtensions` = 'ppt,pps' WHERE `module`.`ModuleID` =4 LIMIT 1 ;
1482+
1483+
1484+/* Add the MD5 and FileSize as columns to the media table */
1485+ALTER TABLE `media` ADD `MD5` VARCHAR( 32 ) NULL AFTER `storedAs` ,
1486+ADD `FileSize` BIGINT NULL AFTER `MD5` ;
1487+
1488+
1489+UPDATE `version` SET `app_ver` = '1.0.4';
1490+UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1491+UPDATE `version` SET `DBVersion` = '8';
1492+=======
1493+ALTER TABLE `module` ADD `ValidExtensions` VARCHAR( 254 ) NULL ;
1494+
1495+UPDATE `module` SET `ValidExtensions` = 'jpg,jpeg,png,bmp,gif' WHERE `module`.`ModuleID` =1 LIMIT 1 ;
1496+
1497+UPDATE `module` SET `ValidExtensions` = 'wmv,avi,mpg,mpeg' WHERE `module`.`ModuleID` =2 LIMIT 1 ;
1498+
1499+UPDATE `module` SET `ValidExtensions` = 'swf' WHERE `module`.`ModuleID` =3 LIMIT 1 ;
1500+
1501+UPDATE `module` SET `ValidExtensions` = 'ppt,pps' WHERE `module`.`ModuleID` =4 LIMIT 1 ;
1502+
1503+/* Add the MD5 and FileSize as columns to the media table */
1504+ALTER TABLE `media` ADD `MD5` VARCHAR( 32 ) NULL AFTER `storedAs` ,
1505+ADD `FileSize` BIGINT NULL AFTER `MD5` ;
1506+
1507+UPDATE `version` SET `app_ver` = '1.0.4';
1508+UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1509+UPDATE `version` SET `DBVersion` = '8';
1510+>>>>>>> MERGE-SOURCE
1511
1512=== modified file 'server/install/database/9.sql'
1513--- server/install/database/9.sql 2009-12-31 11:38:50 +0000
1514+++ server/install/database/9.sql 2010-02-02 19:49:10 +0000
1515@@ -1,3 +1,4 @@
1516+<<<<<<< TREE
1517 INSERT INTO `pages` (
1518 `pageID` ,
1519 `name` ,
1520@@ -16,3 +17,21 @@
1521 UPDATE `version` SET `app_ver` = '1.0.5';
1522 UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1523 UPDATE `version` SET `DBVersion` = '9';
1524+=======
1525+INSERT INTO `pages` (
1526+`name` ,
1527+`pagegroupID`
1528+)
1529+VALUES (
1530+'manual', '2'
1531+);
1532+
1533+INSERT INTO `menuitem` (`MenuID`, `PageID`, `Args`, `Text`, `Class`, `Img`, `Sequence`)
1534+SELECT '2', pageID, 'http://wiki.xibo.org.uk/wiki/Manual:TOC', 'Manual', 'help_button', 'img/dashboard/help.png', '10' FROM pages WHERE name = 'manual';
1535+
1536+UPDATE `module` SET `ValidExtensions` = 'ppt,pps,pptx' WHERE `module`.`ModuleID` =4 LIMIT 1 ;
1537+
1538+UPDATE `version` SET `app_ver` = '1.0.5';
1539+UPDATE `setting` SET `value` = 0 WHERE `setting` = 'PHONE_HOME_DATE';
1540+UPDATE `version` SET `DBVersion` = '9';
1541+>>>>>>> MERGE-SOURCE
1542
1543=== modified file 'server/lib/app/app_functions.php'
1544--- server/lib/app/app_functions.php 2009-12-31 11:38:50 +0000
1545+++ server/lib/app/app_functions.php 2010-02-02 19:49:10 +0000
1546@@ -1,3 +1,4 @@
1547+<<<<<<< TREE
1548 <?php
1549 /*
1550 * Xibo - Digitial Signage - http://www.xibo.org.uk
1551@@ -544,4 +545,645 @@
1552 return $qty;
1553 }
1554 }
1555+=======
1556+<?php
1557+/*
1558+ * Xibo - Digitial Signage - http://www.xibo.org.uk
1559+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
1560+ *
1561+ * This file is part of Xibo.
1562+ *
1563+ * Xibo is free software: you can redistribute it and/or modify
1564+ * it under the terms of the GNU Affero General Public License as published by
1565+ * the Free Software Foundation, either version 3 of the License, or
1566+ * any later version.
1567+ *
1568+ * Xibo is distributed in the hope that it will be useful,
1569+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1570+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1571+ * GNU Affero General Public License for more details.
1572+ *
1573+ * You should have received a copy of the GNU Affero General Public License
1574+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
1575+ */
1576+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
1577+
1578+define('VAR_FOR_SQL',1);
1579+
1580+define('MSG_MODE_MANUAL',2);
1581+define('MSG_MODE_AUTO',1);
1582+
1583+define('AJAX_REDIRECT',3);
1584+define('AJAX_SUCCESS_NOREDIRECT',4);
1585+define('AJAX_SUCCESS_REFRESH',5);
1586+define('AJAX_LOAD_FORM',6);
1587+
1588+/**
1589+ * Sets a message to display, this is checked when each page loads
1590+ *
1591+ * @param string $message
1592+ */
1593+function setMessage($message) {
1594+ if (!isset($_SESSION['message'])) $_SESSION['message'] = "";
1595+ $_SESSION['message'] .= "$message<br />";
1596+}
1597+
1598+function displayMessage($mode = MSG_MODE_AUTO, $msg="", $show_back = true, $template = "template/pages/message_page.php")
1599+{
1600+ switch ($mode)
1601+ {
1602+
1603+ case MSG_MODE_AUTO:
1604+ if (isset($_SESSION['message']))
1605+ {
1606+ echo "<div class=\"highlight\">" . $_SESSION['message'] . "</div>";
1607+ unset($_SESSION['message']);
1608+ }
1609+ break;
1610+
1611+ //Displays a manual message
1612+ case MSG_MODE_MANUAL:
1613+ $errorMessage = $msg;
1614+ //clear the object buffer - so we only see this error message
1615+ //ob_get_clean();
1616+ include($template);
1617+ break;
1618+ }
1619+}
1620+
1621+// Returns a drop down list based on the provided SQL - the ID should be the first field, and the name the second
1622+function dropdownlist($SQL, $list_name, $selected = "", $callback = "", $flat_list = false, $checkPermissions = false, $userid = "", $permissionLevel = "see", $useQueryId = false) {
1623+ global $db;
1624+ global $user;
1625+
1626+ if (!$result = $db->query($SQL))
1627+ {
1628+ trigger_error($db->error());
1629+ return "Query Error";
1630+ }
1631+
1632+ if ($db->num_rows($result)==0)
1633+ {
1634+ $list = "No selections available";
1635+ return $list;
1636+ }
1637+
1638+ if ($flat_list)
1639+ {
1640+ //we want to generate a flat list of option | value pairs
1641+ $list = "";
1642+
1643+ while ($results = $db->get_row($result))
1644+ {
1645+ $col0 = $results[0];
1646+ $col1 = $results[1];
1647+
1648+ if ($checkPermissions)
1649+ {
1650+ $permissionid = $results[2];
1651+ $ownerid = $results[3];
1652+
1653+ if ($useQueryId)
1654+ {
1655+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $col0);
1656+ }
1657+ else
1658+ {
1659+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $userid);
1660+ }
1661+
1662+ if (($permissionLevel == "see" && $see_permissions) || $permissionLevel == "edit" && $edit_permissions) {
1663+ $list .= "$col0|$col1,";
1664+ }
1665+ }
1666+ else
1667+ {
1668+ $list .= "$col0|$col1,";
1669+ }
1670+ }
1671+ //trim the commas
1672+ $list = rtrim($list,",");
1673+ }
1674+ else
1675+ {
1676+ $list = <<<END
1677+ <select name="$list_name" id="$list_name" $callback>
1678+END;
1679+ while ($results = $db->get_row($result))
1680+ {
1681+ $col0 = $results[0];
1682+ $col1 = $results[1];
1683+
1684+ if ($checkPermissions)
1685+ {
1686+ $permissionid = $results[2];
1687+ $ownerid = $results[3];
1688+
1689+ if ($useQueryId)
1690+ {
1691+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $col0);
1692+ }
1693+ else
1694+ {
1695+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $userid);
1696+ }
1697+
1698+ if (($permissionLevel == "see" && $see_permissions) || $permissionLevel == "edit" && $edit_permissions)
1699+ {
1700+ if ($col0 == $selected)
1701+ {
1702+ $list .= "<option value='" . $col0 . "' selected>" . $col1 . "</option>\n";
1703+ }
1704+ else
1705+ {
1706+ $list .= "<option value='" . $col0 . "'>" . $col1 . "</option>\n";
1707+ }
1708+ }
1709+ }
1710+ else
1711+ {
1712+ if ($col0 == $selected)
1713+ {
1714+ $list .= "<option value='" . $col0 . "' selected>" . $col1 . "</option>\n";
1715+ }
1716+ else
1717+ {
1718+ $list .= "<option value='" . $col0 . "'>" . $col1 . "</option>\n";
1719+ }
1720+ }
1721+ }
1722+ $list .= "</select>\n";
1723+ }
1724+ return $list;
1725+}
1726+
1727+function listcontent($list_string, $list_name, $selected = "", $callback = "")
1728+{
1729+ //generates a list based on a list option | value, list
1730+ if ($list_string == "") return "Empty list content";
1731+
1732+ $list_string = rtrim($list_string,","); //clean up
1733+
1734+ $list_values = explode(",", $list_string); //gives us each option value pair
1735+
1736+ $list = <<<END
1737+ <select name="$list_name" id="$list_name" $callback>
1738+END;
1739+ foreach ($list_values as $list_option)
1740+ {
1741+
1742+ $option = explode("|", $list_option);
1743+
1744+ $col0 = $option[0];
1745+ $col1 = $option[1];
1746+
1747+ if ($col0 == $selected)
1748+ {
1749+ $list .= "<option value='" . $col0 . "' selected>" . $col1 . "</option>\n";
1750+ }
1751+ else
1752+ {
1753+ $list .= "<option value='" . $col0 . "'>" . $col1 . "</option>\n";
1754+ }
1755+ }
1756+ $list .= "</select>\n";
1757+
1758+ return $list;
1759+}
1760+
1761+
1762+//generates a list of all the users - assuming that the SQL given contains userid's
1763+function userlist($SQL)
1764+{
1765+ global $db;
1766+ global $user;
1767+
1768+ if (!$result = $db->query($SQL))
1769+ {
1770+ trigger_error($db->error());
1771+ return "Query Error";
1772+ }
1773+
1774+ if ($db->num_rows($result)==0)
1775+ {
1776+ $list = "No selections available";
1777+ return $list;
1778+ }
1779+
1780+ while ($row = $db->get_row($result))
1781+ {
1782+
1783+ $userid = $row[0];
1784+ $username = $user->getNameFromID($userid);
1785+
1786+ $user_ids[] = array('id'=>$userid);
1787+ $user_names[] = array('name'=>$username);
1788+ }
1789+
1790+ array_multisort($user_names, SORT_DESC, $user_ids, SORT_ASC); //sorts the two arrays, so that the usernames are Alpha sorted, and the ID's tag along
1791+
1792+ $list = "";
1793+ foreach ($user_names as $key => $row)
1794+ {
1795+
1796+ if($list != "") $list .= ","; //if we arnt equal to the first, append a seperator
1797+
1798+ $list .= $user_ids[$key]['id']."|".$row['name'];
1799+ }
1800+ return $list;
1801+}
1802+
1803+/**
1804+ * Sets a session variable from a javascript call (so when we XMLHTTPRequest we can set a sesson var)
1805+ * @return
1806+ * @param $page Object
1807+ * @param $var Object
1808+ * @param $value Object
1809+ */
1810+function setSession($page, $var, $value)
1811+{
1812+ $_SESSION[$page][$var] = $value;
1813+
1814+ return true;
1815+}
1816+
1817+/**
1818+ * Depricate
1819+ * @return
1820+ * @param $var Object
1821+ * @param $purpose Object
1822+ * @param $db Object[optional]
1823+ */
1824+function clean_input($var, $purpose, $db = false)
1825+{
1826+ /*Cleans the $var depending on the $purpose*/
1827+
1828+ switch ($purpose)
1829+ {
1830+
1831+ case VAR_FOR_SQL:
1832+ if (!$db)
1833+ {
1834+ trigger_error("Trying to clean a var for SQL, but no DB passed", E_USER_ERROR);
1835+ }
1836+
1837+ if (!get_magic_quotes_gpc())
1838+ {
1839+ $var = $db->escape_string($var);
1840+ }
1841+
1842+ break;
1843+
1844+ }
1845+
1846+ return $var;
1847+}
1848+
1849+
1850+function sec2hms($sec, $padHours = false)
1851+{
1852+ // holds formatted string
1853+ $hms = "";
1854+
1855+ // there are 3600 seconds in an hour, so if we
1856+ // divide total seconds by 3600 and throw away
1857+ // the remainder, we've got the number of hours
1858+ $hours = intval(intval($sec) / 3600);
1859+
1860+ // add to $hms, with a leading 0 if asked for
1861+ $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':':$hours . ':';
1862+
1863+ // dividing the total seconds by 60 will give us
1864+ // the number of minutes, but we're interested in
1865+ // minutes past the hour: to get that, we need to
1866+ // divide by 60 again and keep the remainder
1867+ $minutes = intval(($sec / 60) % 60);
1868+
1869+ // then add to $hms (with a leading 0 if needed)
1870+ $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':';
1871+
1872+ // seconds are simple - just divide the total
1873+ // seconds by 60 and keep the remainder
1874+ $seconds = intval($sec % 60);
1875+
1876+ // add to $hms, again with a leading 0 if needed
1877+ $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
1878+
1879+ // done!
1880+ return $hms;
1881+}
1882+
1883+/**
1884+ * Gets web safe colors
1885+ * @return
1886+ */
1887+function gwsc($list_name, $selected)
1888+{
1889+
1890+ $cs = array('00', '33', '66', '99', 'CC', 'FF');
1891+
1892+ $list = <<<END
1893+ <select name="$list_name" id="$list_name">
1894+END;
1895+
1896+ for($i=0; $i<6; $i++)
1897+ {
1898+ for($j=0; $j<6; $j++)
1899+ {
1900+ for($k=0; $k<6; $k++)
1901+ {
1902+ $c = $cs[$i] .$cs[$j] .$cs[$k];
1903+
1904+ if ($c == $selected)
1905+ {
1906+ $list .= "<option value='".$c."' selected style='background: #$c; color:#$c'>#$c</option>";
1907+ }
1908+ else
1909+ {
1910+ $list .= "<option value='".$c."' style='background: #$c; color:#$c'>#$c</option>";
1911+ }
1912+ }
1913+ }
1914+ }
1915+
1916+ $list .= "</select>\n";
1917+
1918+ return $list;
1919+}
1920+
1921+/**
1922+ * Resizes the image
1923+ * Based on code from the Web - cannot find source.
1924+ * If this is your code please send a mail to info@xibo.org.uk
1925+ * to arrange for correct acknowledgement to be printed.
1926+ * @return
1927+ * @param $file Object The Source File
1928+ * @param $target Object The Target File
1929+ * @param $width Object[optional] The Width
1930+ * @param $height Object[optional] The Height
1931+ * @param $proportional Object[optional] Proportional Resize
1932+ * @param $output Object[optional] file|browser|return
1933+ * @param $delete_original Object[optional]
1934+ * @param $use_linux_commands Object[optional]
1935+ */
1936+function ResizeImage( $file, $target = "", $width = 0, $height = 0, $proportional = false, $output = 'file', $delete_original = false, $use_linux_commands = false )
1937+{
1938+ if ( $height <= 0 && $width <= 0 )
1939+ {
1940+ return false;
1941+ }
1942+
1943+ $info = getimagesize($file);
1944+ $image = '';
1945+
1946+ $final_width = 0;
1947+ $final_height = 0;
1948+ list($width_old, $height_old) = $info;
1949+
1950+ if ($proportional)
1951+ {
1952+ if ($width == 0) $factor = $height/$height_old;
1953+ elseif ($height == 0) $factor = $width/$width_old;
1954+ else $factor = min ( $width / $width_old, $height / $height_old);
1955+
1956+ $final_width = round ($width_old * $factor);
1957+ $final_height = round ($height_old * $factor);
1958+
1959+ }
1960+ else
1961+ {
1962+ $final_width = ( $width <= 0 ) ? $width_old : $width;
1963+ $final_height = ( $height <= 0 ) ? $height_old : $height;
1964+ }
1965+
1966+ switch ( $info[2] )
1967+ {
1968+ case IMAGETYPE_GIF:
1969+ $image = imagecreatefromgif($file);
1970+ break;
1971+ case IMAGETYPE_JPEG:
1972+ $image = imagecreatefromjpeg($file);
1973+ break;
1974+ case IMAGETYPE_PNG:
1975+ $image = imagecreatefrompng($file);
1976+ break;
1977+ default:
1978+ return false;
1979+ }
1980+
1981+ $image_resized = imagecreatetruecolor( $final_width, $final_height );
1982+
1983+ if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) )
1984+ {
1985+ $trnprt_indx = imagecolortransparent($image);
1986+
1987+ // If we have a specific transparent color
1988+ if ($trnprt_indx >= 0)
1989+ {
1990+
1991+ // Get the original image's transparent color's RGB values
1992+ $trnprt_color = imagecolorsforindex($image, $trnprt_indx);
1993+
1994+ // Allocate the same color in the new image resource
1995+ $trnprt_indx = imagecolorallocate($image_resized, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']);
1996+
1997+ // Completely fill the background of the new image with allocated color.
1998+ imagefill($image_resized, 0, 0, $trnprt_indx);
1999+
2000+ // Set the background color for new image to transparent
2001+ imagecolortransparent($image_resized, $trnprt_indx);
2002+ }
2003+ // Always make a transparent background color for PNGs that don't have one allocated already
2004+ elseif ($info[2] == IMAGETYPE_PNG)
2005+ {
2006+ // Turn off transparency blending (temporarily)
2007+ imagealphablending($image_resized, false);
2008+
2009+ // Create a new transparent color for image
2010+ $color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127);
2011+
2012+ // Completely fill the background of the new image with allocated color.
2013+ imagefill($image_resized, 0, 0, $color);
2014+
2015+ // Restore transparency blending
2016+ imagesavealpha($image_resized, true);
2017+ }
2018+ }
2019+
2020+ imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $final_width, $final_height, $width_old, $height_old);
2021+
2022+ if ( $delete_original )
2023+ {
2024+ if ( $use_linux_commands )
2025+ exec('rm '.$file);
2026+ else
2027+ @unlink($file);
2028+ }
2029+
2030+ switch ( strtolower($output) )
2031+ {
2032+ case 'browser':
2033+ $mime = image_type_to_mime_type($info[2]);
2034+ header("Content-type: $mime");
2035+ $output = NULL;
2036+ break;
2037+ case 'file':
2038+ $output = $target;
2039+ break;
2040+ case 'return':
2041+ return $image_resized;
2042+ break;
2043+ default:
2044+ break;
2045+ }
2046+
2047+ switch ( $info[2] ) {
2048+ case IMAGETYPE_GIF:
2049+ imagegif($image_resized, $output);
2050+ break;
2051+ case IMAGETYPE_JPEG:
2052+ imagejpeg($image_resized, $output, 70);
2053+ break;
2054+ case IMAGETYPE_PNG:
2055+ imagepng($image_resized, $output, 5);
2056+ break;
2057+ default:
2058+ return false;
2059+ }
2060+
2061+ return true;
2062+}
2063+
2064+/**
2065+ * Cleans a file name
2066+ * @return
2067+ * @param $filename String
2068+ */
2069+function cleanFilename($name)
2070+{
2071+ $name = strtolower($name);
2072+ $code_entities_match = array( '&quot;' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--');
2073+ $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-');
2074+
2075+ $name = str_replace($code_entities_match, $code_entities_replace, $name);
2076+ return $name;
2077+}
2078+
2079+/**
2080+ * Depricate
2081+ * @return
2082+ * @param $number Object
2083+ */
2084+function CleanNumber($number)
2085+{
2086+ if (!is_numeric($number))
2087+ {
2088+ header("HTTP/1.1 404 Not Found");
2089+ // How do I send the default apache 404 message
2090+ // instead of the message below?
2091+ print("<html><body>HTTP 404 - Possible Hack.</body></html>");
2092+ exit;
2093+ }
2094+ return $number;
2095+}
2096+
2097+/**
2098+ * Depricate
2099+ * @return
2100+ * @param $var Object
2101+ */
2102+function validate($var)
2103+{
2104+ $valid = true;
2105+
2106+ // Validate against XSS
2107+ if (strstr($var, "http")) $valid = false;
2108+ if (strstr($var, "www")) $valid = false;
2109+
2110+ if (eregi('[^A-Za-z0-9_]', $var)) $valid = false;
2111+
2112+ if (!$valid)
2113+ {
2114+ header("HTTP/1.1 404 Not Found");
2115+ // How do I send the default apache 404 message
2116+ // instead of the message below?
2117+ print("<html><body>HTTP 404 - Possible Hack.</body></html>");
2118+ exit;
2119+ }
2120+
2121+ return $var;
2122+}
2123+
2124+/**
2125+* Creates a form token
2126+* @return
2127+*/
2128+function CreateFormToken($tokenName = "token")
2129+{
2130+ //Store in the users session
2131+ $token = md5(uniqid()."xsmsalt".time());
2132+
2133+ $_SESSION[$tokenName] = $token;
2134+ $_SESSION[$tokenName.'_timeout'] = time();
2135+
2136+ return $token;
2137+}
2138+
2139+/**
2140+ * Checks a form token
2141+ * @param string token
2142+ * @return
2143+ */
2144+function CheckFormToken($token, $tokenName = "token")
2145+{
2146+ global $db;
2147+
2148+ if ($token == $_SESSION[$tokenName])
2149+ {
2150+ // See if its still in Date
2151+ if (($_SESSION[$tokenName.'_timeout'] + 1200) <= time())
2152+ {
2153+ return false;
2154+ }
2155+ return true;
2156+ }
2157+ else
2158+ {
2159+ Debug::LogEntry($db, 'error', "Form token incorrect from: ". $_SERVER['REMOTE_ADDR']. " with token [$token]");
2160+ return false;
2161+ }
2162+}
2163+
2164+/**
2165+ * Convert a shorthand byte value from a PHP configuration directive to an integer value
2166+ * @param string $value
2167+ * @return int
2168+ */
2169+function convertBytes( $value )
2170+{
2171+ if ( is_numeric( $value ) )
2172+ {
2173+ return $value;
2174+ }
2175+ else
2176+ {
2177+ $value_length = strlen( $value );
2178+ $qty = substr( $value, 0, $value_length - 1 );
2179+ $unit = strtolower( substr( $value, $value_length - 1 ) );
2180+ switch ( $unit )
2181+ {
2182+ case 'k':
2183+ $qty *= 1024;
2184+ break;
2185+ case 'm':
2186+ $qty *= 1048576;
2187+ break;
2188+ case 'g':
2189+ $qty *= 1073741824;
2190+ break;
2191+ }
2192+ return $qty;
2193+ }
2194+}
2195+>>>>>>> MERGE-SOURCE
2196 ?>
2197\ No newline at end of file
2198
2199=== modified file 'server/lib/app/debug.class.php'
2200--- server/lib/app/debug.class.php 2009-12-31 11:38:50 +0000
2201+++ server/lib/app/debug.class.php 2010-02-02 19:49:10 +0000
2202@@ -1,3 +1,4 @@
2203+<<<<<<< TREE
2204 <?php
2205 /*
2206 * Xibo - Digitial Signage - http://www.xibo.org.uk
2207@@ -187,4 +188,196 @@
2208 return true;
2209 }
2210 }
2211+=======
2212+<?php
2213+/*
2214+ * Xibo - Digitial Signage - http://www.xibo.org.uk
2215+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
2216+ *
2217+ * This file is part of Xibo.
2218+ *
2219+ * Xibo is free software: you can redistribute it and/or modify
2220+ * it under the terms of the GNU Affero General Public License as published by
2221+ * the Free Software Foundation, either version 3 of the License, or
2222+ * any later version.
2223+ *
2224+ * Xibo is distributed in the hope that it will be useful,
2225+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2226+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2227+ * GNU Affero General Public License for more details.
2228+ *
2229+ * You should have received a copy of the GNU Affero General Public License
2230+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
2231+ */
2232+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2233+
2234+class Debug
2235+{
2236+
2237+ public function __construct()
2238+ {
2239+ global $db;
2240+
2241+ if (!defined('AUDIT'))
2242+ {
2243+ // Get the setting from the DB and define it
2244+ if (Config::GetSetting($db, 'audit') != 'On')
2245+ {
2246+ define('AUDIT', false);
2247+ }
2248+ else
2249+ {
2250+ define('AUDIT', true);
2251+ }
2252+ }
2253+ }
2254+
2255+ public function ErrorHandler($errno, $errmsg, $filename, $linenum, $vars) {
2256+
2257+ global $db;
2258+
2259+ // timestamp for the error entry
2260+ $dt = date("Y-m-d H:i:s (T)");
2261+
2262+ // define an assoc array of error string
2263+ // in reality the only entries we should
2264+ // consider are E_WARNING, E_NOTICE, E_USER_ERROR,
2265+ // E_USER_WARNING and E_USER_NOTICE
2266+ $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE =>
2267+ 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error',
2268+ E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error',
2269+ E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error',
2270+ E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT =>
2271+ 'Runtime Notice', E_RECOVERABLE_ERROR => 'Recoverable Error');
2272+
2273+ // set of errors for which a var trace will be saved
2274+ $user_errors_halt = array(E_USER_ERROR);
2275+ $user_errors_inline = array(E_USER_WARNING);
2276+
2277+ $err = "<errormsg>" . $errmsg . "</errormsg>\n";
2278+ $err .= "<errornum>" . $errno . "</errornum>\n";
2279+ $err .= "<errortype>" . $errortype[$errno] . "</errortype>\n";
2280+ $err .= "<scriptname>" . $filename . "</scriptname>\n";
2281+ $err .= "<scriptlinenum>" . $linenum . "</scriptlinenum>\n";
2282+
2283+ // Log everything
2284+ Debug::LogEntry($db, "error", $err);
2285+
2286+ // Test to see if this is a HALT error or not (we do the same if we are in production or not!)
2287+ if (in_array($errno, $user_errors_halt))
2288+ {
2289+ // We have a halt error
2290+ Debug::LogEntry($db, 'audit', 'Creating a Response Manager to deal with the HALT Error.');
2291+
2292+ $response = new ResponseManager();
2293+
2294+ $response->SetError($errmsg);
2295+ $response->Respond();
2296+ }
2297+
2298+ // Is Debug Enabled? (i.e. Development or Support)
2299+ if (error_reporting() != 0)
2300+ {
2301+ if (in_array($errno, $user_errors_inline))
2302+ {
2303+ // This is an inline error - therefore we really want to pop up a message box with this in it - so we know?
2304+ // For now we treat this like a halt error? Or do we just try and output some javascript to pop up an error
2305+ // surely the javascript idea wont work in ajax?
2306+ // or prehaps we add this to the session errormessage so we see it at a later date?
2307+ echo $errmsg;
2308+ die();
2309+ }
2310+ }
2311+
2312+ // Must return false
2313+ return false;
2314+ }
2315+
2316+ /**
2317+ * Mail an error - currently disabled
2318+ * @return
2319+ * @param $errmsg Object
2320+ * @param $err Object
2321+ */
2322+ function MailError($errmsg, $err)
2323+ {
2324+ global $db;
2325+
2326+ return true;
2327+
2328+ $to = 'info@xibo.org.uk';
2329+
2330+ $from = Config::GetSetting($db, "mail_from");
2331+ if ($from == "") return true;
2332+
2333+ $subject = "Error message from Xibo";
2334+ $message = wordwrap("$errmsg\n$err");
2335+
2336+ $headers = "From: $from" . "\r\n" . "Reply-To: $from" . "\r\n" .
2337+ "X-Mailer: PHP/" . phpversion();
2338+
2339+ if (!mail($to, $subject, $message, $headers)) trigger_error("Mail not accepted", E_USER_NOTICE);
2340+ return true;
2341+ }
2342+
2343+ /**
2344+ * Write an Entry to the Log table
2345+ * @return
2346+ * @param $db Object
2347+ * @param $type Object
2348+ * @param $message Object
2349+ * @param $page Object[optional]
2350+ * @param $function Object[optional]
2351+ * @param $logdate Object[optional]
2352+ * @param $displayid Object[optional]
2353+ * @param $scheduleID Object[optional]
2354+ * @param $layoutid Object[optional]
2355+ * @param $mediaid Object[optional]
2356+ */
2357+ static function LogEntry(database $db, $type, $message, $page = "", $function = "", $logdate = "", $displayid = 0, $scheduleID = 0, $layoutid = 0, $mediaid = 0)
2358+ {
2359+ if ($type == 'audit' && !AUDIT)
2360+ {
2361+ return;
2362+ }
2363+
2364+ $currentdate = date("Y-m-d H:i:s");
2365+ $requestUri = Kit::GetParam('REQUEST_URI', $_SERVER, _STRING, 'Not Supplied');
2366+ $requestIp = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING, 'Not Supplied');
2367+ $requestUserAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'Not Supplied');
2368+ $userid = Kit::GetParam('userid', _SESSION, _INT, 0);
2369+ $message = Kit::ValidateParam($message, _HTMLSTRING);
2370+
2371+ if ($logdate == "") $logdate = $currentdate;
2372+
2373+ //Prepare the variables
2374+ if ($page == "")
2375+ {
2376+ $page = Kit::GetParam('p', _GET, _WORD);
2377+ }
2378+
2379+ $SQL = "INSERT INTO log (logdate, type, page, function, message, RequestUri, RemoteAddr, UserAgent, UserID, displayID, scheduleID, layoutID, mediaID) ";
2380+ $SQL .= sprintf("VALUES ('$logdate','$type', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d)",
2381+ $db->escape_string($page),
2382+ $db->escape_string($function),
2383+ $db->escape_string($message),
2384+ $db->escape_string($requestUri),
2385+ $db->escape_string($requestIp),
2386+ $db->escape_string($requestUserAgent),
2387+ $userid, $displayid, $scheduleID, $layoutid, $mediaid);
2388+
2389+ if (!$db->query($SQL))
2390+ {
2391+ // Log the original message
2392+ error_log($message . "\n\n", 3, "./err_log.xml");
2393+
2394+ // Log the log failure
2395+ $message = $db->error();
2396+ error_log($message . "\n\n", 3, "./err_log.xml");
2397+ }
2398+
2399+ return true;
2400+ }
2401+}
2402+>>>>>>> MERGE-SOURCE
2403 ?>
2404\ No newline at end of file
2405
2406=== modified file 'server/lib/app/formmanager.class.php'
2407--- server/lib/app/formmanager.class.php 2009-12-31 11:38:50 +0000
2408+++ server/lib/app/formmanager.class.php 2010-02-02 19:49:10 +0000
2409@@ -1,3 +1,4 @@
2410+<<<<<<< TREE
2411 <?php
2412 /*
2413 * Xibo - Digitial Signage - http://www.xibo.org.uk
2414@@ -150,4 +151,158 @@
2415 return $list;
2416 }
2417 }
2418+=======
2419+<?php
2420+/*
2421+ * Xibo - Digitial Signage - http://www.xibo.org.uk
2422+ * Copyright (C) 2006,2007,2008 Daniel Garner
2423+ *
2424+ * This file is part of Xibo.
2425+ *
2426+ * Xibo is free software: you can redistribute it and/or modify
2427+ * it under the terms of the GNU Affero General Public License as published by
2428+ * the Free Software Foundation, either version 3 of the License, or
2429+ * any later version.
2430+ *
2431+ * Xibo is distributed in the hope that it will be useful,
2432+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2433+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2434+ * GNU Affero General Public License for more details.
2435+ *
2436+ * You should have received a copy of the GNU Affero General Public License
2437+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
2438+ */
2439+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2440+
2441+class FormManager
2442+{
2443+ private $db;
2444+ private $user;
2445+
2446+ public function __construct(database $db, user $user)
2447+ {
2448+ $this->db =& $db;
2449+ $this->user =& $user;
2450+ }
2451+
2452+ /**
2453+ * Returns a drop down list based on the provided SQL - the ID should be the first field, and the name the second
2454+ * @return
2455+ * @param $SQL Object
2456+ * @param $list_name Object
2457+ * @param $selected Object[optional]
2458+ * @param $callback Object[optional]
2459+ * @param $flat_list Object[optional]
2460+ * @param $checkPermissions Object[optional]
2461+ * @param $userid Object[optional]
2462+ * @param $permissionLevel Object[optional]
2463+ * @param $useQueryId Object[optional]
2464+ */
2465+ public function DropDown($SQL, $list_name, $selected = "", $callback = "", $flat_list = false, $checkPermissions = false, $userid = "", $permissionLevel = "see", $useQueryId = false)
2466+ {
2467+ $db =& $this->db;
2468+ $user =& $this->user;
2469+
2470+ if (!$result = $db->query($SQL))
2471+ {
2472+ trigger_error($db->error());
2473+ return "Query Error";
2474+ }
2475+
2476+ if ($db->num_rows($result)==0)
2477+ {
2478+ $list = "No selections available";
2479+ return $list;
2480+ }
2481+
2482+ if ($flat_list)
2483+ {
2484+ //we want to generate a flat list of option | value pairs
2485+ $list = "";
2486+
2487+ while ($results = $db->get_row($result))
2488+ {
2489+ $col0 = $results[0];
2490+ $col1 = $results[1];
2491+
2492+ if ($checkPermissions)
2493+ {
2494+ $permissionid = $results[2];
2495+ $ownerid = $results[3];
2496+
2497+ if ($useQueryId)
2498+ {
2499+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $col0);
2500+ }
2501+ else
2502+ {
2503+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $userid);
2504+ }
2505+
2506+ if (($permissionLevel == "see" && $see_permissions) || $permissionLevel == "edit" && $edit_permissions) {
2507+ $list .= "$col0|$col1,";
2508+ }
2509+ }
2510+ else
2511+ {
2512+ $list .= "$col0|$col1,";
2513+ }
2514+ }
2515+ //trim the commas
2516+ $list = rtrim($list,",");
2517+ }
2518+ else
2519+ {
2520+ $list = <<<END
2521+ <select name="$list_name" id="$list_name" $callback>
2522+END;
2523+ while ($results = $db->get_row($result))
2524+ {
2525+ $col0 = $results[0];
2526+ $col1 = $results[1];
2527+
2528+ if ($checkPermissions)
2529+ {
2530+ $permissionid = $results[2];
2531+ $ownerid = $results[3];
2532+
2533+ if ($useQueryId)
2534+ {
2535+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $col0);
2536+ }
2537+ else
2538+ {
2539+ list($see_permissions , $edit_permissions) = $user->eval_permission($ownerid, $permissionid, $userid);
2540+ }
2541+
2542+ if (($permissionLevel == "see" && $see_permissions) || $permissionLevel == "edit" && $edit_permissions)
2543+ {
2544+ if ($col0 == $selected)
2545+ {
2546+ $list .= "<option value='" . $col0 . "' selected>" . $col1 . "</option>\n";
2547+ }
2548+ else
2549+ {
2550+ $list .= "<option value='" . $col0 . "'>" . $col1 . "</option>\n";
2551+ }
2552+ }
2553+ }
2554+ else
2555+ {
2556+ if ($col0 == $selected)
2557+ {
2558+ $list .= "<option value='" . $col0 . "' selected>" . $col1 . "</option>\n";
2559+ }
2560+ else
2561+ {
2562+ $list .= "<option value='" . $col0 . "'>" . $col1 . "</option>\n";
2563+ }
2564+ }
2565+ }
2566+ $list .= "</select>\n";
2567+ }
2568+ return $list;
2569+ }
2570+}
2571+>>>>>>> MERGE-SOURCE
2572 ?>
2573\ No newline at end of file
2574
2575=== modified file 'server/lib/app/helpmanager.class.php'
2576--- server/lib/app/helpmanager.class.php 2009-12-31 11:38:50 +0000
2577+++ server/lib/app/helpmanager.class.php 2010-02-02 19:49:10 +0000
2578@@ -1,3 +1,4 @@
2579+<<<<<<< TREE
2580 <?php
2581 /*
2582 * Xibo - Digitial Signage - http://www.xibo.org.uk
2583@@ -112,3 +113,99 @@
2584 }
2585 }
2586 ?>
2587+=======
2588+<?php
2589+/*
2590+ * Xibo - Digitial Signage - http://www.xibo.org.uk
2591+ * Copyright (C) 2006,2007,2008 Daniel Garner
2592+ *
2593+ * This file is part of Xibo.
2594+ *
2595+ * Xibo is free software: you can redistribute it and/or modify
2596+ * it under the terms of the GNU Affero General Public License as published by
2597+ * the Free Software Foundation, either version 3 of the License, or
2598+ * any later version.
2599+ *
2600+ * Xibo is distributed in the hope that it will be useful,
2601+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2602+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2603+ * GNU Affero General Public License for more details.
2604+ *
2605+ * You should have received a copy of the GNU Affero General Public License
2606+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
2607+ */
2608+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2609+
2610+class HelpManager
2611+{
2612+ private $db;
2613+ private $user;
2614+
2615+ /**
2616+ * Constructs the Module Manager.
2617+ * @return
2618+ * @param $db Object
2619+ * @param $user Object
2620+ */
2621+ public function __construct(database $db, User $user)
2622+ {
2623+ $this->db =& $db;
2624+ $this->user =& $user;
2625+ }
2626+
2627+ /**
2628+ * Help Button
2629+ * @return
2630+ * @param $location Object
2631+ * @param $return Object[optional]
2632+ */
2633+ public function HelpButton($location, $return = false)
2634+ {
2635+ $db =& $this->db;
2636+
2637+ $helpBase = Config::GetSetting($db, 'HELP_BASE');
2638+
2639+ $link = $helpBase . "?p=$location";
2640+
2641+ $button = <<<END
2642+ <input type="button" onclick="window.open('$link')" value="Help" />
2643+END;
2644+
2645+ if ($return)
2646+ {
2647+ return $button;
2648+ }
2649+ else
2650+ {
2651+ echo $button;
2652+ return true;
2653+ }
2654+ }
2655+
2656+ /**
2657+ * Help Icon
2658+ * @return
2659+ * @param $title Object
2660+ * @param $return Object[optional]
2661+ * @param $image Object[optional]
2662+ * @param $alt Object[optional]
2663+ */
2664+ public function HelpIcon($title, $return = false, $image = "img/forms/info_icon.gif", $alt = "Hover for more info")
2665+ {
2666+ $button = <<<END
2667+ <img src="$image" alt="$alt" title="$title">
2668+END;
2669+
2670+ if ($return)
2671+ {
2672+ return $button;
2673+ }
2674+ else
2675+ {
2676+ echo $button;
2677+ return true;
2678+ }
2679+ }
2680+}
2681+?>
2682+>>>>>>> MERGE-SOURCE
2683
2684=== modified file 'server/lib/app/kit.class.php'
2685--- server/lib/app/kit.class.php 2009-12-31 11:38:50 +0000
2686+++ server/lib/app/kit.class.php 2010-02-02 19:49:10 +0000
2687@@ -1,3 +1,4 @@
2688+<<<<<<< TREE
2689 <?php
2690 /*
2691 * Xibo - Digitial Signage - http://www.xibo.org.uk
2692@@ -367,4 +368,305 @@
2693 return $fullUrl;
2694 }
2695 }
2696-?>
2697\ No newline at end of file
2698+?>=======
2699+<?php
2700+/*
2701+ * Xibo - Digitial Signage - http://www.xibo.org.uk
2702+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
2703+ *
2704+ * This file is part of Xibo.
2705+ *
2706+ * Xibo is free software: you can redistribute it and/or modify
2707+ * it under the terms of the GNU Affero General Public License as published by
2708+ * the Free Software Foundation, either version 3 of the License, or
2709+ * any later version.
2710+ *
2711+ * Xibo is distributed in the hope that it will be useful,
2712+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2713+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2714+ * GNU Affero General Public License for more details.
2715+ *
2716+ * You should have received a copy of the GNU Affero General Public License
2717+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
2718+ */
2719+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
2720+
2721+define('_SESSION', "session");
2722+define('_POST', "post");
2723+define('_GET', "get");
2724+define('_REQUEST', "request");
2725+
2726+define('_STRING', "string");
2727+define('_HTMLSTRING', 'htmlstring');
2728+define('_PASSWORD', "password");
2729+define('_INT', "int");
2730+define('_DOUBLE', "double");
2731+define('_BOOL', "bool");
2732+define('_WORD', "word");
2733+define('_ARRAY', "array");
2734+define('_USERNAME', "username");
2735+define('_CHECKBOX', "checkbox");
2736+define('_FILENAME', "filename");
2737+define('_URI', "uri");
2738+
2739+class Kit
2740+{
2741+ // Ends the current execution and issues a redirect - should only be called before headers have been sent (i.e. no output)
2742+ static function Redirect($page, $message = '', $pageIsUrl = false)
2743+ {
2744+ $url = $page;
2745+ $ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);
2746+
2747+ if ($ajax)
2748+ {
2749+ echo json_encode($page);
2750+ die();
2751+ }
2752+
2753+ // Header or JS redirect
2754+ if (headers_sent())
2755+ {
2756+ echo "<script>document.location.href='$url';</script>\n";
2757+ }
2758+ else
2759+ {
2760+ header( 'HTTP/1.1 301 Moved Permanently' );
2761+ header( 'Location: ' . $url );
2762+ }
2763+
2764+ die();
2765+ }
2766+
2767+ /**
2768+ * Gets the appropriate Param, making sure its valid
2769+ * Based on code from Joomla! 1.5
2770+ * @return
2771+ * @param $param Object
2772+ * @param $source Object[optional]
2773+ * @param $type Object[optional]
2774+ * @param $default Object[optional]
2775+ */
2776+ static public function GetParam($param, $source = _POST, $type = _STRING, $default = '')
2777+ {
2778+ if (is_array($source))
2779+ {
2780+ if(!isset($source[$param]))
2781+ {
2782+ $return = $default;
2783+ }
2784+ else
2785+ {
2786+ $return = $source[$param];
2787+ }
2788+ }
2789+ else
2790+ {
2791+ switch ($source)
2792+ {
2793+ case 'session':
2794+
2795+ if(!isset($_SESSION[$param]))
2796+ {
2797+ $return = $default;
2798+ }
2799+ else if ($type == _CHECKBOX)
2800+ {
2801+ // this means that it was defined correctly and it was set
2802+ $return = 1;
2803+ }
2804+ else
2805+ {
2806+ if ($_SESSION[$param] == '') return $default;
2807+
2808+ $return = $_SESSION[$param];
2809+ }
2810+
2811+ break;
2812+
2813+ case 'request':
2814+
2815+ if(!isset($_REQUEST[$param]))
2816+ {
2817+ $return = $default;
2818+ }
2819+ else
2820+ {
2821+ if ($_REQUEST[$param] == '') return $default;
2822+
2823+ $return = $_REQUEST[$param];
2824+ }
2825+
2826+ break;
2827+
2828+ case 'get':
2829+
2830+ if(!isset($_GET[$param]))
2831+ {
2832+ $return = $default;
2833+ }
2834+ else
2835+ {
2836+ if ($_GET[$param] == '') return $default;
2837+
2838+ $return = $_GET[$param];
2839+ }
2840+
2841+ break;
2842+
2843+ case 'post':
2844+
2845+ if(!isset($_POST[$param]))
2846+ {
2847+ $return = $default;
2848+ }
2849+ else if ($type == _CHECKBOX)
2850+ {
2851+ // this means that it was defined correctly and it was set
2852+ $return = 1;
2853+ }
2854+ else
2855+ {
2856+ if ($_POST[$param] == '') return $default;
2857+
2858+ $return = $_POST[$param];
2859+ }
2860+
2861+ break;
2862+
2863+ default:
2864+ return $default;
2865+ }
2866+ }
2867+
2868+ // Validate this param
2869+ return Kit::ValidateParam($return, $type);
2870+ }
2871+
2872+ /**
2873+ * Validates a Parameter
2874+ * Based on code from Joomla! 1.5
2875+ * @return
2876+ * @param $param Object
2877+ * @param $type Object
2878+ */
2879+ static function ValidateParam($param, $type)
2880+ {
2881+ // If we are a NULL always return a null
2882+ if ($param == "") return "";
2883+
2884+ $return = $param;
2885+
2886+ // Validate
2887+ // Handle the type constraint
2888+ switch ($type)
2889+ {
2890+ case _INT :
2891+ // Only use the first integer value
2892+ @ preg_match('/-?[0-9]+/', $return, $matches);
2893+ $return = @ (int) $matches[0];
2894+ break;
2895+
2896+ case _DOUBLE :
2897+ // Only use the first floating point value
2898+ @ preg_match('/-?[0-9]+(\.[0-9]+)?/', $return, $matches);
2899+ $return = @ (float) $matches[0];
2900+ break;
2901+
2902+ case _BOOL :
2903+ $return = (bool) $return;
2904+ break;
2905+
2906+ case _ARRAY :
2907+ if (!is_array($return))
2908+ {
2909+ $return = array ($return);
2910+ }
2911+ break;
2912+
2913+ case _STRING :
2914+ case _PASSWORD :
2915+ $return = htmlentities($return);
2916+ $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation
2917+ // convert hex
2918+ $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation
2919+ $return = (string) $return;
2920+ break;
2921+
2922+ case _HTMLSTRING :
2923+ $return = preg_replace('/&#(\d+);/me', "chr(\\1)", $return); // decimal notation
2924+ // convert hex
2925+ $return = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $return); // hex notation
2926+ $return = (string) $return;
2927+ break;
2928+
2929+ case _WORD :
2930+ $return = (string) preg_replace( '/[^A-Z_]\\-/i', '', $return );
2931+ break;
2932+
2933+ case _USERNAME :
2934+ $return = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $return );
2935+ $return = strtolower($return);
2936+ break;
2937+
2938+ case _FILENAME :
2939+ // Remove non alphanumerics
2940+ $return = strtolower($return);
2941+ $code_entities_match = array('&quot;' ,'!' ,'@' ,'#' ,'$' ,'%' ,'^' ,'&' ,'*' ,'(' ,')' ,'+' ,'{' ,'}' ,'|' ,':' ,'"' ,'<' ,'>' ,'?' ,'[' ,']' ,'' ,';' ,"'" ,',' ,'_' ,'/' ,'*' ,'+' ,'~' ,'`' ,'=' ,' ' ,'---' ,'--','--');
2942+ $code_entities_replace = array('' ,'-' ,'-' ,'' ,'' ,'' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-' ,'' ,'' ,'' ,'' ,'' ,'-' ,'-' ,'-','-');
2943+
2944+ $return = str_replace($code_entities_match, $code_entities_replace, $return);
2945+ break;
2946+
2947+ case _URI :
2948+ $return = urlencode($return);
2949+ break;
2950+
2951+ case _CHECKBOX:
2952+ if ($return == 'on') $return = 1;
2953+ if ($return == 'off') $return = 0;
2954+
2955+ default :
2956+ // No casting necessary
2957+ break;
2958+ }
2959+
2960+ return $return;
2961+ }
2962+
2963+ /**
2964+ * Gets a formatted Url
2965+ * @return
2966+ * @param $page Object[optional]
2967+ */
2968+ public static function GetURL($page = "")
2969+ {
2970+ $page = ValidateParam($page, _WORD);
2971+ $fullUrl = 'http';
2972+
2973+ if($_SERVER['HTTPS']=='on')
2974+ {
2975+ $fullUrl .= 's';
2976+ }
2977+
2978+ $fullUrl .= '://';
2979+
2980+ if($_SERVER['SERVER_PORT']!='80')
2981+ {
2982+ $fullUrl .= $_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].$_SERVER['SCRIPT_NAME'];
2983+ }
2984+ else
2985+ {
2986+ $fullUrl .= $_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
2987+ }
2988+
2989+ // Append the page if its not empty
2990+ if ($page != '')
2991+ {
2992+ $fullUrl .= '?p=' . $page;
2993+ }
2994+
2995+ return $fullUrl;
2996+ }
2997+}
2998+?>
2999+>>>>>>> MERGE-SOURCE
3000
3001=== modified file 'server/lib/app/menumanager.class.php'
3002--- server/lib/app/menumanager.class.php 2009-12-31 11:38:50 +0000
3003+++ server/lib/app/menumanager.class.php 2010-02-02 19:49:10 +0000
3004@@ -1,3 +1,4 @@
3005+<<<<<<< TREE
3006 <?php
3007 /*
3008 * Xibo - Digitial Signage - http://www.xibo.org.uk
3009@@ -110,4 +111,118 @@
3010 return $this->theMenu[$i];
3011 }
3012 }
3013+=======
3014+<?php
3015+/*
3016+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3017+ * Copyright (C) 2006,2007,2008 Daniel Garner
3018+ *
3019+ * This file is part of Xibo.
3020+ *
3021+ * Xibo is free software: you can redistribute it and/or modify
3022+ * it under the terms of the GNU Affero General Public License as published by
3023+ * the Free Software Foundation, either version 3 of the License, or
3024+ * any later version.
3025+ *
3026+ * Xibo is distributed in the hope that it will be useful,
3027+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3028+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3029+ * GNU Affero General Public License for more details.
3030+ *
3031+ * You should have received a copy of the GNU Affero General Public License
3032+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
3033+ */
3034+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
3035+
3036+class MenuManager
3037+{
3038+ private $db;
3039+ private $user;
3040+ private $p;
3041+ private $q;
3042+
3043+ private $ajax;
3044+ private $userid;
3045+ public $message;
3046+
3047+ private $theMenu;
3048+ private $current;
3049+ private $numberItems;
3050+
3051+ public function __construct(database $db, User $user, $menu)
3052+ {
3053+ $this->db =& $db;
3054+ $this->user =& $user;
3055+ $this->ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);
3056+ $this->q = Kit::GetParam('q', _REQUEST, _WORD);
3057+ $this->userid = Kit::GetParam('userid', _SESSION, _INT);
3058+ $usertypeid = Kit::GetParam('usertype', _SESSION, _INT);
3059+
3060+ if ($menu == '')
3061+ {
3062+ $this->message = 'No menu provided';
3063+ return false;
3064+ }
3065+
3066+ if (!$this->theMenu = $user->MenuAuth($menu))
3067+ {
3068+ $this->message = 'No permissions for this menu.';
3069+ return false;
3070+ }
3071+
3072+ // Set some information about this menu
3073+ $this->current = 0;
3074+ $this->numberItems = count($this->theMenu);
3075+
3076+ // We dont want to do 0 items
3077+ if ($this->numberItems == 0) $this->numberItems = -1;
3078+
3079+ $this->message = $this->numberItems . ' menu items loaded';
3080+
3081+ return true;
3082+ }
3083+
3084+ /**
3085+ * Returns the internal message
3086+ * @return
3087+ */
3088+ public function GetMessage()
3089+ {
3090+ return $this->message;
3091+ }
3092+
3093+ /**
3094+ * Gets the next menu item in the queue
3095+ * @return
3096+ */
3097+ public function GetNextMenuItem()
3098+ {
3099+ if (!$item = $this->GetMenuItem($this->current))
3100+ {
3101+ $message = 'No more items';
3102+ return false;
3103+ }
3104+
3105+ $this->current++;
3106+
3107+ return $item;
3108+ }
3109+
3110+ /**
3111+ * Gets the menu item at position i
3112+ * @return
3113+ * @param $i Object
3114+ */
3115+ public function GetMenuItem($i)
3116+ {
3117+ if ($i >= $this->numberItems)
3118+ {
3119+ $this->message = 'There are only ' . $this->numberItems . ' menu items in this menu.';
3120+ return false;
3121+ }
3122+
3123+ return $this->theMenu[$i];
3124+ }
3125+}
3126+>>>>>>> MERGE-SOURCE
3127 ?>
3128\ No newline at end of file
3129
3130=== modified file 'server/lib/app/pagemanager.class.php'
3131--- server/lib/app/pagemanager.class.php 2009-12-31 11:38:50 +0000
3132+++ server/lib/app/pagemanager.class.php 2010-02-02 19:49:10 +0000
3133@@ -1,3 +1,4 @@
3134+<<<<<<< TREE
3135 <?php
3136 /*
3137 * Xibo - Digitial Signage - http://www.xibo.org.uk
3138@@ -139,4 +140,147 @@
3139 return;
3140 }
3141 }
3142+=======
3143+<?php
3144+/*
3145+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3146+ * Copyright (C) 2006,2007,2008 Daniel Garner
3147+ *
3148+ * This file is part of Xibo.
3149+ *
3150+ * Xibo is free software: you can redistribute it and/or modify
3151+ * it under the terms of the GNU Affero General Public License as published by
3152+ * the Free Software Foundation, either version 3 of the License, or
3153+ * any later version.
3154+ *
3155+ * Xibo is distributed in the hope that it will be useful,
3156+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3157+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3158+ * GNU Affero General Public License for more details.
3159+ *
3160+ * You should have received a copy of the GNU Affero General Public License
3161+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
3162+ */
3163+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
3164+
3165+// I think this will be where the magic happens.
3166+// This will control the callouts from the included page
3167+class PageManager
3168+{
3169+ private $db;
3170+ private $user;
3171+
3172+ private $p;
3173+ private $q;
3174+
3175+ private $page;
3176+ private $path;
3177+ private $ajax;
3178+ private $userid;
3179+ private $authed;
3180+ private $thePage;
3181+
3182+ function __construct(database $db, user $user, $page)
3183+ {
3184+ $this->db =& $db;
3185+ $this->user =& $user;
3186+ $this->path = 'lib/pages/' . $page . '.class.php';
3187+ $this->page = $page . 'DAO';
3188+ $this->p = $page;
3189+ $this->authed = false;
3190+
3191+ $this->ajax = Kit::GetParam('ajax', _REQUEST, _BOOL, false);
3192+ $this->q = Kit::GetParam('q', _REQUEST, _WORD);
3193+ $this->userid = Kit::GetParam('userid', _SESSION, _INT);
3194+
3195+ if(!class_exists($this->page))
3196+ {
3197+ require_once($this->path);
3198+ }
3199+
3200+ return;
3201+ }
3202+
3203+ /**
3204+ * Checks the Security of the logged in user
3205+ * @return
3206+ */
3207+ public function Authenticate()
3208+ {
3209+ $db =& $this->db;
3210+ $user =& $this->user;
3211+
3212+ // create a user object (will try to login)
3213+ // we must do this after executing any functions otherwise we will be logged
3214+ // out again before exec any log in function calls
3215+ if ($this->q != 'login' && $this->q != 'logout')
3216+ {
3217+ // Attempt a user login
3218+ if (!$user->attempt_login($this->ajax))
3219+ {
3220+ return false;
3221+ }
3222+
3223+ $this->authed = $user->PageAuth($this->p);
3224+ }
3225+ else
3226+ {
3227+ // automatically have permission for the login / forgotten details functions
3228+ // these are the only 2 functions at the moment that allow anonomous access
3229+ $this->authed = true;
3230+ }
3231+
3232+ return true;
3233+ }
3234+
3235+ /**
3236+ * Renders this page
3237+ * @return
3238+ */
3239+ public function Render()
3240+ {
3241+ $db =& $this->db;
3242+ $user =& $this->user;
3243+
3244+ if (!$this->authed)
3245+ {
3246+ // Output some message to say that we are not authed
3247+ trigger_error("You do not have permission to access this page.", E_USER_ERROR);
3248+ exit;
3249+ }
3250+
3251+ // Create the requested page
3252+ $this->thePage = new $this->page($db, $user);
3253+
3254+ if ($this->q != '')
3255+ {
3256+ if (method_exists($this->thePage, $this->q))
3257+ {
3258+ $function = $this->q;
3259+ $reloadLocation = $this->thePage->$function();
3260+ }
3261+ else
3262+ {
3263+ trigger_error($this->p . ' does not support the function: ' . $this->q, E_USER_ERROR);
3264+ }
3265+
3266+ if ($this->ajax) exit;
3267+
3268+ // once we have dealt with it, reload the page
3269+ Kit::Redirect($reloadLocation);
3270+ }
3271+ else
3272+ {
3273+ // Display a page instead
3274+ include("template/header.php");
3275+
3276+ $this->thePage->displayPage();
3277+
3278+ include("template/footer.php");
3279+ }
3280+
3281+ return;
3282+ }
3283+}
3284+>>>>>>> MERGE-SOURCE
3285 ?>
3286\ No newline at end of file
3287
3288=== modified file 'server/lib/app/session.class.php'
3289--- server/lib/app/session.class.php 2009-09-22 19:18:00 +0000
3290+++ server/lib/app/session.class.php 2010-02-02 19:49:10 +0000
3291@@ -101,13 +101,13 @@
3292
3293 if (!$db->query(sprintf("UPDATE session SET session_expiration = $newExp, isExpired = 0 WHERE session_id = '%s' ", $db->escape_string($key))))
3294 {
3295- log_entry($db, "error", $db->error());
3296+ Debug::LogEntry($db, "error", $db->error());
3297 }
3298 }
3299 else
3300 {
3301 // Its set - but its wrong - not good
3302- log_entry($db, "error", "Incorrect SecurityToken from " . $remoteAddr);
3303+ Debug::LogEntry($db, "error", "Incorrect SecurityToken from " . $remoteAddr);
3304
3305 $this->isExpired = 1;
3306 }
3307@@ -126,12 +126,12 @@
3308
3309 function write($key, $val)
3310 {
3311- $db =& $this->db;
3312+ $db =& $this->db;
3313
3314- $newExp = time() + $this->max_lifetime;
3315+ $newExp = time() + $this->max_lifetime;
3316 $lastaccessed = date("Y-m-d H:i:s");
3317- $userAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'No user agent');
3318- $remoteAddr = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING);
3319+ $userAgent = Kit::GetParam('HTTP_USER_AGENT', $_SERVER, _STRING, 'No user agent');
3320+ $remoteAddr = Kit::GetParam('REMOTE_ADDR', $_SERVER, _STRING);
3321
3322 $result = $db->query(sprintf("SELECT session_id FROM session WHERE session_id = '%s'", $db->escape_string($key)));
3323
3324@@ -158,7 +158,7 @@
3325
3326 if(!$db->query($SQL))
3327 {
3328- log_entry($db, "error", $db->error());
3329+ Debug::LogEntry($db, "error", $db->error());
3330 return(false);
3331 }
3332
3333@@ -173,16 +173,20 @@
3334
3335 $result = $db->query("$SQL");
3336
3337- if (!$result) log_entry($db,'audit',$db->error());
3338+ if (!$result) Debug::LogEntry($db,'audit',$db->error());
3339
3340 return $result;
3341 }
3342
3343 function gc($max_lifetime)
3344 {
3345- $db =& $this->db;
3346-
3347- return $db->query("UPDATE session SET IsExpired = 1 WHERE session_expiration < ".time());
3348+ $db =& $this->db;
3349+
3350+ // Delete sessions older than 10 times the max lifetime
3351+ $SQL = sprintf("DELETE FROM session WHERE IsExpired = 1 AND session_expiration < %d", time() - ($max_lifetime * 10));
3352+ $db->query($SQL);
3353+
3354+ return $db->query(sprintf("UPDATE session SET IsExpired = 1 WHERE session_expiration < %d", time()));
3355 }
3356
3357 function set_user($key, $userid)
3358@@ -203,19 +207,19 @@
3359 * Updates the session ID with a new one
3360 * @return
3361 */
3362- public function RegenerateSessionID($oldSessionID)
3363- {
3364- $db =& $this->db;
3365-
3366- session_regenerate_id(false);
3367-
3368- $new_sess_id = session_id();
3369-
3370- $this->key = $new_sess_id;
3371-
3372- $query = sprintf("UPDATE session SET session_id = '%s' WHERE session_id = '%s'", $db->escape_string($new_sess_id), $db->escape_string($oldSessionID));
3373- $db->query($query);
3374- }
3375+ public function RegenerateSessionID($oldSessionID)
3376+ {
3377+ $db =& $this->db;
3378+
3379+ session_regenerate_id(false);
3380+
3381+ $new_sess_id = session_id();
3382+
3383+ $this->key = $new_sess_id;
3384+
3385+ $query = sprintf("UPDATE session SET session_id = '%s' WHERE session_id = '%s'", $db->escape_string($new_sess_id), $db->escape_string($oldSessionID));
3386+ $db->query($query);
3387+ }
3388
3389 function set_page($key, $lastpage)
3390 {
3391@@ -243,7 +247,7 @@
3392
3393 if (!$db->query($SQL))
3394 {
3395- log_entry($db, "error", $db->error());
3396+ Debug::LogEntry($db, "error", $db->error());
3397 }
3398 }
3399
3400@@ -255,7 +259,7 @@
3401
3402 if (!$db->query($SQL))
3403 {
3404- log_entry($db, "error", $db->error());
3405+ Debug::LogEntry($db, "error", $db->error());
3406 }
3407 }
3408
3409
3410=== modified file 'server/lib/data/data.class.php'
3411--- server/lib/data/data.class.php 2009-12-31 11:38:50 +0000
3412+++ server/lib/data/data.class.php 2010-02-02 19:49:10 +0000
3413@@ -1,3 +1,4 @@
3414+<<<<<<< TREE
3415 <?php
3416 /*
3417 * Xibo - Digitial Signage - http://www.xibo.org.uk
3418@@ -79,4 +80,85 @@
3419 return;
3420 }
3421 }
3422+=======
3423+<?php
3424+/*
3425+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3426+ * Copyright (C) 2009 Daniel Garner
3427+ *
3428+ * This file is part of Xibo.
3429+ *
3430+ * Xibo is free software: you can redistribute it and/or modify
3431+ * it under the terms of the GNU Affero General Public License as published by
3432+ * the Free Software Foundation, either version 3 of the License, or
3433+ * any later version.
3434+ *
3435+ * Xibo is distributed in the hope that it will be useful,
3436+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3437+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3438+ * GNU Affero General Public License for more details.
3439+ *
3440+ * You should have received a copy of the GNU Affero General Public License
3441+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
3442+ */
3443+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
3444+
3445+class Data
3446+{
3447+ protected $db;
3448+ private $errorNo;
3449+ private $errorMessage;
3450+
3451+ public function __construct(database $db)
3452+ {
3453+ $this->db =& $db;
3454+
3455+ $this->error = false;
3456+ $this->errorNo = 0;
3457+ $this->errorMessage = '';
3458+ }
3459+
3460+ /**
3461+ * Gets the error state
3462+ * @return
3463+ */
3464+ public function IsError()
3465+ {
3466+ return $this->error;
3467+ }
3468+
3469+ /**
3470+ * Gets the Error Number
3471+ * @return
3472+ */
3473+ public function GetErrorNumber()
3474+ {
3475+ return $this->errorNo;
3476+ }
3477+
3478+ /**
3479+ * Gets the Error Message
3480+ * @return
3481+ */
3482+ public function GetErrorMessage()
3483+ {
3484+ return $this->errorMessage;
3485+ }
3486+
3487+ /**
3488+ * Sets the Error for this Data object
3489+ * @return
3490+ * @param $errNo Object
3491+ * @param $errMessage Object
3492+ */
3493+ protected function SetError($errNo, $errMessage)
3494+ {
3495+ $this->error = true;
3496+ $this->errorNo = $errNo;
3497+ $this->errorMessage = $errMessage;
3498+
3499+ return;
3500+ }
3501+}
3502+>>>>>>> MERGE-SOURCE
3503 ?>
3504\ No newline at end of file
3505
3506=== added file 'server/lib/data/resolution.data.class.php'
3507--- server/lib/data/resolution.data.class.php 1970-01-01 00:00:00 +0000
3508+++ server/lib/data/resolution.data.class.php 2010-02-02 19:49:10 +0000
3509@@ -0,0 +1,99 @@
3510+<?php
3511+/*
3512+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3513+ * Copyright (C) 2009 Daniel Garner
3514+ *
3515+ * This file is part of Xibo.
3516+ *
3517+ * Xibo is free software: you can redistribute it and/or modify
3518+ * it under the terms of the GNU Affero General Public License as published by
3519+ * the Free Software Foundation, either version 3 of the License, or
3520+ * any later version.
3521+ *
3522+ * Xibo is distributed in the hope that it will be useful,
3523+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3524+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3525+ * GNU Affero General Public License for more details.
3526+ *
3527+ * You should have received a copy of the GNU Affero General Public License
3528+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
3529+ */
3530+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
3531+
3532+class Resolution extends Data
3533+{
3534+ /**
3535+ * Adds a resolution
3536+ * @param <type> $resolution
3537+ * @param <type> $width
3538+ * @param <type> $height
3539+ * @return <type>
3540+ */
3541+ public function Add($resolution, $width, $height)
3542+ {
3543+ $db =& $this->db;
3544+
3545+ $SQL = "INSERT INTO resolution (resolution, width, height) VALUES ('%s', %d, %d)";
3546+ $SQL = sprintf($SQL, $db->escape_string($resolution), $width, $height);
3547+
3548+ if(!$db->query($SQL))
3549+ {
3550+ trigger_error($db->error());
3551+ $this->SetError(25000, 'Cannot add this resolution.');
3552+
3553+ return false;
3554+ }
3555+
3556+ return true;
3557+ }
3558+
3559+ /**
3560+ * Edits a resolution
3561+ * @param <type> $resolutionID
3562+ * @param <type> $resolution
3563+ * @param <type> $width
3564+ * @param <type> $height
3565+ * @return <type>
3566+ */
3567+ public function Edit($resolutionID, $resolution, $width, $height)
3568+ {
3569+ $db =& $this->db;
3570+
3571+ $SQL = "UPDATE resolution SET resolution = '%s', width = %d, height = %d WHERE resolutionID = %d ";
3572+ $SQL = sprintf($SQL, $db->escape_string($resolution), $width, $height, $resolutionID);
3573+
3574+ if(!$db->query($SQL))
3575+ {
3576+ trigger_error($db->error());
3577+ $this->SetError(25000, 'Cannot edit this resolution.');
3578+
3579+ return false;
3580+ }
3581+
3582+ return true;
3583+ }
3584+
3585+ /**
3586+ * Deletes a Resolution
3587+ * @param <type> $resolutionID
3588+ * @return <type>
3589+ */
3590+ public function Delete($resolutionID)
3591+ {
3592+ $db =& $this->db;
3593+
3594+ $SQL = "DELETE FROM resolution WHERE resolutionID = %d";
3595+ $SQL = sprintf($SQL, $resolutionID);
3596+
3597+ if(!$db->query($SQL))
3598+ {
3599+ trigger_error($db->error());
3600+ $this->SetError(25000, 'Cannot delete this resolution.');
3601+
3602+ return false;
3603+ }
3604+
3605+ return true;
3606+ }
3607+}
3608+?>
3609\ No newline at end of file
3610
3611=== modified file 'server/lib/data/setting.data.class.php'
3612--- server/lib/data/setting.data.class.php 2009-12-31 11:38:50 +0000
3613+++ server/lib/data/setting.data.class.php 2010-02-02 19:49:10 +0000
3614@@ -1,3 +1,4 @@
3615+<<<<<<< TREE
3616 <?php
3617 /*
3618 * Xibo - Digitial Signage - http://www.xibo.org.uk
3619@@ -39,4 +40,47 @@
3620 return true;
3621 }
3622 }
3623+=======
3624+<?php
3625+/*
3626+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3627+ * Copyright (C) 2009 Daniel Garner
3628+ *
3629+ * This file is part of Xibo.
3630+ *
3631+ * Xibo is free software: you can redistribute it and/or modify
3632+ * it under the terms of the GNU Affero General Public License as published by
3633+ * the Free Software Foundation, either version 3 of the License, or
3634+ * any later version.
3635+ *
3636+ * Xibo is distributed in the hope that it will be useful,
3637+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3638+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3639+ * GNU Affero General Public License for more details.
3640+ *
3641+ * You should have received a copy of the GNU Affero General Public License
3642+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
3643+ */
3644+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
3645+
3646+class Setting extends Data
3647+{
3648+ public function Edit($setting, $value)
3649+ {
3650+ $db =& $this->db;
3651+
3652+ $SQL = sprintf("UPDATE setting SET value = '%s' WHERE setting = '%s' ", $db->escape_string($value), $db->escape_string($setting));
3653+
3654+ if(!$db->query($SQL))
3655+ {
3656+ trigger_error($db->error());
3657+ $this->SetError(25000, 'Update of settings failed');
3658+
3659+ return false;
3660+ }
3661+
3662+ return true;
3663+ }
3664+}
3665+>>>>>>> MERGE-SOURCE
3666 ?>
3667\ No newline at end of file
3668
3669=== modified file 'server/lib/include.php'
3670--- server/lib/include.php 2009-12-31 11:38:50 +0000
3671+++ server/lib/include.php 2010-02-02 19:49:10 +0000
3672@@ -1,3 +1,4 @@
3673+<<<<<<< TREE
3674 <?php
3675 /*
3676 * Xibo - Digitial Signage - http://www.xibo.org.uk
3677@@ -133,4 +134,129 @@
3678 $pageManager->Render();
3679
3680 die();
3681+=======
3682+<?php
3683+/*
3684+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3685+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
3686+ *
3687+ * This file is part of Xibo.
3688+ *
3689+ * Xibo is free software: you can redistribute it and/or modify
3690+ * it under the terms of the GNU Affero General Public License as published by
3691+ * the Free Software Foundation, either version 3 of the License, or
3692+ * any later version.
3693+ *
3694+ * Xibo is distributed in the hope that it will be useful,
3695+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
3696+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3697+ * GNU Affero General Public License for more details.
3698+ *
3699+ * You should have received a copy of the GNU Affero General Public License
3700+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
3701+ */
3702+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
3703+
3704+// No errors reported until we read the settings from the DB
3705+error_reporting(0);
3706+ini_set('display_errors', 0);
3707+ini_set('gd.jpeg_ignore_warning', 1);
3708+
3709+// Required Library Files
3710+require_once("lib/app/debug.class.php");
3711+require_once("lib/app/kit.class.php");
3712+require_once("lib/app/pagemanager.class.php");
3713+require_once("lib/app/menumanager.class.php");
3714+require_once("lib/app/modulemanager.class.php");
3715+require_once("lib/app/formmanager.class.php");
3716+require_once("lib/app/helpmanager.class.php");
3717+require_once("lib/app/responsemanager.class.php");
3718+require_once("lib/app/app_functions.php");
3719+require_once("lib/modules/module.interface.php");
3720+require_once("lib/modules/module.class.php");
3721+require_once("lib/data/data.class.php");
3722+require_once("lib/app/session.class.php");
3723+
3724+// Required Config Files
3725+require_once("config/config.class.php");
3726+require_once("config/db_config.php");
3727+
3728+// Sort out Magic Quotes
3729+if (get_magic_quotes_gpc())
3730+{
3731+ function stripslashes_deep($value)
3732+ {
3733+ $value = is_array($value) ?
3734+ array_map('stripslashes_deep', $value) :
3735+ stripslashes($value);
3736+
3737+ return $value;
3738+ }
3739+
3740+ $_POST = array_map('stripslashes_deep', $_POST);
3741+ $_GET = array_map('stripslashes_deep', $_GET);
3742+ $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
3743+ $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
3744+}
3745+
3746+/*
3747+ * Before we do anything else, lets check to see if we have a settings.php file
3748+ * Without that file we can deduce that
3749+ * a) This is a first time install
3750+ * b) This is a corrupt or failed install
3751+ */
3752+if (!file_exists("settings.php"))
3753+{
3754+ Kit::Redirect("install.php");
3755+ die();
3756+}
3757+
3758+if (file_exists("upgrade.php"))
3759+{
3760+ Kit::Redirect("upgrade.php");
3761+ die();
3762+}
3763+
3764+// parse and init the settings.php
3765+Config::Load();
3766+
3767+// create a database class instance
3768+$db = new database();
3769+
3770+if (!$db->connect_db($dbhost, $dbuser, $dbpass)) trigger_error($db->error(), E_USER_WARNING);
3771+if (!$db->select_db($dbname)) trigger_error($db->error(), E_USER_WARNING);
3772+
3773+date_default_timezone_set(Config::GetSetting($db, "defaultTimezone"));
3774+
3775+// Error Handling (our error handler requires a DB connection
3776+set_error_handler(array(new Debug(), "ErrorHandler"));
3777+
3778+// Define the VERSION
3779+Config::Version($db);
3780+
3781+// What is the production mode of the server?
3782+if(Config::GetSetting($db, "SERVER_MODE")=="Test") ini_set('display_errors', 1);
3783+
3784+// Debugging?
3785+if(Config::GetSetting($db, "debug")=="On") error_reporting(E_ALL);
3786+
3787+// Create login control system
3788+require_once('modules/' . Config::GetSetting($db, "userModule"));
3789+
3790+$user = new User($db);
3791+$session = new Session($db);
3792+
3793+// Page variable set? Otherwise default to index
3794+$page = Kit::GetParam('p', _REQUEST, _WORD, 'index');
3795+
3796+// Assign the page name to the session
3797+$session->set_page(session_id(), $page);
3798+
3799+// Create Page
3800+$pageManager = new PageManager($db, $user, $page);
3801+$pageManager->Authenticate();
3802+$pageManager->Render();
3803+
3804+die();
3805+>>>>>>> MERGE-SOURCE
3806 ?>
3807\ No newline at end of file
3808
3809=== modified file 'server/lib/js/core.js'
3810--- server/lib/js/core.js 2009-10-28 20:03:37 +0000
3811+++ server/lib/js/core.js 2010-02-02 19:49:10 +0000
3812@@ -21,14 +21,34 @@
3813 $(document).ready(function(){
3814
3815 // Setup the dialogs
3816+<<<<<<< TREE
3817 $('#system_message').dialog({
3818 title: "Application Message",
3819 width: "320",
3820 height: "120",
3821 draggable: false,
3822 resizable: false,
3823+=======
3824+ $('#div_dialog').dialog({
3825+ title: "Xibo",
3826+ width: "500px",
3827+ height: "240px",
3828+ draggable: true,
3829+ resizable: false,
3830+ bgiframe: true,
3831+ autoOpen: false
3832+ }).parent().parent().css("z-index", "300");
3833+
3834+ $('#system_message').dialog({
3835+ title: "Application Message",
3836+ width: "320px",
3837+ height: "120px",
3838+ draggable: false,
3839+ resizable: false,
3840+>>>>>>> MERGE-SOURCE
3841 bgiframe: true,
3842 autoOpen: false,
3843+<<<<<<< TREE
3844 modal: true,
3845 buttons: {
3846 Ok: function() {
3847@@ -43,6 +63,26 @@
3848 $(this).fadeOut("slow");
3849 });
3850
3851+=======
3852+ modal: true
3853+ }).parent().parent().css("z-index", "300");
3854+
3855+ $('#system_working').dialog({
3856+ title: "Progress...",
3857+ width: "240px",
3858+ height: "90px",
3859+ draggable: false,
3860+ resizable: false,
3861+ bgiframe: true,
3862+ autoOpen: false
3863+ }).ajaxStart(function(){
3864+ $(this).dialog("open");
3865+ }).ajaxComplete(function(){
3866+ $(this).dialog("close");
3867+ }).parent().parent().css("z-index", "300");
3868+
3869+
3870+>>>>>>> MERGE-SOURCE
3871 XiboInitialise();
3872 });
3873
3874@@ -227,6 +267,7 @@
3875 $('#div_dialog').html("");
3876
3877 // Call with AJAX
3878+<<<<<<< TREE
3879 $.ajax({
3880 type: "get",
3881 url: formUrl + "&ajax=true",
3882@@ -238,7 +279,20 @@
3883 if (response.success) {
3884
3885 // Set the dialog HTML to be the response HTML
3886+=======
3887+ $.ajax({
3888+ type: "get",
3889+ url: formUrl + "&ajax=true",
3890+ cache: false,
3891+ dataType: "json",
3892+ success: function(response){
3893+
3894+ // Was the Call successful
3895+ if (response.success) {
3896+ // Set the dialog HTML to be the response HTML
3897+>>>>>>> MERGE-SOURCE
3898 $('#div_dialog').html(response.html);
3899+<<<<<<< TREE
3900
3901 var dialogTitle = "Xibo";
3902 var dialogWidth = "500";
3903@@ -285,7 +339,24 @@
3904 buttons: buttons
3905 });
3906
3907+=======
3908+
3909+ // Is there a title for the dialog?
3910+ if (response.dialogTitle != undefined && response.dialogTitle != "") {
3911+ // Set the dialog title
3912+ $('#div_dialog').parent().children().each(function(){
3913+ $(".ui-dialog-title", this).html(response.dialogTitle);
3914+ });
3915+ }
3916+
3917+ // Do we need to alter the dialog size?
3918+ if (response.dialogSize) {
3919+ $('#div_dialog').parent().parent().width(response.dialogWidth).height(response.dialogHeight);
3920+ }
3921+
3922+>>>>>>> MERGE-SOURCE
3923 // Do we have to call any functions due to this success?
3924+<<<<<<< TREE
3925 if (response.callBack != "" && response.callBack != undefined) {
3926 eval(response.callBack)(name);
3927 }
3928@@ -339,6 +410,21 @@
3929
3930 // Was the Call successful
3931 if (!response.success) {
3932+=======
3933+ if (response.callBack != "" && response.callBack != undefined) {
3934+ eval(response.callBack)(name);
3935+ }
3936+
3937+ $('#div_dialog').dialog("open");
3938+
3939+ // Focus in the first form element
3940+ $('input[@type=text]', '#div_dialog').eq(0).focus();
3941+
3942+ // Call Xibo Init for this form
3943+ XiboInitialise("#div_dialog");
3944+ }
3945+ else {
3946+>>>>>>> MERGE-SOURCE
3947 // Login Form needed?
3948 if (response.login) {
3949 $('#div_dialog').dialog('destroy');
3950@@ -346,6 +432,7 @@
3951 LoginBox(response.message);
3952 return false;
3953 }
3954+<<<<<<< TREE
3955
3956 if (response.clockUpdate) {
3957 XiboClockUpdate(response.html);
3958@@ -354,6 +441,21 @@
3959
3960 return false;
3961 }
3962+=======
3963+ else {
3964+ // Just an error we dont know about
3965+ if (response.message == undefined) {
3966+ SystemMessage(response);
3967+ }
3968+ else {
3969+ SystemMessage(response.message);
3970+ }
3971+ }
3972+ }
3973+
3974+ return false;
3975+ }
3976+>>>>>>> MERGE-SOURCE
3977 });
3978
3979 // Dont then submit the link/button
3980
3981=== modified file 'server/lib/js/display.js'
3982--- server/lib/js/display.js 2009-12-31 11:38:50 +0000
3983+++ server/lib/js/display.js 2010-02-02 19:49:10 +0000
3984@@ -1,3 +1,4 @@
3985+<<<<<<< TREE
3986 /**
3987 * Xibo - Digitial Signage - http://www.xibo.org.uk
3988 * Copyright (C) 2006,2007,2008 Daniel Garner
3989@@ -42,4 +43,24 @@
3990 });
3991
3992 return;
3993-}
3994\ No newline at end of file
3995+}=======
3996+/*
3997+ * Xibo - Digitial Signage - http://www.xibo.org.uk
3998+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
3999+ *
4000+ * This file is part of Xibo.
4001+ *
4002+ * Xibo is free software: you can redistribute it and/or modify
4003+ * it under the terms of the GNU Affero General Public License as published by
4004+ * the Free Software Foundation, either version 3 of the License, or
4005+ * any later version.
4006+ *
4007+ * Xibo is distributed in the hope that it will be useful,
4008+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4009+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4010+ * GNU Affero General Public License for more details.
4011+ *
4012+ * You should have received a copy of the GNU Affero General Public License
4013+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
4014+ */
4015+>>>>>>> MERGE-SOURCE
4016
4017=== modified file 'server/lib/js/layout.js'
4018--- server/lib/js/layout.js 2009-12-31 11:38:50 +0000
4019+++ server/lib/js/layout.js 2010-02-02 19:49:10 +0000
4020@@ -1,3 +1,4 @@
4021+<<<<<<< TREE
4022 /*
4023 * Xibo - Digitial Signage - http://www.xibo.org.uk
4024 * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
4025@@ -316,4 +317,361 @@
4026 return false;
4027 }
4028 });
4029+=======
4030+/*
4031+ * Xibo - Digitial Signage - http://www.xibo.org.uk
4032+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
4033+ *
4034+ * This file is part of Xibo.
4035+ *
4036+ * Xibo is free software: you can redistribute it and/or modify
4037+ * it under the terms of the GNU Affero General Public License as published by
4038+ * the Free Software Foundation, either version 3 of the License, or
4039+ * any later version.
4040+ *
4041+ * Xibo is distributed in the hope that it will be useful,
4042+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4043+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4044+ * GNU Affero General Public License for more details.
4045+ *
4046+ * You should have received a copy of the GNU Affero General Public License
4047+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
4048+ */
4049+
4050+var region_options_callback = function(outputDiv)
4051+{
4052+ //Get all the tooltip_hidden
4053+ $(".tooltip_hidden").parent().hover(function() {
4054+ var html = $(".tooltip_hidden",this).html();
4055+ var left = this.offsetLeft - this.offsetParent.scrollLeft;;
4056+
4057+ //Change the hidden div's content
4058+ $('#tooltip_hover') .html(html)
4059+ .css("left",left)
4060+ .show();
4061+ }, function() {
4062+ $('#tooltip_hover').hide();
4063+ });
4064+
4065+ // Make the elements draggable
4066+ $(".timebar_ctl").draggable({
4067+ containment: document.getElementById("timeline_ctl")
4068+ });
4069+
4070+ $(".mediabreak").droppable({
4071+ accept: ".timebar_ctl",
4072+ tolerance: "pointer",
4073+ drop: function(ev, ui) {
4074+ orderRegion(ui.draggable, this);
4075+ }
4076+ });
4077+
4078+ // Refresh the preview
4079+ var preview = Preview.instances[$('#timeline_ctl').attr('regionid')];
4080+ preview.SetSequence(preview.seq);
4081+}
4082+
4083+var background_button_callback = function()
4084+{
4085+ //Want to attach an onchange event to the drop down for the bg-image
4086+ var id = $('#bg_image').val();
4087+
4088+ $('#bg_image_image').attr("src", "index.php?p=module&q=GetImage&id=" + id + "&width=80&height=80&dynamic");
4089+}
4090+
4091+var text_callback = function()
4092+{
4093+ //Create the FCK editor
4094+ var oFCKeditor = new FCKeditor( 'ta_text' ) ;
4095+ oFCKeditor.BasePath = "3rdparty/fckeditor/" ;
4096+ oFCKeditor.ReplaceTextarea();
4097+
4098+ var regionid = $("#iRegionId").val();
4099+ var width = $("#region_"+regionid).width();
4100+ var height = $("#region_"+regionid).height();
4101+
4102+ //Min width
4103+ if (width < 800) width = 800;
4104+ height = height + 75 //the width of the toolbar
4105+
4106+ $('#ta_text___Frame').attr("width",width+"px");
4107+ $('#ta_text___Frame').attr("height",height+"px");
4108+
4109+ width = width + 50;
4110+ height = height + 220;
4111+
4112+ $('#div_dialog').parent().parent().width(width).height(height);
4113+
4114+ return false; //prevent submit
4115+}
4116+
4117+$(document).ready(function() {
4118+
4119+ var container = document.getElementById('layout');
4120+
4121+ $('.region').draggable({containment:container, stop:function(e, ui){
4122+ //Called when draggable is finished
4123+ submitBackground(this);
4124+ }, drag: updateRegionInfo }).resizable({containment:container, minWidth:25, minHeight:25, stop:function(e, ui){
4125+ //Called when resizable is finished
4126+ submitBackground(this);
4127+ }, resize: updateRegionInfo }
4128+ ).contextMenu('regionMenu', {
4129+ bindings: {
4130+ 'btnTimeline': function(t) {
4131+ XiboFormRender($(t).attr("href"));
4132+ },
4133+ 'options' : function(region) {
4134+ var width = $(region).css("width");
4135+ var height = $(region).css("height");
4136+ var top = $(region).css("top");
4137+ var left = $(region).css("left");
4138+ var regionid = $(region).attr("regionid");
4139+ var layoutid = $(region).attr("layoutid");
4140+
4141+ var layout = $('#layout');
4142+
4143+ XiboFormRender("index.php?p=layout&q=ManualRegionPositionForm&layoutid="+layoutid+"&regionid="+regionid+"&top="+top+"&left="+left+"&width="+width+"&height="+height+"&layoutWidth="+layout.width()+"&layoutHeight="+layout.height());
4144+ },
4145+ 'deleteRegion': function(t) {
4146+ deleteRegion(t);
4147+ },
4148+ 'setAsHomepage': function(t) {
4149+ var layoutid = $(t).attr("layoutid");
4150+ var regionid = $(t).attr("regionid");
4151+
4152+ XiboFormRender("index.php?p=user&q=SetUserHomepageForm&layoutid="+layoutid+"&regionid="+regionid);
4153+ }
4154+ }
4155+ });
4156+
4157+ $('#layout').contextMenu('layoutMenu', {
4158+ bindings: {
4159+ 'addRegion': function(t){
4160+ addRegion(t);
4161+ },
4162+ 'editBackground': function(t) {
4163+ XiboFormRender($('#background_button').attr("href"));
4164+ },
4165+ 'layoutProperties': function(t) {
4166+ XiboFormRender($('#edit_button').attr("href"));
4167+ },
4168+ 'templateSave': function(t) {
4169+ var layoutid = $(t).attr("layoutid");
4170+
4171+ XiboFormRender("index.php?p=template&q=TemplateForm&layoutid="+layoutid);
4172+ }
4173+ }
4174+ });
4175+
4176+
4177+ // Preview
4178+ $('.region').each(function(){
4179+ new Preview(this);
4180+ });
4181+
4182+ // Aspect ration option
4183+ $('#lockAspectRatio').change(function(){
4184+ var opt = $('#lockAspectRatio').val();
4185+
4186+ if (opt == "on") {
4187+ alert("on");
4188+ $('.region').resizable('option', 'aspectRatio', true);
4189+ }
4190+ else {
4191+ $('.region').resizable('option', 'aspectRatio', false);
4192+ }
4193+
4194+ });
4195+});
4196+
4197+/*
4198+ * Updates the Region Info
4199+ */
4200+function updateRegionInfo(e, ui) {
4201+ var pos = $(this).position();
4202+ $('.regionInfo', this).html($(this).width() + " x " + $(this).height() + " (" + pos.left + "," + pos.top + ")");
4203+}
4204+
4205+/**
4206+ * Adds a region to the specified layout
4207+ * @param {Object} layout
4208+ */
4209+function addRegion(layout)
4210+{
4211+ var layoutid = $(layout).attr("layoutid");
4212+
4213+ $.ajax({type:"post", url:"index.php?p=layout&q=AddRegion&layoutid="+layoutid+"&ajax=true", cache:false, dataType:"json",success: XiboSubmitResponse});
4214+}
4215+
4216+/**
4217+ * Submits the background changes from draggable / resizable
4218+ * @param {Object} region
4219+ */
4220+function submitBackground(region)
4221+{
4222+ var width = $(region).css("width");
4223+ var height = $(region).css("height");
4224+ var top = $(region).css("top");
4225+ var left = $(region).css("left");
4226+ var regionid = $(region).attr("regionid");
4227+ var layoutid = $(region).attr("layoutid");
4228+
4229+ var preview = Preview.instances[regionid];
4230+ preview.SetSequence(preview.seq);
4231+
4232+ $.ajax({type:"post", url:"index.php?p=layout&q=RegionChange&layoutid="+layoutid+"&ajax=true", cache:false, dataType:"json",
4233+ data:{"width":width,"height":height,"top":top,"left":left,"regionid":regionid},success: XiboSubmitResponse});
4234+}
4235+
4236+/**
4237+ * Deletes a region
4238+ */
4239+function deleteRegion(region) {
4240+ var regionid = $(region).attr("regionid");
4241+ var layoutid = $(region).attr("layoutid");
4242+
4243+ XiboFormRender("index.php?p=layout&q=DeleteRegionForm&layoutid="+layoutid+"&regionid="+regionid);
4244+}
4245+
4246+/**
4247+ * Reorders the Region specified by the timebar and its position
4248+ * @param {Object} timeBar
4249+ * @param {Object} mediaBreak
4250+ */
4251+function orderRegion(timeBar, mediaBreak) {
4252+ var timeLine = $(timeBar).parent().parent();
4253+
4254+ var layoutid = timeLine.attr("layoutid");
4255+ var regionid = timeLine.attr("regionid");
4256+ var mediaid = $(timeBar).attr("mediaid");
4257+ var lkid = $(timeBar).attr("lkid");
4258+ var sequence = $(mediaBreak).attr("breakid");
4259+
4260+ $.ajax({type:"post", url:"index.php?p=layout&q=RegionOrder&layoutid="+layoutid+"&callingpage=layout&ajax=true", cache:false, dataType:"json",
4261+ data:{"mediaid":mediaid,"lkid":lkid,"sequence":sequence,"regionid":regionid},success: XiboSubmitResponse});
4262+}
4263+
4264+/**
4265+ * Handles the tRegionOptions trigger
4266+ */
4267+function tRegionOptions() {
4268+ var regionid = gup("regionid");
4269+ var layoutid = gup("layoutid");
4270+
4271+ XiboFormRender('index.php?p=layout&layoutid='+layoutid+'&regionid='+regionid+'&q=RegionOptions');
4272+}
4273+
4274+function manualPositionCallback() {
4275+ $('#btnFullScreen').click(function(){
4276+ $('#width', '.XiboForm').val($('#layoutWidth').val());
4277+ $('#height', '.XiboForm').val($('#layoutHeight').val());
4278+ $('#top', '.XiboForm').val('0');
4279+ $('#left', '.XiboForm').val('0');
4280+ })
4281+}
4282+
4283+
4284+function Preview(regionElement)
4285+{
4286+ // Load the preview - sequence 1
4287+ this.seq = 1;
4288+ this.layoutid = $(regionElement).attr("layoutid");
4289+ this.regionid = $(regionElement).attr("regionid");
4290+ this.regionElement = regionElement;
4291+ this.width = $(regionElement).width();
4292+ this.height = $(regionElement).height();
4293+
4294+ var regionHeight = $(regionElement).height();
4295+ var arrowsTop = regionHeight / 2 - 28;
4296+ var regionid = this.regionid;
4297+
4298+ this.previewElement = $('.preview',regionElement);
4299+ this.previewContent = $('.previewContent', this.previewElement);
4300+
4301+ // Setup global control tracking
4302+ Preview.instances[this.regionid] = this;
4303+
4304+ // Create the Nav Buttons
4305+ $('.previewNav',this.previewElement)
4306+ .append("<div class='prevSeq' style='position:absolute; left:1px; top:"+ arrowsTop +"px'><img src='img/arrow_left.gif' /></div>")
4307+ .append("<div class='nextSeq' style='position:absolute; right:1px; top:"+ arrowsTop +"px'><img src='img/arrow_right.gif' /></div>");
4308+
4309+ $('.prevSeq', $(this.previewElement)).click(function() {
4310+ var preview = Preview.instances[regionid];
4311+ var maxSeq = $('#maxSeq', preview.previewContent[0]).val();
4312+
4313+ var currentSeq = preview.seq;
4314+ currentSeq--;
4315+
4316+ if (currentSeq <= 0)
4317+ {
4318+ currentSeq = maxSeq;
4319+ }
4320+
4321+ preview.SetSequence(currentSeq);
4322+ });
4323+
4324+ $('.nextSeq', $(this.previewElement)).click(function() {
4325+ var preview = Preview.instances[regionid];
4326+ var maxSeq = $('#maxSeq', preview.previewContent[0]).val();
4327+
4328+ var currentSeq = preview.seq;
4329+ currentSeq++;
4330+
4331+ if (currentSeq > maxSeq)
4332+ {
4333+ currentSeq = 1;
4334+ }
4335+
4336+ preview.SetSequence(currentSeq);
4337+ });
4338+
4339+ this.SetSequence(1);
4340+}
4341+
4342+Preview.instances = {};
4343+
4344+Preview.prototype.SetSequence = function(seq)
4345+{
4346+ this.seq = seq;
4347+
4348+ //console.log('Setting sequence to: ' + seq);
4349+
4350+ var layoutid = this.layoutid;
4351+ var regionid = this.regionid;
4352+ var previewContent = this.previewContent;
4353+
4354+
4355+ this.width = $(this.regionElement).width();
4356+ this.height = $(this.regionElement).height();
4357+
4358+ //Get the sequence via AJAX
4359+ $.ajax({type:"post",
4360+ url:"index.php?p=layout&q=RegionPreview&ajax=true",
4361+ cache:false,
4362+ dataType:"json",
4363+ data:{"layoutid":layoutid,"seq":seq,"regionid":regionid,"width":this.width, "height":this.height},
4364+ success:function(response) {
4365+
4366+ if (response.success) {
4367+ // Success - what do we do now?
4368+ $(previewContent).html(response.html);
4369+ }
4370+ else {
4371+ // Why did we fail?
4372+ if (response.login) {
4373+ // We were logged out
4374+ LoginBox(response.message);
4375+ return false;
4376+ }
4377+ else {
4378+ // Likely just an error that we want to report on
4379+ $(previewContent).html(response.html);
4380+ }
4381+ }
4382+ return false;
4383+ }
4384+ });
4385+>>>>>>> MERGE-SOURCE
4386 }
4387\ No newline at end of file
4388
4389=== added file 'server/lib/js/resolution.js'
4390--- server/lib/js/resolution.js 1970-01-01 00:00:00 +0000
4391+++ server/lib/js/resolution.js 2010-02-02 19:49:10 +0000
4392@@ -0,0 +1,19 @@
4393+/*
4394+ * Xibo - Digitial Signage - http://www.xibo.org.uk
4395+ * Copyright (C) 2009 Daniel Garner
4396+ *
4397+ * This file is part of Xibo.
4398+ *
4399+ * Xibo is free software: you can redistribute it and/or modify
4400+ * it under the terms of the GNU Affero General Public License as published by
4401+ * the Free Software Foundation, either version 3 of the License, or
4402+ * any later version.
4403+ *
4404+ * Xibo is distributed in the hope that it will be useful,
4405+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4406+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4407+ * GNU Affero General Public License for more details.
4408+ *
4409+ * You should have received a copy of the GNU Affero General Public License
4410+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
4411+ */
4412\ No newline at end of file
4413
4414=== modified file 'server/lib/js/schedule.js'
4415--- server/lib/js/schedule.js 2009-12-31 11:38:50 +0000
4416+++ server/lib/js/schedule.js 2010-02-02 19:49:10 +0000
4417@@ -1,3 +1,4 @@
4418+<<<<<<< TREE
4419 /*
4420 * Xibo - Digitial Signage - http://www.xibo.org.uk
4421 * Copyright (C) 2009 Daniel Garner
4422@@ -158,4 +159,148 @@
4423 rec_detail.parent().parent().show();
4424 rec_range.parent().parent().show();
4425 }
4426+=======
4427+/*
4428+ * Xibo - Digitial Signage - http://www.xibo.org.uk
4429+ * Copyright (C) 2006,2007,2008 Daniel Garner and James Packer
4430+ *
4431+ * This file is part of Xibo.
4432+ *
4433+ * Xibo is free software: you can redistribute it and/or modify
4434+ * it under the terms of the GNU Affero General Public License as published by
4435+ * the Free Software Foundation, either version 3 of the License, or
4436+ * any later version.
4437+ *
4438+ * Xibo is distributed in the hope that it will be useful,
4439+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4440+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4441+ * GNU Affero General Public License for more details.
4442+ *
4443+ * You should have received a copy of the GNU Affero General Public License
4444+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
4445+ */
4446+function set_time(hour_period) {
4447+ /* The form fields */
4448+ var form_start = document.getElementById("form_starttime");
4449+ var form_end = document.getElementById("form_endtime");
4450+
4451+ /* The radio buttons */
4452+ var set_start_time = document.getElementById("heading_select_start");
4453+ var set_end_time = document.getElementById("heading_select_end");
4454+
4455+ /* The start/end tds */
4456+ var time_for_start = document.getElementById("time_for_start");
4457+ var time_for_end = document.getElementById("time_for_end");
4458+
4459+
4460+ if (set_start_time.checked) {
4461+ form_start.value = hour_period;
4462+ set_end_time.checked = true;
4463+ }
4464+ else {
4465+ form_end.value = hour_period;
4466+ set_start_time.checked = true;
4467+ }
4468+
4469+
4470+ form_start = document.getElementById("form_starttime");
4471+ form_end = document.getElementById("form_endtime");
4472+
4473+ time_for_start.innerHTML = format_date(form_start.value);
4474+ time_for_end.innerHTML = format_date(form_end.value)
4475+
4476+ eval_add_cells(get_hours(form_start.value),get_hours(form_end.value));
4477+
4478+ return;
4479+}
4480+
4481+function format_date(date) {
4482+
4483+ var d = new Date(date*1000);
4484+
4485+ var hours = d.getHours();
4486+ var minutes = d.getMinutes();
4487+
4488+ if (hours < 10) hours = "0"+hours;
4489+ if (minutes < 10) minutes = "0"+minutes;
4490+
4491+
4492+ return hours + ":" + minutes;
4493+
4494+}
4495+
4496+function get_hours(date) {
4497+ var d = new Date(date*1000);
4498+
4499+ var hours = d.getHours();
4500+
4501+ return hours;
4502+}
4503+
4504+function eval_add_cells(start, end) {
4505+ /* Set them all to no color */
4506+ for (var i=0; i<=23; i++) {
4507+ var cell = document.getElementById("add_cell_"+i);
4508+
4509+ if (i >= start && i <= end) {
4510+ /* Want to set the color of the hour cells based on start and end time */
4511+ //cell.style.backgroundColor = "red;";
4512+ cell.className = "add";
4513+ }
4514+ else {
4515+ /* set to no color */
4516+ //cell.style.backgroundColor = "#f5f5f5";
4517+ cell.className = "";
4518+ }
4519+ }
4520+ return true;
4521+}
4522+
4523+function setupScheduleForm() {
4524+ //set up any date fields we have with the date picker
4525+ $('.date-pick').datepicker({
4526+ dateFormat: "dd/mm/yy",
4527+ showOn: "button",
4528+ buttonImage: "img/calendar.png",
4529+ buttonImageOnly: true,
4530+ beforeShow: customRange
4531+ });
4532+
4533+ bindRecurrenceCtl();
4534+
4535+ $('#rec_type').change(function() {
4536+ bindRecurrenceCtl();
4537+ });
4538+}
4539+
4540+function customRange(input) {
4541+ return {minDate: (input.id == "endtime" ? $("#starttime").datepicker("getDate") : null),
4542+ maxDate: (input.id == "starttime" ? $("#endtime").datepicker("getDate") : null)};
4543+}
4544+
4545+function bindRecurrenceCtl()
4546+{
4547+ /*
4548+ * Recurrence
4549+ * If the recurrence type value is NULL then hide the rec_detail and rec_range fields
4550+ */
4551+ var rec_type = $('#rec_type');
4552+ var rec_detail = $('#rec_detail');
4553+ var rec_range = $('#rec_range');
4554+
4555+ if (rec_type.val()=="null") {
4556+ rec_detail.parent().parent().hide();
4557+ rec_range.parent().parent().hide();
4558+ }
4559+ else {
4560+ rec_detail.parent().parent().show();
4561+ rec_range.parent().parent().show();
4562+ }
4563+}
4564+
4565+function edit_event_callback() {
4566+ init_callback();
4567+
4568+ set_form_size('900','600');
4569+>>>>>>> MERGE-SOURCE
4570 }
4571\ No newline at end of file
4572
4573=== modified file 'server/lib/modules/module.class.php'
4574--- server/lib/modules/module.class.php 2009-12-31 11:38:50 +0000
4575+++ server/lib/modules/module.class.php 2010-02-02 19:49:10 +0000
4576@@ -1,3 +1,4 @@
4577+<<<<<<< TREE
4578 <?php
4579 /*
4580 * Xibo - Digitial Signage - http://www.xibo.org.uk
4581@@ -564,4 +565,580 @@
4582 return $this->name;
4583 }
4584 }
4585+=======
4586+<?php
4587+/*
4588+ * Xibo - Digitial Signage - http://www.xibo.org.uk
4589+ * Copyright (C) 2006,2007,2008 Daniel Garner
4590+ *
4591+ * This file is part of Xibo.
4592+ *
4593+ * Xibo is free software: you can redistribute it and/or modify
4594+ * it under the terms of the GNU Affero General Public License as published by
4595+ * the Free Software Foundation, either version 3 of the License, or
4596+ * any later version.
4597+ *
4598+ * Xibo is distributed in the hope that it will be useful,
4599+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
4600+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4601+ * GNU Affero General Public License for more details.
4602+ *
4603+ * You should have received a copy of the GNU Affero General Public License
4604+ * along with Xibo. If not, see <http://www.gnu.org/licenses/>.
4605+ */
4606+defined('XIBO') or die("Sorry, you are not allowed to directly access this page.<br /> Please press the back button in your browser.");
4607+
4608+class Module implements ModuleInterface
4609+{
4610+ //Media information
4611+ protected $db;
4612+ protected $user;
4613+ protected $region;
4614+ protected $response;
4615+
4616+ protected $layoutid;
4617+ protected $regionid;
4618+
4619+ protected $mediaid;
4620+ protected $name;
4621+ protected $type;
4622+ private $schemaVersion;
4623+ protected $regionSpecific;
4624+ protected $duration;
4625+ protected $lkid;
4626+ protected $validExtensions;
4627+ protected $validExtensionsText;
4628+
4629+ protected $xml;
4630+
4631+ protected $existingMedia;
4632+ protected $deleteFromRegion;
4633+
4634+ /**
4635+ * Constructor - sets up this media object with all the available information
4636+ * @return
4637+ * @param $db database
4638+ * @param $user user
4639+ * @param $mediaid String[optional]
4640+ * @param $layoutid String[optional]
4641+ * @param $regionid String[optional]
4642+ */
4643+ public function __construct(database $db, user $user, $mediaid = '', $layoutid = '', $regionid = '')
4644+ {
4645+ include_once("lib/pages/region.class.php");
4646+
4647+ $this->db =& $db;
4648+ $this->user =& $user;
4649+
4650+ $this->mediaid = $mediaid;
4651+ $this->name = '';
4652+ $this->layoutid = $layoutid;
4653+ $this->regionid = $regionid;
4654+
4655+ $this->region = new region($db, $user);
4656+ $this->response = new ResponseManager();
4657+
4658+ $this->existingMedia = false;
4659+ $this->deleteFromRegion = false;
4660+ $this->lkid = '';
4661+ $this->duration = '';
4662+
4663+ // Determine which type this module is
4664+ $this->SetModuleInformation();
4665+
4666+ Debug::LogEntry($db, 'audit', 'New module created with MediaID: ' . $mediaid . ' LayoutID: ' . $layoutid . ' and RegionID: ' . $regionid);
4667+
4668+ // Either the information from the region - or some blanks
4669+ $this->SetMediaInformation($this->layoutid, $this->regionid, $mediaid);
4670+
4671+ return true;
4672+ }
4673+
4674+ /**
4675+ * Sets the module information
4676+ * @return
4677+ */
4678+ final private function SetModuleInformation()
4679+ {
4680+ $db =& $this->db;
4681+ $type = $this->type;
4682+
4683+ if ($type == '')
4684+ {
4685+ $this->response->SetError('Unable to create Module [No type given] - please refer to the Module Documentation.');
4686+ $this->response->Respond();
4687+ }
4688+
4689+ $SQL = sprintf("SELECT * FROM module WHERE Module = '%s'", $db->escape_string($type));
4690+
4691+ if (!$result = $db->query($SQL))
4692+ {
4693+ $this->response->SetError('Unable to create Module [Cannot find type in the database] - please refer to the Module Documentation.');
4694+ $this->response->Respond();
4695+ }
4696+
4697+ if ($db->num_rows($result) != 1)
4698+ {
4699+ $this->response->SetError('Unable to create Module [No registered modules of this type] - please refer to the Module Documentation.');
4700+ $this->response->Respond();
4701+ }
4702+
4703+ $row = $db->get_assoc_row($result);
4704+
4705+ $this->schemaVersion = Kit::ValidateParam($row['SchemaVersion'], _INT);
4706+ $this->regionSpecific = Kit::ValidateParam($row['RegionSpecific'], _INT);
4707+ $this->validExtensionsText = Kit::ValidateParam($row['ValidExtensions'], _STRING);
4708+ $this->validExtensions = explode(',', $this->validExtensionsText);
4709+ $this->validExtensionsText = str_replace(',', ', ', $this->validExtensionsText);
4710+
4711+ return true;
4712+ }
4713+
4714+ /**
4715+ * Gets the information about this Media on this region on this layout
4716+ * @return
4717+ * @param $layoutid Object
4718+ * @param $regionid Object
4719+ * @param $mediaid Object
4720+ */
4721+ final private function SetMediaInformation($layoutid, $regionid, $mediaid)
4722+ {
4723+ $db =& $this->db;
4724+ $region =& $this->region;
4725+ $xmlDoc = new DOMDocument();
4726+
4727+ if ($this->mediaid != '' && $this->regionid != '' && $this->layoutid != '')
4728+ {
4729+ $this->existingMedia = true;
4730+
4731+ // Set the layout Xml
4732+ $layoutXml = $region->GetLayoutXml($layoutid);
4733+
4734+ Debug::LogEntry($db, 'audit', 'Layout XML retrieved: ' . $layoutXml);
4735+
4736+ $layoutDoc = new DOMDocument();
4737+ $layoutDoc->loadXML($layoutXml);
4738+
4739+ $layoutXpath = new DOMXPath($layoutDoc);
4740+
4741+ // Get the media node and extract the info
4742+ $mediaNodeXpath = $layoutXpath->query("//region[@id='$regionid']/media[@id='$mediaid']");
4743+
4744+ if ($mediaNodeXpath->length > 0)
4745+ {
4746+ Debug::LogEntry($db, 'audit', 'Media Node Found.');
4747+
4748+ // Create a Media node in the DOMDocument for us to replace
4749+ $xmlDoc->loadXML('<root/>');
4750+ }
4751+ else
4752+ {
4753+ $this->response->SetError('Cannot find this media item. Please refresh the region options.');
4754+ $this->response->Respond();
4755+ }
4756+
4757+ $mediaNode = $mediaNodeXpath->item(0);
4758+ $mediaNode->setAttribute('schemaVersion', $this->schemaVersion);
4759+
4760+ $this->duration = $mediaNode->getAttribute('duration');
4761+ $this->lkid = $mediaNode->getAttribute('lkid');
4762+
4763+ $mediaNode = $xmlDoc->importNode($mediaNode, true);
4764+ $xmlDoc->documentElement->appendChild($mediaNode);
4765+ }
4766+ else
4767+ {
4768+ if ($this->mediaid != '' && $this->regionSpecific == 0)
4769+ {
4770+ // We do not have a region or a layout
4771+ // But this is some existing media
4772+ // Therefore make sure we get the bare minimum!
4773+ $this->existingMedia = true;
4774+
4775+ // Load what we know about this media into the object
4776+ $SQL = "SELECT duration, name FROM media WHERE mediaID = '$mediaid'";
4777+
4778+ Debug::LogEntry($db, 'audit', $SQL, 'Module', 'SetMediaInformation');
4779+
4780+ if (!$result = $db->query($SQL))
4781+ {
4782+ trigger_error($db->error()); //log the error
4783+ }
4784+
4785+ if ($db->num_rows($result) != 0)
4786+ {
4787+ $row = $db->get_row($result);
4788+ $this->duration = $row[0];
4789+ $this->name = $row[1];
4790+ }
4791+ }
4792+
4793+ $xml = <<<XML
4794+ <root>
4795+ <media id="" type="$this->type" duration="" lkid="" schemaVersion="$this->schemaVersion">
4796+ <options />
4797+ <raw />
4798+ </media>
4799+ </root>
4800+XML;
4801+ $xmlDoc->loadXML($xml);
4802+ }
4803+
4804+ $this->xml = $xmlDoc;
4805+
4806+ Debug::LogEntry($db, 'audit', 'XML is: ' . $this->xml->saveXML());
4807+
4808+ return true;
4809+ }
4810+
4811+ /**
4812+ * Sets the Layout and Region Information
4813+ * @return
4814+ * @param $layoutid Object
4815+ * @param $regionid Object
4816+ * @param $mediaid Object
4817+ */
4818+ public function SetRegionInformation($layoutid, $regionid)
4819+ {
4820+ $this->layoutid = $layoutid;
4821+ $this->regionid = $regionid;
4822+
4823+ return true;
4824+ }
4825+
4826+ /**
4827+ * This Media item represented as XML
4828+ * @return
4829+ */
4830+ final public function AsXml()
4831+ {
4832+ // Make sure the required attributes are present on the Media Node
4833+ // We can add / change:
4834+ // MediaID
4835+ // Duration
4836+ // Type
4837+ // SchemaVersion (use the type to get this from the DB)
4838+ // LkID is done by the region code (where applicable - otherwise it will be left blank)
4839+ $mediaNodes = $this->xml->getElementsByTagName('media');
4840+ $mediaNode = $mediaNodes->item(0);
4841+
4842+ $mediaNode->setAttribute('id', $this->mediaid);
4843+ $mediaNode->setAttribute('duration', $this->duration);
4844+ $mediaNode->setAttribute('type', $this->type);
4845+
4846+ return $this->xml->saveXML($mediaNode);
4847+ }
4848+
4849+ /**
4850+ * Adds the name/value element to the XML Options sequence
4851+ * @return
4852+ * @param $name String
4853+ * @param $value String
4854+ */
4855+ final protected function SetOption($name, $value)
4856+ {
4857+ $db =& $this->db;
4858+ if ($name == '') return;
4859+
4860+ Debug::LogEntry($db, 'audit', sprintf('IN with Name=%s and value=%s', $name, $value), 'module', 'Set Option');
4861+
4862+ // Get the options node from this document
4863+ $optionNodes = $this->xml->getElementsByTagName('options');
4864+ // There is only 1
4865+ $optionNode = $optionNodes->item(0);
4866+
4867+ // Create a new option node
4868+ $newNode = $this->xml->createElement($name, $value);
4869+
4870+ Debug::LogEntry($db, 'audit', sprintf('Created a new Option Node with Name=%s and value=%s', $name, $value), 'module', 'Set Option');
4871+
4872+ // Check to see if we already have this option or not
4873+ $xpath = new DOMXPath($this->xml);
4874+
4875+ // Xpath for it
4876+ $userOptions = $xpath->query('//options/' . $name);
4877+
4878+ if ($userOptions->length == 0)
4879+ {
4880+ // Append the new node to the list
4881+ $optionNode->appendChild($newNode);
4882+ }
4883+ else
4884+ {
4885+ // Replace the old node we found with XPath with the new node we just created
4886+ $optionNode->replaceChild($newNode, $userOptions->item(0));
4887+ }
4888+ }
4889+
4890+ /**
4891+ * Gets the value for the option in Parameter 1
4892+ * @return
4893+ * @param $name String The Option Name
4894+ * @param $default Object[optional] The Default Value
4895+ */
4896+ final protected function GetOption($name, $default = false)
4897+ {
4898+ $db =& $this->db;
4899+
4900+ if ($name == '') return false;
4901+
4902+ // Check to see if we already have this option or not
4903+ $xpath = new DOMXPath($this->xml);
4904+
4905+ // Xpath for it
4906+ $userOptions = $xpath->query('//options/' . $name);
4907+
4908+ if ($userOptions->length == 0)
4909+ {
4910+ // We do not have an option - return the default
4911+ Debug::LogEntry($db, 'audit', 'GetOption ' . $name . ': Not Set - returning default ' . $default);
4912+ return $default;
4913+ }
4914+ else
4915+ {
4916+ // Replace the old node we found with XPath with the new node we just created
4917+ Debug::LogEntry($db, 'audit', 'GetOption ' . $name . ': Set - returning: ' . $userOptions->item(0)->nodeValue);
4918+ return $userOptions->item(0)->nodeValue;
4919+ }
4920+ }
4921+
4922+ /**
4923+ * Sets the RAW XML string that is given as the content for Raw
4924+ * @return
4925+ * @param $xml String
4926+ * @param $replace Boolean[optional]
4927+ */
4928+ final protected function SetRaw($xml, $replace = false)
4929+ {
4930+ if ($xml == '') return;
4931+
4932+ // Load the XML we are given into its own document
4933+ $rawNode = new DOMDocument();
4934+ $rawNode->loadXML('<raw>' . $xml . '</raw>');
4935+
4936+ // Import the Raw node into this document (with all sub nodes)
4937+ $importedNode = $this->xml->importNode($rawNode->documentElement, true);
4938+
4939+ // Get the Raw Xml node from our document
4940+ $rawNodes = $this->xml->getElementsByTagName('raw');
4941+
4942+ // There is only 1
4943+ $rawNode = $rawNodes->item(0);
4944+
4945+ // Append the imported node (at the end of whats already there)
4946+ $rawNode->parentNode->replaceChild($importedNode, $rawNode);
4947+ }
4948+
4949+ /**
4950+ * Gets the XML string from RAW
4951+ * @return
4952+ */
4953+ final protected function GetRaw()
4954+ {
4955+ // Get the Raw Xml node from our document
4956+ $rawNodes = $this->xml->getElementsByTagName('raw');
4957+
4958+ // There is only 1
4959+ $rawNode = $rawNodes->item(0);
4960+
4961+ // Return it as a XML string
4962+ return $this->xml->saveXML($rawNode);
4963+ }
4964+
4965+ /**
4966+ * Updates the region information with this media record
4967+ * @return
4968+ */
4969+ final public function UpdateRegion()
4970+ {
4971+ // By this point we expect to have a MediaID, duration
4972+ $layoutid = $this->layoutid;
4973+ $regionid = $this->regionid;
4974+
4975+ if ($this->deleteFromRegion)
4976+ {
4977+ // We call region delete
4978+ if (!$this->region->RemoveMedia($layoutid, $regionid, $this->lkid, $this->mediaid))
4979+ {
4980+ $this->message = "Unable to Remove this media from the Layout";
4981+ return false;
4982+ }
4983+ }
4984+ else
4985+ {
4986+ if ($this->existingMedia)
4987+ {
4988+ // We call region swap with the same media id
4989+ if (!$this->region->SwapMedia($layoutid, $regionid, $this->lkid, $this->mediaid, $this->mediaid, $this->AsXml()))
4990+ {
4991+ $this->message = "Unable to assign to the Region";
4992+ return false;
4993+ }
4994+ }
4995+ else
4996+ {
4997+ // We call region add
4998+ if (!$this->region->AddMedia($layoutid, $regionid, $this->regionSpecific, $this->AsXml()))
4999+ {
5000+ $this->message = "Error adding this media to the library";
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: