Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 32 lines (24 sloc) 0.88 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<?php
/**
* Receives a json request via HTTP POST
*
* The request is specified with the following keys:
* from: The username
* text: The text
* time: The time (not used yet)
*
*/
$postdata = file_get_contents("php://input");

$data = json_decode($postdata,true);

$string = "<".$data["from"].":".$data["time"]."> " .$data["text"];
$string = utf8_decode($string); // For some reason, this is utf8-encoded twice?
$string = iconv("UTF-8", "ISO-8859-15//TRANSLIT", $string); // convert with char matching

output($string);

function output ($string, $count=0) {
    setlocale(LC_CTYPE, "de_DE@euro"); // This is important to have escapeshellarg working properly

    $output = "/home/rzl/ping-plus-host/pingplus.py -c -s ".escapeshellarg($string);

    exec($output, $returnstring, $retval);

    if ($retval == 1 && $count < 6) {
        output($string, $count++);
    }
}
Something went wrong with that request. Please try again.