Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions plataforma/painel/config2/add.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
ob_start();
include_once $_SERVER['DOCUMENT_ROOT'] . '/plataforma/panel/is_logged.php';
$session_info = ob_get_clean();
include 'conexao.php';

// Check if the form is submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Retrieve the form data
$name = $_POST['name'];
$link = $_POST['link'];

// Check if checkboxes are set, assign 0 if not
$guest = isset($_POST['guest']) ? 1 : 0;
$trainee = isset($_POST['trainee']) ? 1 : 0;
$admin = isset($_POST['admin']) ? 1 : 0;
$root = isset($_POST['root']) ? 1 : 0;
$office = isset($_POST['office']) ? 1 : 0;
$block = isset($_POST['block']) ? 1 : 0;

// Prepare SQL query to insert the data into the database
$sql = "INSERT INTO granna80_bdlinks.user_permissions (name, link, guest, trainee, admin, root, office, block)
VALUES ('$name', '$link', '$guest', '$trainee', '$admin', '$root', '$office', '$block')";

// Execute the query
if (mysqli_query($conn, $sql)) {
echo "Record added successfully!";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

// Close the database connection
mysqli_close($conn);
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Record</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header-container">
<div class="session-info"><?php echo $session_info; ?></div>
</div>

<div class="form-container">
<h1>Add New Record</h1>
<form action="add.php" method="POST">
<label>Name:</label>
<input type="text" name="name" required>

<label>Link:</label>
<input type="text" name="link" required>

<div class="checkbox-group" style="text-align: left; margin-bottom: 20px;">
<label>Permissions:</label>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px;">
<label style="font-weight: normal;"><input type="checkbox" name="guest"> Guest</label>
<label style="font-weight: normal;"><input type="checkbox" name="trainee"> Trainee</label>
<label style="font-weight: normal;"><input type="checkbox" name="admin"> Admin</label>
<label style="font-weight: normal;"><input type="checkbox" name="root"> Root</label>
<label style="font-weight: normal;"><input type="checkbox" name="office"> Office</label>
<label style="font-weight: normal;"><input type="checkbox" name="block"> Block</label>
</div>
</div>

<button type="submit">Add Record</button>
</form>
</div>

<div style="text-align: center; margin-top: 20px;">
<a href="index.php">[ Back to Permissions ]</a>
</div>
</body>
</html>
71 changes: 71 additions & 0 deletions plataforma/painel/config2/add_submenu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
ob_start();
include_once $_SERVER['DOCUMENT_ROOT'] . '/plataforma/panel/is_logged.php';
$session_info = ob_get_clean();
include 'conexao.php';

// Get parent_id from URL
if (!isset($_GET['parent_id']) || !is_numeric($_GET['parent_id'])) {
die("Invalid parent ID");
}
$parent_id = intval($_GET['parent_id']);

// Fetch parent name
$query = "SELECT name FROM granna80_bdlinks.user_permissions WHERE id = $parent_id";
$result = mysqli_query($conn, $query);
$parent = mysqli_fetch_assoc($result);
if (!$parent) {
die("Parent ID not found");
}

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = mysqli_real_escape_string($conn, $_POST['name']);
$link = mysqli_real_escape_string($conn, $_POST['link']);

if (!empty($name) && !empty($link)) {
$insertQuery = "INSERT INTO granna80_bdlinks.submenus (parent_id, name, link) VALUES ($parent_id, '$name', '$link')";
if (mysqli_query($conn, $insertQuery)) {
echo "<script>window.location.href='index.php';</script>";
exit();
} else {
echo "Error: " . mysqli_error($conn);
}
} else {
echo "<p style='color: red;'>Please fill all fields.</p>";
}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Submenu</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header-container">
<div class="session-info"><?php echo $session_info; ?></div>
</div>

<div class="form-container">
<h1>Add Submenu for <?php echo htmlspecialchars($parent['name']); ?></h1>
<form action="add_submenu.php?parent_id=<?php echo $parent_id; ?>" method="POST">
<label for="name">Submenu Name:</label>
<input type="text" id="name" name="name" required>

<label for="link">Submenu Link:</label>
<input type="text" id="link" name="link" required>

<button type="submit">Add Submenu</button>
</form>
</div>
<div style="text-align: center;">
<a href="index.php">[ Back to Permissions ]</a>
</div>
</body>
</html>

<?php mysqli_close($conn); ?>
9 changes: 9 additions & 0 deletions plataforma/painel/config2/all.min.css

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions plataforma/painel/config2/component-links.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php
ob_start();
include_once $_SERVER['DOCUMENT_ROOT'] . '/plataforma/panel/is_logged.php';
$session_info = ob_get_clean();
include 'conexao.php';

function getLinkFromDatabase($conn) {
$sql = "SELECT * FROM granna80_bdlinks.back_link_menu LIMIT 1";
$result = $conn->query($sql);
if ($result && $result->num_rows > 0) {
return $result->fetch_assoc();
}
return null;
}

$linkData = getLinkFromDatabase($conn);
$linkExists = !is_null($linkData);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$linkUrl = $conn->real_escape_string($_POST['link_url']);
$description = $conn->real_escape_string($_POST['description']);

if ($linkExists) {
$sql = "UPDATE granna80_bdlinks.back_link_menu SET link_url = '$linkUrl', description = '$description' WHERE id = {$linkData['id']}";
} else {
$sql = "INSERT INTO granna80_bdlinks.back_link_menu (link_url, description) VALUES ('$linkUrl', '$description')";
}

if ($conn->query($sql)) {
header("Location: index.php");
exit();
} else {
echo "<p>Error: " . $conn->error . "</p>";
}
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Back Button Link Manager</title>
<link rel="stylesheet" href="all.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header-container">
<div class="session-info"><?php echo $session_info; ?></div>
</div>

<h1>Back Button Link Manager</h1>

<div style="text-align: center; margin-bottom: 20px;">
<a href="index.php">[ Back to List ]</a>
</div>

<form method="POST" action="">
<label for="link_url">Link URL:</label>
<input type="text" id="link_url" name="link_url" value="<?php echo $linkExists ? $linkData['link_url'] : ''; ?>" required>

<label for="description">Description:</label>
<textarea id="description" name="description"><?php echo $linkExists ? $linkData['description'] : ''; ?></textarea>

<div class="button-container" style="justify-content: flex-start;">
<button type="submit" class="btn">
<?php echo $linkExists ? 'Update Link' : 'Register Link'; ?>
</button>
</div>
</form>

<h2 style="margin-top: 30px;">Registered Links</h2>
<div id="linkTable">
<?php if ($linkExists): ?>
<table>
<thead>
<tr>
<th>ID</th>
<th>URL</th>
<th>Description</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo $linkData['id']; ?></td>
<td><a href="<?php echo $linkData['link_url']; ?>" target="_blank"><?php echo $linkData['link_url']; ?></a></td>
<td><?php echo $linkData['description']; ?></td>
<td><?php echo $linkData['created_at']; ?></td>
</tr>
</tbody>
</table>
<?php else: ?>
<p>No links registered yet.</p>
<?php endif; ?>
</div>
</body>
</html>
Loading