|
|
@@ -4,65 +4,71 @@ ini_set('display_startup_errors', 1);
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
|
|
|
|
|
|
function connect(){
|
|
|
-
|
|
|
- $link = mysql_connect('127.0.0.1','eligibilite','B3Kg7z6d') or die(mysql_error());
|
|
|
- mysql_select_db('eligibilite', $link) or die(mysql_error());
|
|
|
+ // $link = mysqli_connect('127.0.0.1','eligibilite','B3Kg7z6d', 'eligibilite', 3306);
|
|
|
+ $link = mysqli_connect('10.5.255.24','eligibilite','B3Kg7z6d', 'eligibilite', 3306);
|
|
|
+ if (mysqli_connect_errno())
|
|
|
+ {
|
|
|
+ echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
|
|
+ }
|
|
|
+ return $link;
|
|
|
}
|
|
|
|
|
|
-function executeQuery($requete) {
|
|
|
- $resultat = mysql_query($requete) or die(mysql_error());
|
|
|
-
|
|
|
- if(substr($requete, 0, 6) === 'SELECT'){
|
|
|
- while($donnees = mysql_fetch_array($resultat)){
|
|
|
- $resultats[] = $donnees;
|
|
|
+function executeQuery($link, $requete) {
|
|
|
+
|
|
|
+ $q = mysqli_query($link, $requete);
|
|
|
+
|
|
|
+ if(substr($requete, 0, 6) === 'SELECT'){
|
|
|
+ while($donnees = mysqli_fetch_array($q)){
|
|
|
+ $results[] = $donnees;
|
|
|
+ }
|
|
|
+ $q->close();
|
|
|
+ if (!isset($results)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return $results;
|
|
|
}
|
|
|
- if (!isset($resultats)) {
|
|
|
- return null;
|
|
|
+ else if(substr($requete, 0, 6) === 'INSERT'){
|
|
|
+ $results = mysqli_insert_id($link);
|
|
|
}
|
|
|
- return $resultats;
|
|
|
- }
|
|
|
- else if(substr($requete, 0, 6) === 'INSERT'){
|
|
|
- $resultats = mysql_insert_id();
|
|
|
- }
|
|
|
- else {
|
|
|
- $resultats = 'ok';
|
|
|
- }
|
|
|
-
|
|
|
- return $resultats;
|
|
|
+ else {
|
|
|
+ $results = True;
|
|
|
+ }
|
|
|
+
|
|
|
+ return $results;
|
|
|
}
|
|
|
|
|
|
-connect();
|
|
|
+$link = connect();
|
|
|
|
|
|
if(isset($_POST['query'])) {
|
|
|
- $resultat = executeQuery($_POST['query']);
|
|
|
- echo json_encode($resultat);
|
|
|
- return;
|
|
|
+ $resultat = executeQuery($link, $_POST['query']);
|
|
|
+ echo json_encode($resultat);
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
if(isset($_POST['mail'])) {
|
|
|
- $email = 'ftth@manchenumerique.fr';
|
|
|
- $bcc = 'ftth@manchenumerique.fr';
|
|
|
-
|
|
|
- if(isset($_POST['siteEmail'])) {
|
|
|
- $email = $_POST['siteEmail'];
|
|
|
- }
|
|
|
-
|
|
|
- $headers = "";
|
|
|
- $headers .= "Reply-To:".$email."\r\n"."X-Mailer: PHP/".phpversion(). "\r\n";
|
|
|
- $headers .= "MIME-Version: 1.0"."\r\n";
|
|
|
- $headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
|
|
|
- $headers .= "Bcc: ".$bcc."\r\n";
|
|
|
- $headers .= "From: ".utf8_decode("Manche Numérique")." <".$email.">"."\r\n";
|
|
|
-
|
|
|
- $subject = utf8_decode($_POST['mail']['sujet']);
|
|
|
- $subject = mb_encode_mimeheader($subject, "UTF-8");
|
|
|
-
|
|
|
- // Envoi
|
|
|
- $to = $_POST['mail']['to'];
|
|
|
- $resultat = mail($to, $subject, utf8_decode($_POST['mail']['message']), $headers, "-f ".$email);
|
|
|
+ $email = 'ftth@manchenumerique.fr';
|
|
|
+ $bcc = 'ftth@manchenumerique.fr';
|
|
|
+
|
|
|
+ if(isset($_POST['siteEmail'])) {
|
|
|
+ $email = $_POST['siteEmail'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $headers = "";
|
|
|
+ $headers .= "Reply-To:".$email."\r\n"."X-Mailer: PHP/".phpversion(). "\r\n";
|
|
|
+ $headers .= "MIME-Version: 1.0"."\r\n";
|
|
|
+ $headers .= "Content-type: text/html; charset=iso-8859-1"."\r\n";
|
|
|
+ $headers .= "Bcc: ".$bcc."\r\n";
|
|
|
+ $headers .= "From: ".utf8_decode("Manche Numérique")." <".$email.">"."\r\n";
|
|
|
+
|
|
|
+ $subject = utf8_decode($_POST['mail']['sujet']);
|
|
|
+ $subject = mb_encode_mimeheader($subject, "UTF-8");
|
|
|
+
|
|
|
+ // Envoi
|
|
|
+ $to = $_POST['mail']['to'];
|
|
|
+ $resultat = mail($to, $subject, utf8_decode($_POST['mail']['message']), $headers, "-f ".$email);
|
|
|
}
|
|
|
|
|
|
if(isset($resultat)){
|
|
|
- echo json_encode($resultat);
|
|
|
+ echo json_encode($resultat);
|
|
|
}
|
|
|
-?>
|
|
|
+?>
|