vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   AnyMedia BBCode for 3.5.x (https://vborg.vbsupport.ru/showthread.php?t=106239)

imported_yesonline 01-25-2006 10:59 AM

Excellent work, just the one I am looking for. :)

nitro 01-25-2006 11:16 AM

Works great on my test install, I am wondering tho should there be a first post restricion at all as a page full of say swf's added with the media tag is going take quite some time to load. I just added 3 in firefox and as they are cached each time no real problem but then I opened the same page in IE which of course wasnt cached and it took some loading time to completely load the page.

I think it should be conditionaled to certain forum ids so it cannot be used where its not wanted and restriced to first post of the thread. Im sure this can be covered with an if /if around the template edit. :)

jlkimball11 01-25-2006 11:28 AM

Quote:

Originally Posted by Crist
Sorry for my lapsus...
I used the Chinese Product ID write the Code Mods of the English Version.

Now I've Updated the zip pack already,
One who failed to install the hack may download the new pack,
and Redo the Code Modifications. (Just redo this step,others are right.)


:surprised:

OK! Done. Thanks you. Very cool :nervous:

yack 01-25-2006 12:55 PM

Quote:

Originally Posted by sinoeu
A MUST to include in the official vbb version! Crist, you rock!!! :up:

A MUST to include in the official vbb version.

凉鞋,俺挺你,就是挺你,挺着你。

Guest210212002 01-25-2006 02:15 PM

Thank you Crist, that worked perfectly. :D

Great hack!

Mastar 01-25-2006 04:10 PM

I did the update but now when I make a post with the [media][/media] tags, the thread doesn't show.

Can you please come to the site and see for yourself and see what is wrong?

www.thebedrocktavern.com


