Project

General

Profile

Download (7.41 KB) Statistics
| Branch: | Tag: | Revision:
1 a7f908db Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 a7f908db Scott Ullrich
/*
4
    pkg.php
5 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
6 a7f908db Scott Ullrich
    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 1d333258 Scott Ullrich
/*
30
	pfSense_MODULE:	pkgs
31
*/
32 a7f908db Scott Ullrich
33 6b07c15a Matthew Grooms
##|+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 e4bf1c19 Colin Smith
require_once("guiconfig.inc");
41
require_once("pkg-utils.inc");
42 a7f908db Scott Ullrich
43
function gentitle_pkg($pgname) {
44 e3c4b6b7 Scott Ullrich
	global $config;
45
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
46 a7f908db Scott Ullrich
}
47
48 d8c1a6c5 Scott Ullrich
$xml = htmlspecialchars($_GET['xml']);
49 a7f908db Scott Ullrich
50
if($xml == "") {
51 b91540da Scott Ullrich
            print_info_box_np(gettext("ERROR: No package defined."));
52 a7f908db Scott Ullrich
            die;
53
} else {
54 19a11678 Colin Smith
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
55 a7f908db Scott Ullrich
}
56
57 3eaeb703 Scott Ullrich
if($pkg['donotsave'] <> "") {
58
	header("Location:  pkg_edit.php?xml=" . $xml);
59
}
60
61 7c172009 Scott Ullrich
if ($pkg['include_file'] != "") {
62
	require_once($pkg['include_file']);
63
}
64
65 a28c8b59 Scott Ullrich
$package_name = $pkg['menu'][0]['name'];
66
$section      = $pkg['menu'][0]['section'];
67 a7f908db Scott Ullrich
$config_path  = $pkg['configpath'];
68 7c172009 Scott Ullrich
$title	      = $pkg['title'];
69 e3c4b6b7 Scott Ullrich
70 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
71 e3c4b6b7 Scott Ullrich
72
if ($_GET['act'] == "del") {
73 0bb335f4 Scott Ullrich
	    // 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 e3c4b6b7 Scott Ullrich
	    foreach ($evaledvar as $ip) {
77 e55a0a25 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'])
78
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
79 ce696feb Colin Smith
				  ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
80 e55a0a25 Scott Ullrich
			  }
81 e3c4b6b7 Scott Ullrich
	    }
82
83 ce696feb Colin Smith
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
84 e3c4b6b7 Scott Ullrich
85
	    if ($a_pkg[$_GET['id']]) {
86 8060d89a Scott Ullrich
			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 e3c4b6b7 Scott Ullrich
	    }
96
}
97
98 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
99 a7f908db Scott Ullrich
100 194b4e0a Colin Smith
if($pkg['custom_php_global_functions'] <> "")
101
        eval($pkg['custom_php_global_functions']);
102
103 f9a91638 Scott Ullrich
if($pkg['custom_php_command_before_form'] <> "")
104 194b4e0a Colin Smith
	eval($pkg['custom_php_command_before_form']);
105 f9a91638 Scott Ullrich
106 d88c6a9f Scott Ullrich
$pgtitle = array($title);
107 83ddedcd Scott Ullrich
include("head.inc");
108
109 a7f908db Scott Ullrich
?>
110
111
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
112 859329c8 Scott Ullrich
<?php
113
include("fbegin.inc");
114
?>
115 64fba011 Scott Ullrich
<form action="pkg.php" method="post">
116 d8c1a6c5 Scott Ullrich
<? if($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
117 a7f908db Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
118 79f6fe7b Colin Smith
<table width="100%" border="0" cellpadding="0" cellspacing="0">
119 7c061036 Scott Ullrich
<?php
120
if ($pkg['tabs'] <> "") {
121 79f6fe7b Colin Smith
    echo '<tr><td>';
122
    $tab_array = array();
123 7c061036 Scott Ullrich
    foreach($pkg['tabs']['tab'] as $tab) {
124 79f6fe7b Colin Smith
        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 7c061036 Scott Ullrich
    }
142 79f6fe7b Colin Smith
    display_top_tabs($tab_array);
143
    echo '</td></tr>';
144 7c061036 Scott Ullrich
}
145
?>
146 79f6fe7b Colin Smith
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
147 a7f908db Scott Ullrich
  <tr>
148
    <td class="tabcont">
149
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
150
                <tr>
151
                <?php
152
                $cols = 0;
153 2d512c84 Scott Ullrich
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
154
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
155
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
156
			$cols++;
157
		    }
158
		}
159 a7f908db Scott Ullrich
                echo "</tr>";
160 2cf712c4 Scott Ullrich
		    $i=0;
161
		    if($evaledvar)
162
		    foreach ($evaledvar as $ip) {
163
			echo "<tr valign=\"top\">\n";
164 7c061036 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
165 549912e3 Scott Ullrich
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
166
				   ?>
167 5f9c0e68 Bill Marquette
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
168 549912e3 Scott Ullrich
						<?php
169 ce696feb Colin Smith
						    $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
170 549912e3 Scott Ullrich
						    if($column['type'] == "checkbox") {
171
							if($fieldname == "") {
172 b91540da Scott Ullrich
							    echo gettext("No");
173 549912e3 Scott Ullrich
							} else {
174 b91540da Scott Ullrich
							    echo gettext("Yes");
175 549912e3 Scott Ullrich
							}
176
						    } else {
177 009c7905 Colin Smith
							echo $column['prefix'] . $fieldname . $column['suffix'];
178 549912e3 Scott Ullrich
						    }
179
						?>
180
					</td>
181
				   <?php
182
				}
183 2cf712c4 Scott Ullrich
			?>
184
			<td valign="middle" class="list" nowrap>
185 a339c26a Bill Marquette
                          <table border="0" cellspacing="0" cellpadding="1">
186
                            <tr>
187 677c0869 Erik Kristensen
                              <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 b91540da Scott Ullrich
			      <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 a339c26a Bill Marquette
                            </tr>
190
                          </table>
191 2cf712c4 Scott Ullrich
			</td>
192
			<?php
193
			echo "</tr>\n";
194
			$i++;
195
		    }
196
		?>
197 a339c26a Bill Marquette
               <tr>
198
                 <td colspan="<?=$cols?>"></td>
199
                 <td>
200
                    <table border="0" cellspacing="0" cellpadding="1">
201
                      <tr>
202 b91540da Scott Ullrich
                        <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 a339c26a Bill Marquette
                     </tr>
204
                   </table>
205
                 </td>
206
               </tr>
207 a7f908db Scott Ullrich
        </table>
208
    </td>
209
  </tr>
210
</table>
211 79f6fe7b Colin Smith
</div></tr></td></table>
212 3d335c4d Scott Ullrich
213 a7f908db Scott Ullrich
</form>
214
<?php include("fend.inc"); ?>
215 323d040b Scott Ullrich
216
<script type="text/javascript">
217
NiftyCheck();
218
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
219
</script>
220
221 a7f908db Scott Ullrich
</body>
222
</html>