Esempio n. 1
0
	private function is_auth()
	{
		static $flickr_ok = null;
		if ( isset( $flickr_ok ) ){
			return $flickr_ok;
		}

		$flickr_ok = false;
		$token = Options::get( 'flickr_token_' . User::identify()->id );
		if ( $token != '' ){
			$flickr = new Flickr();
			$result = $flickr->call( 'flickr.auth.checkToken', array( 'api_key' => $flickr->key, 'auth_token' => $token ) );
			if ( isset( $result->auth->perms ) ){
				$flickr_ok = true;
				$_SESSION['nsid'] = (string)$result->auth->user['nsid'];
			}
			else{
				Options::set( 'flickr_token_' . User::identify()->id );
				unset( $_SESSION['flickr_token'] );
			}
		}
		return $flickr_ok;
	}
Esempio n. 2
0
		public function exif($type = false) {
			if(!$this->_exif) {
				$response = Flickr::call(array(
					'method' => 'flickr.photos.getExif',
					'photo_id' => $this->_id,
					'secret' => $this->_secret
				),86400);
				
				$exifs = $response['photo']['exif'];

				if($exifs) {
					foreach($exifs as $ex) {
						if($ex['tag'] === 'FNumber' && $ex['tagspace'] === 'ExifIFD') {
							$this->_exif['aperture'] = (float)$ex['raw']['_content'];
						} elseif(!$this->_exif['aperture'] && $ex['tag'] === 33437) {
							$a = explode('/',$ex['clean']['_content']);
							$this->_exif['aperture'] = (float)$a[1];							
						}
						
						if($ex['tag'] === 'ExposureTime' && $ex['tagspace'] === 'ExifIFD') {
							$this->_exif['exposure'] = $ex['raw']['_content'];
						} elseif(!$this->_exif['exposure'] && $ex['tag'] === 33434) {
							$this->_exif['exposure'] = $ex['raw']['_content'];
						}
						
						if($ex['tag'] === 'FocalLength' && $ex['tagspace'] === 'ExifIFD') {
							$a = explode(' ',$ex['raw']['_content']);
							$this->_exif['focal_length'] = (float)$a[0];
						} elseif(!$this->_exif['focal_length'] && $ex['tag'] === 37386) {
							$a = explode(' ',$ex['clean']['_content']);
							$this->_exif['focal_length'] = (float)$a[0];
						}						
						
						if($ex['tag'] === 'ISO' && $ex['tagspace'] === 'ExifIFD') {
							$this->_exif['iso'] = (int)$ex['raw']['_content'];
						} elseif(!$this->_exif['iso'] && $ex['tag'] === 34855) {
							$this->_exif['iso'] = (int)$ex['raw']['_content'];
						}
					}
				}
			}
			
			if(!$type) {
				return ($this->_exif['aperture'] || $this->_exif['exposure'] || $this->_exif['focal_length'] || $this->_exif['iso']);
			}
		
			return $this->_exif[$type] ? $this->_exif[$type] : false;
		}