'data.gchange.fr' ]; private $msgLimit = 30; private $userPubsecPath; public function __construct ($userPubkey, $mode = 'local') { $this->userPubsecPath = __DIR__ .'/../cache/pubsec/'. $userPubkey .'.dunikey'; if ($this->mode != 'local') { $this->fred = new Fred(); } } public function getMessages () { if ($this->mode = 'local') { return [ $this->getInboundMessages(), $this->getOutboundMessages() ]; } else { $this->fred->donneMoiSesPutainDeMessagesGchange($_SESSION['salt'], $_SESSION['pepper'], 'coucou'); } } public function getInboundMessages () { $cmd = $this->jaklisPath; $cmd .= ' --key '. $this->userPubsecPath; $cmd .= ' --node https://'. $this->nodes['gchange']; $cmd .= ' read'; $cmd .= ' --number ' . $this->msgLimit; $cmd .= ' --json'; $output=null; $result_code=null; exec($cmd, $output, $result_code); $json = implode("\n", $output); // echo '

' . $cmd . '

'; // echo '
'; var_dump($json); echo '
'; $result = json_decode($json); // echo '
'; var_dump($result); echo '
'; return $result; } public function getOutboundMessages () { $cmd = $this->jaklisPath; $cmd .= ' --key '. $this->userPubsecPath; $cmd .= ' --node http://'. $this->nodes['gchange']; $cmd .= ' read'; $cmd .= ' --number ' . $this->msgLimit; $cmd .= ' --json'; $cmd .= ' --outbox'; $output=null; $result_code=null; exec($cmd, $output, $result_code); $json = implode("\n", $output); // echo '

' . $cmd . '

'; // echo '
'; var_dump($json); echo '
'; $result = json_decode($json); // echo '
'; var_dump($result); echo '
'; return $result; } private function jescape ($str) { return str_replace('"', '\"', $str); } public function sendMessage ($msg, $toPubkey, $title, $fromPubkey) { $cmd = $this->jaklisPath; $cmd .= ' --key '. $this->userPubsecPath; $cmd .= ' --node http://'. $this->nodes['gchange']; $cmd .= ' send'; $cmd .= ' --destinataire "' . $this->jescape($toPubkey) . '"'; $cmd .= ' --titre "' . $this->jescape($title) . '"'; $cmd .= ' --message "' . $this->jescape($msg) . '"'; // echo '
'. $cmd . '
'; $output=null; $result_code=null; exec($cmd, $output, $result_code); // echo '
'; var_dump($result_code); echo '
'; // echo '
'; var_dump($output); echo '
'; // list($jaklisResult, $id) = $output; // echo '

'. $jaklisResult .'

'; } }