Ejemplo n.º 1
0
 /**
  * method for getting html for front page. If no logo has been 
  * uploaded. You will get logo as html
  * @param type $options options to give to html::createHrefImage
  * @return string $str the html compsoing the logo or main title
  */
 public static function getLogoHTML($options = array())
 {
     $logo = conf::getMainIni('logo');
     if (!$logo) {
         $title = $_SERVER['HTTP_HOST'];
         $link = html::createLink('/', $title);
         return $str = "<div id=\"logo_title\">{$link}</div>";
     } else {
         $file = "/logo/" . conf::getMainIni('logo');
         $src = conf::getWebFilesPath($file);
         if (!isset($options['alt'])) {
             $options['alt'] = $_SERVER['HTTP_HOST'];
         }
         $href = html::createHrefImage('/', $src, $options);
         $str = '<div id="logo_img">' . $href . '</div>' . "\n";
         //die($str);
         return $str;
     }
 }
 /**
  * Images are stored in database. 
  * @param type $url
  * @return boolean
  */
 public function checkImage($url)
 {
     $id = direct::fragment(2, $url);
     $title = direct::fragment(3, $url);
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getWebFilesPath($path);
     $image_url = conf::getSchemeWithServerName() . $url;
     $code = headers::getReturnCode($image_url);
     if ($code != 200) {
         log::error("Could not get file content (image). Got: {$code} " . $image_url);
         return false;
     }
     return $url;
 }
 /**
  * Images are stored in database. 
  * @param type $url
  * @return boolean
  */
 public function saveImage($url)
 {
     $id = direct::fragment(2, $url);
     $title = direct::fragment(3, $url);
     $title = rawurlencode($title);
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getSchemeWithServerName() . conf::getWebFilesPath($path);
     $code = headers::getReturnCode($web_path);
     if ($code != '200') {
         log::error("Could not get file content (image). Got: {$code} " . $web_path . ' in ' . __CLASS__);
         return false;
     }
     return $save_path;
 }
 protected function saveImage($url)
 {
     $id = direct::fragment(2, $url);
     $ext = file::getExtension($url);
     $title = md5(uniqid()) . ".{$ext}";
     $i = new image();
     $file = $i->getFile($id);
     if (empty($file)) {
         return '';
     }
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getWebFilesPath($path);
     $dir = dirname($path);
     file::mkdir($dir);
     file_put_contents($save_path, $file['file']);
     return $web_path;
 }
 protected function saveImage($url)
 {
     $id = direct::fragment(2, $url);
     $title = direct::fragment(3, $url);
     $path = "/images/{$id}/{$title}";
     $save_path = conf::getFullFilesPath($path);
     $web_path = conf::getWebFilesPath($path);
     $image_url = conf::getSchemeWithServerName() . $url;
     $code = headers::getReturnCode($image_url);
     if ($code != 200) {
         log::error("Could not get file content (image). Got: {$code} " . $image_url);
         return '';
     } else {
         $file = file_get_contents($image_url);
     }
     // make dir
     $dir = dirname($path);
     file::mkdir($dir);
     file_put_contents($save_path, $file);
     return $web_path;
 }