Пример #1
0
function format_int_0($str)
{
    $str = format_int($str);
    if ($str == '') {
        return '0';
    }
    return $str;
}
Пример #2
0
function update($table = NULL)
{
    if (!$table) {
        $table = $GLOBALS['table'];
    }
    $id = format_int($_REQUEST['id']);
    db_update($table, fields($table), values($table), "where id={$id}");
}
Пример #3
0
function get_square_id()
{
    if (isset($_REQUEST['square'])) {
        $square = format_int($_REQUEST['square']);
        dbg_log("{$looking} up #{$square}<br />\n");
        if (db4_exists($square)) {
            if (isset($_REQUEST['zoom'])) {
                list($parent, $position, $tog0, $tog1, $tog2, $tog3, $id0, $id1, $id2, $id3) = db_get_square($square);
                switch ($_REQUEST['zoom']) {
                    case '0':
                        $new = $id0;
                        break;
                    case '1':
                        $new = $id1;
                        break;
                    case '2':
                        $new = $id2;
                        break;
                    case '3':
                        $new = $id3;
                        break;
                    case 'out':
                        $new = $parent;
                        break;
                    default:
                        $new = false;
                }
                if ($new) {
                    # zoom zoom
                    $square = $new;
                }
            }
        } else {
            print 'NOT FOUND';
            $square = 1;
        }
    } else {
        $square = 1;
    }
    return $square;
}
Пример #4
0
function _db_printf($str, $args)
{
    $out = '';
    while ($str) {
        $pos = strpos($str, '%');
        if ($pos === false) {
            # not found
            # we hit the end.
            return $out . $str;
        }
        # move everything up to (but not including) % to the output
        $out .= substr($str, 0, $pos);
        # grab the character after the %
        $chr = substr($str, $pos + 1, 1);
        # remove the stuff we've read from input
        $str = substr($str, $pos + 2);
        if ($chr == '"') {
            $out .= '"' . enc_sql(array_shift($args)) . '"';
        } elseif ($chr == 's') {
            $out .= enc_sql(array_shift($args));
        } elseif ($chr == 'i') {
            $int = format_int(array_shift($args));
            if ($int == '') {
                $int = '0';
            }
            $out .= $int;
        } else {
            $out .= $chr;
        }
    }
    return $out;
}