Skip to content

Commit

Permalink
merge conlifct
Browse files Browse the repository at this point in the history
  • Loading branch information
Eneuem committed Dec 8, 2023
2 parents e709329 + 7d6cdc9 commit 1c98885
Show file tree
Hide file tree
Showing 28 changed files with 828 additions and 146 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"php.version": "8.3"
{
"php.version": "8.3"
}
18 changes: 11 additions & 7 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
if (!isset($_SESSION)) {
session_start();
}
var_dump($_SESSION);
// Vérifier l'ID de l'utilisateur

$userLoggedIn = isset($_SESSION['userid']) && $_SESSION['userid'] !== null;
Expand Down Expand Up @@ -77,6 +78,15 @@
<path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z"></path>
</svg>
</div>
<div id="userMenu" class="hidden absolute right-0 top-10 py-2 w-48 bg-white rounded-md shadow-xl z-20">
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">PROFILE</a>

<?php if (isset($_SESSION['user_power']) && $_SESSION['user_power'] != 0) : ?>
<a href="php_bo/main.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">SUPER-ADMIN</a>
<?php endif; ?>

<a href="php/logout.php" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">LOGOUT</a>
</div>
</div>
</div>

Expand Down Expand Up @@ -120,16 +130,10 @@
</div>
</div>
</section>



</div>




<?php include("js/header_script.php"); ?>



<script src="php-recherche/script.js"></script>
<script src="php-recherche/script.js"></script>
106 changes: 83 additions & 23 deletions js/header_script.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,86 @@
var userNameM = document.getElementById('userName-mobile');
var userIconM = document.getElementById('userIcon-mobile');

if (userLoggedIn) {
// Si l'utilisateur est connecté
loginBtn.style.display = 'none';
signupBtn.style.display = 'none';
userName.style.display = 'block';
userIcon.style.display = 'block';
loginBtnM.style.display = 'none';
signupBtnM.style.display = 'none';
userNameM.style.display = 'block';
userIconM.style.display = 'block';
} else {
// Si l'utilisateur n'est pas connecté
loginBtn.style.display = 'block';
signupBtn.style.display = 'block';
userName.style.display = 'none';
userIcon.style.display = 'none';
loginBtnM.style.display = 'block';
signupBtnM.style.display = 'block';
userNameM.style.display = 'none';
userIconM.style.display = 'none';
}
});
</script>
if (userLoggedIn) {
// Si l'utilisateur est connecté
loginBtn.style.display = 'none';
signupBtn.style.display = 'none';
userName.style.display = 'block';
userIcon.style.display = 'block';
loginBtnM.style.display = 'none';
signupBtnM.style.display = 'none';
userNameM.style.display = 'block';
userIconM.style.display = 'block';
} else {
// Si l'utilisateur n'est pas connecté
loginBtn.style.display = 'block';
signupBtn.style.display = 'block';
userName.style.display = 'none';
userIcon.style.display = 'none';
loginBtnM.style.display = 'block';
signupBtnM.style.display = 'block';
userNameM.style.display = 'none';
userIconM.style.display = 'none';
}
});

// Ajouter l'événement de clic
document.addEventListener('DOMContentLoaded', (event) => {
var userName = document.getElementById('userName');
var userMenu = document.getElementById('userMenu');

userName.addEventListener('click', function() {
userMenu.classList.toggle('hidden');
});
});



window.addEventListener('click', function(event) {
if (!userMenu.contains(event.target) && event.target !== userName) {
userMenu.classList.add('hidden');
}
});

const btn = document.getElementById("menu-btn");
const menu = document.getElementById("menu");

btn.addEventListener("click", navToggle);

// Toggle Mobile Menu
function navToggle() {
btn.classList.toggle("open");
menu.classList.toggle("flex");
menu.classList.toggle("hidden");
}

$(document).ready(function() {
// Attachez un gestionnaire d'événements au champ de recherche
$("#search").on("input", function() {
// Obtenez la valeur du champ de recherche
var query = $(this).val();

// Vérifiez si la valeur est vide
if (query === "") {
$("#searchResults").empty();
} else {
// Utilisez Ajax pour interroger l'API et obtenir les suggestions
$.ajax({
url: "suggest.php", // Créez un fichier PHP pour gérer les suggestions
type: "GET",
data: { search: query },
success: function(data) {
// Mettez à jour la liste des suggestions
$("#searchResults").html(data);
}
});
}
});
});






</script>
45 changes: 45 additions & 0 deletions js/signup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function nextStep(step) {
document.querySelectorAll('.step').forEach(function(div) {
div.classList.add('hidden');
});
document.getElementById('step' + step).classList.remove('hidden');

if (step === 3) {
document.getElementById('displayLogin').textContent = document.getElementById('username').value;
document.getElementById('displayEmail').textContent = document.getElementById('email').value;
}
}

