sc-game.phps

<?
    @error_reporting(0);
    ini_set('display_errors', false);

    define('BOMB_SHIFT', 20);
    define('BOMB_X', 195);
    define('BOMB_START', 10);
    define('AIR_SHIFT_BASE', 15);

    $flycolor = 'navy';

    $data = explode('.', basename($_SERVER['REQUEST_URI']), 2);
    $data = gzinflate(base64_decode(str_rot13($data[0])));
    list($fx, $fy, $by, $bomb, $score, $AIR_SHIFT, $pause, $newairshift, $sum) = $data = str_split($data, 2);
    if ($AIR_SHIFT == 0) {
        $AIR_SHIFT = AIR_SHIFT_BASE;
    }

    // http://www.test/fly/ZmN0ZNNvVQN0OJSGDjN.html

    if ($sum <> substr(md5(implode(array_slice($data, 0, -1))), 0, 2)) {
        header('HTTP/1.0 404 Not found');
        exit;
    }

    if ($by < 2){
        $bomb = 0;
        $newairshift = (int) (15 + 10 * sin($fx));
    }

    $by = (int) $bomb ? $by - 1 : BOMB_START;

    if ($pause > 0) {
        $pause--;
        $bx = 0;
        $showair = false;
    } else {
        if ($fx * $AIR_SHIFT > 350) {
            $fx = 0;
            $AIR_SHIFT = $newairshift;
        }

        $exp = $bomb && $by == 1 && abs($fx * $AIR_SHIFT + 20 - BOMB_X) <= 10;

        if ($exp) {
            $flycolor = 'red';
            if ($score < 99) $score++;
            $newfx = 0;
            $pause = (int) abs(5 * cos($fx + BOMB_X + $by + $fy));
            $bomb = 0;
        } else {
            $newfx = $fx + 1;
            $pause = 0;
        }

        $showair = true;
    }



    $next  = gb_tolink($newfx, $fy, $by, $bomb, $score, $AIR_SHIFT, $pause, $newairshift);
    $start = gb_tolink($newfx && $by == BOMB_START ? $newfx - 1 : $newfx, $fy, $by, 1, $score, $AIR_SHIFT, $pause, $newairshift);

    function gb_tolink(/*$params*/)
    {
        $params = func_get_args();
        $url = vsprintf(str_repeat('%02d', sizeof($params)), $params);
        $url.= substr(md5($url), 0, 2);

        return str_rot13(rtrim(base64_encode(gzdeflate($url, 9)), '=')) . '.html';
    }
?>
<head>
    <meta http-equiv="refresh" content="<?=$exp ? 3 : 1?>;URL=<?=$next?>" />
    <title>Pure HTML air fight</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta name="Author" content="Evgeny Stepanischev (http://bolknote.ru)" />
    <meta name="License" content="New BSD" />
</head>
<body bgcolor="black" text="white" scroll="auto">
<?if ($exp):?>
<audio autoplay="autoplay">
  <source src="fly.ogg" type="audio/ogg" />
  <source src="fly.mp3" type="audio/mpeg" />
  <bgsound src="fly.mp3" loop="0" />
</audio>
<?endif?>
<table width="100%" height="100%">
<tr valign="middle" align="center">
    <td><table width="400" height="271" background="bg.jpg" align="center" cellpadding="0" cellspacing="0" border="0">
    <tr height="<?=$fy * $AIR_SHIFT + 1?>">
        <td colspan="2"><img width="1" height="1" src="0.gif" /></td>
    </tr>
    <tr valign="top" align="left" height="1">
        <td width="<?=$fx * $AIR_SHIFT + 1?>"><img width="1" height="1" src="0.gif" /></td>
        <td align="left" width="<?=400 - $fx * $AIR_SHIFT + 1?>"><font color="<?=$flycolor?>" size="7"><?=$showair ? '✈' : ' '?></font></td>
    </tr>
    <tr valign="top">
        <td colspan="2">
        <table width="400" height="<?=$by * BOMB_SHIFT?>" cellpadding="0" cellspacing="0" border="0">
        <tr valign="bottom" align="left">
            <td width="<?=BOMB_X?>" valign="top">  <font face="Tahoma" size="1">score: <?=sprintf('%02d', $score)?></font></td>
            <td align="left"><hr width="10" size="20" color="red" align="left" /></td>
        </tr></table></td>
    </tr>
    </table><br /><form action="<?=$start?>"><input type="image" src="button.png" border="0" width="40" height="40" /></form></td></font>
</tr>
</table>
</body>