Perbaiki .gitignore agar log dan file sensitif tidak ikut commit

This commit is contained in:
WD - Dev
2025-10-18 16:05:45 +07:00
parent eb13c69431
commit 6017dfd369
27 changed files with 89223 additions and 280 deletions
+75
View File
@@ -0,0 +1,75 @@
<?php
require __DIR__ . "/../config/connect.php";
require __DIR__ . "/../config/encrypt.php";
header('Content-Type: application/json');
$id = $_GET['id'] ?? null;
if (!$id) {
echo json_encode(['error' => 'Parameter kosong']);
exit;
}
// Dekripsi dan parsing
$datadecrypt = decrypt_url($id);
$dataurl = json_decode($datadecrypt, true);
$ids = $dataurl[0] ?? null; // hasilnya: "2,3,4,7"
$filter = $dataurl[1] ?? null; // hasilnya: "informasi"
if (!$ids) {
echo json_encode(['error' => 'Parameter tidak boleh kosong']);
exit;
}
// Ubah string ID jadi array angka
$idArray = array_map('intval', explode(',', $ids));
// Buat placeholder dinamis
$placeholders = implode(',', array_fill(0, count($idArray), '?'));
// Query database
$sql = "SELECT * FROM whatsapp_cloud_api WHERE id_data_server IN ($placeholders) LIMIT 1";
$stmt3 = $pdo->prepare($sql);
$stmt3->execute($idArray);
$wacapi = $stmt3->fetch(PDO::FETCH_ASSOC);
if (!$wacapi) {
echo json_encode(['error' => 'Data API WhatsApp Cloud tidak ditemukan.']);
exit;
}
// Ambil token dan ID
$accessToken = $wacapi['token_access'];
$phoneNumberId = $wacapi['waba_id'];
// Panggil API WhatsApp
$url = "https://graph.facebook.com/v17.0/$phoneNumberId/message_templates";
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => ["Authorization: Bearer $accessToken"],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15
]);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo json_encode(['error' => curl_error($ch)]);
exit;
}
curl_close($ch);
// Decode hasil API
$data = json_decode($response, true);
if (!isset($data['data'])) {
echo json_encode(['error' => 'Tidak ada data template ditemukan.']);
exit;
}
// Filter hanya template dengan awalan "informasi_"
$templates = array_values(array_filter($data['data'], function ($tpl) {
return isset($tpl['name']) && strpos($tpl['name'], 'informasi_') === 0;
}));
// Kirim hasil JSON ke fetch
echo json_encode(['templates' => $templates], JSON_UNESCAPED_UNICODE);
+33
View File
@@ -0,0 +1,33 @@
<?php
header("Content-Type: application/json");
// direktori upload
$uploadDir = __DIR__ . "/../img/pesan/";
if (!file_exists($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
if (!isset($_FILES['file'])) {
echo json_encode(["status" => "error", "message" => "No file uploaded"]);
exit;
}
$file = $_FILES['file'];
$ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
$allowed = ['jpg', 'jpeg', 'png', 'gif'];
if (!in_array($ext, $allowed)) {
echo json_encode(["status" => "error", "message" => "Invalid file type"]);
exit;
}
$newName = uniqid("img_") . "." . $ext;
$target = $uploadDir . $newName;
if (move_uploaded_file($file['tmp_name'], $target)) {
$url = "https://manjapro.net/img/pesan/" . $newName;
echo json_encode(["status" => "success", "url" => $url]);
} else {
echo json_encode(["status" => "error", "message" => "Failed to move file"]);
}
?>