function parseFeed() { // read the upload_id.redirect file if ($this->xml_post_data = readUbrFile($this->xml_file)) { // store the raw xml file $this->raw_xml_data = $this->xml_post_data; // format the xml data into 1 long string $this->xml_post_data = preg_replace('/\\>(\\n|\\r|\\r\\n| |\\t)*\\</', '><', $this->xml_post_data); // create the xml parser $this->XML_Parser = xml_parser_create(''); // set xml parser options xml_set_object($this->XML_Parser, $this); xml_parser_set_option($this->XML_Parser, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler($this->XML_Parser, "startHandler", "endHandler"); xml_set_character_data_handler($this->XML_Parser, "dataHandler"); // parse upload_id.redirect file if (!xml_parse($this->XML_Parser, $this->xml_post_data)) { $this->in_error = true; $this->error_msg = sprintf("<span class='ubrError'>XML ERROR</span>: %s at line %d", xml_error_string(xml_get_error_code($this->XML_Parser)), xml_get_current_line_number($this->XML_Parser)); } xml_parser_free($this->XML_Parser); // delete upload_id.redirect file if ($this->delete_xml_file) { for ($i = 0; $i < 3; $i++) { if (@unlink($this->xml_file)) { break; } else { sleep(1); } } } } else { $this->in_error = true; $this->error_msg = "<span class='ubrError'>ERROR</span>: Failed to open redirect file " . $this->upload_id . ".redirect"; } }
if ($_INI['debug_ajax']) { showDebugMessage("Failed to delete " . $TEMP_DIR . $UPLOAD_ID . ".dir"); } } stopUpload(); if ($error_num == 1) { $formatted_error_msg = "<span class='ubrError'>ERROR</span>: Failed to open link file " . $UPLOAD_ID . ".link"; } elseif ($error_num == 2 || $error_num == 3) { $formatted_error_msg = "<span class='ubrError'>ERROR</span>: " . $error_msg; } showAlertMessage($formatted_error_msg, 1); } else { // Keep trying to read the hook file until timeout if ($_INI['cgi_upload_hook']) { for ($i = 0; $i < $_INI['hook_timeout_limit']; $i++) { if ($hook_data = readUbrFile($hook_file, $_INI['debug_ajax'])) { $found_hook_file = true; break; } clearstatcache(); sleep(1); } } // Failed to find the hook file in the alloted time if ($_INI['cgi_upload_hook'] && !$found_hook_file) { if ($_INI['debug_ajax']) { showDebugMessage("Failed to find hook file {$hook_file}"); } showAlertMessage("<span class='ubrError'>ERROR</span>: Failed to find hook file", 1); } if ($_INI['debug_ajax']) {
} $total_bytes_read = 0; $files_uploaded = 0; $current_filename = ''; $bytes_read = 0; $upload_active = 0; $flength_file = $UPLOAD_ID . '.flength'; $path_to_flength_file = $TEMP_DIR . $UPLOAD_ID . '.dir/' . $flength_file; $temp_upload_dir = $TEMP_DIR . $UPLOAD_ID . '.dir'; // If the "/temp_dir/upload_id.dir/upload_id.flength" file exist, the upload is active if (is_readable($path_to_flength_file)) { $upload_active = 1; if ($_INI['cgi_upload_hook']) { // Get upload status by reading the "/temp_dir/upload_id.dir/upload_id.hook" file $hook_file = $TEMP_DIR . $UPLOAD_ID . '.dir/' . $UPLOAD_ID . '.hook'; if ($upload_status = readUbrFile($hook_file, $_INI['debug_ajax'])) { list($total_bytes_read, $files_uploaded, $current_filename, $bytes_read) = explode($DATA_DELIMITER, $upload_status); } else { $upload_active = 0; } } else { // Get upload status by reading the "/temp_dir/upload_id.dir" directory if ($handle = @opendir($temp_upload_dir)) { while (($file_name = @readdir($handle)) !== false) { if ($file_name !== '.' && $file_name !== '..' && $file_name !== $flength_file) { $total_bytes_read += sprintf("%u", @filesize($temp_upload_dir . '/' . $file_name)); $files_uploaded++; } } @closedir($handle); if ($files_uploaded > 0) {