document.getElementById('registrationForm').addEventListener('submit', function(event) {
event.preventDefault();

var username = document.getElementById('username').value;
var email = document.getElementById('email').value;
var password = document.getElementById('password').value;

var formData = new FormData();
formData.append('register', '1'); // Ajouter 'register'
formData.append('userpower', '0'); // Ajouter 'register'
formData.append('username', username);
formData.append('email', email);
formData.append('password', password);

fetch('php/inscription.php', {
method: 'POST',
body: formData
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.text();
})
.then(data => {
console.log('Success:', data); // Utiliser console.log pour voir la réponse du serveur
alert('Response from server: ' + data); // Afficher la réponse du serveur
})
.catch(error => {
console.error('Error:', error);
alert('Error submitting form: ' + error.message);
});
});
6 changes: 0 additions & 6 deletions php-co/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@
$logout_button = ''; // Pas de bouton de déconnexion si l'utilisateur n'est pas connecté
}

// Formulaire d'inscription
include 'inscription.php';

// Formulaire de connexion
include 'connexion.php';


?>

Expand Down
14 changes: 4 additions & 10 deletions php-recherche/dbconnect.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?php
define('HOST', 'localhost');
define('DB_NAME', 'Connexion');
define('DB_NAME', 'test');
define('USER', 'root');
define('PASS', 'root');
define('PASS', 'Quadrastream1!');


try {
// Création de l'objet de connexion PDO
$pdo = new PDO("mysql:host=" . HOST . ";dbname=" . DB_NAME, USER, PASS);
// Configuration pour afficher les erreurs PDO
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
// Afficher l'erreur
echo "Erreur de connexion à la base de données : " . $e->getMessage();
// Arrêter l'exécution du script
die();
}
?>

} catch (PDOException $e) {}

?>
24 changes: 24 additions & 0 deletions php-recherche/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$(document).ready(function() {
// Attachez un gestionnaire d'événements au champ de recherche
$("#search").on("input", function() {
// Obtenez la valeur du champ de recherche
var query = $(this).val();

// Vérifiez si la valeur est vide
if (query === "") {
$("#searchResults").empty();
} else {
// Utilisez Ajax pour interroger l'API et obtenir les suggestions
$.ajax({
url: "../suggest.php", // Créez un fichier PHP pour gérer les suggestions
type: "GET",
data: { search: query },
success: function(data) {
// Mettez à jour la liste des suggestions
$("#searchResults").html(data);
}
});
}
});
});

5 changes: 0 additions & 5 deletions action.php → php/comp/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
<script src="js/script.js" defer></script>
<!-- Hero Container -->
<div class="container max-w-6xl mx-auto px-6 py-12">
</div>
</section>

<!-- Gallery Container -->
<div class="gap-4 grid p-4 sm:grid-cols-3 md:grid-cols- lg:grid-cols-4 xl:grid-cols-6 bg-black">
<!-- Image 1 -->
Expand Down
10 changes: 10 additions & 0 deletions php/comp/cta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<section class="bg-yellow-400 rounded-xl">
<div class="py-4 px-2 mx-auto max-w-screen-xl sm:py-16 lg:px-6">
<div class="mx-auto max-w-screen-sm text-center">
<h2 class="mb-4 text-4xl tracking-tight font-extrabold leading-tight text-gray-900 ">Start your free trial today</h2>
<p class="mb-6 text-white md:text-lg">Try quadra streaming for 30 days free. No credit card required.</p>
<a href="#" class="text-yellow-400 bg-blue-800 hover:opacity-70 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mb-2 ">Free trial for 30 days</a>
</div>
</div>
</section>
5 changes: 3 additions & 2 deletions php/inscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

if ($insert) {
echo "Inscription réussie.";

// Stockez des informations sur l'utilisateur dans la session
$_SESSION['user_id'] = $pdo->lastInsertId();
$_SESSION['userid'] = $pdo->lastInsertId();
$_SESSION['username'] = $pseudo;
$_SESSION['email'] = $email;
header("Location: ../index.php");
} else {
echo "Erreur lors de l'inscription.";
}
Expand Down
28 changes: 15 additions & 13 deletions php/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,46 @@

if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// Si déjà connecté, redirigez vers une autre page (comme le tableau de bord)
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
header("Location: acc_admin.php");
}

// Si déjà connecté, redirigez vers une autre page (comme le tableau de bord)
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true) {
header("Location: ../index.php");
exit;
}
}

require 'db_connect.php'; // Inclure db_connect.php


if (isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];


// Modifier ici pour inclure user_power dans la requête
$query = "SELECT * FROM users WHERE username = ?";
$stmt = $pdo->prepare($query);
$stmt = $pdo->prepare($query);
$stmt->bindParam(1, $username);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);

if ($user && password_verify($password, $user['password'])) {
$_SESSION['loggedin'] = true;
$_SESSION['userid'] = $user['id'];
$_SESSION['userid'] = $user['id'];
$_SESSION['username'] = $user['username'];


// Ajouter user_power à la session
$_SESSION['user_power'] = $user['user_power'];

// Redirection vers index.php
header("Location: ../index.php");
exit;
} else {
$error_message = "Nom d'utilisateur ou mot de passe incorrect";
}
}
}


?>


<div class="mt-3 text-center">
<h1 class="text-lg leading-6 font-medium text-gray-900">Se connecter</h1>
<div class="mt-2 px-7 py-3">
Expand Down
2 changes: 2 additions & 0 deletions php/page_main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php include 'php/comp/cta.php'; ?>
<?php include 'php/comp/action.php'; ?>
Loading

0 comments on commit 1c98885

Please sign in to comment.