Project

General

Profile

Download (7.41 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
	pfSense_MODULE:	pkgs
31
*/
32

    
33
##|+PRIV
34
##|*IDENT=page-package-settings
35
##|*NAME=Package: Settings page
36
##|*DESCR=Allow access to the 'Package: Settings' page.
37
##|*MATCH=pkg.php*
38
##|-PRIV
39

    
40
require_once("guiconfig.inc");
41
require_once("pkg-utils.inc");
42

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

    
48
$xml = htmlspecialchars($_GET['xml']);
49

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

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

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

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

    
70
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
71

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

    
83
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
84

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

    
98
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
99

    
100
if($pkg['custom_php_global_functions'] <> "")
101
        eval($pkg['custom_php_global_functions']);
102

    
103
if($pkg['custom_php_command_before_form'] <> "")
104
	eval($pkg['custom_php_command_before_form']);
105

    
106
$pgtitle = array($title);
107
include("head.inc");
108

    
109
?>
110

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

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

    
213
</form>
214
<?php include("fend.inc"); ?>
215

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

    
221
</body>
222
</html>
(111-111/217)