-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
67 lines (50 loc) · 1.71 KB
/
test.php
File metadata and controls
67 lines (50 loc) · 1.71 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once ('vendor/autoload.php');
require_once ('class/SparqlHttpGraph.php');
if(!file_exists('config.php')){
require_once ('class/RandomStringGenerator.php');
// Create new instance of generator class.
$generator = new RandomStringGenerator;
// Set token length.
$tokenLength = 32;
// Call method to generate random string.
$token = $generator->generate($tokenLength);
$config = '
<?php
$config = array ("secret" => "'.$token.'");
';
file_put_contents('config.php', $config);
}
if(file_exists('config.php')){
require_once ('config.php');
}
echo '<pre>';
if ( isset($_GET['secret']) && $config['secret'] == $_GET['secret']) {
if(isset($_GET['endpoint']) && isset($_GET['data'])){
$log = '';
$endpoint = $_GET['endpoint'];
$data = $_GET['data'];
$SparqlHttpGraph = new SparqlHTTPGraph($endpoint, true);
if(is_array($data) == true){
$i = false;
foreach ($data as $item) {
// First PUT than POST
if($i == false) {
$response = $SparqlHttpGraph->request($item, 'PUT');
$i = true;
}
else {
$response = $SparqlHttpGraph->request($item, 'POST');
}
$log[$item]['status'] = $response->getReasonPhrase();
$log[$item]['message'] = json_decode($response->getBody());
}
}
else{
$response = $SparqlHttpGraph->request($data, 'POST');
$log[$data]['status'] = $response->getReasonPhrase();
$log[$data]['message'] = $response->getBody();
}
print_r(json_encode($log));
}
}