Code:

  }

    /**
  * Handles a match of the [media] tag that will be displayed as an media object
  *
  * Author    Crist Chsu @ VBZH
  *
  * @param  string  The URL to the media.
  *
  * @param  string  If tag has option, the width, height, and whether to autoplay.
  *
  * @return  string  Object code of the contain media.
  */
  function handle_bbcode_media($text, $options='')
  {
    global $vbulletin, $vbphrase, $stylevar;
    if(!$this -> is_wysiwyg())
    {
      $media['url'] = $media['link'] = htmlspecialchars_uni( strip_bbcode( strip_tags( $text ) ) );
      $extensions = explode( ',' , trim( $this->registry->options['anymediasupport'] ) );
      $extensions = iif( is_array( $extensions ) , $extensions , array() );
      if ( !empty( $options ) )
      {
        $option_array=explode( ',' , $options );
        if (  count( $option_array ) > 1 AND count( $option_array ) < 5 )
        {
          $media['width'] = iif( isset( $option_array[0] ) AND !empty( $option_array[0] ) AND ereg( '^[0-9]{1,3}$' , $option_array[0] ), $option_array[0] , $this->registry->options['anymediawidth'] );
          $media['height'] = iif( isset( $option_array[1] ) AND !empty( $option_array[1] ) AND ereg( '^[0-9]{1,3}$' , $option_array[1] ), $option_array[1] , $this->registry->options['anymediaheight'] );
          $media['autoplay'] = iif( isset( $option_array[2] ) AND !empty( $option_array[2] ) AND in_array( $option_array[2] , array( 'true' , 'yes' , '1' ) ) , 'true' , 'false' );
          $media['extension'] = iif( isset( $option_array[3] ) AND !empty( $option_array[3] ) AND in_array( $option_array[3] , $extensions ) , $option_array[3] );
        }
      }
      $media['width'] = iif( isset( $media['width'] ) AND !empty( $media['width'] ) , $media['width'] , $this->registry->options['anymediawidth'] );
      $media['height'] = iif( isset( $media['height'] ) AND !empty( $media['height'] ) , $media['height'] , $this->registry->options['anymediaheight'] );
      $media['autoplay'] = iif( isset( $media['autoplay'] ) AND !empty( $media['autoplay'] ) , $media['autoplay'] , iif($this->registry->options['anymediaautoplay'],'true','false') );
      $media['extension'] = iif( isset( $media['extension'] ) AND !empty( $media['extension'] ) , $media['extension'] , strtolower( file_extension( $text ) ) );
      if ( in_array( $media['extension'] , $extensions ) )
      {
        switch ( $media['extension'] )
        {
          // MP3
          case 'mp3':
            if ( $this->registry->options['anymediamp3player'] )
            {
              $media['url'] = $this->registry->options['bburl'].'/players/mp3player.swf?file=' . htmlentities( urlencode( $media['url'] ) ) . '&autoPlay=' . $media['autoplay'];
              $media['autoplay'] = "true";
              $media['height'] = 20;
              $media['mime']='application/x-shockwave-flash';
              $media['type']='adobe_flash';
            }
            else
            {
              $media['height']=45;
              $media['mime']='application/x-mplayer2';
              $media['type']='windows_media';
            }
            break;
          // Adobe Flash
          case 'flv':
            $media['url'] = $this->registry->options['bburl'].'/players/flvplayer.swf?videoUrl=' . htmlentities( urlencode( $media['url'] ) ) . '&thumbnailUrl=' . urlencode( $this->registry->options['bburl'].'/clear.gif' ) . '&playerMode=embedded';
            $media['autoplay'] = "true";
            $media['height'] += 27;
          case 'swf':
            $media['mime']='application/x-shockwave-flash';
            $media['type']='adobe_flash';
            break;
          case 'spl':
            $media['mime']='application/futuresplash';
            $media['type']='adobe_flash';
            break;
          // Quick Time
          case 'mov':
          case 'qt':
          case 'mqv':
            $media['mime']='video/quicktime';
            $media['type']='quick_time';
            break;
          case 'mpeg':
          case 'mpg':
          case 'm1s':
          case 'm1v':
          case 'm1a':
          case 'm75':
          case 'm15':
          case 'mp2':
          case 'mpm':
          case 'mpv':
          case 'mpa':
            $media['mime']='video/x-mpeg';
            $media['type']='quick_time';
            break;
          case 'flc':
          case 'fli':
          case 'cel':
            $media['mime']='video/flc';
            $media['type']='quick_time';
            break;
          case 'rtsp':
          case 'rts':
            $media['mime']='application/x-rtsp';
            $media['type']='quick_time';
            break;
          case '3gp':
          case '3gpp':
            $media['mime']='video/3gpp';
            $media['type']='quick_time';
            break;
          case '3g2':
          case '3gp2':
            $media['mime']='video/3gpp2';
            $media['type']='quick_time';
            break;
          case 'sdv':
            $media['mime']='video/sd-video';
            $media['type']='quick_time';
            break;
          case 'amc':
            $media['mime']='application/x-mpeg';
            $media['type']='quick_time';
            break;
          case 'mp4':
            $media['mime']='video/mp4';
            $media['type']='quick_time';
            break;
          case 'sdp':
            $media['mime']='application/sdp';
            $media['type']='quick_time';
            break;
          // Real Media
          case 'rm':
          case 'rmvb':
          case 'ra':
          case 'rv':
          case 'ram':
          case 'smil':
            $media['mime']='audio/x-pn-realaudio-plugin';
            $media['type']='real_media';
            break;
          // Windows Media
          case 'wma':
          case 'ogg':
          case 'ape':
          case 'mid':
          case 'midi':
            $media['height']=45;
          case 'asf':
          case 'asx':
          case 'wm':
          case 'wmv':
          case 'wax':
          case 'wvx':
          case 'avi':
            $media['mime']='application/x-mplayer2';
            $media['type']='windows_media';
            break;
          // Adobe PDF
          case 'pdf':
            $media['mime']='application/pdf';
            $media['type']='adobe_pdf';
            break;
          case 'fdf':
            $media['mime']='application/vnd.fdf';
            $media['type']='adobe_pdf';
            break;
          case 'xfdf':
            $media['mime']='application/vnd.adobe.xfdf';
            $media['type']='adobe_pdf';
            break;
          case 'xdp':
            $media['mime']='application/vnd.adobe.xdp+xml';
            $media['type']='adobe_pdf';
            break;
          case 'xfd':
            $media['mime']='application/vnd.adobe.xfd+xml';
            $media['type']='adobe_pdf';
            break;
          // Images
          case 'gif':
          case 'jpg':
          case 'jpeg':
          case 'bmp':
          case 'png':
          case 'xpm':
            $media['type']='image';
            break;
          // Torrent
          case 'torrent':
            include_once("bencode.php");
            $content = @file_get_contents( $media['url'] );
            if ( $content )
            {
              $bencode = new BEncodeLib();
              $torrent = $bencode->bdecode($content);
              if ( is_array( $torrent ) )
              {
                $media['announce'] = $torrent['announce'];
                $media['created_by'] = $torrent['created by'];
                $media['creation_date'] = iif( $torrent['creation date'] , vbdate( $vbulletin->options['dateformat'], $torrent['creation date'], true ) . " <span class=\"time\">" . vbdate( $vbulletin->options['timeformat'], $torrent['creation date'], true )."</span>" );
                $media['encoding'] = $torrent['encoding'];
                $media['codepage'] = $torrent['codepage'];
                $media['name'] = iif( $torrent['info']['name.utf-8'] , $torrent['info']['name.utf-8'] , $torrent['info']['name']);
                $media['length'] = iif( $torrent['info']['length'] , $this -> format_size( $torrent['info']['length'] ) );
                $media['piece_length'] = iif( $torrent['info']['piece length'] , $this -> format_size( $torrent['info']['piece length'] ) );
                $media['publisher'] = iif( $torrent['info']['publisher.utf-8'] , $torrent['info']['publisher.utf-8'] , $torrent['info']['publisher']);
                $media['publisher_url'] = iif( $torrent['info']['publisher-url.utf-8'] , $torrent['info']['publisher-url.utf-8'] , $torrent['info']['publisher-url']);
                if ( is_array( $torrent['nodes'] ) )
                {
                  foreach ( $torrent['nodes'] as $key => $value )
                  {
                    $media['nodes'] .= $torrent['nodes'][$key][0] . ":" . $torrent['nodes'][$key][1] . "<br />";
                  }
                }
                if ( is_array( $torrent['info']['files'] ) )
                {
                  foreach ( $torrent['info']['files'] as $key => $value )
                  {
                    $media['files'] .= iif( $torrent['info']['files'][$key]['path'] , implode( '/' , $torrent['info']['files'][$key]['path.utf-8'] ) , implode( '/' , $torrent['info']['files'][$key]['path'] ) ) . " ( " . $this -> format_size( $torrent['info']['files'][$key]['length'] ) . " ) <br />";
                  }
                }
                $media['type']='torrent';
              }
              else
              {
                $media['type'] = 'torrent_error';
              }
            }
            else
            {
              $media['type'] = 'torrent_error';
            }
            break;
          default:
            $media['type'] = 'unknown';
        }
      }
      else
      {
        $media['type']="unknown";
      }
      $media['id']=rand();
      $media['layout']=$media['width']+$stylevar['cellpadding']*2+$stylevar['cellspacing']*4;
      eval('$text = "' . fetch_template('anymedia') . '";');
    }
    else
    {
      if ( !empty( $options ) )
      {
        $text = "[MEDIA=".$options."]" . $text . "[/MEDIA]" ;
      }
      else
      {
        $text = "[MEDIA]" . $text . "[/MEDIA]" ;
      }
    }
    return $text;
  }

  /**
  * Formatted a size.
  *
  * Author    Crist Chsu @ VBZH
  *
  * @param  integer  The size in byte.
  *
  * @return  string  The formatted size.
  */
  function format_size($size)
  {
    if ( $size < 1024000 )
    {
      return vb_number_format( $size / 1024 ) . " KB";
    }
    elseif ( $size < 1048576000 )
    {
      return vb_number_format( $size / 1048576 ) . " MB";
    }
    elseif ( $size < 1073741824000 )
    {
      return vb_number_format( $size / 1073741824 ) . " GB";
    }
    else
    {
      return vb_number_format( $size / 1099511627776 ) . " TB";
    }
  }
  /**
  * Emulates the behavior of a pre tag in HTML. Tabs and multiple spaces
  * are replaced with spaces mixed with non-breaking spaces. Usually combined
  * with code tags. Note: this still allows the browser to wrap lines.
  *
  * @param  string  Text to convert. Should not have <br> tags!
  *
  * @param  string  Converted text
  */
  function emulate_pre_tag($text)


