$os === Os::OS_LINUX ? 'AppImage' : '', 'title' => $title, 'osTitle' => $osTitle, 'osIcon' => $osIcon, 'osScreenshotSrc' => 'https://spee.ch/b/desktop-035-og.jpeg', 'os' => $os ]; if ($os === OS::OS_ANDROID) { $params['downloadUrl'] = static::ANDROID_STORE_URL; $params['osScreenshotSrc'] = 'https://spee.ch/@lbry:3f/android-08-homepage.gif'; } elseif ($os === OS::OS_IOS) { $params['downloadUrl'] = static::IOS_STORE_URL; $params['osScreenshotSrc'] = 'https://spee.ch/odyseeiosimage.png'; } else { $asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os, $params['preferredExt']); $params['downloadUrl'] = $asset ? $asset['browser_download_url'] : null; } return $params; } public static function executeGet() { $osChoices = OS::getAll(); $os = static::guessOS(); if (isset($os) && isset($osChoices[$os]) && !Request::getParam('showall')) { return ['download/get', static::getGetTemplateParams($os)]; } else { return ['download/get-no-os']; } } public static function prepareListPartial(array $vars) { return $vars + ['osChoices' => isset($vars['excludeOs']) ? array_diff_key(OS::getAll(), [$vars['excludeOs'] => null]) : OS::getAll() ]; } protected static function guessOs() { //if exact OS is requested, use that $uri = Request::getRelativeUri(); foreach (OS::getAll() as $os => $osChoice) { if ($osChoice[0] == $uri) { return $os; } } if (Request::isRobot()) { return null; } //otherwise guess from UA $ua = Request::getUserAgent(); if (stripos($ua, 'OS X') !== false) { return strpos($ua, 'iPhone') !== false || stripos($ua, 'iPad') !== false ? OS::OS_IOS : OS::OS_OSX; } if (stripos($ua, 'Linux') !== false || strpos($ua, 'X11') !== false) { return strpos($ua, 'Android') !== false ? OS::OS_ANDROID : OS::OS_LINUX; } if (stripos($ua, 'Windows') !== false) { return OS::OS_WINDOWS; } } protected static function getEmailParam() { $email = Request::getParam('e'); if (!$email) { $encoded = Request::getParam('ec'); if ($encoded) { $email = Smaz::decode(Encoding::base64DecodeUrlsafe($encoded), Smaz::CODEBOOK_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $email = null; } } } return $email; } public static function prepareDownloadButtonPartial(array $vars) { $osChoices = OS::getAll(); $os = static::guessOS(); if ($os && isset($osChoices[$os])) { list($uri, $osTitle, $osIcon, $oldButtonLabel, $analyticsLabel) = $osChoices[$os]; if ($os === OS::OS_ANDROID) { $asset = ['browser_download_url' => static::ANDROID_STORE_URL]; } elseif ($os === OS::OS_IOS) { $asset = ['browser_download_url' => static::IOS_STORE_URL]; } else { $asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os, $vars['preferredExt'] ?? ''); } $buttonLabel = __('Download for %os%', ['%os%' => $osTitle]); if (isset($vars['preferredExt']) && $vars['preferredExt']) { $buttonLabel = __('Download .%ext%', ['%ext%' => $vars['preferredExt']]); } $vars += [ 'analyticsLabel' => $analyticsLabel, 'buttonLabel' => $buttonLabel, 'isDownload' => true, 'downloadUrl' => $asset ? $asset['browser_download_url'] : null, 'os' => $os, 'skipRender' => isset($vars['preferredExt']) && $vars['preferredExt'] && substr_compare($asset['browser_download_url'], $vars['preferredExt'], -strlen($vars['preferredExt'])) !== 0, 'isAuto' => Request::getParam('auto'), ]; if ($os === OS::OS_LINUX && !isset($vars['preferredExt'])) { $vars['isDownload'] = false; $vars['downloadUrl'] = '/linux'; } } return $vars; } public static function prepareMetaPartial(array $vars) { $osChoices = OS::getAll(); $os = static::guessOS(); if ($os && isset($osChoices[$os])) { list($uri, $osTitle, $osIcon, $buttonLabel, $analyticsLabel) = $osChoices[$os]; if ($os === OS::OS_ANDROID) { $asset = ['browser_download_url' => static::ANDROID_STORE_URL, 'size' => 0]; $release = []; } elseif ($os === OS::OS_IOS) { $asset = ['browser_download_url' => static::IOS_STORE_URL, 'size' => 0]; $release = []; } else { $release = Github::getRepoRelease(GitHub::REPO_LBRY_DESKTOP, false); $asset = Github::getRepoAsset(GitHub::REPO_LBRY_DESKTOP, $os); } $vars += [ 'os' => $os, 'osTitle' => $osTitle, 'osIcon' => $osIcon, 'releaseTimestamp' => $release ? strtotime($release['created_at']) : null, 'size' => $asset ? $asset['size'] / (1024 * 1024) : 0, //bytes -> MB 'sourceLink' => false, 'version' => $release ? $release['name'] : null, 'isAuto' => Request::getParam('auto'), ]; } return $vars; } }