-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.php
executable file
·46 lines (38 loc) · 1.24 KB
/
script.php
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
<?php
/**
* Share information securely using the One-Time Secret service.
*
* @author scottlee
* @link https://github.com/scottlee/alfred-one-time-secret
*
* @license GNU
* @license https://github.com/scottlee/alfred-one-time-secret/blob/master/LICENSE
*
* @uses OneTimeSecret
* @link https://onetimesecret.com/
*/
// Include the API Helper
include( 'onetime-api.php' );
// Bail if the API authentication is missing
$customer_id = ( isset( $argv[1] ) ) ? trim( $argv[1] ) : '';
$API_Key = ( isset( $argv[2] ) ) ? trim( $argv[2] ) : '';
if ( empty( $customer_id ) || empty( $API_Key ) ) {
die( 'Missing customer ID (email) or API key.' );
}
// Friendly var names
$query = explode( '|', $argv[3] );
$secret = ( isset( $query[0] ) ) ? trim( $query[0] ) : '';
$pass = ( isset( $query[1] ) ) ? trim( $query[1] ) : '';
$recipient = ( isset( $query[2] ) ) ? trim( $query[2] ) : false;
// Start it up
$myOnetime = new OneTimeSecret;
$myOnetime->setCustomerID( $customer_id );
$myOnetime->setToken( $API_Key );
$myOnetime->setTTL( 3600 );
// Are we notifying anyone directly?
if ( $recipient ) {
$myOnetime->setRecipient( $recipient );
}
// (doit)
$myResult = $myOnetime->shareSecret( $secret, $pass );
echo $myOnetime->getSecretURI( $myResult );