function compareFiles($file_a, $file_b)
{
    $dir = getImportDir();
    $time_a = filemtime($dir . '/' . $file_a);
    $time_b = filemtime($dir . '/' . $file_b);
    if ($time_a == $time_b) {
        return 0;
    }
    return $time_a > $time_b ? -1 : 1;
}
Example #2
0
 public function execute()
 {
     include_once rex_path::addon('import_export', 'functions/function_import_export.php');
     include_once rex_path::addon('import_export', 'functions/function_import_folder.php');
     $filename = $this->getParam('filename', self::DEFAULT_FILENAME);
     $filename = str_replace('%REX_SERVER', parse_url(rex::getServer(), PHP_URL_HOST), $filename);
     $filename = str_replace('%REX_VERSION', rex::getVersion(), $filename);
     $filename = strftime($filename);
     $file = $filename;
     $dir = getImportDir() . '/';
     $ext = '.sql';
     if (file_exists($dir . $file . $ext)) {
         $i = 1;
         while (file_exists($dir . $file . '_' . $i . $ext)) {
             ++$i;
         }
         $file = $file . '_' . $i;
     }
     if (rex_a1_export_db($dir . $file . $ext)) {
         $message = $file . $ext . ' created';
         if ($this->sendmail) {
             if (!rex_addon::get('phpmailer')->isAvailable()) {
                 $this->setMessage($message . ', mail not sent (addon "phpmailer" isn\'t activated)');
                 return false;
             }
             $mail = new rex_mailer();
             $mail->AddAddress($this->mailaddress);
             $mail->Subject = rex_i18n::msg('im_export_mail_subject');
             $mail->Body = rex_i18n::msg('im_export_mail_body', rex::getServerName());
             $mail->AddAttachment($dir . $file . $ext, $filename . $ext);
             if ($mail->Send()) {
                 $this->setMessage($message . ', mail sent');
                 return true;
             }
             $this->setMessage($message . ', mail not sent');
             return false;
         }
         $this->setMessage($message);
         return true;
     }
     $this->setMessage($file . $ext . ' not created');
     return false;
 }
 function execute()
 {
     global $REX;
     include_once $REX['INCLUDE_PATH'] . '/addons/import_export/functions/function_import_export.inc.php';
     include_once $REX['INCLUDE_PATH'] . '/addons/import_export/functions/function_import_folder.inc.php';
     $file = 'rex_' . $REX['VERSION'] . '_' . date("Ymd");
     $dir = getImportDir() . '/';
     $ext = '.sql';
     if (file_exists($dir . $file . $ext)) {
         $i = 1;
         while (file_exists($dir . $file . '_' . $i . $ext)) {
             $i++;
         }
         $file = $file . '_' . $i;
     }
     if (rex_a1_export_db($dir . $file . $ext)) {
         $this->setMessage($file . $ext . ' created');
         return true;
     }
     return false;
 }
 function execute()
 {
     global $REX;
     include_once $REX['INCLUDE_PATH'] . '/addons/import_export/functions/function_import_export.inc.php';
     include_once $REX['INCLUDE_PATH'] . '/addons/import_export/functions/function_import_folder.inc.php';
     $server = preg_replace('@^https?://|/.*|[^\\w.-]@', '', $REX['SERVER']);
     $file = strtolower($server) . '_rex' . $REX['VERSION'] . $REX['SUBVERSION'] . $REX['MINORVERSION'] . '_' . date('Ymd_Hi');
     $dir = getImportDir() . '/';
     $ext = '.sql';
     if (file_exists($dir . $file . $ext)) {
         $i = 1;
         while (file_exists($dir . $file . '_' . $i . $ext)) {
             $i++;
         }
         $file = $file . '_' . $i;
     }
     if (rex_a1_export_db($dir . $file . $ext)) {
         $this->setMessage($file . $ext . ' created');
         return true;
     }
     return false;
 }
Example #5
0
 public static function loadExistingImport($import_name)
 {
     // ----- vorhandenen Export importieren
     $err_msg = '';
     if ($import_name == '') {
         $err_msg .= '<p>' . rex_i18n::msg('setup_508') . '</p>';
     } else {
         $import_sql = getImportDir() . '/' . $import_name . '.sql';
         $import_archiv = getImportDir() . '/' . $import_name . '.tar.gz';
         // Nur hier zuerst die Addons installieren
         // Da sonst Daten aus dem eingespielten Export
         // Überschrieben würden
         // Da für das Installieren der Addons die rex_config benötigt wird,
         // mit overrideExisting() eine saubere, komplette Basis schaffen
         if ($err_msg == '') {
             $err_msg .= self::overrideExisting();
         }
         if ($err_msg == '') {
             $err_msg .= self::import($import_sql, $import_archiv);
         }
     }
     return $err_msg;
 }
