simpel vraagje over variabele en function

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Zillion

zillion

08/03/2006 18:34:00
Quote Anchor link
hoi ik maak gebruik van een class die van een swf o.a. de breedte en hoogte in pixels weergeeft :

//show de width en height size
require ("images/swfheader.class.php") ;
$swf->loadswf($flashmovie) ;
$swf->showwidth();
$swf->showheight());

als ik dit in mijn script zet wordt er netjes de breedte en hoogte in pixels ge-echood.

maar hoe krijg ik die waarde nou in een variabele?

dus iets van $flashfilewidht=($swf->showwidth()); maar dat werkt dus niet.
 
PHP hulp

PHP hulp

23/11/2024 14:42:08
 

08/03/2006 18:54:00
Quote Anchor link
dan moet je de class gaan verbouwen want in dit stukje code word er niks geëchoed, post anders de class ff
 
Zillion

zillion

08/03/2006 19:30:00
Quote Anchor link
ok, hier komtie. sry dat ik zo'n n00b ben maar ik kon ook niet snel iets vinden qua tutorial wat uitlegt hoe dat nou zit met o.a. $this->

Volgens mij moet $this->widht; aan een variabele toegekend worden die gereturned wordt ofzo in bijv.
function showwidth


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?PHP
//-----------------------------------------------------------------------------
// SWF HEADER - version 1.0
// Small utility class to determine basic data from a SWF file header
// Does not need any php-flash extension, based on raw binary data reading
//-----------------------------------------------------------------------------
//    SWFHEADER CLASS - PHP SWF header parser
//    Copyright (C) 2004  Carlos Falo Hervás
//
//    This library is free software; you can redistribute it and/or
//    modify it under the terms of the GNU Lesser General Public
//    License as published by the Free Software Foundation; either
//    version 2.1 of the License, or (at your option) any later version.
//
//    This library is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//    Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public
//    License along with this library; if not, write to the Free Software
//    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//-----------------------------------------------------------------------------


class swfheader {

    var
$debug ;                // Output DEBUG info
    var $fname ;                // SWF file analyzed
    var $magic ;                // Magic in a SWF file (FWS or CWS)
    var $compressed ;        // Flag to indicate a compressed file (CWS)
    var $version ;            // Flash version
    var $size ;                    // Uncompressed file size (in bytes)
    var $width ;                // Flash movie native width
    var $height ;                // Flash movie native height
    var $valid ;                // Valid SWF file
    var $fps ;                    // Flash movie native frame-rate
    var $frames ;                // Flash movie total frames

    //---------------------------------------------------------------------------     
    // swfheader($debug) :     Constructor, basically does nothing but initilize
    //                                            debug and data fields
    //---------------------------------------------------------------------------

    function swfheader($debug = false) {
        $this->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<br>" ;
      }


    //---------------------------------------------------------------------------
    // 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 . "<br>" ;
            // 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<br>" ;
                $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 . "<br>" ;
                // Version
                $this->version = ord(fread($fp,1)) ;
                if ($this->debug) echo "DEBUG: Read VERSION: " . $this->version . "<br>" ;
                // 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)) . "<br>" ;
                    $lg += ($t<<(8*$i)) ;
                    }

                $this->size = $lg ;
                if ($this->debug) echo "DEBUG: Total SIZE: " . $this->size . "<br>" ;
                // 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<br>" ;
                $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;$n<strlen($tval);$n++) {
                        $atom = substr($tval,$n,1) ;
                        if ($atom=="1") $val+=$c ;
                        // 2^n
                        $c*=2 ;
                      }

                    // TWIPS to PIXELS
                    $val/=20 ;
                    if ($this->debug) echo " (" . $val . ")<br>" ;
                    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] . "<br>" ;
                // 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 . "<br>" ;
                fclose($fp) ;
                if ($this->debug) echo "DEBUG: Finished processing " . $this->fname . "<br>" ;
                $this->valid =  1 ;
              }
        }
