示例#1
0
include_php_dir("includes",$debug);

mysql_init();

document_header();

echo include_javascript_dir("js",$debug);
echo include_stylesheet_dir("stylesheets",$debug);

if (isset($_POST['barcode']) && $_POST['barcode']!="") {
  $punch = punch($_POST['barcode']);
}

if (isset($_POST['barcode']) && $_POST['barcode']=="") {
  $punch = punch(id_to_barcode($_SESSION['user_id']));
}

if (isset($_SESSION['user_id']))
  open_page("Punchclock");
else
  open_punchclock();

page_logic();
close_page();
ob_end_flush(); // Flush the buffer out to client
document_footer(); mysql_end();
?>
<script type="text/javascript">
window.onload = function startTime()
 {
示例#2
0
{
    global $bags, $punches;
    $bags[$i] = 0;
    splash($i - 1);
    splash($i + 1);
    ++$punches;
}
while (TRUE) {
    $tgt = NULL;
    $curcost = 3;
    foreach (range(1, 3) as $bagType) {
        foreach ($bags as $i => $type) {
            if ($type != $bagType) {
                continue;
            }
            $cost = punchcost($i);
            if ($cost < $curcost) {
                $curcost = $cost;
                $tgt = $i;
            }
        }
        if (!is_null($tgt)) {
            break;
        }
    }
    if (is_null($tgt)) {
        break;
    }
    punch($tgt);
}
print $punches . "\n";