Esempio n. 1
0
// Helper function to display the outcome in a readable format, you can ignore this.
function display($title, $data)
{
    echo "<h1>" . $title . "</h1>";
    if (!is_null($data)) {
        echo '<pre>' . print_r($data, true) . '</pre>';
    }
    echo "\n\n";
}
/*
 * In order to communicate with the PatrolServer API, you must register a key and secret.
 */
Patrol::setApiKey('ed94f55159c0710972d7da4b97766767');
Patrol::setApiSecret('92df264e875b0cad2f70906341017efa29eb1c5f35c59e3e380d943c6798f45b');
// Get all the servers from the account linked to the key or secret above.
$servers = Patrol::servers();
display("Servers", $servers);
// Get a single server
$first_server = count($servers) ? $servers[0] : null;
// Let's not continue if no servers are added, we'll continue with this server.
if (!$first_server) {
    die("Add a server on the dashboard first");
}
// Print the first server in the list.
display("First server", $first_server);
/*
 * You can also fetch a single server from the API, provide the ID in the "server" function as first parameter.
 * Optional scopes can also be provided as second parameter. An example:
 *
 * $scopes = [
 *     'exploitable',
Esempio n. 2
0
});
/*
 * Event: webhook.new_server_issues
 *
 * When new issues are found on your server. Let's say, your PHP software package suddenly becomes outdated,
 * this webhook will inform your software about the fact that that particular server now runs an outdated PHP package.
 *
 * An example of the Event data can be found here: https://api.patrolserver.com/#webhooks-integrations
 */
Patrol::webhook('webhook.new_server_issues', function ($event) {
    Patrol::log('webhook.new_server_issues');
    Patrol::log($event);
});
/*
 * Event: webhook.scan_started
 *
 * When a scan is started, both manually or automatically, this webhook will inform your application.
 */
Patrol::webhook('webhook.scan_started', function ($event) {
    Patrol::log('webhook.scan_started');
    Patrol::log($event);
});
/*
 * Event: webhook.scan_finished
 *
 * When we finished scanning your server, both manually or automatically, this webhook will inform your application.
 */
Patrol::webhook('webhook.scan_finished', function ($event) {
    Patrol::log('webhook.scan_finished');
    Patrol::log($event);
});