If elevating machines or hoisting apparatus are used within a building in the course of construction, for the purpose of lifting material, the contractor, owner, or lessee shall cause all shafts or openings in the floors, such as stairways, ladder openings, or elevator shafts, to be enclosed or fenced all around by a substantial railing at least four feet in height.