[]])); $d = json_decode(file_get_contents(RESELLERS_FILE), true); return $d['resellers'] ?? []; } function saveResellers($r) { file_put_contents(RESELLERS_FILE, json_encode(['resellers' => array_values($r)], JSON_PRETTY_PRINT)); } function getLogo($user) { if ($user == 'admin') { foreach (['png','jpg','jpeg','webp'] as $e) { if(file_exists("assets/img/logo.{$e}")) { return "assets/img/logo.{$e}"; } } return null; } foreach (['png','jpg','jpeg','webp'] as $e) { if(file_exists("assets/img/resellers/{$user}.{$e}")) { return "assets/img/resellers/{$user}.{$e}"; } } return null; } function checkExpiration($user) { $resellers = getResellers(); foreach ($resellers as $r) { if ($r['user'] == $user && isset($r['expires'])) { $expires = strtotime($r['expires']); $now = time(); $daysLeft = floor(($expires - $now) / 86400); return ['expires' => $r['expires'], 'days' => $daysLeft, 'expired' => $daysLeft < 0]; } } return null; } // ========== GERADOR DE BANNER ========== function generateBanner($style, $type, $id, $mode, $overview, $size, $user) { $details = getDetails($type, $id); if (!$details) return false; $title = $details['title'] ?? $details['name'] ?? 'Sem Título'; $ov = $overview ?: ($details['overview'] ?? 'Sinopse não disponível'); $poster = $details['poster_path']; $backdrop = $details['backdrop_path']; $rating = number_format($details['vote_average'] ?? 0, 1); $year = date('Y', strtotime($details['release_date'] ?? $details['first_air_date'] ?? 'now')); $s = ['vertical'=>['w'=>1080,'h'=>1350], 'horizontal'=>['w'=>1280,'h'=>720], 'square'=>['w'=>1080,'h'=>1080]]; $sz = $s[$size] ?? $s['vertical']; $w = $sz['w']; $h = $sz['h']; $url = ($mode == 'horizontal') ? ($backdrop ? "https://image.tmdb.org/t/p/original$backdrop" : "https://image.tmdb.org/t/p/original$poster") : ($poster ? "https://image.tmdb.org/t/p/original$poster" : "https://image.tmdb.org/t/p/original$backdrop"); $img = imagecreatetruecolor($w, $h); $bg = imagecolorallocate($img, 15, 18, 28); imagefilledrectangle($img, 0, 0, $w, $h, $bg); $data = @file_get_contents($url, false, stream_context_create(['ssl'=>['verify_peer'=>false]])); if ($data) { $base = @imagecreatefromstring($data); if ($base) { $sw = imagesx($base); $sh = imagesy($base); $r = max($w/$sw, $h/$sh); $nw = (int)($sw*$r); $nh = (int)($sh*$r); imagecopyresampled($img, $base, (int)(($w-$nw)/2), ($mode=='vertical'?0:(int)(($h-$nh)/2)), 0, 0, $nw, $nh, $sw, $sh); imagedestroy($base); } } $lp = getLogo($user); if ($lp) { $ld = @file_get_contents($lp); if ($ld) { $l = @imagecreatefromstring($ld); if ($l) { imagealphablending($l, true); imagesavealpha($l, true); $lw = imagesx($l); $lh = imagesy($l); $lr = min(($w*0.3)/$lw, ($h*0.3)/$lh); imagecopyresampled($img, $l, 40, 40, 0, 0, (int)($lw*$lr), (int)($lh*$lr), $lw, $lh); imagedestroy($l); } } } $branco = imagecolorallocate($img, 255, 255, 255); $dourado = imagecolorallocate($img, 241, 196, 15); $ft = imagecolorallocatealpha($img, 0, 0, 0, 90); // Verifica se as fontes existem $f_bold = __DIR__ . '/assets/fonts/Roboto-Bold.ttf'; $f_reg = __DIR__ . '/assets/fonts/Roboto-Regular.ttf'; // Se não existir, baixa as fontes if (!file_exists($f_bold) || !file_exists($f_reg)) { $fontUrl = 'https://github.com/google/fonts/raw/main/apache/roboto/Roboto-Regular.ttf'; $fontBoldUrl = 'https://github.com/google/fonts/raw/main/apache/roboto/Roboto-Bold.ttf'; @file_put_contents($f_reg, file_get_contents($fontUrl)); @file_put_contents($f_bold, file_get_contents($fontBoldUrl)); } if (file_exists($f_bold) && file_exists($f_reg)) { // Fundo semi-transparente para o texto imagefilledroundedrectangle($img, 50, $h-450, $w-50, $h-50, 25, $ft); // Título $titleText = mb_strtoupper($title, 'UTF-8'); $fontSize = 45; $bbox = imagettfbbox($fontSize, 0, $f_bold, $titleText); $textWidth = $bbox[2] - $bbox[0]; if ($textWidth > ($w - 180)) { $fontSize = floor($fontSize * (($w - 180) / $textWidth)); } imagettftext($img, $fontSize, 0, 90, $h-350, $branco, $f_bold, $titleText); // Ano e nota imagettftext($img, 22, 0, 90, $h-300, $dourado, $f_reg, "★ $rating | $year"); // Sinopse - CORRIGIDO $sinopse = strip_tags($ov); $sinopse = trim(preg_replace('/\s+/', ' ', $sinopse)); $words = explode(' ', $sinopse); $lines = []; $currentLine = ''; $maxWidth = $w - 180; // Quebra a sinopse em linhas que cabem no banner foreach ($words as $word) { $testLine = $currentLine ? $currentLine . ' ' . $word : $word; $bbox = imagettfbbox(20, 0, $f_reg, $testLine); $lineWidth = $bbox[2] - $bbox[0]; if ($lineWidth <= $maxWidth) { $currentLine = $testLine; } else { if ($currentLine) $lines[] = $currentLine; $currentLine = $word; } } if ($currentLine) $lines[] = $currentLine; // Limita a 3 linhas $lines = array_slice($lines, 0, 3); if (count($lines) == 3 && str_word_count($sinopse) > 20) { $lines[2] = rtrim($lines[2]) . '...'; } // Desenha cada linha $yPos = $h-250; foreach ($lines as $line) { imagettftext($img, 20, 0, 90, $yPos, $branco, $f_reg, $line); $yPos += 30; } } // Salva na pasta correta $d = ($user == 'admin') ? "banners" : "resellers_banners/$user"; if (!is_dir($d)) mkdir($d, 0777, true); $n = "$d/".time().".jpg"; imagejpeg($img, $n, 90); imagedestroy($img); return $n; } // ========== LÓGICA ========== $p = $_GET['page'] ?? 'home'; $a = $_GET['action'] ?? ''; $is_admin = isset($_SESSION['admin_logged']); $is_reseller = isset($_SESSION['reseller_logged']); $u = $_SESSION['reseller_user'] ?? null; // Verifica expiração para revendas $expiration = null; if ($is_reseller && $u) { $expiration = checkExpiration($u); if ($expiration && $expiration['expired']) { // Revenda expirada - faz logout session_destroy(); header('Location: ?page=login&expired=1'); exit; } } if ($a == 'login') { $user = $_POST['user'] ?? ''; $pass = $_POST['pass'] ?? ''; if ($user == ADMIN_USER && $pass == ADMIN_PASS) { $_SESSION['admin_logged'] = true; $_SESSION['reseller_user'] = 'admin'; header('Location: ?page=home'); exit; } else { foreach (getResellers() as $r) { if ($r['user'] == $user && $r['pass'] == $pass) { // Verifica se não está expirado $exp = checkExpiration($user); if ($exp && $exp['expired']) { header('Location: ?page=login&expired=1'); exit; } $_SESSION['reseller_logged'] = true; $_SESSION['reseller_user'] = $user; header('Location: ?page=home'); exit; } } } } if ($a == 'logout') { session_destroy(); header('Location: ?page=home'); exit; } if ($a == 'uploadLogo' && ($is_admin || $is_reseller)) { if (isset($_FILES['logo']) && $_FILES['logo']['error'] == 0) { $ext = strtolower(pathinfo($_FILES['logo']['name'], PATHINFO_EXTENSION)); if ($u == 'admin') { foreach(['png','jpg','jpeg','webp'] as $e) @unlink("assets/img/logo.{$e}"); $path = "assets/img/logo.{$ext}"; } else { foreach(['png','jpg','jpeg','webp'] as $e) @unlink("assets/img/resellers/{$u}.{$e}"); $path = "assets/img/resellers/{$u}.{$ext}"; } move_uploaded_file($_FILES['logo']['tmp_name'], $path); } header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } if ($a == 'addReseller' && $is_admin) { $r = getResellers(); $r[] = [ 'user'=>$_POST['user'], 'pass'=>$_POST['pass'], 'name'=>$_POST['name'], 'expires'=>$_POST['expires'] ]; saveResellers($r); header('Location: ?page=admin'); exit; } if ($a == 'updateReseller' && $is_admin) { $r = getResellers(); $id = $_GET['id']; if (isset($r[$id])) { $r[$id]['expires'] = $_POST['expires']; saveResellers($r); } header('Location: ?page=admin'); exit; } if ($a == 'delReseller' && $is_admin) { $r = getResellers(); if (isset($r[$_GET['id']])) { $user = $r[$_GET['id']]['user']; $dir = "resellers_banners/$user"; if (is_dir($dir)) { array_map('unlink', glob("$dir/*.jpg")); rmdir($dir); } foreach(['png','jpg','jpeg','webp'] as $e) @unlink("assets/img/resellers/{$user}.{$e}"); } unset($r[$_GET['id']]); saveResellers($r); header('Location: ?page=admin'); exit; } if ($a == 'generate' && ($is_admin || $is_reseller)) { $file = generateBanner($_GET['style'], $_GET['type'], $_GET['id'], $_GET['mode'], $_POST['overview'], $_GET['size'], $u); echo json_encode(['success'=>!!$file, 'file'=>$file]); exit; } if ($a == 'delBanner' && ($is_admin || $is_reseller)) { $f = $_GET['file']; $allowed = false; if ($u == 'admin' && strpos($f, 'banners/') === 0) { $allowed = true; } else if ($u != 'admin' && strpos($f, "resellers_banners/$u/") === 0) { $allowed = true; } if ($allowed) @unlink($f); header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } if ($a == 'deleteAllBanners' && ($is_admin || $is_reseller)) { $d = ($u == 'admin') ? "banners" : "resellers_banners/$u"; if (is_dir($d)) { $files = glob("$d/*.jpg"); foreach ($files as $f) @unlink($f); } header('Location: ?page=galeria'); exit; } $logo = null; if ($is_admin || $is_reseller) { $logo = getLogo($u); } ?> GERADOR VODS
Sua conta expirou!

Entre em contato com o administrador para renovar.

Login para gerar

Gerenciar Revendas

$r): $bannerCount = count(glob("resellers_banners/{$r['user']}/*.jpg")); $exp = checkExpiration($r['user']); $status = ''; $statusClass = ''; if ($exp) { if ($exp['expired']) { $status = 'Expirado'; $statusClass = 'expired-badge'; } elseif ($exp['days'] <= 5) { $status = $exp['days'] . ' dias'; $statusClass = 'warning-badge'; } else { $status = $exp['days'] . ' dias'; $statusClass = ''; } } else { $status = 'Sem data'; $statusClass = ''; } ?>
Nome Usuário Senha Logo Banners Vencimento Status Ações
Sem logo

Meus Banners Gerados

Novo Banner

Você ainda não gerou nenhum banner.

Gerar Banner

Minha Logo Personalizada

Esta logo aparecerá em todos os seus banners.

Você ainda não tem uma logo configurada.

Sua logo aparecerá em todos os banners que você gerar.

Formatos suportados: PNG, JPG, JPEG, WEBP

Acesso ao Sistema

Sua conta expirou!