示例#1
0
function document_download()
{
    global $Conf, $Me, $Opt;
    $documentType = HotCRPDocument::parse_dtype(@$_REQUEST["dt"]);
    if ($documentType === null) {
        $documentType = @$_REQUEST["final"] ? DTYPE_FINAL : DTYPE_SUBMISSION;
    }
    $attachment_filename = false;
    $docid = null;
    if (isset($_REQUEST["p"])) {
        $paperId = cvtint(@$_REQUEST["p"]);
    } else {
        if (isset($_REQUEST["paperId"])) {
            $paperId = cvtint(@$_REQUEST["paperId"]);
        } else {
            $s = $orig_s = preg_replace(',\\A/*,', "", Navigation::path());
            $documentType = $dtname = null;
            if (str_starts_with($s, $Opt["downloadPrefix"])) {
                $s = substr($s, strlen($Opt["downloadPrefix"]));
            }
            if (preg_match(',\\Ap(?:aper)?(\\d+)/+(.*)\\z,', $s, $m)) {
                $paperId = intval($m[1]);
                if (preg_match(',\\A([^/]+)\\.[^/]+\\z,', $m[2], $mm)) {
                    $dtname = $mm[1];
                } else {
                    if (preg_match(',\\A([^/]+)/+(.*)\\z,', $m[2], $mm)) {
                        list($dtype, $attachment_filename) = array($m[1], $m[2]);
                    }
                }
            } else {
                if (preg_match(',\\A(?:paper)?(\\d+)-?([-A-Za-z0-9_]*)(?:\\.[^/]+|/+(.*))\\z,', $s, $m)) {
                    list($paperId, $dtname, $attachment_filename) = array(intval($m[1]), $m[2], @$m[3]);
                } else {
                    if (preg_match(',\\A([A-Za-z_][-A-Za-z0-9_]*?)?-?(\\d+)(?:\\.[^/]+|/+(.*))\\z,', $s, $m)) {
                        list($paperId, $dtname, $attachment_filename) = array(intval($m[2]), $m[1], @$m[3]);
                    }
                }
            }
            if ($dtname !== null) {
                $documentType = HotCRPDocument::parse_dtype($dtname ?: "paper");
            }
            if ($documentType !== null && $attachment_filename) {
                $o = PaperOption::find($documentType);
                if (!$o || $o->type != "attachments") {
                    $documentType = null;
                }
            }
        }
    }
    if ($documentType === null) {
        document_error("404 Not Found", "Unknown document “" . htmlspecialchars($orig_s) . "”.");
    }
    $prow = $Conf->paperRow($paperId, $Me, $whyNot);
    if (!$prow) {
        document_error("404 Not Found", whyNotText($whyNot, "view"));
    } else {
        if ($whyNot = $Me->perm_view_pdf($prow)) {
            document_error("403 Forbidden", whyNotText($whyNot, "view"));
        } else {
            if ($documentType > 0 && !$Me->can_view_paper_option($prow, $documentType, true)) {
                document_error("403 Forbidden", "You don’t have permission to view this document.");
            }
        }
    }
    if ($attachment_filename) {
        $oa = $prow->option($documentType);
        foreach ($oa ? $oa->documents($prow) : array() as $doc) {
            if ($doc->unique_filename == $attachment_filename) {
                $docid = $doc;
            }
        }
        if (!$docid) {
            document_error("404 Not Found", "No such attachment “" . htmlspecialchars($orig_s) . "”.");
        }
    }
    // Actually download paper.
    session_write_close();
    // to allow concurrent clicks
    if ($Conf->downloadPaper($prow, cvtint(@$_REQUEST["save"]) > 0, $documentType, $docid)) {
        exit;
    }
    document_error("500 Server Error", null);
}
示例#2
0
    loadRows();
}
if (isset($_REQUEST["setfollow"]) && $prow && check_post()) {
    PaperActions::set_follow($prow);
    loadRows();
}
if ($prow && isset($_GET["m"]) && $_GET["m"] === "api" && isset($_GET["fn"]) && isset(SiteLoader::$api_map[$_GET["fn"]])) {
    $Qreq = make_qreq();
    SiteLoader::call_api($Qreq->fn, $Me, $Qreq, $prow);
    json_exit(["ok" => false, "error" => "Internal error."]);
}
// check paper action
if (isset($_REQUEST["checkformat"]) && $prow && $Conf->setting("sub_banal")) {
    $ajax = defval($_REQUEST, "ajax", 0);
    $cf = new CheckFormat();
    $dt = HotCRPDocument::parse_dtype(@$_REQUEST["dt"]);
    if ($dt === null) {
        $dt = @$_REQUEST["final"] ? DTYPE_FINAL : DTYPE_SUBMISSION;
    }
    if ($Conf->setting("sub_banal{$dt}")) {
        $format = $Conf->setting_data("sub_banal{$dt}", "");
    } else {
        $format = $Conf->setting_data("sub_banal", "");
    }
    $status = $cf->analyzePaper($prow->paperId, $dt, $format);
    // chairs get a hint message about multiple checking
    if ($Me->privChair) {
        $nbanal = $Conf->session("nbanal", 0) + 1;
        $Conf->save_session("nbanal", $nbanal);
        if ($nbanal >= 3 && $nbanal <= 6) {
            $cf->msg("info", "To run the format checker for many papers, use Download &gt; Format check on the <a href='" . hoturl("search", "q=") . "'>search page</a>.");