Esempio n. 1
0
    $status = isset($arg["h"]) || isset($arg["help"]) ? 0 : 1;
    fwrite($status ? STDERR : STDOUT, "Usage: php batch/adddoc.php [-n CONFID] [-p PID] [-m MIMETYPE] [-d DTYPE] [--no-file-storage] FILE\n");
    exit($status);
}
$file = count($arg["_"]) ? $arg["_"][0] : "-";
if ($file === "-") {
    $content = stream_get_contents(STDIN);
} else {
    $content = file_get_contents($file);
}
if ($content === false) {
    fwrite(STDERR, "{$file}: Read error\n");
    exit(1);
}
$docclass = new HotCRPDocument((int) $arg["d"]);
$docclass->set_no_database_storage();
if (isset($arg["no-file-storage"])) {
    $docclass->set_no_file_storage();
}
$docinfo = (object) array("paperId" => (int) $arg["p"]);
$doc = (object) array("content" => $content, "documentType" => (int) $arg["d"]);
if (@$arg["f"]) {
    $doc->filename = $arg["f"];
}
if (@$arg["m"]) {
    $doc->mimetype = $arg["m"];
} else {
    if ($m = Mimetype::sniff($doc->content)) {
        $doc->mimetype = $m;
    } else {
        $doc->mimetype = "application/octet-stream";