Project

General

Profile

Download (7.26 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    pkg.php
5
    Copyright (C) 2004, 2005 Scott Ullrich
6
    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
require_once("guiconfig.inc");
31
require_once("pkg-utils.inc");
32

    
33
function gettext($text) {
34
	return $text;
35
}
36

    
37
function gentitle_pkg($pgname) {
38
	global $config;
39
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
40
}
41

    
42
$xml = $_GET['xml'];
43

    
44
if($xml == "") {
45
            print_info_box_np(gettext("ERROR: No package defined."));
46
            die;
47
} else {
48
            $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
49
}
50

    
51
if($pkg['donotsave'] <> "") {
52
	header("Location:  pkg_edit.php?xml=" . $xml);
53
}
54

    
55
if ($pkg['include_file'] != "") {
56
	require_once($pkg['include_file']);
57
}
58

    
59
$package_name = $pkg['menu'][0]['name'];
60
$section      = $pkg['menu'][0]['section'];
61
$config_path  = $pkg['configpath'];
62
$title	      = $pkg['title'];
63

    
64
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
65

    
66
if ($_GET['act'] == "del") {
67
	    // 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
	    foreach ($evaledvar as $ip) {
71
			if($pkg['adddeleteeditpagefields']['columnitem'])
72
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
73
				  ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
74
			  }
75
	    }
76

    
77
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
78

    
79
	    if ($a_pkg[$_GET['id']]) {
80
		if($pkg['custom_delete_php_command'] <> "") {
81
		    if($pkg['custom_php_command_before_form'] <> "")
82
			eval($pkg['custom_php_command_before_form']);
83
		    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
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
94

    
95
if($pkg['custom_php_global_functions'] <> "")
96
        eval($pkg['custom_php_global_functions']);
97

    
98
if($pkg['custom_php_command_before_form'] <> "")
99
	eval($pkg['custom_php_command_before_form']);
100

    
101
$pgtitle = $title;
102
include("head.inc");
103

    
104
?>
105

    
106
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
107
<?php
108
include("fbegin.inc");
109
?>
110
<p class="pgtitle"><?=$pgtitle?></p>
111
<form action="pkg.php" method="post">
112
<? if($_GET['savemsg'] <> "") $savemsg = $_GET['savemsg']; ?>
113
<?php if ($savemsg) print_info_box($savemsg); ?>
114
<table width="100%" border="0" cellpadding="0" cellspacing="0">
115
<?php
116
if ($pkg['tabs'] <> "") {
117
    echo '<tr><td>';
118
    $tab_array = array();
119
    foreach($pkg['tabs']['tab'] as $tab) {
120
        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
    }
138
    display_top_tabs($tab_array);
139
    echo '</td></tr>';
140
}
141
?>
142
<tr><td><div id="mainarea"><table width="100%" border="0" cellpadding="0" cellspacing="0">
143
  <tr>
144
    <td class="tabcont">
145
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
146
                <tr>
147
                <?php
148
                $cols = 0;
149
		if($pkg['adddeleteeditpagefields']['columnitem'] <> "") {
150
		    foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
151
			echo "<td class=\"listhdrr\">" . $column['fielddescr'] . "</td>";
152
			$cols++;
153
		    }
154
		}
155
                echo "</tr>";
156
		    $i=0;
157
		    if($evaledvar)
158
		    foreach ($evaledvar as $ip) {
159
			echo "<tr valign=\"top\">\n";
160
			if($pkg['adddeleteeditpagefields']['columnitem'] <> "")
161
				foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
162
				   ?>
163
					<td class="listlr" ondblclick="document.location='pkg_edit.php?xml=<?=$xml?>&act=edit&id=<?=$i;?>';">
164
						<?php
165
						    $fieldname = $ip[xml_safe_fieldname($column['fieldname'])];
166
						    if($column['type'] == "checkbox") {
167
							if($fieldname == "") {
168
							    echo gettext("No");
169
							} else {
170
							    echo gettext("Yes");
171
							}
172
						    } else {
173
							echo $column['prefix'] . $fieldname . $column['suffix'];
174
						    }
175
						?>
176
					</td>
177
				   <?php
178
				}
179
			?>
180
			<td valign="middle" class="list" nowrap>
181
                          <table border="0" cellspacing="0" cellpadding="1">
182
                            <tr>
183
                              <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
			      <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
                            </tr>
186
                          </table>
187
			</td>
188
			<?php
189
			echo "</tr>\n";
190
			$i++;
191
		    }
192
		?>
193
               <tr>
194
                 <td colspan="<?=$cols?>"></td>
195
                 <td>
196
                    <table border="0" cellspacing="0" cellpadding="1">
197
                      <tr>
198
                        <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
                     </tr>
200
                   </table>
201
                 </td>
202
               </tr>
203
        </table>
204
    </td>
205
  </tr>
206
</table>
207
</div></tr></td></table>
208

    
209
</form>
210
<?php include("fend.inc"); ?>
211

    
212
<script type="text/javascript">
213
NiftyCheck();
214
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
215
</script>
216

    
217
</body>
218
</html>
(82-82/162)