コード例 #1
0
/**
 * Fetch api call logs
 */
function restapi_logger_get($start = 0, $limit = 24, $order = 'DESC', $details = false)
{
    global $db;
    //some sanitization - we cant rely on pear here as it will escape the commands
    $start = ctype_digit($start) ? $start : 0;
    $limit = ctype_digit($limit) ? $limit : 24;
    $order = in_array($order, array('DESC', 'ASC')) ? $order : 'DESC';
    $sql = 'SELECT * FROM restapi_log_events  ORDER BY time ' . $order . ' LIMIT ' . $start . ', ' . $limit;
    $ret = $db->getAll($sql, DB_FETCHMODE_ASSOC);
    db_e($ret);
    if ($details) {
        foreach ($ret as $my => $log) {
            $sql = 'SELECT * FROM restapi_log_event_details WHERE e_id = ?';
            $det = $db->getAll($sql, array($log['id']), DB_FETCHMODE_ASSOC);
            $ret[$my]['id'] = restapi_logger_format_id($ret[$my]['id']);
            foreach ($det as $that => $d) {
                $det[$that]['e_id'] = $ret[$my]['id'];
                $det[$that]['data'] = json_decode($d['data'], true);
            }
            $ret[$my]['events'] = $det;
        }
    }
    return $ret;
}
コード例 #2
0
 function init()
 {
     restapi_logger_clear_history();
     $this->id = restapi_logger_put_header(array('ip' => $this->api->req->headers['ip'], 'server' => $this->api->opts['token'], 'sig' => $this->api->req->headers['signature'], 'token' => $this->api->req->token));
     $this->api->add_header('Request-Id', restapi_logger_format_id($this->id));
 }