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();
25 $config = session::get('config');
27 $ldap = $config->get_ldap_link();
28 $ldap->cd($config->current['BASE']);
30 $sr= $ldap->cat($id, array("FAItemplateFile", "FAIscript", "cn", "objectClass"));
31 $ei= ldap_first_entry($ldap->cid, $sr);
32 if(isset($_GET['is_template'])){
33 $tmp = ldap_get_values_len($ldap->cid, $ei,"FAItemplateFile");
34 }else{
35 $tmp = ldap_get_values_len($ldap->cid, $ei,"FAIscript");
36 }
37 $tmp2 = $ldap->fetch();
39 $name= $tmp2['cn'][0];
40 if(in_array("FAIhookEntry",$tmp2['objectClass'])){
41 $name.= ".FAIhook";
42 }elseif(in_array("FAIscriptEntry",$tmp2['objectClass'])){
43 $name .= ".FAIscript";
44 }elseif(isset($_GET['is_template'])){
45 if(preg_match("/\//",$name)){
46 $name = preg_replace("/^.*\//","",$name);
47 }
48 }
50 if(isset($tmp[0])){
51 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
52 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
53 header("Cache-Control: no-cache");
54 header("Pragma: no-cache");
55 header("Content-transfer-encoding: binary\n");
56 header("Cache-Control: post-check=0, pre-check=0");
57 header("Content-type: application/octet-stream");
58 header("Content-Disposition: attachment; filename=".$name);
59 echo $tmp[0];
60 }else{
61 echo sprintf("Can't query for this item '%s'",$id);
62 }
63 }
65 /* Basic setup, remove eventually registered sessions */
66 @require_once ("../include/php_setup.inc");
67 @require_once ("functions.inc");
68 error_reporting (E_ALL | E_STRICT);
69 session::start();
71 /* Logged in? Simple security check */
72 if (!session::is_set('ui')){
73 new log("security","fai","",array(),"Error: getFAIScript.php called without session") ;
74 header ("Location: index.php");
75 exit;
76 }
77 $ui= session::get("ui");
78 $config= session::get('config');
80 /* Check ACL's */
81 #FIXME Use more specific acl categories instead of all/all
82 $ui = get_userinfo();
83 $acl = $ui->get_permissions(base64_decode($_GET['id']),"all/all");
84 if(!preg_match("/r/",$acl)){
85 header ("Location: index.php");
86 exit;
87 }
88 $dir= $config->search('environment', 'kioskpath', array('main','tabs'));
89 getFAIScript(base64_decode($_GET['id']));
91 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
92 ?>