// all files in files with .sql als endung
$dir = getImportDir();
$folder = readImportFolder(".sql");
foreach ($folder as $file) {
    $filepath = $dir . '/' . $file;
    $filec = date("d.m.Y H:i", filemtime($filepath));
    echo "<tr>\r\n                <td class=lgrey><b>{$file}</b></td>\r\n                <td class=lgrey>{$filec}</td>\r\n                <td class=lgrey><a href=index.php?page={$page}&amp;function=dbimport&amp;impname={$file} title='" . $I18N_IM_EXPORT->msg('import_file') . "' onclick=\"return confirm('" . $I18N_IM_EXPORT->msg('proceed_db_import') . "')\">" . $I18N_IM_EXPORT->msg("import") . "</a></td>\r\n                <td class=lgrey><a href=index.php?page={$page}&amp;function=delete&amp;impname={$file} title='" . $I18N_IM_EXPORT->msg('delete_file') . "' onclick=\"return confirm('" . $I18N->msg('delete') . " ?')\">" . $I18N_IM_EXPORT->msg("delete") . "</a></td></tr>";
}
echo "</table>";
// FILE IMPORT
echo "<br><table width=100% border=0 cellspacing=1 cellpadding=4 bgcolor=#ffffff>\r\n  <tr><td align=left colspan=2 class=lgrey>" . $I18N_IM_EXPORT->msg("files") . "</td>\r\n  <form action=index.php method=post enctype='multipart/form-data'>\r\n  <input type=hidden name=page value={$page}>\r\n  <input type=hidden name=function value=fileimport>\r\n  <tr>\r\n    <td class=lgrey><input type=file name=FORM[importfile]></td>\r\n    <td class=lgrey width=130><input type=submit value='" . $I18N_IM_EXPORT->msg("db_import") . "'></td>\r\n  </tr>\r\n  </form>\r\n  </table>";
echo "<br><table width=100% border=0 cellspacing=1 cellpadding=4 bgcolor=#ffffff>" . "\n";
echo "<tr>\r\n      <td align=left class=lgrey>" . $I18N_IM_EXPORT->msg("filename") . "</td>\r\n      <td width=60 class=lgrey>" . $I18N_IM_EXPORT->msg("createdate") . "</td>\r\n      <td width=60 class=lgrey>&nbsp;</td>\r\n      <td width=60 class=lgrey>&nbsp;</td>" . "\n";
// FILE IMPORT LIST
// all files in files with .tar.gz als endung
$dir = getImportDir();
$folder = readImportFolder(".tar.gz");
foreach ($folder as $file) {
    $filepath = $dir . '/' . $file;
    $filec = date("d.m.Y H:i", filemtime($filepath));
    echo "<tr>\r\n                <td class=lgrey><b>{$file}</b></td>\r\n                <td class=lgrey>{$filec}</td>\r\n                <td class=lgrey><a href=index.php?page={$page}&function=fileimport&impname={$file} title='" . $I18N_IM_EXPORT->msg('import_file') . "' onclick=\"return confirm('" . $I18N_IM_EXPORT->msg('proceed_file_import') . "')\">" . $I18N_IM_EXPORT->msg("import") . "</a></td>\r\n                <td class=lgrey><a href=index.php?page={$page}&function=delete&impname={$file} title='" . $I18N_IM_EXPORT->msg('delete_file') . "' onclick=\"return confirm('" . $I18N->msg('delete') . " ?')\">" . $I18N_IM_EXPORT->msg("delete") . "</a></td></tr>";
}
echo "</table><br />" . "\n";
// ----------------------------------------------------------------- /IMPORT
?>
</td><td valign="top" class="dgrey"><?php 
// ----------------------------------------------------------------- EXPORT
echo "<br />" . $I18N_IM_EXPORT->msg("intro_export") . "<br /><br />" . "\n";
echo "<table width=100% border=0 cellspacing=1 cellpadding=4 bgcolor=#ffffff>\r\n  \r\n  <form action=index.php method=post enctype='multipart/form-data'>\r\n  <input type=hidden name=page value={$page}>\r\n  <input type=hidden name=function value=export>  \r\n  " . "\n";
$checkedsql = "";
$checkedfiles = "";
     case 1:
     case 2:
     case 3:
     case 4:
         $dbchecked[$dbanlegen] = ' checked="checked"';
         break;
     default:
         $dbchecked[0] = ' checked="checked"';
 }
 // Vorhandene Exporte auslesen
 $sel_export = new rex_select();
 $sel_export->setName('import_name');
 $sel_export->setId('import_name');
 $sel_export->setStyle('class="rex-form-select"');
 $sel_export->setAttribute('onclick', 'checkInput(\'dbanlegen_3\')');
 $export_dir = getImportDir();
 $exports_found = false;
 if (is_dir($export_dir)) {
     if ($handle = opendir($export_dir)) {
         $export_archives = array();
         $export_sqls = array();
         while (($file = readdir($handle)) !== false) {
             if ($file == '.' || $file == '..') {
                 continue;
             }
             $isSql = substr($file, strlen($file) - 4) == '.sql';
             $isArchive = substr($file, strlen($file) - 7) == '.tar.gz';
             if ($isSql) {
                 // endung .sql abschneiden
                 $export_sqls[] = substr($file, 0, -4);
                 $exports_found = true;
Example #8
0
    $server = parse_url(rex::getServer(), PHP_URL_HOST);
    $exportfilename = strtolower($server) . '_rex' . rex::getVersion() . '_' . date('Ymd_Hi');
}
if (rex_post('export', 'bool')) {
    // ------------------------------ FUNC EXPORT
    $exportfilename = strtolower($exportfilename);
    $filename = preg_replace('@[^\\.a-z0-9_\\-]@', '', $exportfilename);
    if ($filename != $exportfilename) {
        $success = rex_i18n::msg('im_export_filename_updated');
        $exportfilename = $filename;
    } else {
        $content = '';
        $hasContent = false;
        $header = '';
        $ext = $exporttype == 'sql' ? '.sql' : '.tar.gz';
        $export_path = getImportDir() . '/';
        if (file_exists($export_path . $filename . $ext)) {
            $i = 1;
            while (file_exists($export_path . $filename . '_' . $i . $ext)) {
                ++$i;
            }
            $filename = $filename . '_' . $i;
        }
        if ($exporttype == 'sql') {
            // ------------------------------ FUNC EXPORT SQL
            $header = 'plain/text';
            $hasContent = rex_a1_export_db($export_path . $filename . $ext, $EXPTABLES);
            // ------------------------------ /FUNC EXPORT SQL
        } elseif ($exporttype == 'files') {
            // ------------------------------ FUNC EXPORT FILES
            $header = 'tar/gzip';