From ec6d8cea37dea123458f2a563ce21672bf3628f8 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Wed, 24 Nov 2010 11:32:53 +0000 Subject: [PATCH] replace ugly shell echo by logfile() git-svn-id: http://www.observium.org/svn/observer/trunk@1736 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 3 +-- includes/functions.php | 11 ++++++++++- poller.php | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/discovery.php b/discovery.php index 1961a0cb50..580095ae43 100755 --- a/discovery.php +++ b/discovery.php @@ -184,7 +184,6 @@ if($discovered_devices) { $string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $discovered_devices devices discovered in $proctime secs"; if ($debug) echo("$string\n"); -# FIXME EWW -shell_exec("echo '".$string."' >> ".$config['log_file']); +logfile($string); ?> diff --git a/includes/functions.php b/includes/functions.php index bc5a5c6ed4..6d7c909209 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -45,11 +45,20 @@ function zeropad_lineno($num, $length) return $num; } -function only_alphanumeric( $string ) +function only_alphanumeric($string) { return preg_replace('/[^a-zA-Z0-9]/', '', $string); } +function logfile($string) +{ + global $config; + + $fd = fopen($config['log_file'],'a'); + fputs($fd,$string); + fclose($fd); +} + function write_dev_attrib($device_id, $attrib_type, $attrib_value) { $count_sql = "SELECT COUNT(*) FROM devices_attribs WHERE `device_id` = '" . $device_id . "' AND `attrib_type` = '$attrib_type'"; diff --git a/poller.php b/poller.php index 2e8c161c8a..283ec4c414 100755 --- a/poller.php +++ b/poller.php @@ -326,7 +326,8 @@ if($polled_devices) { $string = $argv[0] . " $doing " . date("F j, Y, G:i") . " - $polled_devices devices polled in $poller_time secs"; if ($debug) echo("$string\n"); -shell_exec("echo '".$string."' >> ".$config['log_file']); # FIXME EWW + +logfile($string); unset($config); ### Remove this for testing