Project

General

Profile

Download (7.27 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
6
    All rights reserved.
7

    
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

    
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

    
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

    
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
require_once("guiconfig.inc");
31
require_once("pkg-utils.inc");
32

    
33
function gettext($text) {
34
	return $text;
35
}
36

    
37
function gentitle_pkg($pgname) {
38
	global $config;
39
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
40
}
41

    
42
$xml = htmlspecialchars($_GET['xml']);
43

    
44
if($xml == "") {
45
            print_info_box_np(gettext("ERROR: No package defined."));
46
            die;
47
} else {
48
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
49
}
50

    
51
if($pkg['donotsave'] <> "") {
52
	header("Location:  pkg_edit.php?xml=" . $xml);
53
}
54

    
55
if ($pkg['include_file'] != "") {
56
	require_once($pkg['include_file']);
57
}
58

    
59
$package_name = $pkg['menu'][0]['name'];
60
$section      = $pkg['menu'][0]['section'];
61
$config_path  = $pkg['configpath'];
62
$title	      = $pkg['title'];
63

    
64
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
65

    
66
if ($_GET['act'] == "del") {
67
	    // loop through our fieldnames and automatically setup the fieldnames
68
	    // in the environment.  ie: a fieldname of username with a value of
69
            // testuser would automatically eval $username = "testuser";
70
	    foreach ($evaledvar as $ip) {
71
			if($pkg['adddeleteeditpagefields']['columnitem'])
72
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
73
				  ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
74
			  }
75
	    }
76

    
77
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
78

    
79
	    if ($a_pkg[$_GET['id']]) {
80
			unset($a_pkg[$_GET['id']]);
81
			write_config();
82
			if($pkg['custom_delete_php_command'] <> "") {
83
			    if($pkg['custom_php_command_before_form'] <> "")
84
					eval($pkg['custom_php_command_before_form']);
85
		    		eval($pkg['custom_delete_php_command']);
86
			}
87
			header("Location:  pkg.php?xml=" . $xml);
88
			exit;
89
	    }
90
}
91

    
92
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
93

    
94
if($pkg['custom_php_global_functions'] <> "")
95
        eval($pkg['custom_php_global_functions']);
96

    
97
if($pkg['custom_php_command_before_form'] <> "")
98
	eval($pkg['custom_php_command_before_form']);
99

    
100
$pgtitle = array($title);
101
include("head.inc");
102

    
103
?>
104

    
105
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106
<?php
107
include("fbegin.inc");
108
?>
109
<form action="pkg.php" method="post">
110
<? if($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
111
<?php if ($savemsg) print_info_box($savemsg); ?>
112
<table width="100%" border="0" cellpadding="0" cellspacing="0">
113
<?php
114
if ($pkg['tabs'] <> "") {
115
    echo '<tr><td>';
116
    $tab_array = array();
117
    foreach($pkg['tabs']['tab'] as $tab) {
118
        if(isset($tab['active'])) {
119
                $active = true;
120
        } else {
121
                $active = false;
122
        }
123
        $urltmp = "";
124
        if($tab['url'] <> "") $urltmp = $tab['url'];
125
        if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
126

    
127
        $myurl = getenv("HTTP_HOST");
128
        // eval url so that above $myurl item can be processed if need be.
129
        $url = str_replace('$myurl', $myurl, $urltmp);
130
        $tab_array[] = array(
131
                                $tab['text'],
132
                                $active,
133
                                $url
134
                        );
135
    }
136
    display_top_tabs($tab_array);
137
    echo '</td></tr>';
138
}
139
?>
140
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
141
  <tr>
142
    <td class="tabcont">
143
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
144
                <tr>
145
                <?php
146
                $cols = 0;
147
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
148
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
149
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
150
			$cols++;
151
		    }
152
		}
153
                echo "</tr>";
154
		    $i=0;
155
		    if($evaledvar)
156
		    foreach ($evaledvar as $ip) {
157
			echo "<tr valign=\"top\">\n";
158
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
159
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
160
				   ?>
161
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
162
						<?php
163
						    $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
164
						    if($column['type'] == "checkbox") {
165
							if($fieldname == "") {
166
							    echo gettext("No");
167
							} else {
168
							    echo gettext("Yes");
169
							}
170
						    } else {
171
							echo $column['prefix'] . $fieldname . $column['suffix'];
172
						    }
173
						?>
174
					</td>
175
				   <?php
176
				}
177
			?>
178
			<td valign="middle" class="list" nowrap>
179
                          <table border="0" cellspacing="0" cellpadding="1">
180
                            <tr>
181
                              <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
182
			      <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this item?");?>')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
183
                            </tr>
184
                          </table>
185
			</td>
186
			<?php
187
			echo "</tr>\n";
188
			$i++;
189
		    }
190
		?>
191
               <tr>
192
                 <td colspan="<?=$cols?>"></td>
193
                 <td>
194
                    <table border="0" cellspacing="0" cellpadding="1">
195
                      <tr>
196
                        <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>&id=<?=$i?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
197
                     </tr>
198
                   </table>
199
                 </td>
200
               </tr>
201
        </table>
202
    </td>
203
  </tr>
204
</table>
205
</div></tr></td></table>
206

    
207
</form>
208
<?php include("fend.inc"); ?>
209

    
210
<script type="text/javascript">
211
NiftyCheck();
212
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
213
</script>
214

    
215
</body>
216
</html>
(93-93/189)