-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupload.php
47 lines (47 loc) · 1.48 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
include("init.php");
include("config.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
if (((date_timestamp_get($begintime) + $duringTime*60 - time() > 0)) || ($duringTime == 0)) {
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
//echo $extension;
if ( !$_FILES["file"]["name"] )
{$message = "LỖI: Chưa chọn tệp.\\n";}
else if ( ! in_array(strtolower($extension), ["pas","cpp","py"]) )
{$message = "LỖI: Chọn sai loại tệp: [".$_FILES["file"]["name"]."].\\n Chỉ được *.CPP hoặc *.PAS thôi!\\n";}
else if ($_FILES["file"]["size"] > 10*1024*1024)
{$message = "LỖI: Tệp có dung lượng quá lớn.\\n";}
else if ($_FILES["file"]["error"] > 0)
{$message = "LỖI: Không rõ.";}
else
{
$dir = $uploadDir;
$ip=explode(".",$_SERVER['REMOTE_ADDR']);
//move_uploaded_file($_FILES["file"]["tmp_name"],$dir ."/". $user['id']."[".$user['username']."][".$temp[0]."].".$extension);
move_uploaded_file($_FILES["file"]["tmp_name"],$dir ."/". $ip[3]."[".$user['username']."][".$temp[0]."].".$extension);
$message = "Nộp bài thành công";
}
?>
<script>
alert("<?php echo $message; ?>");
window.history.back();
</script>
<?php
} else {
?>
<script>
alert("Đã hết thời gian nộp bài! \n Nộp bài không thành công!");
window.history.back();
</script>
<?php
}
?>
</body>
</html>