else {
            $this->valid = 0 ;
            if ($this->debug) echo "DEBUG: Failed to open " . $this->fname . "<br>" ;
          }

        return $this->valid ;
      }


    //---------------------------------------------------------------------------     
    // show() : report to screen all the header info
    //---------------------------------------------------------------------------

    function show() {
      if ($this->valid) {
            // FNAME
            echo "<b>FILE: " . $this->fname . "</b><br>" ;
            // Magic
            echo "<b>MAGIC:</b> " . $this->magic ;
            if ($this->compressed) echo " (COMPRESSED)" ;
            echo "<br>" ;
            // Version
            echo "<b>VERSION:</b> " . $this->version . "<br>" ;
            // Size
            echo "<b>SIZE:</b> " . $this->size . " bytes <br>" ;
            // FRAMESIZE
            echo "<b>WIDHT:</B> " . $this->width . "<br>";
            echo "<b>HEIGHT:</B> " . $this->height . "<br>" ;
            // FPS
            echo "<b>FPS:</b> " . $this->fps[1] . "." . $this->fps[0] . " Frames/s <br>" ;
            // FRAMES
            echo "<b>FRAMES:</b> " . $this->frames . " FRAME <br>" ;
        }
else {
            if (file_exists($this->fname))
                echo $this->fname . "is not a valid SWF file<br>" ;
            else
                if ($this->fname=="")
                    echo "SWFHEADER->SHOW : No file loaded<br>" ;
                else
                    echo "SWFHEDAR->SHOW : " . $this->fname . "was not found<br>" ;
          }
      }

    
    //---------------------------------------------------------------------------     
    // show() : report to screen only widht  --- aanpassing
    //---------------------------------------------------------------------------

    function showwidth() {
      if ($this->valid) {
            // FRAMESIZE
            echo $this->widht;
            
                        
        }
else {
            if (file_exists($this->fname))
                echo $this->fname . "is not a valid SWF file<br>" ;
            else
                if ($this->fname=="")
                    echo "SWFHEADER->SHOW : No file loaded<br>" ;
                else
                    echo "SWFHEDAR->SHOW : " . $this->fname . "was not found<br>" ;
          }
      }

    
    //---------------------------------------------------------------------------     
    // show() : report to screen only  height info  --- aanpassing
    //---------------------------------------------------------------------------

    function showheight() {
      if ($this->valid) {
            // FRAMESIZE
            echo $this->height;
            
        }
else {
            if (file_exists($this->fname))
                echo $this->fname . "is not a valid SWF file<br>" ;
            else
                if ($this->fname=="")
                    echo "SWFHEADER->SHOW : No file loaded<br>" ;
                else
                    echo "SWFHEDAR->SHOW : " . $this->fname . "was not found<br>" ;
          }
      }

    
    
    //---------------------------------------------------------------------------
    // display($trans) : just echo <OBJECT>/<EMBED> 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 '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' . $this->version . ',0,0,0" width="' . $this->width . '" height="' . $this->height . '" id="' . $name . '" align="middle">' . $endl ;
            echo '<param name="allowScriptAccess" value="sameDomain" />' . $endl ;
            if ($trans) {
                echo '<param name="wmode" value="transparent" />' . $endl ;
              }

            echo '<param name="movie" value="' . $this->fname . '" />' . $endl ;
            echo '<param name="quality" value="' . $qlty . '" />' . $endl ;
            echo '<param name="bgcolor" value="' . $bgcolor .'" />' . $endl ;
            echo '<embed src="' . $this->fname . '" ';
            if ($trans) echo 'wmode="transparent" ' ;
            echo 'quality="' . $qlty . '" bgcolor="' . $bgcolor . '" width="' . $this->width . '" height="' . $this->height . '" name="' . $name . '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' . $endl ;
            echo '</object>' . $endl ;
        }
else {
            if ($this->debug) {
              if ($this->fname=="") {
                    echo "SWFHEADER->DISPLAY : No loaded file in the object<br>" ;
                }
else {
                    if (file_exists($this->fname)) {
                        echo "SWFHEADER->DISPLAY : " . $this->fname . " is not a valid SWF file<br>" ;
                    }
else {
                        echo "SWFHEADER->DISPLAY : " . $this->fname . " was not found<br>" ;
                        }
                    }
                }
          }
    }
}

?>
Gewijzigd op 08/03/2006 19:39:00 door zillion
 
Zillion

zillion

08/03/2006 21:05:00
Quote Anchor link
Ik ben er al uit.

function showwidth() {
if ($this->valid) {
// FRAMESIZE

$flashfilewidth=$this->width;
return $flashfilewidth;


en in het script $flashfilewidth=$swf->showwidth();
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.