Managed `syscall` function and hash in send

This commit is contained in:
xdrm-brackets 2017-01-27 12:21:32 +01:00
parent 30db779020
commit 4e58b9b0ca
4 changed files with 75 additions and 4 deletions

0
lib/api/auth Normal file → Executable file
View File

39
lib/api/send Normal file → Executable file
View File

@ -2,6 +2,45 @@
<?php <?php
require_once __DIR__.'/../include/const';
// will send the request using `auth` for cyclic hash // 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 */
?> ?>

View File

@ -2,15 +2,21 @@
<?php <?php
# RESET OUTPUT BUFFER
# MAIN DIRECTORIES # 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('LOG_DIR', ROOT_DIR.'/log');
define('CONF_DIR', ROOT_DIR.'/conf'); 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 # CONFIGURATION FILES
#define('SECRET_CONF', CONF_DIR.'/machine.secret'); define('SECRET_CONF', CONF_DIR.'/machine.secret');
define('SECRET_CONF', '/home/xdrm-brackets/Desktop/git.xdrm.io/logauth-sats/lib/cyclic-hash/secret');
define('STATE_CONF', CONF_DIR.'/machine.state'); define('STATE_CONF', CONF_DIR.'/machine.state');
define('BRANCH_CONF', CONF_DIR.'/machine.branch'); define('BRANCH_CONF', CONF_DIR.'/machine.branch');
define('ID_CONF', CONF_DIR.'/machine.id'); define('ID_CONF', CONF_DIR.'/machine.id');
@ -26,4 +32,6 @@
# SETTINGS # SETTINGS
define('SECRET_SIZE', 250); define('SECRET_SIZE', 250);
require_once __DIR__.'/func';
?> ?>

24
lib/include/func Normal file
View File

@ -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;
}
?>