diff --git a/home/ims/ims_import.php b/home/ims/ims_import.php index 57ba69c0..785dc240 100644 --- a/home/ims/ims_import.php +++ b/home/ims/ims_import.php @@ -237,7 +237,7 @@ function checkResources($import_path){ } //validate the xml by its schema - if (preg_match('/imsqti\_(.*)/', $fileinfo['type'])){ + if (isset($fileinfo['type']) && preg_match('/imsqti\_(.*)/', $fileinfo['type'])){ $qti = new QTIParser($fileinfo['type']); $xml_content = @file_get_contents($import_path . $fileinfo['href']); $qti->parse($xml_content); //will add error to $msg if failed @@ -455,7 +455,7 @@ function startElement($parser, $name, $attrs) { global $course_primary_lang; // get language from CONTENT PACKAGE - if (substr($element_path[count($element_path)-1], -6) == ':title' && substr($name, -11) == ':langstring') { + if (count($element_path) > 0 && substr($element_path[count($element_path)-1], -6) == ':title' && substr($name, -11) == ':langstring') { $course_primary_lang = trim($attrs['xml:lang']); } @@ -498,7 +498,7 @@ function startElement($parser, $name, $attrs) { // special case for webCT content packages that don't specify the `href` attribute // with the `` element. // we take the `href` from the first `` element. - if (isset($items[$current_identifier]) && ($items[$current_identifier]['href'] == '')) { + if (isset($items[$current_identifier]) && isset($items[$current_identifier]['href']) && ($items[$current_identifier]['href'] == '')) { $attrs['href'] = urldecode($attrs['href']); $items[$current_identifier]['href'] = $attrs['href']; } @@ -565,7 +565,7 @@ function startElement($parser, $name, $attrs) { if (isset($_POST['allow_a4a_import']) && isset($items[$current_identifier])) { $items[$current_identifier]['a4a_import_enabled'] = true; } - } else if (($name == 'item') && ($attrs['identifierref'] != '')) { + } else if (($name == 'item') && array_key_exists('identifierref', $attrs) && ($attrs['identifierref'] != '')) { $path[] = $attrs['identifierref']; } else if (($name == 'item') && ($attrs['identifier'])) { $path[] = $attrs['identifier']; @@ -573,7 +573,7 @@ function startElement($parser, $name, $attrs) { } else if (($name == 'resource')) { $current_identifier = $attrs['identifier']; $items[$current_identifier]['type'] = $attrs['type']; - if ($attrs['href']) { + if (isset($attrs['href'])) { $attrs['href'] = urldecode($attrs['href']); $items[$attrs['identifier']]['href'] = $attrs['href']; @@ -596,7 +596,7 @@ function startElement($parser, $name, $attrs) { //if there is a dependency, attach it to the item array['file'] $items[$current_identifier]['dependency'][] = $attrs['identifierref']; } - if (($name == 'item') && ($attrs['parameters'] != '')) { + if (($name == 'item') && array_key_exists('parameters', $attrs) && ($attrs['parameters'] != '')) { $items[$attrs['identifierref']]['test_message'] = $attrs['parameters']; } if ($name=='file'){ @@ -633,17 +633,19 @@ function endElement($parser, $name) { // added by Cindy Li on Jan 10, 2010 // Extract course title, description and primary language for a newly-created course - if (substr($element_path[count($element_path)-2], -6) == ':title') { - if (substr($element_path[count($element_path)-1], -7) == ':string' || - substr($element_path[count($element_path)-1], -11) == ':langstring') { - $course_title = trim($my_data); + if (count($element_path) >= 2) { + if (substr($element_path[count($element_path)-2], -6) == ':title') { + if (substr($element_path[count($element_path)-1], -7) == ':string' || + substr($element_path[count($element_path)-1], -11) == ':langstring') { + $course_title = trim($my_data); + } } - } - if (substr($element_path[count($element_path)-2], -12) == ':description') { - if (substr($element_path[count($element_path)-1], -7) == ':string' || - substr($element_path[count($element_path)-1], -11) == ':langstring') { - $course_description = trim($my_data); + if (substr($element_path[count($element_path)-2], -12) == ':description') { + if (substr($element_path[count($element_path)-1], -7) == ':string' || + substr($element_path[count($element_path)-1], -11) == ':langstring') { + $course_description = trim($my_data); + } } } diff --git a/home/prog.php b/home/prog.php index 19487bff..8166b922 100644 --- a/home/prog.php +++ b/home/prog.php @@ -15,7 +15,7 @@ define('TR_INCLUDE_PATH', '../include/'); require(TR_INCLUDE_PATH.'vitals.inc.php'); session_write_close(); -if ($_GET['tile']) { +if (isset($_GET['tile']) && $_GET['tile']) { $lang_variable = 'tile_progress'; } else { $lang_variable = 'upload_progress'; @@ -26,19 +26,19 @@ <?php echo _AT($lang_variable); ?> - + > +if (!array_key_exists('frame', $_GET)) { ?>  

@@ -51,30 +51,32 @@ $newest_file_time) { - $newest_file_time = $filedata['mtime']; - $newest_file_name = $file; - $size = $filedata['size'] / 1024; + if (isset($_GET['t'])) { + if (!$_GET['t']) { + $newest_file_name = ''; + $newest_file_time = 0; + // get the name of the temp file. + if ($dir = @opendir($tmp_dir)) { + while (($file = readdir($dir)) !== false) { + if ((strlen($file) == 9) && (substr($file, 0, 3) == 'php')) { + $filedata = stat($tmp_dir . $file); + if ($filedata['mtime'] > $newest_file_time) { + $newest_file_time = $filedata['mtime']; + $newest_file_name = $file; + $size = $filedata['size'] / 1024; + } } } + closedir($dir); } - closedir($dir); + } else { + $filedata = stat($tmp_dir . $_GET['t']); + $size = $filedata['size'] / TR_KBYTE_SIZE; } - } else { - $filedata = stat($tmp_dir . $_GET['t']); - $size = $filedata['size'] / TR_KBYTE_SIZE; } - // not sure where these are displayed in the progress popup + // displayed in the small iframe alongside the progress animated image echo ''; - if ($size == '') { + if (!isset($size) || isset($size) && $size == '') { echo ''._AT('unknown').' '._AT('kb'); } else { echo number_format($size, 2).' '._AT('kb');