0% found this document useful (0 votes)
29 views

Index Ja Com As Paginas

This document contains PHP code for including CSS files and templates in the header section of a website. It also contains PHP code for checking if a user is logged in and displaying their username. The navigation bar includes links to different pages and options to add listings, view profile, or access the admin panel depending on the user type. On page load, it checks if a user is logged in and displays a welcome message.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Index Ja Com As Paginas

This document contains PHP code for including CSS files and templates in the header section of a website. It also contains PHP code for checking if a user is logged in and displaying their username. The navigation bar includes links to different pages and options to add listings, view profile, or access the admin panel depending on the user type. On page load, it checks if a user is logged in and displays a welcome message.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

<!

DOCTYPE html>
<html lang="en">

<?php
require_once ("connection/conn.php");
session_start();
?>

<head>

<?php include_once("./templates/csss.php"); ?>

<!-- Load fonts style after rendering the layout styles -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?
family=Roboto:wght@100;200;300;400;500;700;900&display=swap">
<link rel="stylesheet" href="assets/css/fontawesome.min.css">
<!--

balashna ba3d ma 3mlna include lal connection

-->
</head>

<body>
<!-- Start Top Nav -->
<?php include_once("./templates/topnav.php"); ?>
<!-- Close Top Nav -->

<!-- Header -->


<nav class="navbar navbar-expand-lg navbar-light shadow">
<div class="container d-flex justify-content-between align-
items-center">

<a class="navbar-brand text-success logo h1 align-self-


center" href="index.php" style="margin-right: 5% ;">
SpeedyBuy
</a>

<button class="navbar-toggler border-0" type="button" data-


bs-toggle="collapse" data-bs-target="#templatemo_main_nav" aria-
controls="navbarSupportedContent" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="align-self-center collapse navbar-collapse


flex-fill d-lg-flex justify-content-lg-between"
id="templatemo_main_nav">
<div class="flex-fill">
<ul class="nav navbar-nav d-flex justify-content-
between mx-lg-auto">
<li class="nav-item">
<a class="nav-link"
href="index.php">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">Sobre
Nós</a>
</li>
<li class="nav-item">
<a class="nav-link"
href="contact.php">Contacto</a>
</li>
<li class="nav-item">
<a class="nav-link"
href="formpage.php">Opiniões</a>
</li>
<li class="nav-item">
<a class="nav-link"
href="job.php">Contratamos</a>
</li>
</ul>
</div>
<div class="navbar align-self-center d-flex">

<div style="padding-left: 30px; padding-right: 5px;


padding-bottom:5px; padding-top: 5px ">
<?php
if(!isset($_SESSION['usernamelogin'])){
echo" <a class=button style=\"background-color:
#04aa6d; color: white;-webkit-appearance: button;-moz-appearance:
button;appearance: button;text-decoration: none;margin-left: 5px;
padding-left: 7px; padding-right: 7px; padding-bottom:5px; padding-top:
2px \" href=login.php>Login</a>";
echo" <a class=button style=\"background-color:
#04aa6d; color: white;-webkit-appearance: button;-moz-appearance:
button;appearance: button;text-decoration: none;margin-left: 5px;
padding-left: 7px; padding-right: 7px; padding-bottom:5px; padding-top:
2px \"href=register.php>Registrar</a>";
}
elseif (!isset($_SESSION['admin'])){

echo" <a class=button style=\"background-color:


#04aa6d; color: white;-webkit-appearance: button;-moz-appearance:
button;appearance: button;text-decoration: none;margin-left: 5px;
padding-left: 7px; padding-right: 7px; padding-bottom:5px; padding-top:
2px \"href=createads.php>Adicionar anuncio</a>";

echo" <a class=button style=\"background-color:


#04aa6d; color: white;-webkit-appearance: button;-moz-appearance:
button;appearance: button;text-decoration: none;margin-left: 5px;
padding-left: 7px; padding-right: 7px; padding-bottom:5px; padding-top:
2px \"href=myAccountInfos.php>Perfil</a>";

} else{
echo" <a class=button style=\"background-color:
#04aa6d; color: white;-webkit-appearance: button;-moz-appearance:
button;appearance: button;text-decoration: none;margin-left: 5px;
padding-left: 7px; padding-right: 7px; padding-bottom:5px; padding-top:
2px \"href=createads.php>Adicionar anuncio</a>";

echo" <a class=button style=\"background-color:


#04aa6d; color: white;-webkit-appearance: button;-moz-appearance:
button;appearance: button;text-decoration: none;margin-left: 5px;
padding-left: 7px; padding-right: 7px; padding-bottom:5px; padding-top:
2px \"href=myAccountInfos.php>Perfil</a>";
echo '<a class="button" href="admin/index.php"><i
class="fas fa-user-shield"></i></a>';
}

