function import_import_file(&$user, &$file, $more = array())
{
    if (!import_is_valid_mimetype($file, $more)) {
        return array('error' => 'invalid_mimetype', 'ok' => 0);
    }
    # Parse the file
    $process_rsp = import_process_file($file);
    if (!$process_rsp['ok']) {
        return $process_rsp;
    }
    #
    # store the data
    #
    $fingerprint = md5_file($file['path']);
    $label = $more['label'] ? $more['label'] : $process_rsp['label'];
    $import_more = array('return_dots' => $more['return_dots'], 'dots_index_on' => $more['dots_index_on'], 'label' => $label, 'mark_all_private' => $more['mark_all_private'], 'mime_type' => $file['type'], 'fingerprint' => $fingerprint, 'simplified' => $process_rsp['simplified'] ? 1 : 0);
    $import_rsp = import_process_data($user, $process_rsp['data'], $import_more);
    if (!$import_rsp['ok']) {
        return $import_rsp;
    }
    #
    # Hello new thing
    #
    $cache_key = "sheets_lookup_fingerprint_{$fingerprint}";
    cache_unset($cache_key);
    #
    # store the actual file?
    #
    if ($GLOBALS['cfg']['enable_feature_import_archive']) {
        loadlib("archive");
        $archive_rsp = archive_store_file($file, $import_rsp['sheet']);
        # throw an error if archiving fails?
    }
    #
    # happy happy
    #
    return $import_rsp;
}
Beispiel #2
0
# Ideally the front end should remove the 'upload' parameter but
# just in case...
if ($crumb_ok && $_FILES['upload'] && !post_str('url')) {
    $GLOBALS['smarty']->assign('step', 'process');
    $ok = 1;
    if ($_FILES['upload']['error']) {
        $GLOBALS['error']['upload_error'] = 1;
        $GLOBALS['error']['upload_error_msg'] = $_FILES['upload']['error'];
        $ok = 0;
    }
    if ($ok) {
        $more = array();
        if ($mime_type) {
            $more['assume_mime_type'] = $mime_type;
        }
        if (!import_is_valid_mimetype($_FILES['upload'], $more)) {
            $GLOBALS['error']['invalid_mimetype'] = 1;
            $ok = 0;
        } else {
            $_FILES['upload']['path'] = $_FILES['upload']['tmp_name'];
            $fingerprint = md5_file($_FILES['upload']['path']);
            $GLOBALS['smarty']->assign("fingerprint", $fingerprint);
            $sheets = sheets_lookup_by_fingerprint($fingerprint, $GLOBALS['cfg']['user']['id']);
            $GLOBALS['smarty']->assign_by_ref("sheets", $sheets);
            $more = array('dots_index_on' => $dots_index_on);
            $pre_process = import_process_file($_FILES['upload'], $more);
            if (!$pre_process['ok']) {
                $GLOBALS['error']['parse_fail'] = 1;
                $GLOBALS['error']['details'] = $pre_process['error'];
            }
            # convert any errors from a bag of arrays in to a hash