Project

General

Profile

Download (7.6 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
$iflist = get_configured_interface_with_descr(false, true);
99
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
100

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

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

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

    
110
?>
111

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

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

    
216
</form>
217
<?php include("fend.inc"); ?>
218

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

    
224
</body>
225
</html>
(112-112/216)