Skip to content

Commit

Permalink
release: 0.4.2 Pristobrycon
Browse files Browse the repository at this point in the history
release: 0.4.2 Pristobrycon
  • Loading branch information
ZsgsDesign authored Dec 15, 2020
2 parents e12848a + 03ffa29 commit 97e1ec3
Show file tree
Hide file tree
Showing 172 changed files with 1,279 additions and 6,672 deletions.
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ APP_KEY=base64:6KvSj1hj/VJCNXnHECU16OVbcHk7h20O5TbsyOz5WuA= #App Key
APP_DEBUG=true #Debug Mode
APP_URL=http://ojsystem.com/
APP_LOCALE=en
APP_BACKUP=false #Enable Scheduling Backup
APP_LOGO="" #URL for site logo
APP_DESC=

BABEL_MIRROR=https://acm.njupt.edu.cn/babel #The mirror of babel marketplace

Expand Down Expand Up @@ -54,3 +57,7 @@ GITHUB_SECRET=
GITHUB_CALLBACK_URL=

MOSS_USERID=

CONTACT_EMAIL="[email protected]"
CONTACT_QQ="Group 668108264"
CONTACT_TEL=
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ For installation options and troubleshooting tips, see [installation](https://nj

[HTML Purifier](https://github.com/mewebstudio/Purifier)

See `composer.json` or [Dependency List](https://app.fossa.com/attribution/263d9a48-87a3-4043-b6f4-42e0f5755351) for more info.
See `composer.json` or [Dependency List](https://app.fossa.com/reports/86025be3-63af-41dc-9948-7b1738a89649) for more info.

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FZsgsDesign%2FCodeMaster.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FZsgsDesign%2FCodeMaster?ref=badge_large)
115 changes: 95 additions & 20 deletions app/Admin/Controllers/ProblemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Admin\Controllers;

use App\Models\Eloquent\Problem as EloquentProblemModel;
use App\Models\Eloquent\OJ as EloquentOJModel;
use App\Http\Controllers\Controller;
use App\Admin\Forms\ImportPOEM;
use Encore\Admin\Controllers\HasResourceActions;
Expand Down Expand Up @@ -120,7 +121,7 @@ protected function grid()
$filter->like('title');
});

$grid->disableCreateButton();
// $grid->disableCreateButton();

return $grid;
}
Expand Down Expand Up @@ -152,29 +153,61 @@ protected function form($create = false)
$form->text('title')->rules('required');
$form->text('time_limit')->rules('required');
$form->text('memory_limit')->rules('required');
$form->textarea('description')->rows(5);
$form->textarea('input','Sample Input')->rows(3);
$form->textarea('output','Sample Output')->rows(3);
$form->textarea('note')->rows(2);
$form->display('OJ');
$form->display('update_date');
$form->text('tot_score')->rules('required');
$form->simplemde('description')->rules('required');
$form->simplemde('input');
$form->simplemde('output');
$form->simplemde('note');
$form->hasMany('problemSamples', 'samples', function (Form\NestedForm $form) {
$form->textarea('sample_input', 'sample input')->rows(3);
$form->textarea('sample_output', 'sample output')->rows(3);
$form->textarea('sample_note', 'sample note')->rows(3);
});
/* $form->table('samples', function ($table) {
$table->textarea('sample_input', 'sample input');
$table->textarea('sample_output', 'sample output');
$table->textarea('sample_note', 'sample note');
}); */
$ojs_temp = EloquentOJModel::select('oid', 'name')->get()->all();
$ojs = [];
foreach($ojs_temp as $v){
$ojs[$v->oid] = $v->name;
}
$form->select('oj', 'OJ')->options($ojs)->default(1)->rules('required');
$form->select('Hide')->options([
1 => 'yes',
0 => 'no'
])->default(0)->rules('required');
/* $form->display('update_date'); */
/* $form->text('tot_score')->rules('required');
$form->select('partial', 'Partial Score')->options([
0 => "No",
1 => "Yes"
])->rules('required');
$form->select('markdown', 'Markdown Support')->options([
0 => "No",
1 => "Yes"
])->rules('required');
$form->file('test_case');
])->rules('required'); */
$form->hidden('markdown');
$form->hidden('input_type');
$form->hidden('output_type');
$form->hidden('solved_count');
$form->hidden('difficulty');
$form->hidden('file');

$form->radio('spj', 'Use SPJ')
->options([
0 => 'NO',
1 => 'YES',
])->when(0, function (Form $form) {
})->when(1, function (Form $form) {
// $form->clang('spj_src','SPJ Source Code')->rules('required');
// Admin::script("CodeMirror.fromTextArea(document.getElementById(\"spj_src\"), {'mode':'text/x-csrc','lineNumbers':true,'matchBrackets':true});");
})->rules('required');
$form->clang('spj_src','SPJ Source Code');
$form->file('test_case')->rules('required');
$form->ignore(['test_case']);
});
if($create){
/* if($create){
$form->tools(function (Form\Tools $tools) {
$tools->add('<a href="/'.config('admin.route.prefix').'/problems/import" class="btn btn-sm btn-success" style="margin-right:1rem"><i class="MDI file-powerpoint-box"></i>&nbsp;&nbsp;Import from file</a>');
$tools->append('<a href="/'.config('admin.route.prefix').'/problems/import" class="btn btn-sm btn-success" style="margin-right:1rem"><i class="MDI file-powerpoint-box"></i>&nbsp;&nbsp;Import from file</a>');
});
}
} */
$form->saving(function (Form $form){
$err = function ($msg) {
$error = new MessageBag([
Expand Down Expand Up @@ -203,11 +236,47 @@ protected function form($create = false)
if($zip->open($path) !== true) {
$err('You must upload a zip file without encrypt and can open successfully.');
};
$info_content = [];
if(($zip->getFromName('info')) === false){
$err('The zip files must include a file named info including info of test cases, and the format can see ZsgsDesign/NOJ wiki.');
$info_content = [
'spj' => false,
'test_cases' => []
];
$files = [];
for ($i = 0; $i < $zip->numFiles; $i++) {
$filename = $zip->getNameIndex($i);
$files[] = $filename;
}
$files_in = array_filter($files, function ($filename) {
return strpos('.in', $filename) != -1;
});
sort($files_in);
$testcase_index = 1;
foreach($files_in as $filename_in){
$filename = basename($filename_in, '.in');
$filename_out = $filename.'.out';
if(($zip->getFromName($filename_out)) === false) {
continue;
}
$test_case_in = $zip->getFromName($filename_in);
$test_case_out = $zip->getFromName($filename_out);
$info_content['test_cases']["{$testcase_index}"] = [
'input_size' => strlen($test_case_in),
'input_name' => $filename_in,
'output_size' => strlen($test_case_out),
'output_name' => $filename_out,
'stripped_output_md5' => md5(utf8_encode(rtrim($test_case_out)))
];
$testcase_index += 1;
}
$zip->addFromString('info', json_encode($info_content));
$zip->close();
//$err('The zip files must include a file named info including info of test cases, and the format can see ZsgsDesign/NOJ wiki.');
}else{
$info_content = json_decode($zip->getFromName('info'),true);
};
$test_case_info = json_decode($zip->getFromName('info'),true);
$test_cases = $test_case_info['test_cases'];
$zip->open($path);
$test_cases = $info_content['test_cases'];
foreach($test_cases as $index => $case) {
if(!isset($case['input_name']) || !isset($case['output_name'])) {
$err("Test case index {$index}: configuration missing input/output files name.");
Expand All @@ -234,6 +303,12 @@ protected function form($create = false)
$zip->extractTo(base_path().'/storage/test_case/'.$pcode.'/');

}
$form->markdown = true;
$form->input_type = 'standard input';
$form->output_type = 'standard output';
$form->solved_count = 0;
$form->difficulty = -1;
$form->file = 0;
});
return $form;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

Admin::css('/static/css/wemd-color-scheme.css');
Admin::css('/static/fonts/MDI-WXSS/MDI.css');
Admin::css('/static/fonts/mdi-wxss/MDI.css');
Admin::favicon('/favicon.png');
Admin::css('/static/library/highlightjs/styles/atom-one-light.css');
Admin::js('/static/library/highlightjs/highlight.pack.min.js');
Expand Down
2 changes: 1 addition & 1 deletion app/Admin/menu.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"order": 27,
"title": "Solutions",
"icon": "MDI comment-check-outline",
"uri": "\/solutions",
"uri": "\/solutions?audit=0&per_page=30",
"permission": null,
"created_at": "2019-09-03 13:13:13",
"updated_at": "2019-09-03 13:13:13",
Expand Down
1 change: 1 addition & 0 deletions app/Babel/Extension/noj/Monitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function check()
$serverList=$judgerModel->fetchServer($this->oid);
foreach ($serverList as $server) {
if ($server["available"]==0) {
$this->updateStatus($server["jsid"], -2);
continue;
}

Expand Down
17 changes: 15 additions & 2 deletions app/Babel/Extension/noj/Submitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function submitJudger($submitURL, $data)
'max_cpu_time'=>$data['max_cpu_time'],
'max_memory'=>$data['max_memory'],
'spj_version'=>$data['spj_version'],
'spj_config'=>$data['spj_config']
'spj_config'=>$data['spj_config'],
'spj_compile_config'=>$data['spj_compile_config'],
'spj_src'=>$data['spj_src']
]);
}
public function submit()
Expand Down Expand Up @@ -74,11 +76,22 @@ public function submit()
"test_case_id" => $probBasic["pcode"],
"token" => $bestServer["token"],
"spj_version" => null,
"spj_config" => null
"spj_config" => null,
"spj_compile_config" => null,
"spj_src" => null
];
if($probBasic["spj"] && $probBasic["spj_version"]){
$submit_data["spj_version"]=$probBasic["spj_version"];
$submit_data["spj_config"]=$probBasic["spj_lang"];
$submit_data["spj_compile_config"]=[
"src_name" => "spj-{spj_version}.c",
"exe_name" => "spj-{spj_version}",
"max_cpu_time" => 3000,
"max_real_time" => 5000,
"max_memory" => 1073741824,
"compile_command" => "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 {src_path} -lm -o {exe_path}"
]; // fixed at C99, future linked with spj_lang
$submit_data["spj_src"]=$probBasic["spj_src"];
}
$temp=$this->submitJudger($submitURL, $submit_data);
if (isset($this->post_data["contest"])) {
Expand Down
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ protected function schedule(Schedule $schedule)
}
})->everyMinute()->description("Update Judge Server Status");

