From 50edafc0884aa15d0a1aa178089ac6a1ad2eb18a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 31 Aug 2012 15:47:05 +0200 Subject: [PATCH 1/9] Load JSON rather than javascript from phpmyadmin.net Conflicts: js/functions.js libraries/Header.class.php --- js/functions.js | 12 ++++++------ libraries/header_http.inc.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/js/functions.js b/js/functions.js index cdba36886d..ad2e39c8cd 100644 --- a/js/functions.js +++ b/js/functions.js @@ -128,13 +128,13 @@ function parseVersionString (str) /** * Indicates current available version on main page. */ -function PMA_current_version() +function PMA_current_version(data) { var current = parseVersionString(pmaversion); - var latest = parseVersionString(PMA_latest_version); - var version_information_message = PMA_messages['strLatestAvailable'] + ' ' + PMA_latest_version; + var latest = parseVersionString(data['version']); + var version_information_message = PMA_messages['strLatestAvailable'] + ' ' + data['version']; if (latest > current) { - var message = $.sprintf(PMA_messages['strNewerVersion'], PMA_latest_version, PMA_latest_date); + var message = $.sprintf(PMA_messages['strNewerVersion'], data['version'], data['date']); if (Math.floor(latest / 10000) == Math.floor(current / 10000)) { /* Security update */ klass = 'error'; @@ -1734,7 +1734,7 @@ function PMA_createProfilingChartJqplot(target, data) seriesDefaults: { renderer: $.jqplot.PieRenderer, rendererOptions: { - showDataLabels: true + showDataLabels: true } }, legend: { @@ -3218,7 +3218,7 @@ $(document).ready(function() { * Load version information asynchronously. */ if ($('.jsversioncheck').length > 0) { - $.getScript('http://www.phpmyadmin.net/home_page/version.js', PMA_current_version); + $.getJSON('http://www.phpmyadmin.net/home_page/version.json', {}, PMA_current_version); } /** diff --git a/libraries/header_http.inc.php b/libraries/header_http.inc.php index 6bc295bc05..e8126456f3 100644 --- a/libraries/header_http.inc.php +++ b/libraries/header_http.inc.php @@ -22,7 +22,7 @@ $GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT'; /* Prevent against ClickJacking by allowing frames only from same origin */ if (!$GLOBALS['cfg']['AllowThirdPartyFraming']) { header('X-Frame-Options: SAMEORIGIN'); - header("X-Content-Security-Policy: allow 'self'; options inline-script eval-script; frame-ancestors 'self'; img-src 'self' data:; script-src 'self' http://www.phpmyadmin.net"); + header("X-Content-Security-Policy: allow 'self' http://www.phpmyadmin.net; options inline-script eval-script; frame-ancestors 'self'; img-src 'self' data:"); header("X-WebKit-CSP: allow 'self' http://www.phpmyadmin.net; options inline-script eval-script"); } PMA_no_cache_header(); From a547f3d3e2cf36c6a904fa3e053fd8bddd3fbbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 3 Sep 2012 14:57:59 +0200 Subject: [PATCH 2/9] Escape json reply received from server --- js/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/functions.js b/js/functions.js index ad2e39c8cd..b9fad9e9ee 100644 --- a/js/functions.js +++ b/js/functions.js @@ -132,9 +132,9 @@ function PMA_current_version(data) { var current = parseVersionString(pmaversion); var latest = parseVersionString(data['version']); - var version_information_message = PMA_messages['strLatestAvailable'] + ' ' + data['version']; + var version_information_message = PMA_messages['strLatestAvailable'] + ' ' + escapeHtml(data['version']); if (latest > current) { - var message = $.sprintf(PMA_messages['strNewerVersion'], data['version'], data['date']); + var message = $.sprintf(PMA_messages['strNewerVersion'], escapeHtml(data['version']), escapeHtml(data['date'])); if (Math.floor(latest / 10000) == Math.floor(current / 10000)) { /* Security update */ klass = 'error'; From 1136a46c748c723772315dd971a38246fdbdb0ac Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Mon, 3 Sep 2012 17:31:15 +0200 Subject: [PATCH 3/9] improve coding style, fix indentation --- gis_data_editor.php | 384 +++++++++++++++++++++++++------------------- 1 file changed, 217 insertions(+), 167 deletions(-) diff --git a/gis_data_editor.php b/gis_data_editor.php index 9eb0e99744..8c35e1067b 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -28,9 +28,13 @@ if (! isset($gis_data['gis_type'])) { } if (isset($_REQUEST['value']) && trim($_REQUEST['value']) != '') { $start = (substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0; - $gis_data['gis_type'] = substr($_REQUEST['value'], $start, strpos($_REQUEST['value'], "(") - $start); + $gis_data['gis_type'] = substr( + $_REQUEST['value'], $start, strpos($_REQUEST['value'], "(") - $start + ); } - if ((! isset($gis_data['gis_type'])) || (! in_array($gis_data['gis_type'], $gis_types))) { + if ((! isset($gis_data['gis_type'])) + || (! in_array($gis_data['gis_type'], $gis_types)) + ) { $gis_data['gis_type'] = $gis_types[0]; } } @@ -39,20 +43,30 @@ $geom_type = $gis_data['gis_type']; // Generate parameters from value passed. $gis_obj = PMA_GIS_Factory::factory($geom_type); if (isset($_REQUEST['value'])) { - $gis_data = array_merge($gis_data, $gis_obj->generateParams($_REQUEST['value'])); + $gis_data = array_merge( + $gis_data, $gis_obj->generateParams($_REQUEST['value']) + ); } // Generate Well Known Text -$srid = (isset($gis_data['srid']) && $gis_data['srid'] != '') ? htmlspecialchars($gis_data['srid']) : 0; +$srid = (isset($gis_data['srid']) && $gis_data['srid'] != '') + ? htmlspecialchars($gis_data['srid']) : 0; $wkt = $gis_obj->generateWkt($gis_data, 0); $wkt_with_zero = $gis_obj->generateWkt($gis_data, 0, '0'); $result = "'" . $wkt . "'," . $srid; // Generate PNG or SVG based visualization -$format = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER <= 8) ? 'png' : 'svg'; -$visualizationSettings = array('width' => 450, 'height' => 300, 'spatialColumn' => 'wkt'); +$format = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER <= 8) + ? 'png' : 'svg'; +$visualizationSettings = array( + 'width' => 450, + 'height' => 300, + 'spatialColumn' => 'wkt' +); $data = array(array('wkt' => $wkt_with_zero, 'srid' => $srid)); -$visualization = PMA_GIS_visualizationResults($data, $visualizationSettings, $format); +$visualization = PMA_GIS_visualizationResults( + $data, $visualizationSettings, $format +); $open_layers = PMA_GIS_visualizationResults($data, $visualizationSettings, 'ol'); // If the call is to update the WKT and visualization make an AJAX response @@ -72,34 +86,43 @@ ob_start();
-

- -'); - // The input field to which the final result should be added and corresponding null checkbox - if (isset($_REQUEST['input_name'])) { - echo(''); - } - echo PMA_generate_common_hidden_inputs(); +

+'; +echo ''; +// The input field to which the final result should be added +// and corresponding null checkbox +if (isset($_REQUEST['input_name'])) { + echo ''; +} +echo PMA_generate_common_hidden_inputs(); ?>
-' . $visualization; ?>
/>
@@ -112,13 +135,13 @@ ob_start();
@@ -128,185 +151,213 @@ ob_start();
-'); +'; +} +for ($a = 0; $a < $geom_count; $a++) { + if ($geom_type == 'GEOMETRYCOLLECTION') { + echo('

'); echo __("Geometry"); echo($a + 1 . ':
'); + if (isset($gis_data[$a]['gis_type'])) { + $type = $gis_data[$a]['gis_type']; + } else { + $type = $gis_types[0]; } - for ($a = 0; $a < $geom_count; $a++) { - if ($geom_type == 'GEOMETRYCOLLECTION') { - echo('

'); echo __("Geometry"); echo($a + 1 . ':
'); - if (isset($gis_data[$a]['gis_type'])) { - $type = $gis_data[$a]['gis_type']; - } else { - $type = $gis_types[0]; - } - echo(''); - } else { - $type = $geom_type; + echo(''); + } else { + $type = $geom_type; + } - if ($type == 'POINT') { - echo('
'); echo __("Point"); echo(' :'); + if ($type == 'POINT') { + echo('
'); echo __("Point"); echo(' :'); ?> '); - if (isset($gis_data[$a][$type]['add_point'])) { - $no_of_points++; - } - echo(''); - - for ($i = 0; $i < $no_of_points; $i++) { - echo('
'); - printf(__('Point %d'), $i + 1); - echo ':'; + for ($i = 0; $i < $no_of_points; $i++) { + echo '
'; + printf(__('Point %d'), $i + 1); + echo ':'; ?> "> '; - $no_of_lines = isset($gis_data[$a][$type]['no_of_lines']) ? $gis_data[$a][$type]['no_of_lines'] : 1; - if ($no_of_lines < 1) { - $no_of_lines = 1; + for ($i = 0; $i < $no_of_lines; $i++) { + echo '
'; + if ($type == 'MULTILINESTRING') { + echo __("Linestring"); echo ($i + 1) . ':'; + } else { + if ($i == 0) { + echo __("Outer Ring") . ':'; + } else { + echo __("Inner Ring"); echo $i . ':'; } - if (isset($gis_data[$a][$type]['add_line'])) { - $no_of_lines++; - } - echo(''); + } - for ($i = 0; $i < $no_of_lines; $i++) { - echo('
'); - if ($type == 'MULTILINESTRING') { - echo __("Linestring"); echo($i + 1 . ':'); - } else { - if ($i == 0) { - echo __("Outer Ring") . ':'; - } else { - echo __("Inner Ring"); echo($i . ':'); - } - } + $no_of_points = isset($gis_data[$a][$type][$i]['no_of_points']) + ? $gis_data[$a][$type][$i]['no_of_points'] : 2; + if ($type == 'MULTILINESTRING' && $no_of_points < 2) { + $no_of_points = 2; + } + if ($type == 'POLYGON' && $no_of_points < 4) { + $no_of_points = 4; + } + if (isset($gis_data[$a][$type][$i]['add_point'])) { + $no_of_points++; + } + echo ''; - $no_of_points = isset($gis_data[$a][$type][$i]['no_of_points']) ? $gis_data[$a][$type][$i]['no_of_points'] : 2; - if ($type == 'MULTILINESTRING' && $no_of_points < 2) { - $no_of_points = 2; - } - if ($type == 'POLYGON' && $no_of_points < 4) { - $no_of_points = 4; - } - if (isset($gis_data[$a][$type][$i]['add_point'])) { - $no_of_points++; - } - echo(''); - - for ($j = 0; $j < $no_of_points; $j++) { - echo('
'); - printf(__('Point %d'), $j + 1); - echo ':'; + for ($j = 0; $j < $no_of_points; $j++) { + echo('
'); + printf(__('Point %d'), $j + 1); + echo ':'; ?> - "> -
'); + + for ($k = 0; $k < $no_of_polygons; $k++) { + echo('
'); echo __("Polygon"); echo($k + 1 . ':'); + $no_of_lines = isset($gis_data[$a][$type][$k]['no_of_lines']) + ? $gis_data[$a][$type][$k]['no_of_lines'] : 1; + if ($no_of_lines < 1) { + $no_of_lines = 1; + } + if (isset($gis_data[$a][$type][$k]['add_line'])) { + $no_of_lines++; + } + echo(''); + + for ($i = 0; $i < $no_of_lines; $i++) { + echo('

'); + if ($i == 0) { + echo __("Outer Ring") . ':'; + } else { + echo __("Inner Ring"); echo($i . ':'); } - if (isset($gis_data[$a][$type]['add_polygon'])) { - $no_of_polygons++; + + $no_of_points = isset($gis_data[$a][$type][$k][$i]['no_of_points']) + ? $gis_data[$a][$type][$k][$i]['no_of_points'] : 4; + if ($no_of_points < 4) { + $no_of_points = 4; } - echo(''); + if (isset($gis_data[$a][$type][$k][$i]['add_point'])) { + $no_of_points++; + } + echo(''); - for ($k = 0; $k < $no_of_polygons; $k++) { - echo('
'); echo __("Polygon"); echo($k + 1 . ':'); - $no_of_lines = isset($gis_data[$a][$type][$k]['no_of_lines']) ? $gis_data[$a][$type][$k]['no_of_lines'] : 1; - if ($no_of_lines < 1) { - $no_of_lines = 1; - } - if (isset($gis_data[$a][$type][$k]['add_line'])) { - $no_of_lines++; - } - echo(''); - - for ($i = 0; $i < $no_of_lines; $i++) { - echo('

'); - if ($i == 0) { - echo __("Outer Ring") . ':'; - } else { - echo __("Inner Ring"); echo($i . ':'); - } - - $no_of_points = isset($gis_data[$a][$type][$k][$i]['no_of_points']) ? $gis_data[$a][$type][$k][$i]['no_of_points'] : 4; - if ($no_of_points < 4) { - $no_of_points = 4; - } - if (isset($gis_data[$a][$type][$k][$i]['add_point'])) { - $no_of_points++; - } - echo(''); - - for ($j = 0; $j < $no_of_points; $j++) { - echo('
'); - printf(__('Point %d'), $j + 1); - echo ':'; + for ($j = 0; $j < $no_of_points; $j++) { + echo('
'); + printf(__('Point %d'), $j + 1); + echo ':'; ?> " value="" /> " value="" /> - " class="add addPoint" value=""> -
" class="add addLine" value="">
-
" class="add addPolygon" value=""> -

" /> -
" class="add addPolygon" value=""> +

" /> +

-

+

@@ -315,5 +366,4 @@ ob_start(); PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents()); ob_end_clean(); - ?> From b947fd63c3715f169f55176e87d85d68d89af7e8 Mon Sep 17 00:00:00 2001 From: Dieter Adriaenssens Date: Mon, 3 Sep 2012 17:32:11 +0200 Subject: [PATCH 4/9] improve message --- gis_data_editor.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gis_data_editor.php b/gis_data_editor.php index 8c35e1067b..ab1dc6687d 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -351,8 +351,8 @@ if ($geom_type == 'GEOMETRYCOLLECTION') {