Permalink
Browse files

Merge branch 'postgresql' of github.com:tomoconnor/FITB into postgresql

  • Loading branch information...
2 parents 3cab534 + 82fb764 commit c4953db792e58efdbc04c4f1480c7e44f6e191e1 Tom O'Connor committed Apr 25, 2012
Showing with 7 additions and 7 deletions.
  1. +4 −4 search.php
  2. +1 −1 viewgraph.php
  3. +1 −1 viewhost.php
  4. +1 −1 viewport.php
View
@@ -40,15 +40,15 @@
?>
<?php
connectToDB();
- $searchquery = pg_escape_literal($searchquery);
+ $searchquery = pg_escape_string($searchquery);
if (isset($host)) {
- $host = pg_escape_literal($host);
- $type = pg_escape_literal($type);
+ $host = pg_escape_string($host);
+ $type = pg_escape_string($type);
$result = pg_query('SELECT * FROM ports WHERE (name like "%' . $searchquery . '%" OR alias like "%' . $searchquery . '%")
AND graphtype like "%' . $type . '%" AND host="' . $host . '" ORDER BY lastpoll DESC, safename ASC');
} elseif (isset($type)) {
- $type = pg_escape_literal($type);
+ $type = pg_escape_string($type);
$result = pg_query('SELECT * FROM ports WHERE (name like "%' . $searchquery . '%" OR alias like "%' . $searchquery . '%")
AND graphtype="' . $type . '" ORDER BY lastpoll DESC, safename ASC');
} else {
View
@@ -32,7 +32,7 @@
<h2>View graph - <?php echo "$viewhost - $viewport - $viewtype" ?></h2>
<?php
connectToDB();
- $result = pg_query('SELECT * FROM ports WHERE host="' . pg_escape_literal($viewhost). '" AND graphtype="' . pg_escape_literal($viewtype) . '" AND safename="' . pg_escape_literal($viewport) . '" ');
+ $result = pg_query('SELECT * FROM ports WHERE host=\'' . pg_escape_string($viewhost). '\' AND graphtype=\'' . pg_escape_string($viewtype) . '\' AND safename=\'' . pg_escape_string($viewport) . '\' ');
if(pg_num_rows($result) > 0) {
$row = pg_fetch_assoc($result);
View
@@ -28,7 +28,7 @@
<?php
# Lets find some graphs! Connect to the database, select all the ports for this host, and this graphtype (Empty wildcard makes sure all graphs appear if none set)
if (connectToDB()) {
- $result = pg_query('SELECT * FROM ports WHERE host like "%' . pg_escape_literal($viewhost). '%" AND graphtype like "%' . pg_escape_literal($viewtype) . '%" ORDER BY lastpoll DESC, safename ASC');
+ $result = pg_query('SELECT * FROM ports WHERE host like \'%' . pg_escape_string($viewhost). '%\' AND graphtype like \'%' . pg_escape_string($viewtype) . '%\' ORDER BY lastpoll DESC, safename ASC');
if(pg_num_rows($result) > 0) {
View
@@ -27,7 +27,7 @@
<h2>View port - <?php echo "$viewhost - $viewport" ?></h2>
<?php
connectToDB();
- $result = pg_query('SELECT * FROM ports WHERE host="' . pg_escape_literal($viewhost). '" AND safename="' . pg_escape_literal($viewport) . '" ORDER BY lastpoll DESC, safename ASC');
+ $result = pg_query('SELECT * FROM ports WHERE host=\'' . pg_escape_string($viewhost). '\' AND safename=\'' . pg_escape_string($viewport) . '\' ORDER BY lastpoll DESC, safename ASC');
if(pg_num_rows($result) > 0) {

0 comments on commit c4953db

Please sign in to comment.