38751-vm/app/Controllers/ApkController.php
Flatlogic Bot a887a75aed Aslam
2026-02-24 22:20:46 +00:00

39 lines
1.1 KiB
PHP

<?php
namespace App\Controllers;
use App\Core\Controller;
use App\Services\ApkService;
class ApkController extends Controller {
protected $apkService;
public function __construct() {
$this->apkService = new ApkService();
}
public function detail($params) {
$apk = $this->apkService->getBySlug($params['slug']);
if (!$apk) {
header("HTTP/1.0 404 Not Found");
echo "APK Not Found";
return;
}
return $this->view('apk_detail', [
'apk' => $apk,
'title' => $apk['title'] . ' v' . $apk['version'] . ' APK Download'
]);
}
public function download($params) {
$apk = $this->apkService->getBySlug($params['slug']);
if ($apk) {
$this->apkService->incrementDownload($apk['id']);
// In a real app, this would be a link to a file or a CDN.
// For now, let's redirect to a mock download URL or back.
$this->redirect($apk['download_url'] === '#' ? '/apk/' . $apk['slug'] . '?downloaded=1' : $apk['download_url']);
}
}
}