ryxeo-glpi-git / front / link.send.php @ b67d8923
Historique | Voir | Annoter | Télécharger (4,24 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: link.send.php 7875 2009-01-23 15:16:47Z moyo $
|
||
4 | -------------------------------------------------------------------------
|
||
5 | GLPI - Gestionnaire Libre de Parc Informatique
|
||
6 | Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
||
7 | |||
8 | http://indepnet.net/ http://glpi-project.org
|
||
9 | -------------------------------------------------------------------------
|
||
10 | |||
11 | LICENSE
|
||
12 | |||
13 | This file is part of GLPI.
|
||
14 | |||
15 | GLPI is free software; you can redistribute it and/or modify
|
||
16 | it under the terms of the GNU General Public License as published by
|
||
17 | the Free Software Foundation; either version 2 of the License, or
|
||
18 | (at your option) any later version.
|
||
19 | |||
20 | GLPI is distributed in the hope that it will be useful,
|
||
21 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
23 | GNU General Public License for more details.
|
||
24 | |||
25 | You should have received a copy of the GNU General Public License
|
||
26 | along with GLPI; if not, write to the Free Software
|
||
27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
28 | --------------------------------------------------------------------------
|
||
29 | */
|
||
30 | |||
31 | |||
32 | $NEEDED_ITEMS=array("link","knowbase","computer","printer","networking","peripheral","monitor","software","infocom","phone","cartridge","consumable","contract","contact","enterprise"); |
||
33 | |||
34 | define('GLPI_ROOT', '..'); |
||
35 | include (GLPI_ROOT . "/inc/includes.php"); |
||
36 | |||
37 | checkRight("link","r"); |
||
38 | |||
39 | if (isset($_GET["lID"])){ |
||
40 | $query="SELECT glpi_links.ID as ID, glpi_links.link as link,glpi_links.data as data from glpi_links WHERE glpi_links.ID='".$_GET["lID"]."'"; |
||
41 | |||
42 | $result=$DB->query($query); |
||
43 | if ($DB->numrows($result)==1){ |
||
44 | $file=$DB->result($result,0,"data"); |
||
45 | $link=$DB->result($result,0,"link"); |
||
46 | |||
47 | $ci=new CommonItem; |
||
48 | |||
49 | $ci->getFromDB($_GET["type"],$_GET["ID"]); |
||
50 | |||
51 | // Manage Filename
|
||
52 | if (ereg("\[NAME\]",$link)){ |
||
53 | $link=ereg_replace("\[NAME\]",$ci->getName(),$link); |
||
54 | } |
||
55 | |||
56 | if (ereg("\[ID\]",$link)){ |
||
57 | $link=ereg_replace("\[ID\]",$_GET["ID"],$link); |
||
58 | } |
||
59 | |||
60 | |||
61 | // Manage File Content
|
||
62 | |||
63 | if (ereg("\[NAME\]",$file)){ |
||
64 | $file=ereg_replace("\[NAME\]",$ci->getName(),$file); |
||
65 | } |
||
66 | |||
67 | if (ereg("\[ID\]",$file)){ |
||
68 | $file=ereg_replace("\[ID\]",$_GET["ID"],$file); |
||
69 | } |
||
70 | |||
71 | if (ereg("\[SERIAL\]",$file)){ |
||
72 | if (isset($ci->obj->fields["serial"])) |
||
73 | $file=ereg_replace("\[SERIAL\]",$ci->obj->fields["serial"],$file); |
||
74 | } |
||
75 | if (ereg("\[OTHERSERIAL\]",$file)){ |
||
76 | if (isset($ci->obj->fields["otherserial"])) |
||
77 | $file=ereg_replace("\[OTHERSERIAL\]",$ci->obj->fields["otherserial"],$file); |
||
78 | } |
||
79 | |||
80 | |||
81 | if (ereg("\[LOCATIONID\]",$file)){ |
||
82 | if (isset($ci->obj->fields["location"])) |
||
83 | $file=ereg_replace("\[LOCATIONID\]",$ci->obj->fields["location"],$file); |
||
84 | } |
||
85 | if (ereg("\[LOCATION\]",$file)){ |
||
86 | if (isset($ci->obj->fields["location"])) |
||
87 | $file=ereg_replace("\[LOCATION\]",getDropdownName("glpi_dropdown_locations",$ci->obj->fields["location"]),$file); |
||
88 | } |
||
89 | if (ereg("\[NETWORK\]",$file)){ |
||
90 | if (isset($ci->obj->fields["network"])) |
||
91 | $file=ereg_replace("\[NETWORK\]",getDropdownName("glpi_dropdown_network",$ci->obj->fields["network"]),$file); |
||
92 | } |
||
93 | if (ereg("\[DOMAIN\]",$file)){ |
||
94 | if (isset($ci->obj->fields["domain"])) |
||
95 | $file=ereg_replace("\[DOMAIN\]",getDropdownName("glpi_dropdown_domain",$ci->obj->fields["domain"]),$file); |
||
96 | } |
||
97 | $ipmac=array(); |
||
98 | $i=0; |
||
99 | if (ereg("\[IP\]",$file)||ereg("\[MAC\]",$file)){ |
||
100 | $query2 = "SELECT ifaddr,ifmac FROM glpi_networking_ports WHERE (on_device = '".$_GET["ID"]."' AND device_type = '".$_GET["type"]."') ORDER BY logical_number"; |
||
101 | $result2=$DB->query($query2); |
||
102 | if ($DB->numrows($result2)>0){ |
||
103 | $data2=$DB->fetch_array($result2); |
||
104 | $ipmac[$i]['ifaddr']=$data2["ifaddr"]; |
||
105 | $ipmac[$i]['ifmac']=$data2["ifmac"]; |
||
106 | } |
||
107 | } |
||
108 | |||
109 | if (ereg("\[IP\]",$file)||ereg("\[MAC\]",$file)){ |
||
110 | |||
111 | if (count($ipmac)>0){ |
||
112 | foreach ($ipmac as $key => $val){ |
||
113 | $file=ereg_replace("\[IP\]",$val['ifaddr'],$file); |
||
114 | $file=ereg_replace("\[MAC\]",$val['ifmac'],$file); |
||
115 | } |
||
116 | } |
||
117 | } |
||
118 | header("Content-disposition: filename=\"$link\""); |
||
119 | $mime="application/scriptfile"; |
||
120 | |||
121 | header("Content-type: ".$mime); |
||
122 | header('Pragma: no-cache'); |
||
123 | header('Expires: 0'); |
||
124 | |||
125 | // Pour que les \x00 ne devienne pas \0
|
||
126 | $mc=get_magic_quotes_runtime(); |
||
127 | if ($mc) @set_magic_quotes_runtime(0); |
||
128 | |||
129 | echo $file; |
||
130 | |||
131 | if ($mc) @set_magic_quotes_runtime($mc); |
||
132 | |||
133 | } |
||
134 | } |
||
135 | ?> |