From a7d74453873aee4ab60dd459bd65bc17b9259118 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Mon, 6 Apr 2026 17:25:15 +0000 Subject: [PATCH] update courses --- admin_courses.php | 83 ++++++++++++-- checkout.php | 15 +++ index.php | 16 ++- patch_admin.php | 237 ++++++++++++++++++++++++++++++++++++++++ patch_admin.py | 160 +++++++++++++++++++++++++++ patch_admin_courses.php | 31 ++++++ patch_checkout.php | 29 +++++ patch_checkout.py | 34 ++++++ patch_index.py | 29 +++++ 9 files changed, 623 insertions(+), 11 deletions(-) create mode 100644 patch_admin.php create mode 100644 patch_admin.py create mode 100644 patch_admin_courses.php create mode 100644 patch_checkout.php create mode 100644 patch_checkout.py create mode 100644 patch_index.py diff --git a/admin_courses.php b/admin_courses.php index f5a96fd..2549b01 100644 --- a/admin_courses.php +++ b/admin_courses.php @@ -16,6 +16,22 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { exit; } + if ($post_action === 'close_all_registration') { + db()->query("UPDATE courses SET registration_open = 0"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if ($post_action === 'open_all_registration') { + db()->query("UPDATE courses SET registration_open = 1"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if ($post_action === 'reset_all_students') { + db()->query("TRUNCATE TABLE course_students"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if ($post_action === 'edit' || $post_action === 'add') { $name_en = $_POST['name_en'] ?? ''; $name_ar = $_POST['name_ar'] ?? ''; @@ -23,6 +39,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $desc_ar = $_POST['description_ar'] ?? ''; $status = $_POST['status'] ?? 'active'; $price = (float)($_POST['price'] ?? 0); + $max_students = (isset($_POST['max_students']) && $_POST['max_students'] !== '') ? (int)$_POST['max_students'] : null; + $registration_open = isset($_POST['registration_open']) ? 1 : 0; $picture = null; if ($post_action === 'edit' && $post_id > 0) { @@ -44,11 +62,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } if ($post_action === 'edit' && $post_id > 0) { - $stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=? WHERE id=?"); - $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $post_id]); + $stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=?, max_students=?, registration_open=? WHERE id=?"); + $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open, $post_id]); } else { - $stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture) VALUES (?, ?, ?, ?, ?, ?, ?)"); - $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture]); + $stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture, max_students, registration_open) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"); + $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open]); } header('Location: ' . app_url('admin.php', ['page' => 'courses'])); exit; @@ -105,7 +123,21 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC);

