本文整理汇总了PHP中Problem::setSecretBefore方法的典型用法代码示例。如果您正苦于以下问题:PHP Problem::setSecretBefore方法的具体用法?PHP Problem::setSecretBefore怎么用?PHP Problem::setSecretBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Problem
的用法示例。
在下文中一共展示了Problem::setSecretBefore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showProblem
private function showProblem($id, $ignore_git = FALSE)
{
try {
$problem = new Problem($id);
if ($problem->exists()) {
throw new fValidationException("Problem {$id} already exists.");
}
} catch (fNotFoundException $e) {
// fall through
}
$data_base_dir = Variable::getString('data-base-path');
if (!is_dir($data_base_dir)) {
throw new fValidationException("Data base directory {$data_base_dir} does not exist.");
}
if (!$ignore_git) {
$this->gitPullOriginMaster();
}
$problem_dir = "{$data_base_dir}/problems/{$id}";
if (!is_dir($problem_dir)) {
throw new fValidationException("Problem directory {$problem_dir} does not exist.");
}
$problem_conf = "{$problem_dir}/problem.conf";
if (!is_file($problem_conf)) {
throw new fValidationException("Problem configuration file {$problem_conf} does not exist.");
}
$problem_text = "{$problem_dir}/problem.text";
if (!is_file($problem_text)) {
throw new fValidationException("Problem description file {$problem_text} does not exist.");
}
$data_dir = "{$problem_dir}/data";
if (!is_dir($data_dir)) {
throw new fValidationException("Problem {$id} does not have a data directory at {$data_dir}");
}
$properties_content = file_get_contents($problem_conf);
$ini_content = str_replace(': ', ' = ', $properties_content);
$ini = parse_ini_string($ini_content);
if (!array_key_exists('title', $ini) or empty($ini['title'])) {
throw new fValidationException('Problem title is not specified in problem.conf');
}
if (!array_key_exists('author', $ini)) {
throw new fValidationException('Problem author is not specified in problem.conf');
}
if (!array_key_exists('case_count', $ini) or empty($ini['case_count'])) {
throw new fValidationException('Problem case count is not specified in problem.conf');
}
if (!array_key_exists('case_score', $ini) or empty($ini['case_score'])) {
throw new fValidationException('Problem case score is not specified in problem.conf');
}
if (!array_key_exists('time_limit', $ini) or empty($ini['time_limit'])) {
throw new fValidationException('Problem time limit is not specified in problem.conf');
}
if (!array_key_exists('memory_limit', $ini) or empty($ini['memory_limit'])) {
throw new fValidationException('Problem memory limit is not specified in problem.conf');
}
if (!array_key_exists('secret_before', $ini) or empty($ini['secret_before'])) {
throw new fValidationException('Problem secret-before time is not specified in problem.conf');
}
if (empty($ini['author'])) {
$ini['author'] = '-';
}
$problem = new Problem();
$problem->setId($id);
$problem->setTitle($ini['title']);
$problem->setDescription(file_get_contents($problem_text));
$problem->setAuthor($ini['author']);
$problem->setCaseCount($ini['case_count']);
$problem->setCaseScore($ini['case_score']);
$problem->setTimeLimit($ini['time_limit']);
$problem->setMemoryLimit($ini['memory_limit']);
$problem->setSecretBefore($ini['secret_before']);
$problem->validate();
for ($t = 1; $t <= $problem->getCaseCount(); $t++) {
$input = "{$data_dir}/{$t}.in";
if (!is_file($input)) {
throw new fValidationException("Case input file {$input} is not found in {$data_dir}");
}
$output = "{$data_dir}/{$t}.out";
if (!is_file($output)) {
throw new fValidationException("Case output file {$output} is not found in {$data_dir}");
}
}
$problem->store();
}