Revision 4cb6be62
Added by Doktor Notor over 8 years ago
src/etc/inc/pfsense-utils.inc | ||
---|---|---|
909 | 909 |
return; |
910 | 910 |
} |
911 | 911 |
|
912 |
/* |
|
913 |
* php_check_syntax($code_tocheck, $errormessage): checks $code_to_check for errors |
|
914 |
*/ |
|
915 |
if (!function_exists('php_check_syntax')) { |
|
916 |
global $g; |
|
917 |
function php_check_syntax($code_to_check, &$errormessage) { |
|
918 |
return false; |
|
919 |
$fout = fopen("{$g['tmp_path']}/codetocheck.php", "w"); |
|
920 |
$code = $_POST['content']; |
|
921 |
$code = str_replace("<?php", "", $code); |
|
922 |
$code = str_replace("?>", "", $code); |
|
923 |
fwrite($fout, "<?php\n\n"); |
|
924 |
fwrite($fout, $code_to_check); |
|
925 |
fwrite($fout, "\n\n?>\n"); |
|
926 |
fclose($fout); |
|
927 |
$command = "/usr/local/bin/php-cgi -l {$g['tmp_path']}/codetocheck.php"; |
|
928 |
$output = exec_command($command); |
|
929 |
if (stristr($output, "Errors parsing") == false) { |
|
930 |
echo "false\n"; |
|
931 |
$errormessage = ''; |
|
932 |
return(false); |
|
933 |
} else { |
|
934 |
$errormessage = $output; |
|
935 |
return(true); |
|
936 |
} |
|
937 |
} |
|
938 |
} |
|
939 |
|
|
940 |
/* |
|
941 |
* php_check_filename_syntax($filename, $errormessage): checks the file $filename for errors |
|
942 |
*/ |
|
943 |
if (!function_exists('php_check_syntax')) { |
|
944 |
function php_check_syntax($code_to_check, &$errormessage) { |
|
945 |
return false; |
|
946 |
$command = "/usr/local/bin/php-cgi -l " . escapeshellarg($code_to_check); |
|
947 |
$output = exec_command($command); |
|
948 |
if (stristr($output, "Errors parsing") == false) { |
|
949 |
echo "false\n"; |
|
950 |
$errormessage = ''; |
|
951 |
return(false); |
|
952 |
} else { |
|
953 |
$errormessage = $output; |
|
954 |
return(true); |
|
955 |
} |
|
956 |
} |
|
957 |
} |
|
958 |
|
|
959 | 912 |
/* |
960 | 913 |
* rmdir_recursive($path, $follow_links=false) |
961 | 914 |
* Recursively remove a directory tree (rm -rf path) |
Also available in: Unified diff
Remove unused broken functions
Not sure what was the idea here, but these are not used anywhere, do nothing as they immediately call ```return false;``` plus the second one is also misnamed.
(cherry picked from commit edba33b5a567ab8c9d4827fa26a25bd9649e3fac)