If you have had any problems with substance abuse in the past are you allowed to fly planes?

Yes. Employers are not allowed by federal law to discriminate due to past substance abuse.
It depends. If you're 35 now and used marijuana a few times in your teens without any consequences, you'd probably be okay. If you've had a more serious problem with addiction including arrests or frequent relapses, or you've used a lot of hard-core drugs (heroin, meth, etc.), it probably isn't safe for you to be a pilot.