-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend.php
52 lines (44 loc) · 1.11 KB
/
backend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php defined( 'SYSPATH' ) or die( 'No direct script access.' );
define('BACKUP_PLUGIN_FOLDER', DOCROOT . 'backups' . DIRECTORY_SEPARATOR);
if(!is_dir(BACKUP_PLUGIN_FOLDER))
{
mkdir(BACKUP_PLUGIN_FOLDER, 0775);
}
Observer::observe('scheduler_callbacks', function() {
scheduler::add(function($from, $to) {
$color = 'green';
$data = array();
$handle = opendir(BACKUP_PLUGIN_FOLDER);
while (false !== ($file = readdir($handle)))
{
if (!preg_match("/(sql|zip)/", $file, $m))
{
continue;
}
$created = filectime(BACKUP_PLUGIN_FOLDER . $file);
if($from <= $created AND $to >= $created)
{
$data[] = array(
'title' => 'Backup::(' . $file . ')',
'start' => $created,
'url' => Route::url('backend', array(
'controller' => 'backup',
'action' => 'view',
'id' => $file
)),
'color' => $color,
'allDay' => FALSE
);
}
}
closedir($handle);
return $data;
});
});
Route::set( 'backup', ADMIN_DIR_NAME.'/backup(/<action>(/<file>))', array(
'action' => '(view|delete|restore)',
'file' => '.*'
) )
->defaults( array(
'controller' => 'backup'
) );