diff --git a/app/Controllers/HomeController.php b/app/Controllers/HomeController.php index 15ec9d8..4a6e4cc 100644 --- a/app/Controllers/HomeController.php +++ b/app/Controllers/HomeController.php @@ -6,36 +6,15 @@ use App\Core\Controller; use App\Services\ApkService; class HomeController extends Controller { - protected $apkService; - - public function __construct() { - $this->apkService = new ApkService(); - } - + public function index() { - $db = db_pdo(); $category = $_GET['category'] ?? null; + $search = $_GET['search'] ?? null; - // Store global referral code if present - if (isset($_GET['ref'])) { - $_SESSION['global_ref'] = $_GET['ref']; - } - - $sql = "SELECT * FROM apks WHERE status = 'published'"; - $params = []; + $apkService = new ApkService(); + $apks = $apkService->getAllApks($category, $search); - if ($category) { - $sql .= " AND category_id = (SELECT id FROM categories WHERE slug = ?)"; - $params[] = $category; - } - - $sql .= " ORDER BY display_order ASC, created_at DESC LIMIT 12"; - - $stmt = $db->prepare($sql); - $stmt->execute($params); - $apks = $stmt->fetchAll(); - - return $this->view('home', [ + $this->view('home', [ 'apks' => $apks, 'title' => get_setting('site_name', 'ApkNusa') . __('home_title_suffix') ]); @@ -57,14 +36,9 @@ class HomeController extends Controller { $_SESSION['ref_download_' . $apk['id']] = $_GET['ref']; } - $siteName = get_setting('site_name', 'ApkNusa'); - $description = substr(strip_tags($apk['description']), 0, 150) . '...'; - $this->view('apk_detail', [ 'apk' => $apk, - 'title' => sprintf(__('apk_detail_title'), $apk['title'], $apk['version'], $siteName), - 'meta_description' => sprintf(__('apk_detail_meta_desc'), $apk['title'], $apk['version'], $description), - 'meta_keywords' => sprintf(__('apk_detail_meta_keywords'), $apk['title'], $apk['title'], $apk['title']) + 'title' => $apk['title'] . ' - ' . get_setting('site_name', 'ApkNusa') ]); } @@ -79,43 +53,49 @@ class HomeController extends Controller { $this->redirect('/'); } - // Check for referral earnings - // Try specific APK referral first, then global referral - $ref_code = $_SESSION['ref_download_' . $apk['id']] ?? ($_SESSION['global_ref'] ?? null); - - if ($ref_code) { - $stmt = $db->prepare("SELECT id FROM users WHERE referral_code = ?"); + // Increment download count + $stmt = $db->prepare("UPDATE apks SET total_downloads = total_downloads + 1 WHERE id = ?"); + $stmt->execute([$apk['id']]); + + // Referral logic + $ref_key = 'ref_download_' . $apk['id']; + if (isset($_SESSION['ref_download_' . $apk['id']])) { + $ref_code = $_SESSION['ref_download_' . $apk['id']]; + + // Find the user who owns this referral code + $stmt = $db->prepare("SELECT * FROM users WHERE referral_code = ?"); $stmt->execute([$ref_code]); $referrer = $stmt->fetch(); if ($referrer) { - $referrer_id = $referrer['id']; - $ip = $_SERVER['REMOTE_ADDR']; - - // Check if this IP already earned for this APK today (prevent abuse) - $stmt = $db->prepare("SELECT id FROM referral_downloads WHERE referrer_id = ? AND apk_id = ? AND ip_address = ? AND created_at > DATE_SUB(NOW(), INTERVAL 1 DAY)"); - $stmt->execute([$referrer_id, $apk['id'], $ip]); - - if (!$stmt->fetch()) { - // Credit 500 IDR - $stmt = $db->prepare("UPDATE users SET balance = balance + 500 WHERE id = ?"); - $stmt->execute([$referrer_id]); - - // Log download - $stmt = $db->prepare("INSERT INTO referral_downloads (referrer_id, apk_id, ip_address, amount) VALUES (?, ?, ?, 500)"); - $stmt->execute([$referrer_id, $apk['id'], $ip]); - } + // Award points/money to referrer + // For example, 100 rupiah per download + $stmt = $db->prepare("UPDATE users SET balance = balance + 100 WHERE id = ?"); + $stmt->execute([$referrer['id']]); } - // Clear session specific to this APK, but maybe keep global_ref? - // The user might download other APKs too. - unset($_SESSION['ref_download_' . $apk['id']]); + + unset($_SESSION[$ref_key]); } - // Increment total downloads - $stmt = $db->prepare("UPDATE apks SET total_downloads = total_downloads + 1 WHERE id = ?"); - $stmt->execute([$apk['id']]); + header('Location: ' . $apk['download_url']); + exit; + } - // Redirect to actual file - $this->redirect($apk['download_url']); + public function helpCenter() { + $this->view('help_center', [ + 'title' => __('help_center') . ' - ' . get_setting('site_name', 'ApkNusa') + ]); + } + + public function privacyPolicy() { + $this->view('privacy_policy', [ + 'title' => __('privacy_policy') . ' - ' . get_setting('site_name', 'ApkNusa') + ]); + } + + public function termsOfService() { + $this->view('terms_of_service', [ + 'title' => __('terms_of_service') . ' - ' . get_setting('site_name', 'ApkNusa') + ]); } } \ No newline at end of file diff --git a/app/Services/ApkService.php b/app/Services/ApkService.php index a27150f..d3f9ff4 100644 --- a/app/Services/ApkService.php +++ b/app/Services/ApkService.php @@ -12,7 +12,7 @@ class ApkService { } public function getLatest($limit = 10) { - $stmt = $this->db->prepare("SELECT * FROM apks WHERE status = 'published' ORDER BY created_at DESC LIMIT :limit"); + $stmt = $this->db->prepare("SELECT * FROM apks WHERE status = 'published' ORDER BY display_order ASC, created_at DESC LIMIT :limit"); $stmt->bindValue(':limit', (int)$limit, \PDO::PARAM_INT); $stmt->execute(); return $stmt->fetchAll(); @@ -24,9 +24,30 @@ class ApkService { return $stmt->fetch(); } - public function getAllApks() { - $stmt = $this->db->prepare("SELECT * FROM apks ORDER BY created_at DESC"); - $stmt->execute(); + public function getAllApks($category_slug = null, $search = null) { + $query = "SELECT a.* FROM apks a"; + $params = []; + $where = []; + + if ($category_slug) { + $query .= " JOIN categories c ON a.category_id = c.id"; + $where[] = "c.slug = :category_slug"; + $params['category_slug'] = $category_slug; + } + + if ($search) { + $where[] = "a.title LIKE :search"; + $params['search'] = "%$search%"; + } + + if (!empty($where)) { + $query .= " WHERE " . implode(" AND ", $where); + } + + $query .= " ORDER BY a.display_order ASC, a.created_at DESC"; + + $stmt = $this->db->prepare($query); + $stmt->execute($params); return $stmt->fetchAll(); } diff --git a/assets/uploads/icons/699e34c63c00e.jpg b/assets/uploads/icons/699e34c63c00e.jpg new file mode 100644 index 0000000..472e179 Binary files /dev/null and b/assets/uploads/icons/699e34c63c00e.jpg differ diff --git a/index.php b/index.php index 3b53384..9ee36e7 100644 --- a/index.php +++ b/index.php @@ -46,6 +46,11 @@ $router->get('/', 'HomeController@index'); $router->get('/apk/:slug', 'HomeController@apkDetail'); $router->get('/download/:slug', 'HomeController@download'); +// Static Pages +$router->get('/help-center', 'HomeController@helpCenter'); +$router->get('/privacy-policy', 'HomeController@privacyPolicy'); +$router->get('/terms-of-service', 'HomeController@termsOfService'); + // Auth $router->get('/login', 'AuthController@loginForm'); $router->post('/login', 'AuthController@login'); @@ -86,4 +91,4 @@ $router->get('/admin/withdrawals', 'AdminController@withdrawals'); $router->get('/admin/withdrawals/approve/:id', 'AdminController@approveWithdrawal'); $router->get('/admin/withdrawals/reject/:id', 'AdminController@rejectWithdrawal'); -$router->dispatch(); +$router->dispatch(); \ No newline at end of file diff --git a/lang/en.php b/lang/en.php index b07ebf6..e59c771 100644 --- a/lang/en.php +++ b/lang/en.php @@ -134,4 +134,25 @@ return [ // SEO Defaults 'meta_description_default' => 'Download Professional APKs.', 'meta_keywords_default' => 'apk, android, download', + + // Help Center + 'help_center_title' => 'Help Center', + 'faq_title' => 'Frequently Asked Questions', + 'faq_q1' => 'How to download APK from our site?', + 'faq_a1' => 'Simply browse for the app you want, click on it, and then click the green "Download Now" button. Your download will start immediately.', + 'faq_q2' => 'Are the APKs safe?', + 'faq_a2' => 'Yes, all our APKs are sourced from original developers and verified to be safe and clean from any malware.', + 'faq_q3' => 'How does the referral program work?', + 'faq_a3' => 'Register for an account, copy your referral link from an APK page or your profile, and share it. You will earn Rp 500 for every unique download made through your link.', + 'contact_us' => 'Contact Us', + 'contact_text' => 'Still have questions? Our support team is here to help you.', + 'send_email' => 'Send Email', + + // Privacy Policy + 'privacy_policy_title' => 'Privacy Policy', + 'privacy_policy_content' => '
We collect information that you provide directly to us, such as when you create an account, participate in our referral program, or communicate with us.
We use the information we collect to provide, maintain, and improve our services, including processing your referral earnings and withdrawal requests.
We take reasonable measures to help protect information about you from loss, theft, misuse and unauthorized access.
', + + // Terms of Service + 'terms_of_service_title' => 'Terms of Service', + 'terms_of_service_content' => 'By accessing or using our website, you agree to be bound by these terms of service.
You agree not to use the website for any unlawful purpose or in any way that could damage, disable, or impair the website.
Abuse of the referral program, including but not limited to self-referrals or using bots, will result in account suspension and forfeiture of earnings.
', ]; \ No newline at end of file diff --git a/lang/id.php b/lang/id.php index 5b1e119..71d7b69 100644 --- a/lang/id.php +++ b/lang/id.php @@ -134,4 +134,25 @@ return [ // SEO Defaults 'meta_description_default' => 'Unduh APK Profesional.', 'meta_keywords_default' => 'apk, android, unduh', + + // Help Center + 'help_center_title' => 'Pusat Bantuan', + 'faq_title' => 'Pertanyaan yang Sering Diajukan', + 'faq_q1' => 'Bagaimana cara mengunduh APK dari situs kami?', + 'faq_a1' => 'Cukup cari aplikasi yang Anda inginkan, klik aplikasi tersebut, lalu klik tombol hijau "Unduh Sekarang". Unduhan Anda akan segera dimulai.', + 'faq_q2' => 'Apakah APK di sini aman?', + 'faq_a2' => 'Ya, semua APK kami bersumber dari pengembang asli dan diverifikasi aman serta bersih dari malware.', + 'faq_q3' => 'Bagaimana cara kerja program referral?', + 'faq_a3' => 'Daftar akun, salin link referral Anda dari halaman APK atau profil Anda, dan bagikan. Anda akan mendapatkan Rp 500 untuk setiap unduhan unik yang dilakukan melalui link Anda.', + 'contact_us' => 'Hubungi Kami', + 'contact_text' => 'Masih punya pertanyaan? Tim dukungan kami siap membantu Anda.', + 'send_email' => 'Kirim Email', + + // Privacy Policy + 'privacy_policy_title' => 'Kebijakan Privasi', + 'privacy_policy_content' => 'Kami mengumpulkan informasi yang Anda berikan langsung kepada kami, seperti saat Anda membuat akun, berpartisipasi dalam program referral kami, atau berkomunikasi dengan kami.
Kami menggunakan informasi yang kami kumpulkan untuk menyediakan, memelihara, dan meningkatkan layanan kami, termasuk memproses pendapatan referral dan permintaan penarikan Anda.
Kami mengambil langkah-langkah yang wajar untuk membantu melindungi informasi tentang Anda dari kehilangan, pencurian, penyalahgunaan, dan akses yang tidak sah.
', + + // Terms of Service + 'terms_of_service_title' => 'Ketentuan Layanan', + 'terms_of_service_content' => 'Dengan mengakses atau menggunakan situs web kami, Anda setuju untuk terikat oleh ketentuan layanan ini.
Anda setuju untuk tidak menggunakan situs web untuk tujuan yang melanggar hukum atau dengan cara apa pun yang dapat merusak, melumpuhkan, atau mengganggu situs web.
Penyalahgunaan program referral, termasuk namun tidak terbatas pada referral diri sendiri atau menggunakan bot, akan mengakibatkan penangguhan akun dan penghapusan pendapatan.
', ]; \ No newline at end of file diff --git a/views/admin/apks/index.php b/views/admin/apks/index.php index 8f5fe68..a5d9fdb 100644 --- a/views/admin/apks/index.php +++ b/views/admin/apks/index.php @@ -8,6 +8,11 @@ + +