?>
</div>
</div>
</div>
</div>
</nav>
<!-- Close Header -->
<?php
if(!isset($_SESSION['usernamelogin'])){

}
else{
echo "<br>";
echo "<h2 style=\"color: #04aa6d; margin-left:10%;
allign:centre\">Bem vindo, ".$_SESSION['usernamelogin']."</h2>";
}

?>

<!-- Modal -->


<div class="modal fade bg-white" id="templatemo_search" tabindex="-
1" role="dialog" aria-labelledby="exampleModalLabel" aria-
hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="w-100 pt-1 mb-5 text-right">
<button type="button" class="btn-close" data-bs-
dismiss="modal" aria-label="Close"></button>
</div>
<form action="" method="get" class="modal-content modal-
body border-0 p-0">
<div class="input-group mb-2">
<input type="text" class="form-control"
id="inputModalSearch" name="q" placeholder="Search ...">
<button type="submit" class="input-group-text bg-
success text-light">
<i class="fa fa-fw fa-search text-white"></i>
</button>
</div>
</form>
</div>
</div>

<!-- Start Banner Hero -->


<div id="template-mo-zay-hero-carousel" class="carousel slide"
data-bs-ride="carousel">
<ol class="carousel-indicators">
<li data-bs-target="#template-mo-zay-hero-carousel" data-
bs-slide-to="0" class="active"></li>
<li data-bs-target="#template-mo-zay-hero-carousel" data-
bs-slide-to="1"></li>
<li data-bs-target="#template-mo-zay-hero-carousel" data-
bs-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<div class="container">
<div class="row p-5">
<div class="mx-auto col-md-8 col-lg-6 order-lg-
last">
<img class="img-fluid"
src="./assets/img/banner_img_01.jpg" alt="">
</div>
<div class="col-lg-6 mb-0 d-flex align-items-
center">
<div class="text-align-left align-self-
center">
<h1 class="h1 text-
success"><b>SpeedyBuy</b> Loja</h1>
<h3 class="h2">Sapatos para Homens e
Mulheres</h3>
<p>
SpeedyBuy é uma loja profissional
desenvolvida.
Para a venda e compra de bens em
segunda mão.
</p>
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container">
<div class="row p-5">
<div class="mx-auto col-md-8 col-lg-6 order-lg-
last">
<img class="img-fluid"
src="./assets/img/banner_img_02.jpg" alt="">
</div>
<div class="col-lg-6 mb-0 d-flex align-items-
center">
<div class="text-align-left">
<h1 class="h1">Produtos de
Qualidade</h1>
<h3 class="h2">Faça compras com
segurança</h3>
<p>
Loja Segura e confiavel, caso
encontre alguma anomalia contacto-nos imediatamente.
</p>
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="container">
<div class="row p-5">
<div class="mx-auto col-md-8 col-lg-6 order-lg-
last">
<img class="img-fluid"
src="./assets/img/banner_img_03.jpg" alt="">
</div>
<div class="col-lg-6 mb-0 d-flex align-items-
center">
<div class="text-align-left">
<h1 class="h1">Variedade de
produtos</h1>
<h3 class="h2">Nós temos a maior
variedade de produtos do mercado</h3>
<p>
Como nossa loja é feita por pessoas
fisicas a escala é infinita tendo dos mais variados produtos.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev text-decoration-none w-auto ps-
3" href="#template-mo-zay-hero-carousel" role="button" data-bs-
slide="prev">
<i class="fas fa-chevron-left"></i>
</a>
<a class="carousel-control-next text-decoration-none w-auto pe-
3" href="#template-mo-zay-hero-carousel" role="button" data-bs-
slide="next">
<i class="fas fa-chevron-right"></i>
</a>
</div>
<!-- End Banner Hero -->

