Project

General

Profile

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

    
34
function gentitle_pkg($pgname) {
35
	global $config;
36
	return $config['system']['hostname'] . "." . $config['system']['domain'] . " - " . $pgname;
37
}
38

    
39
$xml = $_GET['xml'];
40

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

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

    
52
$package_name = $pkg['menu'][0]['name'];
53
$section      = $pkg['menu'][0]['section'];
54
$config_path  = $pkg['configpath'];
55
$title        = $section . ": " . $package_name;
56

    
57
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
58

    
59
if ($_GET['act'] == "del") {
60
	    // 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
	    foreach ($evaledvar as $ip) {
64
			if($pkg['adddeleteeditpagefields']['columnitem'])
65
			  foreach ($pkg['adddeleteeditpagefields']['columnitem'] as $column) {
66
				  ${xml_safe_fieldname($column['fielddescr'])} = $ip[xml_safe_fieldname($column['fieldname'])];
67
			  }
68
	    }
69

    
70
	    $a_pkg = &$config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
71

    
72
	    if ($a_pkg[$_GET['id']]) {
73
		if($pkg['custom_delete_php_command'] <> "") {
74
		    if($pkg['custom_php_command_before_form'] <> "")
75
			eval($pkg['custom_php_command_before_form']);
76
		    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
$evaledvar = $config['installedpackages'][xml_safe_fieldname($pkg['name'])]['config'];
87

    
88
if($pkg['custom_php_global_functions'] <> "")
89
        eval($pkg['custom_php_global_functions']);
90

    
91
if($pkg['custom_php_command_before_form'] <> "")
92
	eval($pkg['custom_php_command_before_form']);
93

    
94
$pgtitle = $title;
95
include("head.inc");
96

    
97
?>
98

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

    
202
</form>
203
<?php include("fend.inc"); ?>
204

    
205
<script type="text/javascript">
206
NiftyCheck();
207
Rounded("div#mainarea","bl br","#FFF","#eeeeee","smooth");
208
</script>
209

    
210
</body>
211
</html>
(70-70/133)