<?php

    include("/home/c0smic/secure/data_db_settings.php");

    $body = file_get_contents('php://input');

    $stime = "";
    $etime = "";
    $moves = "";

    function parseData($body) {
        $splitter = '|';
        global $stime, $etime, $moves;
        $inc = 1;
        while(strcmp(substr($body, $inc, 1), $splitter) > 0) {
            $stime = $stime . substr($body, $inc, 1);
            $inc++;
        }

        $inc++;
        while(strcmp(substr($body, $inc, 1), $splitter) > 0) {
            $etime = $etime . substr($body, $inc, 1);
            $inc++;
        }

        $inc++;
        while(strcmp(substr($body, $inc, 1), $splitter) > 0) {
            $moves = $moves . substr($body, $inc, 1);
        }
    }
    parseData($body);

    $conn = mysql_connect('localhost:3036', $dbuser, $dbpass);
    if(! $conn )
    {
        die('Could not connect: ' . mysql_error());
    }
    unset($dbuser, $dbpass);

    mysql_select_db('c0smic_maze-game');

    $sql= "INSERT INTO data (stime, etime, moves)
    VALUES
    ('$stime','$etime','$moves')";

    $retval = mysql_query( $sql, $conn );
    if(! $retval )
    {
        die('Could not enter data: ' . mysql_error());
    }

    mysql_close($conn);
    echo $str;

?>
<?php

    include("/home/c0smic/secure/data_db_settings.php");

    $body = file_get_contents('php://input');

    $stime = "";
    $etime = "";
    $moves = "";

    function parseData($body) {
        $splitter = substr($body, 0, 1);
        global $stime, $etime, $moves;

        $mark1 = strpos($body, $splitter, 1);
        $mark2 = strpos($body, $splitter, $mark1+1);
        $mark3 = strpos($body, $splitter, $mark2+1);

        $stime = substr($body, 1, $mark1-1);
        $etime = substr($body, $mark1+1, $mark2-$mark1-1);
        $moves = substr($body, $mark2+1, $mark3-$mark2-1);
    }
    parseData($body);

    $conn = mysql_connect('localhost:3036', $dbuser, $dbpass);
    if(! $conn )
    {
        die('Could not connect: ' . mysql_error());
    }
    unset($dbuser, $dbpass);

    mysql_select_db('c0smic_maze-game');

    $sql= "INSERT INTO data (stime, etime, moves)
    VALUES
    ('$stime','$etime','$moves')";

    $retval = mysql_query( $sql, $conn );
    if(! $retval )
    {
        die('Could not enter data: ' . mysql_error());
    }

    mysql_close($conn);
    echo $str;

?>
Complete parsing system, fully functional
Complete parsing system, fully functional
