Fix #1707 move substr() outside of get_current_location()

As the title says.

https://github.com/mybb/mybb/issues/1707
Simplify the code

...
Merge pull request #1723 from Destroy666x/fix1707

Fix #1707 move substr() outside of get_current_location()