diff --git a/flowview_devices.php b/flowview_devices.php index 31659e1..a337ef4 100644 --- a/flowview_devices.php +++ b/flowview_devices.php @@ -298,7 +298,10 @@ function save_device() { $id = flowview_sql_save($save, 'plugin_flowview_devices', 'id', true); - $pid = db_fetch_cell('SELECT pid FROM processes WHERE tasktype="flowview" AND taskname="master"'); + $pid = db_fetch_cell_prepared('SELECT pid + FROM processes + WHERE tasktype = ? + AND taskname = ?', array('flowview', 'master')); if (is_error_message()) { raise_message(2); @@ -320,10 +323,10 @@ function save_device() { } function restart_services() { - $pid = db_fetch_cell('SELECT pid + $pid = db_fetch_cell_prepared('SELECT pid FROM processes - WHERE tasktype="flowview" - AND taskname="master"'); + WHERE tasktype = ? + AND taskname = ?', array('flowview', 'master')); if ($pid > 0) { if (!defined('SIGHUP')) { @@ -974,4 +977,3 @@ function clearFilter() { form_end(); } - diff --git a/setup.php b/setup.php index cb032bb..fa7e9eb 100644 --- a/setup.php +++ b/setup.php @@ -107,9 +107,9 @@ function plugin_flowview_check_upgrade($force = false) { $info = plugin_flowview_version(); $current = $info['version']; - $old = db_fetch_cell('SELECT version + $old = db_fetch_cell_prepared('SELECT version FROM plugin_config - WHERE directory="flowview"'); + WHERE directory = ?', array('flowview')); if ($current != $old || $force) { $php_binary = read_config_option('path_php_binary'); @@ -321,7 +321,10 @@ function flowview_global_settings_update() { } if ($hup_process) { - $pid = db_fetch_cell('SELECT pid FROM processes WHERE tasktype="flowview" AND taskname="master"'); + $pid = db_fetch_cell_prepared('SELECT pid + FROM processes + WHERE tasktype = ? + AND taskname = ?', array('flowview', 'master')); if ($pid > 0) { if (!defined('SIGHUP')) { @@ -1309,4 +1312,3 @@ function flowview_graph_button($data) { } } } - diff --git a/tests/test_prepared_statements.php b/tests/test_prepared_statements.php new file mode 100644 index 0000000..43693b7 --- /dev/null +++ b/tests/test_prepared_statements.php @@ -0,0 +1,89 @@ +