aboutsummaryrefslogtreecommitdiffstats
path: root/list.php
diff options
context:
space:
mode:
authorWilliam Harrington <kb0iic@berzerkula.org>2018-03-12 15:51:42 -0500
committerWilliam Harrington <kb0iic@berzerkula.org>2018-03-12 15:51:42 -0500
commit6c7a859fcf9691023c418366a62ece2f19cf4c9f (patch)
tree051200b735f41c29fd81a18f982987e152e1f0a8 /list.php
Initial commit for project.
Diffstat (limited to 'list.php')
-rw-r--r--list.php237
1 files changed, 237 insertions, 0 deletions
diff --git a/list.php b/list.php
new file mode 100644
index 0000000..1750a34
--- /dev/null
+++ b/list.php
@@ -0,0 +1,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(' ', '&nbsp;', $row['configure']));
+ }
+ if($bl) {
+ $rowbld = nl2br(str_replace(' ', '&nbsp;', $row['build']));
+ }
+ if($ns) {
+ $rownst = nl2br(str_replace(' ', '&nbsp;', $row['install']));
+ }
+ if($se) {
+ $rowset = nl2br(str_replace(' ', '&nbsp;', $row['setup']));
+ }
+ if($no) {
+ $rownot = nl2br(str_replace(' ', '&nbsp;', $row['notes']));
+ }
+ if($ur) {
+ $rowurl = nl2br(str_replace(' ', '&nbsp;', $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>