-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
109 lines (108 loc) · 3.97 KB
/
config.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
class jsonEditor{
public function __construct()
{
$this->__comentario__ = null;
$this->ubicacion_documentos = null;
$this->servidor = null;
$this->usuario_de_bd = null;
$this->contrasena_bd = null;
$this->base_de_datos = null;
}
public static function tomarArchivo($archivo)
{
$file = @file_get_contents("core/php/data/cfg/$archivo");
$json = null;
if (!$file)
{
$json = new jsonEditor();
$jFile = json_encode($json);
file_put_contents("core/php/data/cfg/configuracion.json", $jFile);
} else {
$file = json_decode($file);
$json = new jsonEditor();
$json->ubicacion_documentos = $file->{'ubicacion_documentos'};
$json->servidor = $file->{'servidor'};
$json->usuario_de_bd = $file->{'usuario_de_bd'};
$json->contrasena_bd = $file->{'contrasena_bd'};
$json->base_de_datos = $file->{'base_de_datos'};
$json->__comentario__ = $file->{'__comentario__'};
}
return $json;
}
public static function guardar($jFile)
{
$jFile = json_encode($jFile);
file_put_contents("core/php/data/cfg/configuracion.json", $jFile);
}
}
$usr = "admin_tecno"; $pass = "admin_tecno";
$config = jsonEditor::tomarArchivo("configuracion.json");
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
if ($usr === $_POST['usr'] && $pass === $_POST['cont'])
{
$config->__comentario__ = (isset($_POST['nota']))
? $_POST['nota'] : null;
$config->ubicacion_documentos = (isset($_POST['direccion']))
? $_POST['direccion'] : null;
$config->servidor = (isset($_POST['servidor']))
? $_POST['servidor'] : null;
$config->usuario_de_bd = (isset($_POST['usuario']))
? $_POST['usuario'] : null;
$config->contrasena_bd =
(isset($_POST['pass']) && $_POST['pass'] != "")
? $_POST['pass'] : $config->contrasena_bd;
$config->base_de_datos = (isset($_POST['bd']))
? $_POST['bd'] : null;
jsonEditor::guardar($config);
echo "Acción realizada";
} else {
echo "No tiene permisos para realizar esta acción";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Configuracion del Repositorio</title>
</head>
<body>
<h2>Configuracion del repositorio</h2>
<form method="post">
<h4>Credencial</h4>
<small>Usuario y contraseña para realizar cambios</small><br>
<label for="usr">UserID</label>
<input type="text" name="usr" id="usr">
<label for="cont">Pw</label>
<input type="password" name="cont" id="cont">
<br><br>
<label for="direccion">Ruta de Guardado de libros</label><br>
<input type="text" name="direccion" id="direccion"
style="width:18em;"
value="<?php echo $config->ubicacion_documentos; ?>">
<br>
<label for="host">Servidor</label><br>
<input type="text" name="servidor" id="servidor"
value="<?php echo $config->servidor; ?>">
<br>
<label for="usuario">Usuario de la BD</label><br>
<input type="text" name="usuario" id="usuario"
value="<?php echo $config->usuario_de_bd; ?>">
<br>
<label for="pass">Contraseña de la BD</label><br>
<input type="password" name="pass" id="pass">
<br>
<label for="bd">Nombre de la BD</label><br>
<input type="text" name="bd" id="bd"
value="<?php echo $config->base_de_datos; ?>">
<br>
<label for="detalle">Notas</label><br>
<input type="text" name="nota" id="nota" style="width: 35em;"
value="<?php echo $config->__comentario__; ?>">
<br>
<input type="submit" value="Guardar">
</form>
</body>
</html>