first commit

main
Suvodip 2025-02-28 17:08:43 +05:30
commit e56d4f72ab
27 changed files with 598 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<?php
$mariaServer = "172.17.0.1";
$mariaUser = "root";
$mariaPass = "pass";
$mariaDb = "db_name";
$mongo ="";

6
.hta_config/conf.php Normal file
View File

@ -0,0 +1,6 @@
<?php
$mariaServer = "172.17.0.1";
$mariaUser = "root";
$mariaPass = "0000";
$mariaDb = "billing";
$mongo ="";

4
.hta_config/var.php Normal file
View File

@ -0,0 +1,4 @@
<?php
$appName = "PHP Boilarplate";
$domain = "domain.ext";
require_once('conf.php');

1
.hta_slug/_404.php Normal file
View File

@ -0,0 +1 @@
404 root

6
.hta_slug/_footer.php Normal file
View File

@ -0,0 +1,6 @@
</main>
<footer class="">
<!-- Footer Content here -->
</footer>
</body>
</html>

31
.hta_slug/_header.php Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<!-- <link rel="stylesheet" type="text/css" href="/assets/main.css" /> -->
<?php
function isMobileDevice() {
// return preg_match('/(android|iphone|ipod|ipad|windows phone)/i', $_SERVER['HTTP_USER_AGENT']);
return preg_match('/(Mobile|iphone|ipod|ipad|windows phone)/i', $_SERVER['HTTP_USER_AGENT']); // removed android as "request desktop site" removes
}
if(isset($web_page_title)) echo '<title>'.$web_page_title.'</title>';
if(isset($web_page_meta_description)) echo '<meta name="description" content="'.$web_page_meta_description.'">';
if(isset($web_page_meta_keywords)) echo '<meta name="keywords" content="'.$web_page_meta_keywords.'">';
if(isset($web_page_meta_author)) echo '<meta name="author" content="'.$web_page_author.'">';
if(isset($web_page_meta_og_title)) echo '<meta property="og:title" content="'.$web_page_meta_og_title.'">';
if(isset($web_page_meta_og_description)) echo '<meta property="og:description" content="'.$web_page_meta_og_description.'">';
if(isset($web_page_meta_og_image)) echo '<meta property="og:image" content="'.$web_page_meta_og_image.'">';
if(isset($web_page_meta_og_url)) echo '<meta property="og:url" content="'.$web_page_meta_og_url.'">';
if(isset($web_page_meta_twitter_title)) echo '<meta name="twitter:title" content="'.$web_page_meta_twitter_title.'">';
if(isset($web_page_meta_twitter_description)) echo '<meta name="twitter:description" content="'.$web_page_meta_twitter_description.'">';
if(isset($web_page_meta_twitter_image)) echo '<meta name="twitter:image" content="'.$web_page_meta_twitter_image.'">';
if(isset($web_page_meta_twitter_card)) echo '<meta name="twitter:card" content="'.$web_page_meta_twitter_card.'">';
?>
</head>
<body class="">

3
.hta_slug/_home.php Normal file
View File

@ -0,0 +1,3 @@
<div class="container mt-4">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quibusdam mollitia quidem sint dolores nostrum, similique nulla consequuntur. Animi neque labore praesentium ratione a? Facere, quasi ea reprehenderit eum tempora voluptatum.
</div>

25
.hta_slug/_nav.php Normal file
View File

@ -0,0 +1,25 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<div class="container">
<a class="navbar-brand" href="#">MyWebsite</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link active" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/customers/new">New Customer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/customers/list">Customer List</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/contact-us">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<main style="scroll-behavior: auto;">

23
.hta_slug/contact-us.php Normal file
View File

