PageRenderTime 63ms CodeModel.GetById 29ms app.highlight 8ms RepoModel.GetById 18ms app.codeStats 1ms

/select.php

https://github.com/toastbrot/datenlandkarte
PHP | 337 lines | 296 code | 35 blank | 6 comment | 21 complexity | 265bd3950ff4e395b2298f063fee4b8a MD5 | raw file
  1<?php
  2    if (!$_POST) header('Location: input.php');
  3
  4    require_once('lib.php');
  5
  6    $keys = get_keys_by_vis($_POST);
  7
  8    $error = array();
  9    if (!$keys)
 10    {
 11        $error = array('Es konnte keine valide Karte verwendet werden');
 12    } else {
 13        $data = get_data($_POST, $keys);
 14
 15        if (empty($_POST['fac']))
 16            $fac = 1.0;
 17        else
 18            $fac = (float)$_POST['fac'];
 19
 20        $error = _error_msg_for_data($data);
 21        if ($error === false) // no error
 22            $data = include_factor($data, $fac);
 23        else
 24            $error = array($error);
 25    }
 26
 27    // Create files
 28    if (empty($error))
 29    {
 30        $image = select_svg_file($_POST);
 31
 32        // sanitize parameters
 33        $file_title = $_POST['title'];
 34        $file_title = preg_replace('/[[:^alnum:]]/', '_', $file_title);
 35        $file_subtitle = $_POST['subtitle'];
 36        $file_subtitle = preg_replace('/[[:^alnum:]]/', '_', $file_subtitle);
 37
 38        $title = htmlspecialchars($_POST['title'], ENT_NOQUOTES);
 39        $subtitle = htmlspecialchars($_POST['subtitle'], ENT_NOQUOTES);
 40
 41        if ($file_title)
 42            $file_title = '-'.$file_title;
 43        if ($file_subtitle)
 44            $file_subtitle = '-'.$file_subtitle;
 45
 46        $dec = $_POST['dec'];
 47        if (strlen($dec) == 0)
 48            $dec = 2;
 49        else
 50            $dec = (int)$_POST['dec'];
 51        if ($dec > 3)
 52            $dec = 3;
 53
 54        $colors = $_POST['colors'];
 55        if (2 < (int)$colors && (int)$colors < 10)
 56            $colors = (int)$colors;
 57        else
 58            $colors = 10;
 59
 60        if (file_exists($image))
 61        {
 62            // Create SVG
 63            $svg = substitute($image, $title, $subtitle,
 64                $dec, $colors, (int)$_POST['grad'], $data);
 65
 66            $date = date('Ymd');
 67            $img_path = $location_creation.
 68                $date.$file_title.$file_subtitle;
 69
 70            // Delete old files
 71            @unlink($img_path.'.svg');
 72            @unlink($img_path.'.png');
 73            @unlink($img_path.'_big.png');
 74
 75            $fp = fopen($img_path.'.svg', 'w');
 76            if ($fp)
 77            {
 78                $a = fwrite($fp, $svg);
 79                if (!$a) {
 80                    $error[] = 'Konnte Datei nicht schreiben. '.
 81                            'Keine Zugriffsrechte.';
 82                } else {
 83                    // PNG1 aus SVG erzeugen
 84                    exec('convert '.$img_path.'.svg '.$img_path.'.png');
 85                    // PNG2 aus SVG erzeugen
 86                    exec('convert -scale 300% '.$img_path.'.svg '.$img_path.'_big.png');
 87                }
 88                fclose($fp);
 89            } else {
 90                $error[] = 'Konnte Datei nicht öffnen. '.
 91                        'Keine Zugriffsrechte.';
 92            }
 93        } else {
 94            $error[] = 'Konnte Basiskarte ('.
 95                htmlspecialchars(basename($image), ENT_NOQUOTES).
 96                ') nicht finden.';
 97        }
 98    }
 99?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