<!-- Start Categories of The Month -->


<section class="container py-5">
<div class="row text-center pt-3">
<div class="col-lg-6 m-auto">
<h1 class="h1">Categorias</h1>
</div>
</div>
</section>

<!--//
searchPPPPPPPPPPPPPPPPPPPPHHHHHHHHHHHHHHHHHHHHHHHHHHHPPPPPPPPPPPPPPPPPP
PPPPPPPPP//////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//////////////////////////-->

<div class="container">
<div class="control d-flex justify-content-around">
<div class="search text-center">
<form method="get" action="index.php" class="">
<input type="button"
onclick="window.location.href='search.php'" class="btn clicksearch"
value="Pesquisa Avançada">
<select class="select" name="Maincategory">
<option value="" hidden="on">Categoria</option>
<?php
$result = mysqli_query($con, "SELECT CategoryID,
CategoryName FROM categories");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row["CategoryID"] . "'>" .
$row["CategoryName"] . "</option>";
}
?>
</select>
<input type="submit" class="btn clicksearch"
value="Pesquisar">
</form>
</div>
</div>
</div>
<!-- Ordenação dos Anúncios -->
<div class='container'>
<div class="btn-group btn-group-justified col-sm-12 m-2">
<a href="index.php?pricedp" class="btn btnselect ">Preço
minimo</a>
<a href="index.php?pricepd" class="btn btnselect ">Preço
maximo</a>
<a href="index.php?New" class="btn btnselect ">Recentes</a>
</div>
</div>

<!-- Anúncios -->


<section class="ads">
<div class="container">
<div class="row ">
<?php
$limit = 9; // Número de anúncios por página
$currentPage = isset($_GET['page']) ? $_GET['page']
: 1; // Página atual
$offset = ($currentPage - 1) * $limit; // Offset
para a consulta SQL

// Consulta para obter os anúncios


