* License and Copyright 2009 Conmunix Networks */ ## Usage example: # # $snapcasa = new Snapcasa(); # echo ''; # class Snapcasa { var $code = 1234; # your snapcasa code var $addr = 'http://snapcasa.com/get.aspx'; # snapcasa address (incl. get.aspx) var $time = 604800; # cache lifetime in seconds (604800 = 1 week) var $size = 's'; # possible values are (l = large, m = medium, s = small, t = tiny) var $tmpdir = '/var/www/vhosts/hendrix/htdocs/tmp/'; # the absolute path to your thumbs (must be writeable! chmod 777 /your/tmpdir) var $thumbs = './tmp/'; # the relative path to your thumbs private function query($url) { return $this->addr.'?'.http_build_query(array('code' => $this->code, 'size' => $this->size, 'url' => $url)); } public function thumb($url) { $filename = md5($url.$this->code.$this->size).'.jpg'; if(!file_exists($this->tmpdir.$filename) or (time()-$this->time >= filemtime($this->tmpdir.$filename)) ) file_put_contents($this->tmpdir.$filename, file_get_contents($this->query($url))); return $this->thumbs.$filename; } } ?>