-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_problem.php
More file actions
executable file
·122 lines (77 loc) · 2.69 KB
/
insert_problem.php
File metadata and controls
executable file
·122 lines (77 loc) · 2.69 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
include "config.php";
?>
<?php
$html = file_get_contents('header.html');
echo $html;
?>
<h2>Agregar Problema</h2>
<p>
<?php
$con = connection_query();
$usuario = $_POST["usuario"];
$pass = sha1($_POST["pass"]);
$result = mysqli_query($con, "SELECT usuario, password FROM admon WHERE usuario = '$usuario' AND password = '$pass'");
$entro = false;
while($row = mysqli_fetch_array($result)) {
$entro = true;
}
if(!$entro){
die('El usuario o la contraseña son incorrectos ');
}
mysqli_close($con);
$con = connection_update();
$nombre = $_POST["nombre"];
$desc = $_POST["descripcion"];
$fecha = $_POST["fecha"];
$lenguaje = $_POST["lenguaje"];
$archivo = $nombre . ".dis";
$in = $nombre . ".in";
$sql = "INSERT INTO problema (nombre, descripcion, codigo, fecha_maxima, lenguaje)
VALUES ('$nombre', '$desc','$archivo', '$fecha', '$lenguaje')";
$retval = mysql_query( $sql );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
//Subir el codigo del problema
$target_path = "problemas/";
//$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$target_path = $target_path . $archivo;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*Converts to unix format*/
$file = file_get_contents("problemas/code.dis");
$file = str_replace("\r", "", $file);
file_put_contents("problemas/code.dis", $file);
//UPLOAD THE IN FILE
$target_path = "problemas/";
//$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$target_path = $target_path . $in;
if(move_uploaded_file($_FILES['filein']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['filein']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*Converts to unix format*/
$file = file_get_contents("problemas/code.dis");
$file = str_replace("\r", "", $file);
file_put_contents("problemas/code.dis", $file);
echo "Problema insertado con exito" ;
// some code
mysql_close($con);
?>
</p>
</div>
</div>
</div>
<div class="cleaner"> </div>
</div>
</div>
<div align=center>Juez creado por: Daniel Serrano, Lenguaje creado por Alfredo Santamaria y Daniel Serrano</div></body>
</html>