A city of the second class shall have the power to prevent the dangerous construction and condition of chimneys, fireplaces, hearths, stoves, stovepipes, ovens, or boilers used in and about any building and to cause such to be removed or placed in a safe condition, as the city council may prescribe by ordinance. Such city may regulate and prevent by ordinance the deposit of ashes in unsafe places and cause all dangerous buildings and enclosures to be put in safe condition.