Location: PHPKode > projects > Work project > workproject/include_log_file.inc
<?
function write_log_user ($filename_log, $log) {

	$entry= date('Y-m-d H:i:s');
	$fp_log = fopen($filename_log, "a+");
	fwrite($fp_log,"Date-heure: ". $entry." -: ". $log." \r\n");
	fclose($fp_log);
}

function viewArray($arr) {
   echo '<table cellpadding="0" cellspacing="0" border="1">';
   foreach ($arr as $key1 => $elem1) {
       echo '<tr>';
       echo '<td>'.$key1.'&nbsp;</td>';
       if (is_array($elem1)) { extArray($elem1); }
       else { echo '<td>'.$elem1.'&nbsp;</td>'; }
       echo '</tr>';
   }
   echo '</table>';
}

function extArray($arr) {
   echo '<td>';
   echo '<table cellpadding="0" cellspacing="0" border="1">';
   foreach ($arr as $key => $elem) {
      echo '<tr>';
       echo '<td>'.$key.'&nbsp;</td>';
       if (is_array($elem)) { extArray($elem); }
       else { echo '<td>'.htmlspecialchars($elem).'&nbsp;</td>'; }
      echo '</tr>';
   }
   echo '</table>';
   echo '</td>';
}

# make http and mailto link urls
function filter_href_tags( $p_string ) {

	global $filename_log;
	
	$findme = "href=";
	$pos = strpos($p_string, $findme);
	#write_log_user($filename_log, "REPLACE pos 1: ".$pos." ".$p_string);
	if ( $pos > 0 ){	
		$findme= "http";
		$pos = strpos($p_string, $findme);	
		#write_log_user($filename_log, "REPLACE pos 2: ".$pos." ".$p_string);
		if ($pos == false ) {
			$p_string = eregi_replace( "<a href=","<a href=http://",$p_string);
			#write_log_user($filename_log, "REPLACE pos 3: ".$pos." ".$p_string);
		}
	}
	#write_log_user($filename_log, "REPLACE pos 4: ".$pos." ".$p_string);

	#$p_string = eregi_replace( "(([a-z0-9_]|\\-|\\.)+@([^[:space:]]*)([[:alnum:]-]))",
    #    						"<a href=\"mailto:\\1\" target=\"_new\">\\1</a>",
    #    						$p_string);
	return $p_string;
}
# process $g_html_tags to be treated as html
function filter_html_tags( $p_string ) {
	global $g_html_tags;

	$t_filter_from 	= @array( "/\//", "/</", "/>/" );
	$t_filter_to 	= @array( "\/", "", "" );
	//$t_filter_from 	= @array( "\/", "<", ">" );
	//$t_filter_to 	= @array( "\/", "", "" );

	$t_tag_count = count( $g_html_tags );
	for ($i=0;$i<$t_tag_count;$i++) {
		$tag = preg_replace( $t_filter_from, $t_filter_to, $g_html_tags[$i] );
		$p_string = preg_replace( "/&lt;($tag)&gt;/i", "<\\1>", $p_string );
	}
	return $p_string;
}
# every string that comes form a textarea should be processed through this
# function *before* insertion into the database.
function string_prepare_textarea( $p_string ) {

	#$p_string = htmlspecialchars( $p_string );
	$p_string = filter_html_tags( $p_string );
	$p_string = filter_href_tags( $p_string );
	#$p_string = addslashes( $p_string );
	return $p_string;
}
?>
Return current item: Work project