Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- namespace Dmcl\AppBundle\Command;
- /**
- * Description of AnuciosCommand
- *
- * @author dani
- */
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand,
- Symfony\Component\Console\Input\InputInterface,
- Symfony\Component\Console\Input\InputOption,
- Symfony\Component\Console\Output\OutputInterface
- ;
- class ScreenshotCommand extends ContainerAwareCommand {
- protected $container;
- protected function configure() {
- $this->setName('webpanel:screenshot');
- }
- protected function execute(InputInterface $input, OutputInterface $output) {
- $this->container = $this->getContainer();
- $em = $this->container->get('doctrine')->getManager();
- $d = new \DateTime("now");
- if(file_exists($this->container->getParameter('kernel.logs_dir')."/.lastScreenshot")){
- try {
- $d = new \DateTime(file_get_contents($this->container->getParameter('kernel.logs_dir')."/.lastScreenshot"));
- } catch (\Exception $e) {
- $d = new \DateTime("now");
- }
- }else{
- file_put_contents($this->container->getParameter('kernel.logs_dir')."/.lastScreenshot",$d->format("Y/m/d h:i:s"));
- }
- // $fr->$format("Y/m/d")
- $errorReport = "";
- $config = $em->getRepository('AppBundle:Config')->findOneBy(array());
- if($config){
- $screenShotIntervals=$config->getScreenshot();
- $now = new \
- DateTime("now");
- $diff = $now->diff($d);
- if($diff->i >= $screenShotIntervals){
- $now = new \DateTime("now");
- file_put_contents($this->container->getParameter('kernel.logs_dir')."/.lastScreenshot",$now->format("Y/m/d h:i:s"));
- $channels = $em->getRepository('AppBundle:Channels')->findAll();
- // $folder = $config->getScreenshotPath() . "webpanel-screenshot/".$now->format("Y-m-d-h-i-s");
- $folder = $this->container->getParameter('uploadLogo')."snapshots/";
- if(!is_dir($folder)){
- mkdir($folder);
- }
- foreach ($channels as $entity) {
- if($entity->getScreenshot()){
- if (file_exists($this->container->getParameter('kernel.logs_dir') . "/cmd_output/" . trim($entity->_getName()) . "/" . trim($entity->_getName()) . ".pid")) {
- $pid = @file_get_contents($this->container->getParameter('kernel.logs_dir') . "/cmd_output/" . trim($entity->_getName()) . "/" . trim($entity->_getName()) . ".pid");
- $pid = str_replace("\n", "", $pid);
- $pid+=0;
- if (file_exists("/proc/$pid") && $pid != "") {
- if(!is_dir($folder)){
- mkdir($folder);
- }
- @exec("/usr/share/webpanel/libs/ffmpeg/ffmpeg -i ".trim($entity->getOutputurl())." -ss 00:00:10 -vframes 1 -s 470X380 -y $folder".$entity->getId().".png > /dev/null 2>&1 &");
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement