forked from RobinCK/kasseler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.php
47 lines (43 loc) · 1.23 KB
/
backup.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
<?php
/**
* Файл создания резервной копии БД
*
* @author Igor Ognichenko
* @copyright Copyright (c)2007-2010 by Kasseler CMS
* @link http://www.kasseler-cms.net/
* @filesource backup.php
* @version 2.0
*/
define('KASSELERCMS', true);
define('E__DATABASECONF___', true);
define('E__DATABASE__', true);
define('E__CORE__', true);
if(!file_exists("uploads/tmpfiles/runer.locked")) exit;
require_once "includes/function/init.php";
main::required("includes/nocache.php");
main::required("includes/classes/backup.class.php");
$max_backups = 3;
$backup = new backuper;
$backup->dir = 'uploads/backup/';
$backup->prefix = 'auto_';
$backup->backup();
$backup_dir = opendir("uploads/backup");
$backups_array = array();
while(($file = readdir($backup_dir))){
if (preg_match('/auto_([0-9\-_]+).([a-z.]*)/s', $file)){
$match = "";
preg_match('/auto_([0-9\-_]+).([a-z.]*)/s', $file, $match);
$backups_array[] = $match[1].".".$match[2];
}
}
closedir($backup_dir);
$count = count($backups_array);
if($count>$max_backups){
sort($backups_array);
$b = 1;
foreach ($backups_array as $name=>$value){
if($b<$count-($max_backups-1)) unlink("uploads/backup/auto_{$value}");
$b++;
}
}
?>