100<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="de-DE"
101 xmlns:og='http://opengraphprotocol.org/schema/'>
102<head profile="http://gmpg.org/xfn/11">
103<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
104
105<title>Datenlandkarte Format wählen</title>
106<meta name="description" content="Hier können Sie selbst Datenlandkarten erstellen. Gleichzeitig werden, falls Sie diese Option aktiviert lassen, die Rohdaten der Visualisierung gespeichert und" />
107<meta name="keywords" content="Bezirke, Kärnten, Alle, Ebenen, Daten, Bundesländer" />
108<meta name="robots" content="index, follow" />
109<link rel="canonical" href="http://www.datenlandkarten.at/datenlandkarte-erstellen/" />
110
111<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
112
113<link rel="stylesheet" href="http://www.datenlandkarten.at/wp-content/themes/datenlandkarten/style.css" type="text/css" media="screen" />
114<!--[if IE 6]><link rel="stylesheet" href="http://www.datenlandkarten.at/wp-content/themes/datenlandkarten/style.ie6.css" type="text/css" media="screen" /><![endif]-->
115<!--[if IE 7]><link rel="stylesheet" href="http://www.datenlandkarten.at/wp-content/themes/datenlandkarten/style.ie7.css" type="text/css" media="screen" /><![endif]-->
116<link rel="pingback" href="http://www.datenlandkarten.at/xmlrpc.php" />
117<link rel="alternate" type="application/rss+xml" title="Datenlandkarten.at &raquo; Feed" href="http://www.datenlandkarten.at/feed/" />
118<link rel="alternate" type="application/rss+xml" title="Datenlandkarten.at &raquo; Kommentar Feed" href="http://www.datenlandkarten.at/comments/feed/" />
119<link rel='stylesheet' id='NextGEN-css'  href='http://www.datenlandkarten.at/wp-content/plugins/nextgen-gallery/css/nggallery.css?ver=1.0.0' type='text/css' media='screen' />
120<link rel='stylesheet' id='shutter-css'  href='http://www.datenlandkarten.at/wp-content/plugins/nextgen-gallery/shutter/shutter-reloaded.css?ver=1.3.0' type='text/css' media='screen' />
121<link rel='stylesheet' id='feedreading_style-css'  href='http://www.datenlandkarten.at/wp-content/plugins/feed-reading-blogroll/css/feedreading_blogroll.css?ver=1.5.6' type='text/css' media='all' />
122<link rel='stylesheet' id='prlipro-post-css'  href='http://www.datenlandkarten.at/wp-content/plugins/pretty-link/pro/css/prlipro-post.css?ver=3.0.4' type='text/css' media='all' />
123<script type='text/javascript' src='http://www.datenlandkarten.at/wp-content/plugins/nextgen-gallery/shutter/shutter-reloaded.js?ver=1.3.0'></script>
124<script type='text/javascript' src='http://www.datenlandkarten.at/wp-includes/js/swfobject.js?ver=2.2'></script>
125<script type='text/javascript' src='http://www.datenlandkarten.at/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
126<script type='text/javascript' src='http://www.datenlandkarten.at/wp-includes/js/comment-reply.js?ver=20090102'></script>
127<script type='text/javascript' src='http://www.datenlandkarten.at/wp-content/feedreading_blogroll.js?ver=1.5.6'></script>
128<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.datenlandkarten.at/xmlrpc.php?rsd" />
129<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.datenlandkarten.at/wp-includes/wlwmanifest.xml" /> 
130<link rel='index' title='Datenlandkarten.at' href='http://www.datenlandkarten.at/' />
131<link rel='next' title='Galerie' href='http://www.datenlandkarten.at/galerie/' />
132				<meta name="DC.publisher" content="Datenlandkarten.at" />
133		<meta name="DC.publisher.url" content="http://www.datenlandkarten.at/" />
134		<meta name="DC.title" content="Datenlandkarte erstellen" />
135		<meta name="DC.identifier" content="http://www.datenlandkarten.at/datenlandkarte-erstellen/" />
136		<meta name="DC.date.created" scheme="WTN8601" content="2011-02-02T20:09:28" />
137		<meta name="DC.created" scheme="WTN8601" content="2011-02-02T20:09:28" />
138		<meta name="DC.date" scheme="WTN8601" content="2011-02-02T20:09:28" />
139		<meta name="DC.creator.name" content="Harm, Robert" />
140		<meta name="DC.creator" content="Harm, Robert" />
141		<meta name="DC.rights.rightsHolder" content="@RobertHarm" />		
142		<meta name="DC.language" content="de-DE" scheme="rfc1766" />
143		<meta name="DC.rights.license" content="http://creativecommons.org/licenses/by/3.0/at/" />
144		<meta name="DC.license" content="http://creativecommons.org/licenses/by/3.0/at/" />
145	<!--Facebook Like Button OpenGraph Settings Start-->
146	<meta property="og:site_name" content="Datenlandkarten.at"/>
147	<meta property="og:title" content="Datenlandkarte erstellen"/>
148		<meta property="og:description" content="Hier können Sie selbst Datenlandkarten erstellen. Gleichzeitig werden, falls Sie diese Option aktiviert lassen, die Rohdaten der Visualisie"/>
149	
150	<meta property="og:url" content="http://www.datenlandkarten.at/datenlandkarte-erstellen/"/>
151	<meta property="fb:admins" content="1039929046" />
152	<meta property="fb:app_id" content="192140977480316" />
153	<meta property="og:image" content="http://www.datenlandkarten.at/wp-content/uploads/opengraph.png" />
154	<meta property="og:type" content="article" />
155		<!--Facebook Like Button OpenGraph Settings End-->
156	      <link rel="shorturl" href="http://datenlandkarte.at/gs8" />
157    
158<meta name='NextGEN' content='1.7.3' />
159<script type="text/javascript" src="http://www.datenlandkarten.at/wp-content/themes/datenlandkarten/script.js"></script>
160<style type="text/css">
161<!--
162    table {
163        width: 100%;
164    }
165    td {
166        vertical-align: top;
167    }
168    select {
169        min-width: 50%;
170    }
171    textarea {
172        width: 100%;
173    }
174    input, textarea { background-color: #CCC; }
175    input:hover, textarea:hover { background-color: #EEE; }
176
177    .error {
178        color: #F00;
179    }
180    .subselect {
181        margin-left: 30px;
182    }
183    .download {
184        background-color: #EEE;
185        margin: 20px;
186        clear: both;
187        padding: 10px;
188    }
189-->
190</style>
191</head>
192<body class="page page-id-2 page-template page-template-default">
193<div id="art-main">
194    <div class="art-sheet">
195        <div class="art-sheet-tl"></div>
196        <div class="art-sheet-tr"></div>
197        <div class="art-sheet-bl"></div>
198        <div class="art-sheet-br"></div>
199        <div class="art-sheet-tc"></div>
200        <div class="art-sheet-bc"></div>
201        <div class="art-sheet-cl"></div>
202        <div class="art-sheet-cr"></div>
203        <div class="art-sheet-cc"></div>
204        <div class="art-sheet-body">
205            <div class="art-header">
206                <div class="art-header-center">
207                    <div class="art-header-png"></div>
208                    <div class="art-header-jpeg"></div>
209                </div>
210                <div class="art-headerobject"></div>
211                <div class="art-logo">
212                                <h1 id="name-text" class="art-logo-name"><a href="http://www.datenlandkarten.at/">Datenlandkarten.at</a></h1>
213                                                    <h2 id="slogan-text" class="art-logo-text">Erstelle deine eigene Visualisierung von Gemeinde-, Bezirks-, und Bundesland-Daten</h2>
214                                </div>
215            </div>
216            <div class="art-nav">
217            	<div class="art-nav-l"></div>
218            	<div class="art-nav-r"></div>
219            	
220<ul class="art-menu">
221	<li><a href="http://www.datenlandkarten.at" title="Startseite"><span class="l"> </span><span class="r"> </span><span class="t">Startseite</span></a>
222	</li>
223	<li class="art-menu-li-separator"><span class="art-menu-separator"> </span></li>
224	<li class="active"><a class="active" href="http://www.datenlandkarten.at/datenlandkarte-erstellen/" title="Datenlandkarte erstellen"><span class="l"> </span><span class="r"> </span><span class="t">Datenlandkarte erstellen</span></a>
225	</li>
226	<li class="art-menu-li-separator"><span class="art-menu-separator"> </span></li>
227	<li><a href="http://www.datenlandkarten.at/rohdaten/" title="Rohdaten"><span class="l"> </span><span class="r"> </span><span class="t">Rohdaten</span></a>
228	</li>
229	<li class="art-menu-li-separator"><span class="art-menu-separator"> </span></li>
230	<li><a href="http://www.datenlandkarten.at/galerie/" title="Galerie"><span class="l"> </span><span class="r"> </span><span class="t">Galerie</span></a>
231	</li>
232	<li class="art-menu-li-separator"><span class="art-menu-separator"> </span></li>
233	<li><a href="http://www.datenlandkarten.at/blog/" title="Blog"><span class="l"> </span><span class="r"> </span><span class="t">Blog</span></a>
234	</li>
235	<li class="art-menu-li-separator"><span class="art-menu-separator"> </span></li>
236	<li><a href="http://www.datenlandkarten.at/impressum/" title="Impressum"><span class="l"> </span><span class="r"> </span><span class="t">Impressum</span></a>
237	</li>
238</ul>
239            </div>
240<div class="art-content-layout">
241    <div class="art-content-layout-row">
242        <div class="art-layout-cell art-content">
243			
244
245
246<div class="art-post post-2 page type-page hentry" id="post-2">
247	    <div class="art-post-body">
248	            <div class="art-post-inner art-article">
249
250
251        <h2 class="art-postheader">Datenlandkarte speichern</h2>
252        <div class="art-postcontent">
253          <noscript>
254            <p>
255              Dieses Formular arbeitet mit Javascript. Bitte aktivieren
256              Sie Javascript in ihrem Browser, wenn möglich.
257            </p>
258          </noscript>
259<?php
260    if (!empty($error)) {
261?>
262          <div class="error">
263            <p>Es traten mindestens 1 Fehler auf:<p>
264            <ul>
265<?php
266        foreach ($error as $e) {
267?>
268
269              <li><?=htmlspecialchars($e, ENT_NOQUOTES); ?></li>
270<?php
271        }
272?>
273            </ul>
274          </div>
275<?php
276    } else {
277?>
278
279          <div class="download">
280           <a href="<?=$img_path; ?>.svg">
281             <img src="img/svg.png" alt="SVG Graphic Datenlandkarte" style="float:left">
282           </a>
283           <h5><a href="<?=$img_path; ?>.svg">Download SVG</a></h5>
284           <p>Scalable Vector Graphics</p>
285          </div>
286
287          <div class="download">
288           <a href="<?=$img_path; ?>.png">
289             <img src="img/png.png" alt="PNG Graphic Datenlandkarte" style="float:left">
290           </a>
291           <h5><a href="<?=$img_path; ?>.png">Download PNG</a></h5>
292           <p>Portable Network Graphics</p>
293          </div>
294
295          <div class="download">
296           <a href="<?=$img_path; ?>_big.png">
297             <img src="img/png.png" alt="PNG Graphic Datenlandkarte" style="float:left">
298           </a>
299           <h5><a href="<?=$img_path; ?>_big.png">Download PNG (3fache Größe)</a></h5>
300           <p>Portable Network Graphics</p>
301          </div>
302<?php } ?>
303                    <div class="cleared"></div>
304            <div class="cleared"></div>
305        </div>
306    </div>
307
308
309          <div class="cleared"></div>
310        </div>
311</div>
312<div class="cleared"></div>
313    <div class="art-footer">
314                <div class="art-footer-t"></div>
315                <div class="art-footer-l"></div>
316                <div class="art-footer-b"></div>
317                <div class="art-footer-r"></div>
318                <div class="art-footer-body">
319
320
321                  <div class="art-footer-text">
322                      <p><div style="float:left;"><a href="http://www.open3.at" target="_blank" title="Webseite open3.at aufrufen"><img src="http://www.datenlandkarten.at/wp-content/uploads/open3logo.png" width="177" height="33"></a></div>
323<div style="float:right;text-align:right;"><a href="http://www.opendefinition.org/okd/deutsch/" target="_blank" title="Definition "Offenes Wissen" auf http://opendefinition.org/ anzeigen"><img src="http://www.datenlandkarten.at/wp-content/uploads/badge-od.png" width="80" height="15"> <img src="http://www.datenlandkarten.at/wp-content/uploads/badge-ok.png" width="80" height="15"> <img src="http://www.datenlandkarten.at/wp-content/uploads/badge-oc.png" width="80" height="15"></a><br/>
324<a href="/impressum" style="text-decoration:none;" title="Impressum anzeigen">Ein Projekt von open3, dem Netzwerk zur Förderung von openSociety, openGovernment und OpenData</a></p></div>                  </div>
325                    <div class="cleared"></div>
326                </div>
327            </div>
328            <div class="cleared"></div>
329        </div>
330    </div>
331    <div class="cleared"></div>
332    <p class="art-page-footer"></p>
333</div>
334    <div id="wp-footer">
335    </div>
336</body>
337</html>