mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
actor fetching :)
Stash / ADultVideoAPI
This commit is contained in:
213
public/index.php
213
public/index.php
@@ -57,7 +57,7 @@ $container->set('view', function () use ($container) {
|
||||
$_SERVER['HTTP_HOST'] ?? 'localhost'
|
||||
);
|
||||
}));
|
||||
|
||||
|
||||
// Add media visibility function
|
||||
$twig->getEnvironment()->addFunction(new TwigFunction('is_media_type_visible', function ($mediaType) {
|
||||
return is_media_type_visible($mediaType);
|
||||
@@ -71,9 +71,6 @@ $container->set('view', function () use ($container) {
|
||||
// Handle common route patterns
|
||||
switch ($name) {
|
||||
case 'home':
|
||||
$basePath = '/';
|
||||
break;
|
||||
case 'dashboard.index':
|
||||
$basePath = '/';
|
||||
break;
|
||||
case 'games.index':
|
||||
@@ -164,8 +161,192 @@ $container->set('view', function () use ($container) {
|
||||
return $authService->generateCSRFToken();
|
||||
}));
|
||||
|
||||
$twig->getEnvironment()->addFunction(new TwigFunction('country_flag', function ($countryName) {
|
||||
if (!$countryName) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Country name to ISO 3166-1 alpha-2 code mapping (most common countries)
|
||||
$countryMap = [
|
||||
'United States' => 'us',
|
||||
'USA' => 'us',
|
||||
'America' => 'us',
|
||||
'United Kingdom' => 'gb',
|
||||
'UK' => 'gb',
|
||||
'Britain' => 'gb',
|
||||
'England' => 'gb',
|
||||
'Germany' => 'de',
|
||||
'France' => 'fr',
|
||||
'Italy' => 'it',
|
||||
'Spain' => 'es',
|
||||
'Canada' => 'ca',
|
||||
'Australia' => 'au',
|
||||
'Japan' => 'jp',
|
||||
'China' => 'cn',
|
||||
'India' => 'in',
|
||||
'Brazil' => 'br',
|
||||
'Mexico' => 'mx',
|
||||
'Russia' => 'ru',
|
||||
'South Korea' => 'kr',
|
||||
'Netherlands' => 'nl',
|
||||
'Sweden' => 'se',
|
||||
'Norway' => 'no',
|
||||
'Denmark' => 'dk',
|
||||
'Finland' => 'fi',
|
||||
'Poland' => 'pl',
|
||||
'Czech Republic' => 'cz',
|
||||
'Hungary' => 'hu',
|
||||
'Romania' => 'ro',
|
||||
'Bulgaria' => 'bg',
|
||||
'Greece' => 'gr',
|
||||
'Portugal' => 'pt',
|
||||
'Belgium' => 'be',
|
||||
'Austria' => 'at',
|
||||
'Switzerland' => 'ch',
|
||||
'Ireland' => 'ie',
|
||||
'New Zealand' => 'nz',
|
||||
'South Africa' => 'za',
|
||||
'Argentina' => 'ar',
|
||||
'Chile' => 'cl',
|
||||
'Colombia' => 'co',
|
||||
'Peru' => 'pe',
|
||||
'Venezuela' => 've',
|
||||
'Ecuador' => 'ec',
|
||||
'Uruguay' => 'uy',
|
||||
'Paraguay' => 'py',
|
||||
'Bolivia' => 'bo',
|
||||
'Thailand' => 'th',
|
||||
'Vietnam' => 'vn',
|
||||
'Philippines' => 'ph',
|
||||
'Indonesia' => 'id',
|
||||
'Malaysia' => 'my',
|
||||
'Singapore' => 'sg',
|
||||
'Turkey' => 'tr',
|
||||
'Israel' => 'il',
|
||||
'Egypt' => 'eg',
|
||||
'Morocco' => 'ma',
|
||||
'Tunisia' => 'tn',
|
||||
'Algeria' => 'dz',
|
||||
'Saudi Arabia' => 'sa',
|
||||
'UAE' => 'ae',
|
||||
'United Arab Emirates' => 'ae',
|
||||
'Qatar' => 'qa',
|
||||
'Kuwait' => 'kw',
|
||||
'Bahrain' => 'bh',
|
||||
'Oman' => 'om',
|
||||
'Jordan' => 'jo',
|
||||
'Lebanon' => 'lb',
|
||||
'Syria' => 'sy',
|
||||
'Iraq' => 'iq',
|
||||
'Iran' => 'ir',
|
||||
'Pakistan' => 'pk',
|
||||
'Bangladesh' => 'bd',
|
||||
'Sri Lanka' => 'lk',
|
||||
'Nepal' => 'np',
|
||||
'Bhutan' => 'bt',
|
||||
'Maldives' => 'mv',
|
||||
'Afghanistan' => 'af',
|
||||
'Kazakhstan' => 'kz',
|
||||
'Uzbekistan' => 'uz',
|
||||
'Turkmenistan' => 'tm',
|
||||
'Kyrgyzstan' => 'kg',
|
||||
'Tajikistan' => 'tj',
|
||||
'Mongolia' => 'mn',
|
||||
'North Korea' => 'kp',
|
||||
'Taiwan' => 'tw',
|
||||
'Hong Kong' => 'hk',
|
||||
'Macau' => 'mo',
|
||||
'South Korea' => 'kr',
|
||||
'Cambodia' => 'kh',
|
||||
'Laos' => 'la',
|
||||
'Myanmar' => 'mm',
|
||||
'Brunei' => 'bn',
|
||||
'East Timor' => 'tl',
|
||||
'Papua New Guinea' => 'pg',
|
||||
'Fiji' => 'fj',
|
||||
'Solomon Islands' => 'sb',
|
||||
'Vanuatu' => 'vu',
|
||||
'Samoa' => 'ws',
|
||||
'Tonga' => 'to',
|
||||
'Tuvalu' => 'tv',
|
||||
'Kiribati' => 'ki',
|
||||
'Marshall Islands' => 'mh',
|
||||
'Micronesia' => 'fm',
|
||||
'Palau' => 'pw',
|
||||
'Nauru' => 'nr',
|
||||
'Cuba' => 'cu',
|
||||
'Jamaica' => 'jm',
|
||||
'Haiti' => 'ht',
|
||||
'Dominican Republic' => 'do',
|
||||
'Puerto Rico' => 'pr',
|
||||
'Bahamas' => 'bs',
|
||||
'Trinidad and Tobago' => 'tt',
|
||||
'Barbados' => 'bb',
|
||||
'Saint Lucia' => 'lc',
|
||||
'Saint Vincent and the Grenadines' => 'vc',
|
||||
'Grenada' => 'gd',
|
||||
'Antigua and Barbuda' => 'ag',
|
||||
'Saint Kitts and Nevis' => 'kn',
|
||||
'Dominica' => 'dm',
|
||||
'Saint Martin' => 'mf',
|
||||
'Guadeloupe' => 'gp',
|
||||
'Martinique' => 'mq',
|
||||
'French Guiana' => 'gf',
|
||||
'Suriname' => 'sr',
|
||||
'Guyana' => 'gy',
|
||||
'Belize' => 'bz',
|
||||
'Costa Rica' => 'cr',
|
||||
'Panama' => 'pa',
|
||||
'Nicaragua' => 'ni',
|
||||
'Honduras' => 'hn',
|
||||
'El Salvador' => 'sv',
|
||||
'Guatemala' => 'gt',
|
||||
'Greenland' => 'gl',
|
||||
'Iceland' => 'is',
|
||||
'Faroe Islands' => 'fo',
|
||||
'Åland Islands' => 'ax',
|
||||
'Guernsey' => 'gg',
|
||||
'Jersey' => 'je',
|
||||
'Isle of Man' => 'im',
|
||||
'Gibraltar' => 'gi',
|
||||
'Malta' => 'mt',
|
||||
'Cyprus' => 'cy',
|
||||
'Luxembourg' => 'lu',
|
||||
'Monaco' => 'mc',
|
||||
'Andorra' => 'ad',
|
||||
'San Marino' => 'sm',
|
||||
'Vatican City' => 'va',
|
||||
'Liechtenstein' => 'li',
|
||||
'Slovenia' => 'si',
|
||||
'Croatia' => 'hr',
|
||||
'Bosnia and Herzegovina' => 'ba',
|
||||
'Serbia' => 'rs',
|
||||
'Montenegro' => 'me',
|
||||
'Kosovo' => 'xk',
|
||||
'North Macedonia' => 'mk',
|
||||
'Albania' => 'al',
|
||||
'Moldova' => 'md',
|
||||
'Ukraine' => 'ua',
|
||||
'Belarus' => 'by',
|
||||
'Lithuania' => 'lt',
|
||||
'Latvia' => 'lv',
|
||||
'Estonia' => 'ee',
|
||||
'Slovakia' => 'sk',
|
||||
'Armenia' => 'am',
|
||||
'Azerbaijan' => 'az',
|
||||
'Georgia' => 'ge',
|
||||
];
|
||||
|
||||
$countryCode = strtolower($countryMap[$countryName] ?? '');
|
||||
|
||||
if ($countryCode) {
|
||||
// Return Iconify flag icon HTML
|
||||
return '<span class="iconify" data-icon="flag:' . $countryCode . '-4x3" data-inline="false" style="width: 20px; height: 15px; display: inline-block;"></span>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}));
|
||||
|
||||
|
||||
$twig->getEnvironment()->addFilter(new TwigFilter('format_duration', function ($minutes) {
|
||||
if (!$minutes || $minutes == 0) {
|
||||
return '0m';
|
||||
@@ -309,56 +490,56 @@ $app->add(TwigMiddleware::create($app, $twig));
|
||||
// PHP DebugBar Setup (only in development)
|
||||
if ($_ENV['APP_DEBUG'] === 'true') {
|
||||
$debugbar = new \DebugBar\StandardDebugBar();
|
||||
|
||||
|
||||
// Set up the debug bar renderer with the correct base URL
|
||||
$baseUrl = rtrim($app->getBasePath(), '/');
|
||||
$debugbarRenderer = $debugbar->getJavascriptRenderer($baseUrl . '/phpdebugbar');
|
||||
|
||||
|
||||
// Add DebugBar to Twig globals
|
||||
$twig->getEnvironment()->addGlobal('debugbarRenderer', $debugbarRenderer);
|
||||
|
||||
|
||||
// Add route to serve DebugBar assets
|
||||
$app->get('/phpdebugbar/{path:.*}', function ($request, $response, $args) use ($debugbar) {
|
||||
$debugbarRenderer = $debugbar->getJavascriptRenderer();
|
||||
$path = $args['path'];
|
||||
|
||||
|
||||
// Serve CSS files
|
||||
if (preg_match('/\.css$/', $path)) {
|
||||
$content = file_get_contents($debugbarRenderer->getBasePath() . '/' . $path);
|
||||
$response->getBody()->write($content);
|
||||
return $response->withHeader('Content-Type', 'text/css');
|
||||
}
|
||||
|
||||
|
||||
// Serve JS files
|
||||
if (preg_match('/\.js$/', $path)) {
|
||||
$content = file_get_contents($debugbarRenderer->getBasePath() . '/' . $path);
|
||||
$response->getBody()->write($content);
|
||||
return $response->withHeader('Content-Type', 'application/javascript');
|
||||
}
|
||||
|
||||
|
||||
// Serve other assets (fonts, etc.)
|
||||
$content = @file_get_contents($debugbarRenderer->getBasePath() . '/' . $path);
|
||||
if ($content !== false) {
|
||||
$response->getBody()->write($content);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
return $response->withStatus(404);
|
||||
});
|
||||
|
||||
|
||||
// Add middleware to collect data
|
||||
$app->add(function ($request, $handler) use ($debugbar) {
|
||||
// Start timing the request
|
||||
$debugbar['time']->startMeasure('app', 'Application');
|
||||
|
||||
|
||||
try {
|
||||
$response = $handler->handle($request);
|
||||
|
||||
|
||||
// Stop timing if it was started
|
||||
if ($debugbar['time']->hasStartedMeasure('app')) {
|
||||
$debugbar['time']->stopMeasure('app');
|
||||
}
|
||||
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
// Make sure to stop timing even if an exception occurs
|
||||
|
||||
Reference in New Issue
Block a user