function apply_rules() { $new_world = []; $_SESSION['last_world'] = $_SESSION['world']; for ($x = 0; $x < SIZE; $x++) { for ($y = 0; $y < SIZE; $y++) { $num_of_neighbors = num_of_neighbors($x, $y); $new_world[$x][$y] = $_SESSION["world"][$x][$y] ? alive($num_of_neighbors) : dead($num_of_neighbors); } } $_SESSION['world'] = $new_world; should_it_continue(); }
function command($Op, $Args = array()) { global $FlashAirIP; if (!alive()) { force_next_update(); exit; } $Command = is_numeric($Op) ? "http://{$FlashAirIP}/command.cgi?op={$Op}" : "http://{$FlashAirIP}/{$Op}?__DUMMY__=1"; foreach ($Args as $k => $v) { $Command .= "&{$k}=" . rawurlencode($v); } $Contents = file_get_contents($Command); if ($Contents === FALSE) { force_next_update(); exit; } return $Contents; }
echo "Error: more arguments required."; return; } get_log($argv[2]); } else { if ($cmd == "result") { if (count($argv) == 2) { echo "Error: more arguments required."; return; } get_result($argv[2]); } else { if ($cmd == "delete") { if (count($argv) == 2) { echo "Error: more arguments required."; return; } delete($argv[2]); } else { if ($cmd == "alive") { alive(); } else { echo "Command not recognized.\n"; show_usage(); } } } } } } }