diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-03-13 21:40:06 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-03-13 21:40:06 +0000 |
commit | ee8f4a58c153037a597f67c5148342971314d338 (patch) | |
tree | b9044e422035319ff683c850b06a1232ec7dc440 /etc | |
parent | 8938884094498d4b605ffdbd0b55b8080af85f15 (diff) | |
download | pfsense-ee8f4a58c153037a597f67c5148342971314d338.zip pfsense-ee8f4a58c153037a597f67c5148342971314d338.tar.gz |
* Add php_check_syntax()
* Add php_check_filename_syntax()
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/pfsense-utils.inc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 0a46eba..eba68c0 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -811,4 +811,40 @@ Content-Length: $content_length } +/* + * php_check_syntax($code_tocheck, $errormessage): checks $code_to_check for errors + */ +if (!function_exists('php_check_syntax')){ + function php_check_syntax($code_to_check, &$errormessage){ + $fout = fopen("/tmp/codetocheck.php","w"); + fwrite($fout, $code_to_check); + $command = 'php -l ' . "/tmp/codetocheck.php"; + $output = shell_exec($command); + if (strpos($output, 'No syntax errors detected in') !== false){ + $errormessage = ''; + return(true); + } else { + $errormessage = $output; + return(false); + } + } +} + +/* + * php_check_filename_syntax($filename, $errormessage): checks the file $filename for errors + */ +if (!function_exists('php_check_filename_syntax')){ + function php_check_filename_syntax($filename, &$errormessage){ + $command = 'php -l ' . $filename; + $output = shell_exec($command); + if (strpos($output, 'No syntax errors detected in') !== false){ + $errormessage = ''; + return(true); + } else { + $errormessage = $output; + return(false); + } + } +} + ?>
\ No newline at end of file |