Пример #1
0
function exportEvents($eids, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat)
{
    if (canView('Events') && !empty($eids)) {
        $export_root = "zmExport";
        $export_listFile = "zmFileList.txt";
        $exportFileList = array();
        $html_eventMaster = '';
        if (is_array($eids)) {
            foreach ($eids as $eid) {
                $exportFileList = array_merge($exportFileList, exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc));
            }
        } else {
            $eid = $eids;
            $exportFileList = exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc);
        }
        // create an master image slider
        if ($exportImages) {
            if (!is_array($eids)) {
                $eids = array($eids);
            }
            $monitorPath = 'events/';
            $html_eventMaster = 'zmEventImagesMaster_' . date('Ymd_His') . '.html';
            if (!($fp = fopen($monitorPath . "/" . $html_eventMaster, "w"))) {
                Fatal("Can't open event images export file '{$html_eventMaster}'");
            }
            fwrite($fp, exportEventImagesMaster($eids));
            fclose($fp);
            $exportFileList[] = $monitorPath . "/" . $html_eventMaster;
        }
        $listFile = "temp/" . $export_listFile;
        if (!($fp = fopen($listFile, "w"))) {
            Fatal("Can't open event export list file '{$listFile}'");
        }
        foreach ($exportFileList as $exportFile) {
            fwrite($fp, "{$exportFile}\n");
        }
        fclose($fp);
        $archive = "";
        if ($exportFormat == "tar") {
            $archive = "temp/" . $export_root . ".tar.gz";
            @unlink($archive);
            $command = "tar --create --gzip --file={$archive} --files-from={$listFile}";
            exec(escapeshellcmd($command), $output, $status);
            if ($status) {
                Error("Command '{$command}' returned with status {$status}");
                if ($output[0]) {
                    Error("First line of output is '" . $output[0] . "'");
                }
                return false;
            }
        } elseif ($exportFormat == "zip") {
            $archive = "temp/zm_export.zip";
            $archive = "temp/" . $export_root . ".zip";
            @unlink($archive);
            $command = "cat " . escapeshellarg($listFile) . " | zip -q " . escapeshellarg($archive) . " -@";
            //cat zmFileList.txt | zip -q zm_export.zip -@
            //-bash: zip: command not found
            exec($command, $output, $status);
            if ($status) {
                Error("Command '{$command}' returned with status {$status}");
                if ($output[0]) {
                    Error("First line of output is '" . $output[0] . "'");
                }
                return false;
            }
        }
        //clean up temporary files
        if (!empty($html_eventMaster)) {
            unlink($monitorPath . '/' . $html_eventMaster);
        }
    }
    return $archive;
}
Пример #2
0
function exportEvents($eids, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc, $exportFormat)
{
    global $thepath;
    //if ( canView( 'Events' ) && !empty($eids) )
    if (!empty($eids)) {
        $export_root = "zmExport";
        $export_listFile = "zmFileList.txt";
        $exportFileList = array();
        if (is_array($eids)) {
            foreach ($eids as $eid) {
                $exportFileList = array_merge($exportFileList, exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc));
            }
        } else {
            $eid = $eids;
            $exportFileList = exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc);
        }
        // create an master image slider
        if ($exportImages) {
            if (!is_array($eids)) {
                $eids = array($eids);
            }
            $monitorPath = $thepath . '/' . ZM_DIR_EVENTS;
            $file = "zmEventImagesMaster" . time() . ".html";
            if (!($fp = fopen($monitorPath . "/" . $file, "w"))) {
                die("Can't open event images export file '{$monitorPath}/{$file}'");
            }
            fwrite($fp, exportEventImagesMaster($eids));
            fclose($fp);
            //$exportFileList[] = $monitorPath."/".$file;
            $exportFileList[] = 'events/' . $file;
        }
        $listFile = $thepath . "/temp/" . $export_listFile;
        if (!($fp = fopen($listFile, "w"))) {
            die("Can't open event export list file '{$listFile}'");
        }
        foreach ($exportFileList as $exportFile) {
            fwrite($fp, "{$exportFile}\n");
        }
        fclose($fp);
        $archive = "";
        if ($exportFormat == "tar") {
            $archive = $thepath . "/temp/" . $export_root . ".tar.gz";
            $directory = $thepath . '/' . ZM_DIR_EVENTS . '/..';
            @unlink($archive);
            $command = "tar --create --gzip --file={$archive} --directory={$directory} --files-from={$listFile}";
            exec(escapeshellcmd($command), $output, $status);
            if ($status) {
                error_log("Command '{$command}' returned with status {$status}");
                if ($output[0]) {
                    error_log("First line of output is '" . $output[0] . "'");
                }
                return false;
            }
        } elseif ($exportFormat == "zip") {
            $archive = $thepath . "/temp/zm_export.zip";
            $archive = $thepath . "/temp/" . $export_root . ".zip";
            @unlink($archive);
            $command = "cat " . escapeshellarg($listFile) . " | zip -q " . escapeshellarg($archive) . " -@";
            //cat zmFileList.txt | zip -q zm_export.zip -@
            //-bash: zip: command not found
            exec($command, $output, $status);
            if ($status) {
                error_log("Command '{$command}' returned with status {$status}");
                if ($output[0]) {
                    error_log("First line of output is '" . $output[0] . "'");
                }
                return false;
            }
        }
    }
    return $archive;
}