function html_header($title, $css = NULL, $ie_css = NULL, $jsfile = NULL, $body_id = null) { global $html_header_sent; if ($html_header_sent) { error('HTML headers already sent!'); } $html_header_sent = true; echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><?php echo $title; ?> </title> <meta name="AUTHOR" content="Arijit De" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <?php # Add CSS link if available if (isset($css)) { echo "\t<link rel=\"stylesheet\" type=\"text/css\" href=\"{$css}\" />\n"; } if (isset($ie_css)) { ?> <!--[if IE]> <link rel="stylesheet" type="text/css" href="<?php echo $ie_css; ?> " /> <![endif]--> <?php } # Add javascript link if available $jspart = ""; if (isset($jsfile)) { echo "\t"; html_include_js($jsfile); $jspart = "onload=\"init()\""; } echo "</head>"; $idpart = ""; if (isset($body_id)) { $idpart = "id=\"{$body_id}\""; } echo "<body {$jspart} {$idpart}>"; }
function submit_field($contest_id, $team_id, &$problem, $practiceMode = false) { global $cfg; if ($practiceMode == true) { // Check for running contests in practice mode $res =& db_query('count_running_contests'); $res->fetchInto($count); if ($count['count'] > 0) { ?> <p class="system_info"><b>Sorry, solution form is disabled in practice mode.</b><br /> This is to preserve server resources for the running contest. Practice submissions will be re-enabled when that contest is over.</p> <?php return; } } html_include_js($cfg['dir']['scripts'] . '/editor.js'); $langs = language_list(); $languages = array(); foreach ($langs as $lang) { require_once $cfg['dir']['languages'] . '/' . $lang . '.php'; $func = 'lang_' . $lang . '_description'; $languages[$lang] = $func(); } $lang = $langs[0]; $source = ''; $res =& db_query('draft_by_user', array($_SESSION['user_id'])); if ($res->fetchInto($draft)) { if ($draft['contest_id'] == $contest_id && $draft['prob_id'] == $problem['prob_id']) { $lang = $draft['language']; $source = $draft['source']; } } // Code editing form $form = new HTML_QuickForm('submitForm', 'post', selflink() . '#results'); $e =& $form->addElement('select', 'language', 'Language: ', $languages); if (!isset($_POST['language'])) { $e->setValue($lang); } $e =& $form->addElement('textarea', 'source', 'Code: ', array('rows' => 12, 'class' => 'editor')); if (!isset($_POST['source'])) { $e->setValue($source); } $form->addElement('html', "\n" . '<tr><td align="right" valign="top"><div id="custom_input1" style="display:none"><b>Custom<br/>Input: </b></div></td> <td><div id="custom_input2" style="display:none"><textarea rows="4" class="editor" name="custom">' . $_POST['custom'] . '</textarea></div></td></tr>' . "\n"); $form->addElement('html', "\n" . '<tr><td align="right" valign="top"></td><td valign="top" align="left"><input name="test" value="Compile and Test" type="submit"/> <input onclick="handleTestButton()" id="custom_button" name="customb" value="Test with custom input" type="button" />' . "\n"); if ($practiceMode == false) { $form->addElement('html', ' <input name="submitit" value="Submit" type="submit" /></td></tr>'); } else { $form->addElement('html', '</td></tr>'); } $form->applyFilter('source', 'trim'); //$form->addRule('source', 'Source code area is blank! Refusing to accept.', 'required', null, 'client'); // Display some text & the form ?> <div class="mimic_para"> <a id="shortcuts_link" onclick="toggleShowShortcuts()" href="#solution">[+] Useful Editor Shortcuts:</a> <div id="shortcuts"></div> </div> <?php html_javascript_check(); html_rounded_box_open(); $form->display(); echo '<div id="edit_status"></div>'; html_rounded_box_close(); if ($form->validate()) { echo "<a name=\"results\"></a>"; ?> <p class="lower"><b>Tester:</b><br /> Please be patient while your code is being compiled and tested. Results will be displayed in the frame below.</p> <?php $solution =& $form->getSubmitValues(); $mode = ""; if ($practiceMode) { $mode = "practice"; } else { if (isset($solution['submitit'])) { $mode = "submit"; } } if ($id = submit_record($contest_id, $problem['prob_id'], $solution, $mode)) { html_rounded_box_open(); ?> <iframe width="90%" height="300" scrolling="yes" src="<?php echo "progress.php?id={$id}"; ?> "> <!-- Following gets displayed if IFRAME is not supported --> <b>Your browser is not supported!</b><br /> Please upgrade your browser, as it lacks basic support for inline-frames, which is necessary for this feature. Recommended browsers are <a href="http://www.getfirefox.com">Mozilla/Firefox</a>, Internet Explorer 5.0+ and Opera 7.0+. </iframe> <?php html_rounded_box_close(); } } }