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 setPictures() { Player_Debug::setStatus('Downloading images...'); $library = $this->getLibraries(); $media = Player_Flags::getFlag('playlist', 'media'); $label = Player_Flags::getFlag('label'); $path = Player_Flags::getFlag('path'); $field = Player_Flags::getFlag('field'); Player_Debug::setDebug('Listing images to download:'); foreach ($library as $key => $value) { $lib = $path['library'] . $path['temp']; $file = Player_File::getFile($lib . $value); $feed = Player_Convert::getXML($file, $label['library']); if (isset($feed[$label['feed']])) { foreach ($feed[$label['feed']] as $k => $v) { if (isset($v[$field['image']])) { if (!empty($v[$field['image']])) { $local = $path['picture']; $temp = $path['picture'] . $path['temp']; $filename = substr($v[$field['image']], strrpos($v[$field['image']], '/') + 1); if (!file_exists($local . $filename)) { Player_File::setDir($temp); $i = 1; do { $success = $this->loadFile($temp . $filename, $v[$field['image']], true); if ($success) { Player_Debug::setDebug('Download:' . Player_Debug::getTab() . '"' . $filename . '"', 1); } else { Player_Debug::setDebug('Trying download ' . $i++ . Player_Debug::getTab() . '"' . $filename . '"', 1); if ($i > 5) { Player_Debug::setDebug('Canceling download after ' . $i++ . ' failed tries.' . Player_Debug::getTab() . '"' . $filename . '"', 1); return false; } } $success = Player_Utils::setSwitch($success, true, false); } while ($success); } $this->setPics($filename); } } } } } return true; }