Rev 6 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6 | Rev 7 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | if ($argc <> 1) { |
7 | if ($argc <> 1) { |
8 | echo "Syntax: $argv[0]\n"; |
8 | echo "Syntax: $argv[0]\n"; |
9 | exit(2); |
9 | exit(2); |
10 | } |
10 | } |
11 | 11 | ||
- | 12 | if (isset($stam_cfg['weblog2_system']) && !empty($stam_cfg['weblog2_system'])) { |
|
- | 13 | ||
- | 14 | ||
- | 15 | # --- |
|
- | 16 | ||
- | 17 | ||
- | 18 | $oidplus_rest_auth = $stam_cfg['weblog2_auth']; |
|
- | 19 | ||
- | 20 | $data = array(); |
|
- | 21 | $ch = curl_init($stam_cfg['weblog2_system']."rest/v1/objects/oid:".$stam_cfg['weblog2_oid']); |
|
- | 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
- | 23 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); |
|
- | 24 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|
- | 25 | curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer $oidplus_rest_auth")); |
|
- | 26 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
- | 27 | $i=0; for($i=0;$i<10;$i++) { $response = curl_exec($ch); if ($response) { break; } else { sleep(1); } } |
|
- | 28 | if ((!$response) || (json_decode($response,true)['status'] < 0)) |
|
- | 29 | { |
|
- | 30 | fwrite(STDERR, "Weblog GET failed: $response\n"); |
|
- | 31 | #weblog_close(); |
|
- | 32 | exit(2); |
|
- | 33 | } |
|
- | 34 | #echo "$response\n\n"; |
|
- | 35 | $children = json_decode($response,true)['children']; |
|
- | 36 | ||
- | 37 | foreach ($children as $child) { |
|
- | 38 | $data = array(); |
|
- | 39 | $ch = curl_init($stam_cfg['weblog2_system']."rest/v1/objects/".$child); |
|
- | 40 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
- | 41 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); |
|
- | 42 | curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); |
|
- | 43 | curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer $oidplus_rest_auth")); |
|
- | 44 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
- | 45 | $i=0; for($i=0;$i<10;$i++) { $response = curl_exec($ch); if ($response) { break; } else { sleep(1); } } |
|
- | 46 | if ((!$response) || (json_decode($response,true)['status'] < 0)) |
|
- | 47 | { |
|
- | 48 | fwrite(STDERR, "Weblog GET failed: $response\n"); |
|
- | 49 | #weblog_close(); |
|
- | 50 | exit(2); |
|
- | 51 | } |
|
- | 52 | #echo "$response\n\n"; |
|
- | 53 | $data = json_decode($response,true); |
|
- | 54 | $ent = $data['description']; |
|
- | 55 | ||
- | 56 | if (isset($stam_cfg['weblog_password']) && !empty($stam_cfg['weblog_password'])) { |
|
- | 57 | $iv = 'AAAAAAAAAAAAAAAA'; |
|
- | 58 | $ent = openssl_decrypt(base64_decode($ent), 'AES-128-CBC', $stam_cfg['weblog_password'], OPENSSL_RAW_DATA, $iv); |
|
- | 59 | } |
|
- | 60 | ||
- | 61 | echo $data['created'] . ': ' . trim($ent) . "\n"; |
|
- | 62 | } |
|
- | 63 | ||
- | 64 | ||
- | 65 | ||
- | 66 | # --- |
|
- | 67 | ||
- | 68 | ||
- | 69 | ||
- | 70 | ||
- | 71 | } |
|
- | 72 | ||
12 | if (isset($stam_cfg['weblog_host']) && !empty($stam_cfg['weblog_host'])) { |
73 | if (isset($stam_cfg['weblog_host']) && !empty($stam_cfg['weblog_host'])) { |
13 | db_close(); |
74 | db_close(); |
14 | 75 | ||
15 | $weblog_host = $stam_cfg['weblog_host']; |
76 | $weblog_host = $stam_cfg['weblog_host']; |
16 | $weblog_user = $stam_cfg['weblog_user']; |
77 | $weblog_user = $stam_cfg['weblog_user']; |
Line 33... | Line 94... | ||
33 | $ent = $row['inp']; |
94 | $ent = $row['inp']; |
34 | if (isset($stam_cfg['weblog_password']) && !empty($stam_cfg['weblog_password'])) { |
95 | if (isset($stam_cfg['weblog_password']) && !empty($stam_cfg['weblog_password'])) { |
35 | $iv = 'AAAAAAAAAAAAAAAA'; |
96 | $iv = 'AAAAAAAAAAAAAAAA'; |
36 | $ent = openssl_decrypt(base64_decode($ent), 'AES-128-CBC', $stam_cfg['weblog_password'], OPENSSL_RAW_DATA, $iv); |
97 | $ent = openssl_decrypt(base64_decode($ent), 'AES-128-CBC', $stam_cfg['weblog_password'], OPENSSL_RAW_DATA, $iv); |
37 | } |
98 | } |
38 | echo $row['ts'] . ': ' . $ent . "\n"; |
99 | echo $row['ts'] . ': ' . trim($ent) . "\n"; |
39 | 100 | ||
40 | } |
101 | } |
41 | } |
102 | } |
42 | 103 | ||
43 | # --- |
104 | # --- |