Managed `syscall` function and hash in send
This commit is contained in:
parent
30db779020
commit
4e58b9b0ca
|
@ -2,6 +2,45 @@
|
|||
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../include/const';
|
||||
|
||||
// will send the request using `auth` for cyclic hash
|
||||
|
||||
/* [1] Fetch useful data
|
||||
=========================================================*/
|
||||
/* (1) Fetch target url */
|
||||
$url = @file_get_contents(URL_CONF);
|
||||
|
||||
if( $url === false )
|
||||
die(1);
|
||||
|
||||
/* (2) Fetch cyclic hash */
|
||||
$hash = syscall(SOURCE_DIR.'/lib/cyclic-hash/hash');
|
||||
echo $hash;
|
||||
|
||||
die(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [1] Create httpRequest basis
|
||||
=========================================================*/
|
||||
/* (1) Set URL */
|
||||
$curl = curl_init($url);
|
||||
|
||||
/* (2) Specify that we want to catch result instead of displaying it */
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFERER, true);
|
||||
|
||||
/* (3) Set HTTP method -> POST */
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
|
||||
/* (4) Section Title */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
@ -2,15 +2,21 @@
|
|||
|
||||
<?php
|
||||
|
||||
# RESET OUTPUT BUFFER
|
||||
|
||||
# MAIN DIRECTORIES
|
||||
define('ROOT_DIR', '/home/sats/satsd');
|
||||
#define('ROOT_DIR', '/home/sats/satsd');
|
||||
#define('LOG_DIR', ROOT_DIR.'/log');
|
||||
#define('CONF_DIR', ROOT_DIR.'/conf');
|
||||
#define('SOURCE_DIR', ROOT_DIR.'/source');
|
||||
|
||||
define('ROOT_DIR', '/home/xdrm-brackets/SANDBOX/sats-local');
|
||||
define('LOG_DIR', ROOT_DIR.'/log');
|
||||
define('CONF_DIR', ROOT_DIR.'/conf');
|
||||
define('SOURCE_DIR', ROOT_DIR.'/source');
|
||||
define('SOURCE_DIR', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats');
|
||||
|
||||
# CONFIGURATION FILES
|
||||
#define('SECRET_CONF', CONF_DIR.'/machine.secret');
|
||||
define('SECRET_CONF', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats/lib/cyclic-hash/secret');
|
||||
define('SECRET_CONF', CONF_DIR.'/machine.secret');
|
||||
define('STATE_CONF', CONF_DIR.'/machine.state');
|
||||
define('BRANCH_CONF', CONF_DIR.'/machine.branch');
|
||||
define('ID_CONF', CONF_DIR.'/machine.id');
|
||||
|
@ -26,4 +32,6 @@
|
|||
|
||||
# SETTINGS
|
||||
define('SECRET_SIZE', 250);
|
||||
|
||||
require_once __DIR__.'/func';
|
||||
?>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/php
|
||||
|
||||
<?php
|
||||
|
||||
function syscall($callable=null){
|
||||
|
||||
/* (1) Check file */
|
||||
if( !file_exists($callable) )
|
||||
return null;
|
||||
|
||||
/* (2) Call and catch output */
|
||||
ob_start();
|
||||
|
||||
include $callable;
|
||||
|
||||
$out = ob_get_clean();
|
||||
|
||||
/* (3) Manage content */
|
||||
if( $out == 0 ) return true;
|
||||
elseif( is_numeric($out) ) return false;
|
||||
else return $out;
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue