-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathverSubmitted.php
90 lines (80 loc) · 1.95 KB
/
verSubmitted.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<title>Opera Omnia</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8"/>
</head>
<header>
<?php include("header.php"); ?>
</header>
<body>
<?php
session_start();
//Verification du fichier
if ($_FILES['paperSubmitted']['error'] == 0)
{
if ($_FILES['paperSubmitted']['size'] <= 10000000)
{
if (pathinfo($_FILES['paperSubmitted']['name'])['extension'] == 'pdf')
{
try
{
$db = new PDO('mysql:host=localhost;dbname=operaomnia v2;charset=utf8', 'root', '');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(Exception $e)
{
die('Error : '.$e->getMessage());
}
$numSubmitted=0;
$reponse=$db->query('SELECT * FROM submitversion');
while ($data = $reponse->fetch())
{
if($data['ID']>$numSubmitted)
{
$numSubmitted=$data['ID'];
}
}
$numSubmitted=$numSubmitted+1;
$req = $db->prepare('INSERT INTO submitversion(ID, FileTitle, paperID, Type, Language)
VALUES(:ID, :FileTitle, :paperID, :Type, :Language)');
$req->execute(array(
'ID' => $numSubmitted,
'FileTitle'=>$_POST['fileTitle'],
'paperID' => $_SESSION['paperID'],
'Type'=>$_POST['type'],
'Language' => $_POST['language'],
));
//$last_id = $db->prepare('SELECT ID FROM submits WHERE title = ?' );
//$last_id->execute(array($_POST['title']));
//$last_id = $last_id -> fetch();
move_uploaded_file($_FILES['paperSubmitted']['tmp_name'], 'submits/ver' .basename($numSubmitted) .'.pdf');
echo "<section>
<h1>Thank you for submitting a paper</h1>
<p>You can now go back <a href='operaomnia.php'>home</a>. Or whatever, you do you...</p>
</section>
<div id='space'></div>";
}
else
{
$error = 1;
}
}
else {
$error = 2;
}
}
else
{
$error = 3;
}
if (isset($error))
{
header('Location: submit.php?error='.$error);
exit();
}
?>
<?php include("footer.php"); ?>
</body>
</html>