예제 #1
0
/**
 * Importiert das Tar-Archiv $filename in den Ordner /files.
 *
 * @param string $filename Pfad + Dateinamen zum Tar-Archiv
 *
 * @return array Gibt ein Assoc. Array zurück.
 *               'state' => boolean (Status ob fehler aufgetreten sind)
 *               'message' => Evtl. Status/Fehlermeldung
 */
function rex_a1_import_files($filename)
{
    $return = [];
    $return['state'] = false;
    if ($filename == '' || substr($filename, -7, 7) != '.tar.gz') {
        $return['message'] = rex_i18n::msg('im_export_no_import_file_chosen') . '<br />';
        return $return;
    }
    // Ordner /files komplett leeren
    rex_dir::deleteFiles(rex_path::media());
    $tar = new rex_tar();
    // ----- EXTENSION POINT
    $tar = rex_extension::registerPoint(new rex_extension_point('A1_BEFORE_FILE_IMPORT', $tar));
    // require import skript to do some userside-magic
    rex_a1_import_skript(str_replace('.tar.gz', '.php', $filename), REX_A1_IMPORT_ARCHIVE, REX_A1_IMPORT_EVENT_PRE);
    $tar->openTAR($filename);
    if (!$tar->extractTar()) {
        $msg = rex_i18n::msg('im_export_problem_when_extracting') . '<br />';
        if (count($tar->getMessages()) > 0) {
            $msg .= rex_i18n::msg('im_export_create_dirs_manually') . '<br />';
            foreach ($tar->getMessages() as $_message) {
                $msg .= rex_path::absolute($_message) . '<br />';
            }
        }
    } else {
        $msg = rex_i18n::msg('im_export_file_imported') . '<br />';
    }
    // ----- EXTENSION POINT
    $tar = rex_extension::registerPoint(new rex_extension_point('A1_AFTER_FILE_IMPORT', $tar));
    // require import skript to do some userside-magic
    rex_a1_import_skript(str_replace('.tar.gz', '.php', $filename), REX_A1_IMPORT_ARCHIVE, REX_A1_IMPORT_EVENT_POST);
    $return['state'] = true;
    $return['message'] = $msg;
    return $return;
}
/**
 * Importiert das Tar-Archiv $filename in den Ordner /files
 *
 * @param string Pfad + Dateinamen zum Tar-Archiv
 *
 * @return array Gibt ein Assoc. Array zurück.
 *               'state' => boolean (Status ob fehler aufgetreten sind)
 *               'message' => Evtl. Status/Fehlermeldung
 */
function rex_a1_import_files($filename)
{
    global $REX, $I18N;
    $return = array();
    $return['state'] = false;
    if ($filename == '' || substr($filename, -7, 7) != '.tar.gz') {
        $return['message'] = $I18N->msg('im_export_no_import_file_chosen') . '<br />';
        return $return;
    }
    // Ordner /files komplett leeren
    rex_deleteFiles($REX['INCLUDE_PATH'] . '/../../' . $REX['MEDIA_DIR']);
    $tar = new rex_tar();
    // ----- EXTENSION POINT
    $tar = rex_register_extension_point('A1_BEFORE_FILE_IMPORT', $tar);
    // require import skript to do some userside-magic
    rex_a1_import_skript(str_replace('.tar.gz', '.php', $filename), REX_A1_IMPORT_ARCHIVE, REX_A1_IMPORT_EVENT_PRE);
    $tar->openTAR($filename);
    if (!$tar->extractTar()) {
        $msg = $I18N->msg('im_export_problem_when_extracting') . '<br />';
        if (count($tar->message) > 0) {
            $msg .= $I18N->msg('im_export_create_dirs_manually') . '<br />';
            foreach ($tar->message as $_message) {
                $msg .= rex_absPath($_message) . '<br />';
            }
        }
    } else {
        $msg = $I18N->msg('im_export_file_imported') . '<br />';
    }
    // ----- EXTENSION POINT
    $tar = rex_register_extension_point('A1_AFTER_FILE_IMPORT', $tar);
    // require import skript to do some userside-magic
    rex_a1_import_skript(str_replace('.tar.gz', '.php', $filename), REX_A1_IMPORT_ARCHIVE, REX_A1_IMPORT_EVENT_POST);
    $return['state'] = true;
    $return['message'] = $msg;
    return $return;
}