@ -0,0 +1,23 @@
<div class="container flex-grow-1 d-flex align-items-center justify-content-center mt-4">
<div class="card shadow-lg border-0 p-4 w-100" style="max-width: 500px;">
<div class="card-body">
<h2 class="text-center text-primary fw-bold">Contact Us</h2>
<p class="text-center text-muted">We'd love to hear from you! Fill out the form below.</p>
<form>
<div class="mb-3">
<label class="form-label fw-semibold">Name</label>
<input type="text" class="form-control" placeholder="Your Name">
</div>
<div class="mb-3">
<label class="form-label fw-semibold">Email</label>
<input type="email" class="form-control" placeholder="Your Email">
</div>
<div class="mb-3">
<label class="form-label fw-semibold">Message</label>
<textarea class="form-control" rows="4" placeholder="Your Message"></textarea>
</div>
<button type="submit" class="btn btn-primary w-100 fw-semibold">Send Message</button>
</form>
</div>
</div>
</div>

8
.htaccess Normal file
View File

@ -0,0 +1,8 @@
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

BIN
billing2.zip Normal file

Binary file not shown.

View File

View File

@ -0,0 +1 @@
sample route home

View File

@ -0,0 +1,106 @@
<?php
require('../.hta_config/conf.php');
// Enable error reporting (for debugging)
error_reporting(E_ALL);
ini_set('display_errors', 1);
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
die("Database connection failed: " . $e->getMessage());
}
// Handle Payment Status Update
if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["emiId"]) && isset($_POST["status"])) {
$emiId = $_POST["emiId"];
$status = $_POST["status"];
try {
$stmt = $db->prepare("UPDATE billing SET emi".$emiId."Status = :status WHERE customerId = :customerId");
$stmt->bindParam(':status', $status, PDO::PARAM_INT);
$stmt->bindParam(':customerId', $_POST["customerId"]);
$stmt->execute();
echo json_encode(["success" => true, "message" => "Payment status updated"]);
} catch (PDOException $e) {
echo json_encode(["success" => false, "message" => "Error updating payment status"]);
}
exit;
}
// Fetch Customer Billing Data
if (!isset($_GET['customerId'])) {
die("Invalid request: Customer ID is required.");
}
$customerId = $_GET['customerId'];
$stmt = $db->prepare("SELECT * FROM billing WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $customerId);
$stmt->execute();
$billingData = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$billingData) {
die("No billing data found for this customer.");
}
?>
<div class="container mt-4">
<h2 class="mb-3 text-center">Customer Billing Details</h2>
<table class="table table-bordered table-striped">
<thead class="thead-dark">
<tr>
<th>#</th>
<th>EMI Date</th>
<th>Amount</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
for ($i = 1; $i <= 12; $i++) {
$emiAmount = $billingData["emi$i"];
$emiDate = $billingData["emi{$i}Date"];
$emiStatus = $billingData["emi{$i}Status"];
if (!$emiAmount || !$emiDate) continue;
echo "<tr>
<td>{$i}</td>
<td>{$emiDate}</td>
<td>{$emiAmount}</td>
<td id='status-$i'>" . ($emiStatus == 1 ? "<span class='badge bg-success'>Paid</span>" : "<span class='badge bg-danger'>Unpaid</span>") . "</td>
<td>
<button class='btn btn-sm " . ($emiStatus == 1 ? "btn-secondary disabled" : "btn-primary") . "' onclick='updatePaymentStatus($i)' id='btn-$i'>Mark as Paid</button>
</td>
</tr>";
}
?>
</tbody>
</table>
</div>
<script>
function updatePaymentStatus(emiId) {
let customerId = "<?php echo $customerId; ?>";
let formData = new FormData();
formData.append("emiId", emiId);
formData.append("status", 1); // Set status to "1" (Paid)
formData.append("customerId", customerId);
fetch("billing-details.php", {
method: "POST",
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById("status-" + emiId).innerHTML = "<span class='badge badge-success'>Paid</span>";
document.getElementById("btn-" + emiId).classList.replace("btn-primary", "btn-secondary");
document.getElementById("btn-" + emiId).classList.add("disabled");
} else {
alert("Failed to update payment status!");
}
})
.catch(error => console.error("Error:", error));
}
</script>

