/** * handle import **/ function wbce_handle_upload() { global $DR_TEXT, $TEXT, $database, $admin; if (isset($_POST['cancel'])) { return; } $return = ''; if (isset($_FILES['userfile']) && isset($_FILES['userfile']['name'])) { // Set temp vars $temp_dir = WB_PATH . '/temp/'; $temp_file = $temp_dir . $_FILES['userfile']['name']; $temp_unzip = WB_PATH . '/temp/unzip/'; $errors = array(); // Try to upload the file to the temp dir if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $temp_file)) { echo $DR_TEXT['Upload failed']; return; } $result = wbce_unpack_and_import($temp_file, $temp_unzip); // Delete the temp zip file if (file_exists($temp_file)) { unlink($temp_file); } rm_full_dir($temp_unzip); // show errors if (isset($result['errors']) && is_array($result['errors']) && count($result['errors']) > 0) { $return = '<div style="border: 1px solid #f00; padding: 5px; color: #f00; font-weight: bold;">' . $DR_TEXT['IMPORT_ERRORS'] . "<br />\n"; foreach ($result['errors'] as $droplet => $error) { $return .= 'Droplet: ' . $droplet . '<br />' . '<span style="padding-left: 15px">' . $error . '</span>'; } $return .= "</div><br /><br />\n"; } $return .= '<div class="drok">' . $result['count'] . " " . $DR_TEXT['IMPORTED'] . '</div><br /><br />'; } $return .= wbce_twig_display(array(), 'upload', true); return $return; }
} // convert some keys into actions foreach (array_values(array('export', 'upload', 'delete')) as $key) { if (isset($_REQUEST[$key])) { $_GET['do'] = $key; break; } } // ----- duplicate ----- if (isset($_GET['copy'])) { $id = $_GET['copy']; if (is_numeric($id)) { wbce_copy_droplet($id); } } elseif (isset($_GET['recover']) && file_exists(WB_PATH . '/modules/droplets/export/' . $_GET['recover'])) { $result = wbce_unpack_and_import(WB_PATH . '/modules/droplets/export/' . $_GET['recover'], WB_PATH . '/temp/unzip/'); // show errors if (isset($result['errors']) && is_array($result['errors']) && count($result['errors']) > 0) { $twig_data['content'] = '<div style="border: 1px solid #f00; padding: 5px; color: #f00; font-weight: bold;">' . $DR_TEXT['IMPORT_ERRORS'] . "<br />\n"; foreach ($result['errors'] as $droplet => $error) { $twig_data['content'] .= 'Droplet: ' . $droplet . '<br />' . '<span style="padding-left: 15px">' . $error . '</span>'; } $twig_data['content'] .= "</div>\n"; } else { $new = isset($result['imported']) ? $result['imported'] : array(); $twig_data['content'] = '<div class="drok">' . $result['count'] . " " . $DR_TEXT['IMPORTED'] . '</div>'; } $twig_data['more_header_links'] = $DR_TEXT['IMPORTED']; } // action if (isset($_GET['do'])) {