Example #1
0
    collectd_flush($identifiers);
    $rrd_cmd = $MetaGraphDefs[$type]($host, $plugin, $pinst, $type, $all_tinst, $opts);
} else {
    if (!in_array(is_null($tinst) ? '' : $tinst, $all_tinst)) {
        return error404($host . '/' . $plugin . (!is_null($pinst) ? '-' . $pinst : '') . '/' . $type . (!is_null($tinst) ? '-' . $tinst : ''), "No rrd file found for graphing");
    }
    collectd_flush(collectd_identifier($host, $plugin, is_null($pinst) ? '' : $pinst, $type, is_null($tinst) ? '' : $tinst));
    if (isset($GraphDefs[$type])) {
        $rrd_cmd = collectd_draw_generic($timespan, $host, $plugin, $pinst, $type, $tinst);
    } else {
        $rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
    }
}
if (isset($_GET['debug'])) {
    header('Content-Type: text/plain; charset=utf-8');
    printf("Would have executed:\n%s\n", $rrd_cmd);
    return 0;
} else {
    if ($rrd_cmd) {
        header('Content-Type: image/png');
        header('Cache-Control: max-age=60');
        $rt = 0;
        passthru($rrd_cmd, $rt);
        if ($rt != 0) {
            return error500($graph_identifier, "RRD failed to generate the graph: " . $rt);
        }
        return $rt;
    } else {
        return error500($graph_identifier, "Failed to tell RRD how to generate the graph");
    }
}
Example #2
0
 private function store_shorturl()
 {
     if (!$this->store_url) {
         return true;
     }
     $query = $this->db_connection->prepare('INSERT INTO shorturls(shorturl, longurl, owner_ip, custom_shorturl) ' . 'VALUES(?, ?, ?, ?);');
     $query->bind_param('sssi', $this->short_url, $this->long_url, client_ip(), $this->custom_url);
     if ($query->execute()) {
         return true;
     } else {
         error500('Something has gone wrong! :( ... Try again? Please?');
         return false;
     }
 }