mirror of
https://github.com/pierre42100/comunic
synced 2025-06-20 17:15:19 +00:00
First commit
This commit is contained in:
115
inc/pages/searchUser/searchUser.inc.php
Executable file
115
inc/pages/searchUser/searchUser.inc.php
Executable file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Search somebody
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
isset($_SESSION) OR exit('Invalid call - '.$_SERVER['PHP_SELF']);
|
||||
|
||||
//On d<>termine un ID de session pour l'utilisateur
|
||||
$id_session = (isset($_SESSION['ID']) ? $_SESSION['ID'] : 0);
|
||||
|
||||
//On corrige la requ<71>te si n<>cessaire
|
||||
if(isset($_GET['q']) AND !isset($_POST['nom']))
|
||||
$_POST['nom'] = $_GET['q'];
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php include(pagesRelativePath('common/head.php')); ?>
|
||||
<title><?php echo $lang[39]; ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<?php include(pagesRelativePath('common/pageTop.php')); ?>
|
||||
<h1 class='titre'><?php echo $lang[40]; ?></h1>
|
||||
<table align='center'>
|
||||
<tr>
|
||||
<td>
|
||||
<form action='recherche.php' name="Recherche d'utilisateurs" method='post'>
|
||||
<input type='text' name='nom' size="53" autocomplete="off" id="searchuser" value="<?php echo(isset($_POST['nom']) ? $_POST['nom']: ""); ?>" placeholder="<?php echo $lang[40]; ?>" style="color:black;" />
|
||||
<input type='submit' value='<?php echo $lang[39]; ?>' />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
if(isset($_POST['nom']))
|
||||
{
|
||||
//Mettons "" <20> la place de "%"
|
||||
$nom = str_replace("%", "", $_POST['nom']);
|
||||
|
||||
//V<>rifions si la personne ne veut pas tout afficher
|
||||
if(($nom != '') && ($nom != '%')&& ($nom != ' '))
|
||||
{
|
||||
//Continuons de prot<6F>ger les personnes et la table
|
||||
$nom = str_replace("'", '"', $nom);
|
||||
|
||||
//Rendons flexible la requete
|
||||
$nom = str_replace(' ', '%', $nom);
|
||||
|
||||
//Nous pouvons maintenant faire la recherche
|
||||
//Requ<71>te SQL
|
||||
//$sql = "SELECT * FROM utilisateurs WHERE (nom LIKE '%".$nom."%') || (prenom LIKE '%".$nom."%') || (CONCAT(prenom, '%', nom) LIKE '%".$nom."%' ) || (CONCAT(prenom, ' ', nom) LIKE '%".$nom."%' ) || (mail LIKE '%".$nom."%') "; //Avec E-mail
|
||||
$sql = "SELECT * FROM utilisateurs WHERE (nom LIKE '%".$nom."%') || (prenom LIKE '%".$nom."%') || (CONCAT(prenom, '%', nom) LIKE '%".$nom."%' ) || (CONCAT(prenom, ' ', nom) LIKE '%".$nom."%' ) "; //Sans E-mail
|
||||
|
||||
//Ex<45>cution de la requete SQL
|
||||
$recherche = $bdd->query($sql);
|
||||
|
||||
//Affichage des r<>sultats
|
||||
echo "<table>";
|
||||
while($afficherrecherche = $recherche->fetch())
|
||||
{
|
||||
//On v<>rifie qu'il ne s'agit pas de l'utilisateur effectuant la recherche
|
||||
if($afficherrecherche['ID'] != $id_session AND ($id_session == 0 ? ( ($afficherrecherche['pageouverte'] == 1 ? true : false) ) : true))
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td><?php
|
||||
echo avatar($afficherrecherche['ID'], "./", 64, 64);
|
||||
?></td>
|
||||
<td><a href='index.php?id=<?php echo $afficherrecherche['ID']; ?>' title='Voire sa page'><?php echo $afficherrecherche['prenom']." ".$afficherrecherche['nom']; ?></a></td>
|
||||
<td>
|
||||
<?php
|
||||
//On v<>rifie si la page est v<>rifi<66>e
|
||||
if($afficherrecherche['page_verifiee'] == 1)
|
||||
{
|
||||
message_checked_page();
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p style="text-align: center;"><?php
|
||||
//Si l'utilisateur n'est pas connect<63>, on lui propose de se connecter
|
||||
if($id_session == 0 AND isset($_POST['nom']))
|
||||
{
|
||||
//Message de proposition avec redirection automatique
|
||||
echo "<a href='connecter.php?redirect=".urlencode("recherche.php?q=".$_POST['nom'])."'>Connectez-vous et accédez à plus de résultats</a>";
|
||||
}
|
||||
?></p>
|
||||
<?php if(isset($_POST['nom'])) { ?><p style="text-align:center;"><a href="http://www.bing.com/search?q=<?php echo urlencode($_POST['nom']); ?>" target="_blank">Elargir la recherche au web avec Bing</a></p><?php } ?>
|
||||
<hr />
|
||||
<?php
|
||||
//Inclusion du pied de page
|
||||
include(pagesRelativePath('common/pageBottom.php'));
|
||||
?>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user