1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if( isset( $_SESSION['counter'] )) {
$_SESSION['counter'] += 1;
} else {
$_SESSION['counter'] = 1;
}
$cn = $_SESSION['cn'];
$bl = $_SESSION['bl'];
$ns = $_SESSION['ns'];
$se = $_SESSION['se'];
$no = $_SESSION['no'];
$ur = $_SESSION['ur'];
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="/css/table.css">
<title></title>
</head>
<body>
<?php
//DEBUG
//echo 'Session: ' . session_id() . '<br>';
//echo '$_SESSION' . var_dump($_SESSION) . '<br>';
//echo '$_POST' . var_dump($_POST) . '<br>';
?>
<a href="add.php" class="stb">Add Record</a><br><br>
<form action="sessionvars.php" method="post">
Select columns:
<input type="checkbox" name="cn" value="Configure"
<?php echo isSet($cn)?" checked":"";?>>Configure
<input type="checkbox" name="bl" value="Build"
<?php echo isSet($bl)?" checked":"";?>>Build
<input type="checkbox" name="ns" value="Install"
<?php echo isSet($ns)?" checked":"";?>>Install
<input type="checkbox" name="se" value="Setup"
<?php echo isSet($se)?" checked":"";?>>Setup
<input type="checkbox" name="no" value="Notes"
<?php echo isSet($no)?" checked":"";?>>Notes
<input type="checkbox" name="ur" value="URL"
<?php echo isSet($ur)?" checked":"";?>>URL
<input type="submit" name="submit" value="Submit">
</form>
<?php
include '/home/kb0iic/config.inc';
$sqlselect = 'SELECT id, seq, name, version';
$sqlfrom = ' FROM PKG';
$sqlwhere = '';
#if columns are selected
if($cn || $bl || $ns || $se || $no || $ur) {
$sqlwhere = ' WHERE';
}
$sqlorder = ' ORDER BY seq ASC';
#if configure is checked
if($cn) {
$sqlselect .= ', configure';
$sqlfrom .= ', PKG_CFG';
$sqlwhere .= ' PKG_CFG.pkg_id = PKG.id';
if($bl || $ns || $se || $no || $ur) {
$sqlwhere .= ' AND';
}
}
#if build is checked
if($bl) {
$sqlselect .= ', build';
$sqlfrom .= ', PKG_BLD';
$sqlwhere .= ' PKG_BLD.pkg_id = PKG.id';
if($ns || $se || $no || $ur) {
$sqlwhere .= ' AND';
}
}
#if install is checked
if($ns) {
$sqlselect .= ', install';
$sqlfrom .= ', PKG_NST';
$sqlwhere .= ' PKG_NST.pkg_id = PKG.id';
if($se || $no || $ur) {
$sqlwhere .= ' AND';
}
}
#if setup is checked
if($se) {
$sqlselect .= ', setup';
$sqlfrom .= ', PKG_SET';
$sqlwhere .= ' PKG_SET.pkg_id = PKG.id';
if($no || $ur) {
$sqlwhere .= ' AND';
}
}
#if notes is checked
if($no) {
$sqlselect .= ', notes';
$sqlfrom .= ', PKG_NOT';
$sqlwhere .= ' PKG_NOT.pkg_id = PKG.id';
if($ur) {
$sqlwhere .= ' AND';
}
}
#if url is checked
if($ur) {
$sqlselect .= ', url';
$sqlfrom .= ', PKG_URL';
$sqlwhere .= ' PKG_URL.pkg_id = PKG.id';
}
$sql = $sqlselect . $sqlfrom . $sqlwhere . $sqlorder;
try {
$stmt = $pdo->prepare($sql);
$stmt->execute();
} catch (PDOException $e) {
echo '<pre style="color:Red">Have a big problem</pre>';
throw $e;
echo "$e->getMessage()";
}
if ($stmt->rowCount() > 0) {
// Data received
// Begin Table
$html_table = '<table class="bdb"><caption>A8-3800 CLFS Server</caption>';
// Table Header
$html_table .= '<thead><tr><th>EDIT</th><th>SEQ</th><th>NAME</th>';
$html_table .= '<th>VERSION</th>';
if($cn){$html_table .= '<th>CONFIGURE</th>';}
if($bl){$html_table .= '<th>BUILD</th>';}
if($ns){$html_table .= '<th>INSTALL</th>';}
if($se){$html_table .= '<th>SETUP</th>';}
if($no){$html_table .= '<th>NOTES</th>';}
if($ur){$html_table .= '<th>URL</th>';}
$html_table .= '<th>DELETE</th></tr></thead>';
// Table Footer
$html_table .= '<tfoot><tr><th>EDIT</th><th>SEQ</th><th>NAME</th>';
$html_table .= '<th>VERSION</th>';
if($cn){$html_table .= '<th>CONFIGURE</th>';}
if($bl){$html_table .= '<th>BUILD</th>';}
if($ns){$html_table .= '<th>INSTALL</th>';}
if($se){$html_table .= '<th>SETUP</th>';}
if($no){$html_table .= '<th>NOTES</th>';}
if($ur){$html_table .= '<th>URL</th>';}
$html_table .= '<th>DELETE</th></tr></tfoot>';
// Table Body
$html_table .= '<tbody>';
// Table Rows
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$rowid = $row['id'];
$rowseq = $row['seq'];
$rownm = $row['name'];
$rowver = $row['version'];
if($cn) {
$rowcfg = nl2br(str_replace(' ', ' ', $row['configure']));
}
if($bl) {
$rowbld = nl2br(str_replace(' ', ' ', $row['build']));
}
if($ns) {
$rownst = nl2br(str_replace(' ', ' ', $row['install']));
}
if($se) {
$rowset = nl2br(str_replace(' ', ' ', $row['setup']));
}
if($no) {
$rownot = nl2br(str_replace(' ', ' ', $row['notes']));
}
if($ur) {
$rowurl = nl2br(str_replace(' ', ' ', $row['url']));
}
$html_table .= '<tr>';
$html_table .= "<td><a href='edit.php?id=".$rowid."'class=\"stb\">Edit</a></td>";
$html_table .= '<td><a name="'.$rowseq.'">'.$rowseq.'</a></td>';
$html_table .= '<td><a href="openfile.php?name='.$rownm.'" title="installed-files"/'.$rownm.'" title="Installed files list" target="_blank">'.($rownm).'</a></td>';
$html_table .= '<td>'.($rowver).'</td>';
if($cn){$html_table .= '<td>'.($rowcfg).'</td>';}
if($bl){$html_table .= '<td>'.($rowbld).'</td>';}
if($ns){$html_table .= '<td>'.($rownst).'</td>';}
if($se){$html_table .= '<td>'.($rowset).'</td>';}
if($no){$html_table .= '<td>'.($rownot).'</td>';}
if($ur){$html_table .= '<td>'.($rowurl).'</td>';}
$html_table .= "<td><a href='delete.php?id=".$rowid."'class=\"stb\">Delete</a></td>";
$html_table .= '</tr>';
}
// End Table Body
$html_table .= '</tbody>';
// End Table
$html_table .= '</table>';
//Output Table
echo $html_table;
} else {
// No Data received
echo '<font color="#D00"><pre>No data found!</pre></font>';
}
?>
<!--- w3c tag -->
<p align="right">
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01 Transitional" height="31" width="88"></a>
</p>
<!-- end w3c tag -->
</body>
</html>
|