Example #1
0
function runInstruction()
{
    global $in, $a, $b, $idx;
    do {
        $cmd = $in[$idx];
        printf("%d\t%d\t%d\t%s\n", $idx, $a, $b, implode(' ', $cmd));
        $inc = true;
        switch ($cmd[0]) {
            case 'hlf':
                ${$cmd}[1] /= 2;
                break;
            case 'tpl':
                ${$cmd}[1] *= 3;
                break;
            case 'inc':
                ${$cmd}[1]++;
                break;
            case 'jmp':
                jmp($cmd[1]);
                $inc = false;
                break;
            case 'jie':
                $r = rtrim($cmd[1], ',');
                if (${$r} % 2 == 0) {
                    jmp($cmd[2]);
                    $inc = false;
                }
                break;
            case 'jio':
                //print ("jio $idx -> ");
                $r = trim($cmd[1], ',');
                if (${$r} == 1) {
                    jmp($cmd[2]);
                    $inc = false;
                }
                //print ("$idx\n");
                break;
            default:
                var_dump($cmd);
                die('Invalid cmd');
                //hlf r sets register r to half its current value, then continues with the next instruction.
                //tpl r sets register r to triple its current value, then continues with the next instruction.
                //inc r increments register r, adding 1 to it, then continues with the next instruction.
                //jmp offset is a jump; it continues with the instruction offset away relative to itself.
                //jie r, offset is like jmp, but only jumps if register r is even ("jump if even").
                //jio r, offset is like jmp, but only jumps if register r is 1 ("jump if one", not odd).
        }
        if ($inc) {
            $idx++;
        }
        usleep(1000);
    } while (isset($in[$idx]));
}
Example #2
0
<?php

include "top.php";
if ($user_type != 'a' && $user_type != 't') {
    jmp(".");
}
require_once "scorelib.php";
function fmt_time($time)
{
    $s = (int) $time;
    //$s = round($time / 10);	// xxx seems $secs is in millis
    $t = "";
    $n = (int) ($s / (60 * 60 * 24));
    if ($n > 0) {
        $t .= "{$n} day(s), ";
        $s = $s % (60 * 60 * 24);
    }
    $n = (int) ($s / (60 * 60));
    if ($n > 0) {
        $t .= "{$n} hour(s), ";
        $s = $s % (60 * 60);
    }
    $n = (int) ($s / 60);
    if ($n > 0) {
        $t .= "{$n} minute(s), ";
        $s = $s % 60;
    }
    $t .= "{$s} second(s)";
    return $t;
}
?>
Example #3
0
<?php

include "dbg.php";
include "lib.php";
$where = rt("where");
dbg("where={$where}");
if ($where == "") {
    $where = "/";
} else {
    if ($where == "/register.php" || $where == "/registration.php") {
        $where = "/register.php";
    } else {
        if ($where == "/prizes.php") {
            $where = "/rules.php#Scoring";
        }
    }
}
//else
//if($where == "/test.php")
//	$where = "/test/index.php";
dbg("where={$where}");
jmp($where);
Example #4
0
<?php 
$action = rt("action");
$group_id = rt("group_id");
if ($action == "weekadvance") {
    $o = dbGetObj("select * from groups where id={$group_id} and teacher_code={$teacher_code}");
    $cw = $o->week;
    $nw = $cw + 1;
    if ($nw > $config["week"]) {
        $nw = $config["week"];
    }
    dbg("group_id={$group_id} teacher_code={$teacher_code} cw={$cw} nw={$nw}");
    $sql = "update users\n\t\t\t\tset week={$nw}\n\t\t\t\twhere\n\t\t\t\t\tteacher_code={$teacher_code}\n\t\t\t\t\tand\n\t\t\t\t\tgroup_id={$group_id}\n\t\t\t\t";
    dbExec($sql);
    $sql = "update groups\n\t\t\t\tset week={$nw}\n\t\t\t\twhere\n\t\t\t\t\tteacher_code={$teacher_code}\n\t\t\t\t\tand\n\t\t\t\t\tid={$group_id}\n\t\t\t\t";
    dbExec($sql);
    jmp("?#team{$group_id}");
}
?>

<style>
	table.info {
		background-color: white;
		border-collapse: collapse;
	}
	td.local {
		vertical-align: top;
		padding: 0.1em 1em 0.1em 1em;
		white-space: nowrap;
		border: solid 1px gray;
	}
	h4 {
Example #5
0
function vrfy($sid, $jp = "", $xm = 30)
{
    $rs = dbExec("select * from auth_users where sid=\"{$sid}\"");
    if ($rs->RecordCount() == 1) {
        dbg("sid freshened: {$sid}");
        setcook("sid", $sid, $xm);
        // freshen sid
        return true;
    }
    dbg("*** bad sid: {$sid}");
    if ($jp != "") {
        jmp($jp);
    }
    return false;
}