How to turn lock/off a iphone 3G when the lock/power button is broken?

My iphone is not jailbroken, just wondering if their is any app which could help.

In settings, general, accessibility turn on assistive touch and a round circle will come up. Click on device and lock screen. To switch it back on just click the home button.

Hope I helped.

Check is the accessibility options on your phone!

You could set the phone to automatically lock after 1 minute for the least. Would be in the Settings app.