Project

General

Profile

Download (7.39 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
##|+PRIV
31
##|*IDENT=page-package-settings
32
##|*NAME=Package: Settings page
33
##|*DESCR=Allow access to the 'Package: Settings' page.
34
##|*MATCH=pkg.php*
35
##|-PRIV
36

    
37

    
38
require_once("guiconfig.inc");
39
require_once("pkg-utils.inc");
40

    
41
function gentitle_pkg($pgname) {
42
	global $config;
43
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
44
}
45

    
46
$xml = htmlspecialchars($_GET['xml']);
47

    
48
if($xml == "") {
49
            print_info_box_np(gettext("ERROR: No package defined."));
50
            die;
51
} else {
52
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
53
}
54

    
55
if($pkg['donotsave'] <> "") {
56
	header("Location:  pkg_edit.php?xml=" . $xml);
57
}
58

    
59
if ($pkg['include_file'] != "") {
60
	require_once($pkg['include_file']);
61
}
62

    
63
$package_name = $pkg['menu'][0]['name'];
64
$section      = $pkg['menu'][0]['section'];
65
$config_path  = $pkg['configpath'];
66
$title	      = $pkg['title'];
67

    
68
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
69

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

    
81
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
82

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

    
96
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
97

    
98
if($pkg['custom_php_global_functions'] <> "")
99
        eval($pkg['custom_php_global_functions']);
100

    
101
if($pkg['custom_php_command_before_form'] <> "")
102
	eval($pkg['custom_php_command_before_form']);
103

    
104
$pgtitle = array($title);
105
include("head.inc");
106

    
107
?>
108

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

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

    
211
</form>
212
<?php include("fend.inc"); ?>
213

    
214
<script type="text/javascript">
215
NiftyCheck();
216
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
217
</script>
218

    
219
</body>
220
</html>
(106-106/206)