Subversion Repositories Applications.bazar

Rev

Rev 472 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 472 Rev 493
Line 1064... Line 1064...
1064
    if (DB::isError($resultat)) {
1064
    if (DB::isError($resultat)) {
1065
        die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1065
        die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1066
    }
1066
    }
1067
	if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
1067
	if (!isset ($_SESSION['_BAZAR_']['fichier'])) {
1068
		if ($resultat->numRows()==0) {
1068
		if ($resultat->numRows()==0) {
-
 
1069
			$nomFichierModifie = $_FILES[$nom_fichier]['name'];
-
 
1070
			// suppression des accents cause codage kipu
-
 
1071
			$nomFichierModifie = wd_remove_accents($nomFichierModifie);
1069
			$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES[$nom_fichier]['name'];
1072
			$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$nomFichierModifie;
1070
			move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
1073
			move_uploaded_file($_FILES[$nom_fichier]['tmp_name'], $chemin_destination);
1071
			chmod ($chemin_destination, 0755);
1074
			chmod ($chemin_destination, 0755);
1072
		}
1075
		}
1073
		$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
1076
		$id_fichier_joint = baz_nextId('bazar_fichier_joint', 'bfj_id_fichier', $GLOBALS['_BAZAR_']['db']) ;
1074
		$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
1077
		$requete = 'INSERT INTO bazar_fichier_joint SET bfj_id_fichier='.$id_fichier_joint.', bfj_ce_fiche='.$idfiche.
1075
		           ', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$_FILES[$nom_fichier]['name'].'"';
1078
		           ', bfj_description="'.addslashes($fichier_description).'", bfj_fichier="'.$nomFichierModifie.'"';
1076
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1079
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1077
        if (DB::isError($resultat)) {
1080
        if (DB::isError($resultat)) {
1078
            return $resultat->getMessage().$resultat->getDebugInfo() ;
1081
            return $resultat->getMessage().$resultat->getDebugInfo() ;
1079
        }
1082
        }
1080
	}
1083
	}
1081
    $_SESSION['_BAZAR_']['fichier'] = 1;
1084
    $_SESSION['_BAZAR_']['fichier'] = 1;
1082
	return;
1085
	return;
1083
}
1086
}
Line -... Line 1087...
-
 
1087
 
-
 
1088
// merci http://www.weirdog.com/blog/php/supprimer-les-accents-des-caracteres-accentues.html
-
 
1089
function wd_remove_accents($str/*, $charset='utf-8'*/)
-
 
1090
{
-
 
1091
	$str = htmlentities($str, ENT_NOQUOTES/*, $charset*/);
-
 
1092
 
-
 
1093
	$str = preg_replace('#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
-
 
1094
	$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. 'œ'
-
 
1095
	$str = preg_replace('#&[^;]+;#', '', $str); // supprime les autres caractères
-
 
1096
 
-
 
1097
	return $str;
-
 
1098
}
Line 1084... Line 1099...
1084
 
1099
 
1085
 
1100
 
1086
/** baz_insertion_image() - inserer une image a une fiche
1101
/** baz_insertion_image() - inserer une image a une fiche
1087
*
1102
*
Line 1094... Line 1109...
1094
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1109
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1095
        if (DB::isError($resultat)) {
1110
        if (DB::isError($resultat)) {
1096
            die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1111
            die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1097
        }
1112
        }
1098
	if ($resultat->numRows()==0) {
1113
	if ($resultat->numRows()==0) {
-
 
1114
		$nomImageModifie = $_FILES['image']['name'];
-
 
1115
		// suppression des accents cause codage kipu
-
 
1116
		$nomImageModifie = wd_remove_accents($nomImageModifie);
1099
		$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$_FILES['image']['name'];
1117
		$chemin_destination=BAZ_CHEMIN_APPLI.'upload/'.$nomImageModifie;
1100
		move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
1118
		move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
1101
		chmod ($chemin_destination, 0755);
1119
		chmod ($chemin_destination, 0755);
1102
	}
1120
	}
1103
	$_SESSION['_BAZAR_']['image'] = 1;
1121
	$_SESSION['_BAZAR_']['image'] = 1;
1104
	return 'bf_url_image="'.$_FILES['image']['name'].'", ' ;
1122
	return 'bf_url_image="'.$nomImageModifie.'", ' ;
1105
}
1123
}
Line 1106... Line 1124...
1106
 
1124
 
1107
 
1125