cron stuff

This commit is contained in:
HB9HIL
2024-04-22 23:58:35 +02:00
parent 452fbfac1a
commit ba3eaa9428
4 changed files with 37 additions and 32 deletions

View File

@@ -1,20 +1,24 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Cron extends CI_Controller
require_once './src/Cron/vendor/autoload.php';
class cron extends CI_Controller
{
function __construct() {
function __construct()
{
parent::__construct();
$this->load->model('user_model');
if (!$this->user_model->authorize(2)) {
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!');
redirect('dashboard');
if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
echo "Maintenance Mode is active. Try again later.\n";
redirect('user/login');
}
$this->load->library('Permissions');
}
public function index() {
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$this->load->helper('file');
$this->load->model('cron_model');
@@ -29,4 +33,8 @@ class Cron extends CI_Controller
$this->load->view('cron/index');
$this->load->view('interface_assets/footer', $footerData);
}
public function run() {
echo "works\n";
}
}

View File

@@ -11,4 +11,13 @@ class Cron_model extends CI_Model
return $results;
}
function set_last_run($cron) {
$data = array(
'last_run' => date('Y-m-d H:i:s')
);
$this->db->where('id', $cron);
$this->db->update('cron', $data);
}
}

View File

@@ -27,13 +27,8 @@
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Function</th>
<th>Minute</th>
<th>Hour</th>
<th>Day (Month)</th>
<th>Month</th>
<th>Day (Week)</th>
<th>Description</th>
<th>Cron Expression</th>
<th>Last Run</th>
<th>Next Run</th>
<th></th>
@@ -43,15 +38,12 @@
<tbody>
<?php foreach ($crons as $cron) { ?>
<tr>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->id; ?>'><?php echo $cron->id; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->name; ?>'><?php echo $cron->name; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->function; ?>'><?php echo $cron->function; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->minute; ?>'><?php echo $cron->minute; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->hour; ?>'><?php echo $cron->hour; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->day_month; ?>'><?php echo $cron->day_month; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->month; ?>'><?php echo $cron->month; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->day_week; ?>'><?php echo $cron->day_week; ?></td>
<td style="text-align: center; vertical-align: middle;" class='band_<?php echo $cron->last_run; ?>'><?php echo $cron->last_run; ?></td>
<td style="vertical-align: middle;" class='cron_<?php echo $cron->id; ?>'><?php echo $cron->id; ?></td>
<td style="vertical-align: middle;"><?php echo $cron->description; ?></td>
<td style="vertical-align: middle;"><?php echo '<code>' .
$cron->expression .
'</code>'; ?></td>
<td style="vertical-align: middle;"><?php echo $cron->last_run ?? 'never'; ?></td>
<td></td>
<td></td>
<td></td>
@@ -66,11 +58,6 @@
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tfoot>
</table>
</div>

View File

@@ -13,12 +13,13 @@ $('.crontable').DataTable({
"language": {
url: getDataTablesLanguageUrl(),
},
responsive: false,
ordering: false,
"scrollY": "500px",
responsive: true,
ordering: true,
"scrollY": "600px",
"scrollCollapse": true,
"paging": false,
"scrollX": true,
"autoWidth": false,
"language": {
url: getDataTablesLanguageUrl(),
}