Project

General

Profile

Download (7.13 KB) Statistics
| Branch: | Tag: | Revision:
1 a7f908db Scott Ullrich
#!/usr/local/bin/php
2
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 a7f908db Scott Ullrich
/*
5
    pkg.php
6 b49448ac Scott Ullrich
    Copyright (C) 2004, 2005 Scott Ullrich
7 a7f908db Scott Ullrich
    All rights reserved.
8
9
    Redistribution and use in source and binary forms, with or without
10
    modification, are permitted provided that the following conditions are met:
11
12
    1. Redistributions of source code must retain the above copyright notice,
13
       this list of conditions and the following disclaimer.
14
15
    2. Redistributions in binary form must reproduce the above copyright
16
       notice, this list of conditions and the following disclaimer in the
17
       documentation and/or other materials provided with the distribution.
18
19
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
    POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31 e4bf1c19 Colin Smith
require_once("guiconfig.inc");
32
require_once("pkg-utils.inc");
33 a7f908db Scott Ullrich
34
function gentitle_pkg($pgname) {
35 e3c4b6b7 Scott Ullrich
	global $config;
36
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
37 a7f908db Scott Ullrich
}
38
39
$xml = $_GET['xml'];
40
41
if($xml == "") {
42 e307a809 Colin Smith
            print_info_box_np("ERROR: No package defined.");
43 a7f908db Scott Ullrich
            die;
44
} else {
45 19a11678 Colin Smith
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
46 a7f908db Scott Ullrich
}
47
48 3eaeb703 Scott Ullrich
if($pkg['donotsave'] <> "") {
49
	header("Location:  pkg_edit.php?xml=" . $xml);
50
}
51
52 a28c8b59 Scott Ullrich
$package_name = $pkg['menu'][0]['name'];
53
$section      = $pkg['menu'][0]['section'];
54 a7f908db Scott Ullrich
$config_path  = $pkg['configpath'];
55 e3c4b6b7 Scott Ullrich
$title        = $section . ": " . $package_name;
56
57 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
58 e3c4b6b7 Scott Ullrich
59
if ($_GET['act'] == "del") {
60 0bb335f4 Scott Ullrich
	    // loop through our fieldnames and automatically setup the fieldnames
61
	    // in the environment.  ie: a fieldname of username with a value of
62
            // testuser would automatically eval $username = "testuser";
63 e3c4b6b7 Scott Ullrich
	    foreach ($evaledvar as $ip) {
64 e55a0a25 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'])
65
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
66 ce696feb Colin Smith
				  ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
67 e55a0a25 Scott Ullrich
			  }
68 e3c4b6b7 Scott Ullrich
	    }
69
70 ce696feb Colin Smith
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
71 e3c4b6b7 Scott Ullrich
72
	    if ($a_pkg[$_GET['id']]) {
73
		if($pkg['custom_delete_php_command'] <> "") {
74 5cd30ac3 Scott Ullrich
		    if($pkg['custom_php_command_before_form'] <> "")
75
			eval($pkg['custom_php_command_before_form']);
76 e3c4b6b7 Scott Ullrich
		    eval($pkg['custom_delete_php_command']);
77
		}
78
79
		unset($a_pkg[$_GET['id']]);
80
		write_config();
81
		header("Location:  pkg.php?xml=" . $xml);
82
		exit;
83
	    }
84
}
85
86 ce696feb Colin Smith
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
87 a7f908db Scott Ullrich
88 194b4e0a Colin Smith
if($pkg['custom_php_global_functions'] <> "")
89
        eval($pkg['custom_php_global_functions']);
90
91 f9a91638 Scott Ullrich
if($pkg['custom_php_command_before_form'] <> "")
92 194b4e0a Colin Smith
	eval($pkg['custom_php_command_before_form']);
93 f9a91638 Scott Ullrich
94 83ddedcd Scott Ullrich
$pgtitle = $title;
95
include("head.inc");
96
97 a7f908db Scott Ullrich
?>
98
99
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
100 859329c8 Scott Ullrich
<?php
101
include("fbegin.inc");
102
?>
103 96d9f5c9 Bill Marquette
<p class="pgtitle"><?=$pgtitle?></p>
104 64fba011 Scott Ullrich
<form action="pkg.php" method="post">
105 8596e0a4 Scott Ullrich
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
106 a7f908db Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
107 79f6fe7b Colin Smith
<table width="100%" border="0" cellpadding="0" cellspacing="0">
108 7c061036 Scott Ullrich
<?php
109
if ($pkg['tabs'] <> "") {
110 79f6fe7b Colin Smith
    echo '<tr><td>';
111
    $tab_array = array();
112 7c061036 Scott Ullrich
    foreach($pkg['tabs']['tab'] as $tab) {
113 79f6fe7b Colin Smith
        if(isset($tab['active'])) {
114
                $active = true;
115
        } else {
116
                $active = false;
117
        }
118
        $urltmp = "";
119
        if($tab['url'] <> "") $urltmp = $tab['url'];
120
        if($tab['xml'] <> "") $urltmp = "pkg_edit.php?xml=" . $tab['xml'];
121
122
        $myurl = getenv("HTTP_HOST");
123
        // eval url so that above $myurl item can be processed if need be.
124
        $url = str_replace('$myurl', $myurl, $urltmp);
125
        $tab_array[] = array(
126
                                $tab['text'],
127
                                $active,
128
                                $url
129
                        );
130 7c061036 Scott Ullrich
    }
131 79f6fe7b Colin Smith
    display_top_tabs($tab_array);
132
    echo '</td></tr>';
133 7c061036 Scott Ullrich
}
134
?>
135 79f6fe7b Colin Smith
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
136 a7f908db Scott Ullrich
  <tr>
137
    <td class="tabcont">
138
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
139
                <tr>
140
                <?php
141
                $cols = 0;
142 2d512c84 Scott Ullrich
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
143
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
144
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
145
			$cols++;
146
		    }
147
		}
148 a7f908db Scott Ullrich
                echo "</tr>";
149 2cf712c4 Scott Ullrich
		    $i=0;
150
		    if($evaledvar)
151
		    foreach ($evaledvar as $ip) {
152
			echo "<tr valign=\"top\">\n";
153 7c061036 Scott Ullrich
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
154 549912e3 Scott Ullrich
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
155
				   ?>
156 5f9c0e68 Bill Marquette
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
157 549912e3 Scott Ullrich
						<?php
158 ce696feb Colin Smith
						    $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
159 549912e3 Scott Ullrich
						    if($column['type'] == "checkbox") {
160
							if($fieldname == "") {
161
							    echo "No";
162
							} else {
163
							    echo "Yes";
164
							}
165
						    } else {
166 009c7905 Colin Smith
							echo $column['prefix'] . $fieldname . $column['suffix'];
167 549912e3 Scott Ullrich
						    }
168
						?>
169
					</td>
170
				   <?php
171
				}
172 2cf712c4 Scott Ullrich
			?>
173
			<td valign="middle" class="list" nowrap>
174 a339c26a Bill Marquette
                          <table border="0" cellspacing="0" cellpadding="1">
175
                            <tr>
176 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>
177
			      <td valign="middle"><a href="pkg.php?xml=<?=$xml?>&act=del&id=<?=$i;?>" onclick="return confirm('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>
178 a339c26a Bill Marquette
                            </tr>
179
                          </table>
180 2cf712c4 Scott Ullrich
			</td>
181
			<?php
182
			echo "</tr>\n";
183
			$i++;
184
		    }
185
		?>
186 a339c26a Bill Marquette
               <tr>
187
                 <td colspan="<?=$cols?>"></td>
188
                 <td>
189
                    <table border="0" cellspacing="0" cellpadding="1">
190
                      <tr>
191 677c0869 Erik Kristensen
                        <td valign="middle"><a href="pkg_edit.php?xml=<?=$xml?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
192 a339c26a Bill Marquette
                     </tr>
193
                   </table>
194
                 </td>
195
               </tr>
196 a7f908db Scott Ullrich
        </table>
197
    </td>
198
  </tr>
199
</table>
200 79f6fe7b Colin Smith
</div></tr></td></table>
201 3d335c4d Scott Ullrich
202 a7f908db Scott Ullrich
</form>
203
<?php include("fend.inc"); ?>
204 323d040b Scott Ullrich
205
<script type="text/javascript">
206
NiftyCheck();
207
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
208
</script>
209
210 a7f908db Scott Ullrich
</body>
211
</html>