1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-04 20:27:40 +02:00

Monstra Library: basic core improvments

This commit is contained in:
Awilum
2013-01-04 21:08:04 +02:00
parent 7437cc6abb
commit ef12b7492e
289 changed files with 16265 additions and 17155 deletions

View File

@@ -1,74 +1,73 @@
<?php
// Add plugin navigation link
Navigation::add(__('Backups', 'backup'), 'system', 'backup', 3);
// Add plugin navigation link
Navigation::add(__('Backups', 'backup'), 'system', 'backup', 3);
/**
* Backup Admin Class
*/
class BackupAdmin extends Backend
{
/**
* Backup Admin Class
* Backup admin
*/
class BackupAdmin extends Backend {
public static function main()
{
$backups_path = ROOT . DS . 'backups';
$backups_list = array();
/**
* Backup admin
*/
public static function main() {
// Create backup
// -------------------------------------
if (Request::post('create_backup')) {
$backups_path = ROOT . DS . 'backups';
if (Security::check(Request::post('csrf'))) {
$backups_list = array();
@set_time_limit(0);
@ini_set("memory_limit", "512M");
// Create backup
// -------------------------------------
if (Request::post('create_backup')) {
$zip = Zip::factory();
if (Security::check(Request::post('csrf'))) {
@set_time_limit(0);
@ini_set("memory_limit", "512M");
// Add storage folder
$zip->readDir(STORAGE . DS, false);
$zip = Zip::factory();
// Add public folder
if (Request::post('add_public_folder')) $zip->readDir(ROOT . DS . 'public' . DS, false);
// Add storage folder
$zip->readDir(STORAGE . DS, false);
// Add plugins folder
if (Request::post('add_plugins_folder')) $zip->readDir(PLUGINS . DS, false);
// Add public folder
if (Request::post('add_public_folder')) $zip->readDir(ROOT . DS . 'public' . DS, false);
// Add plugins folder
if (Request::post('add_plugins_folder')) $zip->readDir(PLUGINS . DS, false);
$zip->archive($backups_path . DS . Date::format(time(), "Y-m-d-H-i-s").'.zip');
$zip->archive($backups_path . DS . Date::format(time(), "Y-m-d-H-i-s").'.zip');
} else { die('csrf detected!'); }
}
// Delete backup
// -------------------------------------
if (Request::get('id') == 'backup' && Request::get('delete_file')) {
if (Security::check(Request::get('token'))) {
File::delete($backups_path . DS . Request::get('delete_file'));
Request::redirect(Option::get('siteurl').'admin/index.php?id=backup');
} else { die('csrf detected!'); }
}
// Download backup
// -------------------------------------
if (Request::get('download')) {
if (Security::check(Request::get('token'))) {
File::download($backups_path . DS . Request::get('download'));
} else { die('csrf detected!'); }
}
// Get backup list
$backups_list = File::scan($backups_path, '.zip');
// Display view
View::factory('box/backup/views/backend/index')
->assign('backups_list', $backups_list)
->display();
} else { die('csrf detected!'); }
}
}
// Delete backup
// -------------------------------------
if (Request::get('id') == 'backup' && Request::get('delete_file')) {
if (Security::check(Request::get('token'))) {
File::delete($backups_path . DS . Request::get('delete_file'));
Request::redirect(Option::get('siteurl').'admin/index.php?id=backup');
} else { die('csrf detected!'); }
}
// Download backup
// -------------------------------------
if (Request::get('download')) {
if (Security::check(Request::get('token'))) {
File::download($backups_path . DS . Request::get('download'));
} else { die('csrf detected!'); }
}
// Get backup list
$backups_list = File::scan($backups_path, '.zip');
// Display view
View::factory('box/backup/views/backend/index')
->assign('backups_list', $backups_list)
->display();
}
}

View File

@@ -1,32 +1,29 @@
<?php
/**
* Backup plugin
*
* @package Monstra
* @subpackage Plugins
* @author Romanenko Sergey / Awilum
* @copyright 2012 Romanenko Sergey / Awilum
* @version 1.0.0
*
*/
/**
* Backup plugin
*
* @package Monstra
* @subpackage Plugins
* @author Romanenko Sergey / Awilum
* @copyright 2012 Romanenko Sergey / Awilum
* @version 1.0.0
*
*/
// Register plugin
Plugin::register( __FILE__,
__('Backup', 'backup'),
__('Backup manager', 'backup'),
'1.0.0',
'Awilum',
'http://monstra.org/',
null,
'box');
// Register plugin
Plugin::register( __FILE__,
__('Backup', 'backup'),
__('Backup manager', 'backup'),
'1.0.0',
'Awilum',
'http://monstra.org/',
null,
'box');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
// Include Backup Admin
Plugin::admin('backup', 'box');
if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin'))) {
// Include Backup Admin
Plugin::admin('backup', 'box');
}
}

View File

@@ -8,4 +8,4 @@
<plugin_version>1.0.0</plugin_version>
<plugin_author>Awilum</plugin_author>
<plugin_author_uri>http://monstra.org/</plugin_author_uri>
</root>
</root>

View File

