1 <?php
2 /*
3 This code is part of GOsa (https://gosa.gonicus.de)
4 Copyright (C) 2003 Cajus Pollmeier
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20 restore_error_handler();
21 function getFAIScript ($id)
22 {
23 restore_error_handler();
24 $ldap = $_SESSION['config']->get_ldap_link();
25 $ldap->cd($_SESSION['config']->current['BASE']);
27 $sr= $ldap->cat($id);
28 $ei= ldap_first_entry($ldap->cid, $sr);
29 $tmp = ldap_get_values_len($ldap->cid, $ei,"FAIscript");
30 $tmp2 = $ldap->fetch();
32 if(in_array("FAIhookEntry",$tmp2['objectClass'])){
33 $suff = ".FAIhook";
34 }else{
35 $suff = ".FAIscript";
36 }
37 $name= $tmp2['cn'][0];
39 if(isset($tmp[0])){
40 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
41 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
42 header("Cache-Control: no-cache");
43 header("Pragma: no-cache");
44 header("Cache-Control: post-check=0, pre-check=0");
45 header("Content-type: application/octet-stream");
46 header("Content-Disposition: attachment; filename=".$name.$suff);
47 echo $tmp[0];
48 }else{
49 echo sprintf("Can't query for this item '%s'",$id);
50 }
51 }
53 /* Basic setup, remove eventually registered sessions */
54 @require_once ("../include/php_setup.inc");
55 @require_once ("functions.inc");
56 error_reporting (E_ALL);
57 session_start ();
59 /* Logged in? Simple security check */
60 if (!isset($_SESSION['ui'])){
61 gosa_log ("Error: getFAIScript.php called without session");
62 header ("Location: ../index.php");
63 exit;
64 }
65 $ui= $_SESSION["ui"];
66 $config= $_SESSION['config'];
68 /* Check ACL's */
69 $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL);
70 $acl= get_module_permission($acl, "all", $config->current['BASE']);
71 if (chkacl($acl, "all") != ""){
72 header ("Location: ../index.php");
73 exit;
74 }
75 $dir = search_config($config->data,"environment", "KIOSKPATH");
76 getFAIScript(base64_decode($_GET['id']));
78 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
79 ?>