Advertisement
annukaka

ymListener.php

Aug 19th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <?php
  2. namespace app\commands\service;
  3.  
  4. use Symfony\Component\Console\Command\Command;
  5.  
  6. use Symfony\Component\Console\Input\InputArgument;
  7. use Symfony\Component\Console\Input\InputDefinition;
  8. use Symfony\Component\Console\Input\InputInterface;
  9. use Symfony\Component\Console\Input\InputOption;
  10. use Symfony\Component\Console\Output\OutputInterface;
  11. use Symfony\Component\Console\Question\ConfirmationQuestion;
  12. use Symfony\Component\Console\Question\Question;
  13. use Symfony\Component\Console\Question\ChoiceQuestion;
  14.  
  15. use app\libs\config;
  16. use app\libs\enc;
  17. use app\libs\log;
  18. use app\libs\db;
  19. use app\libs\say;
  20. use app\libs\ym;
  21. use app\models\provider;
  22. use app\models\device;
  23.  
  24.  
  25. class ymListener extends Command {
  26.     protected function configure() {
  27.         $this->setName("service:ymListener")
  28.              ->setDescription("ym listener". say::info("* DONT DO IT MANUAL IF YOU DONT UNDERSTAND!!"))
  29.              ->addArgument("ymID",InputArgument::REQUIRED,"YM ID")
  30.              ->addOption(
  31.                     "shell","s",InputOption::VALUE_REQUIRED,'shell loop');
  32.     }
  33.     protected function execute(InputInterface $input, OutputInterface $output)
  34.     {
  35.         # get ymID
  36.         $ymID = $input->getArgument("ymID");
  37.         $opt = $input->getOptions();
  38.  
  39.         dump("-o-o");
  40.         # get ym data
  41.         $db = new db;
  42.         $query = "SELECT * FROM ym WHERE ymID = '$ymID'";
  43.         $db->query($query)->execute();
  44.  
  45.         $ym = $db->fetchALL();
  46.  
  47.         // var_dump($ym);die;
  48.         if (isset($ym[0])) {
  49.  
  50.             # run the ym listener
  51.  
  52.             $ymEngine = new ym(
  53.                 $ym[0]["ymID"],
  54.                 $ym[0]["ymPassword"],
  55.                 $ym[0]["ymConsumerKey"],
  56.                 $ym[0]["ymSecretKey"]
  57.             );
  58.  
  59.                 // var_dump($ymEngine);
  60.             # prepare the shell
  61.             $config = new config;
  62.             $ymConfig =$config->get("ym");
  63.             $shell = str_replace("%ymID%", $ym[0]["ymID"], $ymConfig["runonreceive"]);
  64.  
  65.  
  66.             # set the run on receive
  67.             $ymEngine->setRunOnReceive($shell);
  68.             if($ymEngine->connect() == false){
  69.             }
  70.             if($ymEngine->listen() == false){
  71.             }
  72.  
  73.         }
  74.  
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement