Ejemplo n.º 1
0
    public function show($segments)
    {
        $entry = array();
        $data = DB::query('select webcams.title, webcams.caption, webcams.code, webcams.location, users.username, users.title as user_title
			from webcams 
			join users on users.id = webcams.user_id 
			where webcams.code = \'' . $segments[1] . '\'', 1);
        if ($data) {
            $files = File::dir_content(PATH_WEBCAM . $data['username'], '', 'lastsnap.jpg');
            $dotssize = 16;
            $dotssize = count($files);
            $select = array();
            if (count($files)) {
                sort($files);
                foreach ($files as $i => $file) {
                    $tmp = stat(PATH_WEBCAM . $data['username'] . '/' . $file);
                    if (isset($segments[2]) && isset($segments[3])) {
                        if ($tmp[9] >= $segments[2] && $tmp[9] <= $segments[3]) {
                            //$select[] = array($tmp[9],date('Y m d H:i:s',$tmp[9]),timespan($tmp[9]));
                        } else {
                            unset($files[$i]);
                        }
                    } else {
                        if ($i == count($files) - 1) {
                            $segments[3] = $tmp[9];
                        }
                    }
                    $select[] = array($tmp[9], date('Y m d H:i:s', $tmp[9]), timespan($tmp[9]));
                }
                if ($segments[4] == null) {
                    $segments[4] = 1000;
                }
                if ($segments[5] == null) {
                    $segments[5] = 500;
                }
                $stat = stat(PATH_WEBCAM . $data['username'] . '/' . $files[count($files) - 1]);
                $entry = $data;
                $entry['count'] = count($files);
                $entry['timespan'] = timespan($stat[9]);
                //$entry['files'] = array_slice($files,count($files)-$dotssize,count($files));
                $entry['files'] = $files;
            }
        }
        return array('view' => 'webcams/show', 'select' => $select, 'segments' => $segments, 'entry' => $entry);
    }
Ejemplo n.º 2
0
$segments = array_values(array_filter(explode('/', $request_uri)));
$missing_page = '../views/missing.html';
$link = false;
$mode = isset($segments[1]) && $segments[1] == 'views' ? 'include' : 'app';
use App\Helpers\DB;
use App\Helpers\File;
if ($segments[0] == 'webcams' && isset($segments[1])) {
    if (defined('DBPASS')) {
        $link = DB::connect(DBHOST, DBUSER, DBPASS, DBNAME);
    }
    $data = DB::query('select webcams.title, webcams.caption, webcams.code, webcams.location, users.username, users.title as user_title
		from webcams 
		join users on users.id = webcams.user_id 
		where webcams.code = \'' . $segments[1] . '\'', 1);
    if ($data) {
        $files = File::dir_content(PATH_WEBCAM . $data['username'], '', 'lastsnap.jpg');
        $config['og'] = array('title' => $data['title'], 'description' => $data['caption'], 'url' => 'http://social.devmeta.net/webcams/' . $data['code'], 'image' => 'http://social.devmeta.net/upload/webcams/' . $data['username'] . '/' . $files[count($files) - 1]);
    }
}
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    if ($mode == 'app') {
        if (defined('DBPASS')) {
            $link = DB::connect(DBHOST, DBUSER, DBPASS, DBNAME);
        }
        $uname = $segments[0];
        $umethod = "";
        if (strpos($uname, '-') > -1) {
            $umethod = substr(strstr($uname, '-'), 1);
            $uname = strstr($uname, '-', true);
        }
        $controller = $uname;