Esempio n. 1
0
 /**
  * Sets flags.
  *
  * @param  array $flags array
  * @return array
  */
 public static function setFlag($flags = array())
 {
     self::$_flag = array('status' => array('active' => 'ativo', 'run' => 'inicializa', 'download' => 'fimciclo'), 'url' => array('login' => 'login', 'config' => 'config', 'last' => 'ultimoacesso', 'playlist' => 'playlist', 'access' => 'dadosftp'), 'player' => array('id' => 'idplayer', 'name' => 'nome', 'screen' => 'player', 'sector' => 'idponto', 'code' => 'senhaAc', 'status' => 'configurado'), 'user' => array('id' => 'cliente', 'login' => 'login', 'password' => 'senha', 'name' => 'nomecliente', 'category' => 'segmento'), 'settings' => array('start' => 'hrentradaplayer', 'end' => 'hrsaidaplayer', 'width' => 'resolucaolar', 'height' => 'resolucaoalt', 'duration' => 'tempoloop', 'off' => 'deslautomaticoplayer', 'status' => 'inativar'), 'playlist' => array('media' => array('index' => 'midias', 'name' => 'nome', 'title' => 'titulo', 'template' => 'template', 'type' => 'tipo', 'hash' => 'hash', 'status' => 'status', 'file' => 'arquivo', 'filename' => 'arquivo', 'library' => 'biblioteca', 'xml' => 'xml', 'campaign' => 'campanha', 'media' => 'midia', 'status' => 'status', 'duration' => 'duracao')), 'files' => array('refresh' => array('file' => '.refresh'), 'download' => array('file' => 'download.bat'), 'log' => array('file' => 'log.txt'), 'status' => array('file' => 'status.ini'), 'config' => array('file' => 'config.xml'), 'playlist' => array('file' => 'playlist.xml', 'temp' => 'playlist.tmp.xml'), 'loop' => array('file' => 'loop.xml', 'temp' => 'loop.tmp.xml')), 'label' => array('config' => 'config', 'playlist' => 'playlist', 'loop' => 'loop', 'library' => 'biblioteca', 'ftp' => 'ftp', 'feed' => 'feeds'), 'field' => array('image' => 'imagem', 'description' => 'descricao'), 'ftp' => array('host' => 'host', 'file' => 'file', 'feed' => 'feed', 'user' => 'user', 'pass' => 'pass'), 'layout' => array('index' => 'layout', 'login' => 'login', 'download' => 'download', 'play' => 'play'));
     self::$_flag = array_merge(self::$_flag, array('path' => self::getPath()));
 }
