Exemple #1
0
/**
 * Query configuration variable, with optional default value in case
 * the variable does not exist and boolean to indicate if cached
 * values can be used.
 *
 * When $name is null, then all variables will be returned.
 */
function dbconfig_get($name, $default = null, $cacheok = true)
{
    global $LIBDBCONFIG;
    if (!isset($LIBDBCONFIG) || !$cacheok) {
        dbconfig_init();
    }
    if (is_null($name)) {
        $ret = array();
        foreach ($LIBDBCONFIG as $name => $config) {
            $ret[$name] = $config['value'];
        }
        return $ret;
    }
    if (isset($LIBDBCONFIG[$name])) {
        return $LIBDBCONFIG[$name]['value'];
    }
    if ($default === null) {
        error("Configuration variable '{$name}' not found.");
    }
    return $default;
}
     $contest['freezetime_string'] = '+' . substr($contest_yaml_data['scoreboard-freeze'], 0, -3);
 }
 $contest['enabled'] = 1;
 $contest = check_contest($contest);
 $cid = $DB->q("RETURNID INSERT INTO contest SET %S", $contest);
 if (!empty($CHECKER_ERRORS)) {
     echo "<p>Contest data not valid:</p>\n";
     echo "<ul>\n";
     foreach ($CHECKER_ERRORS as $error) {
         echo "<li>" . $error . "</li>\n";
     }
     echo "</ul>\n";
     require LIBWWWDIR . '/footer.php';
     exit;
 }
 dbconfig_init();
 // TODO: event-feed-port
 if (isset($contest_yaml_data)) {
     $LIBDBCONFIG['penalty_time']['value'] = (int) $contest_yaml_data['penaltytime'];
 }
 /* clarification answers/categories currently not supported; ignore them.
 		$LIBDBCONFIG['clar_answers']['value'] = $contest_yaml_data['default-clars'];
 		$categories = array();
 		foreach ( $contest_yaml_data['clar-categories'] as $category ) {
 			$cat_key = substr(str_replace(array(' ', ',', '.'), '-',
 			                  strtolower($category)), 0, 9);
 			$categories[$cat_key] = $category;
 		}
 		$LIBDBCONFIG['clar_categories']['value'] = $categories;
 	*/
 /* Disable importing language details, as there's very little to actually import: