public static function switchDebug($params = null) { if (is_bool($params)) { self::$_debug == $params; } else { self::$_debug = self::$_debug ? false : true; } return self::$_debug; }
public function run() { $options = $this->getOptions(); $proxy = isset($options['proxy']) ? $options['proxy'] : null; $connection = new Player_Connect($proxy); $validate = new Player_Validate(); $activation = $validate->getActivation(); if ($this->getInstall()) { if ($this->getDownload()) { $this->setPlay(); } else { $this->setDownload($connection); $status = Player_Debug::getStatus(); $this->layout->refresh = 5; $this->layout->msg = $status['msg']; $this->layout->status = $status['status']; } } else { $this->layout->status = 'Sign in for activate'; $this->layout->code = $activation; $this->setInstall($connection, $validate); } $this->setScreen(); }
/** * Gets values of the flags from settings. * * @return boolean */ public function setPlay() { if (isset($_GET['layout'])) { if ($_GET['layout'] == 'play') { $session = new Player_Session('play'); $play = new Player_Play($session); $flags = Player_Flags::getFlag(); $media = Player_Flags::getFlag('playlist', 'media'); $path = Player_Flags::getFlag('path', 'rel'); $return = $play->run(); if (Player_Debug::getClear()) { $session->clearSession(); Player_Utils::redirect(); } else { $server = 'http://' . $_SERVER["HTTP_HOST"]; $params = ''; if ($return[$media['type']] == $media['library']) { $params = '?library=' . $server . $path['library'] . $return[$media['xml']] . '&picture=' . $server . $path['picture']; } $this->layout->media = $server . $path['media'] . $return[$media['filename']] . $params; $this->layout->flags = $flags; $this->layout->refresh = $return[$media['duration']] . '; URL=' . $server . '/play'; } } else { Player_Utils::redirect('play'); } } else { Player_Utils::redirect('play'); } }
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; } }
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; }