@@ -1,17 +1,17 @@
<?php
return array(
'backup' => array(
'Backups' => 'Backups',
'Backup date' => 'Backup Datum',
'Create backup' => 'Erstelle Backup',
'Delete' => 'Löschen',
'storage' => 'Speicher',
'public' => 'Öffentliche',
'plugins' => 'Plugins',
'Size' => 'Größe',
'Actions' => 'Aktionen',
'Delete backup: :backup' => 'Lösche Backup: :backup',
'Creating...' => 'Erstellen...',
)
);
<?php
return array(
'backup' => array(
'Backups' => 'Backups',
'Backup date' => 'Backup Datum',
'Create backup' => 'Erstelle Backup',
'Delete' => 'Löschen',
'storage' => 'Speicher',
'public' => 'Öffentliche',
'plugins' => 'Plugins',
'Size' => 'Größe',
'Actions' => 'Aktionen',
'Delete backup: :backup' => 'Lösche Backup: :backup',
'Creating...' => 'Erstellen...',
)
);

View File

@@ -2,10 +2,10 @@
return array(
'backup' => array(
'Backups' => 'Backups',
'Backups' => 'Backups',
'Backup date' => 'Backup date',
'Create backup' => 'Create backup',
'Delete' => 'Delete',
'Create backup' => 'Create backup',
'Delete' => 'Delete',
'storage' => 'storage',
'public' => 'public',
'plugins' => 'plugins',
@@ -14,4 +14,4 @@
'Delete backup: :backup' => 'Delete backup: :backup',
'Creating...' => 'Creating...',
)
);
);

View File

@@ -8,10 +8,10 @@
'Delete' => 'Elimina',
'storage' => 'dati',
'public' => 'pubblica',
'plugins' => 'plugin',
'Size' => 'Dimensione',
'plugins' => 'plugin',
'Size' => 'Dimensione',
'Actions' => 'Azioni',
'Delete backup: :backup' => 'Elimina backup: :backup',
'Creating...' => 'Creazione...',
)
);
);

View File

@@ -14,4 +14,4 @@
'Delete backup: :backup' => 'Ištrinti: :backup',
'Creating...' => 'Kuriama...',
)
);
);

View File

@@ -2,10 +2,10 @@
return array(
'backup' => array(
'Backups' => 'Backups',
'Backups' => 'Backups',
'Backup date' => 'Data do backup',
'Create backup' => 'Criar',
'Delete' => 'Deletar',
'Create backup' => 'Criar',
'Delete' => 'Deletar',
'storage' => 'storage',
'public' => 'public',
'plugins' => 'plugins',
@@ -14,4 +14,4 @@
'Delete backup: :backup' => 'Deletar o backup: :backup',
'Creating...' => 'Criando backup...',
)
);
);

View File

@@ -8,10 +8,10 @@
'Delete' => 'Удалить',
'storage' => 'данные',
'public' => 'публичная',
'plugins' => 'плагины',
'Size' => 'Размер',
'plugins' => 'плагины',
'Size' => 'Размер',
'Actions' => 'Действия',
'Delete backup: :backup' => 'Удалить бекап: :backup',
'Creating...' => 'Создание...',
)
);
);

View File

@@ -8,10 +8,10 @@
'Delete' => 'Видалити',
'storage' => 'дані',
'public' => 'публічна',
'plugins' => 'плагіни',
'Size' => 'Розмір',
'plugins' => 'плагіни',
'Size' => 'Розмір',
'Actions' => 'Дії',
'Delete backup: :backup' => 'Видалити бекап: :backup',
'Creating...' => 'Створення...',
)
);
);

View File

@@ -13,11 +13,11 @@ $().ready(function(){$('[name=create_backup]').click(function(){$(this).button('
Form::hidden('csrf', Security::token()).
Form::checkbox('add_storage_folder', null, true, array('disabled' => 'disabled')) . ' ' . __('storage', 'backup') . ' ' . Html::nbsp(2) .
Form::checkbox('add_public_folder') . ' ' . __('public', 'backup') . ' ' . Html::nbsp(2) .
Form::checkbox('add_plugins_folder') . ' ' . __('plugins', 'backup') . ' ' . Html::nbsp(2) .
Form::checkbox('add_plugins_folder') . ' ' . __('plugins', 'backup') . ' ' . Html::nbsp(2) .
Form::submit('create_backup', __('Create backup', 'backup'), array('class' => 'btn', 'data-loading-text' => __('Creating...', 'backup'))).
Form::close()
Form::close()
);
?>
?>
<!-- Backup_list -->
<table class="table table-bordered">
@@ -34,18 +34,18 @@ $().ready(function(){$('[name=create_backup]').click(function(){$(this).button('
<td>
<?php $name = strtotime(str_replace('-', '', basename($backup, '.zip'))); ?>
<?php echo Html::anchor(Date::format($name, 'F jS, Y - g:i A'), Option::get('siteurl').'admin/index.php?id=backup&download='.$backup.'&token='.Security::token()); ?>
</td>
</td>
<td><?php echo Number::byteFormat(filesize(ROOT . DS . 'backups' . DS . $backup)); ?></td>
<td>
<td>
<div class="pull-right">
<?php echo Html::anchor(__('Delete', 'backup'),
'index.php?id=backup&delete_file='.$backup.'&token='.Security::token(),
array('class' => 'btn btn-small', 'onclick' => "return confirmDelete('".__('Delete backup: :backup', 'backup', array(':backup' => Date::format($name, 'F jS, Y - g:i A')))."')"));
?>
</div>
</td>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<!-- /Backup_list -->
<!-- /Backup_list -->