I believe that there is an error in this part of the code:
$CKEditor_config["docType"] = "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
As if I remove the doctype info and leave "" then it doesn't load it into the database each time (the stylesheet info either.)
$CKEditor_config["docType"] = "";
Something to do with not escaping a quote properly?