function show_file_upload_frame($timestamp, $data, $errors)
{
    global $l;
    $package_tmp_file = get_download_root() . $timestamp . '/tmp/package';
    echo '<div class="form-frame">';
    echo '<h4>Package archive</h4>';
    if (file_exists($package_tmp_file)) {
        echo '<div class="file-field" style="display: none">';
    } else {
        echo '<div class="file-field">';
    }
    show_form_field($data, $errors, 'input', 'FILE', $l->g(549), array('type' => 'file', 'attrs' => array('accept' => 'application/zip,application/gzip', 'multiple' => 'multiple')));
    echo '</div>';
    echo '<div class="progress progress-striped package-progress-bar" style="display: none">';
    echo '<div class="progress-bar progress-bar-success"></div>';
    echo '</div>';
    if (file_exists($package_tmp_file)) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime_type = finfo_file($finfo, $package_tmp_file);
        finfo_close($finfo);
        if ($mime_type == 'application/zip') {
            $ext = 'zip';
        } else {
            if ($mime_type == 'application/x-gzip') {
                $ext = 'tar.gz';
            }
        }
        $size = filesize($package_tmp_file);
        echo '<div class="file-info">';
        echo '<div class="file-type"><b>File type : </b><span>' . $ext . '</span></div>';
        echo '<div class="file-size"><b>File size : </b><span>' . $size . '</span></div>';
        echo '</div>';
    } else {
        echo '<div class="file-info" style="display:none">';
        echo '<div class="file-type"><b>File type : </b><span></span></div>';
        echo '<div class="file-size"><b>File size : </b><span></span></div>';
        echo '</div>';
    }
    echo '</div>';
}
function redistrib_package_exists($timestamp)
{
    return file_exists(get_download_root() . $timestamp . '/info');
}
            echo '{"status": "success", "type": "' . substr($ext, 1) . '", "size": "' . $size . '"}';
        }
        exit;
    } else {
        // Default values
        $form_data = array_merge(array('NAME' => null, 'DESCRIPTION' => null, 'OS' => 'WINDOWS', 'ACTION' => 'STORE', 'ACTION_INPUT' => null, 'DEPLOY_SPEED' => 'MIDDLE', 'PRIORITY' => 5, 'NB_FRAGS' => null, 'NOTIFY_USER' => null, 'NOTIFY_TEXT' => null, 'NOTIFY_COUNTDOWN' => null, 'NOTIFY_CAN_CANCEL' => null, 'NOTIFY_CAN_DELAY' => null, 'NEED_DONE_ACTION' => null, 'NEED_DONE_ACTION_TEXT' => null, 'REDISTRIB_USE' => null, 'REDISTRIB_PRIORITY' => 5, 'REDISTRIB_NB_FRAGS' => null, 'DOWNLOAD_SERVER_DOCROOT' => get_redistrib_distant_download_root()), $_POST);
        $form_data['TIMESTAMP'] = $timestamp;
        $errors = array();
        if (isset($_POST['create_package'])) {
            require_once 'lib/package_forms.php';
            // Perform validation
            $errors = validate_package_form($form_data, $_FILES);
            if (!$errors) {
                require_once 'require/function_telediff.php';
                // Create package
                $sql_details = array('document_root' => get_download_root(), 'timestamp' => $timestamp, 'nbfrags' => $form_data['NB_FRAGS'], 'name' => $form_data['NAME'], 'os' => $form_data['OS'], 'description' => $form_data['DESCRIPTION'], 'size' => 0, 'id_wk' => 0);
                $info_details = array('PRI' => $form_data['PRIORITY'], 'ACT' => $form_data['ACTION'], 'DIGEST' => 'TODO', 'PROTO' => 'HTTP', 'DIGEST_ALGO' => 'MD5', 'DIGEST_ENCODE' => 'HEXA', 'PATH' => $form_data['ACTION_INPUT'], 'NAME' => $form_data['ACTION_INPUT'], 'COMMAND' => $form_data['ACTION_INPUT'], 'NOTIFY_USER' => $form_data['NOTIFY_USER'], 'NOTIFY_TEXT' => $form_data['NOTIFY_TEXT'], 'NOTIFY_COUNTDOWN' => $form_data['NOTIFY_COUNTDOWN'], 'NOTIFY_CAN_ABORT' => $form_data['NOTIFY_CAN_ABORT'], 'NOTIFY_CAN_DELAY' => $form_data['NOTIFY_CAN_DELAY'], 'NEED_DONE_ACTION' => $form_data['NEED_DONE_ACTION'], 'NEED_DONE_ACTION_TEXT' => $form_data['NEED_DONE_ACTION_TEXT'], 'GARDEFOU' => 'rien');
                create_pack($sql_details, $info_details);
            }
        }
        if ($errors or !isset($_POST['create_package'])) {
            require_once 'views/package_form_view.php';
            show_package_form($form_data, $errors);
        }
    }
}
// If the package has been created, show the details of the package
if (package_exists($timestamp)) {
    $form_data = array();
    $errors = array();
    require_once 'views/activate_form_view.php';