*** openx-2.6.3/lib/OA/Creative/File.php.orig Tue Nov 4 14:31:50 2008 --- openx-2.6.3/lib/OA/Creative/File.php Tue Nov 18 10:35:23 2008 *************** *** 80,86 **** } if (!($aImage = @getimagesize($filePath))) { ! return new PEAR_Error("Unrecognized image file format"); } if (!isset($aTypes[$aImage[2]])) { --- 80,91 ---- } if (!($aImage = @getimagesize($filePath))) { ! $swf = new swfheader(false); ! if ($swf->loadswf($filePath)) { ! $aImage = array($swf->width, $swf->height, 4); ! } else { ! return new PEAR_Error("Unrecognized image file format"); ! } } if (!isset($aTypes[$aImage[2]])) { *************** *** 262,265 **** } } ! ?> \ No newline at end of file --- 267,533 ---- } } ! ?> ! debug = $debug ; ! $this->init() ; ! } ! ! //--------------------------------------------------------------------------- ! // init() : initialize the data fields to "empty" values ! //--------------------------------------------------------------------------- ! function init() { ! $this->valid = false ; ! $this->fname = "" ; ! $this->magic = "" ; ! $this->compressed = false ; ! $this->version = 0 ; ! $this->width = 0 ; ! $this->height = 0 ; ! $this->size = 0 ; ! $this->frames = 0 ; ! $this->fps[] = Array() ; ! if ($this->debug) echo "DEBUG: Data values initialized
" ; ! } ! ! //--------------------------------------------------------------------------- ! // loadswf($filename) : loads $filename and stores data from it's header ! //--------------------------------------------------------------------------- ! function loadswf($filename) { ! $this->fname = $filename ; ! $fp = @fopen($filename,"rb") ; ! if ($fp) { ! if ($this->debug) echo "DEBUG: Opened " . $this->fname . "
" ; ! // Read MAGIC FIELD ! $this->magic = fread($fp,3) ; ! if ($this->magic!="FWS" && $this->magic!="CWS") { ! if ($this->debug) echo "DEBUG: " . $this->fname . " is not a valid/supported SWF file
" ; ! $this->valid = 0 ; ! } else { ! // Compression ! if (substr($this->magic,0,1)=="C") $this->compressed = true ; ! else $this->compressed = false ; ! if ($this->debug) echo "DEBUG: Read MAGIC signature: " . $this->magic . "
" ; ! // Version ! $this->version = ord(fread($fp,1)) ; ! if ($this->debug) echo "DEBUG: Read VERSION: " . $this->version . "
" ; ! // Size ! $lg = 0 ; ! // 4 LSB-MSB ! for ($i=0;$i<4;$i++) { ! $t = ord(fread($fp,1)) ; ! if ($this->debug) echo "DEBUG: Partial SIZE read: " . ($t<<(8*$i)) . "
" ; ! $lg += ($t<<(8*$i)) ; ! } ! $this->size = $lg ; ! if ($this->debug) echo "DEBUG: Total SIZE: " . $this->size . "
" ; ! // RECT... we will "simulate" a stream from now on... read remaining file ! $buffer = fread($fp,$this->size) ; ! if ($this->compressed) { ! // First decompress GZ stream ! $buffer = gzuncompress($buffer,$this->size) ; ! } ! $b = ord(substr($buffer,0,1)) ; ! $buffer = substr($buffer,1) ; ! $cbyte = $b ; ! $bits = $b>>3 ; ! if ($this->debug) echo "DEBUG: RECT field size: " . $bits . " bits
" ; ! $cval = "" ; ! // Current byte ! $cbyte &= 7 ; ! $cbyte<<= 5 ; ! // Current bit (first byte starts off already shifted) ! $cbit = 2 ; ! // Must get all 4 values in the RECT ! for ($vals=0;$vals<4;$vals++) { ! $bitcount = 0 ; ! while ($bitcount<$bits) { ! if ($cbyte&128) { ! $cval .= "1" ; ! } else { ! $cval.="0" ; ! } ! $cbyte<<=1 ; ! $cbyte &= 255 ; ! $cbit-- ; ! $bitcount++ ; ! // We will be needing a new byte if we run out of bits ! if ($cbit<0) { ! $cbyte = ord(substr($buffer,0,1)) ; ! $buffer = substr($buffer,1) ; ! $cbit = 7 ; ! } ! } ! // O.k. full value stored... calculate ! $c = 1 ; ! $val = 0 ; ! // Reverse string to allow for SUM(2^n*$atom) ! if ($this->debug) echo "DEBUG: RECT binary value: " . $cval ; ! $tval = strrev($cval) ; ! for ($n=0;$ndebug) echo " (" . $val . ")
" ; ! switch ($vals) { ! case 0: ! // tmp value ! $this->width = $val ; ! break ; ! case 1: ! $this->width = $val - $this->width ; ! break ; ! case 2: ! // tmp value ! $this->height = $val ; ! break ; ! case 3: ! $this->height = $val - $this->height ; ! break ; ! } ! $cval = "" ; ! } ! // Frame rate ! $this->fps = Array() ; ! for ($i=0;$i<2;$i++) { ! $t = ord(substr($buffer,0,1)) ; ! $buffer = substr($buffer,1) ; ! $this->fps[] = $t ; ! } ! if ($this->debug) echo "DEBUG: Frame rate: " . $this->fps[1] . "." . $this->fps[0] . "
" ; ! // Frames ! $this->frames = 0 ; ! for ($i=0;$i<2;$i++) { ! $t = ord(substr($buffer,0,1)) ; ! $buffer = substr($buffer,1) ; ! $this->frames += ($t<<(8*$i)) ; ! } ! if ($this->debug) echo "DEBUG: Frames: " . $this->frames . "
" ; ! fclose($fp) ; ! if ($this->debug) echo "DEBUG: Finished processing " . $this->fname . "
" ; ! $this->valid = 1 ; ! } ! } else { ! $this->valid = 0 ; ! if ($this->debug) echo "DEBUG: Failed to open " . $this->fname . "
" ; ! } ! return $this->valid ; ! } ! ! //--------------------------------------------------------------------------- ! // show() : report to screen all the header info ! //--------------------------------------------------------------------------- ! function show() { ! if ($this->valid) { ! // FNAME ! echo "FILE: " . $this->fname . "
" ; ! // Magic ! echo "MAGIC: " . $this->magic ; ! if ($this->compressed) echo " (COMPRESSED)" ; ! echo "
" ; ! // Version ! echo "VERSION: " . $this->version . "
" ; ! // Size ! echo "SIZE: " . $this->size . " bytes
" ; ! // FRAMESIZE ! echo "WIDHT: " . $this->width . "
"; ! echo "HEIGHT: " . $this->height . "
" ; ! // FPS ! echo "FPS: " . $this->fps[1] . "." . $this->fps[0] . " Frames/s
" ; ! // FRAMES ! echo "FRAMES: " . $this->frames . " FRAME
" ; ! } else { ! if (file_exists($this->fname)) ! echo $this->fname . "is not a valid SWF file
" ; ! else ! if ($this->fname=="") ! echo "SWFHEADER->SHOW : No file loaded
" ; ! else ! echo "SWFHEDAR->SHOW : " . $this->fname . "was not found
" ; ! } ! } ! ! //--------------------------------------------------------------------------- ! // display($trans) : just echo / tags for the parsed file, if ! // trans is set, WMODE is set to transparent ! //--------------------------------------------------------------------------- ! function display($trans = false, $qlty = "high", $bgcolor = "#ffffff", $name = "") { ! ! $endl = chr(13) ; ! ! if ($this->valid) { ! if ($name=="") $name = substr($this->fname,0,strrpos($this->fname,".")) ; ! echo '' . $endl ; ! echo '' . $endl ; ! if ($trans) { ! echo '' . $endl ; ! } ! echo '' . $endl ; ! echo '' . $endl ; ! echo '' . $endl ; ! echo '' . $endl ; ! echo '' . $endl ; ! } else { ! if ($this->debug) { ! if ($this->fname=="") { ! echo "SWFHEADER->DISPLAY : No loaded file in the object
" ; ! } else { ! if (file_exists($this->fname)) { ! echo "SWFHEADER->DISPLAY : " . $this->fname . " is not a valid SWF file
" ; ! } else { ! echo "SWFHEADER->DISPLAY : " . $this->fname . " was not found
" ; ! } ! } ! } ! } ! } ! } ! ?>