diff --git a/api/pexels.php b/api/pexels.php
new file mode 100644
index 0000000..c39da51
--- /dev/null
+++ b/api/pexels.php
@@ -0,0 +1,71 @@
+ 'Failed to fetch videos for query: ' . $query, 'videos' => []]);
+ exit;
+}
+
+$videos = [];
+foreach ($data['videos'] as $video) {
+ $video_file = null;
+ // Find a suitable video file link
+ foreach ($video['video_files'] as $file) {
+ if ($file['quality'] === 'hd' && (strpos($file['link'], '.mp4') !== false)) {
+ $video_file = $file;
+ break;
+ }
+ }
+ // Fallback to any mp4 file
+ if (!$video_file) {
+ foreach ($video['video_files'] as $file) {
+ if (strpos($file['link'], '.mp4') !== false) {
+ $video_file = $file;
+ break;
+ }
+ }
+ }
+
+ if ($video_file) {
+ $videos[] = [
+ 'id' => $video['id'],
+ 'thumbnail' => $video['image'],
+ 'download_url' => $video_file['link'],
+ 'photographer' => $video['user']['name'] ?? 'Unknown',
+ 'photographer_url' => $video['user']['url'] ?? '',
+ ];
+ }
+}
+
+// Second-level filtering for haram terms in video tags, if available
+$filtered_videos = array_filter($videos, function($video) use ($haram_elements) {
+ if (isset($video['tags']) && is_array($video['tags'])) {
+ foreach ($haram_elements as $haram) {
+ if (in_array($haram, $video['tags'])) {
+ return false;
+ }
+ }
+ }
+ return true;
+});
+
+echo json_encode(['videos' => array_values($filtered_videos)]);
\ No newline at end of file
diff --git a/assets/css/custom.css b/assets/css/custom.css
new file mode 100644
index 0000000..b55afcd
--- /dev/null
+++ b/assets/css/custom.css
@@ -0,0 +1,75 @@
+
+body {
+ background-color: #121212;
+ color: #FFFFFF;
+ font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
+ padding-top: 70px; /* For fixed navbar */
+}
+
+.navbar {
+ background-color: #1E1E1E !important;
+}
+
+.navbar-brand {
+ color: #E50914 !important;
+ font-weight: bold;
+}
+
+.hero {
+ padding: 6rem 0;
+ text-align: center;
+}
+
+.hero h1 {
+ font-size: 3.5rem;
+ font-weight: bold;
+}
+
+.hero p {
+ font-size: 1.25rem;
+ color: #a0a0a0;
+}
+
+.btn-primary-custom {
+ background-color: #E50914;
+ border-color: #E50914;
+ font-weight: bold;
+ padding: 0.75rem 1.5rem;
+ border-radius: 0.5rem;
+}
+
+.btn-primary-custom:hover {
+ background-color: #c40812;
+ border-color: #c40812;
+}
+
+.btn-danger-custom {
+ background-color: #6c757d;
+ border-color: #6c757d;
+ color: #fff;
+}
+
+.btn-danger-custom:hover {
+ background-color: #5a6268;
+ border-color: #545b62;
+}
+
+.feature-card {
+ background-color: #1E1E1E;
+ border: 1px solid #333333;
+ border-radius: 0.5rem;
+ padding: 2rem;
+ height: 100%;
+}
+
+.feature-icon {
+ font-size: 2.5rem;
+ color: #E50914;
+}
+
+footer {
+ background-color: #1E1E1E;
+ color: #a0a0a0;
+ padding: 2rem 0;
+ margin-top: 4rem;
+}
diff --git a/assets/js/main.js b/assets/js/main.js
new file mode 100644
index 0000000..8abf11c
--- /dev/null
+++ b/assets/js/main.js
@@ -0,0 +1,11 @@
+document.addEventListener('DOMContentLoaded', function() {
+ const ctaButton = document.querySelector('#cta-button');
+ const createSection = document.querySelector('#create');
+
+ if (ctaButton && createSection) {
+ ctaButton.addEventListener('click', function(e) {
+ e.preventDefault();
+ createSection.scrollIntoView({ behavior: 'smooth' });
+ });
+ }
+});
\ No newline at end of file
diff --git a/includes/pexels.php b/includes/pexels.php
new file mode 100644
index 0000000..5c5aae4
--- /dev/null
+++ b/includes/pexels.php
@@ -0,0 +1,25 @@
+ 0 ? $k : 'Vc99rnmOhHhJAbgGQoKLZtsaIVfkeownoQNbTj78VemUjKh08ZYRbf18';
+}
+function pexels_get($url) {
+ $ch = curl_init();
+ curl_setopt_array($ch, [
+ CURLOPT_URL => $url,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_HTTPHEADER => [ 'Authorization: '. pexels_key() ],
+ CURLOPT_TIMEOUT => 15,
+ ]);
+ $resp = curl_exec($ch);
+ $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ if ($code >= 200 && $code < 300 && $resp) return json_decode($resp, true);
+ return null;
+}
+function download_to($srcUrl, $destPath) {
+ $data = file_get_contents($srcUrl);
+ if ($data === false) return false;
+ if (!is_dir(dirname($destPath))) mkdir(dirname($destPath), 0775, true);
+ return file_put_contents($destPath, $data) !== false;
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index 7205f3d..349178a 100644
--- a/index.php
+++ b/index.php
@@ -1,150 +1,295 @@
query('SELECT id, name FROM affiliate_products ORDER BY name ASC');
+ $products = $stmt->fetchAll(PDO::FETCH_ASSOC);
+} catch (PDOException $e) {
+ error_log('Database Error: ' . $e->getMessage());
+ $products = []; // Ensure products is an array even on error
+}
+
+// Form & AI Processing
+$form_submitted = false;
+$form_success = false;
+$form_message = '';
+$generated_script = '';
+$filtered_script = '';
+$ai_error = '';
+$video_clips = [];
+
+if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ $form_submitted = true;
+ $name = htmlspecialchars($_POST['name'] ?? 'N/A');
+ $email = htmlspecialchars($_POST['email'] ?? 'N/A');
+ $topic = htmlspecialchars($_POST['topic'] ?? '');
+ $product_id = $_POST['product_id'] ?? null;
+
+ $selected_product = null;
+ if ($product_id && !empty($products)) {
+ foreach ($products as $p) {
+ if ($p['id'] == $product_id) {
+ $selected_product = $p;
+ break;
+ }
+ }
+ }
+
+ // 1. Send Email Notification
+ $email_message = "Reel Request: " . $topic;
+ if ($selected_product) {
+ $email_message .= "\nAffiliate Product: " . htmlspecialchars($selected_product['name']);
+ }
+ $to = getenv('MAIL_TO') ?: null;
+ $res = MailService::sendContactMessage($name, $email, $email_message, $to, 'New Reel Generation Request');
+
+ if (!empty($res['success'])) {
+ $form_success = true;
+ $form_message = 'Your request has been submitted! The AI is now generating your script below.';
+ } else {
+ $form_success = false;
+ $form_message = 'Sorry, there was an error sending your request. Please try again later.';
+ error_log('MailService Error: ' . ($res['error'] ?? 'Unknown'));
+ }
+
+ // 2. AI Script Generation & Filtering
+ if ($form_success && !empty($topic)) {
+ $system_prompt = 'You are an expert scriptwriter for short, high-retention social media videos. Create a script up to 60 seconds long.';
+ $user_prompt = 'Write a video script about: ' . $topic;
+
+ if ($selected_product) {
+ $user_prompt .= "\n\nIncorporate the following affiliate product naturally into the script: " . htmlspecialchars($selected_product['name']) . ".";
+ }
+
+ $generation_prompt = [
+ 'input' => [
+ ['role' => 'system', 'content' => $system_prompt],
+ ['role' => 'user', 'content' => $user_prompt],
+ ],
+ ];
+ $generation_resp = LocalAIApi::createResponse($generation_prompt);
+
+ if (!empty($generation_resp['success'])) {
+ $generated_script = LocalAIApi::extractText($generation_resp);
+
+ if (!empty($generated_script)) {
+ $filtering_prompt = [
+ 'input' => [
+ ['role' => 'system', 'content' => 'You are a content moderator. Review the following script. Remove or rewrite any parts that are not compliant. Non-compliant ("haram") content includes explicit material, alcohol, pork, gambling, violence, offensive language, and religious insensitivity. Be conservative in your filtering. Output only the clean, final script. Do not add any introductory text or commentary.'],
+ ['role' => 'user', 'content' => $generated_script],
+ ],
+ ];
+ $filtering_resp = LocalAIApi::createResponse($filtering_prompt);
+
+ if (!empty($filtering_resp['success'])) {
+ $filtered_script = LocalAIApi::extractText($filtering_resp);
+ if (empty($filtered_script)) {
+ $ai_error = 'The AI moderated the content but returned an empty script. This can happen with sensitive topics.';
+ } else {
+ // 3. AI Keyword Extraction
+ $keyword_prompt = [
+ 'input' => [
+ ['role' => 'system', 'content' => 'You are a keyword extraction specialist. From the following script, extract 3-5 relevant keywords for a stock video search. The keywords should be single words or short phrases that visually represent the scenes. Output only a comma-separated list of keywords. For example: "sunrise, coffee, laptop, city view".'],
+ ['role' => 'user', 'content' => $filtered_script],
+ ],
+ ];
+ $keyword_resp = LocalAIApi::createResponse($keyword_prompt);
+
+ if (!empty($keyword_resp['success'])) {
+ $keywords = LocalAIApi::extractText($keyword_resp);
+ if (!empty($keywords)) {
+ // 4. Fetch Video Clips
+ $api_url = 'http://' . $_SERVER['HTTP_HOST'] . '/api/pexels.php?query=' . urlencode($keywords) . '&orientation=portrait';
+ $videos_json = @file_get_contents($api_url);
+ if ($videos_json) {
+ $videos_data = json_decode($videos_json, true);
+ if (!empty($videos_data['videos'])) {
+ $video_clips = $videos_data['videos'];
+ }
+ }
+ }
+ }
+ }
+ } else {
+ $ai_error = 'The AI failed to moderate the script. Error: ' . ($filtering_resp['error'] ?? 'Unknown');
+ error_log('AI Filtering Error: ' . ($filtering_resp['error'] ?? 'Unknown'));
+ }
+ } else {
+ $ai_error = 'The AI generated an empty script. Please try a different topic.';
+ }
+ } else {
+ $ai_error = 'The AI failed to generate a script. Error: ' . ($generation_resp['error'] ?? 'Unknown');
+ error_log('AI Generation Error: ' . ($generation_resp['error'] ?? 'Unknown'));
+ }
+ }
+}
?>
-
+
-
-
- New Style
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ AI Reel Generator
+
+
+
-
-
-
-
Analyzing your requirements and generating your website…
-
- Loading…
-
-
= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : 'Flatlogic' ?> AI is collecting your requirements and applying the first changes.
-
This page will update automatically as the plan is implemented.
-
Runtime: PHP = htmlspecialchars($phpVersion) ?> — UTC = htmlspecialchars($now) ?>
-
-
-
+
+
+
+
+
+
+ AI-Powered Reels. Pure Content.
+ Generate high-retention video scripts, automatically filtered for brand safety. Focus on your message, we'll handle the rest.
+ Start Creating
+
+
+
+
+
+
+
+
+
AI Generation
+
From a simple idea to a full video script in seconds. Our AI crafts engaging content tailored for short-form video.
+
+
+
+
+
+
+
+
Haram-Free Content
+
Automatic, conservative filtering removes non-compliant elements, ensuring your content is always safe for your audience.
+
+
+
+
+
+
+
+
Affiliate Integration
+
Easily attach affiliate products to your content and track performance with our simple, built-in tools.
+
+
+
+
+
+
+
+ Generate Your Script
+
+
+
+
+
+
+
+
+
+
+
+
Your AI-Generated Script
+
+
+ AI Error:
+
+
+
+
+
+
+
+
+
Suggested Halal Video Clips
+
Based on your script, here are some pre-filtered, royalty-free video clips you can download and use.
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/products.php b/products.php
new file mode 100644
index 0000000..52cdd5b
--- /dev/null
+++ b/products.php
@@ -0,0 +1,163 @@
+exec("CREATE TABLE IF NOT EXISTS `affiliate_products` (
+ `id` INT AUTO_INCREMENT PRIMARY KEY,
+ `product_name` VARCHAR(255) NOT NULL,
+ `affiliate_link` VARCHAR(2048) NOT NULL,
+ `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+ )");
+
+ // Handle form submission for adding a new product
+ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_product'])) {
+ $product_name = trim($_POST['product_name']);
+ $affiliate_link = trim($_POST['affiliate_link']);
+
+ if (!empty($product_name) && !empty($affiliate_link) && filter_var($affiliate_link, FILTER_VALIDATE_URL)) {
+ $stmt = $pdo->prepare("INSERT INTO affiliate_products (product_name, affiliate_link) VALUES (?, ?)");
+ $stmt->execute([$product_name, $affiliate_link]);
+ header("Location: products.php?status=success");
+ exit;
+ } else {
+ $error = "Invalid input. Please provide a valid product name and URL.";
+ }
+ }
+
+ // Handle deletion
+ if (isset($_GET['action']) && $_GET['action'] === 'delete' && isset($_GET['id'])) {
+ $id = filter_var($_GET['id'], FILTER_VALIDATE_INT);
+ if ($id) {
+ $stmt = $pdo->prepare("DELETE FROM affiliate_products WHERE id = ?");
+ $stmt->execute([$id]);
+ header("Location: products.php?status=deleted");
+ exit;
+ }
+ }
+
+ // Fetch all products
+ $products = $pdo->query("SELECT * FROM affiliate_products ORDER BY created_at DESC")->fetchAll(PDO::FETCH_ASSOC);
+
+} catch (PDOException $e) {
+ $error = "Database error: " . $e->getMessage();
+ $products = [];
+}
+?>
+
+
+
+
+
+ Affiliate Product Management
+
+
+
+
+
+
+
+
+
+
+
+
Affiliate Product Management
+
+
+
+
+
+
Product added successfully!
+
+
+
Product deleted.
+
+
+
+
+
+
+
+
+
Existing Products
+
+
+
+
+ | Product Name |
+ Affiliate Link |
+ Actions |
+
+
+
+
+
+ | No products found. |
+
+
+
+
+ |
+ |
+
+
+ Delete
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file