From eb0e501008e8aab816f96e030a7b3c0b22aaf7a2 Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 10 Oct 2011 15:41:41 +0100 Subject: [PATCH 1/7] 4888: ims_import.php: prevent "Undefined index: -1" warning --- home/ims/ims_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/ims/ims_import.php b/home/ims/ims_import.php index 57ba69c0..54f962b9 100644 --- a/home/ims/ims_import.php +++ b/home/ims/ims_import.php @@ -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']); } From 2bb149b66b421a6a5193f2c88929efc57b3fba47 Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 10 Oct 2011 15:58:47 +0100 Subject: [PATCH 2/7] 4888: ims_import.php: prevent "Undefined index: identifierref and parameters in startElement() --- home/ims/ims_import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/ims/ims_import.php b/home/ims/ims_import.php index 54f962b9..b4628b15 100644 --- a/home/ims/ims_import.php +++ b/home/ims/ims_import.php @@ -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']; @@ -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'){ From dabd698f4b63dc8bc94fbd8cda01ac85cd017c6c Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 10 Oct 2011 16:07:34 +0100 Subject: [PATCH 3/7] 4888: ims_import.php: prevent "Undefined index: href in startElement() --- home/ims/ims_import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/home/ims/ims_import.php b/home/ims/ims_import.php index b4628b15..d6415012 100644 --- a/home/ims/ims_import.php +++ b/home/ims/ims_import.php @@ -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']; } @@ -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']; From 64a82d8adbc57673ef264eebe0375ae47d411d66 Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 10 Oct 2011 16:10:59 +0100 Subject: [PATCH 4/7] 4888: ims_import.php: prevent "Undefined index: -1 in endElement() --- home/ims/ims_import.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/home/ims/ims_import.php b/home/ims/ims_import.php index d6415012..1ecf8e8a 100644 --- a/home/ims/ims_import.php +++ b/home/ims/ims_import.php @@ -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); + } } } From bde9900bc4489235ee0cafe60fb3d9ccfefb0de6 Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 10 Oct 2011 16:13:36 +0100 Subject: [PATCH 5/7] 4888: ims_import.php: prevent "Undefined index: type in checkResources() --- home/ims/ims_import.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/home/ims/ims_import.php b/home/ims/ims_import.php index 1ecf8e8a..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 From 7dc9105396b2e96b514732c8bebbe2675ae671da Mon Sep 17 00:00:00 2001 From: TJ Date: Mon, 10 Oct 2011 16:42:26 +0100 Subject: [PATCH 6/7] 4888: prog.php: prevent "Undefined index: tile and t" and "Undefined variable: size" --- home/prog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/home/prog.php b/home/prog.php index 19487bff..6ce833bd 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'; @@ -51,7 +51,7 @@ '; - if ($size == '') { + if (isset($size) && $size == '') { echo ''._AT('unknown').' '._AT('kb'); } else { echo number_format($size, 2).' '._AT('kb'); From 7076b3ae431c3e2a8bea09744e72e590c1a67b73 Mon Sep 17 00:00:00 2001 From: TJ Date: Tue, 11 Oct 2011 13:21:38 +0100 Subject: [PATCH 7/7] 4888: prog.php: prevent "Undefined index:" frame, done and t --- home/prog.php | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/home/prog.php b/home/prog.php index 6ce833bd..8166b922 100644 --- a/home/prog.php +++ b/home/prog.php @@ -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 (isset($size) && $size == '') { + if (!isset($size) || isset($size) && $size == '') { echo ''._AT('unknown').' '._AT('kb'); } else { echo number_format($size, 2).' '._AT('kb');