Beispiel #1
0
 /**
  * @Security("has_role('ROLE_SUPER_ADMIN')")
  */
 public function coreAction()
 {
     // Initialize filesystem Manager
     $filesystem = new Filesystem();
     // Load Core if config.yml exist
     if ($filesystem->exists('../INSTALL')) {
         return $this->redirect($this->generateUrl('app_feather_install'));
     } else {
         // Checking authentication parameter
         $transmission_authentication = $this->container->getParameter('transmission_authentication');
         // Get download and  temporary path
         $transmission_dir = $this->container->getParameter('transmission_dir');
         $transmission_tmp = $this->container->getParameter('transmission_tmp');
         // Initialize Transmission Connector
         $transmission = new Transmission();
         // Checking if transmission authentication is enabled
         if ($transmission_authentication == true) {
             $this->username = $this->container->getParameter('transmission_username');
             $this->password = $this->container->getParameter('transmission_password');
             // Initialize Client
             if (!isset($client)) {
                 $client = new Client();
                 $client->authenticate($this->username, $this->password);
             }
             // Inject authentication informations
             $transmission->setClient($client);
         }
         // Configuring many var of transmission and save as session
         $session = $transmission->getSession();
         $session->setDownloadDir($transmission_dir);
         $session->setIncompleteDir($transmission_tmp);
         $session->setIncompleteDirEnabled(true);
         $session->save();
         // Get list of current torrents in queue
         $torrents = $transmission->all();
         // Display total disk free space left
         $diskspace = disk_free_space($transmission_dir);
         // Return twig file
         return $this->render('AppFeatherBundle:Core:index.html.twig', array('torrents' => $torrents, 'diskspace' => $diskspace));
     }
 }