News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Disabling View Source

Started by -=[Vyorel]=-, May 25, 2012, 07:38:52 PM

Previous topic - Next topic

-=[Vyorel]=-

Hello all!

Is there a script that will disable view source altogether?
My mods for SMF - [6].

Arantor


MrPhil

You mean the HTML page source? No. It's not that valuable, anyway -- it would just be a static page. The real treasure is the data and the SMF PHP code. No one can get directly to your copies. What are you trying to hide?

Arantor

Normally this gets asked alongside 'how can I block right click?' (answer, you can't) and 'how do I protect people copy/pasting text/images' (answer, you can't)

I've found, though, that this is a battle that isn't generally worth fighting over and normally leave it at 'it isn't possible' because it only leads to 'but it must be' followed by explaining the various provisions that make whatever you try to put in to 'protect yourself' easy to bypass...

-=[Vyorel]=-

For disable right click is perfectly this mod, but I need to disable Ctrl+U.

For example this code:
<script language="JavaScript">
function disableCtrlAltrKeyCombination(e)
{
    var ctrlu='u';
    var altrs='s';
    var key;
    var isCtrl;
    var isAltr;

    //For Ctrl
    //For Internet Explorer

    if(window.event)
    {
        key = window.event.keyCode;
        if(window.event.ctrlKey)
            isCtrl = true;
            else
        isCtrl = false;
    }
    //For Firefox
    else
    {
        key = e.which;     //firefox
        if(e.ctrlKey)
            isCtrl = true;
            else
        isCtrl = false;
    }

    //For Alter
    //For Internet Explorer
    if(window.event)
    {
        key = window.event.keyCode;     //IE
        if(window.event.altrKey)
            isAltr = true;
            else
        isAltr = false;
    }
    //For Firefox
    else
    {
        key = e.which;     //firefox
        if(e.altrKey)
            isAltr = true;
            else
        isAltr= false;
    }

    //Check For CTRL+U
    if(isCtrl)
    {
        if(ctrlu.toLowerCase() == String.fromCharCode(key).toLowerCase())
        {
            alert('Key combination CTRL + U has been disabled.');
        }
        return false;
    }

    //Check For ALTR+S
    if(isCtrl)
    {
        if(altrs.toLowerCase() == String.fromCharCode(key).toLowerCase())
        {
            alert('Key combination ALTR + S has been disabled.');
        }
        return false;
    }
    return true;
}
</script>

<input type="text" name="mytext" onKeyPress="return disableCtrlAltrKeyCombination(event);" onKeyDown="return disableCtrlAltrKeyCombination(event);" />

but this code is not run.  :(
My mods for SMF - [6].

Arantor

You realise that it's trivially possible to bypass disable-right click, right?

And that even if you attach code to forcibly suppress Ctrl-U, and F12 to bring up developer tools, there's no way to stop users going to the menus in browsers or using the likes of Firebug or Chrome Inspector.

Long story short (as entirely predicted) this is NOT POSSIBLE. No matter how much protection you think you have against this, it's almost always trivially easy to bypass and even where it isn't trivial, it's still no more than a few minutes' work.

-=[Vyorel]=-

Quote from: Arantor on May 25, 2012, 09:23:09 PM
Long story short (as entirely predicted) this is NOT POSSIBLE. No matter how much protection you think you have against this, it's almost always trivially easy to bypass and even where it isn't trivial, it's still no more than a few minutes' work.
Look here. Is possible. :(
My mods for SMF - [6].

Arantor

Seriously I'm telling you it's not possible to prevent view source from being used - not without infecting the browser with some malware - and I don't think your users would like that.

I would look at that site but it appears to be down - and even if it were up I know full well I could view the source with a few keypresses. Just because you don't know how to immediately do so doesn't mean I can't bypass that with minimal effort.

Advertisement: