-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinclude.php
More file actions
41 lines (29 loc) · 1.08 KB
/
include.php
File metadata and controls
41 lines (29 loc) · 1.08 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
32
33
34
35
36
37
38
39
40
41
<?php
// (c) Har01d
require_once('config.php');
$postgresql = pg_connect('host=' . POSTGRESQL_HOST . ' dbname=' . POSTGRESQL_DB . ' user=' . POSTGRESQL_LOGIN . ' password=' . POSTGRESQL_PASSWORD);
function daemon($method, $params = [])
{
static $curl = null;
if (is_null($curl))
{
$curl = curl_init();
}
$curl_address = DAEMON_PROTOCOL . '://' . DAEMON_LOGIN . ':' . DAEMON_PASSWORD . '@' . DAEMON_HOST . ':' . DAEMON_PORT . '/';
static $id = 0;
$request = json_encode(array('method' => $method, 'params' => $params, 'id' => $id));
$options = array(CURLOPT_URL => $curl_address, CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 10,
CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_POST => true, CURLOPT_POSTFIELDS => $request);
curl_setopt_array($curl, $options);
$response = json_decode(curl_exec($curl), true);
$id++;
if (!$response)
{
die('Daemon: no connection');
}
if ($response['error'])
{
die('Daemon: no response: ' . print_r($response['error'], true));
}
return $response['result'];
}