Committed for move

This commit is contained in:
2023-05-15 16:45:18 -05:00
parent 343a01cf61
commit 6194dda84a
8 changed files with 172 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
<?php
echo "Total Crontabs:<br>";
$crontab_counts=shell_exec('./count-crontabs.sh');
$crontab_counts=shell_exec('../../Scripts/count-crontabs.sh');
echo "$crontab_counts";
?>

27
api/crontab_view.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
/*
GET Variables
name: Name of crontab
*/
$GLOBALS['db'] = new SQLite3('../../webcron.db');
if (!array_key_exists("name", $_GET)) {
$name = "";
} else {
$name = $_GET["name"];
}
$db = $GLOBALS['db'];
$id = $db->querySingle("select crontab_id from crontabs where crontab_path like '%/$name';");
if (empty($id)){
echo "$name is not a valid crontab";
} else {
$data = $db->querySingle("SELECT crontab_data FROM crontabs WHERE crontab_id = $id;");
echo "$data";
}
?>

View File

@@ -5,6 +5,7 @@ This endpoint will get specific tables from the db
Args will be:
name: Table Name
limit: number of entries to return (default all)
columns: This will be a comma delimited list of column names (in the order that it needs to be displayed)
*/
if ( ! array_key_exists("name", $_GET) ){
echo "A tablename was not provided with the request";
@@ -19,6 +20,11 @@ if ( array_key_exists("limit", $_GET)){
$limit=0;
}
if ( array_key_exists("columns", $_GET)){
echo $_GET["columns"];
$columns = explode(',', $_GET["columns"]);
}
$query_modifier="";
if (filter_var($limit, FILTER_VALIDATE_INT)){
if ($limit > 0){
@@ -35,20 +41,32 @@ if (filter_var($limit, FILTER_VALIDATE_INT)){
echo '<div class="log_table bordered">';
echo '<div class="table_row">';
$counter=0;
for ($i = 0; $i < $res->numColumns(); $i++ ){
echo "<div class=\"table_header\">{$res->columnName($i)}</div>";
$counter++;
if ( !empty($columns) ) {
foreach($columns as $column_name){
echo "<div class=\"table_header\">{$column_name}</div>";
}
} else {
$counter=0;
for ($i = 0; $i < $res->numColumns(); $i++ ){
echo "<div class=\"table_header\">{$res->columnName($i)}</div>";
$counter++;
}
}
echo '</div>';
while ($row = $res->fetchArray()){
echo "<div class=\"table_row\">";
for ($i = 0; $i < $counter; $i++){
echo "<div class=\"table_cell\">{$row[$i]}</div>";
if ( !empty($columns) ) {
foreach($columns as $column_name){
echo "<div class=\"table_cell\">{$row[$column_name]}</div>";
}
} else {
for ($i = 0; $i < $counter; $i++){
echo "<div class=\"table_cell\">{$row[$i]}</div>";
}
}
echo "</div>";
}
echo '</div>';