Пример #1
0
/**
 * delete .bak files
 *
 * @param string the directory to start with
 * @see scripts/update.php
 */
function delete_backup($path)
{
    global $context;
    $path_translated = $context['path_to_root'] . $path;
    if ($handle = Safe::opendir($path_translated)) {
        while (($node = Safe::readdir($handle)) !== FALSE) {
            if ($node[0] == '.') {
                continue;
            }
            // make a real name
            $target = str_replace('//', '/', $path . '/' . $node);
            $target_translated = str_replace('//', '/', $path_translated . '/' . $node);
            // delete a sub directory
            if (is_dir($target_translated) && !strpos($path_translated, '/files/') && !strpos($path_translated, '/images/')) {
                delete_backup($target);
            } elseif (preg_match('/\\.bak$/i', $target_translated)) {
                $context['text'] .= sprintf(i18n::s('Deleting %s'), $target_translated) . BR . "\n";
                Safe::unlink($target_translated);
                global $deleted_nodes;
                $deleted_nodes++;
            }
            // ensure we have enough time
            Safe::set_time_limit(30);
        }
        Safe::closedir($handle);
    }
}
Пример #2
0
function _moduleContent(&$smarty, $module_name)
{
    //include elastix framework
    include_once "libs/paloSantoValidar.class.php";
    include_once "libs/misc.lib.php";
    include_once "libs/paloSantoForm.class.php";
    include_once "modules/{$module_name}/libs/paloSantoFTPBackup.class.php";
    //include module files
    include_once "modules/{$module_name}/configs/default.conf.php";
    load_language_module($module_name);
    //global variables
    global $arrConf;
    global $arrConfModule;
    $arrConf = array_merge($arrConf, $arrConfModule);
    //conexion resource
    $pDB = new paloDB($arrConf['dsn_conn_database']);
    //folder path for custom templates
    $base_dir = dirname($_SERVER['SCRIPT_FILENAME']);
    $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes';
    $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme'];
    $dir_backup = $arrConf["dir"];
    $accion = getAction();
    $content = "";
    switch ($accion) {
        case 'delete_backup':
            //BOTON DE BORRAR BACKUP "ELIMINAR"
            $content = delete_backup($smarty, $module_name, $local_templates_dir, $dir_backup, $pDB);
            break;
        case 'backup':
            //BOTON "RESPALDAR"
            $content = backup_form($smarty, $local_templates_dir, $module_name);
            break;
        case 'submit_restore':
            //BOTON DE RSTAURAR, lleva a la ventana de seleccion para restaurar
            $content = restore_form($smarty, $local_templates_dir, $dir_backup, $module_name);
            break;
        case 'process_backup':
            $content = process_backup($smarty, $local_templates_dir, $module_name);
            break;
        case 'process_restore':
            $content = process_restore($smarty, $local_templates_dir, $dir_backup, $module_name);
            break;
        case 'download_file':
            $content = downloadBackup($smarty, $module_name, $local_templates_dir, $dir_backup);
            break;
            /******************************* PARA FTP BACKUP ***************************************/
        /******************************* PARA FTP BACKUP ***************************************/
        case "save_new_FTP":
            $content = saveNewFTPBackup($smarty, $module_name, $local_templates_dir, $pDB);
            break;
        case "view_form_FTP":
            $content = viewFormFTPBackup($smarty, $module_name, $local_templates_dir, $pDB);
            break;
        case 'uploadFTPServer':
            $content = file_upload_FTPServer($module_name, $pDB);
            break;
        case 'downloadFTPServer':
            $content = file_download_FTPServer($module_name, $pDB);
            break;
            /***************************************************************************************/
        /***************************************************************************************/
        case "detail":
            $content = viewDetail($smarty, $module_name, $local_templates_dir, $dir_backup);
            break;
            /******************************* PARA BACKUP AUTOMATICO ********************************/
        /******************************* PARA BACKUP AUTOMATICO ********************************/
        case "automatic":
            $content = automatic_backup($smarty, $module_name, $local_templates_dir, $dir_backup, $pDB);
            break;
            /***************************************************************************************/
        /***************************************************************************************/
        default:
            $content = report_backup_restore($smarty, $module_name, $local_templates_dir, $dir_backup, $pDB);
            break;
    }
    return $content;
}
Пример #3
0
        unlink(DIR_BACKUPS_PREFIX . $file);
    }
}
//
// Main
//
global $author_session;
// Restrict page to administrators
if ($author_session['status'] != 'admin') {
    lcm_page_start(_T('title_archives'), '', '', 'archives_export');
    echo '<p class="normal_text">' . _T('warning_forbidden_not_admin') . "</p>\n";
    lcm_page_end();
    exit;
}
switch ($_REQUEST['action']) {
    case 'export':
        // Automatic name (lcm-YYYYMMDD)
        export_database();
        break;
    case 'download':
        download_backup($_REQUEST['file']);
        break;
    case 'rem_file':
        foreach ($_REQUEST['rem_file'] as $key => $val) {
            delete_backup($val);
        }
        header('Location: export_db.php#listbk');
        break;
    default:
        show_export_form();
}