Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
TypeIco.php
01 <?php
02
03 /**
04 * fast-image-size image type ico
05 * @package fast-image-size
06 * @copyright (c) Marc Alexander <admin@m-a-styles.de>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace FastImageSize\Type;
13
14 class TypeIco extends TypeBase
15 {
16 /** @var string ICO reserved field */
17 const ICO_RESERVED = 0;
18
19 /** @var int ICO type field */
20 const ICO_TYPE = 1;
21
22 /**
23 * {@inheritdoc}
24 */
25 public function getSize($filename)
26 {
27 // Retrieve image data for ICO header and header of first entry.
28 // We assume the first entry to have the same size as the other ones.
29 $data = $this->fastImageSize->getImage($filename, 0, 2 * self::LONG_SIZE);
30
31 if ($data === false)
32 {
33 return;
34 }
35
36 // Check if header fits expected format
37 if (!$this->isValidIco($data))
38 {
39 return;
40 }
41
42 $size = unpack('Cwidth/Cheight', substr($data, self::LONG_SIZE + self::SHORT_SIZE, self::SHORT_SIZE));
43
44 $this->fastImageSize->setSize($size);
45 $this->fastImageSize->setImageType(IMAGETYPE_ICO);
46 }
47
48 /**
49 * Return whether image is a valid ICO file
50 *
51 * @param string $data Image data string
52 *
53 * @return bool True if file is a valid ICO file, false if not
54 */
55 protected function isValidIco($data)
56 {
57 // Get header
58 $header = unpack('vreserved/vtype/vimages', $data);
59
60 return $header['reserved'] === self::ICO_RESERVED && $header['type'] === self::ICO_TYPE && $header['images'] > 0 && $header['images'] <= 255;
61 }
62 }
63