Exemple #1
0
            $new_fog[$new_y] = substr_replace($new_fog[$new_y], substr($old_fog[$old_y], $old_x, $length), $new_x, $length);
        }
        // remove walls outside the map
        if ($rows[0]['type'] == 'hex') {
            // remove SW and SE walls from first row of odd numbered columns
            for ($x = 1; $x < $new_width + 2; $x += 2) {
                $new_walls[0][$x] = $base64[strpos($base64, $new_walls[0][$x]) & 12];
            }
        } else {
            // remove E walls from first row
            for ($x = 0; $x < $new_width + 2; $x++) {
                $new_walls[0][$x] = $base64[strpos($base64, $new_walls[0][$x]) & 12];
            }
        }
        for ($x = $new_width + 1, $y = 0; $y < $new_height + 1; $y++) {
            // remove SW and S walls from left column
            $new_walls[$y][0] = $base64[strpos($base64, $new_walls[$y][0]) & 3];
            // remove S and SE or E walls from right column
            $new_walls[$y][$x] = $base64[strpos($base64, $new_walls[$y][$x]) & 48];
        }
        // save the changes
        $b64fog = '';
        // pack new fog bits one sextuplet at a time
        foreach (str_split(implode($new_fog), 6) as $b) {
            $b64fog .= b2a($b);
        }
        if (LT_call('update_map_size', $map, $left, $top, $right, $bottom, implode($new_tiles), implode($new_walls), $b64fog)) {
            $LT_SQL->commit();
        }
    }
}
Exemple #2
0
// Interpret the Request
$map = intval($_REQUEST['map']);
$x = intval($_REQUEST['x']);
$y = intval($_REQUEST['y']);
$fog = $LT_SQL->real_escape_string($_REQUEST['fog']);
// Query the Database
if (LT_can_edit_map($map)) {
    $LT_SQL->autocommit(FALSE);
    /* avoid canceling simultaneous edits */
    if ($rows = LT_call('read_map_tiles', $map)) {
        $width = intval($rows[0]['columns']);
        $height = intval($rows[0]['rows']);
        if ($x >= 0 && $x < $width && $y >= 0 && $y < $height) {
            $old_fog = '';
            // unpack fog bits one sextuplet at a time
            foreach (str_split($rows[0]['fog']) as $a) {
                $old_fog .= a2b($a);
            }
            $old_fog[$x + $y * $width] = $fog;
            // change fog state
            $new_fog = '';
            // pack new fog bits one sextuplet at a time
            foreach (str_split($old_fog, 6) as $b) {
                $new_fog .= b2a($b);
            }
            if (is_array(LT_call('update_map_fog', $map, $new_fog))) {
                $LT_SQL->commit();
            }
        }
    }
}
Exemple #3
0
function template_torrents($v)
{
    $d = '';
    $d .= '<center>';
    $d .= '<form action="?" method=post>';
    $d .= '<table>';
    $d .= '<caption>Torrents</caption>';
    $d .= '<tr>';
    $d .= '<th>';
    $d .= '<th align=left>Name';
    $d .= '<th align=right>%';
    $d .= '<th align=right>Left';
    $d .= '<th align=right>Size';
    $d .= '<th align=right>Downloaded';
    $d .= '<th align=right>Uploaded';
    $d .= '<th align=right>Down rate';
    $d .= '<th align=right>Up rate';
    $d .= '<th align=right>Leechers';
    $d .= '<th align=right>Seeders';
    $d .= '<th align=right>Priority';
    $d .= '<th align=right>State';
    $d .= $v['rows'];
    if ($v['aggregate']['size']) {
        $d .= '<tr>';
        $d .= '<th>';
        $d .= '<th>';
        $d .= sprintf('<th align=right>%d', ($v['aggregate']['size'] - $v['aggregate']['left']) * 100 / $v['aggregate']['size']);
        $d .= sprintf('<th align=right>%s', b2a($v['aggregate']['left']));
        $d .= sprintf('<th align=right>%s', b2a($v['aggregate']['size']));
        $d .= sprintf('<th align=right>%s', b2a($v['aggregate']['total downloaded']));
        $d .= sprintf('<th align=right>%s', b2a($v['aggregate']['total uploaded']));
        $d .= sprintf('<th align=right>%s', b2a($v['aggregate']['down rate']));
        $d .= sprintf('<th align=right>%s', b2a($v['aggregate']['up rate']));
        $d .= sprintf('<th align=right>');
        if ($v['aggregate']['incomplete'] || $v['aggregate']['incomplete total']) {
            $d .= $v['aggregate']['incomplete'];
            if ($v['aggregate']['incomplete total']) {
                $d .= ' / ' . $v['aggregate']['incomplete total'];
            }
        }
        $d .= sprintf('<th align=right>');
        if ($v['aggregate']['complete'] || $v['aggregate']['complete total']) {
            $d .= $v['aggregate']['complete'];
            if ($v['aggregate']['complete total']) {
                $d .= ' / ' . $v['aggregate']['complete total'];
            }
        }
        $d .= '<th>';
        $d .= '<th>';
    }
    $d .= '</table>';
    $d .= '<br>';
    $d .= '<select name="a" onchange="this.form.submit();">';
    $d .= '<option>Do...</option>';
    $d .= '<option value="set_priority_high">Priority - High</option>';
    $d .= '<option value="set_priority_normal">Priority - Normal</option>';
    $d .= '<option value="set_priority_low">Priority - Low</option>';
    $d .= '<option value="set_state_queued">State - Queued</option>';
    $d .= '<option value="set_state_started">State - Started</option>';
    $d .= '<option value="set_state_paused">State - Paused</option>';
    $d .= '<option value="set_state_stopped">State - Stopped</option>';
    $d .= '<option value="close">Close</option>';
    $d .= '</select>';
    $d .= '</form>';
    $d .= '</center>';
    $d .= '<hr>';
    $d .= '<center>';
    $d .= '<form action="?" enctype="multipart/form-data" method=post>';
    $d .= '<table>';
    $d .= '<tr>';
    $d .= '<td><input type=file name=file>';
    $d .= '<td><input type=submit value="Open">';
    $d .= '</table>';
    $d .= '</form>';
    $d .= '</center>';
    return $d;
}