Love land entrance opening

This commit is contained in:
qo-op 2020-05-13 22:58:10 +02:00
parent 4d0151cce8
commit 52366218b9
6 changed files with 101 additions and 45 deletions

View File

@ -285,10 +285,12 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
python3 /home/$YOU/.zen/astroport/zen/tools/key_create_dunikey.py "$UIDNA" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey python3 /home/$YOU/.zen/astroport/zen/tools/key_create_dunikey.py "$UIDNA" "$PIN" ## Copy PubSec file to /tmp/secret.dunikey
mv /tmp/secret.dunikey /home/$YOU/.zen/g1sms_wallets/$PHONE/ mv /tmp/secret.dunikey /home/$YOU/.zen/g1sms_wallets/$PHONE/
PUBKEY=$(cat $DUNIKEYFILE | grep 'pub:' | cut -d ' ' -f 2) PUBKEY=$(cat $DUNIKEYFILE | grep 'pub:' | cut -d ' ' -f 2)
log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE = $UIDNA $PIN : $PUBKEY" log "__SUB:sms_INIT_ACCOUNT: !! G1 Wallet CREATED: $PHONE = $UIDNA $PIN : $PUBKEY"
[[ $PUBKEY == "" ]] && log "__SUB:sms_INIT_ACCOUNT: Problem making secret.dunikey" && exit 1 [[ $PUBKEY == "" ]] && log "__SUB:sms_INIT_ACCOUNT: Problem making secret.dunikey" && exit 1
####################### #######################
# ACTIVATE G1SMS WALLET # ACTIVATE G1SMS WALLET SEND 3.14 G1
####################### #######################
# log "$NODE_PUBSECFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY" # log "$NODE_PUBSECFILE $PUBKEY THIRD_PARTY_MANAGER:$NODE_G1PUBKEY"
duniter_server=$(/home/$YOU/.zen/astroport/zen/tools/duniter_getnode.sh) duniter_server=$(/home/$YOU/.zen/astroport/zen/tools/duniter_getnode.sh)
@ -301,7 +303,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT" log "__SUB:sms_INIT_ACCOUNT: G1 Wallet TX OUT: $TX_OUT"
################ ################
# GPG cypher PIN (ONLY CREATOR NODE CAN ACCESS IT !) # GPG cypher PIN so ONLY CREATOR NODE CAN ACCESS IT !)
################ ################
echo "$PIN" > "$PINFILE" echo "$PIN" > "$PINFILE"
echo "${IPFSPrivKey}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE" echo "${IPFSPrivKey}" | gpg -q --output "$GPGPINFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$PINFILE"

View File

