Esempio n. 1
0
function fourChanFormat($data)
{
    $returnArr = array();
    $returnArr['no'] = (int) $data['no'];
    $returnArr['now'] = date("m/d/y(D)H:i:s", $data['time']);
    $returnArr['name'] = $data['name'];
    $returnArr['com'] = $data['comment'];
    if ($data['tim'] > 0) {
        $returnArr['filename'] = $data['filename'];
        $returnArr['ext'] = $data['ext'];
        $returnArr['w'] = (int) $data['w'];
        $returnArr['h'] = (int) $data['h'];
        list($returnArr['tn_w'], $returnArr['tn_h']) = tn_Size($data['w'], $data['h']);
        $returnArr['tim'] = (int) $data['tim'];
    }
    $returnArr['time'] = (int) $data['time'];
    if ($data['md5'] != "") {
        $returnArr['md5'] = $data['md5'];
        $returnArr['fsize'] = (int) $data['fsize'];
    }
    if ($data['subject'] != "") {
        $returnArr['sub'] = $data['subject'];
    }
    if ($data['trip'] != "") {
        $returnArr['trip'] = $data['trip'];
    }
    if ($data['email'] != "") {
        $returnArr['email'] = $data['email'];
    }
    $returnArr['resto'] = $data['threadid'];
    $returnArr['id'] = $data['id'] != '' ? $data['id'] : $data['ns_id'] != '' ? $data['ns_id'] : '';
    if ($data['no'] == $data['threadid']) {
        $returnArr['bumplimit'] = 0;
        $returnArr['imagelimit'] = 0;
        $returnArr['replies'] = 0;
        $returnArr['images'] = 0;
    }
    return $returnArr;
}
Esempio n. 2
0
 private static function makeImageBlock(Post $post, $display)
 {
     /**
      * The following block is only for posts with an image attached.
      */
     if ($post->hasImage() && !$post->imgbanned) {
         $md5Filename = str_replace('/', '-', $post->md5);
         $humanFilesize = $post->fsize > 0 ? human_filesize($post->fsize) . ", " : "";
         list($thumbW, $thumbH) = tn_Size($post->w, $post->h);
         if ($display == self::DISPLAY_OP && ($post->w > 125 || $post->h > 125)) {
             //OP thumbs are 250x250 rather than 125x125
             $thumbW *= 2;
             $thumbH *= 2;
         }
         $thumb = "<a class='fileThumb' href='{$post->getImgUrl()}' target='_blank'>" . "<img src='{$post->getThumbUrl()}' alt='' data-md5='{$post->md5}' data-md5-filename='{$md5Filename}' data-ext='{$post->ext}' data-full-img='{$post->getImgUrl()}' width='{$thumbW}' height='{$thumbH}' data-width='{$post->w}' data-height='{$post->h}' />" . "</a>";
         $chanMedia = $post->board == 'f' ? '//i.4cdn.org/f/src/' . $post->filename . $post->ext : '//i.4cdn.org/' . $post->board . '/src/' . $post->tim . $post->ext;
         $fullImgLink = $post->getExtension() == '.swf' ? $post->getSwfUrl() : $post->getImgUrl();
         $fileDiv = div('', 'file')->set('id', 'f' . $post->no);
         $fileInfo = div('', 'fileInfo');
         $fileText = span('', 'fileText')->set('id', 'fT' . $post->no)->set('data-filename', $post->filename . $post->ext);
         $fileText->append(a($post->filename . $post->ext, $chanMedia)->set("target", "_blank")->set("title", $post->filename . $post->ext)->set("class", 'imageLink')->set('rel', 'noreferrer'))->append('&nbsp;')->append("({$humanFilesize}{$post->w}x{$post->h}, " . ($post->board == 'f' ? $post->tag . ")" : "<span title='{$post->filename}{$post->ext}'>{$post->tim}{$post->ext}</span>)&nbsp;"));
         if ($post->getExtension() != '.swf') {
             $fileText->append(a('iqdb', "http://iqdb.org/?url={$post->getThumbUrl()}")->set("target", "_blank") . '&nbsp;' . a('google', "http://www.google.com/searchbyimage?image_url={$post->getThumbUrl()}")->set("target", "_blank"));
         }
         $fileText->append('&nbsp;' . a('reposts', "/{$post->board}/search/md5/{$post->getMD5Hex()}")->set("target", "_blank") . '&nbsp;' . a('full', $fullImgLink)->set("target", '_blank'));
         $fileInfo->append($fileText);
         $fileDiv->append($fileInfo);
         $fileDiv->append($thumb);
         return $fileDiv;
     } else {
         if ($post->imgbanned) {
             return Site::parseHtmlFragment("post/banned_image.html");
         } else {
             return "";
         }
     }
 }
Esempio n. 3
0
 /**
  * Returns the post as a PHP array, good for integrating into API calls.
  * @return array
  */
 function asArray()
 {
     $returnArr = [];
     $returnArr['no'] = (int) $this->no;
     $returnArr['now'] = $this->getChanTime();
     $returnArr['time'] = (int) $this->time;
     $returnArr['name'] = $this->name;
     $returnArr['com'] = $this->com;
     if ($this->tim > 0 && !$this->imgbanned) {
         $returnArr['filename'] = $this->filename;
         $returnArr['ext'] = $this->ext;
         $returnArr['w'] = (int) $this->w;
         $returnArr['h'] = (int) $this->h;
         list($returnArr['tn_w'], $returnArr['tn_h']) = tn_Size($this->w, $this->h);
         $returnArr['tim'] = $this->getTim();
         $returnArr['md5'] = str_replace("-", "/", $this->md5);
         $returnArr['md5_hex'] = bin2hex($this->md5bin);
         $returnArr['fsize'] = (int) $this->fsize;
     }
     if ($this->sub != "") {
         $returnArr['sub'] = $this->sub;
     }
     if ($this->trip != "") {
         $returnArr['trip'] = $this->trip;
     }
     if ($this->email != "") {
         $returnArr['email'] = $this->email;
     }
     if ($this->id != '') {
         $returnArr['id'] = $this->id;
     }
     $returnArr['resto'] = (int) $this->threadid;
     if ($this->no == $this->threadid) {
         $returnArr['bumplimit'] = 0;
         $returnArr['imagelimit'] = 0;
         $returnArr['replies'] = 0;
         $returnArr['images'] = 0;
     }
     return $returnArr;
 }