From ffd308284efd6662cdd74886adc59902561ec01f Mon Sep 17 00:00:00 2001 From: Henoch Einbier <axcessor@hotmail.com> Date: Thu, 13 Aug 2020 09:02:05 +0300 Subject: [PATCH] new features: add and delete cronjob files in database --- adminforce/content/interfacedaten/crons.php | 80 +++++++++++++++++++-- 1 file changed, 74 insertions(+), 6 deletions(-) diff --git a/adminforce/content/interfacedaten/crons.php b/adminforce/content/interfacedaten/crons.php index 00358b6..f74e5b0 100644 --- a/adminforce/content/interfacedaten/crons.php +++ b/adminforce/content/interfacedaten/crons.php @@ -1,9 +1,73 @@ -<?php head("Crons (Übersicht und manuell Start)");?> -<table class="tabellen"> -<tr class="tabellenhead"> +<?php +//Dateien holen +$files = array_slice(scandir('../crons/'), 2); + +head("Cronjob hinzufügen"); + +//wenn formular abgeschickt cron hinzufügen +if ( (isset($_POST['cron_art'])) && (isset($_POST['cron_dateiname'])) && (isset($_POST['cron_bezeichnung'])) ) { +$sql = sql::$db->query("INSERT INTO " . _VMS_ . "_crons (`cron`, `datei`, `bezeichnung`) + VALUES ('".$_POST['cron_art']."', 'crons/".$_POST['cron_dateiname']."', '".$_POST['cron_bezeichnung']."')"); +echo 'Cron eingetragen!'; +} +?> +<br> +Cron Datei bitte vorher in /crons kopieren!<br> +<br> +<form action="" method="post"> +<table class="table table-hover table-sm table-responsive"> +<tr> +<td>Cron Art:</td> + <td> + <select name="cron_art" size="1"> + <option>ext_cron</option> + <option>int_forcedbanner</option> + <option>int_highforcedbanner</option> + <option>int_text</option> + <option>int_traffic</option> + <option>int_paidmail</option> + <option>int_htmlpaidmail</option> + </select> + </td> + </tr> +<tr> +<td>Cron Datei wählen:</td> + <td><select name="cron_dateiname" size="1"/> +<?php +//alle crons aus DB einlesen +$cronfiles_sql = sql::$db->prepare("SELECT datei FROM " . _VMS_ . "_crons "); +$cronfiles_sql->execute(); +$cronfiles = $cronfiles_sql->fetchAll(PDO::FETCH_COLUMN, 0); + +for ($x = 0; $x < count($files); $x++) { + //wenn Datei noch nicht eingetragen dann zur Auswahl zeigen + $temp = 'crons/'.$files[$x]; + if (in_array ($temp, $cronfiles) != true ) { + echo '<option value="'.$files[$x].'">'.$files[$x].'</option>'.PHP_EOL; + } +} + +echo '</select> (zeigt nur Dateien die noch nicht in der DB sind)</td></tr>'; +?> +<tr> +<td>Bezeichnung</td> +<td><input type="text" name="cron_bezeichnung" size="60"/></td> +</tr> +</table> +<input class="btn btn-light" type="submit" value="Eintragen"/> +</form> +<br><br> + +<?php +foot(); + +head("Crons (Übersicht, manueller Start und Löschen)");?> +<table class="table table-hover table-sm table-responsive"> +<tr> <td align="center"><b>Cron</b></td> <td align="center"><b>Laufzeit</b></td> - <td align="center">URL</td> + <td align="center">Ausführen</td> + <td align="center">Löschen</td> </tr> <?php $i = 0; @@ -19,11 +83,15 @@ while ($crontabelle = $crons->fetch() ) { </td> <td align="center" valign="middle"> - <font color="#000080">' . date("d.m.Y - H:i:s", $crontabelle['laufzeit']) . '</font> + ' . date("d.m.Y - H:i:s", $crontabelle['laufzeit']) . ' </td> <td align="center" valign="middle"> - <a href="../cron.php?id=' . $crontabelle['id'] . '&pw=' . $system['cron_pw'] . '" target="_blank"><img src="images/gruen.gif" width="15" height="15" border="0" alt="Ausführen"></a> + <a href="../cron.php?id=' . $crontabelle['id'] . '&pw=' . $system['cron_pw'] . '" target="_blank"><button class="btn btn-light">Starten</button></a> + </td> + + <td align="center" valign="middle"> + <a href="../cron.php?id=' . $crontabelle['id'] . '&delete=yes&pw=' . $system['cron_pw'] . '" target="_blank"><button class="btn btn-light">Löschen</button></a> </td> </tr> -- GitLab