Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* "Avatar Collision Finder Class.php" */
- include_once("{$_SERVER['DOCUMENT_ROOT']}/Url Check Class.php");
- $urlCheck = new UrlCheckClass(['audience','author'], false);
- include_once("{$_SERVER['DOCUMENT_ROOT']}/Impressions.php");
- $audienceFolder = $urlCheck->audienceFolder;
- $fullPath = $urlCheck->fullPath;
- class AvatarCollisionFinderClass
- {
- protected string $avatar;
- protected string $basePath;
- protected array $track = [];
- public function __construct(array $get, array $nsfz)
- {
- $this->avatar = pathinfo($get['author'] ?? '', PATHINFO_FILENAME) . '.png';
- $this->basePath = "{$_SERVER['DOCUMENT_ROOT']}/../../nsfz.1.test/../nsfz-author-cache/authors/images";
- if ($get['audience'] !== '')
- {
- $this->track[] = '.';
- }
- foreach ($nsfz['captions']['audience']['default'] as $default)
- {
- if ($get['audience'] !== $default)
- {
- continue;
- }
- $this->track[] = $default;
- }
- $this->track[] = 'vods';
- }
- public function output()
- {
- foreach ($this->track as $folder)
- {
- $check = $this->basePath . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $this->avatar;
- if (is_file($check))
- {
- header('HTTP/1.1 200 OK');
- header('Content-Type: image/png');
- readfile($check);
- exit;
- }
- }
- // Fallback to "Various.png" in tracked folders
- foreach ($this->track as $folder)
- {
- $fallback = $this->basePath . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . 'Various.png';
- if (is_file($fallback))
- {
- header('HTTP/1.1 200 OK');
- header('Content-Type: image/png');
- readfile($fallback);
- exit;
- }
- }
- // Final fallback to root-level Various.png
- $fallback = $this->basePath . DIRECTORY_SEPARATOR . 'Various.png';
- if (is_file($fallback))
- {
- header('Content-Type: image/png');
- readfile($fallback);
- exit;
- }
- // Still not found
- http_response_code(404);
- header('Content-Type: text/plain');
- echo "Avatar not found: {$this->avatar} or fallback.";
- exit;
- }
- }
- $finder = new AvatarCollisionFinderClass($get, $nsfz);
- $finder->output();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement