コード例 #1
0
function exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc)
{
    if (canView('Events') && $eid) {
        $sql = 'SELECT E.Id,E.MonitorId,M.Name AS MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived FROM Monitors AS M INNER JOIN Events AS E ON (M.Id = E.MonitorId) WHERE E.Id = ?';
        $event = dbFetchOne($sql, NULL, array($eid));
        $eventPath = ZM_DIR_EVENTS . '/' . mygetEventPath($event);
        $files = array();
        if ($dir = opendir($eventPath)) {
            while (($file = readdir($dir)) !== false) {
                if (is_file($eventPath . "/" . $file)) {
                    $files[$file] = $file;
                }
            }
            closedir($dir);
        }
        $exportFileList = array();
        if ($exportDetail) {
            $file = "zmEventDetail.html";
            if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                Fatal("Can't open event detail export file '{$file}'");
            }
            fwrite($fp, exportEventDetail($event, $exportFrames, $exportImages));
            fclose($fp);
            $exportFileList[$file] = $eventPath . "/" . $file;
        }
        if ($exportFrames) {
            $file = "zmEventFrames.html";
            if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                Fatal("Can't open event frames export file '{$file}'");
            }
            fwrite($fp, exportEventFrames($event, $exportDetail, $exportImages));
            fclose($fp);
            $exportFileList[$file] = $eventPath . "/" . $file;
        }
        if ($exportImages) {
            $filesLeft = array();
            $myfilelist = array();
            foreach ($files as $file) {
                if (preg_match("/-(?:capture|analyse).jpg\$/", $file)) {
                    $exportFileList[$file] = $eventPath . "/" . $file;
                    $myfilelist[$file] = $eventPath . "/" . $file;
                } else {
                    $filesLeft[$file] = $file;
                }
            }
            $files = $filesLeft;
            // create an image slider
            if (!empty($myfilelist)) {
                $file = "zmEventImages.html";
                if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                    Fatal("Can't open event images export file '{$file}'");
                }
                fwrite($fp, exportEventImages($event, $exportDetail, $exportFrames, $myfilelist));
                fclose($fp);
                $exportFileList[$file] = $eventPath . "/" . $file;
            }
        }
        if ($exportVideo) {
            $filesLeft = array();
            foreach ($files as $file) {
                if (preg_match("/\\.(?:mpg|mpeg|avi|asf|3gp)\$/", $file)) {
                    $exportFileList[$file] = $eventPath . "/" . $file;
                } else {
                    $filesLeft[$file] = $file;
                }
            }
            $files = $filesLeft;
        }
        if ($exportMisc) {
            foreach ($files as $file) {
                $exportFileList[$file] = $eventPath . "/" . $file;
            }
            $files = array();
        }
    }
    return array_values($exportFileList);
}
コード例 #2
0
ファイル: export_functions.php プロジェクト: mondychan/modern
function exportFileList($eid, $exportDetail, $exportFrames, $exportImages, $exportVideo, $exportMisc)
{
    //if ( canView( 'Events' ) && $eid )
    if ($eid) {
        $sql = "select E.Id,E.MonitorId,M.Name As MonitorName,M.Width,M.Height,E.Name,E.Cause,E.Notes,E.StartTime,E.Length,E.Frames,E.AlarmFrames,E.TotScore,E.AvgScore,E.MaxScore,E.Archived from Monitors as M inner join Events as E on (M.Id = E.MonitorId) where E.Id = '" . dbEscape($eid) . "'";
        $event = dbFetchOne($sql);
        $eventPath = mygetEventPath($event);
        $eventRoot = 'events/' . myEventRoot($event);
        $files = array();
        if ($dir = opendir($eventPath)) {
            while (($file = readdir($dir)) !== false) {
                if (is_file($eventPath . "/" . $file)) {
                    $files[$file] = $file;
                }
            }
            closedir($dir);
        }
        $exportFileList = array();
        if ($exportDetail) {
            $file = "zmEventDetail.html";
            if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                die("Can't open event detail export file '{$file}'");
            }
            fwrite($fp, exportEventDetail($event, $exportFrames, $exportImages));
            fclose($fp);
            $exportFileList[$file] = $eventRoot . "/" . $file;
        }
        if ($exportFrames) {
            $file = "zmEventFrames.html";
            if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                die("Can't open event frames export file '{$file}'");
            }
            fwrite($fp, exportEventFrames($event, $exportDetail, $exportImages));
            fclose($fp);
            $exportFileList[$file] = $eventRoot . "/" . $file;
        }
        if ($exportImages) {
            $filesLeft = array();
            $myfilelist = array();
            foreach ($files as $file) {
                if (preg_match("/-(?:capture|analyse).jpg\$/", $file)) {
                    $exportFileList[$file] = $eventRoot . "/" . $file;
                    $myfilelist[$file] = $eventPath . "/" . $file;
                } else {
                    $filesLeft[$file] = $file;
                }
            }
            $files = $filesLeft;
            // create an image slider
            if (!empty($myfilelist)) {
                $file = "zmEventImages.html";
                if (!($fp = fopen($eventPath . "/" . $file, "w"))) {
                    die("Can't open event images export file '{$file}'");
                }
                fwrite($fp, exportEventImages($event, $exportDetail, $exportFrames, $myfilelist));
                fclose($fp);
                $exportFileList[$file] = $eventRoot . "/" . $file;
            }
        }
        if ($exportVideo) {
            $filesLeft = array();
            foreach ($files as $file) {
                if (preg_match("/\\.(?:mpg|mpeg|avi|asf|3gp)\$/", $file)) {
                    $exportFileList[$file] = $eventRoot . "/" . $file;
                } else {
                    $filesLeft[$file] = $file;
                }
            }
            $files = $filesLeft;
        }
        if ($exportMisc) {
            foreach ($files as $file) {
                $exportFileList[$file] = $eventRoot . "/" . $file;
            }
            $files = array();
        }
    }
    return array_values($exportFileList);
}