<?php

// ------------------------------------------------------------------------- //
// Repertoire téléphonique                                                   //
// ------------------------------------------------------------------------- //
// Auteur: Bruno Castagné <ccrealink@aol.com>                                //
// Web:    http://www.net16annonce.com/                                      //
// ------------------------------------------------------------------------- //

/*
Voici un repertoire téléphonique, qui vous sera surement utile. Pour amis et
professionnels (il gére les 2). Toutes les explications sont dans l'en-tête du
script. De plus vous pouvez le tester en ligne sur
http://www.net16annonce.com/rep/rep.php3 et pour poser des questions sur celui
ci http://www.net16annonce.com/forum.php3

<<<<<<<<< COMMENT CA FONCTIONNE >>>>>>>>>>
Pour enregistrer un contact cliquez sur <nouveau contact>.
Pour ouvrir le répertoire cliquez sur <répertoire>.
AMIS ou PROFESSIONNELS apparait. Cliquez sur l'un des deux.Ensuite
la sélection se fait par index alphabétique, et seules les lettres qui ont une correspondences sont visibles.
(si aucun nom commence par un P le P ne serra pas visible.)Et a coté de chaque lettres est inscrit le nombre de contact) Cliquez sur la lettre et la liste apparait.
Pour modifier ou suprimer un contact il faudra cliquer sur (détail).
Pour les mels cliquez sur mailling et suivez les instructions....

<<<<<<<<<<<<<<<<<<<< IT'S ALL >>>>>>>>>>>>>>>>>>>>>

Vous pouvez le tester directement sur mon site
   http://www.net16annonce.com/rep/rep.php3
Et si le coeur vous en dit, vous pourrez vous enregistrer en tant que nouveau contact...
(juste pour savoir le nombre de personne qui sont allez le voir :) )
Cordialement.
Bruno

///******\\\\\-----/////******\\\
          INSTRUCTIONS
         \ ---------- /
               
Creer une table sur votre base de données comme suit...

CREATE TABLE rep (
  id char(8) NOT NULL default '',
  nom char(25) NOT NULL default '',
  prenom char(20) NOT NULL default '',
  adresse char(200) NOT NULL default '',
  tel1 char(15) NOT NULL default '',
  tel2 char(15) NOT NULL default '',
  email char(100) NOT NULL default '',
  qualite char(1) NOT NULL default '',
  tel3 char(15) NOT NULL default '',
  metier char(50) NOT NULL default ''
) TYPE=MyISAM;

   Intituler le script comme_vous_voulez.php3 ou php4 ou php. Et n'oubliez pas de changer les parammetres de conexion..
   et roule ma poule.......
*/
?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>REPERTOIRE TELEPHONIQUE V1</title><meta name="author" content="BRUNO CASTAGNE"></head>
<STYLE type="text/css">
BODY {scrollbar-face-color: #000000; scrollbar-shadow-color: #CCFF00;
scrollbar-highlight-color: #CCFF00; scrollbar-3dlight-color: #CCFF00;
scrollbar-darkshadow-color: #CCFF00; scrollbar-track-color: #000000;
scrollbar-arrow-color:#CCFF00;background:#000000; color:#CCFF00; font-family:verdana; font-weight:bold;
font-size:14px }
A:link {font-size:12px; color:#ccff00; font-family:tahoma; font-weight:bold }
A:hover {zoom:105%; background:#2d2d2d; color:#ffffff; font-weight:bold; font-family:verdana }
A:visited {font-size:12px; color:#ccFf00; font-weight:bold; font-family:tahoma }
.saisie {font-weight:bold;font-size:13px; color:#CCFFFF;text-align:left; }
input {border-top-color:#000000; border-bottom-color:#000000;border-right-color:#000000; border-left-color:#000000; background:#2D2D2D; font-weight:bold; color:#ccff00;text-align:center }
.style1 {border-top-color:#2D2D2D; border-bottom-color:#2D2D2D;border-right-color:#2D2D2D; border-left-color:#2D2D2D; background:#000000; font-weight:bold; color:#ccffff;}
.class1 {font-size:12px; color:#ccff00; font-family:tahoma; font-weight:bold }
.class2 {font-size:12px; color:#ccffFF; font-family:tahoma; font-weight:bold }
textarea {background:#2d2d2d;font-weight:bold; color:#ccff00;border-top-color:#000000; border-bottom-color:#000000;border-right-color:#000000; border-left-color:#000000;}
</style>
<?
$retour
="<a href=\"$HTTP_REFERER\">RETOUR</a>";
print(
"<body>");
print(
"<form name=\"f\" action=\"rep.php3\" method=\"post\">");
///// Vos param....
$host="localhost";$user="root";$db="repertoire";
$my_sql=mysql_connect($host,$user,$pw) or die(mysql_error());mysql_select_db("$db") or die(mysql_error());
//// ENREGISTREMENT DES DONNEES......
if($enr){
   
$id=(uniqid(''));$id=substr($id, 4, 8);
   if(
$ami){$qualite ="A";}else{}
   if(
$prof){$qualite ="P";}else{}
   
$my="insert into rep(id,nom,prenom,tel1,tel2,tel3,email,adresse,qualite,metier) values (\"$id\",\"$nom\",\"$prenom\",\"$tel1\",\"$tel2\",\"$tel3\",\"$mel\",\"$adresse\",\"$qualite\",\"$metier\")";
   
mysql_query($my);
}
if(
$efface){$my_del=" delete from rep where id like '$id' ";mysql_query($my_del);}

$my0=" select * from rep ";$res=mysql_query($my0);$tot=mysql_num_rows($res);
if(
$tot <= 1){$c="contact";}else{$c="contacts";}
print(
"<center>Répertoire Téléphonique.&nbsp;<hr width=30% color=#CCFFCC size=2></center><p>");
print(
"<table><tr><td valign=top>");
print(
"<table border=1 cellspacing=0 cellpadding=15 bordercolor=#ccff00 width=180><tr align=center valign=middle>");
print(
"<td>");
print(
"<font size=1 color=#CCFFFF>($tot $c.)</font><br>");
print(
"<a href=\"?cont=oui&intro=oui\">Nouveau contact</a><p>");
print(
"<a href=\"?select=oui&intro=oui\">Répertoire</a>");
if(
$select){print("<p><a href=\"?repert=oui&categ=A&intro=oui\"><font color=#ccffff>AMIS</font></a><br><a href=\"?repert=oui&categ=P&intro=oui\"><font color=#ccffff>PROFESSIONNELS</font></a><p>");}else{}
print(
"<p><a href=\"javascript:modification()\">Modifier</a><p>");
print(
"<a href=\"javascript:del()\">Effacer</a><p>");
print(
"<a href=\"?mel_liste=oui&intro=oui\">Mailling</a>");
if(
$mel_liste){print("<p><a href=\"?mel_bis=oui&categ=A&intro=oui\"><font color=#ccffff>AMIS</font></a><br><a href=\"?mel_bis=oui&categ=P&intro=oui\"><font color=#ccffff>PROFESSIONNELS</font></a><p>");}else{}
print(
"</td></tr></table></td><td width=20></tD>");

///////
if($cont){
if(
$enr){$nom="";$prenom="";$adresse="";$tel1="";$tel2="";$tel3="";$mel="";$ami="";$prof="";$metier="";}
else{
if(
$detail){$my_detail="select * from rep where id like '$id' ";$res=mysql_query($my_detail);
while(
$row=mysql_fetch_array($res)){
$nom=$row[nom];$prenom=$row[prenom];$adresse=$row[adresse];$tel1=$row[tel1];$tel2=$row[tel2];$tel3=$row[tel3];$mel=$row[email];$metier=$row[metier];
if(
$row[qualite]== "A"){$ami="X";};if($row[qualite]== "P"){$prof="X";}
}}}
print(
"<td><input type=hidden name=\"id\" value=\"$id\">");
print(
"<table class=\"saisie\"><tr>");
print(
"<td>Nom : </tD><td><input type=text size=22 name=\"nom\" value=\"$nom\"></td></tr><tr>");
print(
"<td>Prénom : </tD><td><input type=text size=22 name=\"prenom\" value=\"$prenom\"></td></tr><tr>");
print(
"<td>Adresse : </tD><td><input type=text size=35 name=\"adresse\" value=\"$adresse\"></td></tr><tr>");
print(
"<td>Fixe : </tD><td><input type=text size=22 name=\"tel1\" value=\"$tel1\"></td></tr><tr>");
print(
"<td>Portable : </tD><td><input type=text size=22 name=\"tel2\" value=\"$tel2\"></td></tr><tr>");
print(
"<td>Bureau : </tD><td><input type=text size=22 name=\"tel3\" value=\"$tel3\"></td></tr><tr>");
print(
"<td>E-mail : </tD><td><input type=text size=22 name=\"mel\" value=\"$mel\"></td></tr>");
print(
"<td>Ami : </tD><td><input type=text size=1 name=\"ami\" value=\"$ami\" onclick=\"croix(1)\" style=\"cursor:crosshair\"></td></tr><tr>");
print(
"<td>Professionnel : </tD><td><input type=text size=1 name=\"prof\" value=\"$prof\" onclick=\"croix(2)\" style=\"cursor:crosshair\"></td></tr>");
print(
"<td>Profession : </tD><td><input type=text size=22 name=\"metier\" value=\"$metier\"></td></tr>");
print(
"<tr align=center><td colspan=2>");
if(
$detail){print("$retour</td>");}else{print("<input type=button value=\"ENREGISTRER\" onclick=\"valide()\" class=\"style1\"></td>");}
print(
"</tr><table>");
}
if(
$repert){
print(
"<td valign=top>");
$class="class1";
        
$lettre=array("","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
for(
$l=1;$l<=27;$l++){
    switch(
$l){case "13": $casse="<br>"; break; default: $casse="";}
    
$L=$lettre[$l];
    
$my3="select nom,qualite from rep where nom like '$L%' and qualite like '$categ'";$res=mysql_query($my3);
    
$tot=mysql_num_rows($res);
    if(
$tot >=1 && $l<27){
        print(
"<a href=\"?repert=oui&let=$L&categ=$categ&intro=oui\">$L</a>");
     print(
"<font size=1 color=#cfffff>($tot)-$casse");}else {}
      }
print(
"<p><table>");
if(
$let){
    
$my4="select * from rep where nom like '$let%' and qualite like '$categ' order by nom ";$res=mysql_query($my4);
  while(
$row = mysql_fetch_array($res)){
print(
"<tr><td class=\"$class\">$row[nom]&nbsp;$row[prenom]&nbsp;");
if(
$row[tel1] == ''){print("$row[tel2]&nbsp;");}else{print("$row[tel1]&nbsp;");}
print(
"<a href=\"?detail=oui&cont=oui&id=$row[id]&intro=oui\"><font size=1 color=#ffffff>(détail)</font></a></td></tr>");
   if(
$class == "class1"){$class="class2";}else{$class="class1";}
     }
print(
"</table>");
      }
      }
if(
$modif){
print(
"<td valign=center class=\"class2\">");
if(!
$nom){print("Vous devez afficher le detail pour accéder à la modification !<p>$retour");}else{
if(
$ami){$qualite = "A";}else{$qualite = "P" ;}
$my_modif=" update rep set nom='$nom',prenom='$prenom',adresse='$adresse',tel1='$tel1',tel2='$tel2',tel3='$tel3',email='$mel',qualite='$qualite',metier='$metier' where id like '$id' ";mysql_query($my_modif);
$nom=stripslashes(htmlentities($nom));
$prenom=stripslashes(htmlentities($prenom));
print(
"$nom $prenom<br>vient d'être modifier!");
}
}

if(
$efface){
print(
"<td valign=center class=\"class2\">");
if(!
$nom){print("Vous devez afficher le detail pour pouvoir effacer un contact!<p>$retour");}else{
$nom=stripslashes(htmlentities($nom));
$prenom=stripslashes(htmlentities($prenom));
print(
"$nom $prenom<br>vient d'être effacer !");
}
}
/// SELCTION POUR LES MELS...
if($mel_bis){
print(
"<td valign=top class=\"class2\">");
if(
$categ == "A"){$cat="AMIS";}
if(
$categ == "P"){$cat="PROFESSIONNELS";}
print(
"Liste des $cat possédant une adresse electronique.<br>");
print(
"Pour envoyer un message à tous <a href=\"?mel_a_tous=oui&categ=$categ&intro=oui\">cliquez içi</a>.<br>Sinon sélectionner une adresse en cliquant dessus.<hr width=30% color=#CCFFCC size=2>");
$my_mel=" select * from rep where email <>'' and qualite like '$categ' order by nom";$res=mysql_query($my_mel);
while(
$row=mysql_fetch_array($res)){
print(
"<a href=\"?mel_a_tous=oui&only=oui&dest=$row[email]&intro=oui\">$row[email]</a>&nbsp;($row[nom]-$row[prenom])<br>");}
}
////// ENVOIE D'UN MEL A TOUS...
if($mel_a_tous){
print(
"<td valign=center align=center><input type=hidden name=\"categ\" value=\"$categ\">");
print(
"<table class=\"class2\"><tr align=left>");
if(
$only){print("<td>Expedier à :</td><td><input type=texte size=25 name=\"dest\" value=\"$dest\"></td></tr><tr align=left>");}
print(
"<td>De la part de:</td><td><input type=text size=25 name=\"expediteur\"></td></tr><tr align=left>");
print(
"<td>Sujet :</td><td><input type=text size=25 name=\"sujet\"></td></tr><tr align=center>");
print(
"<td colspan=2><textarea cols=40 rows=6 name=\"contenu\"></textarea></td></tr><tr align=center>");
print(
"<td colspan=2><input type=button value=\"ENVOYER\" onclick=\"envoi_mel()\"></td></tr></table>");
}
///// expedition du mel....
if($mel_1){
print(
"<td valign=top class=\"class2\">");
$texte=stripslashes(htmlentities($contenu));
if(
$dest){$mailTo="$dest";$mailSubject="$sujet.\n";$mailBody="$texte\n";$mailHeaders="$expediteur";
          
$ok=mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
                  if(
$ok){print("Votre e-mail vient d'être envoyer à $dest.");}else{
                  print(
"<font color=#ff0000>échec de l'envoie</font>");}}
   else{
   
$my_mel=" select * from rep where email <>'' and qualite like '$categ' order by nom";$res=mysql_query($my_mel);
   while(
$row=mysql_fetch_array($res)){
   
$mailTo="$row[email]";$mailSubject="$sujet.\n";$mailBody="$texte\n";$mailHeaders="$expediteur";
   
$ok=mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
   if(
$ok){print("envoyer à :$row[email]<br>");}else{print("<font color=#ff0000>echec : $row[email]</font><br>");}
}
}
}
if(!
$intro){
print(
"<td valign=center>");
print(
"<table border=1 bordercolor=#ff0000 cellspacing=0 cellpadding=20><tr align=center class=\"class2\">");
print(
"<td>Création de Bruno Castagné.<p>Toutes copies fortement conseillées.<p>");
print(
"Pour toutes améliorations et critiques de ce programme envoyer moi un mel:<br>");
print(
"<a href=\"?intro=oui&mel_a_tous=oui&only=oui&dest=ccrealink@aol.com\">ccrealink@aol.com</a><p>");
print(
"<a href=\"http://127.0.0.1/net16annonce/telecharger/rep.zip\"><font color=\"#ff000000\"><b>Télecharger rep.zip</b></font></a>");
print(
"</td></tr></table>");
}

print(
"</td></tr></table>");
print(
"</td></tr></table><hr width=65% color=#CCFFCC size=3>");

print(
"<input type=hidden name=\"enr\"><input type=hidden name=\"detail\"><input type=hidden name=\"cont\"><input type=hidden name=\"modif\"><input type=hidden name=\"efface\">");
print(
"<input type=hidden name=\"mel_1\"><input type=hidden name=\"intro\">");
?>
<script language="javascript">
var ok1;var ok2;
function croix (x){
if(x == 1){document.f.ami.value="X";document.f.prof.value="";}
if(x == 2){document.f.prof.value="X";document.f.ami.value="";} }
function valide() {
if(document.f.ami.value == false && document.f.prof.value == false){alert('Une des 2 cases doit être cocher.\n AMI ou PROFESSIONNEL.');return true;}
document.f.cont.value='oui';document.f.enr.value='oui';document.f.intro.value='oui';f.submit();}
function modification(){document.f.modif.value='oui';document.f.intro.value='oui';f.submit();}
function del(){document.f.efface.value='oui';document.f.intro.value='oui';f.submit();}
function envoi_mel(){
if(document.f.expediteur.value==""){alert('Notez votre adresse electronique');return true;}
if(document.f.contenu.value==""){alert('Votre message!');return true;}
document.f.mel_1.value='oui';document.f.intro.value='oui';f.submit();
}
</script></form></body></html>