Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace app\commands\service;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputDefinition;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\OutputInterface;
- use Symfony\Component\Console\Question\ConfirmationQuestion;
- use Symfony\Component\Console\Question\Question;
- use Symfony\Component\Console\Question\ChoiceQuestion;
- use app\libs\config;
- use app\libs\enc;
- use app\libs\log;
- use app\libs\db;
- use app\libs\say;
- use app\libs\ym;
- use app\models\provider;
- use app\models\device;
- class ymListener extends Command {
- protected function configure() {
- $this->setName("service:ymListener")
- ->setDescription("ym listener". say::info("* DONT DO IT MANUAL IF YOU DONT UNDERSTAND!!"))
- ->addArgument("ymID",InputArgument::REQUIRED,"YM ID")
- ->addOption(
- "shell","s",InputOption::VALUE_REQUIRED,'shell loop');
- }
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- # get ymID
- $ymID = $input->getArgument("ymID");
- $opt = $input->getOptions();
- dump("-o-o");
- # get ym data
- $db = new db;
- $query = "SELECT * FROM ym WHERE ymID = '$ymID'";
- $db->query($query)->execute();
- $ym = $db->fetchALL();
- // var_dump($ym);die;
- if (isset($ym[0])) {
- # run the ym listener
- $ymEngine = new ym(
- $ym[0]["ymID"],
- $ym[0]["ymPassword"],
- $ym[0]["ymConsumerKey"],
- $ym[0]["ymSecretKey"]
- );
- // var_dump($ymEngine);
- # prepare the shell
- $config = new config;
- $ymConfig =$config->get("ym");
- $shell = str_replace("%ymID%", $ym[0]["ymID"], $ymConfig["runonreceive"]);
- # set the run on receive
- $ymEngine->setRunOnReceive($shell);
- if($ymEngine->connect() == false){
- }
- if($ymEngine->listen() == false){
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement