Exemplo n.º 1
0
 /**
  * Sets the player activation code and writes in the .activation filename.
  *
  * @return string
  */
 public function setActivation()
 {
     $code = $this->_setCode();
     Player_File::setFile($this->_filename, $code, true);
     $this->_activation = $code;
     return $this->_activation;
 }
Exemplo n.º 2
0
 /**
  * Write a .ini file.
  *
  * @param  array $params array
  * @param  string $filename null
  * @param  string $level -1
  * @return mixed
  */
 public static function setIni($params = array(), $filename = null, $level = -1)
 {
     if ($params && $filename) {
         $return = '';
         $level++;
         foreach ($params as $key => $value) {
             if (is_array($value)) {
                 if (count($value) > 1) {
                     $return .= self::setIni($value, $filename, $level);
                 } else {
                     $return .= $key . ' = "' . self::setIni($value, $filename, $level) . '"' . PHP_EOL;
                 }
             } else {
                 if (is_int($value)) {
                     $return .= $key . ' = "' . $value . '"' . PHP_EOL;
                 } else {
                     $return .= $key . ' = "' . $value . '"' . PHP_EOL;
                 }
             }
         }
         if ($level == 0) {
             $return = Player_File::setFile($filename, $return, true);
         }
         return $return;
     }
     return false;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 public function showLayout($layout = null, $options = null)
 {
     if ($options != null) {
         $this->customLayout($options);
     }
     $filename = $this->getLayout($layout);
     $file = Player_File::getFile($filename);
     ob_start();
     include $filename;
     $return = ob_get_contents();
     ob_end_clean();
     print $return;
 }
Exemplo n.º 5
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;
     }
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 /**
  * Load a File from any server
  * 
  * Sets and gets the validation of the player
  *
  * @param  string $path null
  * @param  array $params null
  * @return array
  */
 public function loadFile($filename = null, $path = null, $overwrite = false)
 {
     if ($this->checkConnection()) {
         $url = $path;
         $curl = curl_init();
         $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_URL => $url);
         $proxy = new Player_Connect_Proxy();
         if (is_array($proxy::getProxy())) {
             $options[CURLOPT_HTTPPROXYTUNNEL] = true;
             $options[CURLOPT_PROXY] = $proxy::$server;
             $options[CURLOPT_PROXYPORT] = $proxy::$port;
         }
         curl_setopt_array($curl, $options);
         $return = curl_exec($curl);
         $error = curl_errno($curl);
         $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
         $size = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
         $total = curl_getinfo($curl, CURLINFO_SIZE_DOWNLOAD);
         curl_close($curl);
         if ($error == 0) {
             if ($code < 400) {
                 if ($size === $total) {
                     if (Player_File::setFile($filename, $return, $overwrite)) {
                         return true;
                     }
                 }
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 8
0
 public function setLoop($campaigns = null, $medias = null)
 {
     $loop = $this->getLoop();
     $media = Player_Flags::getFlag('playlist', 'media');
     $files = Player_Flags::getFlag('files', 'loop');
     $label = Player_Flags::getFlag('label', 'loop');
     $path = Player_Flags::getFlag('path');
     if (isset($loop[$campaigns][$medias])) {
         $loop[$campaigns][$medias][$media['status']] = false;
     }
     $file = Player_Convert::setXML($label, $loop);
     if (Player_File::setFile($path['config'] . $files['file'], $file, true)) {
         return true;
     }
     return false;
 }
Exemplo n.º 9
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;
 }