gohome(); } // are you in the correct group? if ($_SESSION['role_id'] < 1) { errormsg('Your role does not have access to this resource'); } else { // row count $tablerows = 0; // get all hosts $query = "SELECT host_id,host_name,host_alias,host_state,host_key FROM hosts ORDER BY host_name"; $stmt = $mysqli->prepare($query); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $table = new Jacopo\Bootstrap3Table\BootstrapTable(); $table->setConfig(array("table-hover" => true, "table-condensed" => true, "table-striped" => true)); $table->setHeader(array("Host Name", "Alias", "State", "Actions")); // output data of each row $stmt->bind_result($host_id, $host_name, $host_alias, $host_state, $host_key); while ($stmt->fetch()) { // check the state if ($host_state == "new") { $state = "<p class='text-info'>New <a href=" . SITE_URL . "/?api=" . $host_key . "&do=hostsetup>(install)</a></p>"; } if ($host_state == "online") { $state = "<p class='text-success'>Online</p>"; } if (strpos($host_state, "provision") !== false) { $state = "<p class='text-info'>Provisioning <a href=" . SITE_URL . "/?api=" . $host_key . "&do=hostsetup>(progress)</a></p>"; } // create table row for each result
function get_message_table($count, $mailwatchdb) { // create table $table = new Jacopo\Bootstrap3Table\BootstrapTable(); $table->setConfig(array("table-hover" => true, "table-condensed" => true, "table-striped" => true)); $table->setHeader(array("id", "timestamp", "from_address", "to_address", "subject", "sascore")); $query = "(SELECT id,timestamp,from_address,to_address,subject,sascore FROM maillog ORDER BY timestamp DESC LIMIT ?) ORDER BY timestamp ASC"; if ($stmt = $mailwatchdb->prepare($query)) { $stmt->bind_param('i', $count); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows > 0) { $stmt->bind_result($id, $timestamp, $from_address, $to_address, $subject, $sascore); while ($row = $stmt->fetch()) { $table->addRows("<a href=" . SITE_URL . "/?do=list&object=message&id=" . $id . ">" . $id . "</a>", $timestamp, $from_address, $to_address, $subject, $sascore); } return $table->getHtml(); } else { return false; } } else { return false; } }