View File

@ -0,0 +1,109 @@
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card shadow-lg">
<div class="card-header bg-primary text-white text-center">
<h4>Edit Customer Details</h4>
</div>
<div class="card-body">
<?php
require('../.hta_config/conf.php');
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Update customer details
$stmt = $db->prepare("UPDATE customers SET name = :name, mobile = :mobile, email = :email WHERE customerId = :customerId");
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':mobile', $_POST['mobile']);
$stmt->bindParam(':email', $_POST['email']);
$stmt = $db->prepare("SELECT COUNT(*) FROM address WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $_POST['customerId']);
$stmt->execute();
$addressExists = $stmt->fetchColumn();
if ($addressExists) {
$stmt = $db->prepare("UPDATE address SET city = :city, district = :district, state = :state, pinCode = :pin WHERE customerId = :customerId");
} else {
$stmt = $db->prepare("INSERT INTO address (customerId, city, district, state, pinCode) VALUES (:customerId, :city, :district, :state, :pin)");
}
$stmt->bindParam(':city', $_POST['city']);
$stmt->bindParam(':district', $_POST['district']);
$stmt->bindParam(':state', $_POST['state']);
$stmt->bindParam(':pin', $_POST['pinCode']);
$stmt->bindParam(':customerId', $_POST['customerId']);
if ($stmt->execute()) {
echo '<div class="alert alert-success">Customer details updated successfully.</div>';
} else {
echo '<div class="alert alert-danger">Error updating customer.</div>';
}
}
// Fetch customer data
$stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $_GET['customerId']);
$stmt->execute();
$customer = $stmt->fetch(PDO::FETCH_ASSOC);
$stmtAddress = $db->prepare("SELECT * FROM address WHERE customerId = :customerId");
$stmtAddress->bindParam(':customerId', $_GET['customerId']);
$stmtAddress->execute();
$customerAddress = $stmtAddress->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
?>
<?php if ($customer): ?>
<form method="POST">
<input type="hidden" name="customerId" value="<?php echo htmlspecialchars($customer['customerId']); ?>">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" class="form-control" value="<?php echo htmlspecialchars($customer['name']); ?>" required>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<input type="text" id="mobile" name="mobile" class="form-control" value="<?php echo htmlspecialchars($customer['mobile']); ?>" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" class="form-control" value="<?php echo htmlspecialchars($customer['email']); ?>" required>
</div>
<div class="form-group">
<label for="city">City:</label>
<input type="text" id="city" name="city" class="form-control" value="<?php echo htmlspecialchars($customerAddress['city'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label for="district">District:</label>
<input type="text" id="district" name="district" class="form-control" value="<?php echo htmlspecialchars($customerAddress['district'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label for="state">State:</label>
<input type="text" id="state" name="state" class="form-control" value="<?php echo htmlspecialchars($customerAddress['state'] ?? ''); ?>" required>
</div>
<div class="form-group">
<label for="pinCode">Pin Code:</label>
<input type="text" id="pinCode" name="pinCode" class="form-control" value="<?php echo htmlspecialchars($customerAddress['pinCode'] ?? ''); ?>" required>
</div>
<button type="submit" class="btn btn-success btn-block mt-2">Update Customer</button>
</form>
<?php else: ?>
<div class="alert alert-danger text-center">Customer not found!</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>

100
customers/.hta_slug/emi.php Normal file
View File

