<?php
include_once('class.mysql.php');
class Picasa
{
	private $id_empresa;

	public function __construct()
	{
		ob_start();
		session_start();
		$this->id_empresa = $_SESSION["fild_id_empresa"];
		$mysqlCom = new MysqlConnect();
	}



	public function PicasaUmaFoto($id_evento, $tamanho = '72')
	{
		$sql = "select usuario, album, capa from evento_picasa
						where id_evento = $id_evento
						and id_empresa = $this->id_empresa";
		$qry = mysqli_query($mysqlCom->connect(), $sql);
		while ($row = mysqli_fetch_object($qry)) {
			$usuario = $row->usuario;
			$album   = $row->album;
			$capa    = $row->capa;
		}

		if ($usuario != '') {
			if ($capa == '') {
				$tt = file_get_contents("http://picasaweb.google.com/data/feed/api/user/$usuario/album/$album");
				$xml = simplexml_load_string($tt);

				for ($i = 0; $i < 1; $i++) {
					$nome = $media->{title};
					$media = $xml->{"entry"}[$i];
					echo $media->{"content"}[0]->attributes()->src . '?imgmax=' . $tamanho;
				}
			} else {
				echo $capa . '?imgmax=' . $tamanho;
			}
		} else {
			echo 'img/perfil.png';
		}
	}
}
