Project

General

Profile

Download (7.3 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 = htmlspecialchars($_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
			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
	    }
90
}
91

    
92
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
93

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

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

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

    
103
?>
104

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

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

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

    
216
</body>
217
</html>
(88-88/173)