Beispiel #1
0
<?php

Labyrinth::main();
class Labyrinth
{
    private static $lab = array(array('.', '.', '.', '*', '.', '.', '.'), array('*', '*', '.', '*', '.', '*', '.'), array('.', '.', '.', '.', '.', '.', '.'), array('.', '*', '*', '*', '*', '*', '.'), array('.', '.', '.', '.', '.', '.', 'E'));
    private static $numRows = 4;
    private static $numcols = 6;
    public static function main()
    {
        self::head();
        self::printLabyrinth();
        self::findExit(0, 0, 'S');
    }
    private static function head()
    {
        echo "<!doctype html>\n                <head>\n                    <style>\n                        body { \n                            font-family: Lucida Console,Lucida Sans Typewriter,monaco,Bitstream Vera Sans Mono,monospace; \n                            font-size: 36px;\n                            }\n                    </style>\n                </head>\n            <body>";
    }
    private static function findExit($row, $col, $dir)
    {
        if ($row < 0 || $col < 0 || $row > self::$numRows || $col > self::$numcols) {
            return;
        }
        if (self::$lab[$row][$col] == 'E') {
            // exit
            self::printLabyrinth();
            return;
        }
        if (self::$lab[$row][$col] != '.') {
            // cell already visited
            return;
Beispiel #2
0
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 */
include_once 'config.inc.php';
include_once 'labyrinth.inc.php';
include_once 'dissociated-press.inc.php';
$labyrinth_handle = new Labyrinth($_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT']);
// Obviously, a search engine spider hitting this will be like an unstoppable
// force striking an immovable object. If the user agent appears to be a
// search engine return a 404 error and serenade them with some Tom Petty.
if ($labyrinth_handle->CheckForSearchEngines()) {
    header("HTTP/1.0 404 Not Found");
    print "o/~ Whatever you're looking for... / Hey! Don't come around here no more... o/~";
    exit;
}
// Randomly generate an error just to "Keep it real"
// This was mainly done to fool w3af
$labyrinth_handle->SpinTheWheelOfErrors();
// If index.php is in the request URI, lob it off. Otherwise, lob off the trailing slash.
if (preg_match("/index.php/", $_SERVER['REQUEST_URI'])) {
    $directory = dirname($_SERVER['REQUEST_URI']);
} else {