Your honest and broken cry has been heard, and I thank God with you for the improvement He has already brought. All glory belongs to the Lord Jesus Christ for every step of freedom He has given, and it is right to give Him thanks for what He has done and to keep asking Him for lasting and true deliverance for His glory.
What you are describing begins in the heart. Scripture teaches that a person is tempted when he is drawn away by his own desires and enticed, and when that desire is allowed to remain it gives birth to sin. James also shows that the conflicts and struggles within us come from the lusts that war within us. John explains this further when he says that all that is in the world, the desire of the flesh, the desire of the eyes, and the pride of life, is not from the Father but from the world. The world and its desires are passing away, but the one who does the will of God remains forever. To be a friend of the world in this way is to be opposed to God, so we are called to turn from it completely.
Pornography is one of the most powerful tools the enemy uses to inflame those desires. It is designed to stir up the passions of the flesh and the eyes, and once the door is opened it puts pressure on the heart toward further sexual sin. I have counseled many who found that it took hold of them like a drug, like chains they could not break on their own. It promises pleasure but it enslaves, it damages families and relationships, and it leaves the mind defiled. Flirting, lustful fantasies, and sexual acts outside of God's design all follow that same pattern. God created sex as good, but He placed it within the lifelong covenant of marriage between one man and one woman. Outside of that covenant it is not love but lust, and it will always lead away from holiness.
There is hope because Jesus came to set captives free and to wash us. The time past in our lives is enough to have lived to fulfill the desires of the flesh, living for what the lower nature wants. Now in Christ we are called to live no longer for the lusts of men but for the will of God, to walk in purity and holiness even as Christ is pure. This requires more than trying harder in our own strength. It requires the renewing of the mind. God renews us as we are washed by His Word, as we let Scripture fill our thoughts and replace what has defiled us. It means not looking with lust upon beauty that is meant to entice, cutting the temptation off at the very first thought in the heart rather than letting it grow, and fleeing from every place and image and conversation that feeds it.
The purpose of prayer is not to get God to do our will so we can use His help to satisfy our own desires. We sometimes ask and do not receive because we ask to spend what we receive on our own pleasures. True prayer seeks God's will to be done in us. So we come to Him for mercy, not to bargain with Him, but to surrender fully to Him and ask Him to make us wise, to give us understanding, to speak to us through His Word, and to deliver us completely.
Let us pray together for you now. Father, in the name of Jesus Christ I ask for Your mercy upon this dear one who has wept and prayed before You. Thank You for the victory You have already given and for the work You have begun. I ask that You would complete it and make it lasting and true. Renew the mind, wash the heart and thoughts with Your Word, and make this life wise with the wisdom that comes from You. Break every chain of pornography, masturbation, flirting and sexual sin, and keep these sins far away forever. Teach this heart to hate what You hate and to love purity, to flee temptation, to guard the eyes and the heart, and to live for Your will and Your glory. Give understanding, give strength to walk in the Spirit and not fulfill the desires of the flesh, and let this life show forth the freedom that is in Christ alone. Amen.
Keep seeking the Lord daily in His Word, bring your struggles into the light with a trusted mature believer who can walk with you and hold you accountable, and when temptation comes, turn immediately to Christ and flee. God is faithful, and He who has begun a good work will be faithful to complete it as you continue to walk with Him.