anchor.diff:  escape(html, [Char | Text]) ->
       [Char | escape(html, Text)].
   
  -
  -create_table(#state{dbref=DBRef}) ->
  -	?INFO_MSG("Mysql Conn.: ~p", [DBRef]),
  -	Query =  ["CREATE TABLE IF NOT EXISTS ", table_name(), "(",
  -                "id INT AUTO_INCREMENT PRIMARY KEY, ",
  -                "fromJid VARCHAR(255) NOT NULL,",
  -				"toJid VARCHAR(255) NOT NULL,",
  -				"sentDate TIMESTAMP NOT NULL,",
  -				"body TEXT,",
  -				"type VARCHAR(10)",
  -                ") ENGINE=MyISAM CHARACTER SET utf8"],
  -	case sql_query_internal(DBRef, Query) of
  -		{updated, _} -> ok;
  -		{error, _Reason} -> error
  -	end.
  -
  -insert_row(FromJid, ToJid, Body, Type) ->
  -	[{_, DBRef}] = ets:lookup(mod_log_chat_mysql5, dbref),
  -	Query = ["INSERT INTO ", table_name(), " (fromJid, toJid, sentDate, body, type) VALUES",
  -	 		"(\"",
  -	FromJid,
  -	"\", \"",
  -	ToJid, "\", NOW(), \"",
  -	Body, "\", \"", Type ,"\");"],
  -
  -	case sql_query_internal(DBRef, Query) of
  -		{updated, _} -> ok;
  -		{error, _Reason} -> error
  -	end.
  -
  -
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -%
  -% SQL internals
  -%
  -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  -sql_query_internal(DBRef, Query) ->
  -    case sql_query_internal_silent(DBRef, Query) of
  +sql_query(Query) ->
  +    case sql_query_internal_silent(Query) of
            {error, Reason} ->
  -            ?ERROR_MSG("~p while ~p", [Reason, lists:append(Query)]),
  +           ?INFO_MSG("~p while ~p", [Reason, lists:append(Query)]),
               {error, Reason};
            Rez -> Rez
       end.
   
  -sql_query_internal_silent(DBRef, Query) ->
  -    ?DEBUG("DOING: \"~s\"", [lists:append(Query)]),
  -    get_result(mysql_conn:fetch(DBRef, Query, self())).
  +sql_query_internal_silent(Query) ->
  +    ?INFO_MSG("DOING: \"~s\"", [lists:append(Query)]),
  +    get_result(mysql:fetch(mod_log_chat_mysql5_db, Query)).
   
   get_result({updated, MySQLRes}) ->
       {updated, mysql:get_result_affected_rows(MySQLRes)};
  
positive.code: log_packet(_From, _To, _Packet) ->
      ok.
  
  write_packet(From, To, Packet, Type) ->
      Body = escape(html, xml:get_path_s(Packet, [{elem, "body"}, cdata])),
      case Body of
  
negative.code: 	User = gen_mod:get_opt(user, Opts, "root"),
  	Password = gen_mod:get_opt(password, Opts, ""),
  
  	?INFO_MSG("Opening mysql connection ~s@~s:~p/~s", [User, Server, Port, DB]),
  	mysql:start_link(mod_log_chat_mysql5_db, Server, Port, User, Password, DB, LogFun).
  
  %%--------------------------------------------------------------------
  %% Function: terminate(Reason, State) -> void()
  %% Description: This function is called by a gen_server when it is about to
  %% terminate. It should be the opposite of Module:init/1 and do any necessary
  %% cleaning up. When it returns, the gen_server terminates with Reason.
  %% The return value is ignored.
  %%--------------------------------------------------------------------
  terminate(_Reason, _State) ->
  	mysql:stop(),
      ok.
  
  %%--------------------------------------------------------------------
  %% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}
  %% Description: Convert process state when code is changed
  %%--------------------------------------------------------------------
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  %%--------------------------------------------------------------------
  %% Function: %% handle_call(Request, From, State) -> {reply, Reply, State} |
  %%                                      {reply, Reply, State, Timeout} |
  %%                                      {noreply, State} |
  %%                                      {noreply, State, Timeout} |
  %%                                      {stop, Reason, Reply, State} |
  %%                                      {stop, Reason, State}
  %% Description: Handling call messages
  %%--------------------------------------------------------------------
  handle_call(stop, _From, State) ->
      {stop, normal, ok, State}.
  
  %%--------------------------------------------------------------------
  %% Function: handle_cast(Msg, State) -> {noreply, State} |
  %%                                      {noreply, State, Timeout} |
  %%                                      {stop, Reason, State}
  %% Description: Handling cast messages
  %%--------------------------------------------------------------------
  handle_cast({insert_row, FromJid, ToJid, Body, Type}, State) ->
  	?INFO_MSG("inserting row: %p, %p, %s, %s", [FromJid, ToJid, Body, Type]),
  	Query = ["INSERT INTO ", table_name(), " (fromJid, toJid, sentDate, body, type) VALUES",
  	 		"(\"",
  	FromJid,
  	"\", \"",
  	ToJid, "\", NOW(), \"",
  	Body, "\", \"", Type ,"\");"],
  
  	sql_query(Query),
  	{noreply, State}.
  
  %% handle module infos
  handle_info({'DOWN', _MonitorRef, process, _Pid, _Info}, State) ->
      {stop, connection_dropped, State};
  handle_info(Info, State) ->
      ?INFO_MSG("Got Info:~p, State:~p", [Info, State]),
      {noreply, State}.
  
  %% ejabberd hook
  log_packet_send(From, To, Packet) ->
      log_packet(From, To, Packet).
  
  