Project

General

Profile

Download (7.3 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 b5aebbf5 Scott Ullrich
$xml = htmlspecialchars($_GET['xml']);
43 a7f908db Scott Ullrich
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 8060d89a Scott Ullrich
			unset($a_pkg[$_GET['id']]);
81
			write_config();
82
			if($pkg['custom_delete_php_command'] <> "") {
83
			    if($pkg['custom_php_command_before_form'] <> "")
84
					eval($pkg['custom_php_command_before_form']);
85
		    		eval($pkg['custom_delete_php_command']);
86
			}
87
			header("Location:  pkg.php?xml=" . $xml);
88
			exit;
89 e3c4b6b7 Scott Ullrich
	    }
90
}
91
92 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
93 a7f908db Scott Ullrich
94 194b4e0a Colin Smith
if($pkg['custom_php_global_functions'] <> "")
95
        eval($pkg['custom_php_global_functions']);
96
97 f9a91638 Scott Ullrich
if($pkg['custom_php_command_before_form'] <> "")
98 194b4e0a Colin Smith
	eval($pkg['custom_php_command_before_form']);
99 f9a91638 Scott Ullrich
100 83ddedcd Scott Ullrich
$pgtitle = $title;
101
include("head.inc");
102
103 a7f908db Scott Ullrich
?>
104
105
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
106 859329c8 Scott Ullrich
<?php
107
include("fbegin.inc");
108
?>
109 96d9f5c9 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
110 64fba011 Scott Ullrich
<form action="pkg.php" method="post">
111 b5aebbf5 Scott Ullrich
<? if($_GET['savemsg'] <> "") $savemsg = htmlspecialchars($_GET['savemsg']); ?>
112 a7f908db Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
113 79f6fe7b Colin Smith
<table width="100%" border="0" cellpadding="0" cellspacing="0">
114 7c061036 Scott Ullrich
<?php
115
if ($pkg['tabs'] <> "") {
116 79f6fe7b Colin Smith
    echo '<tr><td>';
117
    $tab_array = array();
118 7c061036 Scott Ullrich
    foreach($pkg['tabs']['tab'] as $tab) {
119 79f6fe7b Colin Smith
        if(isset($tab['active'])) {
120
                $active = true;
121
        } else {
122
                $active = false;
123
        }
124
        $urltmp = "";
125
        if($tab['url'] <> "") $urltmp = $tab['url'];
126
        if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
127
128
        $myurl = getenv("HTTP_HOST");
129
        // eval url so that above $myurl item can be processed if need be.
130
        $url = str_replace('$myurl', $myurl, $urltmp);
131
        $tab_array[] = array(
132
                                $tab['text'],
133
                                $active,
134
                                $url
135
                        );
136 7c061036 Scott Ullrich
    }
137 79f6fe7b Colin Smith
    display_top_tabs($tab_array);
138
    echo '</td></tr>';
139 7c061036 Scott Ullrich
}
140
?>
141 79f6fe7b Colin Smith
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
142 a7f908db Scott Ullrich
  <tr>
143
    <td class="tabcont">
144
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
145
                <tr>
146
                <?php
147
                $cols = 0;
148 2d512c84 Scott Ullrich
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
149
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
150
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
151
			$cols++;
152
		    }
153
		}
154 a7f908db Scott Ullrich
                echo "</tr>";
155 2cf712c4 Scott Ullrich
		    $i=0;
156
		    if($evaledvar)
157
		    foreach ($evaledvar as $ip) {
158
			echo "<tr valign=\"top\">\n";
159 7c061036 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
160 549912e3 Scott Ullrich
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
161
				   ?>
162 5f9c0e68 Bill Marquette
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
163 549912e3 Scott Ullrich
						<?php
164 ce696feb Colin Smith
						    $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
165 549912e3 Scott Ullrich
						    if($column['type'] == "checkbox") {
166
							if($fieldname == "") {
167 b91540da Scott Ullrich
							    echo gettext("No");
168 549912e3 Scott Ullrich
							} else {
169 b91540da Scott Ullrich
							    echo gettext("Yes");
170 549912e3 Scott Ullrich
							}
171
						    } else {
172 009c7905 Colin Smith
							echo $column['prefix'] . $fieldname . $column['suffix'];
173 549912e3 Scott Ullrich
						    }
174
						?>
175
					</td>
176
				   <?php
177
				}
178 2cf712c4 Scott Ullrich
			?>
179
			<td valign="middle" class="list" nowrap>
180 a339c26a Bill Marquette
                          <table border="0" cellspacing="0" cellpadding="1">
181
                            <tr>
182 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>
183 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>
184 a339c26a Bill Marquette
                            </tr>
185
                          </table>
186 2cf712c4 Scott Ullrich
			</td>
187
			<?php
188
			echo "</tr>\n";
189
			$i++;
190
		    }
191
		?>
192 a339c26a Bill Marquette
               <tr>
193
                 <td colspan="<?=$cols?>"></td>
194
                 <td>
195
                    <table border="0" cellspacing="0" cellpadding="1">
196
                      <tr>
197 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>
198 a339c26a Bill Marquette
                     </tr>
199
                   </table>
200
                 </td>
201
               </tr>
202 a7f908db Scott Ullrich
        </table>
203
    </td>
204
  </tr>
205
</table>
206 79f6fe7b Colin Smith
</div></tr></td></table>
207 3d335c4d Scott Ullrich
208 a7f908db Scott Ullrich
</form>
209
<?php include("fend.inc"); ?>
210 323d040b Scott Ullrich
211
<script type="text/javascript">
212
NiftyCheck();
213
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
214
</script>
215
216 a7f908db Scott Ullrich
</body>
217
</html>