Пример #1
0
 public static function thumb($file)
 {
     require_once dirname(__FILE__) . '/../phpthumb/phpthumb.class.php';
     $path = File::r2a(File::a2r($file), Settings::$thumbs_dir);
     // We check that the thumb already exists, was created after the image, at the right size
     $goodThumb = false;
     if (file_exists($path) && filectime($file) < filectime($path)) {
         $dim = getimagesize($path);
         $goodThumb = $dim[0] == Settings::$thumbs_size && $dim[1] == Settings::$thumbs_size;
     }
     /// If we need to create a thumb, then this is a new picture
     if (!$goodThumb) {
         if (Judge::is_public($file)) {
             $r = new RSS(Settings::$conf_dir . "/photos_feed.txt");
             $webpath = Settings::$site_address . "?f=" . urlencode(File::a2r($file));
             $r->add(basename($file), $webpath, "<img src='{$webpath}&t=Thb' />");
         }
         /// Create directories
         if (!file_exists(dirname($path))) {
             @mkdir(dirname($path), 0750, true);
         }
         /// Create thumbnail
         $thumb = new phpthumb();
         if (!empty(Settings::$imagemagick_path)) {
             $thumb->config_imagemagick_path = Settings::$imagemagick_path;
         }
         $thumb->setSourceData(file_get_contents($file));
         $thumb->CalculateThumbnailDimensions();
         $thumb->w = Settings::$thumbs_size;
         $thumb->h = Settings::$thumbs_size;
         $thumb->zc = Settings::$thumbs_size;
         $thumb->q = Settings::$quality_mini;
         if (File::Type($file) == 'Image' && Provider::get_orientation_degrees($file) != 0) {
             $thumb->SourceImageToGD();
             //$thumb->ra = Provider::get_orientation_degrees($file);
             $thumb->Rotate();
         }
         $thumb->GenerateThumbnail();
         $thumb->RenderToFile($path);
         chmod($path, 0775);
     }
     /* Implementation of webp... for later.
        $webp = $path.".webp";
        if(!file_exists($webp) ||  filectime($webp) < filectime($path) ){
            imagewebp(imagecreatefromjpeg($path),$webp);
        } */
     return $path;
 }
Пример #2
0
function RSS($id = null, PDO $db = null)
{
    if (!$db) {
        global $db;
    }
    $q = is_numeric($id) ? 'ID=' . $id : 'auto=1';
    $all = $db->query('SELECT ID,name,dsc,url,lang,num FROM ' . PRE . 'rss WHERE ' . $q)->fetchAll(3);
    foreach ($all as $x) {
        require_once './lib/rss.php';
        $rss = new RSS();
        $rss->title = $x[1];
        $rss->desc = $x[2];
        $rss->link = $x[3];
        $rss->base = URL;
        #Pobierz ostatnie nowości
        $q = $db->query('SELECT i.ID,i.name,i.date,i.txt,i.opt,c.name as cat FROM ' . PRE . 'news i JOIN ' . PRE . 'cats c ON i.cat=c.ID WHERE i.access=1 AND
		(c.access=1 OR c.access="' . $x[4] . '") ORDER BY i.ID DESC LIMIT ' . $x[5]);
        foreach ($q as $item) {
            $rss->add(array('ID' => $item['ID'], 'title' => $item['name'], 'text' => $item['opt'] & 1 ? nl2br($item['txt']) : $item['txt'], 'cat' => $item['cat'], 'date' => date('r', strtotime($item['date'] . ' UTC')), 'url' => URL . url('news/' . $item['ID'])));
        }
        $rss->save('rss/' . $x[0] . '.xml');
    }
}