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>.");
        }
    }
    $cf->reportMessages();
    if ($ajax) {
        $Conf->ajaxExit(array("status" => $status), true);
    }
}
// withdraw and revive actions
if (isset($_REQUEST["withdraw"]) && !$newPaper && check_post()) {
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf;
     $result = Dbl::qe_raw($Conf->paperQuery($user, ["paperId" => $ssel->selection()]));
     $papers = [];
     while ($prow = PaperInfo::fetch($result, $user)) {
         if ($user->can_view_pdf($prow)) {
             $papers[$prow->paperId] = $prow;
         }
     }
     $csvg = downloadCSV(false, ["paper", "title", "pages", "format"], "formatcheck");
     echo $csvg->headerline;
     $format = $Conf->setting_data("sub_banal", "");
     foreach ($ssel->reorder($papers) as $prow) {
         $pages = "?";
         if ($prow->mimetype == "application/pdf") {
             $cf = new CheckFormat();
             $dtype = $prow->finalPaperStorageId ? DTYPE_FINAL : DTYPE_SUBMISSION;
             if ($cf->analyzePaper($prow->paperId, $dtype, $format)) {
                 $format = array();
                 foreach (CheckFormat::$error_types as $en => $etxt) {
                     if ($cf->errors & $en) {
                         $format[] = $etxt;
                     }
                 }
                 $format = empty($format) ? "ok" : join(",", $format);
                 $pages = $cf->pages;
             } else {
                 $format = "error";
             }
         } else {
             $format = "notpdf";
         }
         echo $prow->paperId, ",", CsvGenerator::quote($prow->title), ",", $pages, ",", CsvGenerator::quote($format), "\n";
         ob_flush();
         flush();
     }
     exit;
 }