本文整理汇总了PHP中auditlog函数的典型用法代码示例。如果您正苦于以下问题:PHP auditlog函数的具体用法?PHP auditlog怎么用?PHP auditlog使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了auditlog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genpw
function genpw($users, $group, $format)
{
global $DB;
$teamroleid = $DB->q('VALUE SELECT roleid FROM role WHERE role = %s', 'team');
$juryroleid = $DB->q('VALUE SELECT roleid FROM role WHERE role = %s', 'jury');
$adminroleid = $DB->q('VALUE SELECT roleid FROM role WHERE role = %s', 'admin');
if ($format == "page") {
echo "\n\n<pre>";
}
foreach ($users as $user) {
// checks if user has a "higher" role
// FIXME: integrate in users query
if ($group == 'team') {
if ($DB->q('VALUE SELECT COUNT(*) FROM userrole
WHERE userid = %i AND (roleid = %i OR roleid = %i)', $user['userid'], $juryroleid, $adminroleid) > 0) {
continue;
}
} else {
if ($group == 'judge') {
if ($DB->q('VALUE SELECT COUNT(*) FROM userrole
WHERE userid = %i AND roleid = %i', $user['userid'], $adminroleid) > 0) {
continue;
}
}
}
$pass = genrandpasswd();
// update the user table with a password
$DB->q('UPDATE user SET password = %s WHERE username = %s', md5($user['username'] . '#' . $pass), $user['username']);
auditlog('user', $user['username'], 'set password');
$line = implode("\t", array($group, $group == 'team' ? $user['teamid'] : '', str_replace("\t", " ", $user['name']), str_replace("\t", " ", $user['username']), $pass)) . "\n";
if ($format == "page") {
echo htmlspecialchars($line);
} else {
echo $line;
}
}
if ($format == "page") {
echo "</pre><hr />\n\n<pre>";
}
}
示例2: tsv_accounts_set
function tsv_accounts_set($data)
{
global $DB;
$c = 0;
foreach ($data as $row) {
$DB->q("REPLACE INTO user SET %S", $row['user']);
$userid = $DB->q("VALUE SELECT userid FROM user WHERE username = %s", $row['user']['username']);
auditlog('user', $userid, 'replaced', 'imported from tsv');
$row['userrole']['userid'] = $userid;
$DB->q("REPLACE INTO userrole SET %S", $row['userrole']);
auditlog('userrole', $userid, 'replaced', 'imported from tsv');
$c++;
}
return $c;
}
示例3: warning
require_once LIBWWWDIR . '/header.php';
}
if (!isset($jid)) {
warning("Cannot claim this submission: no valid judging found.");
} else {
if ($jdata[$jid]['verified']) {
warning("Cannot claim this submission: judging already verified.");
} else {
if (empty($jury_member) && isset($_REQUEST['claim'])) {
warning("Cannot claim this submission: no jury member specified.");
} else {
if (!empty($jdata[$jid]['jury_member']) && isset($_REQUEST['claim']) && $jury_member !== $jdata[$jid]['jury_member']) {
warning("Submission claimed and previous owner " . @$jdata[$jid]['jury_member'] . " replaced.");
}
$DB->q('UPDATE judging SET jury_member = ' . (isset($_REQUEST['unclaim']) ? 'NULL %_ ' : '%s ') . 'WHERE judgingid = %i', $jury_member, $jid);
auditlog('judging', $jid, isset($_REQUEST['unclaim']) ? 'unclaimed' : 'claimed');
if (isset($_REQUEST['unclaim'])) {
header('Location: submissions.php');
}
}
}
}
}
// Headers might already have been included.
require_once LIBWWWDIR . '/header.php';
echo "<br/><h1 style=\"display:inline;\">Submission s" . $id . (isset($submdata['origsubmitid']) ? ' (resubmit of <a href="submission.php?id=' . urlencode($submdata['origsubmitid']) . '">s' . specialchars($submdata['origsubmitid']) . '</a>)' : '') . ($submdata['valid'] ? '' : ' (ignored)') . "</h1>\n\n";
if (IS_ADMIN) {
$val = !$submdata['valid'];
$unornot = $val ? 'un' : '';
echo " \n" . addForm('ignore.php') . addHidden('id', $id) . addHidden('val', $val) . '<input type="submit" value="' . $unornot . 'IGNORE this submission" onclick="return confirm(\'Really ' . $unornot . "ignore submission s{$id}?');\" /></form>\n";
}
示例4: auditlog
}
auditlog('rejudging', $id, 'canceling rejudge', '(start)');
$res = $DB->q('SELECT submitid, cid, teamid, probid
FROM submission
WHERE rejudgingid=%i', $id);
while ($row = $res->next()) {
// restore old judgehost association
$valid_judgehost = $DB->q('VALUE SELECT judgehost FROM judging
WHERE submitid=%i AND valid=1', $row['submitid']);
$DB->q('UPDATE submission SET rejudgingid = NULL, judgehost=%s
WHERE rejudgingid = %i', $valid_judgehost, $id);
}
$DB->q('UPDATE rejudging
SET endtime=%s, userid_finish=%i, valid=0
WHERE rejudgingid=%i', now(), $userdata['userid'], $id);
auditlog('rejudging', $id, 'canceled rejudge', '(end)');
header('Location: rejudging.php?id=' . urlencode($id));
}
}
$userdata = $DB->q('KEYVALUETABLE SELECT userid, name FROM user
WHERE userid=%i OR userid=%i', $rejdata['userid_start'], @$rejdata['userid_finish']);
echo '<br/><h1 style="display:inline;">Rejudging r' . $id . ($rejdata['valid'] ? '' : ' (canceled)') . "</h1>\n\n";
echo "<table>\n";
echo "<tr><td>Reason:</td><td>";
if (empty($rejdata['reason'])) {
echo '<span class="nodata">none</span>';
} else {
echo specialchars($rejdata['reason']);
}
echo "</td></tr>\n";
foreach (array('userid_start' => 'Issued by', 'userid_finish' => ($rejdata['valid'] ? 'Accepted' : 'Canceled') . ' by') as $user => $msg) {
示例5: array
$refresh = array('after' => 15, 'url' => $pagename . '?id=' . urlencode($id) . $extra);
}
// This doesn't return, call before sending headers
if (isset($cmd) && $cmd == 'viewtext') {
putProblemText($id);
}
require LIBWWWDIR . '/header.php';
if (isset($_POST['upload'])) {
if (!empty($_FILES['problem_archive']['tmp_name'][0])) {
foreach ($_FILES['problem_archive']['tmp_name'] as $fileid => $tmpname) {
$cid = $_POST['contest'];
checkFileUpload($_FILES['problem_archive']['error'][$fileid]);
$zip = openZipFile($_FILES['problem_archive']['tmp_name'][$fileid]);
$newid = importZippedProblem($zip, empty($id) ? NULL : $id, $cid);
$zip->close();
auditlog('problem', $newid, 'upload zip', $_FILES['problem_archive']['name'][$fileid]);
}
if (count($_FILES['problem_archive']['tmp_name']) == 1) {
$probid = empty($newid) ? $id : $newid;
$probname = $DB->q('VALUE SELECT name FROM problem
WHERE probid = %i', $probid);
echo '<p><a href="' . $pagename . '?id=' . urlencode($probid) . '">Return to problem p' . specialchars($probid) . ': ' . specialchars($probname) . ".</a></p>\n";
}
echo "<p><a href=\"problems.php\">Return to problems overview.</a></p>\n";
} else {
error("Missing filename for problem upload. Maybe you have to increase upload_max_filesize, see config checker.");
}
require LIBWWWDIR . '/footer.php';
exit;
}
if (!empty($cmd)) {
示例6: error
case 'SETNULL':
$warnings[] = "create dangling references in {$table}";
break;
case 'NOCONSTRAINT':
break;
default:
error("{$t}.{$key} is referenced in {$table} with unknown action '{$action}'.");
}
}
}
}
if (isset($_POST['confirm'])) {
// LIMIT 1 is a security measure to prevent our bugs from
// wiping a table by accident.
$DB->q("DELETE FROM {$t} WHERE %SS LIMIT 1", $k);
auditlog($t, implode(', ', $k), 'deleted');
echo "<p>" . ucfirst($t) . " <strong>" . specialchars(implode(", ", $k)) . "</strong> has been deleted.</p>\n\n";
if (!empty($referrer)) {
echo "<p><a href=\"" . $referrer . "\">back to overview</a></p>";
} else {
// one table falls outside the predictable filenames
$tablemulti = $t == 'team_category' ? 'team_categories' : $t . 's';
echo "<p><a href=\"" . $tablemulti . ".php\">back to {$tablemulti}</a></p>";
}
} else {
echo addForm($pagename) . addHidden('table', $t);
foreach ($k as $key => $val) {
echo addHidden($key, $val);
}
echo msgbox("Really delete?", "You're about to delete {$t} <strong>" . specialchars(join(", ", array_values($k))) . (empty($desc) ? '' : ' "' . specialchars($desc) . '"') . "</strong>.<br />\n" . (count($warnings) > 0 ? "<br /><strong>Warning, this will:</strong><br />" . implode('<br />', $warnings) : '') . "<br /><br />\n" . "Are you sure?<br /><br />\n\n" . (empty($referrer) ? '' : addHidden('referrer', $referrer)) . addSubmit(" Never mind... ", 'cancel') . addSubmit(" Yes I'm sure! ", 'confirm'));
echo addEndForm();
示例7: error
/**
* Change the valid status of a given submission.
*
* Part of the DOMjudge Programming Contest Jury System and licenced
* under the GNU GPL. See README and COPYING for details.
*/
require 'init.php';
if (!IS_ADMIN) {
error("Admin privileges are required for this operation.");
}
$id = @$_POST['id'];
$val = @$_POST['val'];
if (empty($id)) {
error("No submission ID passed to mark as (in)valid.");
}
$cnt = $DB->q('RETURNAFFECTED UPDATE submission s
SET s.valid = %i WHERE s.submitid = %i', $val, $id);
auditlog('submission', $id, 'marked ' . ($val ? 'valid' : 'invalid'));
if ($cnt == 0) {
error("Submission s{$id} not found.");
} else {
if ($cnt > 1) {
error("Ignored more than one submission.");
}
}
$sdata = $DB->q('TUPLE SELECT submitid, cid, teamid, probid
FROM submission
WHERE submitid = %i', $id);
calcScoreRow($sdata['cid'], $sdata['teamid'], $sdata['probid']);
/* redirect back. */
header('Location: submission.php?id=' . urlencode($sdata['submitid']));
示例8: list
if (isset($_POST['submit']) && !empty($_POST['bodytext'])) {
list($cid, $probid) = explode('-', $_POST['problem']);
$category = NULL;
if (!ctype_digit($probid)) {
$category = $probid;
$probid = NULL;
}
// Disallow problems that are not submittable or
// before contest start.
if (!problemVisible($probid)) {
$probid = NULL;
}
$newid = $DB->q('RETURNID INSERT INTO clarification
(cid, submittime, sender, probid, category, body)
VALUES (%i, %s, %i, %i, %s, %s)', $cid, now(), $teamid, $probid, $category, $_POST['bodytext']);
auditlog('clarification', $newid, 'added', null, null, $cid);
// redirect back to the original location
header('Location: ./');
exit;
}
$title = 'Clarifications';
require LIBWWWDIR . '/header.php';
if (isset($id)) {
// display clarification thread
if ($myrequest) {
echo "<h1>Clarification Request</h1>\n\n";
} else {
echo "<h1>Clarification</h1>\n\n";
}
putClarification($respid, $teamid);
echo "<h2>Send Clarification Request</h2>\n\n";
示例9: elseif
} elseif (isset($_COOKIE['domjudge_cid']) && $_COOKIE['domjudge_cid'] >= 1) {
$contests = array($_COOKIE['domjudge_cid']);
}
if (!isset($_REQUEST['refresh'])) {
if (count($contests) == 1) {
$cname = $DB->q('VALUE SELECT shortname FROM contest
WHERE cid = %i', reset($contests));
}
echo addForm($pagename);
echo msgbox('Significant database impact', 'Refreshing the scoreboard cache can have a significant impact on the database load, ' . 'and is not necessary in normal operating circumstances.<br /><br />' . 'Refresh scoreboard cache for ' . (count($contests) == 1 ? "contest '{$cname}'" : 'all active contests') . ' now?<br /><br />' . addSubmit(" Refresh now! ", 'refresh'));
echo addEndForm();
require LIBWWWDIR . '/footer.php';
exit;
}
$time_start = microtime(TRUE);
auditlog('scoreboard', null, 'refresh cache');
// no output buffering... we want to see what's going on real-time
ob_implicit_flush();
foreach ($contests as $contest) {
// get the contest, teams and problems
$teams = $DB->q('TABLE SELECT t.teamid FROM team t
INNER JOIN contest c ON c.cid = %i
LEFT JOIN contestteam ct ON ct.teamid = t.teamid AND ct.cid = c.cid
WHERE (c.public = 1 OR ct.teamid IS NOT NULL) ORDER BY teamid', $contest);
$probs = $DB->q('TABLE SELECT probid, cid FROM problem
INNER JOIN contestproblem USING (probid)
WHERE cid = %i ORDER BY shortname', $contest);
echo "<p>Recalculating all values for the scoreboard cache for contest c{$contest} (" . count($teams) . " teams, " . count($probs) . " problems)...</p>\n\n<pre>\n";
if (count($teams) == 0) {
echo "No teams defined, doing nothing.</pre>\n\n";
continue;
示例10: array
// rebuild array of filenames, paths to get rid of empty upload fields
$FILEPATHS = $FILENAMES = array();
foreach ($_FILES['code']['tmp_name'] as $fileid => $tmpname) {
if (!empty($tmpname)) {
checkFileUpload($_FILES['code']['error'][$fileid]);
$FILEPATHS[] = $_FILES['code']['tmp_name'][$fileid];
$FILENAMES[] = $_FILES['code']['name'][$fileid];
}
}
// FIXME: the following checks are also performed inside
// submit_solution.
/* Determine the problem */
$probid = @$_POST['probid'];
$prob = $DB->q('MAYBETUPLE SELECT probid, name FROM problem
INNER JOIN contestproblem USING (probid)
WHERE allow_submit = 1 AND probid = %i AND cid = %i', $probid, $cid);
if (!isset($prob)) {
err("Unable to find problem p{$probid}");
}
$probid = $prob['probid'];
/* Determine the language */
$langid = @$_POST['langid'];
$lang = $DB->q('MAYBETUPLE SELECT langid, name FROM language
WHERE langid = %s AND allow_submit = 1', $langid);
if (!isset($lang)) {
err("Unable to find language '{$langid}'");
}
$langid = $lang['langid'];
$sid = submit_solution($teamid, $probid, $cid, $langid, $FILEPATHS, $FILENAMES);
auditlog('submission', $sid, 'added', null, null, $cid);
header('Location: index.php?submitted=' . urlencode($sid));
示例11: elseif
if (isset($_POST['cmd'])) {
$pcmd = $_POST['cmd'];
} elseif (isset($_GET['cmd'])) {
$cmd = $_GET['cmd'];
}
if (!empty($pcmd)) {
if (empty($id)) {
error("Missing language id");
}
if (isset($pcmd['toggle_submit'])) {
$DB->q('UPDATE language SET allow_submit = %i WHERE langid = %s', $_POST['val']['toggle_submit'], $id);
auditlog('language', $id, 'set allow submit', $_POST['val']['toggle_submit']);
}
if (isset($pcmd['toggle_judge'])) {
$DB->q('UPDATE language SET allow_judge = %i WHERE langid = %s', $_POST['val']['toggle_judge'], $id);
auditlog('language', $id, 'set allow judge', $_POST['val']['toggle_judge']);
}
}
require LIBWWWDIR . '/header.php';
if (!empty($cmd)) {
requireAdmin();
echo "<h2>{$title}</h2>\n\n";
echo addForm('edit.php');
echo "<table>\n";
if ($cmd == 'edit') {
$row = $DB->q('MAYBETUPLE SELECT * FROM language WHERE langid = %s', $id);
if (!$row) {
error("Missing or invalid language id");
}
echo "<tr><td>Language ID/ext:</td><td>" . addHidden('keydata[0][langid]', $row['langid']) . specialchars($row['langid']);
} else {
示例12: warning
if ($jdata[$jid]['verified']) {
warning("Cannot " . $unornot . "claim this submission: judging already verified.");
} else {
if (empty($jury_member) && $unornot === '') {
warning("Cannot claim this submission: no jury member specified.");
} else {
if (!empty($jdata[$jid]['jury_member']) && isset($_REQUEST['claim']) && $jury_member !== $jdata[$jid]['jury_member'] && !isset($_REQUEST['forceclaim'])) {
// Don't use warning() here since it implies that a
// recoverable error has occurred. Also, it generates
// invalid HTML (using an unclosed <b> tag) to detect such
// issues.
echo "<fieldset class=\"warning\"><legend>Warning</legend>" . "Submission has been claimed by " . @$jdata[$jid]['jury_member'] . ". Claim again on this page to force an update.</fieldset>";
goto claimdone;
}
$DB->q('UPDATE judging SET jury_member = ' . ($unornot === 'un' ? 'NULL %_ ' : '%s ') . 'WHERE judgingid = %i', $jury_member, $jid);
auditlog('judging', $jid, $unornot . 'claimed');
if ($unornot === 'un') {
header('Location: submissions.php');
} else {
header('Location: submission.php?id=' . $id);
}
exit;
}
}
}
}
claimdone:
if (!isset($jid)) {
// Automatically refresh page while we wait for judging data.
$refresh = array('after' => 15, 'url' => 'submission.php?id=' . urlencode($id));
}
示例13: error
* Part of the DOMjudge Programming Contest Jury System and licenced
* under the GNU GPL. See README and COPYING for details.
*/
require 'init.php';
$id = @$_POST['id'];
$val = @$_POST['val'];
$comment = @$_POST['comment'];
if (empty($id)) {
error("No judging ID passed to mark as verified.");
}
$jury_member = $username;
// Explicitly unset jury_member when unmarking verified: otherwise this
// judging would be marked as "claimed".
$cnt = $DB->q('RETURNAFFECTED UPDATE judging
SET verified = %i, jury_member = ' . ($val ? '%s ' : 'NULL %_ ') . ', verify_comment = %s WHERE judgingid = %i', $val, $jury_member, $comment, $id);
auditlog('judging', $id, $val ? 'set verified' : 'set unverified');
if ($cnt == 0) {
error("Judging '{$id}' not found or nothing changed.");
} else {
if ($cnt > 1) {
error("Validated more than one judging.");
}
}
$jdata = $DB->q('TUPLE SELECT j.result, s.submitid, s.cid, s.teamid, s.probid, s.langid
FROM judging j
LEFT JOIN submission s USING (submitid)
WHERE judgingid = %i', $id);
if (dbconfig_get('verification_required', 0)) {
calcScoreRow($jdata['cid'], $jdata['teamid'], $jdata['probid']);
// log to event table (case of no verification required is handled
// in the REST API function judging_runs_POST)
示例14: check_add
function check_add($probid, $rank, $FILES)
{
global $DB;
$result = '';
if (!empty($_FILES['add_input']['name']) || !empty($_FILES['add_output']['name'])) {
$content = array();
foreach ($FILES as $file) {
if (empty($_FILES['add_' . $file]['name'])) {
warning("No {$file} file specified for new testcase, ignoring.");
} else {
checkFileUpload($_FILES['add_' . $file]['error']);
$content[$file] = file_get_contents($_FILES['add_' . $file]['tmp_name']);
}
}
$DB->q("INSERT INTO testcase\n\t\t (probid,rank,md5sum_input,md5sum_output,input,output,description,sample)\n\t\t VALUES (%i,%i,%s,%s,%s,%s,%s,%i)", $probid, $rank, md5(@$content['input']), md5(@$content['output']), @$content['input'], @$content['output'], @$_POST['add_desc'], isset($_POST['add_sample']));
if (!empty($content['image'])) {
list($thumb, $type) = get_image_thumb_type($content['image']);
$DB->q('UPDATE testcase SET image = %s, image_thumb = %s, image_type = %s
WHERE probid = %i AND rank = %i', @$content['image'], $thumb, $type, $probid, $rank);
}
auditlog('testcase', $probid, 'added', "rank {$rank}");
$result .= "<li>Added new testcase {$rank} from files " . specialchars($_FILES['add_input']['name']) . " (" . printsize($_FILES['add_input']['size']) . ") and " . specialchars($_FILES['add_output']['name']) . " (" . printsize($_FILES['add_output']['size']) . ").";
if ($_FILES['add_output']['size'] > dbconfig_get('output_limit') * 1024) {
$result .= "<br /><b>Warning: output file size exceeds " . "<code>output_limit</code> of " . dbconfig_get('output_limit') . " kB. This will always result in wrong answers!</b>";
}
if (empty($content['input']) || empty($content['output'])) {
$result .= "<br /><b>Warning: empty testcase file(s)!</b>";
}
$result .= "</li>\n";
}
return $result;
}
示例15: error
continue;
}
$filename = $zip->getNameIndex($j);
// overwrite it
if (FALSE === file_put_contents($tmpexecdir . "/" . $filename, str_replace("\r\n", "\n", $_POST['texta' . $j]))) {
error("Could not overwrite zip file contents.");
}
}
$zip->close();
system("zip -r -j {$tmpfname} '{$tmpexecdir}'", $retval);
if ($retval != 0) {
error("failed to zip executable files.");
}
$content = file_get_contents($tmpfname . ".zip");
$DB->q('UPDATE executable SET zipfile = %s, md5sum = %s WHERE execid = %s', $content, md5($content), $id);
auditlog('executable', $id, 'updated');
unlink($tmpfname);
unlink($tmpfname . ".zip");
system("rm -rf '{$tmpexecdir}'");
header('Location: executable.php?id=' . $id);
exit;
}
$id = getRequestID(FALSE);
$executable = $DB->q('MAYBETUPLE SELECT * FROM executable
WHERE execid = %s', $id);
if (empty($executable)) {
error("Executable {$id} not found");
}
// Download was requested
if (isset($_GET['fetch'])) {
error("downloading of single files not implemented yet");