Chrisj Posted October 5, 2013 Share Posted October 5, 2013 Is there any way to block a web visitor from seeing the code of my php web site, when they right-click > View Source? Or at least blocking them from copying the code that they see when they right-click > View Source? Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/ Share on other sites More sharing options...
fastsol Posted October 5, 2013 Share Posted October 5, 2013 Not reliably, most modern browsers have other means besides right-click to view the source also, so you can override that aspect at all. There are ways to modify the right-click menu or disable right-click on the webpage but it's not a universal thing you can consistently control. If the use simply disabled javascript your attempts to disable would be disabled itself. Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/#findComment-1452651 Share on other sites More sharing options...
.josh Posted October 5, 2013 Share Posted October 5, 2013 You can do a basic shell of a webpage and then use AJAX (javascript) to load the content. This will make the bulk of your stuff not show up in the viewsource. However it makes your site reliant on javascript to work, and anybody who is determined to see/get the page's sourcecode can quite easily get it from somewhere else besides viewing the source. You should not worry about this sort of thing. There is nothing you can output that can't be found somewhere else, and you can't do anything about it anyways. Instead you should just focus on your server-side validation/security and offering up a great product or service or whatever your site is about. Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/#findComment-1452653 Share on other sites More sharing options...
jcbones Posted October 5, 2013 Share Posted October 5, 2013 Even at that, they can highlight the page, then select view selected source, and it will show the source. Even if loaded with javascript. Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/#findComment-1452657 Share on other sites More sharing options...
ignace Posted October 5, 2013 Share Posted October 5, 2013 (edited) You can also just: $ curl http://www.your-domain.top/The only way to block people from viewing your source is to do this: <?php exit;At the start of every script. This effectively blocks anyone from viewing source or anything else for that matter. Another option to block people from viewing source is to change your DNS entry: your-domain.top A 88.88.88.88You can change the IP to whatever you like, it really does not matter. It may take a few hours though before they are no longer able to view your source. Though it is more effective then the previous described technique. The third option saves you money to stop people from viewing your source. Simply stop paying your hosting company. And you'll see that after some time, they won't be able to view source. Cost effective, but slow. Edited October 5, 2013 by ignace Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/#findComment-1452669 Share on other sites More sharing options...
devhinge086 Posted October 7, 2013 Share Posted October 7, 2013 Hey dude 3rd is awesome Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/#findComment-1452905 Share on other sites More sharing options...
brentman Posted October 10, 2013 Share Posted October 10, 2013 Server Side language isn't viewable in "View Source" only the output. You can't block the output. But the important part, the php code, is not viewable and safe. (Providing your code is secure) Quote Link to comment https://forums.phpfreaks.com/topic/282727-block-web-visitors-from-view-source/#findComment-1453490 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.