if (count($import_files) > 0) $my_files = array_merge($my_files, $import_files);
foreach ($my_files as $file) {
/* filter out full urls */
- $url_parts = @parse_url($file);
+ $url_parts = @parse_url($file);
// if (isset($url_parts['scheme'])) {
// continue;
// }
} else {
$zip_path = 'resources/' . $content['content_path'] . $file;
}
-
$zipfile->add_file(@file_get_contents($file_path), $zip_path, $file_info['mtime']);
}
}
//http://www.atutor.ca/atutor/mantis/view.php?id=4313
//relative link that goes beyond get.php shouldn't be added
//relative link that does not exist shouldn't be added.
- $content_files .= str_replace('{FILE}', $content['content_path'] . $file, $ims_template_xml['file']);
+ $filepath_array = explode('/', $content['content_path'] . $file);
+ $new_filepath_array = array();
+ if (in_array('..', $filepath_array)){
+ while (!empty($filepath_array)){
+ $temp = array_shift($filepath_array);
+ if ($temp == '..'){
+ array_pop($new_filepath_array);
+ } else {
+ array_push($new_filepath_array, $temp);
+ }
+ }
+ $file = implode('/', $new_filepath_array);
+ } else {
+ $file = $content['content_path'] . $file;
+ }
+ $content_files .= str_replace('{FILE}', $file, $ims_template_xml['file']);
}
}
}
//generate a file tree
$data = rscandir($import_path);
-
//check if every file is presented in the manifest
foreach($data as $filepath){
- $filepath = substr($filepath, strlen($import_path));
-
+ debug(preg_match('/(.*)\.xml/', substr($filepath, strlen($import_path))));
//validate xml via its xsd/dtds
- if (preg_match('/(.*)\.xml/', $filepath)){
+ if (preg_match('/(.*)\.xml/', substr($filepath, strlen($import_path)))){
libxml_use_internal_errors(true);
$dom = new DOMDocument();
- $dom->load(realpath($import_path.$filepath));
- if (!@$dom->schemaValidate('main.xsd')){
+ $dom->load(realpath($filepath));
+ debug(realpath($filepath), 'filepath');
+ if (!$dom->schemaValidate('main.xsd')){
$errors = libxml_get_errors();
+ debug($errors);exit;
foreach ($errors as $error) {
//suppress warnings
if ($error->level==LIBXML_ERR_WARNING){
}
libxml_clear_errors();
}
+
//if this is the manifest file, we do not have to check for its existance.
// if (preg_match('/(.*)imsmanifest\.xml/', $filepath)){
// continue;
}
$temp_path = pathinfo($attrs['href']);
- $temp_path = explode('/', $temp_path['dirname']);
- if (empty($package_base_path)){
- $package_base_path = $temp_path;
- }
- if ($all_package_base_path!='' && empty($all_package_base_path)){
- $all_package_base_path = $temp_path;
+ if (!strpos($temp_path['dirname'], 'Share')) {
+ $temp_path = explode('/', $temp_path['dirname']);
+ if (empty($package_base_path)){
+ $package_base_path = $temp_path;
+ }
+ if ($all_package_base_path!='' && empty($all_package_base_path)){
+ $all_package_base_path = $temp_path;
+ }
+ $package_base_path = array_intersect_assoc($package_base_path, $temp_path);
}
- $package_base_path = array_intersect_assoc($package_base_path, $temp_path);
//calculate the depths of relative paths
if ($all_package_base_path!=''){
if (in_array('..', $temp_path)){
$sizeofrp = array_count_values($temp_path);
}
-
//for IMSCC, assume that all resources lies in the same folder, except styles.css
if ($items[$current_identifier]['type']=='webcontent' || $items[$current_identifier]['type']=='imsdt_xmlv1p0'){
//find the intersection of each item's related files, then that intersection is the content_path
if (isset($items[$current_identifier]['file'])){
foreach ($items[$current_identifier]['file'] as $resource_path){
- $temp_path = pathinfo($resource_path);
- $temp_path = explode('/', $temp_path['dirname']);
- $package_base_path = array_intersect_assoc($package_base_path, $temp_path);
+ if (!strpos($resource_path, 'Share')) {
+ $temp_path = pathinfo($resource_path);
+ $temp_path = explode('/', $temp_path['dirname']);
+ $package_base_path = array_intersect_assoc($package_base_path, $temp_path);
+ }
}
}
}
-
//real content path
if($sizeofrp['..'] > 0 && !empty($all_package_base_path)){
for ($i=0; $i<$sizeofrp['..']; $i++){