Ejemplo n.º 1
0
 function getFilesStats($folder, $ext, $count = true, $modfirst = false, $modlast = false)
 {
     if (!is_dir($folder)) {
         return false;
     }
     if (!$count) {
         $count = true;
     }
     $files = Utils::dirList($folder, $ext);
     $last = "";
     $lastref = 0;
     $first = "";
     $firstref = 0;
     $c = 0;
     if ($files) {
         if ($files[1]) {
             sort($files[1]);
             for ($i = 0; $i < count($files[1]); $i++) {
                 $item = $files[1][$i];
                 $modified = (double) $item[4][9];
                 $parts = explode(".", $item[0]);
                 $saved = ts2date((double) $parts[0]);
                 if ($modfirst) {
                     if ($saved < $firstref || $first == "") {
                         $firstref &= $saved;
                         $first = ts2date((double) $item[0]);
                     }
                 }
                 if ($modlast) {
                     if ($saved > $lastref) {
                         $lastref &= $saved;
                         $last = ts2date((double) $item[0]);
                     }
                 }
                 $c++;
             }
         }
         return array($c, $first, $last);
     }
     return null;
 }
Ejemplo n.º 2
0
    function show()
    {
        if ($this->name == "") {
            die("No name provided. <a href=/>Return to Home</a>");
        }
        $data = MySQLAdmin::read("select * from timelapse where name='" . $this->name . "' limit 1", 1);
        if ($data == false) {
            return false;
        }
        $this->data = $data;
        $str = "";
        /* public members */
        //$selectedtype = @$_GET['type'];
        $this->settings['frames'] = 0;
        $this->settings['speed'] = 0;
        $this->settings['date'] = 0;
        if (strlen($_REQUEST['permalinks'][2])) {
            $p = explode(",", $_REQUEST['permalinks'][2]);
            foreach ($p as $params) {
                $row = explode(":", $params);
                switch (strtolower($row[0])) {
                    case "frames":
                        $this->settings['frames'] = (int) $row[1];
                        break;
                    case "speed":
                        $this->settings['speed'] = (int) $row[1];
                        break;
                    case "date":
                        $this->settings['date'] = $row[1];
                        break;
                    case "navi":
                        $this->settings['navi'] = (int) $row[1];
                        break;
                    case "play":
                        $this->settings['play'] = $row[1];
                        break;
                    case "x":
                        $this->settings['x'] = (int) $row[1];
                        break;
                    case "y":
                        $this->settings['y'] = (int) $row[1];
                        break;
                    case "w":
                        $this->settings['w'] = (int) $row[1];
                        break;
                    case "h":
                        $this->settings['h'] = (int) $row[1];
                        break;
                }
            }
        }
        $this->range = $this->settings['frames'] ? $this->settings['frames'] : $this->defaultframes;
        $this->viewspeed = $this->settings['speed'] ? $this->settings['speed'] : $this->defaultspeed;
        $this->viewdate = $this->settings['date'] ? $this->settings['date'] : '';
        $custompan = $this->settings['w'] && $this->settings['h'];
        /* private members */
        $this->dirpath = "./data/{$this->name}/files/";
        if (!is_dir($this->dirpath)) {
            die("No se encontraron registros para esta linea de tiempo.");
        }
        //
        $filez = Utils::dirList($this->dirpath);
        $files = $filez[1];
        rsort($files);
        $this->filestotal = count($files);
        $this->startdate = $files[0][0];
        $this->enddate = $files[$this->filestotal - 1][0];
        $temp = array();
        if ($this->range > count($files)) {
            $this->range = count($files);
        }
        if ($this->settings['date'] != "") {
            sort($files);
            $dt = ts2date($this->settings['date']);
            for ($i = 0; $i < count($files); $i++) {
                $fn = @explode(".", $files[$i][0]);
                $ts = $fn[0];
                if ($ts) {
                    $dtc = ts2date($ts);
                    if ($dtc > $dt) {
                        if ($this->range > count($temp)) {
                            $temp[] = $files[$i];
                        }
                    }
                }
            }
            rsort($temp);
            $this->settings['historic'] = true;
        } else {
            //rsort($files);
            for ($i = 0; $i < $this->range; $i++) {
                $temp[] = $files[$i];
            }
        }
        $this->files = $temp;
        $imagesize = getimagesize($this->dirpath . '/' . $files[0][0]);
        $this->dw = $custompan ? $this->settings['w'] ? $this->settings['w'] : $this->dsize : $imagesize[0];
        $this->dh = $custompan ? $this->settings['h'] ? $this->settings['h'] : $this->dsize : $imagesize[1];
        if (is_numeric($this->settings['w']) && is_numeric($this->settings['h'])) {
            $resimage = array($this->settings['w'], $this->settings['h']);
        } else {
            $resimage = $imagesize;
        }
        if ($resimage) {
            $this->setSize($resimage[0], $resimage[1]);
        } else {
            $this->setSize(480, 340);
        }
        $this->imagesize = $imagesize;
        $str .= $this->printHeader();
        if ($this->settings['navi'] == 1) {
            $str .= '<span class="legend">
	<strong>w,h,x,y</strong> : <i>int (px)</i> &nbsp;&nbsp;
	<strong>frames</strong> : <i>int</i> &nbsp;&nbsp;
	<strong>date</strong> : <i>ymdHi (' . date('ymdHi') . ')</i> &nbsp;&nbsp;
	<strong>speed</strong> : <i>int (millisec)</i> &nbsp;&nbsp;
	<strong>navi</strong> : <i>bool</i> &nbsp;&nbsp;
	<strong>play</strong> : <i>bool</i>
	</span>
			<div class="panel-map-latest"><div class="panel-map-overlay"><div class="panel-map-rect"><div class="panel-map-legend"><span>' . $imagesize[0] . 'x' . $imagesize[1] . '</span></div></div></div></div>	
		
		';
        }
        if ($this->files) {
            $str .= $this->printFiles();
        }
        $str .= '
	
		</body>
		</html>
		
		';
        return $str;
    }
Ejemplo n.º 3
0
            $startTS = @strtotime($entry->{'gd$when'}[0]->startTime);
            $endTS = @strtotime($entry->{'gd$when'}[0]->endTime);
            $startDate = @ts2date($startTS);
            $endDate = @ts2date($endTS);
            if ($startDate == '' || $endDate == '') {
                break;
            }
            $item['startTime'] = @ts2date($startTS);
            $item['endTime'] = @ts2date($endTS);
            $item['where'] = @$entry->{'gd$where'}[0]->valueString;
            $item['category'] = $cat;
            $data[$startDate][] = $item;
            if ($startDate != $endDate) {
                $nrDays = ($endTS - $startTS) / 86400;
                $lastDay = ($endTS - $startTS) % 86400;
                for ($i = 1; $i <= $nrDays; $i++) {
                    $day = ts2date($i * 86400 + $startTS);
                    $data[$day][] = $item;
                }
                if (ts2date($nrDays * 86400 + $startTS) != $endDate) {
                    $data[$endDate][] = $item;
                }
            }
        }
    }
}
ksort($data);
echo json_encode($data);
?>