Project

General

Profile

Download (7.23 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 gentitle_pkg($pgname) {
34
	global $config;
35
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
36
}
37

    
38
$xml = htmlspecialchars($_GET['xml']);
39

    
40
if($xml == "") {
41
            print_info_box_np(gettext("ERROR: No package defined."));
42
            die;
43
} else {
44
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
45
}
46

    
47
if($pkg['donotsave'] <> "") {
48
	header("Location:  pkg_edit.php?xml=" . $xml);
49
}
50

    
51
if ($pkg['include_file'] != "") {
52
	require_once($pkg['include_file']);
53
}
54

    
55
$package_name = $pkg['menu'][0]['name'];
56
$section      = $pkg['menu'][0]['section'];
57
$config_path  = $pkg['configpath'];
58
$title	      = $pkg['title'];
59

    
60
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
61

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

    
73
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
74

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

    
88
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
89

    
90
if($pkg['custom_php_global_functions'] <> "")
91
        eval($pkg['custom_php_global_functions']);
92

    
93
if($pkg['custom_php_command_before_form'] <> "")
94
	eval($pkg['custom_php_command_before_form']);
95

    
96
$pgtitle = array($title);
97
include("head.inc");
98

    
99
?>
100

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

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

    
203
</form>
204
<?php include("fend.inc"); ?>
205

    
206
<script type="text/javascript">
207
NiftyCheck();
208
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
209
</script>
210

    
211
</body>
212
</html>
(94-94/193)