Mark Salling, known for playing Puck on FOX's hit show Glee, has pled guilty to child pornography charges right before going to trial.

"Mark is focused on accepting responsibility and atoning for his conduct," his lawyer, said in a statement to E! News.

This comes a week after his indictment by a federal grand jury on two counts of child porn for obtaining and possessing over 50,000 images and 600 videos of girls ages 3 to 5 years of age of a sexual nature, according to Mirror UK.

U.S. Attorney Eileen M. Decker said at the time, "Those who download and possess child pornography create a market that causes more children to be harmed. Young victims are harmed every time an image is generated, every time it is distributed, and every time it is viewed."

Salling will serve up to seven years in prison, with this plea. While in prison, he will go through a treatment program and once his time in jail is served he will be registered as a sex offender and spend 20 more years under supervised release.

Terms of the plea also include that he have no verbal or electronic contact with anyone under the age of 18; stay 100 feet away from any place children may be and pay $50,000 in restitution to each victim, according to the documents.