<?php
// This is the automatic DB push code
// This value is pulled from the HTTP server
$spaces=" ";
$yikes ="!!!!!!!!";
$IPAddress = $_SERVER['1.2.3.4'];
$dieClose = "
</body>
</html>\n";
if ( empty ( $_POST ) )
{
die ( "No variables passed in on HTTP POST" . $dieClose );//GET variables have been set
}
//setup filters to prevent invalid data input and malicious code insertion
$filters = array
(
"eventid" => array ("filter"=>FILTER_VALIDATE_REGEXP,
// STRING epoch date int followed by "_" followed by an IP address i.e.: "1384204604_172.16.198.48"
"options"=>array("regexp"=>"/^([0-9]+)_(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/")),
"oslist" => array ("filter"=>FILTER_VALIDATE_REGEXP,
// STRING (alnum and "," only), CSV OS name list. i.e.: "win7x64,debianx64,dos"
"options"=>array("regexp"=>"/^((([a-zA-Z0-9]+),)*)([a-zA-Z0-9_]+)$/")),
"hostip" => array ("filter"=>FILTER_VALIDATE_IP),
"state" => array ("filter"=>FILTER_VALIDATE_REGEXP,
// STRING characters "s" and "e" ONLY!!! indicates "start" or "end"
"options"=>array("regexp"=>"/^[se]$/")),
"hddinfo" => array ("filter"=>FILTER_VALIDATE_REGEXP,
// STRING (0-9 and "," only), CSV HDD size list in kB i.e. "12313,123123,1132"
"options"=>array("regexp"=>"/^((\d+,)*)(\d+)$/")),
"meminfo" => array ("filter"=>FILTER_SANITIZE_STRING),
"cpuinfo" => array ("filter"=>FILTER_SANITIZE_STRING),
"error" => array ("filter"=>FILTER_VALIDATE_INT,
"options"=>array("min_range"=>0,"max_range"=>1024)
),
);
$inputFields = filter_input_array(INPUT_POST, $filters);
//var_dump($inputFields); //for debugging
$DBfields=array("eventid", "oslist", "hostip", "state", "hddinfo", "meminfo", "cpuinfo", "error");
$Results =array();
//$keyvalue="eventid";
foreach ($DBfields as &$keyvalue) {
if (!$inputFields[$keyvalue])
{
die($yikes . $keyvalue . "=" . $_POST[$keyvalue] . " invalid" . $yikes . $dieClose);
}
else
{
//echo($spaces . "Got a valid " . $keyvalue . "=" . $inputFields[$keyvalue] . "\n" ); //for debugging
$Results[$keyvalue] = $inputFields[$keyvalue];
}
}
$MyQuery = "INSERT INTO `clonestats`.`stattable` ( `eventid`, `oslist`, `hostip`, `state`, `hddinfo`, `meminfo`, `cpuinfo`, `error` ) " .
"VALUES ( '" . $Results['eventid'] . "', '" . $Results['oslist'] . "', '" . $IPAddress . ", " . $Results['hostip'] . "','" . $Results['state'] . "', '" . $Results['hddinfo'] .
"', '" . $Results['meminfo'] . "', '" . $Results['cpuinfo'] . "', '" . $Results['error'] . "' );";
//echo("my query is \n\t$MyQuery"); //for debugging only
$NewDBConnection = mysql_connect ( "localhost", "CloneStatPush", "5a97114c932162a11622eb34cb2589586ffa70fb7ee85d267c8dc06ba3de2a9c" );
if (!$NewDBConnection)
{
die ( "\n".$yikes." I didn't successfully connect to the database" . $yikes . $dieClose ); // link to DB is bad
}
else
{
mysql_select_db ( "clonestats" );
// echo $MyQuery;
mysql_query ( $MyQuery );
echo mysql_affected_rows ( ); // Prints the result of the INSERT command, client doesn't need to do anything with it
mysql_close ( $DBlink );
}
?>
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Warning: Undefined array key "1.2.3.4" in /in/SKQnf on line 6
No variables passed in on HTTP POST
</body>
</html>
- Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.35, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
- Notice: Undefined index: 1.2.3.4 in /in/SKQnf on line 6
No variables passed in on HTTP POST
</body>
</html>
- Output for 7.3.32 - 7.3.33, 7.4.26
- No variables passed in on HTTP POST
</body>
</html>
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
- Notice: Undefined index: 1.2.3.4 in /in/SKQnf on line 6
No variables passed in on HTTP POST
</body>
</html>
- Output for 4.4.2 - 4.4.9
- Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/SKQnf on line 42
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
- Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/SKQnf on line 42
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/SKQnf on line 42
Process exited with code 255.
preferences:
251.4 ms | 401 KiB | 344 Q