Saturday, October 4, 2008

Source Code Hackery

Many websites these days hide valuable information from the public in an attempt to turn a quick dollar. "Information" could be porn, sure, but it also could be just about anything else. The internet is information...and some of us want free access to all of it. Fortunately, we (PC users) have the almighty right click and the command menu at our disposal (not to say MAC and other users have no solutions: I'm familiar with my tools only).

For example, I came across a particular website with the usual Question/Answer format looking for a solution to a computing problem I had. The answers were hidden behind some great links to "Get Started!" and "Login" and for "Free Trials!"

Naturally, I wasn't going to pay thirteen bucks a month to a website I would probably never see again for an a solution to a massively trivial problem. Out of pure curiosity I pulled up the page's source code (the entire page is right-click friendly) and skimmed through. About halfway through I found these peculiar lines (I used the HTML code for "left bracket" and "right bracket" to prevent the code from executing {Internal side note monologue: I came across a defunct tag that was intended to display HTML without executing: <XMP> and </XMP>, view it in action [link]} and yes those are my italics using good old <i></i>):


<div class="answerer"> Accepted Solution by <a href="/M_1010672.html">JohnChapin</a>:</div>
<div class="answerBody quoted" id="EchoTopic">

Somewhere in your loops put a change to a form control (label or textbox).<br />Then right after the change put a 'doevents' to be sure it registers on the screen.<br />Put it in the smallest loop if you want to see a lot of activity.<br /><br />HTH John</div>


Clearly this is the answer hidden behind the ads. There's a secondary solution just after the first answer that is also revealed in the source code:

<div class="answerer"> Assisted Solution by <a href="/M_1539809.html">Idle_Mind</a>:</div>
<div class="answerBody quoted" id="EchoTopic">
In your <span class="searchTerm">code</span> you probably have a loop running for x iterations or until some condition is met. Inside that loop you need to place a "DoEvents" to allow the application to respond to messages and to allow it to refresh its screen. <br /><br />If you want to be able to <span class="searchTerm">pause</span> the <span class="searchTerm">code</span> from within the program then create a boolean variable and toggle its value from true/false when a button is pressed. Inside your main loop for the genetic algorithm, check the status of the variable and make the loop wait in a Do...While loop until the variable is reset. Again, you will need a "DoEvents" inside that Do...While loop to allow the application to process messages like your <span class="searchTerm">pause</span> button being pushed. A Do...While loop with nothing but DoEvents in it will cause the CPU usage to ramp to 100% but the app will still be responsive. Just thought I would forewarn you.<br /><br />Idle_Mind</div>


Once more, with the code executed (notice the relative/referential links in the posters' names and the problem this causes on this particular website):



Accepted Solution by JohnChapin:



Somewhere in your loops put a change to a form control (label or textbox).
Then right after the change put a 'doevents' to be sure it registers on the screen.
Put it in the smallest loop if you want to see a lot of activity.

HTH John


Assisted Solution by Idle_Mind:


In your code you probably have a loop running for x iterations or until some condition is met. Inside that loop you need to place a "DoEvents" to allow the application to respond to messages and to allow it to refresh its screen.

If you want to be able to pause the code from within the program then create a boolean variable and toggle its value from true/false when a button is pressed. Inside your main loop for the genetic algorithm, check the status of the variable and make the loop wait in a Do...While loop until the variable is reset. Again, you will need a "DoEvents" inside that Do...While loop to allow the application to process messages like your pause button being pushed. A Do...While loop with nothing but DoEvents in it will cause the CPU usage to ramp to 100% but the app will still be responsive. Just thought I would forewarn you.

Idle_Mind



I don't feel comfortable just giving out which website I pulled this simple trick. This has just been a small exhibition of rudimentary information system, breaking and entering.