2019-12-08 02:33:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of RaspiSMS.
|
|
|
|
*
|
|
|
|
* (c) Pierre-Lin Bonnemaison <plebwebsas@gmail.com>
|
|
|
|
*
|
|
|
|
* This source file is subject to the GPL-3.0 license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace controllers\internals;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to call the console scripts
|
|
|
|
*/
|
|
|
|
class Console extends \descartes\InternalController
|
|
|
|
{
|
2020-01-07 01:31:34 +01:00
|
|
|
/**
|
2020-01-08 18:20:17 +01:00
|
|
|
* Start launcher daemon
|
2020-01-07 01:31:34 +01:00
|
|
|
*/
|
2020-01-08 18:20:17 +01:00
|
|
|
public function launcher ()
|
2019-12-08 02:33:53 +01:00
|
|
|
{
|
2020-01-08 18:20:17 +01:00
|
|
|
new \daemons\Launcher();
|
2019-12-08 02:33:53 +01:00
|
|
|
}
|
2019-12-17 14:38:16 +01:00
|
|
|
|
|
|
|
|
2020-01-07 01:31:34 +01:00
|
|
|
/**
|
|
|
|
* Start sender daemon
|
|
|
|
*/
|
|
|
|
public function sender ()
|
2019-12-17 14:38:16 +01:00
|
|
|
{
|
2020-01-07 01:31:34 +01:00
|
|
|
new \daemons\Sender();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start webhook daemon
|
|
|
|
*/
|
|
|
|
public function webhook ()
|
|
|
|
{
|
|
|
|
new \daemons\Webhook();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start a phone daemon
|
|
|
|
* @param $id_phone : Phone id
|
|
|
|
*/
|
|
|
|
public function phone ($id_phone)
|
|
|
|
{
|
|
|
|
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, 'UTF8');
|
|
|
|
$internal_phone = new \controllers\internals\Phone($bdd);
|
|
|
|
|
|
|
|
$phone = $internal_phone->get($id_phone);
|
|
|
|
if (!$phone)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
new \daemons\Phone($phone);
|
2019-12-17 14:38:16 +01:00
|
|
|
}
|
2020-01-12 22:20:12 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cette fonction retourne la fenetre de connexion.
|
|
|
|
*/
|
|
|
|
public function test($id_phone)
|
|
|
|
{
|
|
|
|
$bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD, 'UTF8');
|
|
|
|
$internal_phone = new \controllers\internals\Phone($bdd);
|
|
|
|
$phone = $internal_phone->get($id_phone);
|
|
|
|
if (!$phone)
|
|
|
|
{
|
|
|
|
echo "No phone for id : $id_phone\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Found phone for id : $id_phone\n";
|
|
|
|
|
|
|
|
$adapter_classname = $phone['adapter'];
|
|
|
|
$adapter = new $adapter_classname($phone['number'], $phone['adapter_datas']);
|
|
|
|
|
|
|
|
//Try send a message
|
2020-01-12 23:57:24 +01:00
|
|
|
/*
|
2020-01-12 22:20:12 +01:00
|
|
|
$destination = '+33669529042';
|
|
|
|
$text = "Coucou c'est pour un test !";
|
|
|
|
$flash = false;
|
|
|
|
$uid = $adapter->send($destination, $text, $flash);
|
|
|
|
|
|
|
|
if (!$uid)
|
|
|
|
{
|
|
|
|
echo "Cannot send message to $destination\n";
|
2020-01-12 23:57:24 +01:00
|
|
|
return false;
|
2020-01-12 22:20:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "Send a message to $destination with uid $uid \n";
|
2020-01-12 23:57:24 +01:00
|
|
|
*/
|
|
|
|
$smss = $adapter->read();
|
|
|
|
var_dump($smss);
|
2020-01-12 22:20:12 +01:00
|
|
|
}
|
2019-12-08 02:33:53 +01:00
|
|
|
}
|