if (isset($_GET['pricedp'])) {
$result = mysqli_query($con, "SELECT * FROM
advertisments ORDER BY Price ASC LIMIT $offset, $limit");
} elseif (isset($_GET['pricepd'])) {
$result = mysqli_query($con, "SELECT * FROM
advertisments ORDER BY Price DESC LIMIT $offset, $limit");
} elseif (isset($_GET['New'])) {
$result = mysqli_query($con, "SELECT * FROM
advertisments ORDER BY Date DESC LIMIT $offset, $limit");
} elseif (isset($_GET['Maincategory']) &&
$_GET['Maincategory'] != 0) {
$categoryID = $_GET['Maincategory'];
$result = mysqli_query($con, "SELECT * FROM
advertisments, categories WHERE categories.CategoryID = $categoryID AND
advertisments.CategoryID = categories.CategoryID ORDER BY
advertisments.Details ASC LIMIT $offset, $limit");
} else {
$result = mysqli_query($con, "SELECT * FROM
advertisments ORDER BY Details ASC LIMIT $offset, $limit");
}

if (mysqli_num_rows($result) > 0) {
// Exibir os anúncios
while ($row = mysqli_fetch_assoc($result)) {
if ($row['status'] == 1 || isLogged() == 2) {
echo "<div class='col-md-4 col-sm-6'>
<div class='card'>
<img src='assets/img/{$row['Image']}'
class='card-img-top' alt='...'>
<span class='float-left'>{$row['Price']}
€</span>
<div class='card-body'>
<h5 class='card-
title'>{$row['Title']}</h5>
<p class='card-
text'>{$row['Details']}</p>
<a href='pageads.php?ADS-
ID={$row['AdsID']}' class='btn btn-primary'>Mais detalhes</a>";

if ($row['status'] == 1 && (isLogged() == 2))


{
echo "<a href='adsshoworhide.php?ADS-
ID={$row['AdsID']}' class='btn btn-danger ml-2'>Hide</a>";
} elseif ($row['status'] == 0 && (isLogged()
== 2)) {
echo "<a href='adsshoworhide.php?ADS-
ID={$row['AdsID']}' class='btn btn-primary ml-2'>Show</a>";
}

echo "</div>
</div>
</div>";
}
}
} else {
outputMessage("Não foram encontrados anúncios no
nosso catálogo", 'warning');
}

function isLogged()
{
if (isset($_SESSION['usernamelogin'])) {
// Usuário logado
return 1;
} elseif (isset($_SESSION['admin_id'])) {
// Logado como administrador
return 2;
} else {
// Não logado
return 3;
}
}

function outputMessage($message = '', $type =


'success')
{
echo "<div class='alert alert-
{$type}'>{$message}</div>";
}
?>

</div>
<!-- Paginação -->
<div class="row mt-4">
<div class="col-12 text-center">
<?php
// Cálculo do número total de páginas
$totalPages = ceil(mysqli_num_rows(mysqli_query($con,
"SELECT * FROM advertisments")) / $limit);

// Verificar se há páginas anteriores


$prevPage = $currentPage - 1;
if ($prevPage >= 1) {
echo "<a href='index.php?page=$prevPage' class='btn btn-
primary mr-2'>Página Anterior</a>";
}

// Verificar se há páginas seguintes


$nextPage = $currentPage + 1;
if ($nextPage <= $totalPages) {
echo "<a href='index.php?page=$nextPage' class='btn btn-
primary'>Próxima Página</a>";
}
?>
</div>
</div>
</div>
</section>
<!--///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//////////////////////////////////////////-->

<!-- End Categories -->

<!-- Start Featured Product -->

<!-- Anúncios de Hoje -->


<section class="ads">
<div class="container">
<div class="row text-center py-3">
<div class="col-lg-6 m-auto">
<h1 class="h1">Anúncios de Hoje</h1>
</div>
</div>
<div class="row">
<?php
$today = date("Y-m-d");
$res1 = mysqli_query($con, "SELECT * FROM `advertisments`
WHERE Date = '$today' ORDER BY Price LIMIT 9");

if (mysqli_num_rows($res1) > 0) {
// Exibir os anúncios de hoje
while ($row = mysqli_fetch_assoc($res1)) {
if ($row['status'] == 1 || isLogged() == 2) {
echo "<div class='col-md-4 col-sm-6'>
<div class='card'>
<img src='assets/img/{$row['Image']}' class='card-
img-top' alt='...'>
<span class='float-left'>{$row['Price']} €</span>
<div class='card-body'>
<h5 class='card-title'>{$row['Title']}</h5>
<p class='card-text'>{$row['Details']}</p>
<a href='pageads.php?ADS-ID={$row['AdsID']}'
class='btn btn-primary'>Mais detalhes</a>";

if ($row['status'] == 1 && (isLogged() == 2)) {


echo "<a href='adsshoworhide.php?ADS-
ID={$row['AdsID']}' class='btn btn-danger ml-2'>Hide</a>";
} elseif ($row['status'] == 0 && (isLogged() == 2)) {
echo "<a href='adsshoworhide.php?ADS-
ID={$row['AdsID']}' class='btn btn-primary ml-2'>Show</a>";
}

echo "</div>
</div>
</div>";
}
}
} else {
outputMessage("Não foram encontrados anúncios para hoje",
'warning');
}
?>

</div>
</div>
</section>

<!-- End Featured Product -->


<?php include_once("footer.php"); ?>

<!-- Start Script -->


<script src="assets/js/jquery-1.11.0.min.js"></script>
<script src="assets/js/jquery-migrate-1.2.1.min.js"></script>
<script src="assets/js/bootstrap.bundle.min.js"></script>
<script src="assets/js/templatemo.js"></script>
<script src="assets/js/custom.js"></script>
<!-- End Script -->
</body>

</html>

You might also like