<?php

if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource']))
{
  
highlight_file(__FILE__);
  die();
}

$postdata file_get_contents('php://input');

if(!
$postdata)
{
    exit(
'nothing to process');
}

/**
 * parse the incoming POST
 */ 

$fragments = array();

if(
preg_match_all('/<methodName>(.*?)<\/methodName>/u'$postdata$matches))
{
    
$methodNames $matches[1];
    if(
is_array($methodNames))
    {
        
$fragments['methods'] = 'methodName = "'.implode(', '$methodNames).'" ';    
    }
}

if(
preg_match_all('/<value><(.*?)>(.*?)<\/\1><\/value>/u'$postdata$matches))
{
    
$types $matches[1];
    
$values $matches[2];
    if(
is_array($types))
    {
        foreach(
$types as $i => $type)
        {
            
$fragments['values'] .= 'value:'.$type.' = "'.$values[$i].'" ';
        }
    }
}

$description 'src = "'.$_SERVER['REMOTE_ADDR'].'" '.$fragments['methods'].$fragments['values'];

/**
 * log the request
 */ 

$logs = array();

if(
file_exists('logs.txt'))
{
    
$txt file_get_contents('logs.txt');
    
$logs unserialize($txt);
}

date_default_timezone_set('Asia/Kuala_Lumpur'); 

$logs[date('Y-m-d H:i:s')] = $description;

while(
sizeof($logs)>50)
{
    
array_shift($logs);
}

$txt serialize($logs);

file_put_contents('logs.txt'$txt);

exit();

?>