function run()
{
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            print getUrl($_GET['url']);
            break;
        case 'POST':
            print sendPostRequest($_GET['url'], $_POST);
            break;
        default:
    }
}
function sendAnnotation($timestamp, $tags, $text, $title, $name)
{
    /*
        curl -X POST -d ''  'http://10.1.3.220:8086/db/annotations/series?u=root&p=root&time_precision=s'
    */
    $payload = createAnnotationBody($name, $timestamp, $tags, $text, $title);
    $precision = calculatePrecision($timestamp);
    $url = "http://" . $_SESSION['host'] . ":8086/db/" . $_SESSION['annotation_database'] . "/series?u=" . urlencode($_SESSION['user']) . "&p=" . urlencode($_SESSION['pw']) . "&time_precision=" . $precision;
    $httpResult = sendPostRequest($url, $payload);
    $success = 200 == $httpResult['status_code'];
    if (!$success) {
        debug("Error when setting annotation: " . $url . " => " . $httpResult['status_code'] . " " . $httpResult['results']);
        debug("Payload: " . $payload);
    }
    return $success ? "" : $httpResult['results'];
}
Exemple #3
0
            if (isset($_GET['code']) && $_GET['code'] != '') {
                $xml = '<?xml version="1.0" encoding="utf-8"?>
<root>
	<update>
		<param type="code" value="' . $_GET['code'] . '" />
	</update>
	<ftp>
		<param type="server" value="' . $cfg['etc']['ftp_server'] . '" />
		<param type="port" value="' . $cfg['etc']['ftp_port'] . '" />
		<param type="username" value="' . $cfg['etc']['ftp_username'] . '" />
		<param type="password" value="' . $cfg['etc']['ftp_password'] . '" />
		<param type="start" value="' . $cfg['etc']['ftp_start'] . '" />
	</ftp>
</root>';
                $data = array('XML' => $xml);
                $response = sendPostRequest('http://cmsupdate.blackpig.cz/updates_global.php?function=request_update', http_build_query($data));
                if ($response == 'ERROR') {
                    print 'ERROR';
                } else {
                    $sql = new MySQLOBject();
                    if ($sql->query("\r\nINSERT INTO " . $sql->table('updates') . "\r\n(`code`,`date`)\r\nVALUES\r\n('" . $sql->escape($_GET['code']) . "'," . time() . ")")) {
                        print 'OK';
                    } else {
                        print 'ERROR';
                    }
                }
            }
            break;
        case 'ignore_update':
            if (isset($_GET['code']) && $_GET['code'] != '') {
                $sql = new MySQLOBject();