<?php
// This function is used to store the log messages into the logfile and print the message on the screen.
function writelog($type) {
// Specify the global variables.
global $message;
global $open_log_file;
global $log_file;
// We check if we have to write to the logfile.
if($type == 'l' || $type == 'b') {
// We check if logging is enabled.
if($log_file == 1) {
// Specify the html tags which have to be removed.
$pattern = array("<strong>", "</strong>");
// Remove html tags from the message.
$log_message = str_replace("<br />", "\n", $message);
$log_message = str_replace($pattern, "", $log_message);
// Writing to the logfile.
if (!fwrite($open_log_file, $log_message)) {
echo "Cannot write to the logfile !<br />\n";
}
}
}
// We check if we have to write to the screen.
if($type == 's' || $type == 'b') {
// Writing to the screen.
echo $message."\n";
}
}
?>