@ -3,45 +3,65 @@
# Author: Fred (support@qo-op.com) # Author: Fred (support@qo-op.com)
# Version: 0.1 # Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
# This script is for inscription from a Web page (RUN by cron_MINUTE.sh) ################################################################################
# Web Ajax Form -> /tmp/loveland_entrance/$hashphone # AJAX REQUEST TRACKER : ASTROPORT ON BOARDING
# GETTING : PHONE + PARRAIN + NAISSANCE
#
# DataFlow : index.html + ajaxform.js + zen_loveland_entrance.php
################################################################################ ################################################################################
MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
source $MY_PATH/init.sh source $MY_PATH/init.sh
source $MY_PATH/functions.sh source $MY_PATH/functions.sh
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
TODAY=$(date '+%Y%m%d') TODAY=$(date '+%Y%m%d')
timestamp=$(date -u +%s%N | cut -b1-13) timestamp=$(date -u +%s%N | cut -b1-13)
log "__SUB:sms_ASTROPORT.sh" echo '
___ __ __
/ | _____/ /__________ ____ ____ _____/ /_
/ /| | / ___/ __/ ___/ __ \/ __ \/ __ \/ ___/ __/
/ ___ |(__ ) /_/ / / /_/ / /_/ / /_/ / / / /_
/_/ |_/____/\__/_/ \____/ .___/\____/_/ \__/
/_/
Love Land ENTRANCE CHECKING
# VERIFY task relay directory EXISTS and is 777 '
# LOCAL MODE
[[ ! -d /tmp/loveland_entrance ]] && mkdir -p /tmp/loveland_entrance && chmod -R 777 /tmp/loveland_entrance
# SWARM MODE
[[ ! -d /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/TASK/loveland_entrance ]] \
&& mkdir -p /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/TASK/loveland_entrance \
&& chmod -R 777 /home/$YOU/.zen/ipfs_swarm/.$ipfsnodeid/TASK/loveland_entrance
# SWARM MODE # TODO SWARM MODE TEST and activate ?
# for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do #for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
# TODO SSB task relay MODE # PHONE=$(cat $hashfile)
# HPHONE=$(basename -- "$hashfile")
# echo "We have received Ajax Astroport request from $PHONE"
#done
# if [[ ! -f /home/$YOU/.zen/ipfs_swarm/.Qm*/CHANNEL/$PHONEHASH@*/_pub ]]; then
# fi
# TODO SSB task relay MODE ??
# Search new SSB Publish # Search new SSB Publish
for hashfile in $(ls /tmp/loveland_entrance/); do for hashfile in $(ls /tmp/loveland_entrance/); do
PHONE=$(cat $hashfile) PP=$(cat $hashfile)
PHONEHASH=$(basename -- "$hashfile") PHONE=$(echo $PP | cut -d '|' -f 1)
PARRAIN=$(echo $PP | cut -d '|' -f 2)
NAISSANCE=$(echo $PP | cut -d '|' -f 3)
# TODO CHECK PHONE IN SWARM HPHONE=$(basename -- "$hashfile")
# if [[ ! -f /home/$YOU/.zen/ipfs_swarm/.Qm*/CHANNEL/$PHONEHASH@*/_pub ]]; then
# fi echo "Astroport Ajax Request received $PP"
if [[ ! -f /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub ]]; then if [[ ! -f /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub ]]; then
# NOT THERE # UNKNOW
sms_INIT_ACCOUNT "$PHONE" # CHECK for Associated PARRAIN. GET PubKey?
PARRAIN=$(echo "$PARRAIN" | grep -E "([A-Za-z0-9\-\_]+$)")
[[ $PARRAIN ]] && MEMRIB=$(sms_uid2key "$PARRAIN" "$PHONE" "$PIN") && echo "RIB PARRAIN: $MEMRIB"
# CREATE G1 WALLET
./sms_NEW.sh "$PHONE" "$PARRAIN"
else else
# ALREADY THERE # ACCOUNT ALREADY EXISTING
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU # Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
PUBKEY=$(cat /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub) PUBKEY=$(cat /home/$YOU/.zen/g1sms_wallets/$PHONE/_pub)
AMOUNTG1=$(silkaj_balance $PUBKEY) AMOUNTG1=$(silkaj_balance $PUBKEY)
@ -49,15 +69,15 @@ for hashfile in $(ls /tmp/loveland_entrance/); do
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR") AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
# DOUBLE AUTH SMS !! # DOUBLE AUTH SMS !!
./sms_AUTH.sh "$PHONE" "$PARRAIN"
mess="Bonjour
Compte mess="Bonjour! Astroport Station"
Astroport Station"
# Send response SMS # Send response SMS
sms_SEND "$PHONE" "$mess" sms_SEND "$PHONE" "$mess"
# SEND THE KEY !! # SEND THE KEY !! AND START ONBOARDING
@ -65,9 +85,16 @@ Astroport Station"
done done
[[ -d /home/$YOU/.zen/g1sms_wallets/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms_wallets/$PHONE [[ -d /home/$YOU/.zen/g1sms_wallets/$PHONE ]] && [[ $(whoami) == "root" ]] && chown -R $YOU /home/$YOU/.zen/g1sms_wallets/$PHONE
log "__SUB:sms_AUTH.sh: END sms_AUTH.sh " # VERIFY task relay directory EXISTS and is 777
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~" # LOCAL MODE
[[ ! -d /tmp/loveland_entrance ]] && mkdir -p /tmp/loveland_entrance && chmod -R 777 /tmp/loveland_entrance
# TASK SWARM MODE
[[ ! -d /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance ]] \
&& mkdir -p /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance \
&& chmod -R 777 /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance
exit 0 exit 0

View File

@ -17,14 +17,13 @@ source $MY_PATH/init.sh
source $MY_PATH/functions.sh source $MY_PATH/functions.sh
PHONE=$1 PHONE=$1
VALEUR=$2 PARRAIN=$2
TODAY=$(date '+%Y%m%d') TODAY=$(date '+%Y%m%d')
log "__SUB:sms_AUTH.sh ($PHONE, $VALEUR)" log "__SUB:sms_AUTH.sh ($PHONE, $PARRAIN) $TODAY"
## INITIALIZE RESULT FILE ## INITIALIZE RESULT FILE
[[ $VALEUR == "" ]] && echo "Indiquez la valeur des G1Billets" && exit 1 # [[ $PHONE != "" ]] && sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1 # VERIFICATION ALREADY DONE BY CALLING bash
[[ $PHONE != "" ]] && sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1 #[[ $UNKNOWN == "unknown" ]] && echo "G1sms Wallet $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1
[[ $UNKNOWN == "unknown" ]] && echo "G1sms Wallet $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU # Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
AMOUNTG1=$(silkaj_balance $PUBKEY) AMOUNTG1=$(silkaj_balance $PUBKEY)
@ -32,7 +31,7 @@ AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR") AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
# Convert amount to G1 unit # Convert amount to G1 unit
VIR=$(bc -l <<< "scale=2; $VALEUR * $DUFACTOR / 100") VIR=$(bc -l <<< "scale=2; $PARRAIN * $DUFACTOR / 100")
# Need at least $MIN G1 available! # Need at least $MIN G1 available!
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT") MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT")

View File

@ -7,10 +7,12 @@ jQuery(document).ready(function () {
"<h5>Suivez ses instructions pour finaliser votre inscription.</h5></p>"); "<h5>Suivez ses instructions pour finaliser votre inscription.</h5></p>");
// declare these vars // declare these vars
var phone = jQuery("#phone"); var phone = jQuery("#phone");
var parrain = jQuery("#parrain");
var naissance = jQuery("#naissance");
var data = ''; var data = '';
// ajax call to ajax.php // ajax call to ajax.php
jQuery.getJSON("zen_loveland_entrance.php", { jQuery.getJSON("zen_loveland_entrance.php", {
phone: phone.val() phone: phone.val(), parrain: parrain.val(), naissance: naissance.val()
}, function (data) { }, function (data) {
$("#phoneresultat").html("<p>Votre inscription en prise en compte...</p>"); $("#phoneresultat").html("<p>Votre inscription en prise en compte...</p>");
}); });

View File

@ -73,7 +73,6 @@
<form id="formphone"> <form id="formphone">
<div class="form-row"> <div class="form-row">
<div class="col-12 col-md-9 mb-2 mb-md-0"> <div class="col-12 col-md-9 mb-2 mb-md-0">
<input id="phone" type="phone" class="form-control form-control-lg" placeholder="Saisissez votre numéro de téléphone mobile..."> <input id="phone" type="phone" class="form-control form-control-lg" placeholder="Saisissez votre numéro de téléphone mobile...">
</div> </div>
<div class="col-12 col-md-3"> <div class="col-12 col-md-3">
@ -83,6 +82,7 @@
</form> </form>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xl-9 mx-auto"> <div class="col-xl-9 mx-auto">
<div id="phoneresultat"> <div id="phoneresultat">
@ -193,6 +193,24 @@
</div> </div>
</div> </div>
</section> </section>
<div class="row">
<div class="col-xl-9 mx-auto">
<div id="phoneresultat">
<br><h4>DEV ZONE<br></h4>
<div class="col-4 col-md-9 mb-2 mb-md-0">
<input id="parrain" type="parrain" class="form-control form-control-lg" placeholder="Pseudo du G1 Parrain">
</div>
<div class="col-4 col-md-9 mb-2 mb-md-0">
<input id="naissance" type="naissance" class="form-control form-control-lg" placeholder="Date de naissance? (optionnel)">
</div>
<div class="col-12 col-md-3">
<button type="submit" class="btn btn-block btn-lg btn-primary">Valider!</button>
</div>
</div>
</div>
</div>
<!-- Navigation --> <!-- Navigation -->
<nav class="navbar navbar-light bg-light static-top"> <nav class="navbar navbar-light bg-light static-top">
<div class="container"> <div class="container">

View File

@ -2,26 +2,34 @@
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
if ( ! isset($_REQUEST['phone']) ) { if ( ! isset($_REQUEST['phone']) ) {
// DEBUG // DEBUG
$_REQUEST['phone']="0647683646" $_REQUEST['phone'] = "0647683646";
$_REQUEST['parrain'] = "Fred";
$_REQUEST['naissance'] = "21-03-1972_18:04";
} }
if (strlen($_REQUEST['phone']) == 10 ) { if (strlen($_REQUEST['phone']) == 10 ) {
// Replace leading 0 with +33 // Replace leading 0 with +33
$PHONE = preg_replace('/^0?/', '+33', $_REQUEST['phone']); $PHONE = preg_replace('/^0?/', '+33', $_REQUEST['phone']);
$PARRAIN = $_REQUEST['parrain'];
$naissance = $_REQUEST['naissance'];
// HASH NUMBER // HASH NUMBER
$HPHONE=hash('sha256', $PHONE); $HPHONE=hash('sha256', $PHONE);
// CREATE FILE for POST TREATMENT with sms_ASTROPORT.sh // CREATE FILE for POST TREATMENT with sms_ASTROPORT.sh
// LOCAL // LOCAL
$fp = fopen('/tmp/loveland_entrance/'.$HPHONE, 'a'); $fp = fopen('/tmp/loveland_entrance/'.$HPHONE, 'w');
fwrite($fp, $PHONE); fwrite($fp, $PHONE.'|'.$PARRAIN.'|'.$naissance);
// SWARM /*
// MODE SWARM Syntax error: ")" unexpected TODO DEBUG
exec("ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)", $YOU, $return); exec("ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)", $YOU, $return);
if ($return == 0) { if ($return == 0) {
exec("ipfs id -f='<id>\n'", $ipfsnodeid, $return); print ($YOU);
exec("ipfs id -f='<id>\n'", $IPFSNODEID, $return);
// ACCESS RIGHT PROBLEM !!! // ACCESS RIGHT PROBLEM !!!
$fp = fopen('/home/$YOU/.zen/ipfs/.'.$ipfsnodeid.'/TASK/loveland_entrance/'.$HASH, 'a'); $fp = fopen('/home/$YOU/.zen/ipfs/.'.$IPFSNODEID.'/TASK/loveland_entrance/'.$HPHONE, 'w');
fwrite($fp, $PHONE); fwrite($fp, $PHONE);
} }
*/
return true; return true;
} else { } else {
return false; return false;