mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 05:48:41 +00:00
revert(web): 07f7782ae4
This commit is contained in:
parent
faae5a49c5
commit
2d04d7b486
@ -724,26 +724,6 @@ LOCK TABLES `user_system_msg` WRITE;
|
||||
/*!40000 ALTER TABLE `user_system_msg` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
create table pastes
|
||||
(
|
||||
`index` varchar(20) null,
|
||||
creator varchar(20) null,
|
||||
created_at datetime null,
|
||||
content text null
|
||||
);
|
||||
|
||||
create unique index pastes_index_uindex
|
||||
on pastes (`index`);
|
||||
|
||||
create index pastes_created_at_index
|
||||
on pastes (created_at);
|
||||
|
||||
alter table pastes
|
||||
add constraint pastes_pk
|
||||
primary key (`index`);
|
||||
|
||||
|
||||
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
|
2
web/.gitignore
vendored
2
web/.gitignore
vendored
@ -7,7 +7,5 @@ composer.lock
|
||||
app/.config.php
|
||||
app/storage/tmp/*
|
||||
app/storage/submission/*
|
||||
app/storage/paste/*
|
||||
!app/storage/tmp/.gitkeep
|
||||
!app/storage/submission/.gitkeep
|
||||
!app/storage/paste/.gitkeep
|
||||
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
requirePHPLib('form');
|
||||
requirePHPLib('judger');
|
||||
|
||||
if (!Auth::check()) {
|
||||
becomeMsgPage(UOJLocale::get('need login'));
|
||||
}
|
||||
|
||||
|
||||
function handleUpload($zip_file_name, $content, $tot_size) {
|
||||
global $myUser;
|
||||
$esc_content = DB::escape(json_encode($content));
|
||||
$index = uojRandString(20);
|
||||
$esc_index = DB::escape($index);
|
||||
while (DB::selectFirst("select count(*) as count from pastes where `index` = '$esc_index'")['count'] != "0") {
|
||||
$index = uojRandString(20);
|
||||
$esc_index = DB::escape($index);
|
||||
}
|
||||
DB::query("insert into pastes (`index`, `creator`, `content`, `created_at`) values ('$esc_index', '${myUser['username']}', '$esc_content', '".date('Y-m-d H:i:s')."')");
|
||||
redirectTo("/pastes/".$index);
|
||||
}
|
||||
|
||||
$paste_form = newSubmissionForm('paste',
|
||||
[
|
||||
[
|
||||
'type' => "source code",
|
||||
"name" => "paste",
|
||||
"file_name" => "paste.code"
|
||||
]
|
||||
],
|
||||
'uojRandAvaiablePasteFileName',
|
||||
'handleUpload');
|
||||
$paste_form->succ_href = '/paste';
|
||||
$paste_form->runAtServer();
|
||||
echoUOJPageHeader("Paste!");
|
||||
$paste_form->printHTML();
|
||||
echoUOJPageFooter();
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!Auth::check()) {
|
||||
becomeMsgPage(UOJLocale::get('need login'));
|
||||
}
|
||||
|
||||
$paste_id = $_GET['rand_str_id'];
|
||||
|
||||
$paste = DB::selectFirst("select * from pastes where `index` = '".DB::escape($paste_id)."'");
|
||||
if (!$paste) {
|
||||
become404Page();
|
||||
}
|
||||
$REQUIRE_LIB['shjs'] = "";
|
||||
echoUOJPageHeader("Paste!");
|
||||
echoPasteContent($paste);
|
||||
echoUOJPageFooter();
|
@ -377,22 +377,6 @@
|
||||
};
|
||||
$judger_deleter->runAtServer();
|
||||
|
||||
$paste_deleter = new UOJForm('paste_deleter');
|
||||
$paste_deleter->addInput('paste_deleter_name', 'text', 'Paste ID', '',
|
||||
function ($x, &$vdata) {
|
||||
if (DB::selectCount("select count(*) from pastes where `index`='$x'")==0) {
|
||||
return '不合法';
|
||||
}
|
||||
$vdata['name'] = $x;
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$paste_deleter->handle = function(&$vdata) {
|
||||
DB::delete("delete from pastes where `index` = '${vdata['name']}'");
|
||||
};
|
||||
$paste_deleter->runAtServer();
|
||||
|
||||
$judgerlist_cols = array('judger_name', 'password');
|
||||
$judgerlist_config = array();
|
||||
$judgerlist_header_row = <<<EOD
|
||||
@ -469,10 +453,6 @@ EOD;
|
||||
'judger' => array(
|
||||
'name' => '评测机管理',
|
||||
'url' => '/super-manage/judger'
|
||||
),
|
||||
'paste' => array(
|
||||
'name' => '剪贴板管理',
|
||||
'url' => '/super-manage/paste'
|
||||
)
|
||||
);
|
||||
|
||||
@ -588,11 +568,6 @@ EOD;
|
||||
</div>
|
||||
<h3>评测机列表</h3>
|
||||
<?php echoLongTable($judgerlist_cols, 'judger_info', "1=1", '', $judgerlist_header_row, $judgerlist_print_row, $judgerlist_config) ?>
|
||||
<?php elseif ($cur_tab === 'paste'): ?>
|
||||
<div>
|
||||
<h4>Paste管理</h4>
|
||||
<?php echoPastesList() ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -411,93 +411,6 @@ function echoSubmissionsList($cond, $tail, $config, $user) {
|
||||
}, $table_config);
|
||||
}
|
||||
|
||||
function echoPastesList() {
|
||||
$header_row = '<tr>';
|
||||
$col_names = ['`index`','creator','created_at'];
|
||||
$header_row .= '<th>ID</th>';
|
||||
$header_row .= '<th>'.UOJLocale::get("problems::submitter").'</th>';
|
||||
$header_row .= '<th>'.UOJLocale::get('problems::submit time').'</th>';
|
||||
$header_row .= '<th> 操作 </th>';
|
||||
$header_row .= '</tr>';
|
||||
$table_name = 'pastes';
|
||||
echoLongTable($col_names, $table_name, "1", 'order by created_at desc', $header_row,
|
||||
function($paste) {
|
||||
$user = getUserLink($paste['creator']);
|
||||
$token = HTML::hiddenToken();
|
||||
echo <<<HTML
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/pastes/{$paste['index']}">{$paste['index']}</a>
|
||||
</td>
|
||||
<td>
|
||||
{$user}
|
||||
</td>
|
||||
<td>
|
||||
{$paste['created_at']}
|
||||
</td>
|
||||
<td>
|
||||
<form action="/super-manage/paste" method="post" class="form-horizontal">
|
||||
{$token}
|
||||
<input type="text" class="form-control" name="paste_deleter_name" id="input-paste_deleter_name" value="{$paste['index']}" style="display: none;">
|
||||
<button type="submit" name="submit-paste_deleter" value="paste_deleter" class="btn btn-sm btn-danger" style="margin: 0">删除</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
HTML;
|
||||
}, []);
|
||||
}
|
||||
|
||||
function echoPasteContent($paste) {
|
||||
$zip_file = new ZipArchive();
|
||||
$submission_content = json_decode($paste['content'], true);
|
||||
$zip_file->open(UOJContext::storagePath().$submission_content['file_name']);
|
||||
|
||||
$config = array();
|
||||
foreach ($submission_content['config'] as $config_key => $config_val) {
|
||||
$config[$config_val[0]] = $config_val[1];
|
||||
}
|
||||
|
||||
$file_content = $zip_file->getFromName("paste.code");
|
||||
$file_content = uojTextEncode($file_content, array('allow_CR' => true, 'html_escape' => true));
|
||||
$file_language = htmlspecialchars($config["paste_language"]);
|
||||
$footer_text = UOJLocale::get('problems::source code').', '.UOJLocale::get('problems::language').': '.$file_language;
|
||||
$footer_text .= ", ".UOJLocale::get("problems::submitter") . <<<HTML
|
||||
: <a href="/user/profile/${paste['creator']}">${paste['creator']}</a>
|
||||
HTML;
|
||||
$footer_text .= ", ".UOJLocale::get("problems::submit time").": ".$paste['created_at'];
|
||||
|
||||
switch ($file_language) {
|
||||
case 'C++':
|
||||
case 'C++11':
|
||||
$sh_class = 'sh_cpp';
|
||||
break;
|
||||
case 'Python2':
|
||||
case 'Python3':
|
||||
$sh_class = 'sh_python';
|
||||
break;
|
||||
case 'C':
|
||||
$sh_class = 'sh_c';
|
||||
break;
|
||||
case 'Pascal':
|
||||
$sh_class = 'sh_pascal';
|
||||
break;
|
||||
default:
|
||||
$sh_class = '';
|
||||
break;
|
||||
}
|
||||
echo '<div class="card border-info mb-3">';
|
||||
echo '<div class="card-header bg-info">';
|
||||
echo '<h4 class="card-title">Paste!</h4>';
|
||||
echo '</div>';
|
||||
echo '<div class="card-body">';
|
||||
echo '<pre><code class="'.$sh_class.'">'.$file_content."\n".'</code></pre>';
|
||||
echo '</div>';
|
||||
echo '<div class="card-footer">'.$footer_text.'</div>';
|
||||
echo '</div>';
|
||||
|
||||
$zip_file->close();
|
||||
}
|
||||
|
||||
function echoSubmissionContent($submission, $requirement) {
|
||||
$zip_file = new ZipArchive();
|
||||
$submission_content = json_decode($submission['content'], true);
|
||||
|
@ -31,7 +31,3 @@ function uojRandAvaiableSubmissionFileName() {
|
||||
}
|
||||
return uojRandAvaiableFileName("/submission/$num/");
|
||||
}
|
||||
|
||||
function uojRandAvaiablePasteFileName() {
|
||||
return uojRandAvaiableFileName('/paste/');
|
||||
}
|
||||
|
@ -68,9 +68,6 @@ Route::group([
|
||||
|
||||
Route::any('/click-zan', '/click_zan.php');
|
||||
|
||||
Route::any('/paste', '/paste_post.php');
|
||||
Route::any('/pastes/{rand_str_id}', '/paste_view.php');
|
||||
|
||||
Route::any('/map_visualizer', '/map_visualizer.php');
|
||||
}
|
||||
);
|
||||
|
@ -18,7 +18,6 @@
|
||||
工具
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="<?= HTML::url('/paste') ?>"><span class="glyphicon glyphicon-paste"></span> 代码分享 </a>
|
||||
<a class="dropdown-item" href="<?= HTML::url('/map_visualizer') ?>"><span class="glyphicon glyphicon-retweet"></span> 图可视化 </a>
|
||||
</div>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user