The best thing to do is to avoid the computer completely until you've finished your work; you know that the "simple check-up" is going to turn into a full fledged 10 hour session. However, it's always hard to go cold turkey.
When I was in school, something I found useful was an egg timer. Set it for fifteen minutes or less, just enough to do whatever you need to do, and then when it goes off you're jarred out of the comatose, drug-like trance that compels you to waste your time. You could also use an incredibly loud and annoying alarm clock, which is what I preferred. Set it far enough away from wherever you're sitting that you HAVE to get up to turn it off. The physical stimulation should do you good.
Also, I strongly suggest joining a study group. Bonus points if you study outside of your home, like at a library or park or even somebody else's house.