if (!env("APP_DEBUG")) {
if (!config("app.debug") && config("app.backup")) {
$schedule->command('backup:run')->weekly()->description("BackUp Site");
}

if (!env("APP_DEBUG")) {
if (!config("app.debug") && config("app.backup")) {
$schedule->command('backup:run --only-db')->dailyAt('00:30')->description("BackUp DataBase");
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Ajax/ContestAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public function update(Request $request)
'cid' => 'required|integer',
'name' => 'required|max:255',
'problems' => 'required|max:2550',
'status_visibility' => 'required|integer',
'begin_time' => 'required|date',
'end_time' => 'required|date|after:begin_time',
'description' => 'string'
Expand Down Expand Up @@ -133,7 +134,7 @@ public function update(Request $request)
];
}
}
$allow_update = ['name','description','begin_time','end_time'];
$allow_update = ['name','description','begin_time','end_time', 'status_visibility'];

foreach($all_data as $key => $value){
if(!in_array($key,$allow_update)){
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Ajax/GroupManageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function arrangeContest(Request $request)
'name' => 'required|max:255',
'problems' => 'required|max:2550',
'begin_time' => 'required|date',
'status_visibility' => 'required|integer',
'end_time' => 'required|date|after:begin_time',
'gid' => 'required|integer',
'description' => 'string',
Expand Down Expand Up @@ -70,6 +71,7 @@ public function arrangeContest(Request $request)
"assign_uid"=>Auth::user()->id,
"name"=>$all_data["name"],
"description"=>$all_data["description"],
"status_visibility"=>$all_data["status_visibility"],
"begin_time"=>$all_data["begin_time"],
"end_time"=>$all_data["end_time"],
"practice"=>$all_data["practice"] ?? 0,
Expand Down
6 changes: 2 additions & 4 deletions app/Http/Controllers/Tool/Ajax/PastebinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Tool\Ajax;

use App\Models\Tool\PastebinModel;
use App\Models\Eloquent\Tool\Pastebin;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
Expand Down Expand Up @@ -39,9 +39,7 @@ public function generate(Request $request)
$all_data=$request->all();
$all_data["uid"]=Auth::user()->id;

$pastebinModel=new PastebinModel();

$ret=$pastebinModel->generate($all_data);
$ret=Pastebin::generate($all_data);

if (is_null($ret)) {
return ResponseModel::err(1001);
Expand Down
12 changes: 9 additions & 3 deletions app/Http/Controllers/Tool/PastebinController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Tool;

use App\Models\Tool\PastebinModel;
use App\Models\Eloquent\Tool\Pastebin;
use App\Http\Controllers\Controller;
use Auth;

Expand All @@ -15,8 +15,14 @@ class PastebinController extends Controller
*/
public function view($code)
{
$pastebinModel=new PastebinModel();
$detail=$pastebinModel->detail($code);
$detail=Pastebin::where('code', $code)->first();
if(is_null($detail)){
return abort('404');
}
if(!is_null($detail->expired_at) && strtotime($detail->expired_at) < strtotime(date("y-m-d h:i:s"))){
Pastebin::where('code', $code)->delete();
return abort('404');
}
return view('tool.pastebin.view', [
'page_title' => "Detail",
'site_title' => "PasteBin",
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Babel/ExtensionModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Models\Babel;

use Illuminate\Database\Eloquent\Model;
use App\Models\Eloquent\OJModel;
use App\Models\Eloquent\OJ;
use PharIo\Version\Version;
use Throwable;

Expand Down Expand Up @@ -54,7 +54,7 @@ public static function localList()
$temp["details"]["official"]=0;
}

$installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
$installedConfig=OJ::where(["ocode"=>$extension["code"]])->first();
if (is_null($installedConfig)){
$temp["status"]=1;
} else {
Expand Down Expand Up @@ -105,7 +105,7 @@ public static function list()
$remoteVersion=new Version($extension["version"]);
$temp["updatable"]=$remoteVersion->isGreaterThan($downloadedVersion);

$installedConfig=OJModel::where(["ocode"=>$extension["code"]])->first();
$installedConfig=OJ::where(["ocode"=>$extension["code"]])->first();
if (is_null($installedConfig)){
$temp["status"]=1;
} else {
Expand Down
4 changes: 2 additions & 2 deletions app/Models/ContestModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -1500,8 +1500,8 @@ public function arrangeContest($gid, $config, $problems)
"registration_due"=>null, //todo
"registant_type"=>0, //todo
"froze_length"=>0, //todo
"status_visibility"=>2, //todo
"created_up"=>date("Y-m-d H:i:s"),
"status_visibility"=>$config["status_visibility"],
"created_at"=>date("Y-m-d H:i:s"),
"crawled" => isset($config['vcid'])?$config['crawled'] : null,
"audit_status"=>$config["public"] ? 0 : 1
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class OJModel extends Model
class OJ extends Model
{
protected $table='oj';
protected $primaryKey='oid';
Expand Down
Loading

0 comments on commit 97e1ec3

Please sign in to comment.