Linux unitednationsplay.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
nginx/1.20.1
Server IP : 188.130.139.92 & Your IP : 18.227.102.59
Domains :
Cant Read [ /etc/named.conf ]
User : web
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
home /
www /
3 /
endroid /
qr-code /
src /
Writer /
Delete
Unzip
Name
Size
Permission
Date
Action
AbstractWriter.php
2.47
KB
-rw-r--r--
2020-11-27 09:00
BinaryWriter.php
962
B
-rw-r--r--
2020-11-27 09:00
DebugWriter.php
1.62
KB
-rw-r--r--
2020-11-27 09:00
EpsWriter.php
2.05
KB
-rw-r--r--
2020-11-27 09:00
FpdfWriter.php
4.2
KB
-rw-r--r--
2020-11-27 09:00
PngWriter.php
8.27
KB
-rw-r--r--
2020-11-27 09:00
SvgWriter.php
12.55
KB
-rw-r--r--
2021-03-22 09:00
WriterInterface.php
741
B
-rw-r--r--
2020-11-27 09:00
Save
Rename
<?php declare(strict_types=1); /* * (c) Jeroen van den Enden <info@endroid.nl> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace Endroid\QrCode\Writer; use Endroid\QrCode\Exception\GenerateImageException; use Endroid\QrCode\Exception\MissingLogoHeightException; use Endroid\QrCode\Exception\ValidationException; use Endroid\QrCode\QrCodeInterface; use SimpleXMLElement; class SvgWriter extends AbstractWriter { public function writeString(QrCodeInterface $qrCode): string { $options = $qrCode->getWriterOptions(); if ($qrCode->getValidateResult()) { throw new ValidationException('Built-in validation reader can not check SVG images: please disable via setValidateResult(false)'); } $data = $qrCode->getData(); $svg = new SimpleXMLElement('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/>'); $svg->addAttribute('version', '1.1'); $svg->addAttribute('width', $data['outer_width'].'px'); $svg->addAttribute('height', $data['outer_height'].'px'); $svg->addAttribute('viewBox', '0 0 '.$data['outer_width'].' '.$data['outer_height']); $svg->addChild('defs'); // Block definition $block_id = isset($options['rect_id']) && $options['rect_id'] ? $options['rect_id'] : 'block'; $blockDefinition = $svg->defs->addChild('circle'); $blockDefinition->addAttribute('id', $block_id); $blockDefinition->addAttribute('r', strval($data['block_size']/2.5)); $blockDefinition->addAttribute('cy', strval(0)); //$blockDefinition->addAttribute('width', strval($data['block_size'])); //$blockDefinition->addAttribute('height', strval($data['block_size'])); $blockDefinition->addAttribute('fill', '#'.sprintf('%02x%02x%02x', $qrCode->getForegroundColor()['r'], $qrCode->getForegroundColor()['g'], $qrCode->getForegroundColor()['b'])); $blockDefinition->addAttribute('fill-opacity', strval($this->getOpacity($qrCode->getForegroundColor()['a']))); // Big blue circle $blockDefinition = $svg->defs->addChild('circle'); $blockDefinition->addAttribute('id', 'big_blue_circle'); $blockDefinition->addAttribute('r', strval(3.5)); $blockDefinition->addAttribute('cy', strval(0)); $blockDefinition->addAttribute('fill', '#'.sprintf('%02x%02x%02x', $qrCode->getForegroundColor()['r'], $qrCode->getForegroundColor()['g'], $qrCode->getForegroundColor()['b'])); $blockDefinition->addAttribute('fill-opacity', strval($this->getOpacity($qrCode->getForegroundColor()['a']))); // Big white circle $blockDefinition = $svg->defs->addChild('circle'); $blockDefinition->addAttribute('id', 'big_white_circle'); $blockDefinition->addAttribute('r', strval(2.5)); $blockDefinition->addAttribute('cy', strval(0)); $blockDefinition->addAttribute('fill', strval('#062f88')); $blockDefinition->addAttribute('fill-opacity', strval(255)); // Big white circle $blockDefinition = $svg->defs->addChild('circle'); $blockDefinition->addAttribute('id', 'big_white_circle2'); $blockDefinition->addAttribute('r', strval(2.5)); $blockDefinition->addAttribute('cy', strval(0)); $blockDefinition->addAttribute('fill', strval('#051f5a')); $blockDefinition->addAttribute('fill-opacity', strval(255)); // Small blue circle $blockDefinition = $svg->defs->addChild('circle'); $blockDefinition->addAttribute('id', 'small_blue_circle'); $blockDefinition->addAttribute('r', strval(1.5)); $blockDefinition->addAttribute('cy', strval(0)); $blockDefinition->addAttribute('fill', '#'.sprintf('%02x%02x%02x', $qrCode->getForegroundColor()['r'], $qrCode->getForegroundColor()['g'], $qrCode->getForegroundColor()['b'])); $blockDefinition->addAttribute('fill-opacity', strval($this->getOpacity($qrCode->getForegroundColor()['a']))); // Background $background = $svg->addChild('rect'); $background->addAttribute('x', '0'); $background->addAttribute('y', '0'); $background->addAttribute('width', strval($data['outer_width'])); $background->addAttribute('height', strval($data['outer_height'])); $background->addAttribute('fill', '#'.sprintf('%02x%02x%02x', $qrCode->getBackgroundColor()['r'], $qrCode->getBackgroundColor()['g'], $qrCode->getBackgroundColor()['b'])); $background->addAttribute('fill-opacity', strval($this->getOpacity($qrCode->getBackgroundColor()['a']))); for ($i=0;$i<=6; $i++) { $data['matrix'][0][$i] = 0; $data['matrix'][6][$i] = 0; } for ($i=21;$i<=28; $i++) { $data['matrix'][0][$i] = 0; $data['matrix'][6][$i] = 0; } for ($i=0;$i<=6; $i++) { $data['matrix'][22][$i] = 0; $data['matrix'][28][$i] = 0; } $data['matrix'][1][0] = 0; $data['matrix'][1][6] = 0; $data['matrix'][1][22] = 0; $data['matrix'][1][28] = 0; $data['matrix'][23][0] = 0; $data['matrix'][23][6] = 0; $data['matrix'][2][0] = 0; $data['matrix'][2][6] = 0; $data['matrix'][2][22] = 0; $data['matrix'][2][28] = 0; $data['matrix'][24][0] = 0; $data['matrix'][24][6] = 0; $data['matrix'][3][0] = 0; $data['matrix'][3][6] = 0; $data['matrix'][3][22] = 0; $data['matrix'][3][28] = 0; $data['matrix'][25][0] = 0; $data['matrix'][25][6] = 0; $data['matrix'][4][0] = 0; $data['matrix'][4][6] = 0; $data['matrix'][4][22] = 0; $data['matrix'][4][28] = 0; $data['matrix'][26][0] = 0; $data['matrix'][26][6] = 0; $data['matrix'][5][0] = 0; $data['matrix'][5][6] = 0; $data['matrix'][5][22] = 0; $data['matrix'][5][28] = 0; $data['matrix'][27][0] = 0; $data['matrix'][27][6] = 0; $data['matrix'][2][2] = 0; $data['matrix'][2][24] = 0; $data['matrix'][24][2] = 0; $data['matrix'][2][3] = 0; $data['matrix'][2][25] = 0; $data['matrix'][24][3] = 0; $data['matrix'][2][4] = 0; $data['matrix'][2][26] = 0; $data['matrix'][24][4] = 0; $data['matrix'][3][2] = 0; $data['matrix'][3][24] = 0; $data['matrix'][25][2] = 0; $data['matrix'][3][3] = 0; $data['matrix'][3][25] = 0; $data['matrix'][25][3] = 0; $data['matrix'][3][4] = 0; $data['matrix'][3][26] = 0; $data['matrix'][25][4] = 0; $data['matrix'][4][2] = 0; $data['matrix'][4][24] = 0; $data['matrix'][26][2] = 0; $data['matrix'][4][3] = 0; $data['matrix'][4][25] = 0; $data['matrix'][26][3] = 0; $data['matrix'][4][4] = 0; $data['matrix'][4][26] = 0; $data['matrix'][26][4] = 0; foreach ($data['matrix'] as $row => $values) { foreach ($values as $column => $value) { if (1 === $value) { $block = $svg->addChild('use'); $block->addAttribute('x', strval($data['margin_left'] + $data['block_size'] * $column)); $block->addAttribute('y', strval($data['margin_left'] + $data['block_size'] * $row)); $block->addAttribute('xlink:href', '#'.$block_id, 'http://www.w3.org/1999/xlink'); } } } $block = $svg->addChild('use'); $block->addAttribute('x', strval(4)); $block->addAttribute('y', strval(4)); $block->addAttribute('xlink:href', '#big_blue_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(4)); $block->addAttribute('y', strval(4)); $block->addAttribute('xlink:href', '#big_white_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(4)); $block->addAttribute('y', strval(4)); $block->addAttribute('xlink:href', '#small_blue_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(26)); $block->addAttribute('y', strval(4)); $block->addAttribute('xlink:href', '#big_blue_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(26)); $block->addAttribute('y', strval(4)); $block->addAttribute('xlink:href', '#big_white_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(26)); $block->addAttribute('y', strval(4)); $block->addAttribute('xlink:href', '#small_blue_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(4)); $block->addAttribute('y', strval(26)); $block->addAttribute('xlink:href', '#big_blue_circle', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(4)); $block->addAttribute('y', strval(26)); $block->addAttribute('xlink:href', '#big_white_circle2', 'http://www.w3.org/1999/xlink'); $block = $svg->addChild('use'); $block->addAttribute('x', strval(4)); $block->addAttribute('y', strval(26)); $block->addAttribute('xlink:href', '#small_blue_circle', 'http://www.w3.org/1999/xlink'); $logoPath = $qrCode->getLogoPath(); if (is_string($logoPath)) { $forceXlinkHref = false; if (isset($options['force_xlink_href']) && $options['force_xlink_href']) { $forceXlinkHref = true; } $this->addLogo($svg, $data['outer_width'], $data['outer_height'], $logoPath, $qrCode->getLogoWidth(), $qrCode->getLogoHeight(), $forceXlinkHref); } $xml = $svg->asXML(); if (!is_string($xml)) { throw new GenerateImageException('Unable to save SVG XML'); } if (isset($options['exclude_xml_declaration']) && $options['exclude_xml_declaration']) { $xml = str_replace("<?xml version=\"1.0\"?>\n", '', $xml); } return $xml; } private function addLogo(SimpleXMLElement $svg, int $imageWidth, int $imageHeight, string $logoPath, int $logoWidth = null, int $logoHeight = null, bool $forceXlinkHref = false): void { $mimeType = $this->getMimeType($logoPath); $imageData = file_get_contents($logoPath); if (!is_string($imageData)) { throw new GenerateImageException('Unable to read image data: check your logo path'); } if ('image/svg+xml' === $mimeType && (null === $logoHeight || null === $logoWidth)) { throw new MissingLogoHeightException('SVG Logos require an explicit height set via setLogoSize($width, $height)'); } if (null === $logoHeight || null === $logoWidth) { $logoImage = imagecreatefromstring(strval($imageData)); if (!is_resource($logoImage)) { throw new GenerateImageException('Unable to generate image: check your GD installation or logo path'); } $logoSourceWidth = imagesx($logoImage); $logoSourceHeight = imagesy($logoImage); imagedestroy($logoImage); if (null === $logoWidth) { $logoWidth = $logoSourceWidth; } if (null === $logoHeight) { $aspectRatio = $logoWidth / $logoSourceWidth; $logoHeight = intval($logoSourceHeight * $aspectRatio); } } $logoX = $imageWidth / 2 - $logoWidth / 2; $logoY = $imageHeight / 2 - $logoHeight / 2; $imageDefinition = $svg->addChild('image'); $imageDefinition->addAttribute('x', strval($logoX)); $imageDefinition->addAttribute('y', strval($logoY)); $imageDefinition->addAttribute('width', strval($logoWidth)); $imageDefinition->addAttribute('height', strval($logoHeight)); $imageDefinition->addAttribute('preserveAspectRatio', 'none'); // xlink:href is actually deprecated, but still required when placing the qr code in a pdf. // SimpleXML strips out the xlink part by using addAttribute(), so it must be set directly. if ($forceXlinkHref) { $imageDefinition['xlink:href'] = 'data:'.$mimeType.';base64,'.base64_encode($imageData); } else { $imageDefinition->addAttribute('href', 'data:'.$mimeType.';base64,'.base64_encode($imageData)); } } private function getOpacity(int $alpha): float { $opacity = 1 - $alpha / 127; return $opacity; } public static function getContentType(): string { return 'image/svg+xml'; } public static function getSupportedExtensions(): array { return ['svg']; } public function getName(): string { return 'svg'; } }