Project

General

Profile

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