2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /************************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
19 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
20 require(AT_INCLUDE_PATH . '../mods/_core/themes/classes/ThemeParser.class.php');
22 // theme content folder
23 $theme_content_folder = AT_CONTENT_DIR . "theme/";
25 if (isset($_GET["theme"])) $theme = str_replace(array('.','..'), '', $_GET['theme']);
26 else if (isset($_POST["theme"])) $theme = $_POST["theme"];
28 if (isset($_GET["title"])) $title = $_GET['title'];
29 else if (isset($_POST["title"])) $title = $_POST["title"];
31 if (isset($_GET["permission_granted"])) $permission_granted = $_GET["permission_granted"];
32 else if (isset($_POST["permission_granted"])) $permission_granted = $_POST["permission_granted"];
34 // copy theme from content folder into themes folder
35 if (isset($_GET["theme"]))
37 copys($theme_content_folder.$theme, '../../../themes/'.$theme);
39 $theme_xml = @file_get_contents('../../../themes/'.$theme . '/theme_info.xml');
41 //Check if XML file exists (if it doesnt send error and clear directory)
42 if ($theme_xml == false)
45 $extra_info = 'unspecified';
50 $xml_parser = new ThemeParser();
51 $xml_parser->parse($theme_xml);
53 $version = $xml_parser->theme_rows['version'];
54 $type = $xml_parser->theme_rows['type'];
55 $extra_info = $xml_parser->theme_rows['extra_info'];
58 if ($title == '') $title = str_replace('_', ' ', $theme);
59 $last_updated = date('Y-m-d');
62 //if version number is not compatible with current Atutor version, set theme as disabled
63 if ($version != VERSION) $status = '0';
65 //save information in database
66 $sql = "INSERT INTO ".TABLE_PREFIX."themes (title, version, dir_name, type, last_updated, extra_info, status) ".
67 "VALUES ('$title', '$version', '$theme', '$type', '$last_updated', '$extra_info', '$status')";
68 $result = mysql_query($sql, $db);
70 write_to_log(AT_ADMIN_LOG_INSERT, 'themes', mysql_affected_rows($db), $sql);
73 if (!$result) // error occurs
75 clr_dir("../../themes/".$theme);
77 if ($_GET['permission_granted']==1)
79 header('Location: '.AT_BASE_HREF.'mods/_core/themes/theme_install_step_3.php?error=1');
83 $msg->addError('IMPORT_FAILED');
84 header('Location: '.AT_BASE_HREF.'mods/_core/themes/install_themes.php');
89 if ($_GET['permission_granted']==1)
91 header('Location: '.AT_BASE_HREF.'mods/_core/themes/theme_install_step_3.php?installed=1');
95 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
96 header('Location: '.AT_BASE_HREF.'mods/_core/themes/index.php');