- +
+
+ + +
+
+ + +
+
+ + +
+ +
@@ -128,9 +160,10 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC); - + + - + @@ -163,11 +196,21 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC); + + / + + + + + + + + - +
+ + +
+
@@ -276,6 +323,12 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+
+ /> + +
+
@@ -290,7 +343,7 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC); - + @@ -342,6 +395,10 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC);
+ + +
+
@@ -352,6 +409,12 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC); +
+
+ + +
+
@@ -362,4 +425,4 @@ $items = $stmt->fetchAll(PDO::FETCH_ASSOC);
- + \ No newline at end of file diff --git a/checkout.php b/checkout.php index 24c58e8..78ccd3f 100644 --- a/checkout.php +++ b/checkout.php @@ -9,6 +9,21 @@ $courseIdForView = (int) ($_GET['course_id'] ?? $_POST['course_id'] ?? 0); $course = null; if ($courseIdForView > 0) { $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch(); + if ($course) { + if (!$course['registration_open']) { + $msg = current_lang() === 'ar' ? 'التسجيل في هذه الدورة/الدفعة مغلق حالياً.' : 'Registration for this course/batch is currently closed.'; + die("

" . $msg . "

" . (current_lang() === 'ar' ? 'العودة' : 'Back') . "
"); + } + if ($course['max_students'] > 0) { + $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = $courseIdForView")->fetchColumn(); + if ($enrolled >= $course['max_students']) { + $msg = current_lang() === 'ar' ? 'لقد وصلت هذه الدورة إلى الحد الأقصى لعدد الطلاب.' : 'This course has reached its maximum capacity.'; + die("

" . $msg . "

" . (current_lang() === 'ar' ? 'العودة' : 'Back') . "
"); + } + } + } else { + die('Course not found'); + } } $errors = []; $form = [ diff --git a/index.php b/index.php index 154dcf6..f7425f8 100644 --- a/index.php +++ b/index.php @@ -96,7 +96,21 @@ $metrics = ['subjects' => count($subjects), 'teachers' => db()->query("SELECT CO

- + 0) { + $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = " . $course['id'])->fetchColumn(); + if ($enrolled >= $course['max_students']) { + $isFull = true; + } + } + if ($isClosed || $isFull): + ?> + + + +
diff --git a/patch_admin.php b/patch_admin.php new file mode 100644 index 0000000..572e6a9 --- /dev/null +++ b/patch_admin.php @@ -0,0 +1,237 @@ +query("UPDATE courses SET registration_open = 0"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if (\$post_action === 'open_all_registration') { + db()->query("UPDATE courses SET registration_open = 1"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if (\$post_action === 'reset_all_students') { + db()->query("TRUNCATE TABLE course_students"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + + if (\$post_action === 'edit' || \$post_action === 'add') { +PHP; +$content = str_replace($post_actions_orig, $post_actions_new, $content); + +// 2. Add max_students and registration_open to post +$vars_orig = <<execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $post_id]);'; +$edit_new = '$stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=?, max_students=?, registration_open=? WHERE id=?");' . "\n" . + ' $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open, $post_id]);'; +$content = str_replace($edit_orig, $edit_new, $content); + +// 4. Update query add +$add_orig = '$stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture) VALUES (?, ?, ?, ?, ?, ?, ?)");' . "\n" . + ' $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture]);'; +$add_new = '$stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture, max_students, registration_open) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");' . "\n" . + ' $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open]);'; +$content = str_replace($add_orig, $add_new, $content); + +// 5. Add bulk buttons +$buttons_orig = << +

+ + + + +
+PHP; +$buttons_new = << +

+
+
+
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+PHP; +$content = str_replace($buttons_orig, $buttons_new, $content); + +// 6. List view columns +$th_orig = << + +PHP; +$th_new = << + + +PHP; +$content = str_replace($th_orig, $th_new, $content); + +$td_orig = << + + + + + + +
+
+ + +PHP; +$edit_modal_new = << + + +
+
+ + +
+
+ + +PHP; +$content = str_replace($edit_modal_orig, $edit_modal_new, $content); + +$edit_modal_orig2 = << + + +
+PHP; +$edit_modal_new2 = << + + + +
+
+ /> + +
+
+PHP; +$content = str_replace($edit_modal_orig2, $edit_modal_new2, $content); + +$add_modal_orig = << + + + +
+ + +PHP; +$add_modal_new = << + + +
+
+ + +
+
+ + +PHP; +$content = str_replace($add_modal_orig, $add_modal_new, $content); + +$add_modal_orig2 = << + + +
+PHP; +$add_modal_new2 = << + + + +
+
+ + +
+
+PHP; +$content = str_replace($add_modal_orig2, $add_modal_new2, $content); + + +file_put_contents('admin_courses.php', $content); +echo "Done"; +?> diff --git a/patch_admin.py b/patch_admin.py new file mode 100644 index 0000000..8f90dac --- /dev/null +++ b/patch_admin.py @@ -0,0 +1,160 @@ +import sys +import re + +with open('admin_courses.php', 'r') as f: + content = f.read() + +# 1. Add post actions +content = content.replace( + " if ($post_action === 'edit' || $post_action === 'add') {", + """ if ($post_action === 'close_all_registration') { + db()->query(\"UPDATE courses SET registration_open = 0\"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if ($post_action === 'open_all_registration') { + db()->query(\"UPDATE courses SET registration_open = 1\"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if ($post_action === 'reset_all_students') { + db()->query(\"TRUNCATE TABLE course_students\"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + + if ($post_action === 'edit' || $post_action === 'add') {""" +) + +# 2. Add max_students and registration_open to post +content = content.replace( + """ $status = $_POST['status'] ?? 'active'; + $price = (float)($_POST['price'] ?? 0);""", + """ $status = $_POST['status'] ?? 'active'; + $price = (float)($_POST['price'] ?? 0); + $max_students = (isset($_POST['max_students']) && $_POST['max_students'] !== '') ? (int)$_POST['max_students'] : null; + $registration_open = isset($_POST['registration_open']) ? 1 : 0;""" +) + +# 3. Update query edit +content = content.replace( + '$stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=? WHERE id=?");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $post_id]);', + '$stmt = db()->prepare("UPDATE courses SET name_en=?, name_ar=?, description_en=?, description_ar=?, status=?, price=?, picture=?, max_students=?, registration_open=? WHERE id=?");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open, $post_id]);' +) + +# 4. Update query add +content = content.replace( + '$stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture) VALUES (?, ?, ?, ?, ?, ?, ?)");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture]);', + '$stmt = db()->prepare("INSERT INTO courses (name_en, name_ar, description_en, description_ar, status, price, picture, max_students, registration_open) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");\n $stmt->execute([$name_en, $name_ar, $desc_en, $desc_ar, $status, $price, $picture, $max_students, $registration_open]);' +) + +# 5. Add bulk buttons +content = content.replace( + """
+

?= h(t('Courses', 'الدورات')) ?>

+
+ + + +
+", + """
+

?= h(t('Courses', 'الدورات')) ?>

+
+
+
'courses'])) \" class=\"m-0\" onsubmit=\"return confirm('');\"> + + +
+
'courses'])) \" class=\"m-0\" onsubmit=\"return confirm('');\"> + + +
+ +
+
+ +
+""" +) + +# 6. Modal edit +content = content.replace( + """
+ + \"> +
""", + """
+ + \"> +
+
+ + \" value=\"\"> +
+
+
+ \" value=\"1\" /> + +
+
""" +) + +# 7. Modal add +content = content.replace( + """
+ + +
""", + """
+ + +
+
+ + \"> +
+
+
+ + +
+
""" +) + +# 8. update list to show registration status +content = content.replace( + """ ?= h(t('Assigned', 'مخصص')) ?> + ?= h(t('Actions', 'الإجراءات')) ?>""", + """ ?= h(t('Assigned', 'مخصص')) ?> + ?= h(t('Reg Status', 'حالة التسجيل')) ?> + ?= h(t('Actions', 'الإجراءات')) ?>""" +) + +content = content.replace( + """ + ?= h($assigned_count) ?> + + +""", + """ + ?= h($assigned_count) ?> + + / + + + + + ?= h(t('Open', 'مفتوح')) ?> + + ?= h(t('Closed', 'مغلق')) ?> + + + +""" +) + +with open('admin_courses.php', 'w') as f: + f.write(content) + +print("Done") diff --git a/patch_admin_courses.php b/patch_admin_courses.php new file mode 100644 index 0000000..4517cd5 --- /dev/null +++ b/patch_admin_courses.php @@ -0,0 +1,31 @@ +query("UPDATE courses SET registration_open = 0"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + if ($post_action === 'open_all_registration') { + db()->query("UPDATE courses SET registration_open = 1"); + header('Location: ' . app_url('admin.php', ['page' => 'courses'])); + exit; + } + + if ($post_action === 'edit' || $post_action === 'add') { +PHP; +$content = str_replace(" if ($post_action === 'edit' || $post_action === 'add') {", $new_actions, $content); + +// 2. Add max_students and registration_open to post +$vars = <<<'PHP' + $status = $_POST['status'] ?? 'active'; + $price = (float)($_POST['price'] ?? 0); + $max_students = (isset($_POST['max_students']) && $_POST['max_students'] !== '') ? (int)$_POST['max_students'] : null; + $registration_open = isset($_POST['registration_open']) ? 1 : 0; +PHP; +$content = preg_replace("/\$status = \\\\[_POST\['status'\] \\\\] \\\\\? \\\\[\\\\] 'active';\\\\\s*\\\\[_price = \\\\[(float)\\\\[_POST\['price'\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \\\\] \**PHP** + if ($post_action === 'close_all_registration') { + db()->query( \ No newline at end of file diff --git a/patch_checkout.php b/patch_checkout.php new file mode 100644 index 0000000..463696d --- /dev/null +++ b/patch_checkout.php @@ -0,0 +1,29 @@ + 0) { + $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch(); + if ($course) { + if (! $course['registration_open']) { + die(t('Registration for this course is currently closed.', 'التسجيل في هذه الدورة مغلق حالياً.')); + } + if ($course['max_students'] > 0) { + $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = $courseIdForView")->fetchColumn(); + if ($enrolled >= $course['max_students']) { + die(t('This course has reached its maximum number of students.', 'لقد وصلت هذه الدورة إلى الحد الأقصى لعدد الطلاب.')); + } + } + } else { + die('Course not found'); + } +} +PHP; + +$content = preg_replace("/if \(\\$courseIdForView > 0\) \{\\s*\\\$course = db\(\)->query\(\"SELECT \* FROM courses WHERE id = \\\$courseIdForView\"\)->fetch\(\);\\s*\}", $limit_check, $content); + +file_put_contents($file, $content); +echo "Done\n"; + diff --git a/patch_checkout.py b/patch_checkout.py new file mode 100644 index 0000000..294a324 --- /dev/null +++ b/patch_checkout.py @@ -0,0 +1,34 @@ +import sys + +with open('checkout.php', 'r') as f: + content = f.read() + +old_code = """if ($courseIdForView > 0) { + $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch(); +}""" + +new_code = """if ($courseIdForView > 0) { + $course = db()->query("SELECT * FROM courses WHERE id = $courseIdForView")->fetch(); + if ($course) { + if (!$course['registration_open']) { + $msg = current_lang() === 'ar' ? 'التسجيل في هذه الدورة/الدفعة مغلق حالياً.' : 'Registration for this course/batch is currently closed.'; + die(""); + } + if ($course['max_students'] > 0) { + $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = $courseIdForView")->fetchColumn(); + if ($enrolled >= $course['max_students']) { + $msg = current_lang() === 'ar' ? 'لقد وصلت هذه الدورة إلى الحد الأقصى لعدد الطلاب.' : 'This course has reached its maximum capacity.'; + die(""); + } + } + } else { + die('Course not found'); + } +}""" + +content = content.replace(old_code, new_code) + +with open('checkout.php', 'w') as f: + f.write(content) + +print("Done") diff --git a/patch_index.py b/patch_index.py new file mode 100644 index 0000000..c298819 --- /dev/null +++ b/patch_index.py @@ -0,0 +1,29 @@ +import sys + +with open('index.php', 'r') as f: + content = f.read() + +old_button = """""" + +new_button = """ 0) { + $enrolled = db()->query("SELECT COUNT(*) FROM course_students WHERE course_id = " . $course['id'])->fetchColumn(); + if ($enrolled >= $course['max_students']) { + $isFull = true; + } + } + if ($isClosed || $isFull): + ?> + + + + """ + +content = content.replace(old_button, new_button) + +with open('index.php', 'w') as f: + f.write(content) + +print("Done")