MOD: Admin DB Backup files display

Thought I throw something back to you guys, hope you find it useful.

This is tested on code in 1.3.4sp3, but I don’t think there should be any hassles on other versions.



This is a mod to add time/date of backup to table(including time), not relying on db name for date referencing.

I also changed default naming scheme to dump_yyyymmdd.

Table sort order is now newest to oldest (based on conventional/updated scheme).



Later on I might modify the code to sort by date regardless of name.



Highlighted in [COLOR=“Red”]red[/COLOR] is added, or changed code in: include/admin/database.php


// Backup database
if ($mode == 'backup') {

if (empty($dbdump_filename)) {
[COLOR="Red"] $dbdump_filename = 'dump_'.date('Ymd').'.sql';[/COLOR]
}


$files = fn_get_dir_contents($var_dir['database'].'backup', false, true, '.sql');
[COLOR="Red"]// sort($files, SORT_STRING);[/COLOR]
[COLOR="Red"]array_multisort($files,SORT_DESC,SORT_STRING);[/COLOR]

$backup_files = array();
if (is_array($files)) {
foreach ($files as $file) {
$backup_files[$file]['size'] = filesize($var_dir['database'].'backup'.DS.$file);
$backup_files[$file]['type'] = strpos($file, '.tgz')===false ? 'sql' : 'tgz';
[COLOR="Red"]$backup_files[$file]['time'] = date("H:i:s d/m/Y",filemtime($var_dir['database'].'backup'.DS.$file));[/COLOR]
}
}
fn_add_breadcrumb(fn_get_lang_var('tools'));
fn_add_breadcrumb(fn_get_lang_var('database_maintenance'));
$smarty->assign('backup_files', $backup_files);
$smarty->assign('backup_dir', $var_dir['database'].'backup'.DS);
$smarty->assign('content', 'database');
}

?>




Highlighted in [COLOR=“Red”]red[/COLOR] is added, or changed code in: skins/~skin name~/admin/tools_pages/database.tpl

```php


{$lang.backup_filename}:

[COLOR="Red"]

Backup Format: dump_yyyymmdd.sql
{$lang.text_backup_filename}
{$backup_dir}[/COLOR]


``````php






[COLOR="Red"] [/COLOR]


{if $backup_files}
{foreach from=$backup_files item=file key=name}





[COLOR="Red"][/COLOR]

{/foreach}
{else}
```

Also add language variable [COLOR="Red"]backup_time[/COLOR] with value [COLOR="Red"]Backup Time[/COLOR] (thanks for the reminder [B]wartornskull[/B])

Attached jpeg is how the finished code should look.
I would like to see similar code added to future versions, IMO it is quite handy.

Let me know what you guys think.

database_mod.jpg


{$lang.type} {$lang.filename} {$lang.filesize} {$lang.backup_time}

[{$file.type}]
{$name}

{$file.size|number_format} {$lang.bytes}

{$file.time}

Thanks, Works perfect on 1.3.5 RC1.



Also when adding the above mod you will also need to create a new language value for Backup Time.



Variable = backup_time

Value = Backup Time

Are you really running a store based on the [COLOR=“Red”]beta[/COLOR] 1.3.5 RC1? There is both an official release and a service pack already available that you should consider installing before going further.



Bob

Nope sorry i meant SP1 lol