Remove useless code, variable is set again on next line
Make sure variables are escaped, also replace exec calls to run rm by unlink_if_exists()