/
export.php
239 lines (137 loc) · 7.55 KB
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<?php
/**
*
* export, allows the creation of zip and scorm packages
*
* @author Patrick Lockley
* @version 1.0
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/
require_once("../../../config.php");
include "archive.php";
include "scorm_library.php";
include "../screen_size_library.php";
include "../template_status.php";
include "../user_library.php";
include "../url_library.php";
$folder_id_array = array();
$folder_array = array();
$file_array = array();
$delete_file_array = array();
$delete_folder_array = array();
ini_set('max_execution_time', 300);
if(is_numeric($_GET['template_id'])){
$_GET['template_id'] = (int) $_GET['template_id'];
$proceed = false;
if(is_template_exportable($_GET['template_id'])){
$proceed = true;
}else{
if(is_user_creator($_GET['template_id'])||is_user_admin()){
$proceed = true;
}
}
if($proceed){
$mysql_id=database_connect("Scorm export database connect success","Scorm export database connect failed");
/*
* Get the file path
*/
$query = "select " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_name as zipname, " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id, " . $xerte_toolkits_site->database_table_prefix . "logindetails.username, " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails.template_name, " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails.template_framework from " . $xerte_toolkits_site->database_table_prefix . "templaterights, " . $xerte_toolkits_site->database_table_prefix . "logindetails, " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails, " . $xerte_toolkits_site->database_table_prefix . "templatedetails where " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_type_id = " . $xerte_toolkits_site->database_table_prefix . "originaltemplatesdetails.template_type_id and " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id = " . $xerte_toolkits_site->database_table_prefix . "templatedetails.template_id and " . $xerte_toolkits_site->database_table_prefix . "templatedetails.creator_id = " . $xerte_toolkits_site->database_table_prefix . "logindetails.login_id and " . $xerte_toolkits_site->database_table_prefix . "templaterights.template_id=\"" . mysql_real_escape_string($_GET['template_id']) . "\" AND role=\"creator\"";
$query_response = mysql_query($query);
$row = mysql_fetch_array($query_response);
/*
* Set up the paths
*/
$dir_path = $xerte_toolkits_site->users_file_area_full . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/";
$parent_template_path = $xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/parent_templates/" . $row['template_name'] . "/";
$scorm_path = $xerte_toolkits_site->basic_template_path . $row['template_framework'] . "/scorm/";
/*
* Make the zip
*/
$zipfile = new zip_file("example_zipper_new" . time() . ".zip");
$zipfile->set_options(array('basedir' => $dir_path, 'prepand' => "", 'inmemory' => 1, 'recurse' => 1, 'storepaths' => 1));
/*
* Copy the core files over from the parent folder
*/
folder_loop($parent_template_path);
copy($dir_path . "data.xml",$dir_path . "template.xml");
if(isset($_GET['local'])){
if($_GET['local']=="true"){
$string = file_get_contents($dir_path . "/template.xml");
$string = str_replace($xerte_toolkits_site->site_url . $xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row['username'] . "-" . $row['template_name'] . "/", "", $string);
$fh = fopen($dir_path . "/template.xml", 'w+');
fwrite($fh,$string);
fclose($fh);
}
}
copy_parent_files();
/*
* If scorm copy the scorn files as well
*/
$scorm=mysql_real_escape_string($_GET['scorm']);
if($scorm=="true"){
folder_loop($scorm_path);
copy_scorm_files();
}else{
copy($scorm_path . "rloObject.js", $dir_path . "rloObject.js");
array_push($delete_file_array, $dir_path . "rloObject.js");
copy($scorm_path . "MainPreloader.swf", $dir_path . "MainPreloader.swf");
array_push($delete_file_array, $dir_path . "MainPreloader.swf");
copy($scorm_path . "resources.swf", $dir_path . "resources.swf");
array_push($delete_file_array, $dir_path . "resources.swf");
}
copy($xerte_toolkits_site->root_file_path . "XMLEngine.swf", $dir_path . "XMLEngine.swf");
array_push($delete_file_array, $dir_path . "XMLEngine.swf");
/*
* Language support
*/
mkdir($dir_path . 'languages');
chmod($dir_path . 'languages', 0777);
array_push($delete_folder_array, $dir_path . 'languages');
copy($xerte_toolkits_site->root_file_path . "languages/language-config.xml", $dir_path . "languages/language-config.xml");
array_push($delete_file_array, $dir_path . "languages/language-config.xml");
copy($xerte_toolkits_site->root_file_path . "languages/engine_" . $_SESSION['default_language'] . ".xml", $dir_path . "languages/engine_" . $_SESSION['default_language'] . ".xml");
array_push($delete_file_array, $dir_path . "languages/engine_" . $_SESSION['default_language'] . ".xml");
if($scorm=="true"){
copy($dir_path . $row['template_name'] . ".rlt", $dir_path . "learningobject.rlo");
unlink($dir_path . $row['template_name'] . ".rlt");
array_push($delete_file_array, $dir_path . "learningobject.rlo");
}else{
copy($dir_path . $row['template_name'] . ".rlt", $dir_path . "learningobject.rlt");
unlink($dir_path . $row['template_name'] . ".rlt");
array_push($delete_file_array, $dir_path . "learningobject.rlt");
}
folder_loop($dir_path);
/*
* Create scorm manifests of a basic HTML page
*/
if($scorm=="true"){
if(isset($_GET['data'])){
if($_GET['data']==true){
$query = "select * from " . $xerte_toolkits_site->database_table_prefix ."templatesyndication where template_id = " . mysql_real_escape_string($_GET['template_id']);
$query_response_metadata = mysql_query($query);
$metadata = mysql_fetch_array($query_response_metadata);
$query = "select * from " . $xerte_toolkits_site->database_table_prefix ."templaterights, " . $xerte_toolkits_site->database_table_prefix ."logindetails where template_id = " . mysql_real_escape_string($_GET['template_id']) . " and login_id = user_id";
$query_response_users = mysql_query($query);
lmsmanifest_create_rich($row, $metadata, $query_response_users);
}
}else{
lmsmanifest_create($row['zipname']);
}
scorm_html_page_create($row['template_name'],$row['template_framework']);
}else{
basic_html_page_create($row['template_name'],$row['template_framework']);
}
/*
* Add the files to the zip file, create the archive, then send it to the user
*/
xerte_zip_files();
$zipfile->create_archive();
$zipfile->download_file($row['zipname']);
/*
* remove the files
*/
clean_up_files();
unlink($dir_path . "template.xml");
}
}