Esempio n. 2
0
 /**
  * Run installation.
  *
  * @return string
  */
 private function __runInstall($connection, $validate, $params = null)
 {
     $url = Player_Flags::getFlag('url');
     $status = Player_Flags::getFlag('status');
     $player = Player_Flags::getFlag('player');
     $label = Player_Flags::getFlag('label');
     $login = $connection->loadConnection($this->getEnvironment(), $url['login'], $params);
     if ($login) {
         $xml = Player_Convert::getXML($login, $label['config']);
         if (isset($xml[$status['active']])) {
             if (intval($xml[$status['active']]) == 1) {
                 Player_File::setFile($this->getConfigFile(), $login, true);
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 3
0
 public static function getMediaFTP($host, $user, $pass, $server, $local, $file, $hashing = false)
 {
     $label = Player_Flags::getFlag('playlist', 'media');
     Player_File::setDir($local);
     $done = array();
     foreach ($file as $key => $value) {
         if (self::connect($host)) {
             if (self::login($user, $pass)) {
                 $hostpath = explode('/', $server);
                 foreach ($hostpath as $dir) {
                     self::chdir($dir);
                 }
                 if (!in_array($value[$label['file']], $done)) {
                     $i = 1;
                     do {
                         Player_Debug::setDebug($value[$label['file']], 1);
                         $result = true;
                         self::get($local . $value[$label['file']], $value[$label['file']]);
                         $log = self::getLastResult();
                         if ($log == self::FTP_COMMAND_OK || $log == self::FTP_FILE_ACTION_OK || $log == self::FTP_FILE_TRANSFER_OK || $log == self::FTP_PASSIVE_MODE) {
                             if ($hashing) {
                                 $hash = Player_Encrypt::setHashFile($local . $value[$label['file']]);
                                 if ($value[$label['hash']] === $hash) {
                                     $result = false;
                                     array_push($done, $value[$label['file']]);
                                 }
                             } else {
                                 $result = false;
                                 array_push($done, $value[$label['file']]);
                             }
                             self::disconnect();
                         } else {
                             Player_Debug::setDebug('Error downloading ' . $value[$label['file']] . '. Trying again.', 2);
                             Player_Debug::setDebug('Fail: ' . $i++ . '; Log: ' . $log, 3);
                             if ($i > 5) {
                                 Player_Debug::setDebug('Canceling download after ' . $i++ . ' failed tries.' . Player_Debug::getTab() . '"' . $value[$label['file']] . '"', 1);
                                 return false;
                             }
                         }
                     } while ($result);
                 }
             }
             self::disconnect();
         } else {
             return false;
         }
     }
     if (count($done) == count($file)) {
         return true;
     }
 }
Esempio n. 4
0
 public static function setClear()
 {
     $path = Player_Flags::getFlag('path');
     $files = Player_Flags::getFlag('files', 'refresh');
     $filename = $path['config'] . $files['file'];
     if (Player_File::setFile($filename)) {
         return true;
     }
     return false;
 }
Esempio n. 5
0
 protected function checkNewMedia($campaigns = 0, $medias = 0)
 {
     $playlist = $this->getPlaylist();
     $media = Player_Flags::getFlag('playlist', 'media');
     $label = Player_Flags::getFlag('label', 'playlist');
     $path = Player_Flags::getFlag('path');
     $next = false;
     $each = false;
     $return = null;
     foreach ($playlist as $key => $value) {
         if ($each == true) {
             $next = true;
             $each = false;
         }
         foreach ($value[$media['index']] as $k => $v) {
             if (!in_array($campaigns, array_keys($playlist))) {
                 $next = true;
             }
             if ($campaigns == $key) {
                 if (!in_array($medias, array_keys($playlist[$key][$media['index']]))) {
                     $each = true;
                 }
             }
             if ($next && $return == null) {
                 if (file_exists($path['media'] . $v[$media['filename']])) {
                     if ($v[$media['type']] == $media['file']) {
                         $loop = $this->checkLoop($key, $k);
                         if ($loop[$media['status']]) {
                             $return = array($media['campaign'] => $key, $media['media'] => $k);
                         }
                     } else {
                         $return = array($media['campaign'] => $key, $media['media'] => $k);
                     }
                 }
             }
             if ($key == $campaigns) {
                 if ($k == $medias) {
                     if ($v[$media['type']] == $media['file']) {
                         $each = true;
                     } else {
                         $next = true;
                     }
                 }
             }
         }
     }
     if ($return == null) {
         $return = $this->checkMedia($campaigns, $medias, true);
     }
     $this->setNextMedia($return);
 }
Esempio n. 6
0
 public function setDownload()
 {
     Player_Debug::setDebug('Saving settings...');
     Player_Debug::setStatus('Finishing download...');
     $path = Player_Flags::getFlag('path');
     $files = Player_Flags::getFlag('files');
     $label = Player_Flags::getFlag('label');
     $status = Player_Flags::getFlag('status');
     $file = Player_File::getFile($path['config'] . $files['config']['file']);
     $xml = Player_Convert::getXML($file, $label['config']);
     $xml[$status['download']] = 1;
     $file = Player_Convert::setXML($label['config'], $xml);
     if (Player_File::setFile($path['config'] . $files['config']['file'], $file, true)) {
         if (file_exists($path['config'] . $files['download']['file'])) {
             if (Player_File::unsetFile($path['config'] . $files['download']['file'])) {
                 return true;
             } else {
                 return false;
             }
         }
         return true;
     }
     return false;
 }