astrXbian/www/boris/ajax.php

36 lines
1.2 KiB
PHP

<?php
$headers = "From: support@qo-op.com"; // Who should it come from?
$to = "support@qo-op.com"; // Your email address
$subject = "Astroport qo-op BLOB";
$arguments = getopt("l:p:"); // php ajax.php -l "https://myserve.com/link.html"
if (isset($_REQUEST['link'])) $link = $_REQUEST['link']; else $link = urldecode($arguments['l']);
if (isset($_REQUEST['phone'])) $phone = $_REQUEST['phone']; else $phone = urldecode($arguments['p']);
$message = "Proposition de ". $phone ." message : ".$link;
$TIMESTAMP=system("date -u +%s%N | cut -b1-13", $retval);
print_r($TIMESTAMP);
$YOU=system("ps u -C ipfs | tail -n 1 | cut -f 1 -d ' '", $retval);
print_r($YOU);
//$IPFSNODEID=curl_exec("http://127.0.0.1:5001/ipns/");
//print_r($IPFSNODEID);
// WRITE MESSAGE LOCALY
$myfile = fopen("/home/".$YOU."/astroport/www/".$TIMESTAMP.".newfile.txt", "w") or die("Unable to open file!");
fwrite($myfile, $message);
fclose($myfile);
// WRITE MESSAGE TO IPFS
//$myfile = fopen("/home/".$YOU."/.zen/ipfs/.$IPFSNODEID/astroport/www/newfile.txt", "w") or die("Unable to open file!");
//fwrite($myfile, $message);
//fclose($myfile);
error_log("SEND ". $phone ." message : ".$link );
mail($to, $subject, $message, $headers);
echo "OK";
?>