From 015b57ddfd3cb9f9336e297fc4b08623f3ec0f6e Mon Sep 17 00:00:00 2001 From: nestict Date: Sat, 24 May 2025 12:34:29 +0200 Subject: [PATCH] Upload files to "system/plugin" Signed-off-by: nestict --- system/plugin/download.php | 755 +++++++++++++++++++++++++++++ system/plugin/error_log | 12 + system/plugin/hotspot_plan.php | 79 +++ system/plugin/hotspot_settings.php | 229 +++++++++ system/plugin/index.html | Bin 0 -> 1024 bytes 5 files changed, 1075 insertions(+) create mode 100644 system/plugin/download.php create mode 100644 system/plugin/error_log create mode 100644 system/plugin/hotspot_plan.php create mode 100644 system/plugin/hotspot_settings.php create mode 100644 system/plugin/index.html diff --git a/system/plugin/download.php b/system/plugin/download.php new file mode 100644 index 0000000..604cc4a --- /dev/null +++ b/system/plugin/download.php @@ -0,0 +1,755 @@ +connect_error) { + die("Connection failed: " . $mysqli->connect_error); +} + +// Function to get a setting value +function getSettingValue($mysqli, $setting) { + $query = $mysqli->prepare("SELECT value FROM tbl_appconfig WHERE setting = ?"); + $query->bind_param("s", $setting); + $query->execute(); + $result = $query->get_result(); + if ($row = $result->fetch_assoc()) { + return $row['value']; + } + return ''; +} + +// Fetch hotspot title and description from tbl_appconfig +$hotspotTitle = getSettingValue($mysqli, 'hotspot_title'); +$description = getSettingValue($mysqli, 'description'); +$phone = getSettingValue($mysqli, 'phone'); +$company = getSettingValue($mysqli, 'CompanyName'); + +// Fetch router name and router ID from tbl_appconfig +$routerName = getSettingValue($mysqli, 'router_name'); +$routerId = getSettingValue($mysqli, 'router_id'); + +// Fetch available plans + +$planQuery = "SELECT id, type, name_plan, price, validity, validity_unit FROM tbl_plans WHERE routers = ? AND type = 'Hotspot'"; +$planStmt = $mysqli->prepare($planQuery); +$planStmt->bind_param("s", $routerName); +$planStmt->execute(); +$planResult = $planStmt->get_result(); + + +$htmlContent = ""; +$htmlContent .= "\n"; +$htmlContent .= "\n"; +$htmlContent .= "\n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " $company\n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; + + + + + +$htmlContent .= "\n"; +$htmlContent .= "\n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "

$company HOTSPOT LOGIN

\n"; +$htmlContent .= "
    \n"; +$htmlContent .= "
  1. Click on your preferred package
  2. \n"; +$htmlContent .= "
  3. Enter Mpesa No.
  4. \n"; +$htmlContent .= "
  5. Enter pin
  6. \n"; +$htmlContent .= "
  7. Wait to be connected
  8. \n"; +$htmlContent .= "
\n"; +$htmlContent .= "

For any enquiries contact : $phone

\n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; + + + + + + + +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; + + + + + + + + + +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; + +// New HTML content added +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "

Enter code to reconnect

\n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "

Already Have an Active Package?

\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= " \n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "

© " . date("Y") . ". Powered by NestICT