@ -0,0 +1,100 @@
<?php
require('../.hta_config/conf.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$customerId = $_POST['customerId'];
$totalAmount = $_POST['totalAmount'];
$tenure = min($_POST['tenure'], 18); // Limit tenure to 18 months
$firstEmiDate = $_POST['firstEmiDate'];
$emiAmount = $totalAmount / $tenure;
// Prepare the query dynamically
$columns = ['customerId', 'totalAmount', 'tenure', 'emiAmount', 'firstEmiDate'];
$placeholders = [':customerId', ':totalAmount', ':tenure', ':emiAmount', ':firstEmiDate'];
$params = [
':customerId' => $customerId,
':totalAmount' => $totalAmount,
':tenure' => $tenure,
':emiAmount' => $emiAmount,
':firstEmiDate' => $firstEmiDate
];
// Add EMI columns dynamically based on tenure
for ($i = 1; $i <= $tenure; $i++) {
$emiDate = date('Y-m-d', strtotime("+$i months", strtotime($firstEmiDate)));
$columns[] = "emi$i";
$columns[] = "emi{$i}Date";
$placeholders[] = ":emi$i";
$placeholders[] = ":emi{$i}Date";
$params[":emi$i"] = $emiAmount;
$params[":emi{$i}Date"] = $emiDate;
}
// Construct SQL statement
$sql = "INSERT INTO billing (" . implode(',', $columns) . ") VALUES (" . implode(',', $placeholders) . ")";
$stmt = $db->prepare($sql);
// Execute the query
if ($stmt->execute($params)) {
echo '<div class="alert alert-success">New EMI plan for <strong>' . htmlspecialchars($customerId) . '</strong> saved successfully.</div>';
} else {
echo '<div class="alert alert-danger">Error executing statement: ' . $stmt->errorInfo()[2] . '</div>';
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
// Fetch customer details
$customer = null;
if (!empty($_GET['customerId'])) {
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT * FROM customers WHERE customerId = :customerId");
$stmt->bindParam(':customerId', $_GET['customerId']);
if ($stmt->execute()) {
$customer = $stmt->fetch(PDO::FETCH_ASSOC);
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
?>
<div class="container mt-4">
<h2>EMI Calculation</h2>
<?php if (!empty($customer)): ?>
<p><strong>Name:</strong> <?= htmlspecialchars($customer['name']) ?></p>
<p><strong>Mobile:</strong> <?= htmlspecialchars($customer['mobile']) ?></p>
<?php else: ?>
<div class="alert alert-warning">Customer not found.</div>
<?php endif; ?>
<form method="POST">
<input type="hidden" name="customerId" value="<?= htmlspecialchars($_GET['customerId'] ?? '') ?>">
<div class="mb-3">
<label for="totalAmount" class="form-label">Total Amount:</label>
<input type="number" class="form-control" id="totalAmount" name="totalAmount" required>
</div>
<div class="mb-3">
<label for="tenure" class="form-label">Tenure (Months):</label>
<input type="number" class="form-control" id="tenure" name="tenure" min="1" max="18" required>
</div>
<div class="mb-3">
<label for="firstEmiDate" class="form-label">First EMI Date:</label>
<input type="date" class="form-control" id="firstEmiDate" name="firstEmiDate" required>
</div>
<button type="submit" class="btn btn-primary">Save EMI</button>
</form>
</div>

View File

@ -0,0 +1,49 @@
<?php
require('../.hta_config/conf.php');
?>
<div class="container mt-4">
<h2 class="mb-3 text-center">Customer List</h2>
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover">
<thead class="thead-dark">
<tr>
<th>Sl No</th>
<th>Name</th>
<th>Mobile</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT * FROM customers ORDER BY regDate DESC");
$stmt->execute();
$content = $stmt->fetchAll(PDO::FETCH_ASSOC);
$customerSerial = 1; // Moved outside loop
foreach ($content as $customer) {
?>
<tr>
<td><?php echo $customerSerial++; ?></td>
<td><?php echo htmlspecialchars($customer['name']); ?></td>
<td><?php echo htmlspecialchars($customer['mobile']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<td>
<a href="/customers/edit/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Edit</a>
<a href="/customers/emi/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Bill</a>
<a href="/customers/billing-details/?customerId=<?php echo $customer['customerId']; ?>" class="btn btn-primary btn-sm">Billing Info</a>
</td>
</tr>
<?php
}
} catch (PDOException $e) {
echo '<tr><td colspan="5" class="text-danger text-center">Error: ' . $e->getMessage() . '</td></tr>';
}
?>
</tbody>
</table>
</div>
</div>

View File

@ -0,0 +1,51 @@
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-lg">
<div class="card-header bg-primary text-white text-center">
<h4>Customer Registration</h4>
</div>
<div class="card-body">
<?php
require('../.hta_config/conf.php');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
$db = new PDO("mysql:host=$mariaServer;dbname=$mariaDb", $mariaUser, $mariaPass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("INSERT INTO customers (name, mobile, email) VALUES (:name, :mobile, :email)");
$stmt->bindParam(':name', $_POST['name']);
$stmt->bindParam(':mobile', $_POST['mobile']);
$stmt->bindParam(':email', $_POST['email']);
if ($stmt->execute()) {
echo '<div class="alert alert-success">New Customer <strong>' . htmlspecialchars($_POST['name']) . '</strong> created successfully.</div>';
} else {
echo '<div class="alert alert-danger">Error executing statement: ' . $stmt->errorInfo()[2] . '</div>';
}
} catch (PDOException $e) {
echo '<div class="alert alert-danger">Error: ' . $e->getMessage() . '</div>';
}
}
?>
<form method="POST">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" class="form-control" required>
</div>
<div class="form-group">
<label for="mobile">Mobile:</label>
<input type="text" id="mobile" name="mobile" class="form-control" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" class="form-control" required>
</div>
<button type="submit" class="btn btn-success btn-block mt-2">Save Customer</button>
</form>
</div>
</div>
</div>
</div>
</div>

8
customers/.htaccess Normal file
View File

@ -0,0 +1,8 @@
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

18
customers/index.php Normal file
View File

@ -0,0 +1,18 @@
<?php
require('../.hta_slug/_header.php');
require('../.hta_slug/_nav.php');
require_once('../.hta_config/var.php');
$url = explode('/', $_SERVER['REQUEST_URI']);
if (strpos($url[1], "?") !== false) {
$url2 = explode('?', $url[1]);
$slug=$url2[0];
} else $slug=$url[2];
require_once('../.hta_slug/_header.php');
if($slug=="") require_once('.hta_slug/_home.php');
elseif(file_exists(".hta_slug/".$slug.".php")) include ".hta_slug/".$slug.".php";
else require_once('.hta_slug/_404.php');
require_once('../.hta_slug/_footer.php');

View File

@ -0,0 +1 @@
sample-page

16
index.php Normal file
View File

@ -0,0 +1,16 @@
<?php
require_once('.hta_config/var.php');
$url = explode('/', $_SERVER['REQUEST_URI']);
if (strpos($url[1], "?") !== false) {
$url2 = explode('?', $url[1]);
$slug=$url2[0];
} else $slug=$url[1];
require_once('.hta_slug/_header.php');
require_once('.hta_slug/_nav.php');
if($slug=="") require_once('.hta_slug/_home.php');
elseif(file_exists(".hta_slug/".$slug.".php")) include ".hta_slug/".$slug.".php";
else require_once('.hta_slug/_404.php');
require_once('.hta_slug/_footer.php');

View File

View File

@ -0,0 +1 @@
sample route home

8
sample_route/.htaccess Normal file
View File

@ -0,0 +1,8 @@
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php

16
sample_route/index.php Normal file
View File

@ -0,0 +1,16 @@
<?php
require_once('../.hta_config/var.php');
$url = explode('/', $_SERVER['REQUEST_URI']);
if (strpos($url[1], "?") !== false) {
$url2 = explode('?', $url[1]);
$slug=$url2[0];
} else $slug=$url[2];
require_once('../.hta_slug/_header.php');
if($slug=="") require_once('.hta_slug/_home.php');
elseif(file_exists(".hta_slug/".$slug.".php")) include ".hta_slug/".$slug.".php";
else require_once('.hta_slug/_404.php');
require_once('../.hta_slug/_footer.php');

View File

@ -0,0 +1 @@
sample-page