Project

General

Profile

Download (7.26 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 e4bf1c19 Colin Smith
require_once("guiconfig.inc");
31
require_once("pkg-utils.inc");
32 a7f908db Scott Ullrich
33 b91540da Scott Ullrich
function gettext($text) {
34
	return $text;
35
}
36
37 a7f908db Scott Ullrich
function gentitle_pkg($pgname) {
38 e3c4b6b7 Scott Ullrich
	global $config;
39
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
40 a7f908db Scott Ullrich
}
41
42
$xml = $_GET['xml'];
43
44
if($xml == "") {
45 b91540da Scott Ullrich
            print_info_box_np(gettext("ERROR: No package defined."));
46 a7f908db Scott Ullrich
            die;
47
} else {
48 19a11678 Colin Smith
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
49 a7f908db Scott Ullrich
}
50
51 3eaeb703 Scott Ullrich
if($pkg['donotsave'] <> "") {
52
	header("Location:  pkg_edit.php?xml=" . $xml);
53
}
54
55 7c172009 Scott Ullrich
if ($pkg['include_file'] != "") {
56
	require_once($pkg['include_file']);
57
}
58
59 a28c8b59 Scott Ullrich
$package_name = $pkg['menu'][0]['name'];
60
$section      = $pkg['menu'][0]['section'];
61 a7f908db Scott Ullrich
$config_path  = $pkg['configpath'];
62 7c172009 Scott Ullrich
$title	      = $pkg['title'];
63 e3c4b6b7 Scott Ullrich
64 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
65 e3c4b6b7 Scott Ullrich
66
if ($_GET['act'] == "del") {
67 0bb335f4 Scott Ullrich
	    // loop through our fieldnames and automatically setup the fieldnames
68
	    // in the environment.  ie: a fieldname of username with a value of
69
            // testuser would automatically eval $username = "testuser";
70 e3c4b6b7 Scott Ullrich
	    foreach ($evaledvar as $ip) {
71 e55a0a25 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'])
72
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
73 ce696feb Colin Smith
				  ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
74 e55a0a25 Scott Ullrich
			  }
75 e3c4b6b7 Scott Ullrich
	    }
76
77 ce696feb Colin Smith
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
78 e3c4b6b7 Scott Ullrich
79
	    if ($a_pkg[$_GET['id']]) {
80
		if($pkg['custom_delete_php_command'] <> "") {
81 5cd30ac3 Scott Ullrich
		    if($pkg['custom_php_command_before_form'] <> "")
82
			eval($pkg['custom_php_command_before_form']);
83 e3c4b6b7 Scott Ullrich
		    eval($pkg['custom_delete_php_command']);
84
		}
85
86
		unset($a_pkg[$_GET['id']]);
87
		write_config();
88
		header("Location:  pkg.php?xml=" . $xml);
89
		exit;
90
	    }
91
}
92
93 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
94 a7f908db Scott Ullrich
95 194b4e0a Colin Smith
if($pkg['custom_php_global_functions'] <> "")
96
        eval($pkg['custom_php_global_functions']);
97
98 f9a91638 Scott Ullrich
if($pkg['custom_php_command_before_form'] <> "")
99 194b4e0a Colin Smith
	eval($pkg['custom_php_command_before_form']);
100 f9a91638 Scott Ullrich
101 83ddedcd Scott Ullrich
$pgtitle = $title;
102
include("head.inc");
103
104 a7f908db Scott Ullrich
?>
105
106
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
107 859329c8 Scott Ullrich
<?php
108
include("fbegin.inc");
109
?>
110 96d9f5c9 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
111 64fba011 Scott Ullrich
<form action="pkg.php" method="post">
112 8596e0a4 Scott Ullrich
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
113 a7f908db Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
114 79f6fe7b Colin Smith
<table width="100%" border="0" cellpadding="0" cellspacing="0">
115 7c061036 Scott Ullrich
<?php
116
if ($pkg['tabs'] <> "") {
117 79f6fe7b Colin Smith
    echo '<tr><td>';
118
    $tab_array = array();
119 7c061036 Scott Ullrich
    foreach($pkg['tabs']['tab'] as $tab) {
120 79f6fe7b Colin Smith
        if(isset($tab['active'])) {
121
                $active = true;
122
        } else {
123
                $active = false;
124
        }
125
        $urltmp = "";
126
        if($tab['url'] <> "") $urltmp = $tab['url'];
127
        if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
128
129
        $myurl = getenv("HTTP_HOST");
130
        // eval url so that above $myurl item can be processed if need be.
131
        $url = str_replace('$myurl', $myurl, $urltmp);
132
        $tab_array[] = array(
133
                                $tab['text'],
134
                                $active,
135
                                $url
136
                        );
137 7c061036 Scott Ullrich
    }
138 79f6fe7b Colin Smith
    display_top_tabs($tab_array);
139
    echo '</td></tr>';
140 7c061036 Scott Ullrich
}
141
?>
142 79f6fe7b Colin Smith
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
143 a7f908db Scott Ullrich
  <tr>
144
    <td class="tabcont">
145
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
146
                <tr>
147
                <?php
148
                $cols = 0;
149 2d512c84 Scott Ullrich
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
150
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
151
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
152
			$cols++;
153
		    }
154
		}
155 a7f908db Scott Ullrich
                echo "</tr>";
156 2cf712c4 Scott Ullrich
		    $i=0;
157
		    if($evaledvar)
158
		    foreach ($evaledvar as $ip) {
159
			echo "<tr valign=\"top\">\n";
160 7c061036 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
161 549912e3 Scott Ullrich
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
162
				   ?>
163 5f9c0e68 Bill Marquette
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
164 549912e3 Scott Ullrich
						<?php
165 ce696feb Colin Smith
						    $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
166 549912e3 Scott Ullrich
						    if($column['type'] == "checkbox") {
167
							if($fieldname == "") {
168 b91540da Scott Ullrich
							    echo gettext("No");
169 549912e3 Scott Ullrich
							} else {
170 b91540da Scott Ullrich
							    echo gettext("Yes");
171 549912e3 Scott Ullrich
							}
172
						    } else {
173 009c7905 Colin Smith
							echo $column['prefix'] . $fieldname . $column['suffix'];
174 549912e3 Scott Ullrich
						    }
175
						?>
176
					</td>
177
				   <?php
178
				}
179 2cf712c4 Scott Ullrich
			?>
180
			<td valign="middle" class="list" nowrap>
181 a339c26a Bill Marquette
                          <table border="0" cellspacing="0" cellpadding="1">
182
                            <tr>
183 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>
184 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>
185 a339c26a Bill Marquette
                            </tr>
186
                          </table>
187 2cf712c4 Scott Ullrich
			</td>
188
			<?php
189
			echo "</tr>\n";
190
			$i++;
191
		    }
192
		?>
193 a339c26a Bill Marquette
               <tr>
194
                 <td colspan="<?=$cols?>"></td>
195
                 <td>
196
                    <table border="0" cellspacing="0" cellpadding="1">
197
                      <tr>
198 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>
199 a339c26a Bill Marquette
                     </tr>
200
                   </table>
201
                 </td>
202
               </tr>
203 a7f908db Scott Ullrich
        </table>
204
    </td>
205
  </tr>
206
</table>
207 79f6fe7b Colin Smith
</div></tr></td></table>
208 3d335c4d Scott Ullrich
209 a7f908db Scott Ullrich
</form>
210
<?php include("fend.inc"); ?>
211 323d040b Scott Ullrich
212
<script type="text/javascript">
213
NiftyCheck();
214
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
215
</script>
216
217 a7f908db Scott Ullrich
</body>
218
</html>