Example #1
0
function load($file)
{
    $data = array();
    $handle = fopen($file, "r");
    while (!feof($handle)) {
        $line = rtrim(fgets($handle));
        $data = array_merge($data, parseLine($line));
    }
    return $data;
}
Example #2
0
/**
 * Parses gcode string
 * @param  SPLFixedArray $gcode The gcode as an SPLFixedArray of lines
 * @return array                An array of lines where each entry is split into command and parameters
 */
function parseGcode($gcode)
{
    global $debug;
    global $lookahead;
    global $start;
    $output = array();
    $gcode->rewind();
    $lastValid = false;
    for (; $gcode->valid(); $gcode->next()) {
        $output[] = parseLine($gcode->current());
    }
    return array_filter($output);
}
Example #3
0
function read($n)
{
    loadNames();
    global $sData;
    $start = false;
    $fd = fopen($n, "r");
    while (!feof($fd)) {
        $buffer = fgets($fd);
        $line = trim($buffer);
        if ($start) {
            parseLine($line);
        }
        if (substr($line, 0, 34) == "do_system_check_initialisation() {") {
            $start = true;
        }
        if (trim(substr($line, 0, 14)) == "# Evil strings") {
            $start = false;
        }
    }
    fclose($fd);
    saveFile('out.txt', $sData);
}
Example #4
0
function parseFile(&$targets, $input, $ver)
{
    if (!($fin = fopen($input, "r"))) {
        die("Failed to open {$input} for reading.\n");
    } else {
        $lineno = 0;
        while (!feof($fin)) {
            $elements = array();
            $old_line = trim(fgets($fin));
            $lineno++;
            if (empty($old_line)) {
                continue;
            }
            if (strstr($old_line, "#")) {
                continue;
            }
            $elements = explode("\t", $old_line);
            parseLine($elements, $lineno, $input);
            /*
             * We have a valid line.
             */
            buildHosts($targets, $elements, $ver);
        }
        /* while(!feof($fin)) */
        fclose($fin);
    }
}
Example #5
0
#!/usr/local/bin/php
<?php 
//^^ adrress php-cgi
//how use it ./1.php 123.123.123 27015 26666
$s_ip = $argv[1];
//Grab vars
$s_port = $argv[2];
$d_port = $argv[3];
//Init Socks
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, '0.0.0.0', $d_port);
while (true) {
    if (($len = @socket_recvfrom($socket, $buf, 2048, 0, $c_ip, $c_port)) != false) {
        if ($c_ip != $s_ip or $c_port != $s_port) {
            continue;
        }
        $buf = utf8_decode($buf);
        if (substr($buf, 0, 4) != "?RL ") {
            continue;
        }
        // HERE BEGINS MAGIC
        $log .= $len . '\\n';
        // detect game end
        if (parseLine($len) == 2) {
            parse($log);
            break;
        }
    }
}
     if ($scan_typ == 'Geschützscan') {
         // 2
         $scan_type = 3;
         $daten = parseLine($zeilen[3]);
         // Leichtes Orbitalgeschütz 400
         $scan_glo = trim($daten[4]);
         $daten = parseLine($zeilen[4]);
         // Leichtes Raumgeschütz 0
         $scan_glr = trim($daten[4]);
         $daten = parseLine($zeilen[5]);
         // Mittleres Raumgeschütz 0
         $scan_gmr = trim($daten[4]);
         $daten = parseLine($zeilen[6]);
         // Schweres Raumgeschütz 0
         $scan_gsr = trim($daten[4]);
         $daten = parseLine($zeilen[7]);
         // Abfangjäger 1000
         $scan_ga = trim($daten[3]);
         addgnuser($scan_rg, $scan_rp, $scan_rn);
         $SQL_Result = tic_mysql_query('DELETE FROM `gn4scans` WHERE rg="' . $scan_rg . '" and rp="' . $scan_rp . '" AND type="' . $scan_type . '";', $SQL_DBConn);
         $insert_names = 'glo, glr, gmr, gsr, ga';
         $insert_values = '"' . $scan_glo . '", "' . $scan_glr . '", "' . $scan_gmr . '", "' . $scan_gsr . '", "' . $scan_ga . '"';
         $SQL_Result = tic_mysql_query('INSERT INTO `gn4scans` (type, zeit, g, p, rg, rp, gen, ' . $insert_names . ') VALUES ("' . $scan_type . '", "' . date("H:i d.m.Y") . '", "' . $Benutzer['galaxie'] . '", "' . $Benutzer['planet'] . '", "' . $scan_rg . '", "' . $scan_rp . '", "' . $scan_gen . '", ' . $insert_values . ');', $SQL_DBConn) or die('ERROR 2 Konnte Datensatz nicht schreiben');
     }
     // 2
     CountScans($Benutzer['id']);
     $modul = 'scans';
     $txtScanGalaxie = $scan_rg;
     $txtScanPlanet = $scan_rp;
 } else {
     // 1
<?php

require_once dirname(__FILE__) . '/helpers.php';
$wires = [];
$queue = [];
$lines = file(dirname(__FILE__) . '/input.txt');
foreach ($lines as $line) {
    $queue[] = trim($line);
}
// while there is still lines in the queue that needs processing
while (count($queue) > 0) {
    $line = array_shift($queue);
    list($a, $op, $b, $out) = parseLine($line);
    if (in_array($op, ['AND', 'OR', 'LSHIFT', 'RSHIFT'])) {
        $num = getNum($a);
        if ($num === false) {
            $queue[] = $line;
            continue;
        }
        $num2 = getNum($b);
        if ($num2 === false) {
            $queue[] = $line;
            continue;
        }
        switch ($op) {
            case 'AND':
                $wires[$out] = $num & $num2;
                break;
            case 'OR':
                $wires[$out] = $num | $num2;
                break;
Example #8
0
<?php

$values = [];
while (!array_key_exists('a', $values)) {
    foreach (getLine() as $line) {
        $command = parseLine($line);
        $firstInput = $command[1];
        $operator = $command[2];
        $secondInput = $command[3];
        $outputName = $command[4];
        if ($operator === '') {
            if (is_numeric($secondInput)) {
                $inputValue = (int) $secondInput;
            } else {
                if (array_key_exists($secondInput, $values)) {
                    $inputValue = $values[$secondInput];
                } else {
                    continue;
                }
            }
            $outputValue = $inputValue;
        } else {
            if ($operator === 'NOT') {
                if (is_numeric($secondInput)) {
                    $num = (int) $secondInput;
                    $inputValue = $num;
                } else {
                    if (array_key_exists($secondInput, $values)) {
                        $inputValue = $values[$secondInput];
                    } else {
                        continue;