I was thinking about creating a site that just loads the site content from a .txt file or something like that through and AJAX connection with jquery. The thing is, If I do that,can’t people (by people I mean hackers and what not) just come along and change around my .txt file, and is there a way I can secure this?
Share
As long as the AJAX request has the
HTTP_X_REQUESTED_WITHwith it (jQuery ajax requests have this) then you can redirect the user away from the file with PHP like this:If this is at the top of the text file, then it will work but you will have to request the text file with the
.phpextension rather than.txtbut it will still be a text file because the firstheader()call sets it to plain text.