1st step, get a good battery and see if the phone stops shutting off and turning on when charging on M. We can take it from there after you have a charge. Like has been said. You might need to flash a Rom or SBF your phone. Lets get it charged 1st.
Sent from a long time ago in a galaxy far far away, from my hTc Thunderbolt