Recent Advances in Functionalized Nanoporous Carbons Derived from Waste Resources and Their Applications in Energy and Environment