vpl_inmediate_redirect(vpl_mod_href('view.php', 'id', $id));
    die;
}
if ($fromform = $mform->get_data()) {
    $raw_POST_size = strlen(file_get_contents("php://input"));
    if ($_SERVER['CONTENT_LENGTH'] != $raw_POST_size) {
        $error = "NOT SAVED (Http POST error: CONTENT_LENGTH expected " . $_SERVER['CONTENT_LENGTH'] . " found {$raw_POST_size})";
        notice($error, vpl_mod_href('forms/submission.php', 'id', $id, 'userid', $userid), $vpl->get_course());
        die;
    }
    $rfn = $vpl->get_required_fgm();
    $minfiles = count($rfn->getFilelist());
    $files = array();
    for ($i = 0; $i < $instance->maxfiles; $i++) {
        $attribute = 'file' . $i;
        $name = $mform->get_new_filename($attribute);
        $data = $mform->get_file_content($attribute);
        if ($data !== false && $name !== false) {
            //autodetect data file encode
            $encode = mb_detect_encoding($data, 'UNICODE, UTF-16, UTF-8, ISO-8859-1', true);
            if ($encode > '') {
                //If code detected
                $data = iconv($encode, 'UTF-8', $data);
            }
            $files[] = array('name' => $name, 'data' => $data);
        } else {
            if ($i < $minfiles) {
                //add empty file if required
                $files[] = array('name' => '', 'data' => '');
            }
        }
Beispiel #2
0
    vpl_inmediate_redirect(vpl_mod_href('view.php', 'id', $id));
    die;
}
if ($fromform = $mform->get_data()) {
    $raw_POST_size = strlen(file_get_contents("php://input"));
    if ($_SERVER['CONTENT_LENGTH'] != $raw_POST_size) {
        $error = "NOT SAVED (Http POST error: CONTENT_LENGTH expected " . $_SERVER['CONTENT_LENGTH'] . " found {$raw_POST_size})";
        notice($error, vpl_mod_href('forms/submission.php', 'id', $id, 'userid', $userid), $vpl->get_course());
        die;
    }
    $rfn = $vpl->get_required_fgm();
    $minfiles = count($rfn->getFilelist());
    $files = array();
    for ($i = 0; $i < $instance->maxfiles; $i++) {
        $attribute = 'file' . $i;
        $name = trim($mform->get_new_filename($attribute));
        $data = $mform->get_file_content($attribute);
        if ($data !== false && $name !== false) {
            //autodetect data file encode
            $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
            if (in_array($ext, array('jar', 'zip', 'jpg', 'gif'))) {
                $data = chunk_split(base64_encode($data));
                $name .= '.b64';
            } else {
                if ($data != '') {
                    $encode = mb_detect_encoding($data, 'UNICODE, UTF-16, UTF-8, ISO-8859-1', true);
                    if ($encode > '') {
                        //If code detected
                        $data = iconv($encode, 'UTF-8', $data);
                    }
                }