|
Invité de passage
Inscription : avril 2011 Messages : 3 Détails du profil  Informations personnelles : Sexe :  Localisation : Bénin Informations forums :
Inscription : avril 2011 Messages : 3 Points : 0 Points : 0
|
Je mets le script des deux pages qui posent problème
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| <?php
session_start (); //Lancer la session
if ((isset($_SESSION['mot_de_passe']) && isset($_SESSION['login'])) && isset($_SESSION['type'])) //Permet de savoir si l'utilisateur est passé par le formulaire
{
if ($_SESSION['type']=="secretariat")
{
include("fonctions.php");
$db = "gestion_courrier_atrpt";
open_database();
if ((isset($_POST['objet']) && isset($_POST['date'])) && isset($_POST['reference']))
{
$date = mktime(0, 0, 0, $_POST['mois'], $_POST['date'], $_POST['annee']);
$objet = mysql_real_escape_string(htmlspecialchars($_POST['objet']));
$reference = mysql_real_escape_string(htmlspecialchars($_POST['reference']));
$num_attribution = mysql_real_escape_string(htmlspecialchars($_POST['num_attribution']));
$type = mysql_real_escape_string(htmlspecialchars($_POST['type']));
$affiliation = mysql_real_escape_string(htmlspecialchars($_POST['affiliation']));
$commentaire = mysql_real_escape_string(htmlspecialchars($_POST['commentaire']));
$attribution = NULL;
$sous_attribution = NULL;
$url1 = NULL;
$contact_interlocuteur = mysql_real_escape_string(htmlspecialchars($_POST['contact_interlocuteur']));
$nom_interlocuteur = mysql_real_escape_string(htmlspecialchars($_POST['nom_interlocuteur']));
$adresse_interlocuteur = mysql_real_escape_string(htmlspecialchars($_POST['adresse_interlocuteur']));
$date_creation = mysql_real_escape_string(htmlspecialchars($_POST['date_creation']));
$date_modification = mysql_real_escape_string(htmlspecialchars($_POST['date_modification']));
$request1 = "INSERT INTO courrier(id, date, objet, reference, num_attribution, contact_interlocuteur, nom_interlocuteur, adresse_interlocuteur, date_creation, date_modification, type, affiliation, commentaire, url) VALUES('', '". $date ."', '". $objet ."', '". $reference ."', '". $num_attribution ."', '". $contact_interlocuteur ."', '". $nom_interlocuteur ."', '". $adresse_interlocuteur ."', '". $date_creation ."', '". $date_modification ."', '". $type ."', '". $affiliation ."', '". $commentaire ."', '". $url1 ."')";
$retour1 = writter_database($db, $request1);
//$retour = mysql_query("INSERT INTO courrier(id, date, objet, reference, attribution, contact_interlocuteur, nom_interlocuteur, adresse_interlocuteur, date_creation, date_modification, url) VALUES('', '". $date ."', '". $objet ."', '". $reference ."', '". $attribution ."', '". $contact_interlocuteur ."', '". $nom_interlocuteur ."', '". $adresse_interlocuteur ."', '". $date_creation ."', '". $date_modification ."', 'papa')");
if (!(empty($_FILES['fichier']['tmp_name'])))
{
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'pdf');
$extension_upload = strtolower( substr( strrchr($_FILES['fichier']['name'], '.') ,1) );
$request2 = "SELECT id FROM courrier ORDER BY id DESC LIMIT 1";
$retour2 = reader_database($db, $request2);
while ($donnees2 = mysql_fetch_array($retour2))
{
$id = $donnees2['id'];
}
if (($type == "arrivee") && (!empty($num_attribution)))
{
$nom = "uploads/a_{$num_attribution}.{$extension_upload}";
}
elseif (($type == "depart") && (!empty($num_attribution)))
{
$nom = "uploads/d_{$num_attribution}.{$extension_upload}";
}
else
{
$nom = "uploads/{$id}.{$extension_upload}";
}
if ($_FILES['fichier']['error'] == 0)
{
//if ($_FILES['fichier']['size'] > $maxsize)
//{
if ( in_array($extension_upload,$extensions_valides) )
{
$resultat = move_uploaded_file($_FILES['fichier']['tmp_name'],$nom);
$url = $nom;
}
//}
}
if (isset($url))
{
$request3 = "UPDATE courrier SET url='". $url ."' WHERE id='". $id ."'";
$retour3 = writter_database($db, $request3);
}
}
writter_log( "La secretaire a ajouté le courrier " . $id . " au système.", "log.txt" );
header ('location: secretariat.php');
}
else
{
$request4 = "SELECT * FROM courrier WHERE type='arrivee' AND archive='non'";
$retour4 = reader_database($db, $request4);
$request5 = "SELECT * FROM courrier WHERE type='depart' AND archive='non'";
$retour5 = reader_database($db, $request5);
?> |
le second
Code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
| <?php
session_start (); //Lancer la session
if ((isset($_SESSION['mot_de_passe']) && isset($_SESSION['login'])) && isset($_SESSION['type'])) //Permet de savoir si l'utilisateur est passé par le formulaire
{
if ($_SESSION['type']=="secretariat")
{
include("fonctions.php");
$db = "gestion_courrier_atrpt";
open_database();
if ((isset($_POST['objet']) && isset($_POST['date'])) && isset($_POST['reference']))
{
$id = mysql_real_escape_string(htmlspecialchars($_POST['id']));
$date = mktime(0, 0, 0, $_POST['mois'], $_POST['date'], $_POST['annee']);
$objet = mysql_real_escape_string(htmlspecialchars($_POST['objet']));
$reference = mysql_real_escape_string(htmlspecialchars($_POST['reference']));
$num_attribution = mysql_real_escape_string(htmlspecialchars($_POST['num_attribution']));
$type = mysql_real_escape_string(htmlspecialchars($_POST['type']));
$affiliation = mysql_real_escape_string(htmlspecialchars($_POST['affiliation']));
$commentaire = mysql_real_escape_string(htmlspecialchars($_POST['commentaire']));
$attribution = mysql_real_escape_string(htmlspecialchars($_POST['attribution']));
$sous_attribution = mysql_real_escape_string(htmlspecialchars($_POST['sous_attribution']));
$contact_interlocuteur = mysql_real_escape_string(htmlspecialchars($_POST['contact_interlocuteur']));
$nom_interlocuteur = mysql_real_escape_string(htmlspecialchars($_POST['nom_interlocuteur']));
$adresse_interlocuteur = mysql_real_escape_string(htmlspecialchars($_POST['adresse_interlocuteur']));
$date_creation = mysql_real_escape_string(htmlspecialchars($_POST['date_creation']));
$date_modification = mysql_real_escape_string(htmlspecialchars($_POST['date_modification']));
if (empty($_FILES['fichier']['tmp_name']))
{
$request1= "UPDATE courrier SET id='". $id ."', date='". $date ."', objet='". $objet ."', reference='". $reference ."', num_attribution='". $num_attribution ."', attribution='". $attribution ."', sous_attribution='". $sous_attribution ."', contact_interlocuteur='". $contact_interlocuteur ."', nom_interlocuteur='". $nom_interlocuteur ."', adresse_interlocuteur='". $adresse_interlocuteur ."', date_creation='". $date_creation ."', date_modification='". $date_modification ."', type='". $type ."', affiliation='". $affiliation ."', commentaire='". $commentaire ."' WHERE id='". $id ."'";
$retour1 = writter_database($db, $request1);
$request6 = "SELECT url FROM courrier WHERE id=" . $_POST['id'];
$retour6 = reader_database($db, $request6);
while ($donnees6 = mysql_fetch_array($retour6))
{
$url = $donnees6['url'];
}
$extension_upload = strtolower( substr( strrchr($url, '.') ,1) );
if (($type == "arrivee") && (!empty($num_attribution)))
{
$nom = "uploads/a_{$num_attribution}.{$extension_upload}";
rename($url, $nom);
$url = $nom;
}
elseif (($type == "depart") && (!empty($num_attribution)))
{
$nom = "uploads/d_{$num_attribution}.{$extension_upload}";
rename($url, $nom);
$url = $nom;
}
else
{
$nom = "uploads/{$id}.{$extension_upload}";
rename($url, $nom);
$url = $nom;
}
$request7 = "UPDATE courrier SET url='". $url ."' WHERE id='". $id ."'";
$retour7 = writter_database($db, $request7);
}
else
{
$extensions_valides = array( 'jpg' , 'jpeg' , 'gif' , 'png', 'pdf');
$extension_upload = strtolower( substr( strrchr($_FILES['fichier']['name'], '.') ,1) );
if (($type == "arrivee") && (!empty($num_attribution)))
{
$nom = "uploads/a_{$num_attribution}.{$extension_upload}";
}
elseif (($type == "depart") && (!empty($num_attribution)))
{
$nom = "uploads/d_{$num_attribution}.{$extension_upload}";
}
else
{
$nom = "uploads/{$id}.{$extension_upload}";
}
if ($_FILES['fichier']['error'] == 0)
{
//if ($_FILES['fichier']['size'] > $maxsize)
//{
if ( in_array($extension_upload,$extensions_valides) )
{
unlink($nom);
$resultat = move_uploaded_file($_FILES['fichier']['tmp_name'],$nom);
$url = $nom;
}
//}
}
$request2= "UPDATE courrier SET id='". $id ."', date='". $date ."', objet='". $objet ."', reference='". $reference ."', attribution='". $attribution ."', contact_interlocuteur='". $contact_interlocuteur ."', nom_interlocuteur='". $nom_interlocuteur ."', adresse_interlocuteur='". $adresse_interlocuteur ."', date_creation='". $date_creation ."', date_modification='". $date_modification ."', type='". $type ."', affiliation='". $affiliation ."', commentaire='". $commentaire ."', url='". $url ."' WHERE id='". $id ."'";
$retour2 = writter_database($db, $request2);
}
writter_log( "La secretaire a modifié le courrier " . $id . " du système.", "log.txt" );
header ('location: secretariat.php');
}
if (isset($_GET['modifier_courrier']))
{
$request = "SELECT * FROM courrier WHERE id='" . $_GET['modifier_courrier'] . "'";
$retour = reader_database($db, $request);
$request4 = "SELECT * FROM courrier WHERE type='arrivee' AND archive='non'";
$retour4 = reader_database($db, $request4);
$request5 = "SELECT * FROM courrier WHERE type='depart' AND archive='non'";
$retour5 = reader_database($db, $request5);
?> |
|