コード例 #1
0
/**
 * 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;
}
コード例 #2
0
                    foreach ($backup_files as $file) {
                        unlink(WB_PATH . '/modules/droplets/export/' . $file);
                    }
                }
            }
            $backup_files = wbce_find_backups(WB_PATH . '/modules/droplets/export/');
            $data = array();
            if (count($backup_files) > 0) {
                // sort by name
                sort($backup_files);
                foreach ($backup_files as $i => $file) {
                    // stat
                    $stat = stat(WB_PATH . '/modules/droplets/export/' . $file);
                    // get zip contents
                    $zip = new PclZip(WB_PATH . '/modules/droplets/export/' . $file);
                    // get file count in zip
                    $count = $zip->listContent();
                    $data[] = array('stat' => $stat, 'count' => count($count), 'name' => $file, 'list' => implode(", ", array_map(create_function('$cnt', 'return $cnt["filename"];'), $count)));
                }
            }
            $twig_data['content'] = wbce_twig_display(array('backup_files' => $data), 'backups', true);
            $twig_data['more_header_links'] = $DR_TEXT['MANAGE_BACKUPS'];
            break;
    }
}
if (!isset($twig_data['content'])) {
    $twig_data['droplets'] = wbce_list_droplets();
}
// print result
wbce_twig_display($twig_data);