Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Code Obfuscation

By the way... if anyone is interested... I have accidentally found a way to keep the HTML hidden. If you care, that is. From what I have seen most people are cool with the source code being out there because it isn't super helpful anyway.

But if you are wanting to do that, a side-benefit is that it allows you to protect your story unless an audience member has specific permission to see it.  For example if you were charging people (as in game distribution).

While I was setting up that part of it all, I stumbled over the source code thing. 
<HTML>
<HEAD></HEAD>

<BODY>
<?php



if (


$_POST['uname'] == "test123" ||
$_POST['uname'] == "someUser" ||
$_POST['uname'] == "otherUser"



)

{


$myfile = fopen("Story.html", "r") or die("Unable to open file!");
echo fread($myfile,filesize("Story.html"));
fclose($myfile);

}

else{
?>


<form action="index.php" method="post"> P: <input type="text" name="uname" />
<input type="submit" />
</form>



<?php
}
?>

</BODY>
</HTML>
Paste that into a new file called index.php and you are all set.

BE CAREFUL NOT TO OVERWRITE YOUR EXISTING INDEX. YOU WILL BE ANGRY IF YOU DO.

Comments

  • When you view the source, all you get is this:

    <HTML>
    <HEAD></HEAD>

    <BODY>


    <form action="index.php" method="post"> P: <input type="text" name="uname" />
    <input type="submit" />
    </form>




    </BODY>
    </HTML>
  • im affraid this will make some issue in the future, such as saving file in SugarCube maybe ? but better wait for advice from the expert for this  ;D

    i hope there's no issue about this, this will be awesome  8)  good job

  • You might be able to skip the entire password protection thing and just use the FOPEN/FREAD and then you would get the same results of hiding the html code, but you would not have guarded the access to playing it.
  • Thank you! I wanted a way to help the people that have helped me so much on this forum so I posted some code. I will look into the SugarCube thing as you suggest.
  • This method may work when the users is using the View Source option but wont stop someone using the browser's built-in developer tools from dumping the DOM into a file which will result in them having a copy of your stories HTML.

    HTML, CSS and Javascript are interpreter based languages so if the browser has access to the source of your story then the user has access to the source of your story, it is that simple.

    note: I edited the above line because I realized that I implied that this problem has a solution and it doesn't.

    There are many tricks you can use to make it harder for someone to access the source code but all they do is increase the effort that someone needs to go through to get the source. They also increase the effort the developer needs to go to to create their product but more importantly they increase the risk of the application not working correctly for the paying customer.
  • When you say MAY work... for the view-source option, is that because some browsers will view source differently than another? I only have chrome and it wasn't important enough for me to test it elsewhere because the only part I needed was the password-protection part. And I can tell you, that part does work every time (since the server doesn't serve it without the right password).

    You have me curious about the other part though.  When I look at the source code, that's ALL I SEE (the thing I pasted in).

    Do you see more of it?
  • When viewing a story (or any webpage for that matter) in Chrome press the F12 key to open the Developer Tools, this will open a panel (generally at the bottom of the browser's viewpane) that has a number of tabs across the top of it, click on the first one named Elements.

    This pane contains the HTML elements currently being displayed, place your mouse cursor over the line near the top that starts with <html then use the right mouse button to show a context menu. If you select the Edit as HTML option you will have access to the HTML of the current page which you can cut-n-paste into a file.

    note: This is only one of the ways to get access to the source.

    [quote]When you say MAY work... for the view-source option, is that because some browsers will view source differently than another
    yes.

    p.s. I edited my previous post to remove a part that implied that there is a solution to this issue.
  • Well at least we gave them a way to lock the door and maybe pick up a paycheck!
  • The best answer to the problem of someone taking a copy of your HTML creation (story/web application) is to not worry about it.

    If you make your creation available to your potential customers at a reasonable price (for the content they are getting) and use payment methods that are accessible to them then the average customer will pay for it.
  • I agree completely. Hopefully the log-in screen will help them get there.
Sign In or Register to comment.