当前位置: 首页>>代码示例>>PHP>>正文


PHP difftime函数代码示例

本文整理汇总了PHP中difftime函数的典型用法代码示例。如果您正苦于以下问题:PHP difftime函数的具体用法?PHP difftime怎么用?PHP difftime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了difftime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: infreeze

function infreeze($cdata, $time)
{
    if (!empty($cdata['freezetime']) && difftime($time, $cdata['freezetime']) > 0 && (empty($cdata['unfreezetime']) || difftime($time, $cdata['unfreezetime']) <= 0)) {
        return TRUE;
    }
    return FALSE;
}
开发者ID:retnan,项目名称:domjudge,代码行数:7,代码来源:index.php

示例2: error

}
if (!function_exists('curl_init')) {
    error("PHP cURL extension required. Please install the php5-curl package.");
}
if (isset($_REQUEST['fetch'])) {
    $ch = curl_init(ICPCWSCLICS . $contest);
} else {
    $ch = curl_init(ICPCWSSTANDINGS . $contest);
}
curl_setopt($ch, CURLOPT_USERAGENT, "DOMjudge/" . DOMJUDGE_VERSION);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "{$token}:");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json"));
if (isset($_REQUEST['upload'])) {
    if (difftime($cdata['endtime'], now()) >= 0) {
        error("Contest did not end yet. Refusing to upload standings before contest end.");
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml'));
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
    $data = '<?xml version="1.0" encoding="UTF-8"?><icpc computeCitations="1" name="Upload_via_DOMjudge_' . date("c") . '">';
    $teams = $DB->q('SELECT teamid, externalid FROM team
	                 WHERE externalid IS NOT NULL AND enabled=1');
    while ($row = $teams->next()) {
        $totals = $DB->q('MAYBETUPLE SELECT points, totaltime
		                  FROM rankcache_jury
		                  WHERE cid = %i AND teamid = %i', $cid, $row['teamid']);
        if ($totals === null) {
            $totals['points'] = $totals['totaltime'] = 0;
        }
        $rank = calcTeamRank($cdata, $row['teamid'], $totals, TRUE);
开发者ID:sponi78,项目名称:domjudge,代码行数:31,代码来源:impexp_baylor.php

示例3: urlencode

</td></tr>
<tr><td>Restriction:</td><td>
	<?php 
if (is_null($row['restrictionname'])) {
    echo '<i>None</i>';
} else {
    echo '<a href="judgehost_restriction.php?id=' . urlencode($row['restrictionid']) . '">' . htmlspecialchars($row['restrictionname']) . '</a>';
}
?>
</td></tr>
<tr><td>Status:</td><td>
<?php 
if (empty($row['polltime'])) {
    echo "Judgehost never checked in.";
} else {
    $reltime = floor(difftime(now(), $row['polltime']));
    if ($reltime < dbconfig_get('judgehost_warning', 30)) {
        echo "OK";
    } else {
        if ($reltime < dbconfig_get('judgehost_critical', 120)) {
            echo "Warning";
        } else {
            echo "Critical";
        }
    }
    echo ", time since judgehost last checked in: " . printtimediff($row['polltime']) . 's.';
}
?>
</td></tr>
</table>
开发者ID:kien8995,项目名称:domjudge,代码行数:30,代码来源:judgehost.php

示例4: IN

     $rows = $DB->q('TABLE SELECT * FROM contest WHERE cid IN (%Ai)', $curcids);
 }
 echo "</legend>\n\n";
 foreach ($rows as $row) {
     $prevchecked = false;
     $hasstarted = difftime($row['starttime'], $now) <= 0;
     $hasended = difftime($row['endtime'], $now) <= 0;
     $hasfrozen = !empty($row['freezetime']) && difftime($row['freezetime'], $now) <= 0;
     $hasunfrozen = !empty($row['unfreezetime']) && difftime($row['unfreezetime'], $now) <= 0;
     $contestname = specialchars(sprintf('%s (%s - c%d)', $row['name'], $row['shortname'], $row['cid']));
     echo "<form action=\"contests.php\" method=\"post\">\n";
     echo addHidden('cid', $row['cid']);
     echo "<fieldset><legend>{$contestname}</legend>\n";
     echo "<table>\n";
     foreach ($times as $time) {
         $haspassed = difftime($row[$time . 'time'], $now) <= 0;
         echo "<tr><td>";
         // display checkmark when done or ellipsis when next up
         if (empty($row[$time . 'time'])) {
             // don't display anything before an empty row
         } elseif ($haspassed) {
             echo "<img src=\"../images/s_success.png\" alt=\"&#10003;\" class=\"picto\" />\n";
             $prevchecked = true;
         } elseif ($prevchecked) {
             echo "…";
             $prevchecked = false;
         }
         echo "</td><td>" . ucfirst($time) . " time:</td><td>" . printtime($row[$time . 'time'], '%Y-%m-%d %H:%M (%Z)') . "</td><td>";
         // Show a button for setting the time to now(), only when that
         // makes sense. E.g. only for end contest when contest has started.
         // No button for 'activate', because when shown by definition always already active
开发者ID:sponi78,项目名称:domjudge,代码行数:31,代码来源:contests.php

示例5: header

 * under the GNU GPL. See README and COPYING for details.
 */
require 'init.php';
$title = 'Submit';
if (!isset($_POST['submit'])) {
    header('Location: ./');
    return;
}
if (is_null($cid)) {
    require LIBWWWDIR . '/header.php';
    echo "<p class=\"nodata\">No active contest</p>\n";
    require LIBWWWDIR . '/footer.php';
    exit;
}
$now = now();
if (!checkrole('jury') && difftime($cdata['starttime'], $now) > 0) {
    require LIBWWWDIR . '/header.php';
    echo "<p class=\"nodata\">Contest has not yet started.</p>\n";
    require LIBWWWDIR . '/footer.php';
    exit;
}
/** helper to output an error message. */
function err($string)
{
    // Annoying PHP: we need to import global variables here...
    global $title;
    require LIBWWWDIR . '/header.php';
    echo "<h2>Submit - error</h2>\n\n";
    echo '<div id="uploadstatus">';
    logmsg(LOG_WARNING, $string);
    echo '</div>';
开发者ID:bertptrs,项目名称:domjudge,代码行数:31,代码来源:upload.php

示例6: dj_setcookie

}
$viewall = TRUE;
// Restore most recent view from cookie (overridden by explicit selection)
if (isset($_COOKIE['domjudge_balloonviewall'])) {
    $viewall = $_COOKIE['domjudge_balloonviewall'];
}
// Did someone press the view button?
if (isset($_REQUEST['viewall'])) {
    $viewall = $_REQUEST['viewall'];
}
dj_setcookie('domjudge_balloonviewall', $viewall);
$refresh = array('after' => 15, 'url' => 'balloons.php');
require LIBWWWDIR . '/header.php';
echo "<h1>Balloon Status</h1>\n\n";
foreach ($cdatas as $cdata) {
    if (isset($cdata['freezetime']) && difftime($cdata['freezetime'], now()) <= 0) {
        echo "<h4>Scoreboard of c{$cdata['cid']} ({$cdata['shortname']}) is now frozen.</h4>\n\n";
    }
}
echo addForm($pagename, 'get') . "<p>\n" . addHidden('viewall', $viewall ? 0 : 1) . addSubmit($viewall ? 'view unsent only' : 'view all') . "</p>\n" . addEndForm();
$contestids = $cids;
if ($cid !== null) {
    $contestids = array($cid);
}
// Problem metadata: colours and names.
if (empty($cids)) {
    $probs_data = array();
} else {
    $probs_data = $DB->q('KEYTABLE SELECT probid AS ARRAYKEY,name,color,cid
	                      FROM problem
	                      INNER JOIN contestproblem USING (probid)
开发者ID:bertptrs,项目名称:domjudge,代码行数:31,代码来源:balloons.php

示例7: putClarificationForm

/**
 * Output a form to send a new clarification.
 * Set respid to a clarid, to make only responses to same
 * sender(s)/recipient(s) or ALL selectable.
 */
function putClarificationForm($action, $respid = NULL, $onlycontest = NULL)
{
    $cdatas = getCurContests(TRUE);
    if (isset($onlycontest)) {
        $cdatas = array($onlycontest => $cdatas[$onlycontest]);
    }
    $cids = array_keys($cdatas);
    if (empty($cids)) {
        echo '<p class="nodata">No active contests</p>';
        return;
    }
    require_once 'forms.php';
    global $DB;
    ?>

<script type="text/javascript">
<!--
function confirmClar() {
<?php 
    if (IS_JURY) {
        ?>
	var sendto_field = document.forms['sendclar'].sendto;
	var sendto = sendto_field.value;
	var sendto_text = sendto_field.options[sendto_field.selectedIndex].text;

	if ( sendto=='domjudge-must-select' ) {
		alert('You must select a recipient for this clarification.');
		return false;
	}
	return confirm("Send clarification to " + sendto_text + "?");
<?php 
    } else {
        ?>
	return confirm("Send clarification request to Jury?");
<?php 
    }
    ?>
}
// -->
</script>

<?php 
    echo addForm($action, 'post', 'sendclar');
    echo "<table>\n";
    if ($respid) {
        $clar = $DB->q('MAYBETUPLE SELECT c.*, t.name AS toname, f.name AS fromname
		                FROM clarification c
		                LEFT JOIN team t ON (t.teamid = c.recipient)
		                LEFT JOIN team f ON (f.teamid = c.sender)
		                WHERE c.clarid = %i', $respid);
    }
    if (IS_JURY) {
        // list all possible recipients in the "sendto" box
        echo "<tr><td><b><label for=\"sendto\">Send to</label>:</b></td><td>\n";
        if (!empty($respid)) {
            echo addHidden('id', $respid);
        }
        $options = array('domjudge-must-select' => '(select...)', '' => 'ALL');
        if (!$respid) {
            $teams = $DB->q('KEYVALUETABLE SELECT teamid, name
			                 FROM team
			                 ORDER BY categoryid ASC, team.name COLLATE utf8_general_ci ASC');
            $options += $teams;
        } else {
            if ($clar['sender']) {
                $options[$clar['sender']] = $clar['fromname'] . ' (t' . $clar['sender'] . ')';
            } else {
                if ($clar['recipient']) {
                    $options[$clar['recipient']] = $clar['toname'] . ' (t' . $clar['recipient'] . ')';
                }
            }
        }
        echo addSelect('sendto', $options, 'domjudge-must-select', true);
        echo "</td></tr>\n";
    } else {
        echo "<tr><td><b>To:</b></td><td>Jury</td></tr>\n";
    }
    // Select box for a specific problem (only when the contest
    // has started) or general issue.
    $options = array();
    foreach ($cdatas as $cid => $cdata) {
        $row = $DB->q('TUPLE SELECT CONCAT(cid, "-general") AS c
		               FROM contest WHERE cid = %i', $cid);
        if (IS_JURY && count($cdatas) > 1) {
            $options[$row['c']] = "{$cdata['shortname']} - General issue";
        } else {
            $options[$row['c']] = "General issue";
        }
        if (difftime($cdata['starttime'], now()) <= 0) {
            $problem_options = $DB->q('KEYVALUETABLE SELECT CONCAT(cid, "-", probid),
				                             CONCAT(shortname, ": ", name) as name
				        FROM problem
				        INNER JOIN contestproblem USING (probid)
				        WHERE cid = %i AND allow_submit = 1
				        ORDER BY shortname ASC', $cid);
//.........这里部分代码省略.........
开发者ID:nya3jp,项目名称:domjudge,代码行数:101,代码来源:clarification.php

示例8: difftime

$from = $cdata['starttime'];
$workcontest = $DB->q($query, $now, $from, $from);
$clen = difftime($now, $cdata['starttime']);
if ($res->count() == 0) {
    echo "<p class=\"nodata\">No judgehosts defined</p>\n\n";
} else {
    echo "<table class=\"list sortable\">\n<thead>\n" . "<tr><th scope=\"col\">hostname</th>" . "<th scope=\"col\">active</th>" . "<th class=\"sorttable_nosort\">status</th>" . "<th class=\"sorttable_nosort\">restriction</th>" . "<th class=\"sorttable_nosort\">load</th></tr>\n" . "</thead>\n<tbody>\n";
    while ($row = $res->next()) {
        $link = '<a href="judgehost.php?id=' . urlencode($row['hostname']) . '">';
        echo "<tr" . ($row['active'] ? '' : ' class="disabled"') . "><td>" . $link . printhost($row['hostname']) . '</a>' . "</td><td class=\"tdcenter\">" . $link . printyn($row['active']) . "</a></td>";
        echo "<td class=\"tdcenter ";
        if (empty($row['polltime'])) {
            echo "judgehost-nocon";
            echo "\" title =\"never checked in\">";
        } else {
            $reltime = floor(difftime($now, $row['polltime']));
            if ($reltime < dbconfig_get('judgehost_warning', 30)) {
                echo "judgehost-ok";
            } else {
                if ($reltime < dbconfig_get('judgehost_critical', 120)) {
                    echo "judgehost-warn";
                } else {
                    echo "judgehost-crit";
                }
            }
            echo "\" title =\"last checked in {$reltime} seconds ago\">";
        }
        echo $link . CIRCLE_SYM . "</a></td>";
        echo "<td>" . $link . (is_null($row['name']) ? '<i>none</i>' : $row['name']) . '</a></td>';
        echo "<td title=\"load during the last 2 and 10 minutes and the whole contest\">" . $link . sprintf('%.2f&nbsp;%.2f&nbsp;%.2f', @$work2min[$row['hostname']] / (2 * 60), @$work10min[$row['hostname']] / (10 * 60), @$workcontest[$row['hostname']] / $clen) . "</a></td>";
        if (IS_ADMIN) {
开发者ID:nya3jp,项目名称:domjudge,代码行数:31,代码来源:judgehosts.php

示例9: putProblemText

/**
 * Outputs a problem description text, either as download or inline.
 * It is assumed that the headers have not been sent yet, and this
 * function terminates the PHP script execution.
 */
function putProblemText($probid)
{
    global $DB, $cdata;
    $prob = $DB->q("MAYBETUPLE SELECT cid, shortname, problemtext, problemtext_type\n\t                FROM problem INNER JOIN contestproblem USING (probid)\n\t                WHERE OCTET_LENGTH(problemtext) > 0\n\t                AND probid = %i AND cid = %i", $probid, $cdata['cid']);
    if (empty($prob) || !(IS_JURY || $prob['cid'] == $cdata['cid'] && difftime($cdata['starttime'], now()) <= 0)) {
        error("Problem p{$probid} not found or not available");
    }
    switch ($prob['problemtext_type']) {
        case 'pdf':
            $mimetype = 'application/pdf';
            break;
        case 'html':
            $mimetype = 'text/html';
            break;
        case 'txt':
            $mimetype = 'text/plain';
            break;
        default:
            error("Problem p{$probid} text has unknown type");
    }
    $filename = "prob-{$prob['shortname']}.{$prob['problemtext_type']}";
    header("Content-Type: {$mimetype}; name=\"{$filename}\"");
    header("Content-Disposition: inline; filename=\"{$filename}\"");
    header("Content-Length: " . strlen($prob['problemtext']));
    echo $prob['problemtext'];
    exit(0);
}
开发者ID:nya3jp,项目名称:domjudge,代码行数:32,代码来源:common.php

示例10: error

<?php

/**
 * Upload form for documents to be sent to the printer.
 *
 * Part of the DOMjudge Programming Contest Jury System and licenced
 * under the GNU GPL. See README and COPYING for details.
 */
require 'init.php';
$title = 'Print';
require LIBWWWDIR . '/header.php';
echo "<h1>Print source</h1>\n\n";
if (!have_printing()) {
    error("Printing disabled.");
}
// Seems reasonable to require that there's a contest running
// before allowing to submit printouts.
if (is_null($cid) || difftime($cdata['starttime'], now()) > 0) {
    echo "<p class=\"nodata\">Contest has not yet started.</p>\n";
    require LIBWWWDIR . '/footer.php';
    exit;
}
if (isset($_POST['langid'])) {
    handle_print_upload();
} else {
    put_print_form();
}
require LIBWWWDIR . '/footer.php';
开发者ID:rohit-takhar,项目名称:domjudge,代码行数:28,代码来源:print.php

示例11: XMLaddnode

            $timestamp += (double) $jrun['runtime'];
        }
        XMLaddnode($run, 'judged', 'True');
        XMLaddnode($run, 'status', 'done');
        XMLaddnode($run, 'result', $result_map[$jdata['result']]);
        if ($jdata['result'] == 'correct') {
            XMLaddnode($run, 'solved', 'True');
            XMLaddnode($run, 'penalty', 'False');
        } else {
            XMLaddnode($run, 'solved', 'False');
            if ($compile_penalty == 0 && $jdata['result'] == 'compiler-error') {
                XMLaddnode($run, 'penalty', 'False');
            } else {
                XMLaddnode($run, 'penalty', 'True');
            }
        }
    }
}
// We don't support a finalize attribute in DOMjudge master branch, so
// just output some fake data if the contest has finished.
if (difftime(now(), $cdata['endtime']) >= 0) {
    $node = XMLaddnode($root, 'finalized');
    XMLaddnode($node, 'timestamp', $cdata['endtime']);
    XMLaddnode($node, 'last-gold', 0);
    XMLaddnode($node, 'last-silver', 0);
    XMLaddnode($node, 'last-bronze', 0);
    XMLaddnode($node, 'comment', 'Automatically finalized by DOMjudge');
}
header('Content-Type: text/xml; charset=' . DJ_CHARACTER_SET);
$xmldoc->formatOutput = true;
echo $xmldoc->saveXML();
开发者ID:kien8995,项目名称:domjudge,代码行数:31,代码来源:ext.php

示例12: putSampleTestcase

/**
 * Outputs a specific sample testcase for a problem.
 * A testcase is sample if it is marked as such. It's then available from
 * the team interface for download.
 *
 * $seq is the number of the testcase when selecting only the testcases
 * marked sample for the given problem, ordered by testcaseid. This is
 * done as to not leak the total number of testcases to teams.
 *
 * $type is "in" or "out".
 */
function putSampleTestcase($probid, $seq, $type)
{
    global $DB, $cdata;
    $sample = $DB->q('MAYBETUPLE SELECT shortname, ' . $type . 'put AS content
	                  FROM problem INNER JOIN testcase USING (probid)
	                  INNER JOIN contestproblem USING (probid)
	                  WHERE probid = %i AND cid = %i AND allow_submit = 1
	                  AND sample = 1 ORDER BY testcaseid ASC LIMIT %i,1', $probid, $cdata['cid'], $seq - 1);
    if (empty($sample) || difftime($cdata['starttime'], now()) > 0) {
        error("Problem p{$probid} not found or not available");
    }
    $probname = $sample['shortname'];
    $filename = "sample-{$probname}.{$seq}.{$type}";
    header("Content-Type: text/plain; name=\"{$filename}\"");
    header("Content-Disposition: attachment; filename=\"{$filename}\"");
    header("Content-Length: " . strlen($sample['content']));
    echo $sample['content'];
    exit(0);
}
开发者ID:Surya97,项目名称:domjudge,代码行数:30,代码来源:common.php

示例13: XMLaddnode

        XMLaddnode($node, 'to-all', isset($row['recipient']) ? 'False' : 'True');
    } else {
        XMLaddnode($node, 'answered', 'False');
    }
}
$compile_penalty = dbconfig_get('compile_penalty', 0);
// write out runs
while ($row = $events->next()) {
    if ($row['description'] != 'problem submitted' && $row['description'] != 'problem judged') {
        continue;
    }
    $data = $DB->q('MAYBETUPLE SELECT submittime, teamid, probid, name AS langname, valid
	                FROM submission
	                LEFT JOIN language USING (langid)
	                WHERE valid = 1 AND submitid = %i', $row['submitid']);
    if (empty($data) || difftime($data['submittime'], $cdata['endtime']) >= 0 || !isset($prob_to_id[$data['probid']]) || !isset($team_to_id[$data['teamid']])) {
        continue;
    }
    $run = XMLaddnode($root, 'run');
    XMLaddnode($run, 'id', $row['submitid']);
    XMLaddnode($run, 'problem', $prob_to_id[$data['probid']]);
    XMLaddnode($run, 'team', $team_to_id[$data['teamid']]);
    XMLaddnode($run, 'timestamp', $row['eventtime']);
    XMLaddnode($run, 'time', calcContestTime($data['submittime'], $cid));
    XMLaddnode($run, 'language', $data['langname']);
    if ($row['description'] == 'problem submitted') {
        XMLaddnode($run, 'judged', 'False');
        XMLaddnode($run, 'status', 'fresh');
    } else {
        $jdata = $DB->q('MAYBETUPLE SELECT result, starttime FROM judging j
		                 LEFT JOIN submission USING(submitid)
开发者ID:retnan,项目名称:domjudge,代码行数:31,代码来源:ext.php

示例14: check_judging

function check_judging($data, $keydata = null)
{
    if (!empty($data['endtime']) && difftime($data['endtime'], $data['starttime']) < 0) {
        ch_error('Judging ended before it started');
    }
    if (!empty($data['submittime']) && difftime($data['starttime'], $data['submittime']) < 0) {
        ch_error('Judging started before it was submitted (clocks unsynched?)');
    }
    return $data;
}
开发者ID:kien8995,项目名称:domjudge,代码行数:10,代码来源:checkers.jury.php

示例15: submit_solution

/**
 * This function takes a (set of) temporary file(s) of a submission,
 * validates it and puts it into the database. Additionally it
 * moves it to a backup storage.
 */
function submit_solution($team, $prob, $contest, $lang, $files, $filenames, $origsubmitid = NULL)
{
    global $DB;
    if (empty($team)) {
        error("No value for Team.");
    }
    if (empty($prob)) {
        error("No value for Problem.");
    }
    if (empty($contest)) {
        error("No value for Contest.");
    }
    if (empty($lang)) {
        error("No value for Language.");
    }
    if (!is_array($files) || count($files) == 0) {
        error("No files specified.");
    }
    if (count($files) > dbconfig_get('sourcefiles_limit', 100)) {
        error("Tried to submit more than the allowed number of source files.");
    }
    if (!is_array($filenames) || count($filenames) != count($files)) {
        error("Nonmatching (number of) filenames specified.");
    }
    if (count($filenames) != count(array_unique($filenames))) {
        error("Duplicate filenames detected.");
    }
    $sourcesize = dbconfig_get('sourcesize_limit');
    // If no contest has started yet, refuse submissions.
    $now = now();
    $contestdata = $DB->q('MAYBETUPLE SELECT starttime,endtime FROM contest WHERE cid = %i', $contest);
    if (!isset($contestdata)) {
        error("Contest c{$contest} not found.");
    }
    if (difftime($contestdata['starttime'], $now) > 0) {
        error("The contest is closed, no submissions accepted. [c{$contest}]");
    }
    // Check 2: valid parameters?
    if (!($langid = $DB->q('MAYBEVALUE SELECT langid FROM language
	                        WHERE langid = %s AND allow_submit = 1', $lang))) {
        error("Language '{$lang}' not found in database or not submittable.");
    }
    if (!($teamid = $DB->q('MAYBEVALUE SELECT teamid FROM team
	                        WHERE teamid = %i AND enabled = 1', $team))) {
        error("Team '{$team}' not found in database or not enabled.");
    }
    $probdata = $DB->q('MAYBETUPLE SELECT probid, points FROM problem
	                    INNER JOIN contestproblem USING (probid)
	                    WHERE probid = %s AND cid = %i AND allow_submit = 1', $prob, $contest);
    if (empty($probdata)) {
        error("Problem p{$prob} not found in database or not submittable [c{$contest}].");
    } else {
        $points = $probdata['points'];
        $probid = $probdata['probid'];
    }
    // Reindex arrays numerically to allow simultaneously iterating
    // over both $files and $filenames.
    $files = array_values($files);
    $filenames = array_values($filenames);
    $totalsize = 0;
    for ($i = 0; $i < count($files); $i++) {
        if (!is_readable($files[$i])) {
            error("File '" . $files[$i] . "' not found (or not readable).");
        }
        if (!preg_match(FILENAME_REGEX, $filenames[$i])) {
            error("Illegal filename '" . $filenames[$i] . "'.");
        }
        $totalsize += filesize($files[$i]);
    }
    if ($totalsize > $sourcesize * 1024) {
        error("Submission file(s) are larger than {$sourcesize} kB.");
    }
    logmsg(LOG_INFO, "input verified");
    // Insert submission into the database
    $id = $DB->q('RETURNID INSERT INTO submission
	              (cid, teamid, probid, langid, submittime, origsubmitid)
	              VALUES (%i, %i, %i, %s, %s, %i)', $contest, $teamid, $probid, $langid, $now, $origsubmitid);
    for ($rank = 0; $rank < count($files); $rank++) {
        $DB->q('INSERT INTO submission_file
		        (submitid, filename, rank, sourcecode) VALUES (%i, %s, %i, %s)', $id, $filenames[$rank], $rank, getFileContents($files[$rank], false));
    }
    // Recalculate scoreboard cache for pending submissions
    calcScoreRow($contest, $teamid, $probid);
    // Log to event table
    $DB->q('INSERT INTO event (eventtime, cid, teamid, langid, probid, submitid, description)
	        VALUES(%s, %i, %i, %s, %i, %i, "problem submitted")', now(), $contest, $teamid, $langid, $probid, $id);
    if (is_writable(SUBMITDIR)) {
        // Copy the submission to SUBMITDIR for safe-keeping
        for ($rank = 0; $rank < count($files); $rank++) {
            $fdata = array('cid' => $contest, 'submitid' => $id, 'teamid' => $teamid, 'probid' => $probid, 'langid' => $langid, 'rank' => $rank, 'filename' => $filenames[$rank]);
            $tofile = SUBMITDIR . '/' . getSourceFilename($fdata);
            if (!@copy($files[$rank], $tofile)) {
                warning("Could not copy '" . $files[$rank] . "' to '" . $tofile . "'");
            }
        }
//.........这里部分代码省略.........
开发者ID:22a,项目名称:Cleaner-Ducss-Judge,代码行数:101,代码来源:lib.misc.php


注:本文中的difftime函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。