Exemple #1
0
 public function setBulk(CommentBulk $bulk)
 {
     $this->radix = $bulk->getRadix();
     $this->bulk = $bulk;
     $this->comment = $bulk->comment;
     $this->media = $bulk->media;
     $this->reports = null;
     // format 4chan archive timestamp
     if ($this->radix->archive && !$this->comment->isArchiveTimezone()) {
         $timestamp = new \DateTime(date('Y-m-d H:i:s', $this->comment->timestamp), new \DateTimeZone('America/New_York'));
         $timestamp->setTimezone(new \DateTimeZone('UTC'));
         $this->comment->timestamp = strtotime($timestamp->format('Y-m-d H:i:s'));
         if ($this->comment->timestamp_expired > 0) {
             $timestamp_expired = new \DateTime(date('Y-m-d H:i:s', $this->comment->timestamp_expired), new \DateTimeZone('America/New_York'));
             $timestamp_expired->setTimezone(new \DateTimeZone('UTC'));
             $this->comment->timestamp_expired = strtotime($timestamp_expired->format('Y-m-d H:i:s'));
         }
         $this->comment->setArchiveTimezone(true);
     }
     if ($this->comment->poster_country !== null) {
         $this->comment->poster_country_name = $this->config->get('foolz/foolfuuka', 'geoip_codes', 'codes.' . strtoupper($this->comment->poster_country));
     }
     $num = $this->comment->getPostNum(',');
     $this->comment_factory->posts[$this->comment->thread_num][] = $num;
 }
Exemple #2
0
 public function setBulk(CommentBulk $bulk)
 {
     $this->radix = $bulk->getRadix();
     $this->bulk = $bulk;
     $this->media = $bulk->media;
     // some cases we don't have a comment attached, like banning/deleting
     if (isset($bulk->comment)) {
         $this->op = $bulk->comment->op;
     }
     if ($this->radix->archive) {
         // archive entries for media_filename are already encoded and we risk overencoding
         $this->media->media_filename = html_entity_decode($this->media->media_filename, ENT_QUOTES, 'UTF-8');
     }
     // let's unset 0 sizes so maybe the __get() can save the day
     if (!$this->media->preview_w || !$this->media->preview_h) {
         $this->media->preview_h = 0;
         $this->media->preview_w = 0;
         if ($this->radix->archive && $this->media->spoiler) {
             try {
                 $imgsize = Cache::item('foolfuuka.media.call.spoiler_size.' . $this->radix->id . '.' . $this->media->media_id . '.' . ($this->op ? 'op' : 'reply'))->get();
                 $this->media->preview_w = $imgsize[0];
                 $this->media->preview_h = $imgsize[1];
             } catch (\OutOfBoundsException $e) {
                 $imgpath = $this->getDir(true);
                 if ($imgpath !== null) {
                     $imgsize = @getimagesize($imgpath);
                     Cache::item('foolfuuka.media.call.spoiler_size.' . $this->radix->id . '.' . $this->media->media_id . '.' . ($this->op ? 'op' : 'reply'))->set($imgsize, 86400);
                     if ($imgsize !== false) {
                         $this->media->preview_w = $imgsize[0];
                         $this->media->preview_h = $imgsize[1];
                     }
                 }
             }
         }
     }
     // we set them even for admins
     if ($this->media->banned) {
         $this->media->media_status = static::STATUS_BANNED;
     } elseif ($this->radix->hide_thumbnails && !$this->getAuth()->hasAccess('media.see_hidden')) {
         $this->media->media_status = static::STATUS_FORBIDDEN;
     } else {
         $this->media->media_status = static::STATUS_NORMAL;
     }
 }