Yet again:

Don't understand why ppl keep asking this. He travelled the world for seven years without any money, and learned how to survive whether it be from hustling, stealing, or living off the land..and this was before he was trained by the League of Shadows. He's now a full fledged trained ninja thanks to the LOS training. Now the Bruce in 'Rises' not only has all the experience i just mentioned, he has also been Batman. Add all that up, and it's not hard to fathom that he could journey back and sneak into Gotham, undetected.
And it wasn't a few hours. The movie doesn't need to spell everything out for us. When Bane had the Doctor tamper with the bomb he said it would go off in 5 months. So from the time of the stadium attack to the events in the final showdown, was 5 months. Bruce had been in that prison i believe about 3 maybe 4 months, he arrived back in Gotham a day or two before the bomb was going to explode, so that means he took
several weeks to get back to Gotham by way of the skills he had learned before. I know the movie doesn't communicate the time transition well, but the film makers don't want to spoon feed us every little bit of info. The fun part about a movie like this is that you sometimes have to figure things out yourself...
In the flashback, when Ra's returns with young Talia and the League of Shadows to get Bane, the prison looks empty. We can assume that Ra's and The League killed all the inmates for what they did to his wife. The man that was taking care of Bruce said "
This is Bane's prison now." So the inmates that were there when Bruce was there were probably ppl who had crossed Bane at some point or another, and weren't actually criminals...