-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolicitud.php
More file actions
108 lines (89 loc) · 2.73 KB
/
solicitud.php
File metadata and controls
108 lines (89 loc) · 2.73 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
<?php
function date2mes($n) {
switch($n)
{
case "1":
return "enero";
case "2":
return "febrero";
case "3":
return "marzo";
case "4":
return "abril";
case "5":
return "mayo";
case "6":
return "junio";
case "7":
return "julio";
case "8":
return "agosto";
case "9":
return "septiembre";
case "10":
return "octubre";
case "11":
return "noviembre";
case "12":
return "diciembre";
}
}
if (isset($_POST["nombre"]) && (strlen($_POST["nombre"]) > 0))
$nombre = $_POST["nombre"];
else
$nombre = "____(nombre completo)____";
if (isset($_POST["domicilio"]) && (strlen($_POST["domicilio"]) > 0))
$domicilio = $_POST["domicilio"];
else
$domicilio = "____(domicilio completo)____";
if (isset($_POST["tlf"]) && (strlen($_POST["tlf"]) > 0))
$tlf = $_POST["tlf"];
else
$tlf = "____(telefono)____";
if (isset($_POST["email"]) && (strlen($_POST["email"]) > 0))
$email = $_POST["email"];
else
$email = "____(email)____";
if (isset($_POST["nif"]) && (strlen($_POST["nif"]) > 0))
$nif = $_POST["nif"];
else
$nif = "____(NIF)____";
if (isset($_POST["web"]) && (strlen($_POST["web"]) > 0))
$web = $_POST["web"];
else
$web = "____(web)____";
if (isset($_POST["ciudad"]) && (strlen($_POST["ciudad"]) > 0))
$ciudad = $_POST["ciudad"];
else
$ciudad = "____(ciudad)____";
$contacto = $tlf . " / " . $email;
$diadenuncia = mktime(0, 0, 0, 3, 1, 2012);
$hoy = mktime(4, 0, 0, date("n"), date("j"), date("Y"));
$dias = floor(abs(($diadenuncia - $hoy) / (60 * 60 * 24)));
$mes = date2mes(date("n"));
$fecha_hoy = date("j") . " de " . $mes . " de " . date("Y");
$formfile = "reclama/automodelo.odt";
$tmpfname = tempnam("/tmp", "formwert");
if (!copy($formfile, $tmpfname)) {
echo "Error creando archivo temporal\n";
return;
}
$za = new ZipArchive();
$za->open($tmpfname);
$xmlcontent = $za->getFromName("content.xml");
$xmlcontent = str_replace("%NOMBRE%", $nombre, $xmlcontent);
$xmlcontent = str_replace("%DIRECCION%", $domicilio, $xmlcontent);
$xmlcontent = str_replace("%CONTACTO%", $contacto, $xmlcontent);
$xmlcontent = str_replace("%NIF%", $nif, $xmlcontent);
$xmlcontent = str_replace("%WEB%", $web, $xmlcontent);
$xmlcontent = str_replace("%DIAS%", $dias, $xmlcontent);
$xmlcontent = str_replace("%FECHAHOY%", $fecha_hoy, $xmlcontent);
$xmlcontent = str_replace("%CIUDAD%", $ciudad, $xmlcontent);
$za->deleteName("content.xml");
$za->addFromString("content.xml", $xmlcontent);
$za->close();
header('Content-disposition: attachment; filename=wertdeenlaces_modelo.odt');
header('Content-type: application/vnd.oasis.opendocument.text');
readfile($tmpfname);
unlink($tmpfname);
?>