Guest210212002 01-25-2006 04:21 PM

I had to reimport the product to get it to work, in addition to the new code edit.

Also, depending on how you have it configured, the template compressor hack breaks this.

Mastar 01-25-2006 05:00 PM

Quote:

Originally Posted by Chris-777
I had to reimport the product to get it to work, in addition to the new code edit.

Also, depending on how you have it configured, the template compressor hack breaks this.

I reimported the product also & I don't have the template compressor installed

whatelse counld be wrong?

imported_predatorkill 01-25-2006 06:42 PM

In IE works perfectly but in Firefox it says "Install Missing Plugins"

When i click on that is says "Unknown plugin" :ermm: :ermm:

Great hack tho!It wont stream the video,it will just cache it all and play it,right?

nitro 01-25-2006 07:50 PM

Im streaming avi in FF right now with it on my testbed accross my home network its running fine.

@imported_predatorkill What type of media file you put in ?

My question now is it seem there is no restriction. Someone could load the first page of a thread with 10 1.5 GB avi's and it will sit there loading each one eventually. You can even use the ftp:// protocol in the tags :o One avi will load quickly but how is a thread page going to handle multiple posts with media tages or even a single post with multiple media tags. :D


All times are GMT. The time now is 03:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05141 seconds
  • Memory Usage 1,806KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete