Path traversal prevention in PHP
Security

This can be bypassed by /\... 

You are currently checking if / is followed by . and reject the input if that is the case. But as you can see, it is possible to traverse with different sequences (null bytes would be another candidate for bypasses).

It would be a bit more secure if you checked for ... To really prevent directory traversal, you should check if the resolved path is inside the desired directory.

Misc


dieing inside a function is always a bad idea, as you have no more control over the code. The calling function can't recover, the function can't be reused, etc.
You are vulnerable to XSS.
I would put each statement on it's own line (e.g. if/else on the same line is a bit difficult to read).