forked from axiom-team/astroport
web API phone + val => sms_ASTROPORT sms_AUTH
This commit is contained in:
parent
83f25350b1
commit
b895261c94
|
@ -116,7 +116,7 @@ fi
|
|||
|
||||
# COHERENCE TEST
|
||||
[[ -f /home/$YOU/.zen/secret.astroport.key ]] && source /home/$YOU/.zen/secret.astroport.key || echo "Missing /home/$YOU/.zen/secret.astroport.key" || exit 1
|
||||
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && NODE_UIDNA=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)|| echo "Missing _uidna" || exit 1
|
||||
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && export NODE_UIDNA=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)|| echo "Missing _uidna" || exit 1
|
||||
|
||||
## INIT NODE G1 PUB & PRIV KEY
|
||||
NODE_G1PUBKEY=$G1PUB
|
||||
|
|
|
@ -91,6 +91,12 @@ for hashfile in /tmp/loveland_entrance/*; do
|
|||
|
||||
done
|
||||
|
||||
## CHECK FOR DOUBLE AUTH REQUEST
|
||||
[[ ! -f /tmp/sms.commands ]] && exit 1
|
||||
for phone_auth in $(cat /tmp/sms.auth.commands) do
|
||||
$MY_PATH/sms_AUTH.sh $phone_auth
|
||||
done
|
||||
|
||||
[[ -d /home/$YOU/.zen/g1sms/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms/$PHONE
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -17,12 +17,12 @@ source $MY_PATH/init.sh
|
|||
source $MY_PATH/functions.sh
|
||||
|
||||
PHONE=$1
|
||||
PARRAIN=$2
|
||||
NBLOVE=$2
|
||||
TODAY=$(date '+%Y%m%d')
|
||||
log "__SUB:sms_AUTH.sh ($PHONE, $PARRAIN) $TODAY"
|
||||
|
||||
[[ $PHONE != "" ]] && sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1 # VERIFICATION ALREADY DONE BY CALLING bash ?
|
||||
[[ $UNKNOWN == "unknown" ]] && echo "G1sms Wallet $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1
|
||||
[[ $PHONE != "" ]] && $MY_PATH/sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1 # VERIFICATION ALREADY DONE BY CALLING bash ?
|
||||
[[ $UNKNOWN == "unknown" ]] && sms_SEND "$PHONE" "Portefeuille $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1
|
||||
|
||||
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
|
||||
AMOUNTG1=$(silkaj_balance $PUBKEY)
|
||||
|
@ -30,19 +30,20 @@ AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
|
|||
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
|
||||
|
||||
# Convert amount to G1 unit
|
||||
VIR=$(bc -l <<< "scale=2; $PARRAIN * $DUFACTOR / 100")
|
||||
VIR=$(bc -l <<< "scale=2; $NBLOVE * $DUFACTOR / 100")
|
||||
|
||||
# Need at least $MIN G1 available!
|
||||
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT")
|
||||
testmin=$( echo "${VIR} < ${MIN}" | bc -l )
|
||||
|
||||
SMSPIN=$((1000 + RANDOM % 9999))
|
||||
|
||||
log "__SUB:sms_AUTH.sh: CODE $SMSPIN : $VIR < $MIN ? $testmin"
|
||||
if [[ "$testmin" -eq "1" ]]
|
||||
then
|
||||
mess="CODE: $SMSPIN
|
||||
A saisir pour vous authentifier...
|
||||
[G1] Zen Astroport Station #$(cat /etc/hostname)"
|
||||
[G1sms] Astroport Station $NODE_UIDNA"
|
||||
# Send response SMS
|
||||
sms_SEND "$PHONE" "$mess"
|
||||
echo $SMSPIN > /tmp/$PHONE.PIN.auth
|
||||
|
|
|
@ -3,10 +3,10 @@ header("Access-Control-Allow-Origin: *");
|
|||
if (strlen($_REQUEST['num']) == 10 ) {
|
||||
$newNumber = preg_replace('/^0?/', '+33', $_REQUEST['num']);
|
||||
$data = '"'.$newNumber.'" "'.$_REQUEST['val'].'"'.PHP_EOL;
|
||||
$fp = fopen('/tmp/sms.commands', 'w');
|
||||
$fp = fopen('/tmp/sms.auth.commands', 'w');
|
||||
fwrite($fp, $data);
|
||||
sleep(1);
|
||||
echo exec('cat /tmp/sms.commmand.result');
|
||||
//sleep(1);
|
||||
echo "OK commnand sent! $data";
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue