コード例 #1
0
 public function document_callback($dj, $prow, $dtype, $drow)
 {
     if ($drow->docclass->load($drow)) {
         $dj->content_file = HotCRPDocument::filename($drow);
         $this->zipdoc->add_as($drow, $dj->content_file);
     }
 }
コード例 #2
0
<?php

$ConfSitePATH = preg_replace(',/batch/[^/]+,', '', __FILE__);
require_once "{$ConfSitePATH}/src/init.php";
$arg = getopt("hfn:", array("help", "force", "name:"));
if (isset($arg["h"]) || isset($arg["help"])) {
    fwrite(STDOUT, "Usage: php batch/killinactivedoc.php [--force]\n");
    exit(0);
}
$storageIds = $Conf->active_document_ids();
$force = isset($arg["f"]) || isset($arg["force"]);
$result = $Conf->qe("select paperStorageId, paperId, timestamp, mimetype,\n        compression, sha1, documentType, filename, infoJson\n        from PaperStorage where paperStorageId not in (" . join(",", $storageIds) . ")\n        and paper is not null and paperStorageId>1 order by timestamp");
$killable = array();
while ($doc = $Conf->document_row($result, null)) {
    $killable[$doc->paperStorageId] = "[" . $Conf->unparse_time_log($doc->timestamp) . "] " . HotCRPDocument::filename($doc) . " ({$doc->paperStorageId})";
}
if (count($killable)) {
    fwrite(STDOUT, join("\n", $killable) . "\n");
    if (!$force) {
        fwrite(STDOUT, "\nKill " . plural($killable, "document") . "? (y/n) ");
        $x = fread(STDIN, 100);
        if (!preg_match('/\\A[yY]/', $x)) {
            die("* Exiting\n");
        }
    }
    $Conf->qe("update PaperStorage set paper=NULL where paperStorageId in (" . join(",", array_keys($killable)) . ")");
    fwrite(STDOUT, count($killable) . " documents killed.\n");
} else {
    fwrite(STDOUT, "Nothing to do\n");
}
コード例 #3
0
 private function __downloadPaper($paperId, $attachment, $documentType, $docid)
 {
     global $Opt, $Me;
     if (is_object($docid)) {
         $docs = array($docid);
     } else {
         $result = $this->document_result($paperId, $documentType, $docid);
         if (!$result) {
             $this->log("Download error: " . $this->dblink->error, $Me, $paperId);
             return set_error_html("Database error while downloading paper.");
         } else {
             if (edb_nrows($result) == 0) {
                 return set_error_html("No such document.");
             }
         }
         // Check data
         $docs = array();
         while ($doc = $this->document_row($result, $documentType)) {
             if (!$doc->mimetype) {
                 $doc->mimetype = Mimetype::PDF;
             }
             $doc->filename = HotCRPDocument::filename($doc);
             $docs[] = $doc;
         }
         Dbl::free($result);
     }
     if (count($docs) == 1 && $docs[0]->paperStorageId <= 1) {
         return set_error_html("Paper #" . $docs[0]->paperId . " hasn’t been uploaded yet.");
     }
     $downloadname = false;
     if (count($docs) > 1) {
         $name = HotCRPDocument::unparse_dtype($documentType);
         if ($documentType <= 0) {
             $name = pluralize($name);
         }
         $downloadname = $Opt["downloadPrefix"] . "{$name}.zip";
     }
     return Filer::multidownload($docs, $downloadname, $attachment);
 }
コード例 #4
0
        continue;
    }
    $result = $Conf->qe("select paperStorageId, paperId, timestamp, mimetype,\n        compression, sha1, documentType, filename, infoJson,\n        paper is null as paper_null\n        from PaperStorage where paperStorageId={$sid}");
    $doc = $Conf->document_row($result, null);
    if ($doc->paper_null && !$doc->docclass->filestore_check($doc)) {
        continue;
    }
    $saved = $checked = $doc->docclass->s3_check($doc);
    if (!$saved) {
        $saved = $doc->docclass->s3_store($doc, $doc);
    }
    if (!$saved) {
        sleep(0.5);
        $saved = $doc->docclass->s3_store($doc, $doc);
    }
    $front = "[" . $Conf->unparse_time_log($doc->timestamp) . "] " . HotCRPDocument::filename($doc) . " ({$sid})";
    if ($checked) {
        fwrite(STDOUT, "{$front}: " . HotCRPDocument::s3_filename($doc) . " exists\n");
    } else {
        if ($saved) {
            fwrite(STDOUT, "{$front}: " . HotCRPDocument::s3_filename($doc) . " saved\n");
        } else {
            fwrite(STDOUT, "{$front}: SAVE FAILED\n");
            ++$failures;
        }
    }
    if ($saved && $kill) {
        $Conf->qe("update PaperStorage set paper=null where paperStorageId={$sid}");
    }
}
if ($failures) {
コード例 #5
0
ファイル: conference.php プロジェクト: benesch/peteramati
 function makeDownloadPath($doc)
 {
     global $ConfSiteBase, $ConfSiteSuffix;
     if (!property_exists($doc, "mimetype") || !isset($doc->documentType)) {
         $trace = debug_backtrace();
         error_log($trace[0]["file"] . ":" . $trace[0]["line"] . ": makeDownloadPath called with incomplete document");
     }
     if ($doc->mimetype) {
         return $ConfSiteBase . "doc{$ConfSiteSuffix}/" . HotCRPDocument::filename($doc);
     } else {
         $x = $ConfSiteBase . "doc{$ConfSiteSuffix}?p=" . $doc->paperId;
         if ($doc->documentType == DTYPE_FINAL) {
             return $x . "&amp;final=1";
         } else {
             if ($doc->documentType > 0) {
                 return $x . "&amp;dt={$doc->documentType}";
             } else {
                 return $x;
             }
         }
     }
 }