\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "
\n"; +$htmlContent .= "\n"; + +// Add the closing script section as well, if necessary +$htmlContent .= "\n"; + + + + + + + + + + + + + + + + + + + + + + +$htmlContent .= "\n"; + + + + + + + + + + + +$htmlContent .= "\n"; +$htmlContent .= "\n"; + + + + + + + + + + + + + + + + + + + + + + +$htmlContent .= "\n"; +$htmlContent .= "\n"; + + + + + + + + + + + + + + + + + + + +$htmlContent .= "\n"; + + + + + + + + + + + + + + + + + + + + + + +$htmlContent .= "\n"; +$htmlContent .= "\n"; +$htmlContent .= "\n"; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +$planStmt->close(); +$mysqli->close(); +// Check if the download parameter is set +if (isset($_GET['download']) && $_GET['download'] == '1') { + // Prepare the HTML content for download + // ... build your HTML content ... + + // Specify the filename for the download + $filename = "login.html"; + + // Send headers to force download + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename='.basename($filename)); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . strlen($htmlContent)); + + // Output the content + echo $htmlContent; + + // Prevent any further output + exit; +} + +// Regular page content goes here +// ... HTML and PHP code to display the page ... + + diff --git a/system/plugin/error_log b/system/plugin/error_log new file mode 100644 index 0000000..903f614 --- /dev/null +++ b/system/plugin/error_log @@ -0,0 +1,12 @@ +[06-Jul-2024 15:05:25 UTC] PHP Fatal error: Uncaught Error: Undefined constant "request" in /home/codevibe/kejos.codevibeisp.co.ke/system/plugin/download.php:154 +Stack trace: +#0 {main} + thrown in /home/codevibe/kejos.codevibeisp.co.ke/system/plugin/download.php on line 154 +[06-Jul-2024 15:05:28 UTC] PHP Fatal error: Uncaught Error: Undefined constant "request" in /home/codevibe/kejos.codevibeisp.co.ke/system/plugin/download.php:154 +Stack trace: +#0 {main} + thrown in /home/codevibe/kejos.codevibeisp.co.ke/system/plugin/download.php on line 154 +[06-Jul-2024 17:35:47 UTC] PHP Fatal error: Uncaught Error: Undefined constant "request" in /home/codevibe/kejos.codevibeisp.co.ke/system/plugin/download.php:154 +Stack trace: +#0 {main} + thrown in /home/codevibe/kejos.codevibeisp.co.ke/system/plugin/download.php on line 154 diff --git a/system/plugin/hotspot_plan.php b/system/plugin/hotspot_plan.php new file mode 100644 index 0000000..6c5e06b --- /dev/null +++ b/system/plugin/hotspot_plan.php @@ -0,0 +1,79 @@ +find_many(); + $plans_hotspot = ORM::for_table('tbl_plans')->where('type', 'Hotspot')->find_many(); + + // Fetch bandwidth limits for all plans + $bandwidth_limits = ORM::for_table('tbl_bandwidth')->find_many(); + $bandwidth_map = []; + foreach ($bandwidth_limits as $limit) { + $bandwidth_map[$limit['plan_id']] = [ + 'downlimit' => $limit['rate_down'], + 'uplimit' => $limit['rate_up'], + ]; + } + + // Fetch currency from tbl_appconfig using the correct column names + $currency_config = ORM::for_table('tbl_appconfig')->where('setting', 'currency_code')->find_one(); + $currency = $currency_config ? $currency_config->value : 'Ksh'; // Default to 'Ksh' if not found + + // Initialize empty data array to store router-specific plans + $data = []; + + // Process each router to filter and collect hotspot plans + foreach ($routers as $router) { + if ($router['name'] === $routerName) { // Check if router name matches POSTed routername + $routerData = [ + 'name' => $router['name'], + 'router_id' => $router['id'], + 'description' => $router['description'], + 'plans_hotspot' => [], + ]; + + // Filter and collect hotspot plans associated with the router + foreach ($plans_hotspot as $plan) { + if ($router['name'] == $plan['routers']) { + $plan_id = $plan['id']; + $bandwidth_data = isset($bandwidth_map[$plan_id]) ? $bandwidth_map[$plan_id] : []; + + // Construct payment link using $_url + $paymentlink = "https://codevibeisp.co.ke/index.php?_route=plugin/hotspot_pay&routerName={$router['name']}&planId={$plan['id']}&routerId={$router['id']}"; + + // Prepare plan data to be sent in JSON response + $routerData['plans_hotspot'][] = [ + 'plantype' => $plan['type'], + 'planname' => $plan['name_plan'], + 'currency' => $currency, + 'price' => $plan['price'], + 'validity' => $plan['validity'], + 'device' => $plan['shared_users'], + 'datalimit' => $plan['data_limit'], + 'timelimit' => $plan['validity_unit'] ?? null, + 'downlimit' => $bandwidth_data['downlimit'] ?? null, + 'uplimit' => $bandwidth_data['uplimit'] ?? null, + 'paymentlink' => $paymentlink, + 'planId' => $plan['id'], + 'routerName' => $router['name'], + 'routerId' => $router['id'] + ]; + } + } + + // Add router data to $data array + $data[] = $routerData; + } + } + + // Respond with JSON data + // header('Content-Type: application/json'); + // header('Access-Control-Allow-Origin: *'); // Adjust this based on your CORS requirements + echo json_encode(['data' => $data], JSON_PRETTY_PRINT); + exit(); +} +?> diff --git a/system/plugin/hotspot_settings.php b/system/plugin/hotspot_settings.php new file mode 100644 index 0000000..2a845c5 --- /dev/null +++ b/system/plugin/hotspot_settings.php @@ -0,0 +1,229 @@ +assign('_title', 'Hotspot Dashboard'); + $ui->assign('_admin', $admin); + + // Check if form is submitted + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + // Update Hotspot Title + $newHotspotTitle = isset($_POST['hotspot_title']) ? trim($_POST['hotspot_title']) : ''; + if (!empty($newHotspotTitle)) { + $updateStmt = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'hotspot_title'"); + $updateStmt->execute([$newHotspotTitle]); + } + + // Add similar logic for FAQ fields here + // FAQ Headline 1 Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['frequently_asked_questions_headline1']) ? trim($_POST['frequently_asked_questions_headline1']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'frequently_asked_questions_headline1'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } + } + + // FAQ Headline 2 Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['frequently_asked_questions_headline2']) ? trim($_POST['frequently_asked_questions_headline2']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'frequently_asked_questions_headline2'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } +} + + // FAQ Headline 3 Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['frequently_asked_questions_headline3']) ? trim($_POST['frequently_asked_questions_headline3']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'frequently_asked_questions_headline3'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } +} + + // FAQ Answer 1 Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['frequently_asked_questions_answer1']) ? trim($_POST['frequently_asked_questions_answer1']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'frequently_asked_questions_answer1'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } +} + + + // FAQ Answer 2 Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['frequently_asked_questions_answer2']) ? trim($_POST['frequently_asked_questions_answer2']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'frequently_asked_questions_answer2'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } +} + + // FAQ Answer 3 Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['frequently_asked_questions_answer3']) ? trim($_POST['frequently_asked_questions_answer3']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'frequently_asked_questions_answer3'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } +} + + // FAQ Description Posting To Database + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $newFaqHeadline1 = isset($_POST['description']) ? trim($_POST['description']) : ''; + if (!empty($newFaqHeadline1)) { + $updateFaqStmt1 = $conn->prepare("UPDATE tbl_appconfig SET value = ? WHERE setting = 'description'"); + $updateFaqStmt1->execute([$newFaqHeadline1]); + } +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + // Get router name from user input + $routerName = isset($_POST['router_name']) ? trim($_POST['router_name']) : ''; + + if (!empty($routerName)) { + // Fetch the router ID based on the router name + $routerStmt = $conn->prepare("SELECT id FROM tbl_routers WHERE name = :router_name"); + $routerStmt->execute(['router_name' => $routerName]); + $router = $routerStmt->fetch(PDO::FETCH_ASSOC); + + if ($router) { + // Update router_id in tbl_appconfig + $updateRouterIdStmt = $conn->prepare("UPDATE tbl_appconfig SET value = :router_id WHERE setting = 'router_id'"); + $updateRouterIdStmt->execute(['router_id' => $router['id']]); + + // Update router_name in tbl_appconfig + $updateRouterNameStmt = $conn->prepare("UPDATE tbl_appconfig SET value = :router_name WHERE setting = 'router_name'"); + $updateRouterNameStmt->execute(['router_name' => $routerName]); + } else { + // Handle the case where no matching router is found + // For example, you can set an error message or take any other appropriate action + } + } + // Other form handling code (if any) +} + + + // Redirect with a success message + r2(U . "plugin/hotspot_settings", 's', "Settings Saved"); + } + + + + + + + + + + + // Fetch the current hotspot title from the database + $stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'hotspot_title'"); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $hotspotTitle = $result ? $result['value'] : ''; + + // Assign the fetched title to the template + $ui->assign('hotspot_title', $hotspotTitle); + + + + + // Fetch the current faq headline 1 from the database + $stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'frequently_asked_questions_headline1'"); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $headline1 = $result ? $result['value'] : ''; + + // Assign the fetched title to the template + $ui->assign('frequently_asked_questions_headline1', $headline1); + + + // Fetch the current faq headline 2 from the database + $stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'frequently_asked_questions_headline2'"); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $headline2 = $result ? $result['value'] : ''; + + // Assign the fetched title to the template + $ui->assign('frequently_asked_questions_headline2', $headline2); + + + + // Fetch the current faq headline 3 from the database + $stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'frequently_asked_questions_headline3'"); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $headline3 = $result ? $result['value'] : ''; + + // Assign the fetched title to the template + $ui->assign('frequently_asked_questions_headline3', $headline3); + + + // Fetch the current faq Answer1 from the database + $stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'frequently_asked_questions_answer1'"); + $stmt->execute(); + $result = $stmt->fetch(PDO::FETCH_ASSOC); + $answer1 = $result ? $result['value'] : ''; + + // Assign the fetched title to the template +$ui->assign('frequently_asked_questions_answer1', $answer1); + +// Fetch the current faq Answer2 from the database +$stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'frequently_asked_questions_answer2'"); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_ASSOC); +$answer2 = $result ? $result['value'] : ''; + +// Assign the fetched title to the template +$ui->assign('frequently_asked_questions_answer2', $answer2); + +// Fetch the current faq Answer 3 from the database +$stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'frequently_asked_questions_answer3'"); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_ASSOC); +$answer3 = $result ? $result['value'] : ''; + +// Assign the fetched title to the template +$ui->assign('frequently_asked_questions_answer3', $answer3); + +// Fetch the current faq description from the database +$stmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'description'"); +$stmt->execute(); +$result = $stmt->fetch(PDO::FETCH_ASSOC); +$description = $result ? $result['value'] : ''; + +// Assign the fetched title to the template +$ui->assign('description', $description); + + + +/// Fetch the current router name from the database for display in the form +$routerIdStmt = $conn->prepare("SELECT value FROM tbl_appconfig WHERE setting = 'router_id'"); +$routerIdStmt->execute(); +$routerIdResult = $routerIdStmt->fetch(PDO::FETCH_ASSOC); +if ($routerIdResult) { + $routerStmt = $conn->prepare("SELECT name FROM tbl_routers WHERE id = :router_id"); + $routerStmt->execute(['router_id' => $routerIdResult['value']]); + $router = $routerStmt->fetch(PDO::FETCH_ASSOC); + if ($router) { + $ui->assign('router_name', $router['name']); + } +} + + + // Render the template + $ui->display('hotspot_settings.tpl'); +} + + + + + + diff --git a/system/plugin/index.html b/system/plugin/index.html new file mode 100644 index 0000000000000000000000000000000000000000..06d7405020018ddf3cacee90fd4af10487da3d20 GIT binary patch literal 1024 ScmZQz7zLvtFd70QH3R?z00031 literal 0 HcmV?d00001