Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ods_svg {
- private $anime1 = '<animate attributeName="visibility" from="visible" to="hidden" dur="1s" repeatCount="indefinite" />';
- private $anime2 = '<animate attributeName="visibility" from="visible" to="hidden" dur="2s" repeatCount="indefinite" />';
- private $animeall = '<animate attributeName="visibility" from="visible" to="hidden" dur="0.5s" repeatCount="indefinite" />';
- private $animeous = '<animate attributeName="visibility" values="visible;hidden;visible;hidden;visible;hidden;visible;visible;visible;visible;visible" dur="0.8s" repeatCount="indefinite" />';
- public function run()
- {
- $script = substr(stristr(strtok($_SERVER['REQUEST_URI'],'?'), 'images/'),7);
- $script = str_replace(['/','\\',':','.'],'_',$script);
- $method = strtolower($_SERVER['REQUEST_METHOD'].'_'.$script);
- if( method_exists($this, $method) ) {
- $this->$method();
- }
- else {
- header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
- echo('Not Found');
- }
- }
- private function get_galbox_svg() {
- $header = !isset($_GET['noxml']);
- $box = new ods_box($_GET['cnf']);
- if($header)
- header ('Content-Type: image/svg+xml');
- header_remove("Pragma");
- header_remove("Expires");
- header("Cache-Control: max-age=86400");
- echo $box->run($header);
- }
- private function get_lamp_svg() {
- $anm='';
- $anm2='';
- $foncolor = "rgb(0,176,80)";
- $incolor="white";
- if(isset($_GET['auto']))
- $foncolor = "rgb(0,176,80)";
- if(isset($_GET['manual']))
- $foncolor = "rgb(0,112,192)";
- if(isset($_GET['unmanaged']))
- $foncolor = "rgb(166,166,166)";
- $outcolor = $foncolor;
- if(isset($_GET['nopower']))
- $outcolor = "rgb(255,0,0)";
- if(isset($_GET['on']))
- $incolor="white";
- if(isset($_GET['off']))
- $incolor="black";
- $circlecolor=$incolor;
- if(isset($_GET['trouble']))
- $circlecolor="red";
- $opa=1;
- if(isset($_GET['nocon']))
- $opa="0.5";
- if (isset($_GET['shape'])) {
- $foncolor="black";
- $outcolor="black";
- $circklecolor="white";
- $incolor="white";
- }
- if(isset($_GET['timeallert']))
- $anm=$this->anime1;
- if(isset($_GET['controlallert']))
- $anm=$this->anime2;
- if(isset($_GET['timeallert']) && isset($_GET['controlallert']))
- $anm=$this->animeall;
- if(isset($_GET['open']))
- $anm=$this->animeall;
- if(isset($_GET['ous']))
- $anm2=$this->animeous;
- $data = <<<EOT
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- version="1.1"
- id="Capa_1"
- x="0px"
- y="0px"
- width="333.668"
- height="491.582"
- viewBox="0 0 333.668 491.582"
- xml:space="preserve"
- sodipodi:docname="location.svg"
- inkscape:version="0.92.1 r15371"><metadata
- id="metadata4620"><rdf:RDF><cc:Work
- rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
- id="defs4618" /><sodipodi:namedview
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1"
- objecttolerance="10"
- gridtolerance="10"
- guidetolerance="10"
- inkscape:pageopacity="0"
- inkscape:pageshadow="2"
- inkscape:window-width="1920"
- inkscape:window-height="1017"
- id="namedview4616"
- showgrid="false"
- inkscape:zoom="1.5480632"
- inkscape:cx="166.834"
- inkscape:cy="245.791"
- inkscape:window-x="1272"
- inkscape:window-y="-8"
- inkscape:window-maximized="1"
- inkscape:current-layer="Capa_1" />
- <g>
- $anm
- $anm2
- <path style="fill:$outcolor;fill-opacity:$opa;"
- d="M 166.834,0 C 74.842,0 0,74.841 0,166.833 0,203.8 21.764,260.02 68.493,343.759 c 31.887,57.138 63.627,105.4 64.966,107.433 l 22.941,34.773 c 2.313,3.507 6.232,5.617 10.434,5.617 4.202,0 8.121,-2.11 10.434,-5.617 l 22.94,-34.771 c 1.326,-2.01 32.835,-49.855 64.967,-107.435 46.729,-83.735 68.493,-139.955 68.493,-176.926 C 333.668,74.841 258.826,0 166.834,0 Z m 76.511,331.576 C 211.66,388.351 180.649,435.445 179.342,437.424 L 166.834,456.383 154.33,437.429 C 153.016,435.434 121.767,387.918 90.323,331.576 46.978,253.9 25,198.472 25,166.833 25,88.626 88.626,25 166.834,25 c 78.208,0 141.834,63.626 141.834,141.833 0,31.643 -21.978,87.069 -65.323,164.743 z"
- id="out"
- inkscape:connector-curvature="0" /><path
- d="m 166.51102,70.061158 c -52.60786,0 -95.40686,42.800032 -95.40686,95.406862 0,52.60682 42.799,95.40685 95.40686,95.40685 52.60786,0 95.40685,-42.80003 95.40685,-95.40685 0,-52.60683 -42.79899,-95.406862 -95.40685,-95.406862 z m 0,165.028072 c -38.38966,0 -69.62123,-31.23156 -69.62123,-69.62121 0,-38.38966 31.23157,-69.621225 69.62123,-69.621225 38.39069,0 69.62121,31.231565 69.62121,69.621225 0,38.38965 -31.23052,69.62121 -69.62121,69.62121 z"
- id="path4579"
- inkscape:connector-curvature="0"
- style="stroke-width:1.0314256; fill:$circlecolor;fill-opacity:$opa" /><g
- id="g4585"
- transform="translate(-78.957)" /><g
- id="g4587"
- transform="translate(-78.957)" /><g
- id="g4589"
- transform="translate(-78.957)" /><g
- id="g4591"
- transform="translate(-78.957)" /><g
- id="g4593"
- transform="translate(-78.957)" /><g
- id="g4595"
- transform="translate(-78.957)" /><g
- id="g4597"
- transform="translate(-78.957)" /><g
- id="g4599"
- transform="translate(-78.957)" /><g
- id="g4601"
- transform="translate(-78.957)" /><g
- id="g4603"
- transform="translate(-78.957)" /><g
- id="g4605"
- transform="translate(-78.957)" /><g
- id="g4607"
- transform="translate(-78.957)" /><g
- id="g4609"
- transform="translate(-78.957)" /><g
- id="g4611"
- transform="translate(-78.957)" /><g
- id="g4613"
- transform="translate(-78.957)" /><path
- style="opacity:1;fill:$incolor;fill-opacity:$opa;fill-rule:evenodd;stroke:none;stroke-width:1.39170384;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="m 139.55478,232.35515 c -16.58989,-6.60707 -28.58213,-18.03317 -37.03437,-35.28599 -6.38482,-13.03281 -7.31297,-17.131 -7.19708,-31.77843 0.10703,-13.52786 1.31773,-19.29209 6.19162,-29.47857 20.24225,-42.306575 76.0645,-53.865996 110.39606,-22.86032 16.49621,14.89816 23.55823,30.9106 23.55823,53.41604 0,15.0389 -0.98737,19.91288 -6.1896,30.55391 -6.8541,14.01987 -18.68856,25.94228 -33.23311,33.48003 -13.78082,7.14194 -41.09228,8.08629 -56.49175,1.95333 z"
- id="in"
- inkscape:connector-curvature="0" /><path
- style="opacity:1;fill:$foncolor;fill-opacity:$opa;fill-rule:evenodd;stroke:none;stroke-width:1.32080853;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
- d="M 155.30991,441.46651 C 87.7426,335.06388 48.24689,260.59788 30.49318,206.13462 17.902965,167.51149 22.33961,127.83742 43.19548,92.545955 47.13571,85.878452 57.60351,73.120056 66.45725,64.193964 79.6908,50.852276 86.10715,46.269966 102.51958,38.439622 c 25.34418,-12.091664 38.10009,-15.050718 64.51217,-14.965211 39.60128,0.128207 71.08382,13.371175 99.77161,41.968433 33.76712,33.66056 48.87939,78.982346 40.21435,120.602906 -9.96466,47.86278 -55.10745,138.24455 -118.4759,237.20424 -10.9865,17.15712 -20.90722,31.50438 -22.04607,31.8828 -1.13885,0.37843 -6.17246,-5.77141 -11.18583,-13.66628 z m 37.97331,-186.45037 c 7.0625,-2.19116 16.94549,-6.38177 21.96218,-9.31247 11.50031,-6.71836 29.4853,-25.54903 35.35406,-37.01644 C 277.86863,155.40391 249.9923,90.544348 192.68445,73.937085 172.78736,68.171099 145.53005,70.166632 127.17736,78.732914 64.14447,108.15411 51.97082,190.13931 103.86658,235.72282 c 5.57279,4.89497 12.99612,10.39475 16.49629,12.22174 21.51321,11.22941 50.46835,14.03738 72.92035,7.07158 z"
- id="fon"
- inkscape:connector-curvature="0" />
- </g>
- <circle cx="50" cy="50" r="5" fill="green" />
- <circle cx="70" cy="50" r="5" fill="green" />
- </svg>
- EOT;
- $this->output($data);
- }
- private function get_box_svg() {
- $anm='';
- $anm2='';
- $foncolor = "rgb(0,176,80)";
- $incolor="white";
- $depth = 33;
- $bodyX = 42.333332;
- $bodyW = 74.083336;
- $bodyH = 89.958336;
- $canvasW = $bodyW + $depth*2 + 5;
- $canvasH = 100.79864;
- if(isset($_GET['auto']))
- $foncolor = "rgb(0,176,80)";
- if(isset($_GET['manual']))
- $foncolor = "rgb(0,112,192)";
- if(isset($_GET['unmanaged']))
- $foncolor = "rgb(166,166,166)";
- $outcolor = $foncolor;
- if(isset($_GET['nopower']))
- $outcolor = "rgb(255,0,0)";
- if(isset($_GET['on']))
- $incolor="white";
- if(isset($_GET['off']))
- $incolor="black";
- $circlecolor=$foncolor;
- if(isset($_GET['trouble']))
- $circlecolor="red";
- $opa=1;
- if(isset($_GET['nocon']))
- $opa="0.5";
- if(isset($_GET['timeallert']))
- $anm=$this->anime1;
- if(isset($_GET['controlallert']))
- $anm=$this->anime2;
- if(isset($_GET['timeallert']) && isset($_GET['controlallert']))
- $anm=$this->animeall;
- if(isset($_GET['open']))
- $anm=$this->animeall;
- if(isset($_GET['ous']))
- $anm2=$this->animeous;
- if (isset($_GET['shape'])) {
- $foncolor="black";
- $outcolor="black";
- $circlecolor="black";
- $incolor="white";
- }
- $circlesCount = isset($_GET['multiple']) && $_GET['multiple'] == 'true' ? 2 : 1;
- $centerX = 78.845825;
- $circle1 = '<circle
- style="fill:' . $incolor . ';fill-opacity:' . $opa . ';stroke:none;stroke-width:0.26458332"
- id="dyra"
- cx="' . $centerX . '"
- cy="136.13333"
- r="18.520834" />';
- $circle2 = '';
- if ($circlesCount === 2) {
- $spacing = 30;
- $circle1 = '<circle
- style="fill:' . $incolor . ';fill-opacity:' . $opa . ';stroke:none;stroke-width:0.26458332"
- id="dyra"
- cx="' . ($centerX - $spacing / 2) . '"
- cy="136.13333"
- r="14" />';
- $circle2 = '<circle
- style="fill:' . $incolor . ';fill-opacity:' . $opa . ';stroke:none;stroke-width:0.26458332"
- id="dyra2"
- cx="' . ($centerX + $spacing / 2) . '"
- cy="136.13333"
- r="14" />';
- }
- $doorSvg = '';
- if (isset($_GET['open']) && $_GET['open']=='1') {
- $bodyY = 106.5;
- $slant = 15;
- $doorClr = '#002b5c';
- $bodyR = $bodyX + $bodyW;
- $leftX = $bodyX - $depth;
- $rightX = $bodyR + $depth;
- $DL_p1 = $bodyX .','.$bodyY;
- $DL_p2 = $bodyX .','.($bodyY + $bodyH - $slant);
- $DL_p3 = $leftX .','.($bodyY + $bodyH );
- $DL_p4 = $leftX .','.($bodyY + $slant);
- $DR_p1 = $bodyR .','.$bodyY;
- $DR_p2 = $bodyR .','.($bodyY + $bodyH - $slant);
- $DR_p3 = $rightX.','.($bodyY + $bodyH );
- $DR_p4 = $rightX.','.($bodyY + $slant);
- $doorSvg = '
- <polygon id="doorLeft" points="'.$DL_p1.' '.$DL_p2.' '.$DL_p3.' '.$DL_p4.'" style="fill:'.$doorClr.';fill-opacity:'.$opa.';stroke:none"/>
- <polygon id="doorRight" points="'.$DR_p1.' '.$DR_p2.' '.$DR_p3.' '.$DR_p4.'" style="fill:'.$doorClr.';fill-opacity:'.$opa.';stroke:none"/>';
- }
- $data = <<<EOT
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width ="{$canvasW}mm"
- height="{$canvasH}mm"
- viewBox="-{$depth} 0 {$canvasW} {$canvasH}"
- version="1.1"
- id="svg8"
- inkscape:version="0.92.1 r15371"
- sodipodi:docname="box.svg">
- <defs
- id="defs2" />
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="0.5"
- inkscape:cx="257.32181"
- inkscape:cy="180.5"
- inkscape:document-units="mm"
- inkscape:current-layer="layer1"
- showgrid="false"
- inkscape:window-width="1920"
- inkscape:window-height="1017"
- inkscape:window-x="1272"
- inkscape:window-y="-8"
- inkscape:window-maximized="1">
- <inkscape:grid
- type="xygrid"
- id="grid4493"
- originx="-36.916937"
- originy="-100.40938" />
- </sodipodi:namedview>
- <metadata
- id="metadata5">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(-36.916938,-95.791984)">
- $anm
- $anm2
- <rect
- style="fill:$foncolor;fill-opacity:$opa;stroke:#ffffff;stroke-width:0.24052194"
- id="rectbox"
- width="74.083336"
- height="89.958336"
- x="42.333332"
- y="106.5" />
- <rect
- style="fill:$outcolor;fill-opacity:$opa;stroke:#ffffff;stroke-width:0.24945155"
- id="rectup"
- width="84.666664"
- height="10.583333"
- x="37.041664"
- y="95.91671"
- inkscape:label="#rrectup" />
- <rect
- style="fill:$circlecolor;fill-opacity:$opa;stroke:#ffffff;stroke-width:0.26458332"
- id="rectdown"
- width="74.083336"
- height="26.458332"
- x="42.333328"
- y="170" />
- $circle1
- $circle2
- $doorSvg
- </g>
- </svg>
- EOT;
- $this->output($data);
- }
- private function putsvg($data, $addxml=false) {
- $header = "<svg>";
- $header = <<<EOT
- <svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- viewBox="0 0 1000 600"
- version="1.1"
- id="svg8"
- >
- EOT;
- $tail = '</svg>';
- if($addxml) {
- $header = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n\n$header";
- }
- return $header."\n".$data."\n".$tail;
- }
- private function get_test_svg() {
- //$data = $this->draw_fuze_group();
- $data = $this->draw_box();
- $this->output( $this->putsvg($data, true) );
- }
- private function output($data) {
- header_remove("Pragma");
- header_remove("Expires");
- //header("Cache-Control: max-age=86400");
- header('Content-type: image/svg+xml');
- header('Content-Length: '.strlen($data));
- echo $data;
- }
- private function err_out() {
- header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
- echo $this->num . ' Not Found ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement