<?php
echo "log_server_cli\n";
define("WIN32_STDOUT", -11);
define("BLACK", 0);
define("BLUE", 1);
define("GREEN", 2);
define("CYAN", 3);
define("RED", 4);
define("BROWN", 5);
define("YELLOW", 6);
define("WHITE", 7);

ini_set("max_execution_time", 0);
error_reporting(E_ERROR);

/**
 * dl("php_w32api.dll");
 * $api = new win32;
 * $api->registerfunction("long SetConsoleTextAttribute(long handel,int attribute) from kernel32.dll");
 * $api->registerfunction("long GetStdHandle(long handle) from kernel32.dll");
 * $con = $api->GetStdHandle(WIN32_STDOUT);
 */

$debug_server_port = 19793;
$debug_server_ip = "127.0.0.1";

$debug_server_port = 19793;
$debug_server_ip = "0.0.0.0";

$sock = socket_create(AF_INET, SOCK_DGRAM, 0) or die("Could not create socket\n");

$result = socket_bind($sock, $debug_server_ip, $debug_server_port) or die("Could not bind to socket\n");

$buf = "";
$msg = "";
$input = "";
while (1) {
    if (!empty($input)) {
        echo trim($input) . "\n";
    } 

    $input = socket_read($sock, 1024) or die("Could not read input\n");

    if (strpos($input, "cmd:cls") > 0)
        echo("\n\n\n-----------------------------------------------------------------------\n");
    /**
     * if( strpos($input,"M_DEBUG") == 1 ) {$api->SetConsoleTextAttribute($con,GREEN+8);continue;}
     * if( strpos($input,"M_INFO") == 1 ) {$api->SetConsoleTextAttribute($con,BLUE+8);continue;}
     * if( strpos($input,"M_WARN") == 1 ) {$api->SetConsoleTextAttribute($con,YELLOW+8);continue;}
     * if( strpos($input,"M_ERROR") == 1) {$api->SetConsoleTextAttribute($con,WHITE+8);continue;}
     * if( strpos($input,"M_FATAL") == 1) {$api->SetConsoleTextAttribute($con,RED+8);continue;}
     * $api->SetConsoleTextAttribute(7,0x0f);
     */
} 

socket_close($sock);
// $api->SetConsoleTextAttribute(7,0x0f);
?> 
		
