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
|
<?php require_once('../../Connections/connect.php');
function replace_dangerous_char($fichierdangereux)
{
$resultat=str_replace(" ","_",$fichierdangereux);
$result=str_replace("'","_",$result);
$result=str_replace("/","_",$result);
$result=str_replace("\\","_",$result);
$result=str_replace(":","_",$result);
$result=str_replace("*","_",$result);
$result=str_replace("?","_",$result);
$result=str_replace("<","_",$result);
$result=str_replace(">","_",$result);
$result=str_replace("\"","_",$result);
$result=str_replace("|","_",$result);
return $resultat;
}
$colname_Fiche_p = "-1";
if (isset($_GET['id_tmp2'])) {
$colname_Fiche_p = (get_magic_quotes_gpc()) ? $_GET['id_tmp2'] : addslashes($_GET['id_tmp2']);
}
mysql_select_db($database_connect, $connect);
$query_Fiche_p = sprintf("SELECT * FROM fiche, tmp_personne WHERE id_tmp2 = %s AND tmp_personne.id_tmp=fiche.id_tmp", $colname_Fiche_p);
$Fiche_p = mysql_query($query_Fiche_p, $connect) or die(mysql_error());
$row_Fiche_p = mysql_fetch_assoc($Fiche_p);
$totalRows_Fiche_p = mysql_num_rows($Fiche_p);
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "formulaire_envoi_fichier")) {
if ($cv!="")
{
if (!is_uploaded_file($cv))
{
echo "erreur lors du téléchargement du fichier<br>";
}
else
{
$fichiercv=replace_dangerous_char($_FILES["cv"]["name"]);
copy($cv,"../../images/img/".$fichiercv);
}
}
$updateSQL = sprintf("UPDATE fiche SET photo=%s WHERE id_tmp2=%s ",
GetSQLValueString($fichiercv, "text"),
GetSQLValueString($_POST['id_tmp2'], "int"));
mysql_select_db($database_connect, $connect);
$Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());
$updateGoTo = "main.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
@header(sprintf("Location: %s", $updateGoTo));
}
/*
$updateSQL = sprintf("UPDATE tmp_personne SET photo=%s WHERE id_tmp=%s",
GetSQLValueString($_POST['photo'], "text"),
GetSQLValueString($_POST['id_tmp'], "int"));
mysql_select_db($database_connect, $connect);
$Result1 = mysql_query($updateSQL, $connect) or die(mysql_error());
$updateGoTo = "main.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
@header(sprintf("Location: %s", $updateGoTo));
}
}*/
?>
<form name="formulaire_envoi_fichier" enctype="multipart/form-data" method="POST" action="<?php echo $editFormAction; ?>">
<input name="id_tmp2" type="hidden" id="id_tmp2" value="<?php echo $row_Fiche_p['id_tmp2']; ?>" />
<label></label>
<br />
<input name="cv" type="file" id="cv" size="50" />
<br>
<input type="submit" name="bouton_submit" value="Envoyer le fichier">
<input type="hidden" name="MM_update" value="formulaire_envoi_fichier">
</form>
<?php
mysql_free_result($Fiche_p);
?> |
Partager