Update sql_query_result.php

This commit is contained in:
FusionPBX
2019-04-17 09:38:54 -06:00
committed by GitHub
parent 3b1ff3e0ef
commit 9ec2587059
+8 -8
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@@ -129,7 +129,7 @@ if (count($_POST)>0) {
if (sizeof($sql_array) > 1 || $show_query) { if (sizeof($sql_array) > 1 || $show_query) {
if ($sql_index > 0) { echo "<br /><br /><br />"; } if ($sql_index > 0) { echo "<br /><br /><br />"; }
echo "<span style='display: block; padding: 8px; color: green; background-color: #eefff0;'>".$sql.";</span><br />"; echo "<span style='display: block; padding: 8px; color: green; background-color: #eefff0;'>".escape($sql).";</span><br />";
} }
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -152,7 +152,7 @@ if (count($_POST)>0) {
$x = 0; $x = 0;
if (is_array($result[0])) { if (is_array($result[0])) {
foreach ($result[0] as $key => $value) { foreach ($result[0] as $key => $value) {
echo "<th>".$key."</th>"; echo "<th>".escape($key)."</th>";
$column_array[$x++] = $key; $column_array[$x++] = $key;
} }
} }
@@ -163,7 +163,7 @@ if (count($_POST)>0) {
echo "<tr>\n"; echo "<tr>\n";
if (is_array($column_array)) { if (is_array($column_array)) {
foreach ($column_array as $column_index => $column) { foreach ($column_array as $column_index => $column) {
echo "<td class='".$row_style[$c]."' ".(($column_index == 0) ? "style='border-left: none;'" : null).">".$row[$column]."&nbsp;</td>"; echo "<td class='".$row_style[$c]."' ".(($column_index == 0) ? "style='border-left: none;'" : null).">".escape($row[$column])."&nbsp;</td>";
} }
} }
echo "</tr>\n"; echo "</tr>\n";
@@ -233,7 +233,7 @@ if (count($_POST)>0) {
} }
} }
if (is_array($values) && sizeof($values) > 0) { if (is_array($values) && sizeof($values) > 0) {
echo implode(', ', $values); echo implode(', ', escape($values));
} }
echo ");<br />\n"; echo ");<br />\n";
unset($columns, $values); unset($columns, $values);
@@ -246,7 +246,7 @@ if (count($_POST)>0) {
//set the headers //set the headers
header('Content-type: application/octet-binary'); header('Content-type: application/octet-binary');
header('Content-Disposition: attachment; filename='.$table_name.'.csv'); header('Content-Disposition: attachment; filename='.escape($table_name).'.csv');
//get the table data //get the table data
$sql = trim($sql); $sql = trim($sql);
@@ -272,13 +272,13 @@ if (count($_POST)>0) {
} }
} }
//column names //column names
echo '"'.implode('","', $column_array).'"'."\r\n"; echo '"'.implode('","', escape($column_array)).'"'."\r\n";
//column values //column values
if (is_array($result)) { if (is_array($result)) {
foreach ($result as &$row) { foreach ($result as &$row) {
$x = 1; $x = 1;
foreach ($column_array as $column) { foreach ($column_array as $column) {
echo '"'.check_str($row[$column]).'"'.(($x++ < count($column_array)) ? ',' : null); echo '"'.escape($row[$column]).'"'.(($x++ < count($column_array)) ? ',' : null);
} }
echo "\n"; echo "\n";
} }