redray
2008-11-19 7d78160cfc5041e43a330708c264b0de32f08098
commit | author | age
b5a2f8 1 <?php
T 2 /*
3 Copyright (c) 2005, Till Brehm, projektfarm Gmbh
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
8
9     * Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright notice,
12       this list of conditions and the following disclaimer in the documentation
13       and/or other materials provided with the distribution.
14     * Neither the name of ISPConfig nor the names of its contributors
15       may be used to endorse or promote products derived from this software without
16       specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 require_once('../../lib/config.inc.php');
31 require_once('../../lib/app.inc.php');
32
33 if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required.");
34
910093 35 //* Check permissions for module
T 36 $app->auth->check_module_permissions('designer');
b5a2f8 37
T 38 // Lade Template
39 $app->uses('tpl');
40 $app->tpl->newTemplate("form.tpl.htm");
41 $app->tpl->setInclude('content_tpl','templates/module_nav_edit.htm');
42
43 // ID importieren
44 $module_name = $_REQUEST["module_name"];
45 $nav_id = $_REQUEST["nav_id"];
46 $dir = $_REQUEST["dir"];
47
48 if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars.");
49 if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$nav_id)) die("nav_id contains invalid chars.");
50
51 if(empty($module_name)) die("module is empty.");
52
53 if($nav_id != '') {
54
55     $filename = "../".$module_name."/lib/module.conf.php";
56         
57     if(!@is_file($filename)) die("File not found: $filename");
58     include_once($filename);
59     
60     if($dir == 'up' and $nav_id > 0) {
61         $tmp = $module["nav"][$nav_id - 1];
62         $module["nav"][$nav_id - 1] = $module["nav"][$nav_id];
63         $module["nav"][$nav_id] = $tmp;
64     }
65     
66     if($dir == 'down' and $nav_id < count($module["nav"]) -1) {
67         $tmp = $module["nav"][$nav_id + 1];
68         $module["nav"][$nav_id + 1] = $module["nav"][$nav_id];
69         $module["nav"][$nav_id] = $tmp;
70     }
71     
72     $m = "<?php\r\n".'$module = '.var_export($module,true)."\r\n?>";
73             
74     // writing module.conf
75     if (!$handle = fopen($filename, 'w')) { 
76         print "Cannot open file ($filename)"; 
77         exit; 
78     } 
79     if (!fwrite($handle, $m)) { 
80         print "Cannot write to file ($filename)"; 
81         exit; 
82     } 
83    
84     fclose($handle);
85     
86     
87     // zu Liste springen
cf71a4 88        echo "HEADER_REDIRECT:designer/module_show.php?id=$module_name";
b5a2f8 89     exit;
T 90 }
91 ?>