mirror of https://github.com/itsmrval/subway
Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
|
|
@ -30,7 +30,7 @@ Note: This app is not intended for production use, but for personal or education
|
||||||
This section list major frameworks/libraries used
|
This section list major frameworks/libraries used
|
||||||
|
|
||||||
* 
|
* 
|
||||||
* 
|
* 
|
||||||
* 
|
* 
|
||||||
|
|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
@ -74,9 +74,7 @@ Then, create a user with a database
|
||||||
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
||||||
|
|
||||||
|
|
||||||
## Known issues
|
|
||||||
|
|
||||||
- Some stations with RER A doesnt display timetables
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
|
||||||
|
|
@ -70,38 +70,4 @@ $userDetails = getUserDetails($_SESSION['user_id']);
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
function getUserLogs($userId) {
|
|
||||||
global $conn;
|
|
||||||
try {
|
|
||||||
$query = $conn->prepare("SELECT logs.ip, logs.date, users.email FROM logs JOIN users ON logs.userId = users.id WHERE logs.userId = ?");
|
|
||||||
$query->execute([$userId]);
|
|
||||||
return $query->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
} catch(PDOException $e) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$logDetails = getUserLogs($_SESSION['user_id']);
|
|
||||||
?>
|
|
||||||
<table class="table mt-4">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>IP</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Email</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<?php foreach ($logDetails as $log): ?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo $log['ip']; ?></td>
|
|
||||||
<td><?php echo $log['date']; ?></td>
|
|
||||||
<td><?php echo $log['email']; ?></td>
|
|
||||||
</tr>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
@ -12,8 +12,8 @@ function getStopName($stopId) {
|
||||||
function getFavorites($lineId) {
|
function getFavorites($lineId) {
|
||||||
global $conn;
|
global $conn;
|
||||||
try {
|
try {
|
||||||
$query = $conn->prepare("SELECT stopId FROM favorites WHERE lineId = ? AND userId = ?");
|
$query = $conn->prepare("SELECT stopId FROM favorites WHERE lineId = ?");
|
||||||
$query->execute([$lineId, $_SESSION['user_id']]);
|
$query->execute([$lineId]);
|
||||||
$result = $query->fetchAll(PDO::FETCH_ASSOC);
|
$result = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,13 @@ $directions = [];
|
||||||
if (isset($data['Siri']['ServiceDelivery']['StopMonitoringDelivery'][0]['MonitoredStopVisit'])) {
|
if (isset($data['Siri']['ServiceDelivery']['StopMonitoringDelivery'][0]['MonitoredStopVisit'])) {
|
||||||
foreach ($data['Siri']['ServiceDelivery']['StopMonitoringDelivery'][0]['MonitoredStopVisit'] as $visit) {
|
foreach ($data['Siri']['ServiceDelivery']['StopMonitoringDelivery'][0]['MonitoredStopVisit'] as $visit) {
|
||||||
$vehicleJourney = $visit['MonitoredVehicleJourney'];
|
$vehicleJourney = $visit['MonitoredVehicleJourney'];
|
||||||
if (strpos($vehicleJourney['OperatorRef']['value'], '.' . $lineId . '.' . $lineId . ':')) {
|
if (isset($vehicleJourney['MonitoredCall']['ExpectedArrivalTime'])) {
|
||||||
if (isset($vehicleJourney['MonitoredCall']['ExpectedDepartureTime'])) {
|
$direction = $vehicleJourney['DirectionName'][0]['value'];
|
||||||
$direction = $vehicleJourney['DestinationName'][0]['value'];
|
$expectedArrival = $vehicleJourney['MonitoredCall']['ExpectedArrivalTime'];
|
||||||
$expectedDeparture = $vehicleJourney['MonitoredCall']['ExpectedDepartureTime'];
|
$expectedDeparture = $vehicleJourney['MonitoredCall']['ExpectedDepartureTime'];
|
||||||
|
|
||||||
$departureTime = date('H:i', strtotime($expectedDeparture . ' +2 hours'));
|
$departureTime = date('H:i', strtotime($expectedArrival . ' +2 hours'));
|
||||||
$currentTime = date('H:i', strtotime('now' . ' +2 hours'));
|
|
||||||
|
|
||||||
if ($departureTime > $currentTime) {
|
|
||||||
if (!isset($directions[$direction])) {
|
if (!isset($directions[$direction])) {
|
||||||
$directions[$direction] = [];
|
$directions[$direction] = [];
|
||||||
}
|
}
|
||||||
|
|
@ -30,8 +28,6 @@ if (isset($data['Siri']['ServiceDelivery']['StopMonitoringDelivery'][0]['Monitor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$finalDirections = [];
|
$finalDirections = [];
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,9 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
$_SESSION['is_admin'] = $user['is_admin'];
|
$_SESSION['is_admin'] = $user['is_admin'];
|
||||||
header("Location: /");
|
header("Location: /");
|
||||||
|
|
||||||
$log = $conn->prepare("INSERT INTO logs (userId, date, ip) VALUES (:userId, :date, :ip)");
|
$log = $conn->prepare("INSERT INTO logs (userId, date) VALUES (:userId, :date)");
|
||||||
$log->bindParam(':userId', $user['id']);
|
$log->bindParam(':userId', $user['id']);
|
||||||
$log->bindParam(':date', date('Y-m-d-H-i-s'));
|
$log->bindParam(':date', date('Y-m-d-H-i-s'));
|
||||||
$log->bindParam(':ip', $_SERVER['REMOTE_ADDR']);
|
|
||||||
$log->execute();
|
$log->execute();
|
||||||
} else {
|
} else {
|
||||||
$errorMessage = "Invalid email or password.";
|
$errorMessage = "Invalid email or password.";
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||||
if (action === 'add') {
|
if (action === 'add') {
|
||||||
buttonElement.classList.remove('add-stop', 'btn-success');
|
buttonElement.classList.remove('add-stop', 'btn-success');
|
||||||
buttonElement.classList.add('remove-stop', 'btn-danger');
|
buttonElement.classList.add('remove-stop', 'btn-danger');
|
||||||
buttonElement.textContent = 'Revoke';
|
buttonElement.textContent = 'Retirer';
|
||||||
} else {
|
} else {
|
||||||
buttonElement.classList.remove('remove-stop', 'btn-danger');
|
buttonElement.classList.remove('remove-stop', 'btn-danger');
|
||||||
buttonElement.classList.add('add-stop', 'btn-success');
|
buttonElement.classList.add('add-stop', 'btn-success');
|
||||||
buttonElement.textContent = 'Add';
|
buttonElement.textContent = 'Ajouter';
|
||||||
}
|
}
|
||||||
buttonElement.removeEventListener('click', arguments.callee);
|
buttonElement.removeEventListener('click', arguments.callee);
|
||||||
buttonElement.addEventListener('click', arguments.callee);
|
buttonElement.addEventListener('click', arguments.callee);
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($errorMessage)) {
|
if (!isset($errorMessage)) {
|
||||||
try {
|
|
||||||
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
|
||||||
$query = $conn->prepare("INSERT INTO users (firstName, lastName, email, password) VALUES (:firstName, :lastName, :email, :password)");
|
$query = $conn->prepare("INSERT INTO users (firstName, lastName, email, password) VALUES (:firstName, :lastName, :email, :password)");
|
||||||
$query->bindParam(':firstName', $_POST['firstName']);
|
$query->bindParam(':firstName', $_POST['firstName']);
|
||||||
$query->bindParam(':lastName', $_POST['lastName']);
|
$query->bindParam(':lastName', $_POST['lastName']);
|
||||||
$query->bindParam(':email', $_POST['email']);
|
$query->bindParam(':email', $_POST['email']);
|
||||||
$query->bindParam(':password', $password);
|
$query->bindParam(':password', password_hash($_POST['password'], PASSWORD_DEFAULT));
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
$query = $conn->prepare("SELECT COUNT(*) as count FROM users");
|
$query = $conn->prepare("SELECT COUNT(*) as count FROM users");
|
||||||
|
|
@ -35,9 +33,6 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
|
|
||||||
header("Location: login.php");
|
header("Location: login.php");
|
||||||
exit();
|
exit();
|
||||||
} catch (PDOException $e) {
|
|
||||||
$errorMessage = "Please fill correct values";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Subway</title>
|
<title>Subway schedules</title>
|
||||||
<link rel="icon" href="assets/logo/favicon.png">
|
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||||
<?php
|
<?php
|
||||||
if (!isset($_SESSION['user_id'])) {
|
if (!isset($_SESSION['user_id'])) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
|
|
@ -11,17 +11,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['stopId'], $_POST['lin
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($action === 'add') {
|
if ($action === 'add') {
|
||||||
$query = $conn->prepare("SELECT * FROM favorites WHERE userId = ? AND stopId = ? AND lineId = ?");
|
$stmt = $conn->prepare("INSERT INTO favorites (userId, stopId, lineId) VALUES (?, ?, ?)");
|
||||||
$query->execute([$userId, $stopId, $lineId]);
|
$stmt->execute([$userId, $stopId, $lineId]);
|
||||||
$existingFavorite = $query->fetch();
|
|
||||||
|
|
||||||
if (!$existingFavorite) {
|
|
||||||
$query = $conn->prepare("INSERT INTO favorites (userId, stopId, lineId) VALUES (?, ?, ?)");
|
|
||||||
$query->execute([$userId, $stopId, $lineId]);
|
|
||||||
}
|
|
||||||
} elseif ($action === 'remove') {
|
} elseif ($action === 'remove') {
|
||||||
$query = $conn->prepare("DELETE FROM favorites WHERE userId = ? AND stopId = ? AND lineId = ?");
|
$stmt = $conn->prepare("DELETE FROM favorites WHERE userId = ? AND stopId = ? AND lineId = ?");
|
||||||
$query->execute([$userId, $stopId, $lineId]);
|
$stmt->execute([$userId, $stopId, $lineId]);
|
||||||
}
|
}
|
||||||
echo json_encode(['success' => true]);
|
echo json_encode(['success' => true]);
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,7 @@ try {
|
||||||
lastName VARCHAR(50) NOT NULL,
|
lastName VARCHAR(50) NOT NULL,
|
||||||
email VARCHAR(100) NOT NULL UNIQUE,
|
email VARCHAR(100) NOT NULL UNIQUE,
|
||||||
password VARCHAR(255) NOT NULL,
|
password VARCHAR(255) NOT NULL,
|
||||||
is_admin BOOLEAN NOT NULL DEFAULT 0,
|
is_admin BOOLEAN NOT NULL DEFAULT 0
|
||||||
CHECK (LENGTH(firstName) >= 2),
|
|
||||||
CHECK (LENGTH(lastName) >= 2),
|
|
||||||
CHECK (email REGEXP '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$')
|
|
||||||
)");
|
)");
|
||||||
|
|
||||||
$conn->exec("CREATE TABLE IF NOT EXISTS favorites (
|
$conn->exec("CREATE TABLE IF NOT EXISTS favorites (
|
||||||
|
|
@ -27,7 +24,6 @@ try {
|
||||||
$conn->exec("CREATE TABLE IF NOT EXISTS logs (
|
$conn->exec("CREATE TABLE IF NOT EXISTS logs (
|
||||||
userId INT NOT NULL,
|
userId INT NOT NULL,
|
||||||
date DATETIME NOT NULL,
|
date DATETIME NOT NULL,
|
||||||
ip VARCHAR(255) NOT NULL,
|
|
||||||
FOREIGN KEY (userId) REFERENCES users(id)
|
FOREIGN KEY (userId) REFERENCES users(id)
|
||||||
)");
|
)");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue