Woooh, plein de nouveaux fichiers. Ajout des discussions avec des jolies classes.

This commit is contained in:
Mysaa
2021-06-05 20:09:07 +02:00
parent 20a9f135e7
commit 2ea296cd61
52 changed files with 7560 additions and 658 deletions
+23 -1
View File
@@ -9,4 +9,26 @@
</div>
<a href="" id="haut_de_page">Haut de page</a>
</footer>
</footer>
<?php
if(isset($_SESSION['current_error'])){
?>
<div class="fullscreen opaque">
<div class="screen-vertical-centered">
<div class="screen-horizontal-centered"><?php echo $_SESSION['current_error'];?></div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$('.fullscreen').on('click',function(){
$('.fullscreen').animate({opacity:0},1000,function(){
$('.fullscreen').css('display','none');
});
});
</script>
<?php
unset($_SESSION['current_error']);
}
?>
+30 -16
View File
@@ -1,13 +1,25 @@
<header>
<?php include_once('includes/bdd.php');
$req = $bdd->prepare('SELECT * FROM users WHERE ID=? AND mdp=?');
if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp'])){
$req->execute(array($_SESSION['session_id'],$_SESSION['session_mdp']));
$rep = $req->fetch();
}if(isset($_SESSION['session_id']) && isset($_SESSION['session_mdp']) && isset($rep['pseudo']) ){
<!--
000000000000000800000000000000000000000000000000000000000000000000000
000000000000008000000000000000000000000000000000000000000000000000000
000000000000080000000000000888000000000000000000000000000000000000000
000000000000800000000000088000880000000000000000000000000000000000000
000000000008008000000000000000080000000000000000000000000000000000000
000000000080008000000000000000800000000000000000000000000000000000000
000000000888888888000000000008000000000000000000000000000000000000000
000000000000008000000000000080000000000000000000000000000000000000000
000000000000008000000000000800000000000000000000000000000000000000000
000000000000008000000000088888880000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000
-->
<?php
include_once('includes/inter.php');
if(isConnected()){
?>
<div id="bienvenue">Bienvenue &agrave; toi ,<?php echo $rep['pseudo']; ?>
<div id="bienvenue">Bienvenue &agrave; toi, <?php echo getPseudo(); ?>
<form id="headDisconnectForm" method="post" action="disconnect.php">
<input type="submit" value="Se d&eacute;connecter" />
</form>
@@ -17,24 +29,26 @@
<form id="headLoginForm" method="post" action="logging.php">
<label for="pseudo">Pseudo :</label>
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" required />
<input type="text" name="pseudo" id="pseudo" placeholder="Ex:Bernard" />
<label for="mdp">Mot de passe :</label>
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" required />
<input type="Submit" value="Se connecter" />
<input type="password" name="mdp" id="mdp" placeholder="Votre mot de passe" />
<input type="submit" value="Se connecter" />
</form>
<form id="headLittleLoginForm" method="post" action="login.php">
<input type="submit" value="Se connecter" />
</form>
<form id="headRegisterForm" method="post" action="register.php">
<input type="submit" value="S'inscrire" />
<br/>
</form>
<?php } ?>
<img id="bande" src="pictures/bande.png" alt="Erreur d'affichage de l'image" />
<img id="bande" src="pictures/<?php if(rand()*31415 < 110*42)echo "lucas_president.png";else echo "bande.png";?>" alt="Erreur d'affichage de l'image" width=1000 height="89" />
<nav id="navLinks">
<a href="index.php">Acceuil</a><br class="navV"/>
<a href="index.php">Accueil</a><br class="navV"/>
<a href="projets.php">Mes Projets</a><br class="nav2x2"/>
<a href="others.php">Tous les projets</a><br class="navV"/>
<a href="discuts.php">Discussions</a><br class="navV"/>
<a href="profile.php">Mon profil</a><br class="navV"/>
</nav>
</header>
</header>
+297 -16
View File
@@ -1,32 +1,123 @@
<?php
include_once 'includes/bdd.php';
function isConnected2S($username, $mdp) {
$req = $bdd->prepare ( 'SELECT * FROM users WHERE ID=? AND mdp=?' );
function isConnected($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$username,
$mdp
$sid
) );
return ( bool ) $req->fetch ();
if ($rep = $req->fetch ()) {
$connected = password_verify ( $mdp, $rep ['mdp'] );
} else {
$connected = FALSE;
}
$req->closeCursor ();
return $connected;
}
function isConnected() {
return isConnected2S ( $_SESSION ['session_id'], $_SESSION ['session_mdp'] );
}
function getProjectVersionDataFromIDs($project, $version) {
$req = $bdd->prepare ( 'SELECT p.ID AS pID , ' . 'v.versionAbs AS versionAbs , ' . 'p.name AS name , ' . 'v.version AS version , ' . 'v.language AS language , ' . 'p.permissions AS permissions , ' . 'p.ownersID AS owners ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE v.project_id LIKE = ? AND v.versionAbs = ?' );
function getAdminLevel($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return - 1;
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$_GET ['id'],
$_GET ['v']
$sid
) );
if ($result = $req->fetch ()) {
$adminLevel = $result ['administration'];
} else {
$adminLevel = - 1;
}
$req->closeCursor ();
return intval($adminLevel);
}
function getPseudo($sid = NULL, $mdp = NULL) {
if (! isset ( $sid ) or ! isset ( $mdp )) {
$sid = $_SESSION ['session_id'];
$mdp = $_SESSION ['session_mdp'];
}
if (! isConnected ( $sid, $mdp ))
return "neant";
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function getPseudoOf($sid) {
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE ID=?' );
$req->execute ( array (
$sid
) );
$pseudo = $req->fetch () ['pseudo'];
$req->closeCursor ();
return $pseudo;
}
function tryToConnect($pseudo = NULL, $mdp = NULL) {
if (! isset ( $pseudo ) or ! isset ( $mdp )) {
$pseudo = $_POST ['pseudo'];
$mdp = $_POST ['mdp'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT * FROM users WHERE pseudo=?' );
$req->execute ( array (
$pseudo
) );
$reponce = $req->fetch ();
if ($reponce != NULL) {
if (password_verify ( $mdp, $reponce ['mdp'] )) {
$req->closeCursor ();
return $reponce ['ID'];
} else {
$req->closeCursor ();
return 'errormdp';
}
} else {
$req->closeCursor ();
return 'errorpseudo';
}
}
function getProjectVersionData($project = NULL, $version = NULL) {
if (! isset ( $project ) or ! isset ( $version )) {
$project = $_GET ['id'];
$version = $_GET ['v'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS pID ,' . ' ' . 'v.versionAbs AS versionAbs , ' . ' ' . 'p.name AS name ,' . ' ' . 'v.version AS version ,' . ' ' . 'v.language AS language ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'INNER JOIN versions AS v' . ' ' . 'ON v.project_id = p.ID' . ' ' . 'WHERE v.project_id = ? AND v.versionAbs = ?' );
$req->execute ( array (
$project,
$version
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getProjectVersionData() {
return getProjectVersionDataFromIds ( $_GET ['id'], $_GET ['v'] );
function getProjectData($project = NULL) {
if (! isset ( $project )) {
$project = $_GET ['id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'SELECT p.ID AS ID ,' . ' ' . 'p.name AS name ,' . ' ' . 'p.permissions AS permissions ,' . ' ' . 'p.ownersID AS owners' . ' ' . 'FROM projets AS p' . ' ' . 'WHERE p.ID = ?' );
$req->execute ( array (
$project
) );
if (($data = $req->fetch ())) {
$req->closeCursor ();
return $data;
} else {
$req->closeCursor ();
return NULL;
}
}
function getPermissionsFromData($data) {
function getPermissions($data) {
$permissions = array (
FALSE,
FALSE,
@@ -37,6 +128,196 @@ function getPermissionsFromData($data) {
$permissions [1] = preg_match ( '#^(0|1)1#', $data ['permissions'] );
$permissions [2] = preg_match ( '#^(0|1){2}1#', $data ['permissions'] );
$permissions [3] = preg_match ( '#^(0|1){3}1#', $data ['permissions'] );
return $permissions;
}
function getProjectsWithFirstPermission() {
$requete = 'SELECT p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.permissions LIKE "1%" ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
$req->closeCursor ();
return $projects;
}
function getVersions($pid = NULL) {
if (! isset ( $pid )) {
$pid = $_GET ['id'];
}
$requete = 'SELECT * FROM versions WHERE project_id = ?';
$req = $GLOBALS ['bdd']->prepare ( $requete );
$req->execute ( array (
$pid
) );
// ADDPOINT langage
$versions = array (
array (),
array ()
);
while ( $rep = $req->fetch () ) {
$versions [$rep ['language']] [] = array (
'versionAbs' => $rep ['versionAbs'],
'versionName' => $rep ['version']
);
}
$req->closeCursor ();
return $versions;
}
function getOwnersisProjects($sid = NULL) {
if (! isset ( $sid )) {
$sid = $_SESSION ['session_id'];
}
$requete = 'SELECT p.ownersID AS ownersID , p.ID AS projectID , v.versionAbs AS versionAbs , p.name AS projectName , v.version AS versionName ' . 'FROM projets AS p ' . 'INNER JOIN versions AS v ' . 'ON v.project_id = p.ID ' . 'WHERE p.ownersID REGEXP \'[^0-9]?' . $sid . '[^0-9]?\' ';
$req = $GLOBALS ['bdd']->query ( $requete );
$projects = array ();
while ( $rep = $req->fetch () ) {
if (! isset ( $projects [$rep ['projectID']] )) {
$projects [$rep ['projectID']] = $rep;
} else if ($projects [$rep ['projectID']] ['versionAbs'] < $rep ['versionAbs']) {
$projects [$rep ['projectID']] = $rep;
}
}
return $projects;
}
function registerPerson($pseudo, $mdp) {
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM users WHERE pseudo=?" );
$req->execute ( array (
$_POST ['pseudo']
) );
if ($req->fetch ()) {
return 'usedPseudo';
} else {
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO users(pseudo,mdp,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$_POST ['pseudo'],
password_hash ( $_POST ['mdp'], PASSWORD_DEFAULT )
) );
return 'ok';
}
}
function getMessages($discut = NULL) {
if (! isset ( $discut )) {
$discut = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE discussion_id=? ORDER BY sendTime DESC" );
$req->execute ( array (
$discut
) );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 0)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscuts() {
$req = $GLOBALS ['bdd']->query ( "SELECT * FROM discussions ORDER BY date_creation DESC" );
$rep = array ();
while ( $rep [] = $req->fetch () )
;
if (count ( $rep ) <= 1)
$rep = NULL;
$req->closeCursor ();
return array_slice ( $rep, 0, - 1, TRUE );
}
function getDiscutInfos($did = NULL) {
if (! isset ( $did )) {
$did = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM discussions WHERE ID=?" );
$req->execute ( array (
$did
) );
return $req->fetch ();
}
function sendMessage($discut = NULL, $text = NULL, $sender = NULL) {
if (! isset ( $discut ) || ! isset ( $text ) || ! isset ( $sender )) {
$discut = $_GET ['d'];
$text = $_POST ['msg'];
$sender = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO messages(discussion_id,texte,senderID,sendTime) VALUES (?,?,?,NOW())' );
$req->execute ( array (
$discut,
htmlspecialchars ( $text ),
$sender
) );
return 'ok';
}
function createDiscut($name = NULL, $owner = NULL) {
if (! isset ( $name ) || ! isset ( $owner )) {
$name = $_POST ['name'];
$owner = $_SESSION ['session_id'];
}
$req = $GLOBALS ['bdd']->prepare ( 'INSERT INTO discussions(name,creator_id,date_creation) VALUES (?,?,NOW())' );
$req->execute ( array (
$name,
$owner
) );
return 'ok';
}
function testInt($var, $errorLocation = NULL) {
if (preg_match ( '#^[0-9]+$#', $var )) {
return intval ( $var );
} else {
if (isset ( $errorLocation )) {
header ( 'Location:' + $errorLocation );
exit ();
}
return null;
}
}
function getMessage($m = NULL) {
if (! isset ( $m )) {
$m = $_GET ['m'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM messages WHERE ID=?" );
$req->execute ( array (
$m
) );
if ($rep = $req->fetch ())
return $rep;
return - 1;
}
function removeMessage($m = NULL) {
if (! isset ( $m )) {
$m = $_GET ['m'];
}
$req = $GLOBALS ['bdd']->prepare ( "DELETE FROM messages WHERE ID=?" );
$req->execute ( array (
$m
) );
}
function changePassword($oldPassword = NULL, $newPassword = NULL, $newPasswordBis = NULL) {
if (! isset ( $oldPassword ) || ! isset ( $newPassword ) || ! isset ( $newPasswordBis )) {
$oldPassword = $_POST ['rmdp'];
$newPassword = $_POST ['nmdp'];
$newPasswordBis = $_POST ['nmdp2'];
}
if(!isConnected($_SESSION['session_id'],$oldPassword))
return 'falsePassword';
if($newPassword != $newPasswordBis)
return 'passwordMissmatch';
$req = $GLOBALS['bdd']->prepare('UPDATE users SET mdp=? WHERE ID=?');
$req->execute(array(password_hash ( $newPassword, PASSWORD_DEFAULT ),$_SESSION['session_id']));
return true;
}
function discutExists($did = NULL) {
if (! isset ( $did )) {
$did = $_GET ['d'];
}
$req = $GLOBALS ['bdd']->prepare ( "SELECT * FROM discussions WHERE ID=?" );
$req->execute ( array (
$did
) );
return $req->fetch();
}
?>
+14 -6
View File
@@ -1,11 +1,19 @@
<title>Le site de tous les bernards !</title>
<meta charset="utf-8" />
<meta name="keywords" lang="fr" content="cercloid officiel, zx project" />
<meta name="keywords" lang="fr" content="cercloid officiel, zeidhyx project" />
<meta name="viewport" content="width=device-width" />
<link rel="stylesheet" href="css/style.css" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
<script type="text/x-mathjax-config"> MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}}); </script>
<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML"> </script>
<script type="text/javascript">
var link = document.createElement( "link" );
link.type = "text/css";
link.rel = "stylesheet";
link.media = "screen,print";
if(!!navigator.userAgent.match(/firefox/i)){
link.href = "css/firefoxStyle.css";
}else{
link.href = "css/noFirefoxStyle.css";
}
document.getElementsByTagName("head")[0].appendChild( link );
</script>