0byt3m1n1
Path:
/
home
/
kassiope
/
www
/
lib
/
fonctions
/
[
Home
]
File: fonctions.php
<?php function get_commercial($cp) { $rec_commercial = mysql_query_override("select * from gaia_commerciaux where departements like '%".substr($cp,0,2).";%'; "); return $commercial = mysql_fetch_array_override($rec_commercial); } function cpt_prod($id){ mysql_query_override("update gaia_produits set compteur = (compteur+1) where id = '".$id."'"); } function skip_accents( $str, $charset='utf-8' ) { $str = htmlentities( $str, ENT_NOQUOTES, $charset ); $str = preg_replace( '#&([A-za-z])(?:acute|cedil|caron|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str ); $str = preg_replace( '#&([A-za-z]{2})(?:lig);#', '\1', $str ); $str = preg_replace( '#&[^;]+;#', '', $str ); return $str; } function split_title($title, $color='#000') { $t = explode(' ',$title); $t[(count($t)-1)] = '<span style="color:'.$color.'">'.$t[(count($t)-1)].'</span>'; return implode(' ',$t); } function getcolors($id) { $tabcolor = array(); $rec = mysql_query_override("select c.* from gaia_couleurs c, gaia_produits_couleurs pc where pc.produit_id = '".$id."' and pc.couleur_id = c.id group by c.id order by c.position"); while($data = mysql_fetch_array_override($rec)) { $tabcolor[] = array('color'=>$data['color'],'name'=>$data['nom_'.$_SESSION['langue']]); } return $tabcolor; } function callAPI(){ global $id_colissimo, $pwd_colissimo; $url = "https://ws.colissimo.fr/widget-point-retrait/rest/authenticate.rest"; $method = "POST"; $data_array = array('login'=>$id_colissimo,'password'=>$pwd_colissimo); $data = json_encode($data_array); $curl = curl_init(); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json' )); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); $result = curl_exec($curl); curl_close($curl); return json_decode($result); } function get_pointrelais($tab) { echo '<div class="row">'; foreach($tab as $k => $v) { echo '<div class="col-xl-1 col-lg-1 col-md-1 col-sm-2 col-xs-2 col-2 text-end ptrelaisradio">'; echo '<input type="radio" id="'.$v['identifiant'].'" name="the_point_relais" value="'.$v['identifiant'].'" />'; echo '</div>'; echo '<div class="col-xl-3 col-lg-5 col-md-5 col-sm-10 col-xs-10 col-10 ptrelais mb-3">'; //echo '<div class="col-xl-4 col-lg-6 col-md-6 col-xs-12 ptrelais">'; echo '<label for="'.$v['identifiant'].'">'; echo '<b>'.$v['nom'].'</b> <a href="javascript:void(null)" data-bs-toggle="modal" data-bs-target="#modal'.$v['identifiant'].'"><i class="fa fa-question-circle"></i></a><br />'; echo $v['adresse'].'<br />'.$v['codePostal'].' '.$v['localite'].'<br />'; echo '</label>'; echo '</div>'; $lundi = $mardi = $mercredi = $jeudi = $vendredi = $samedi = $dimanche = ''; for($i=0;$i<4;$i++) : $lundi .= (!empty($v['lundi'][$i])?'<td align="center">'.get_hour($v['lundi'][$i]).'</td>':''); $mardi .= (!empty($v['mardi'][$i])?'<td align="center">'.get_hour($v['mardi'][$i]).'</td>':''); $mercredi .= (!empty($v['mercredi'][$i])?'<td align="center">'.get_hour($v['mercredi'][$i]).'</td>':''); $jeudi .= (!empty($v['jeudi'][$i])?'<td align="center">'.get_hour($v['jeudi'][$i]).'</td>':''); $vendredi .= (!empty($v['vendredi'][$i])?'<td align="center">'.get_hour($v['vendredi'][$i]).'</td>':''); $samedi .= (!empty($v['samedi'][$i])?'<td align="center">'.get_hour($v['samedi'][$i]).'</td>':''); $dimanche .= (!empty($v['dimanche'][$i])?'<td align="center">'.get_hour($v['dimanche'][$i]).'</td>':''); endfor; if(empty($lundi)) $lundi = (!empty($v['lundi_am'])?'<td align="center">'.($v['lundi_am']).'</td>':'').(!empty($v['lundi_pm'])?'<td align="center">'.($v['lundi_pm']).'</td>':''); if(empty($mardi)) $mardi = (!empty($v['mardi_am'])?'<td align="center">'.($v['mardi_am']).'</td>':'').(!empty($v['mardi_pm'])?'<td align="center">'.($v['mardi_pm']).'</td>':''); if(empty($mercredi)) $mercredi = (!empty($v['mercredi_am'])?'<td align="center">'.($v['mercredi_am']).'</td>':'').(!empty($v['mercredi_pm'])?'<td align="center">'.($v['mercredi_pm']).'</td>':''); if(empty($jeudi)) $jeudi = (!empty($v['jeudi_am'])?'<td align="center">'.($v['jeudi_am']).'</td>':'').(!empty($v['jeudi_pm'])?'<td align="center">'.($v['jeudi_pm']).'</td>':''); if(empty($vendredi)) $vendredi = (!empty($v['vendredi_am'])?'<td align="center">'.($v['vendredi_am']).'</td>':'').(!empty($v['vendredi_pm'])?'<td align="center">'.($v['vendredi_pm']).'</td>':''); if(empty($samedi)) $samedi = (!empty($v['samedi_am'])?'<td align="center">'.($v['samedi_am']).'</td>':'').(!empty($v['samedi_pm'])?'<td align="center">'.($v['samedi_pm']).'</td>':''); if(empty($dimanche)) $dimanche = (!empty($v['dimanche_am'])?'<td align="center">'.($v['dimanche_am']).'</td>':'').(!empty($v['dimanche_pm'])?'<td align="center">'.($v['dimanche_pm']).'</td>':''); echo '<div class="modal fade" id="modal'.$v['identifiant'].'" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Horaires d\'ouverture</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <table width="100%"> <tr> <th>Lundi</th>'.(!empty($lundi)?$lundi:'<td align="center" colspan="4">-</td>').' </tr> <tr> <th>Mardi</th>'.(!empty($mardi)?$mardi:'<td align="center" colspan="4">-</td>').' </tr> <tr> <th>Mercredi</th>'.(!empty($mercredi)?$mercredi:'<td align="center" colspan="4">-</td>').' </tr> <tr> <th>Jeudi</th>'.(!empty($jeudi)?$jeudi:'<td align="center" colspan="4">-</td>').' </tr> <tr> <th>Vendredi</th>'.(!empty($vendredi)?$vendredi:'<td align="center" colspan="4">-</td>').' </tr> <tr> <th>Samedi</th>'.(!empty($samedi)?$samedi:'<td align="center" colspan="4">-</td>').' </tr> <tr> <th>Dimanche</th>'.(!empty($dimanche)?$dimanche:'<td align="center" colspan="4">-</td>').' </tr> </table> </div> </div> </div> </div>'; } echo '</div>'; } function get_hour($hour) { return substr($hour,0,2).'h'.substr($hour,-2,2); } function colissimo_pr_one($id) { $client = new soapClient("https://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS/2.0?wsdl"); //$tabparam = array("address" => "189 avenue Colgate","zipCode" => "13009","city" => "Marseille","requestId" => rand(1,100000000)); $params = array( "accountNumber" => "380507", "password" => "Numberone96@", "id" => $id, "date" => date('d/m/Y'), ); $response = $client->__soapCall("findPointRetraitAcheminementByID", array($params)); $v = $response->return->pointRetraitAcheminement; $tabreturn['type'] = 'COLISSIMO - POINT RELAIS'; $tabreturn['identifiant'] = $v->identifiant; $tabreturn['nom'] = $v->nom.' ('.$v->identifiant.')'; $tabreturn['adresse'] = $v->adresse1.' '.$v->adresse2; $tabreturn['codePostal'] = $v->codePostal; $tabreturn['localite'] = $v->localite; return $tabreturn; } function colissimo_pr($tabparam) { $client = new soapClient("https://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS/2.0?wsdl"); //$tabparam = array("address" => "189 avenue Colgate","zipCode" => "13009","city" => "Marseille","requestId" => rand(1,100000000)); $params = array( "accountNumber" => "380507", "password" => "Numberone96@", "address" => $tabparam['address'], "zipCode" => $tabparam['zipCode'], "city" => $tabparam['city'], "countryCode" => "FR", "weight" => "1000", "shippingDate" => date('d/m/Y'), "filterRelay" => "1", "requestId" => $tabparam['requestId'], "lang" => "FR", "optionInter" => "0", ); $response = $client->__soapCall("findRDVPointRetraitAcheminement", array($params)); $tabreturn = array(); $cpt=0; foreach($response->return->listePointRetraitAcheminement as $k => $v) { $tabreturn[$cpt]['identifiant'] = $v->identifiant; $tabreturn[$cpt]['nom'] = $v->nom.' ('.$v->identifiant.')'; $tabreturn[$cpt]['adresse'] = $v->adresse1.' '.$v->adresse2; $tabreturn[$cpt]['codePostal'] = $v->codePostal; $tabreturn[$cpt]['localite'] = $v->localite; $jour = explode(' ',$v->horairesOuvertureLundi); $tabreturn[$cpt]['lundi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['lundi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureMardi); $tabreturn[$cpt]['mardi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['mardi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureMercredi); $tabreturn[$cpt]['mercredi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['mercredi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureJeudi); $tabreturn[$cpt]['jeudi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['jeudi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureVendredi); $tabreturn[$cpt]['vendredi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['vendredi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureSamedi); $tabreturn[$cpt]['samedi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['samedi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureDimanche); $tabreturn[$cpt]['dimanche_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['dimanche_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $cpt++; } return $tabreturn; } function mondial_pr($tabparam) { $client = new soapClient("http://api.mondialrelay.com/Web_Services.asmx?WSDL"); //$tabparam = array("address" => "189 avenue Colgate","zipCode" => "13009","city" => "Marseille","requestId" => rand(1,100000000)); $MR_WebSiteId = "CC21RHJ6"; $MR_WebSiteKey = "GxmhB0jr"; $params = array( 'Enseigne' => $MR_WebSiteId, 'Pays' => "FR", //'NumPointRelais' => "", 'Ville' => $tabparam['city'], 'CP' => $tabparam['zipCode'], 'Latitude' => "", 'Longitude' => "", 'Taille' => "", 'Poids' => "1000", 'Action' => "", 'DelaiEnvoi' => "0", 'RayonRecherche' => "20", //'TypeActivite' => "", //'NACE' => "", ); // We generate the request's security code // On génère la clé de sécurité de l'appel $code = implode("", $params); $code .= $MR_WebSiteKey; $params["Security"] = strtoupper(md5($code)); $response = $client->__soapCall("WSI3_PointRelais_Recherche", array($params)); $tabreturn = array(); $cpt=0; foreach($response->WSI3_PointRelais_RechercheResult->PointsRelais->PointRelais_Details as $k => $v) { $tabreturn[$cpt]['identifiant'] = $v->Num; $tabreturn[$cpt]['nom'] = $v->LgAdr1.' ('.$v->Num.')'; $tabreturn[$cpt]['adresse'] = $v->LgAdr3; $tabreturn[$cpt]['codePostal'] = $v->CP; $tabreturn[$cpt]['localite'] = $v->Ville; $tabreturn[$cpt]['pays'] = $v->Pays; for($i=0;$i<4;$i++) : $tabreturn[$cpt]['lundi'][] = (!empty($v->Horaires_Lundi->string[$i])?$v->Horaires_Lundi->string[$i]:''); $tabreturn[$cpt]['mardi'][] = (!empty($v->Horaires_Mardi->string[$i])?$v->Horaires_Mardi->string[$i]:''); $tabreturn[$cpt]['mercredi'][] = (!empty($v->Horaires_Mercredi->string[$i])?$v->Horaires_Mercredi->string[$i]:''); $tabreturn[$cpt]['jeudi'][] = (!empty($v->Horaires_Jeudi->string[$i])?$v->Horaires_Jeudi->string[$i]:''); $tabreturn[$cpt]['vendredi'][] = (!empty($v->Horaires_Vendredi->string[$i])?$v->Horaires_Vendredi->string[$i]:''); $tabreturn[$cpt]['samedi'][] = (!empty($v->Horaires_Samedi->string[$i])?$v->Horaires_Samedi->string[$i]:''); $tabreturn[$cpt]['dimanche'][] = (!empty($v->Horaires_Dimanche->string[$i])?$v->Horaires_Dimanche->string[$i]:''); endfor; $cpt++; } return $tabreturn; } function mondial_pr_one($id, $pais) { $client = new soapClient("http://api.mondialrelay.com/Web_Services.asmx?WSDL"); //$tabparam = array("address" => "189 avenue Colgate","zipCode" => "13009","city" => "Marseille","requestId" => rand(1,100000000)); $MR_WebSiteId = "CC21RHJ6"; $MR_WebSiteKey = "GxmhB0jr"; $params = array( 'Enseigne' => $MR_WebSiteId, 'Pays' => $pais, 'NumPointRelais' => $id ); // We generate the request's security code // On génère la clé de sécurité de l'appel $code = implode("", $params); $code .= $MR_WebSiteKey; $params["Security"] = strtoupper(md5($code)); $response = $client->__soapCall("WSI3_PointRelais_Recherche", array($params)); $v = $response->WSI3_PointRelais_RechercheResult->PointsRelais->PointRelais_Details; $tabreturn['type'] = 'MONDIAL RELAY'; $tabreturn['identifiant'] = $v->Num; $tabreturn['nom'] = $v->LgAdr1.' ('.$v->Num.')'; $tabreturn['adresse'] = $v->LgAdr3; $tabreturn['codePostal'] = $v->CP; $tabreturn['pays'] = $v->Pays; $tabreturn['localite'] = $v->Ville; return $tabreturn; } function dpd_pr($tabparam) { $params = array( "carrier" => "EXA", "key" => "deecd7bc81b71fcc0e292b53e826c48f", "address" => $tabparam['address'], "zipCode" => $tabparam['zipCode'], "city" => $tabparam['city'], "countrycode" => "FR", "requestID" => $tabparam['requestId'], "date_from" => date('d/m/Y') ); ini_set("default_socket_timeout", 3); $soappudo = new soapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?WSDL", array('connection_timeout' => 3, 'cache_wsdl' => WSDL_CACHE_NONE, 'exceptions' => true)); //var_dump($soappudo->__getTypes()); //var_dump($soappudo->__getFunctions()); $GetPudoList = $soappudo->GetPudoList($params); //print_r($GetPudoList); $doc_xml = new SimpleXMLElement($GetPudoList->GetPudoListResult->any); //print_r($doc_xml); $quality = $doc_xml->attributes()->quality; // indice de qualité de la réponse SOAP if ($doc_xml->xpath('ERROR')) { // si le webservice répond un code erreur, afficher un message d'indisponibilité echo '<ul class="messages"><li class="warnmsg"><ul><li>error</li></ul></li></ul>'; } else { if ($quality == 0) { // Si la qualité de la réponse est 0, "merci d'indiquer une autre adresse" echo '<ul class="messages"><li class="warnmsg"><ul><li>error</li></ul></li></ul>'; } else { $allpudoitems = $doc_xml->xpath('PUDO_ITEMS'); //print_r($allpudoitems); // acceder a la balise pudo_items foreach ($allpudoitems as $singlepudoitem) { $result = $singlepudoitem->xpath('PUDO_ITEM'); $cpt = 0; foreach ($result as $result2) { $tabreturn[$cpt]['identifiant'] = $result2->PUDO_ID; $tabreturn[$cpt]['nom'] = $result2->NAME.' ('.$result2->PUDO_ID.')'; $tabreturn[$cpt]['adresse'] = $result2->ADDRESS1.' '.$result2->ADDRESS2; $tabreturn[$cpt]['codePostal'] = $result2->ZIPCODE; $tabreturn[$cpt]['localite'] = $result2->CITY; $tabreturn[$cpt]['distance'] = $result2->DISTANCE / 1000; //distance $result2->DISTANCE / 1000 km $days = array(1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday', 7 => 'sunday'); $point = array(); $item = (array) $result2; if (count($item['OPENING_HOURS_ITEMS']->OPENING_HOURS_ITEM) > 0) { foreach ($item['OPENING_HOURS_ITEMS']->OPENING_HOURS_ITEM as $k => $oh_item) { $oh_item = (array) $oh_item; $point[$days[$oh_item['DAY_ID']]][] = $oh_item['START_TM'] . ' - ' . $oh_item['END_TM']; } } if (empty($point['monday'])) { $tabreturn[$cpt]['lundi_am'] = 'Fermé'; } else { $tabreturn[$cpt]['lundi_am'] = $point['monday'][0]; if (!empty($point['monday'][1])) $tabreturn[$cpt]['lundi_pm'] = $point['monday'][1]; } if (empty($point['tuesday'])) { $tabreturn[$cpt]['mardi_am'] = 'Fermé'; } else { $tabreturn[$cpt]['mardi_am'] = $point['tuesday'][0]; if (!empty($point['tuesday'][1])) $tabreturn[$cpt]['mardi_pm'] = $point['tuesday'][1]; } if (empty($point['wednesday'])) { $tabreturn[$cpt]['mercredi_am'] = 'Fermé'; } else { $tabreturn[$cpt]['mercredi_am'] = $point['wednesday'][0]; if (!empty($point['wednesday'][1])) $tabreturn[$cpt]['mercredi_pm'] = $point['wednesday'][1]; } if (empty($point['thursday'])) { $tabreturn[$cpt]['jeudi_am'] = 'Fermé'; } else { $tabreturn[$cpt]['jeudi_am'] = $point['monday'][0]; if (!empty($point['thursday'][1])) $tabreturn[$cpt]['jeudi_pm'] = $point['thursday'][1]; } if (empty($point['friday'])) { $tabreturn[$cpt]['vendredi_am'] = 'Fermé'; } else { $tabreturn[$cpt]['vendredi_am'] = $point['friday'][0]; if (!empty($point['friday'][1])) $tabreturn[$cpt]['vendredi_pm'] = $point['friday'][1]; } if (empty($point['saturday'])) { $tabreturn[$cpt]['samedi_am'] = 'Fermé'; } else { $tabreturn[$cpt]['samedi_am'] = $point['monday'][0]; if (!empty($point['saturday'][1])) $tabreturn[$cpt]['samedi_pm'] = $point['saturday'][1]; } if (empty($point['sunday'])) { $tabreturn[$cpt]['dimanche_am'] = 'Fermé'; } else { $tabreturn[$cpt]['dimanche_am'] = $point['sunday'][0]; if (!empty($point['sunday'][1])) $tabreturn[$cpt]['dimanche_pm'] = $point['sunday'][1]; } $cpt++; } } } } /* $tabreturn = array(); $cpt=0; foreach($response->return->listePointRetraitAcheminement as $k => $v) { $tabreturn[$cpt]['identifiant'] = $v->identifiant; $tabreturn[$cpt]['nom'] = $v->nom.' ('.$v->identifiant.')'; $tabreturn[$cpt]['adresse'] = $v->adresse1.' '.$v->adresse2; $tabreturn[$cpt]['codePostal'] = $v->codePostal; $tabreturn[$cpt]['localite'] = $v->localite; $jour = explode(' ',$v->horairesOuvertureLundi); $tabreturn[$cpt]['lundi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['lundi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureMardi); $tabreturn[$cpt]['mardi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['mardi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureMercredi); $tabreturn[$cpt]['mercredi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['mercredi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureJeudi); $tabreturn[$cpt]['jeudi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['jeudi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureVendredi); $tabreturn[$cpt]['vendredi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['vendredi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureSamedi); $tabreturn[$cpt]['samedi_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['samedi_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $jour = explode(' ',$v->horairesOuvertureDimanche); $tabreturn[$cpt]['dimanche_am'] = (isset($jour[0])&& $jour[0]<>'00:00-00:00'?$jour[0]:''); $tabreturn[$cpt]['dimanche_pm'] = (isset($jour[1])&& $jour[1]<>'00:00-00:00'?$jour[1]:''); $cpt++; } */ return $tabreturn; } function dpd_pr_one($id) { $params = array( "carrier" => "EXA", "key" => "deecd7bc81b71fcc0e292b53e826c48f", "pudo_id" => $id ); ini_set("default_socket_timeout", 3); $soappudo = new soapClient("http://mypudo.pickup-services.com/mypudo/mypudo.asmx?WSDL", array('connection_timeout' => 3, 'cache_wsdl' => WSDL_CACHE_NONE, 'exceptions' => true)); $GetPudoDetails = $soappudo->GetPudoDetails($params); $doc_xml = new SimpleXMLElement($GetPudoDetails->GetPudoDetailsResult->any); $allpudoitems = $doc_xml->xpath('PUDO_ITEMS'); // acceder a la balise pudo_items foreach ($allpudoitems as $singlepudoitem) { $result = $singlepudoitem->xpath('PUDO_ITEM'); $cpt = 0; foreach ($result as $result2) { $tabreturn['type'] = 'DPD - POINT RELAIS'; $tabreturn['identifiant'] = $result2->PUDO_ID; $tabreturn['nom'] = $result2->NAME.' ('.$result2->PUDO_ID.')'; $tabreturn['adresse'] = $result2->ADDRESS1.' '.$result2->ADDRESS2; $tabreturn['codePostal'] = $result2->ZIPCODE; $tabreturn['localite'] = $result2->CITY; $tabreturn['distance'] = $result2->DISTANCE / 1000; } } return $tabreturn; } function wishlist($prod, $picto=1) { global $wwwroot, $lg; $class=""; if(!est_identifie()) $link = 'data-toggle="modal" data-target="#wishlist"'; else { $allwish = array(); $recwish = mysql_query_override("select * from gaia_utilisateurs_wishlist w, gaia_produits p where p.id = w.produit_id and w.id_utilisateur = '".$_SESSION['utilisateur']['id_utilisateur']."'"); while($wish = mysql_fetch_array_override($recwish)) { $allwish[] = $wish['produit_id']; } $link = 'onclick="xajax_addwish(\''.$prod.'\',\''.$_SESSION['utilisateur']['id_utilisateur'].'\');" data-toggle="tooltip" title="'.ADD_ENVIE.'"'; if(in_array($prod,$allwish)) $class = 'active'; } $ret = '<a href="javascript:void(null)" '.$link.' id="wishlist-link" class="wishlist-link '.$class.' text-center"> '.(($picto==1)?'':ADD_ENVIE).'</a>'; return $ret; } function compte_wish() { $nb = '0'; if(est_identifie()) { $recwish = mysql_query_override("select w.* from gaia_utilisateurs_wishlist w, gaia_produits p where p.etat =1 and p.id = w.produit_id and w.id_utilisateur = '".$_SESSION['utilisateur']['id_utilisateur']."'"); $nb = mysql_num_rows_override($recwish); } return $nb; } function syncMailchimp($data) { $apiKey = 'd2112ec737025cf512931febcada58ba-us7'; $listId = 'ed080c28fe'; $auth = base64_encode( 'user:'.$apikey ); $memberId = md5(strtolower($data['email'])); $dataCenter = substr($apiKey,strpos($apiKey,'-')+1); $url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listId . '/members/' . $memberId; $json = json_encode([ 'email_address' => $data['email'], 'status' => $data['status'] // "subscribed","unsubscribed","cleaned","pending" ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $errors = curl_error($ch); curl_close($ch); return $httpCode; } function get_blocs($id) { global $lg, $wwwroot; } function get_color($id) { global $lg; $recolor = mysql_query_override("select * from gaia_couleurs where id = '".$id."'"); if(mysql_num_rows_override($recolor)>0) return mysql_result_override($recolor,'0','nom_fr'); else return ''; } function get_colors($id, $gencode) { global $lg, $wwwroot; $tabcolors = array(); $tabcolors_tmp = array(); $recprods = mysql_query_override("select p.*, pc.categorie_id as catid, c.nom_".$lg." as catname from gaia_produits p, gaia_produits_categories pc, gaia_categories c where pc.categorie_id = c.id and p.id = pc.produit_id and p.gencode = '".$gencode."' and p.etat=1 group by p.id"); if(mysql_num_rows_override($recprods)>1 && !empty($gencode)) { while($prods = mysql_fetch_array_override($recprods)) { $link = $wwwroot.'/'.$prods['id'].'-'.$prods['catid'].'-p-'.propre($prods['catname']).'-'.propre($prods['nom_'.$lg].' '.get_color($prods['color'])).'.html'; if($prods['id']==$id) $tabcolors[] = '<option value="" data-imagesrc="upload/little_'.$prods['image1'].'" >'.get_color($prods['color']).'</option>'; else $tabcolors_tmp[] = '<option value="'.$link.'" data-imagesrc="upload/little_'.$prods['image1'].'" >'.get_color($prods['color']).'</option>'; } $result = array_merge ($tabcolors, $tabcolors_tmp); return implode(' ',$result); } else { return ''; } } function get_price($prix) { $prix = number_format($prix,2,'.',''); $p = explode('.',$prix); return '<span>'.$p[0].'</span>€'.$p[1]; } function get_parent_cat($catid) { global $lg; $s = "SELECT * FROM gaia_categories WHERE id = $catid"; $r = mysql_query_override($s); $row = mysql_fetch_array_override($r); if($row['parent_id'] == 0) { $name = $row['nom_'.$lg]; return $name; } else { return get_parent_cat($row['parent_id']); } } function get_label_($id) { global $lg; $rec = mysql_query_override("select * from gaia_produits_marques pm, gaia_marques m where m.id = pm.marque_id and pm.produit_id = '".$id."'"); while($data = mysql_fetch_array_override($rec)) { echo '<div class="col-sm-6"> <div class="row"> <div class="col-sm-4"><img src="upload/'.$data['image'].'" class="img-fluid" /> </div> <div class="col-sm-8">'.stripslashes($data['nom_'.$lg]).'</div> </div> </div>'; } } function get_label_short_($id) { global $lg; $ret = ''; $ret = '<div class="row">'; $rec = mysql_query_override("select * from gaia_produits_marques pm, gaia_marques m where m.id = pm.marque_id and pm.produit_id = '".$id."'"); while($data = mysql_fetch_array_override($rec)) { $ret .= '<div class="col"> <img src="upload/'.$data['image'].'" class="img-fluid" /> </div>'; } $ret .= '</div>'; return $ret; } function get_origine($origine) { global $lg; $recorigine = mysql_query_override("select * from gaia_origines where id = '".$origine."'"); return mysql_result_override($recorigine,0,'nom_'.$lg); } function breadcrumb($id, $except = null) { global $lg, $wwwroot, $site; $s = "SELECT * FROM gaia_categories WHERE id = $id"; $r = mysql_query_override($s); $row = mysql_fetch_array_override($r); if($row['parent_id'] == 0) { $name = $row['nom_'.$lg]; return "<li class=\"breadcrumb-item\"><a href='".$wwwroot."'>".HOME."</a> </li><li class=\"breadcrumb-item\"> <a href='".$wwwroot.$id."-boutique-".propre($site)."-".propre($name).".html'>".$name."</a></li>"; } else { $name = $row['nom_'.$lg]; if(!empty($except) && $except == $name) { return breadcrumb($row['parent_id'], $except)." ".$name; } return breadcrumb($row['parent_id'], $except). " <li class=\"breadcrumb-item\"><a href='".$wwwroot.$id."-boutique-".propre($site)."-".propre($name).".html'>".$name."</a></li>"; } } function get_intensite($intensite) { global $lg; $ret = ''; for($i=0;$i<10;$i++) { if($i<$intensite) $ret .= '<i class="fas fa-circle"></i>'; else $ret .= '<i class="far fa-circle"></i>'; } return $ret; } function get_slider() { global $lg; $cpt=3; $rec = mysql_query_override("select * from gaia_accueil order by position"); while($data = mysql_fetch_array_override($rec)) { echo '<li data-index="rs-673" data-transition="zoomout" data-slotamount="default" data-easein="default" data-easeout="default" data-masterspeed="default" data-rotate="0" data-saveperformance="off" data-description=""> <img src="upload/'.$data['image'].'" alt="" data-bgposition="center center" data-bgfit="cover" data-bgrepeat="no-repeat" data-bgparallax="5" class="rev-slidebg" data-no-retina> <div class="tp-caption font-poppins font-white tp-resizeme rs-parallaxlevel-6" id="slide-8981-layer-1" style="z-index: 8; white-space: nowrap;" data-fontsize="[\'20\',\'24\',\'24\',\'24\']" data-fontweight="400" data-height="none" data-lineheight="[\'74\',\'74\',\'74\',\'74\']" data-responsive_offset="on" data-splitin="none" data-splitout="none" data-start="350" data-transform_idle="o:1;" data-transform_in="y:[100%];z:0;rX:0deg;rY:0;rZ:0;sX:1;sY:1;skX:0;skY:0;opacity:0;s:1500;e:Power4.easeInOut;" data-transform_out="y:[100%];s:1000;e:Power2.easeInOut;s:1000;e:Power2.easeInOut;" data-mask_in="x:0px;y:[100%];s:inherit;e:inherit;" data-mask_out="x:inherit;y:inherit;s:inherit;e:inherit;" data-whitespace="nowrap" data-width="none" data-x="[\'center\',\'center\',\'center\',\'center\']" data-hoffset="[\'0\',\'0\',\'0\',0\']" data-y="[\'center\',\'center\',\'center\',\'center\']" data-voffset="[\'-70\',\'-90\',\'-70\',\'-55\']"> '.stripslashes($data['titre1']).' </div> <!-- LAYER NR. 2 --> <div class="tp-caption font-poppins font-white tp-resizeme rs-parallaxlevel-6" id="slide-8981-layer-2" style="z-index: 8; white-space: nowrap;" data-fontsize="[\'70\',\'50\',\'80\',\'50\']" data-fontweight="600" data-height="none" data-lineheight="[\'120\',\'130\',\'110\',\'95\']" data-responsive_offset="on" data-splitin="none" data-splitout="none" data-start="550" data-transform_idle="o:1;" data-transform_in="z:0;rX:0deg;rY:0;rZ:0;sX:1.5;sY:1.5;skX:0;skY:0;opacity:0;s:1500;e:Power3.easeInOut;" data-transform_out="y:[100%];s:1000;e:Power2.easeInOut;s:1000;e:Power2.easeInOut;" data-mask_in="x:0px;y:0px;" data-mask_out="x:inherit;y:inherit;" data-whitespace="nowrap" data-width="none" data-x="[\'center\',\'center\',\'center\',\'center\']" data-hoffset="[\'0\',\'0\',\'0\',0\']" data-y="[\'center\',\'center\',\'center\',\'center\']" data-voffset="[\'0\',\'0\',\'0\',0\']"> '.stripslashes($data['titre2']).' </div> '.(!empty($data['lien'])?' <!-- LAYER NR. 3 --> <div class="tp-caption rs-parallaxlevel-6" id="slide-1291-layer-3" data-x="[\'center\',\'center\',\'center\',\'center\']" data-hoffset="[\'0\',\'0\',\'0\',\'0\']" data-y="[\'center\',\'center\',\'center\',\'center\']" data-voffset="[\'90\',\'120\',\'100\',80\']" data-width="none" data-height="none" data-whitespace="nowrap" data-transform_idle="o:1;" data-transform_hover="o:1;rX:0;rY:0;rZ:0;z:0;s:300;e:Power1.easeInOut;" data-style_hover="c:rgba(255, 255, 255, 1.00);bc:rgba(255, 255, 255, 1.00);cursor:pointer;" data-transform_in="y:50px;opacity:0;s:1500;e:Power4.easeInOut;" data-transform_out="y:[175%];s:1000;e:Power2.easeInOut;s:1000;e:Power2.easeInOut;" data-mask_out="x:inherit;y:inherit;s:inherit;e:inherit;" data-start="1000" data-splitin="none" data-splitout="none" data-responsive_offset="on" data-responsive="off" style="z-index: 8; white-space: nowrap;outline:none;"> <a class="tp-button1 button medium full-rounded thin white ml-20" href="'.$data['lien'].'">'.$data['intitule_lien'].'</a> </div> ':'').' </li> '; } } function get_bloc_home() { global $lg; $rec = mysql_query_override("select * from gaia_accueil_bloc order by position"); while($data = mysql_fetch_array_override($rec)) { echo (!empty($data['lien'])?'<a href="'.$data['lien'].'">':'').'<img src="upload/'.$data['image'].'" class="img-fluid" alt="'.stripslashes($data['titre1']).'"/>'.(!empty($data['lien'])?'</a>':''); } } function get_article($id) { global $lg; $rec = mysql_query_override("select * from gaia_static where id = '".$id."'"); $data = mysql_fetch_array_override($rec); return ' <div class="col-sm-4 article"> <a href="'.get_link($id).'"><img class="img-fluid" src="upload/'.$data['image1'].'" alt="'.stripslashes($data['nom_'.$lg.'']).'"></a> <h4>'.stripslashes($data['nom_'.$lg.'']).'</h4> '.(!empty($data['surtitre_'.$lg.''])?'<span class="time"><span>'.stripslashes($data['surtitre_'.$lg.'']).'</span></span>':'').' <p>'.stripslashes($data['descriptif_'.$lg.'']).'</p> '.(($data['rub']<>'boutique')?'<a class="more" href="'.get_link($id).'">LIRE LA SUITE</a>':'').' </div>'; } function getdatezeez($date,$separ='-') { $ddeb = explode($separ,$date); return $ddeb; } function get_label($produit_id, $label_id=0) { global $lg; $sql = "select l.* from gaia_labels l, gaia_produits_labels pl where value_id = l.id and produit_id = '".$produit_id."' ".(($label_id>0)?" and label_id = '".$label_id."' ":""); $rec = mysql_query_override($sql); if(mysql_num_rows_override($rec)) return mysql_fetch_array_override($rec); else return false; } function get_link($id, $long=0, $aclass='', $liclass='') { global $lg,$wwwroot,$site; //$long = 0 -> lien / $long = 1 -> lien + li / $long = 2 -> lien a / $long = 3 -> lien a.nav-link $rec = mysql_query_override("select * from gaia_static where id = '".$id."'"); $data = mysql_fetch_array_override($rec); return ($long==0?$wwwroot.$id.'-p-'.propre($data['nom_'.$lg.'']).'-'.propre($site).'.html': (($long==1)?'<li class="'.$liclass.'"><a class="'.$aclass.'" href="'.$wwwroot.$id.'-p-'.propre($data['nom_'.$lg.'']).'-'.propre($site).'.html" aria-label="'.stripslashes($data['nom_'.$lg.'']).'">'.stripslashes($data['nom_'.$lg.'']).'</a></li>': (($long==2)?'<a class="'.$aclass.'" href="'.$wwwroot.$id.'-p-'.propre($data['nom_'.$lg.'']).'-'.propre($site).'.html" aria-label="'.stripslashes($data['nom_'.$lg.'']).'">'.stripslashes($data['nom_'.$lg.'']).'</a>': '<a class="nav-link '.$aclass.'" href="'.$wwwroot.$id.'-p-'.propre($data['nom_'.$lg.'']).'-'.propre($site).'.html" aria-label="'.stripslashes($data['nom_'.$lg.'']).'">'.stripslashes($data['nom_'.$lg.'']).'</a>'))); } function get_static($id) { if(is_numeric($id)) $rec = mysql_query_override("select * from gaia_static where id = '".$id."'"); else $rec = mysql_query_override("select * from gaia_static where rub = '".$id."' limit 0,1"); if(mysql_num_rows_override($rec)>0) return mysql_fetch_array_override($rec); else return null; } function get_static_prod($id, $limit=0, $order='p.position') { $tabstat = array(); $sql = "select sp.produit_id from gaia_static_produits sp, gaia_produits p where static_id = '".$id."' and produit_id = p.id and p.etat = 1 order by ".$order." ".(($limit>0)?'limit 0,'.$limit:'').""; $rec = mysql_query_override($sql); while($data = mysql_fetch_array_override($rec)) { $tabstat[] = $data; } return $tabstat; } function get_static_list($rub, $mea='', $limit=0, $order='position') { $tabstat = array(); $sql = "select * from gaia_static where rub = '".$rub."' and etat = 1 ".(!empty($mea)?'and '.$mea.' = 1':'')." order by ".$order." ".(($limit>0)?'limit 0,'.$limit:'').""; $rec = mysql_query_override($sql); while($data = mysql_fetch_array_override($rec)) { $tabstat[] = $data; } return $tabstat; } function get_static_list_parent($rub, $parent='', $val='', $limit=0, $order='position') { $tabstat = array(); $sql = "select * from gaia_static where rub = '".$rub."' and etat = 1 ".(!empty($parent)?'and '.$parent.' = '.$val.'':'')." order by ".$order." ".(($limit>0)?'limit 0,'.$limit:'').""; $rec = mysql_query_override($sql); while($data = mysql_fetch_array_override($rec)) { $tabstat[] = $data; } return $tabstat; } function header_page($titre1, $bandeau='', $bread='') { global $wwwroot; //$type : 0 = caddie / 1 : static : 2: prod echo ' <section class="banner page"> '.(!empty($bandeau)?'<img src="upload/'.$bandeau.'" alt="'.stripslashes($titre1).'">':'').' <div class="filter"></div> <div class="filter-top"></div> </section> '; if(!empty($bread)) { echo '<section> <div class="container"> <div class="row"> <div class="col-12"> <ul class="ariane">'.$bread.'</ul> </div> </div> </div> </section>'; } echo '<section '.(empty($bread)?'class="py-5 my-5"':'').'> <div class="container"> <div class="row"> <div class="col-12">'; } function footer_page() { echo '</div></div></div></section>'; } function first_img ($imok, $id, $system='') { if (!empty($system)) $sup = " and s.nom_fr = '".$system."' "; else $sup = ""; $verif = mysql_query_override ("SELECT s.* FROM gaia_produits_tailles ps, gaia_tailles s WHERE ps.produit_id = '".$id."' ".$sup." and ps.taille_id > 0 and ps.taille_id = s.id group by taille_id order by ps.prix asc, s.position, s.nom_fr"); if(mysql_num_rows_override($verif)>0) { $system = mysql_fetch_array_override($verif); $recc = mysql_query_override ("select * from gaia_produits_photos where produit_id = '".$id."' and taille_id = '".$system['id']."'"); $img = mysql_fetch_array_override($recc); $imok = $img['image1']; } return $imok; } function verif_link($link) { if (mb_ereg($link,$_SERVER['PHP_SELF'])) echo 'class="open"'; } function est_identifie() { /* Retourne true si l'utilisateur des identifie */ return isset($_SESSION) && isset($_SESSION['utilisateur']) && !empty($_SESSION['utilisateur']['email']) && vb($_SESSION['url']) == $_SERVER['HTTP_HOST']; } function cut_sentence($Texte,$nbcar=0) { if ( strlen($Texte) > $nbcar && (0!=$nbcar) ) { $Tmp_Tb = explode( ' ', $Texte ); $Tmp_Count = 0; $Tmp_O = ''; while( list(,$v) = each($Tmp_Tb) ) { if ( strlen($Tmp_O) >= $nbcar ) break; $Tmp_O .= $v.' '; } $Tmp_O = substr( $Tmp_O, 0, strlen($Tmp_O)-1 ); if ( count($Tmp_Tb) > 1 ) $Tmp_O .= '...'; } else $Tmp_O = $Texte; return $Tmp_O; } function necessite_identification() { /* Cette fonction vérifie si l'utilisateur est identifié. Si non affiche * l'écran d'authentification avant de laisser l'utilisateur continuer */ global $wwwroot; if (! est_identifie()) { if(!mb_ereg('administrer', $_SERVER['PHP_SELF'])) $link = $wwwroot.'membre.php'; else $link = $wwwroot.'administrer/login.php'; $_SESSION['wantsurl'] = $_SERVER['PHP_SELF']; echo "<meta http-equiv='Refresh' content='0; url=".$link."'>"; } } function necessite_priv($priv) { /* Cette fonction vérifie si l'utilisateur a les privilèges de $priv. Si non affiche * l'écran informant que les privilèges sont insuffisants et arrête le traitement */ global $wwwroot; if ( vb($_SESSION['utilisateur']['priv']) != "admin" ) { if ( vb($_SESSION['utilisateur']['priv']) != "redac" ) { ?> <html> <head> <title>Privilèges Non accordés</title> </head> <style> h1 { font-family: Tahoma, Arial, sans-serif; font-size: 13px; font-weight: bold; color: #CC0000; } </style> <body bgcolor=#ffffff link=#0000ff vlink=#000099 alink=#ff0000> <h1 align=center>Vous n'avez pas les autorisations nécessaires pour accéder à l'administration du site. <p></p>Insérer votre identifiant et votre mot de passe. <a href="<?=$wwwroot?>/index.php">Cliquez ici pour revenir à la boutique</a> </h1> </body> </html> <? die; } } } function necessite_priv_affilie($priv) { /* Cette fonction vérifie si l'utilisateur a les privilèges de $priv. Si non affiche * l'écran informant que les privilèges sont insuffisants et arrête le traitement */ global $wwwroot; if ( $_SESSION['utilisateur']['priv'] != "affi") { ?> <html> <head> <title>Privilèges Non accordés</title> </head> <style> h1 { font-family: verdana, Arial, sans-serif; font-size: 10pt; font-weight: bold; color: #CC0000; } </style> <body bgcolor=#ffffff link=#0000ff vlink=#000099 alink=#ff0000> <h1 align=center>Vous n'avez pas les autorisations nécessaires pour accéder à l'interface Affilié. <p></p>Insérer votre identifiant et votre mot de passe. </h1> </body> </html> <? die; } } function a_priv($priv) { /* Renvoie true si l'utilisateur de la session a le privilège $priv */ return $_SESSION['utilisateur']['priv'] == $priv; } function affiche_arbre_categorie($catid=false) { /* Affiche l'arbre de categories tree en appelemnt recupere_arbre_categorie */ echo recupere_arbre_categorie($catid); } function recupere_arbre_categorie($catid=0) { /* Renvoie l'arbre des catégories des produits, en commençant de top jusquà la * categorie specifiee par $id */ global $wwwroot; $qid = mysql_query_override("SELECT parent_id, nom_".$_SESSION['langue']." FROM gaia_categories WHERE id = '$catid' AND etat = '1'"); if ($qid) { if (mysql_num_rows_override($qid)) { list($parent, $nom) = mysql_fetch_row_override($qid); $nom = "<a class=petit href='$wwwroot/achat/index.php?catid=$catid'>$nom</a>"; } else { $parent = 0; $nom = ""; } } else { $parent = 0; $nom = ""; } if ($parent > 0) { return affiche_arbre_categorie($parent) . "<span class=\"petit\"> > " . $nom."</span"; } elseif ($catid > 0) { return "<span class=\"petit\"> ".HERE."</span> : <span class=\"petit\"><a class=petit href='$wwwroot/achat/index.php'>".HOME."</a> > " . $nom."</span>"; } elseif ($catid == 0) { return "<span class=\"petit\"> ".HERE."</span> : <a class=petit href='$wwwroot/achat/index.php'>".HOME."</a>"; } } function construit_arbo_cat(&$sortie, &$preselectionne, $parent=0, $indent="") { /* Parcours récurcivement l'arbre des catégories, commençant d'un parent * il descend dans l'arbre et affiche les options pour une liste de boîtes de sélection * Les élément preselectionnés sont marqué comme tel */ $qid = mysql_query_override("SELECT id, nom_".$_SESSION['langue'].", parent_id FROM gaia_categories WHERE parent_id = $parent ORDER BY position asc, nom_fr asc"); if ($qid) { if (mysql_num_rows_override($qid) > 0) { while ($cat = mysql_fetch_array_override($qid)) { $selectionne = in_array($cat['id'], $preselectionne) ? "selected" : ""; $sortie .= "<option value=\"" . $cat['id'] . "\" $selectionne>$indent" .stripslashes($cat['nom_'.$_SESSION['langue'].''])."</option>"; if ($cat['id'] != $parent) { construit_arbo_cat($sortie, $preselectionne, $cat['id'], $indent." "); } } } } } function construit_arbo_cat_amazon(&$sortie, &$preselectionne, $parent=0, $indent="") { /* Parcours récurcivement l'arbre des catégories, commençant d'un parent * il descend dans l'arbre et affiche les options pour une liste de boîtes de sélection * Les élément preselectionnés sont marqué comme tel */ $qid = mysql_query_override("SELECT id, nom_".$_SESSION['langue'].", parent_id FROM gaia_categories_amazon WHERE parent_id = $parent ORDER BY id asc"); if ($qid) { if (mysql_num_rows_override($qid) > 0) { while ($cat = mysql_fetch_array_override($qid)) { $selectionne = in_array($cat['id'], $preselectionne) ? "selected" : ""; $sortie .= "<option value=\"" . $cat['id'] . "\" $selectionne>$indent" .stripslashes($cat['nom_'.$_SESSION['langue'].''])."</option>"; if ($cat['id'] != $parent) { construit_arbo_cat_amazon($sortie, $preselectionne, $cat['id'], $indent." "); } } } } } function select_arbo_cat(&$sortie, $parent=0, $indent="") { $qid = mysql_query_override("SELECT id, nom_".$_SESSION['langue'].", parent_id FROM gaia_categories WHERE parent_id = $parent ORDER BY position, nom_".$_SESSION['langue']."") or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); if ($qid) { if (mysql_num_rows_override($qid) > 0) { while ($cat = mysql_fetch_array_override($qid)) { $sortie .= "<option value=\"" . $cat['id'] . "\" ".((isset($_REQUEST['categorie']) && $_REQUEST['categorie'] ==$cat['id'])?'selected':'')."> $indent" .stripslashes($cat['nom_'.$_SESSION['langue'].''])."</option>"; if ($cat['id'] != $parent) { select_arbo_cat($sortie, $cat['id'], $indent." "); } } } } } function affiche_arbre_rubrique($rubid=false) { echo recupere_arbre_rubrique($rubid); } function recupere_arbre_rubrique($rubid=0) { /* Renvoie l'arbre des catégories des produits, en commençant de top jusquà la * categorie specifiee par $id */ global $wwwroot; $qid = mysql_query_override("SELECT parent_id, nom_".$_SESSION['langue']." FROM gaia_rubriques WHERE id = $rubid AND etat = '1'"); if ($qid) { if (mysql_num_rows_override($qid)) { list($parent, $nom) = mysql_fetch_row_override($qid); $nom = "<a class=petit href='$wwwroot/lire/index.php?rubid=$rubid'>$nom</a>"; } else { $parent = 0; $nom = HERE." : "; } } else { $parent = 0; $nom = ""; } if ($parent > 0) { return affiche_arbre_rubrique($parent) . " > " . $nom; } elseif ($rubid > 0) { return "<span class=\"petit\">".HERE."</span> : <a class=petit href='$wwwroot/lire/index.php'>".HOME."</a> > " . $nom; } elseif ($rubid == 0) { return "<span class=\"petit\">".HERE."</span> : <a class=petit href='$wwwroot/lire/index.php'>".HOME."</a>"; } } function construit_arbo_rub(&$sortie, &$preselectionne, $parent=0, $indent="") { $qid = mysql_query_override("SELECT id, nom_".$_SESSION['langue'].", parent_id FROM gaia_rubriques WHERE parent_id = $parent ORDER BY position") or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); if ($qid) { if (mysql_num_rows_override($qid) > 0) { while ($rub = mysql_fetch_array_override($qid)) { $selectionne = in_array($rub['id'], $preselectionne) ? "selected" : ""; $sortie .= "<option value=\"" . $rub['id'] . "\" $selectionne>$indent" . $rub['nom_'.$_SESSION['langue'].'']; if ($rub['id'] != $parent) { construit_arbo_rub($sortie, $preselectionne, $rub['id'], $indent." "); } } } } } // Fonction récursive pour rechercher si $noeud fait partie de l'arborescence d'un noeud donné // Utilisé par construit_menu afin d'ouvrir les DIV necesssaires dans l'arborescence function parent_noeud_rub($noeud_rub,$aktul_rub,&$actif_rub){ // Si c'est pas la racine if($aktul_rub != 0 && $noeud_rub != 0){ // Recherche le parent du noeud à tester $sql=mysql_query_override("SELECT id, parent_id FROM gaia_rubriques WHERE id = $aktul_rub"); // récupère le résultat $rub=mysql_fetch_array_override($sql); // Appel récursif jusqu'à la racine parent_noeud_rub($noeud_rub,$rub['parent_id'],$actif_rub); // Si le noeud testé est le noeud recherché if($rub['parent_id']==$noeud_rub){ // Met le drapeau à 1 $actif_rub=1; } } } function recupere_articles_caddie() { /* Retourne $qid de tous les éléments du caddie */ $in_clause = $_SESSION['caddie']->recupere_produitid_list(); if (empty($in_clause)) { return false; } $requete = "SELECT id, reference, nom, promotion, prix, tva, poids, stock FROM gaia_produits WHERE id IN ($in_clause)"; return mysql_query_override($requete); } function initialise_mot_passe($email) { /* Initialise le mot de passe de l'utilisateur et lui envoie par e-mail*/ global $support, $site; /* Chargement des infos de l'utilisateur */ $qid = mysql_query_override("SELECT email, prenom, nom_famille FROM gaia_utilisateurs WHERE email = '$email'"); $utilisateur = mysql_fetch_array_override($qid); /* initialise le mot de passe */ $nouveau_mot_passe = MDP(); $qid = mysql_query_override("UPDATE gaia_utilisateurs SET mot_passe = '" . md5($nouveau_mot_passe) ."' WHERE email = '$email'"); /* envoie par email */ $email = $utilisateur['email']; $mailSujet = SUBJECT_PASSWORD_EMAIL." : ". $mailObjet = OBJECT_EMAIL_PASSWORD; $mailObjet .= IDENTIFIANT_EMAIL." : ".$email."\n\r"; $mailObjet .= IDENTIFIANT_PASSWORD." : ".$nouveau_mot_passe."\n\r"; mail_confirm($email,$mailSujet,nl2br($mailObjet),"From:$support"); } function lit_modele($nom_fichier, &$var) { /* Retourne une chaine contenant le contenu d'un fichier modele avec interpolation * des variables. Toutes les variables doivent être dans le tableau $var[] * ATTENTION: Ne pas utiliser sur les gros fichiers!! */ $temp = str_replace("\\", "\\\\", implode(file($nom_fichier), "")); $temp = str_replace('"', '\"', $temp); eval("\$modele = \"$temp\";"); return $modele; } function chop_ccnum($ccnum) { /* Retourne des infos parcélaires sur la carte de crédit pour discrétion */ return substr($ccnum, 0, 4) . "..." . substr($ccnum, -4); } function enregistre_commandeinfo(&$frm) { $commande = array(); $commande['client1'] = $frm['client1']; $commande['contact1'] = $frm['contact1']; $commande['email1'] = $frm['email1']; $commande['adresse1'] = $frm['adresse1']; $commande['code_postal1'] = $frm['code_postal1']; $commande['ville1'] = $frm['ville1']; $commande['pays1'] = $frm['pays1']; $commande['client2'] = $frm['client2']; $commande['contact2'] = $frm['contact2']; $commande['email2'] = $frm['email2']; $commande['adresse2'] = $frm['adresse2']; $commande['code_postal2'] = $frm['code_postal2']; $commande['ville2'] = $frm['ville2']; $commande['pays2'] = $frm['pays2']; $commande['commentaires'] = $frm['commentaires']; $commande['cgv'] = $frm['cgv']; $commande['point_relais'] = $frm['point_relais']; $commande['the_point_relais'] = $frm['the_point_relais']; $criteres = explode("|", $frm['paiement']); $paiement = $criteres[0]; $tarif_paiement = $criteres[1]; $id_paiement = $criteres[2]; $commande['paiement'] = $paiement; $commande['tarif_paiement'] = $tarif_paiement; $commande['id_paiement'] = $id_paiement; $_SESSION['commande'] = $commande; } function charge_commande() { if (empty($_SESSION['commande'])) { return false; } else { return $_SESSION['commande']; } } function vide_commandeinfo() { unset($_SESSION['commande']); } function print_societe() { /* Affiche la liste des catégories qui sont spéciales */ $qid = mysql_query_override("SELECT * FROM gaia_societe"); if ($qid) { if (mysql_num_rows_override($qid) > 0) { $ligne = mysql_fetch_object_override($qid); echo "<br />"; if (!empty($ligne->societe)) { echo "<br /><b>" . html_entity_decode($ligne->societe) . "</b> ";} if (!empty($ligne->adresse)) { echo "<br />" .html_entity_decode($ligne->adresse) . " ";} if (!empty($ligne->code_postal)) { echo "<br />" .$ligne->code_postal . " ";} if (!empty($ligne->ville)) { echo " " .html_entity_decode($ligne->ville) . " ";} if (!empty($ligne->pays)) { echo "<br />" .html_entity_decode($ligne->pays) . " ";} if (!empty($ligne->tel)) { echo "<br />Tel. : " . $ligne->tel . "";} if (!empty($ligne->fax)) { echo "<br />Fax. : " . $ligne->fax . "";} if (!empty($ligne->siren)) { echo "<br />Siren : " . $ligne->siren . "";} if (!empty($ligne->tvaintra)) { echo "<br />TVA Intracommunaire : " . $ligne->tvaintra. "";} if (!empty($ligne->cnil)) { echo "<br />Numéro CNIL. : " . $ligne->cnil . "";} echo "<br />"; } } } function print_rib() { /* Affiche la liste des catégories qui sont spéciales */ $qid = mysql_query_override("SELECT * FROM gaia_societe"); if ($qid) { if (mysql_num_rows_override($qid) > 0) { $ligne = mysql_fetch_object_override($qid); print "<div class=\"normal\">"; if (!empty($ligne->code_banque)) { print "<b>Code banque :</b> $ligne->code_banque<br />";} if (!empty($ligne->code_guichet)) { print "<b>Code guichet :</b> $ligne->code_guichet<br />";} if (!empty($ligne->numero_compte)) { print "<b>Numéro de compte :</b> $ligne->numero_compte<br />";} if (!empty($ligne->cle_rib)) { print "<b>Clé RIB :</b> $ligne->cle_rib<br />";} if (!empty($ligne->titulaire)) { print "<b>Titulaire du compte :</b> $ligne->titulaire<br />";} if (!empty($ligne->domiciliation)) { print "<b>Domiciliation :</b> $ligne->domiciliation<br />";} if (!empty($ligne->iban)) { print "<b>IBAN :</b> $ligne->iban<br />";} if (!empty($ligne->swift)) { print "<b>SWIFT:</b> $ligne->swift<br />";} print "</div>"; } } } function fdate(&$date_nok) { $date_ok = date("d-m-Y H:i",strtotime($date_nok)); return $date_ok; } function fprix(&$prix_nok) { $prix_ok = number_format($prix_nok,2, ',', ' '); return $prix_ok; } function pprix(&$prix_nok) { $prix_ok = number_format($prix_nok,0, '', ''); return $prix_ok; } # fonction de validation d'adresse mail trouvée sur http://www.phpinfo.net/?p=trucs&rub=astuces function EmailOK($email) { return( ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'. '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email) ); } # création d'un mot de passe crypté function unique_id() { mt_srand((double)microtime()*1000000); return md5( mt_rand(0,9999999) ); } function return_date_fr($timestamp){ // par defaut on affiche la date du jour $jsem = date('w', strtotime($timestamp)); // jour de la semaine $jmois = date('j', strtotime($timestamp)); // jour du mois ('d' est aussi utilisable) $mois = date('n', strtotime($timestamp)); // mois de l'annee $annee = date('Y', strtotime($timestamp)); // l'annee $tabjour=array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'vendredi', 'Samedi'); $tabmois=array('0', 'janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'); // construction de la date formatee $datefr = $tabjour[$jsem]." $jmois ".$tabmois[$mois]." $annee"; // affichage (remplacer 'echo' par 'return' pour retourner le resultat) return $datefr; } function cree_commande(&$commande) { // Enregistre la commande dans la base global $normal; global $express; global $site; global $support; global $wwwroot; global $seuil; global $affiliate_rate; global $id_colissimo; global $pwd_colissimo; global $agence_dpd; global $contrat_dpd; global $active_promo1; global $ca_promo; global $remise_ca_promo; $remise = 0; $tab_pays1 = mysql_fetch_array_override(mysql_query_override("SELECT pays_".$_SESSION['langue']." FROM gaia_pays WHERE id = '".$commande['pays1']."'")); // Constuit les infos du client en une chaîne // Addresse de facturation $client_info1 = $commande['client1']."\n" .$commande['adresse1']."\n" .$commande['code_postal1']."\n" .$commande['ville1']."\n" .$tab_pays1['pays_'.$_SESSION['langue'].'']."\n" .$commande['contact1']."\n" .$commande['email1']."\n"; $coord1 = explode(" ", $commande['client1']); if (empty($commande['adresse2']) || empty($commande['code_postal2']) || empty($commande['ville2'])) { // Addresse de livraison $client_info2 = $commande['client1']."\n" .$commande['adresse1']."\n" .$commande['code_postal1']."\n" .$commande['ville1']."\n" .$_SESSION['caddie']->pays."\n" .$commande['contact1']."\n" .$commande['email1']."\n"; } else { // Addresse de livraison $client_info2 = $commande['client2']."\n" .$commande['adresse2']."\n" .$commande['code_postal2']."\n" .$commande['ville2']."\n" .$_SESSION['caddie']->pays."\n" .$commande['contact2']."\n" .$commande['email2']."\n"; } $coord1 = explode(" ", $commande['client1']); $coord2 = explode(" ", $commande['client2']); /* Le reversement affilié est calculé sur le total ht des produits */ if (isset($_SESSION['affilie'])) { $affilie = 1; $statut_affilie = 0; $montant_affilie = $_SESSION['caddie']->total_produit_ht * $affiliate_rate/100; } else { $affilie = 0; $montant_affilie = 0; $statut_affilie = 0;} $sql = " INSERT INTO gaia_commandes ( email , id_utilisateur , o_timestamp , a_timestamp , statut , statut_details , client_info1 , client_info2 , commentaires , montant , montant_ht , total_tva , tva_transport , total_produit_avant_promo , total_produit_avant_promo_ht , total_produit , type , zone , zone_tva , pays , transport , cout_transport , cout_transport_ht , lang , points , points_etat , poids , affilie , montant_affilie , statut_affilie , remise_produit , remise_produit_ht , remise_client , remise_client_ht , remise_client_percent , remise_speciale , remise_speciale_ht , remise_speciale_percent , remise_code , remise_code_ht , remise_code_percent , code_promo , code_cheque_cadeau , remise_cheque , remise_cheque_ht , code_bon , remise_bon , remise_bon_ht , avoir , paiement , tarif_paiement , prenom_bill , nom_bill , adresse_bill , zip_bill , ville_bill , pays_bill , email_bill , telephone_bill , prenom_ship , nom_ship , adresse_ship , zip_ship , ville_ship , pays_ship , email_ship , telephone_ship , id_parrain , parrain , ecotaxe_ttc , ecotaxe_ht , point_relais , point_relais_id ) VALUES ( '{$_SESSION['utilisateur']['email']}' ,'".intval($_SESSION['utilisateur']['id_utilisateur'])."' ,now() ,now() ,0 ,'commande initialisée' ,'".addslashes($client_info1)."' ,'".addslashes($client_info2)."' ,'".addslashes($commande['commentaires'])."' ,'".$_SESSION['caddie']->total."' ,'".$_SESSION['caddie']->total_ht."' ,'".$_SESSION['caddie']->total_tva."' ,'".$_SESSION['caddie']->tva_transport."' ,'".$_SESSION['caddie']->total_produit_avant_promo."' ,'".$_SESSION['caddie']->total_produit_avant_promo_ht."' ,'".$_SESSION['caddie']->total_produit."' ,'".addslashes($_SESSION['caddie']->type)."' ,'".addslashes($_SESSION['caddie']->zone)."' ,'".intval($_SESSION['caddie']->zoneTva)."' ,'".addslashes($_SESSION['caddie']->pays)."' ,'".addslashes($_SESSION['caddie']->zone)." - ".addslashes($_SESSION['caddie']->type)."' ,'".$_SESSION['caddie']->cout_transport."' ,'".$_SESSION['caddie']->cout_transport_ht."' ,'".$_SESSION['langue']."' ,'".$_SESSION['caddie']->total_points."' ,'0' ,'".$_SESSION['caddie']->total_poids."' ,'".$affilie."' ,'".$montant_affilie."' ,'".$statut_affilie."' ,'".$_SESSION['caddie']->total_remise_produit."' ,'".$_SESSION['caddie']->total_remise_produit_ht."' ,'".$_SESSION['caddie']->total_remise_client."' ,'".$_SESSION['caddie']->total_remise_client_ht."' ,'".$_SESSION['caddie']->remise_client_percent."' ,'".$_SESSION['caddie']->total_remise_speciale."' ,'".$_SESSION['caddie']->total_remise_speciale_ht."' ,'".$_SESSION['caddie']->remise_speciale_percent."' ,'".$_SESSION['caddie']->total_remise_code."' ,'".$_SESSION['caddie']->total_remise_code_ht."' ,'".$_SESSION['caddie']->remise_code_percent."' ,'".addslashes($_SESSION['caddie']->code_promo)."' ,'".addslashes($_SESSION['caddie']->code_cheque)."' ,'".$_SESSION['caddie']->total_remise_cheque."' ,'".$_SESSION['caddie']->total_remise_cheque_ht."' ,'".addslashes($_SESSION['caddie']->code_bon)."' ,'".$_SESSION['caddie']->total_remise_bon."' ,'".$_SESSION['caddie']->total_remise_bon_ht."' ,'".$_SESSION['caddie']->avoir."' ,'".addslashes($_SESSION['caddie']->paiement)."' ,'".$_SESSION['caddie']->tarif_paiement."' , '".addslashes(vb($coord1[0]))."' , '".addslashes(vb($coord1[1]))."' , '".addslashes($commande['adresse1'])."' , '".addslashes($commande['code_postal1'])."' , '".addslashes($commande['ville1'])."' , '".addslashes($tab_pays1['pays_'.$_SESSION['langue'].''])."' , '".addslashes($commande['email1'])."' , '".addslashes($commande['contact1'])."' , '".addslashes(vb($coord2[0]))."' , '".addslashes(vb(str_replace($coord2[0],'', $commande['client2'])))."' , '".addslashes($commande['adresse2'])."' , '".addslashes($commande['code_postal2'])."' , '".addslashes($commande['ville2'])."' , '".addslashes($_SESSION['caddie']->pays)."' , '".addslashes($commande['email2'])."' , '".addslashes($commande['contact2'])."' ,'".vn($_SESSION['utilisateur']['id_parrain'])."' ,'".vb($_SESSION['utilisateur']['type'])."' ,'".$_SESSION['caddie']->ecotaxe_ttc."' ,'".$_SESSION['caddie']->ecotaxe_ht."' , '".addslashes($commande['point_relais'])."' , '".addslashes($commande['the_point_relais'])."' )"; $qid = mysql_query_override($sql) or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); $commandeid = mysql_insert_id_override(); //------------------------------------------ // Inscription à la newsletter par marque si l'utilisateur est opt-in if($_SESSION['utilisateur']['newsletter']==1) newsletter_mark($commandeid, $_SESSION['utilisateur']['email']); //------------------------------------------ $codp = mysql_fetch_array_override(mysql_query_override("SELECT * FROM gaia_pays WHERE pays_".$_SESSION['langue']." = '".$_SESSION['caddie']->pays."'")); //#################################################### $pos = stripos($_SESSION['caddie']->type, 'Colissimo'); if($pos !== false) { $poids = $_SESSION['caddie']->total_poids/1000; $prenom = vb($coord2[0]); $nom_famille = str_replace($coord2[0],'', $commande['client2']); $adresse = substr($commande['adresse2'],0,35); $adresse2 = substr($commande['adresse2'],35,100); $telephone = $commande['contact2']; $ville = $commande['ville2']; $cp = $commande['code_postal2']; $email = $commande['email2']; $pays = $codp['iso']; $num_dossier = $commandeid; include(__DIR__.'/envoi_colissimo.php'); } //#################################################### $pos = stripos($_SESSION['caddie']->type, 'Mondial'); if($pos !== false) { $poids = $_SESSION['caddie']->total_poids; $total = $_SESSION['caddie']->total; $cli = $commande['client2']; $adresse = substr($commande['adresse2'],0,35); $adresse2 = substr($commande['adresse2'],35,100); $telephone = $commande['contact2']; $ville = $commande['ville2']; $cp = $commande['code_postal2']; $pays = $_SESSION['caddie']->pays; $point_relais = $commande['point_relais']; $point_relais_pays = 'FR'; $email = $commande['email2']; $num_dossier = $commandeid; //include(__DIR__.'/envoi_mondialrelay.php'); ---> Etiquette facturée à l'édition : génération après paiement } //#################################################### $pos = stripos($_SESSION['caddie']->type, 'DPD'); if($pos !== false) { $numcolis = $commandeid.'_'.$agence_dpd.$contrat_dpd; $sql="UPDATE gaia_commandes SET colis ='".$numcolis."' WHERE id='".$commandeid."'"; mysql_query_override($sql); } //#################################################### mysql_query_override("UPDATE gaia_utilisateurs SET avoir = avoir - '".vn($_SESSION['caddie']->avoir)."', parrain = '' WHERE id_utilisateur = '".intval($_SESSION['utilisateur']['id_utilisateur'])."'"); if (isset($_SESSION['affilie'])) { mysql_query_override("INSERT INTO gaia_utilisateurs_commandes (utilisateur_id, commande_id) VALUES ('".$_SESSION['affilie']."', '".$commandeid."')"); } if (!empty($_SESSION['caddie']->code_cheque)) { mysql_query_override("UPDATE gaia_cheques_cadeaux SET a_timestamp = now(), etat = '0' WHERE code = '".$_SESSION['caddie']->code_cheque."'"); } /* ajout des articles à la table commandes_articles */ foreach ($_SESSION['caddie']->articles as $i => $produitid) { $qid = mysql_query_override("SELECT * FROM gaia_produits WHERE id= '$produitid'"); if ($qid) { if (mysql_num_rows_override($qid) > 0) { $article=mysql_fetch_array_override($qid); if ($article['on_stock'] == 1) { $c = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_couleurs WHERE nom_".$_SESSION['langue']." = '".$_SESSION['caddie']->couleur[$i]."'")); $t = mysql_fetch_array_override(mysql_query_override("SELECT id FROM gaia_tailles WHERE nom_".$_SESSION['langue']." = '".$_SESSION['caddie']->taille[$i]."'")); $s = mysql_fetch_array_override(mysql_query_override("SELECT stock, ean FROM gaia_stocks WHERE produit_id = '".$article['id']."' AND couleur_id = '".vn($c['id'])."' AND taille_id = '".vn($t['id'])."'")); mysql_query_override("UPDATE gaia_produits_listes set etat = 1 where produit_id = '".$article['id']."' and liste_id = '".$_SESSION['caddie']->liste_id[$i]."' and couleur = '".vn($c['id'])."' and taille = '".vn($t['id'])."'"); $stock = $s['stock'] - $_SESSION['caddie']->quantite[$i]; if ($stock >= 0) { $stock_restant = $stock; } else { $stock_restant = 0; } if ($stock < 0) { $stock_to_order = $_SESSION['caddie']->quantite[$i] - $s['stock'] ; /* Calcul le stock restant à commander */ mysql_query_override("UPDATE gaia_commandes SET statut = '9' WHERE id = '".$commandeid."'"); /* Passage de la commande en stand by */ } else { $stock_to_order = 0; } mysql_query_override("UPDATE gaia_stocks SET stock = ".$stock_restant." WHERE produit_id = '".$article['id']."' AND couleur_id = '".vn($c['id'])."' AND taille_id = '".vn($t['id'])."'"); $sqlStockTemp = "SELECT stock, qte FROM gaia_stocks_temp WHERE produit_id = '".$article['id']."' AND couleur_id = '".vn($c['id'])."' AND taille_id = '".vn($t['id'])."'"; $resStockTemp = mysql_query_override($sqlStockTemp); $StockTemp = mysql_fetch_array_override($resStockTemp); if ($StockTemp['qte'] == $_SESSION['caddie']->quantite[$i]) { mysql_query_override("DELETE FROM gaia_stocks_temp WHERE produit_id = '".$article['id']."' AND couleur_id = '".vn($c['id'])."' AND taille_id = '".vn($t['id'])."'"); } else { mysql_query_override("UPDATE gaia_stocks_temp SET stock = ".$stock_restant.", qte = qte - ".$_SESSION['caddie']->quantite[$i].", o_timestamp = now() WHERE produit_id = '".$article['id']."' AND couleur_id = '".vn($c['id'])."' AND taille_id = '".vn($t['id'])."'"); } if ($s['stock'] <= $seuil) { mail_confirm("$support","[$site] Notification d'alerte STOCK","Seuil d'alerte atteint pour le produit ".utf8_decode(html_entity_decode($article['nom_'.$_SESSION['langue'].'']))."<br /><br /> Couleur : ".$_SESSION['caddie']->couleur[$i]."<br /><br /> Taille : ".$_SESSION['caddie']->taille[$i]."<br /><br /> Stock restant : ".$s['stock']."<br />"); } } $is_pack = 0; if(!empty($_SESSION['caddie']->pack[$i])) { $is_pack = 1; foreach($_SESSION['caddie']->pack[$i] as $v) : //$p = mysql_fetch_array_override(mysql_query_override("SELECT * FROM gaia_produits WHERE id = '".$v['id']."'")); $s = mysql_fetch_array_override(mysql_query_override("SELECT stock, ean FROM gaia_stocks WHERE produit_id = '".$v['id']."'")); $stock = $s['stock'] - $v['qte']; if ($stock >= 0) { $stock_restant = $stock; } else { $stock_restant = 0; } if ($stock < 0) mysql_query_override("UPDATE gaia_commandes SET statut = '9' WHERE id = '".$commandeid."'"); /* Passage de la commande en stand by */ mysql_query_override("UPDATE gaia_stocks SET stock = ".$stock_restant." WHERE produit_id = '".$v['id']."'"); $sqlStockTemp = "SELECT stock, qte FROM gaia_stocks_temp WHERE produit_id = '".$v['id']."'"; $resStockTemp = mysql_query_override($sqlStockTemp); $StockTemp = mysql_fetch_array_override($resStockTemp); if ($StockTemp['qte'] == $v['qte']) { mysql_query_override("DELETE FROM gaia_stocks_temp WHERE produit_id = '".$v['id']."'"); } else { mysql_query_override("UPDATE gaia_stocks_temp SET stock = ".$stock_restant.", qte = qte - ".$v['qte'].", o_timestamp = now() WHERE produit_id = '".$v['id']."'"); } if ($s['stock'] <= $seuil) { mail_confirm("$support","[$site] Notification d'alerte STOCK","Seuil d'alerte atteint pour le produit ".utf8_decode(html_entity_decode($v['nom']))."<br /><br /> Stock restant : ".$s['stock']."<br />"); } endforeach; } $requete = "INSERT INTO gaia_commandes_articles ( commande_id , produit_id , ean , is_pack , nom_produit , prix_cat , prix_cat_ht , prix , prix_ht , total_prix , total_prix_ht , quantite , promotion , remise_produit , tva , tva_percent , couleur , taille , comment , option_prix , delivery_stock , order_stock , points , poids , liste_id , email_check ) VALUES ( '$commandeid' ,'".$article['id']."' ,'".$s['ean']."' ,'".$is_pack."' ,'".addslashes($article['nom_'.$_SESSION['langue'].''])."' ,'".$_SESSION['caddie']->prix_cat[$i]."' ,'".$_SESSION['caddie']->prix_cat_ht[$i]."' ,'".$_SESSION['caddie']->prix[$i]."' ,'".$_SESSION['caddie']->prix_ht[$i]."' ,'".$_SESSION['caddie']->total_prix[$i]."' ,'".$_SESSION['caddie']->total_prix_ht[$i]."' ,'".$_SESSION['caddie']->quantite[$i]."' ,'".$_SESSION['caddie']->remise_produit_percent[$i]."' ,'".$_SESSION['caddie']->remise_produit[$i]."' ,'".$_SESSION['caddie']->tva[$i]."' ,'".$_SESSION['caddie']->tva_percent[$i]."' ,'".addslashes($_SESSION['caddie']->couleur[$i])."' ,'".addslashes($_SESSION['caddie']->taille[$i])."' ,'".addslashes($_SESSION['caddie']->comment[$i])."' ,'".addslashes($_SESSION['caddie']->option[$i])."' ,'".addslashes($_SESSION['caddie']->delivery_stock[$i])."' ,'".intval(vn($stock_to_order))."' ,'".addslashes($_SESSION['caddie']->points[$i])."' ,'".addslashes($_SESSION['caddie']->poids[$i])."' ,'".addslashes($_SESSION['caddie']->liste_id[$i])."' ,'".addslashes($_SESSION['caddie']->email_check[$i])."' )" ; mysql_query_override($requete) or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); $articleid = mysql_insert_id_override(); if(!empty($_SESSION['caddie']->pack[$i])) { $is_pack = 1; foreach ($_SESSION['caddie']->pack[$i] as $v) : mysql_query_override("insert into gaia_commandes_articles_pack (article_id, produit_id, nom, qte) values ('".$articleid."','".$v['id']."','".addslashes($v['nom'])."','".$v['qte']."')"); endforeach; } if (!empty($_SESSION['caddie']->email_check[$i])) { $code = strtoupper(MDP()); $email_client = $_SESSION['utilisateur']['email']; $email_ami = $_SESSION['caddie']->email_check[$i]; /* Mode production : mettre l'état à 0 et passer les fonctions mails dans la liste des chèques cadeaux */ mysql_query_override("INSERT INTO gaia_cheques_cadeaux ( id_utilisateur, email_acheteur, email_ami, nom_produit, code, remise_cheque, o_timestamp, seuil, etat ) VALUES ( '".intval($_SESSION['utilisateur']['id_utilisateur'])."', '$email_client', '$email_ami', '".addslashes($article['nom_'.$_SESSION['langue'].''])."', '".$code."', '".$_SESSION['caddie']->prix[$i]."', now(), '".$_SESSION['caddie']->prix[$i]."', '1')") or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR()); $message = "Bonjour,\n\r"; $message .= "Votre ami ".$_SESSION['utilisateur']['prenom']." ".$_SESSION['utilisateur']['nom_famille']." a souhaité vous offrir un chèque cadeau sur le site $site.\n\r"; $message .= "Pour en bénéficier, connectez vous simplement au site $wwwroot et utilisez votre code $code.\n\rVous bénéficierez alors d'un avoir de ".$_SESSION['caddie']->prix[$i]." EURO TTC sur votre commande.\n\r"; $message .= "A bientôt sur $site."; mail_confirm($email_ami,"[$site] ".$_SESSION['utilisateur']['email']." vous offre un chèque cadeau",nl2br($message)); mail_confirm($email_client ,"[$site - copie du message envoyé à ".$_SESSION['caddie']->email_check[$i]."] ".$_SESSION['utilisateur']['email']." vous offre un chèque cadeau",$message); $message_support = "Bonjour,\n\rLe code chèque cadeau $code vient d'être créé sur $site.\n\r Merci de le valider à réception du règlement."; mail_confirm($support ,"[$site] Création d'un chèque cadeau à valider",nl2br($message_support)); } } } } /* Annule la remise en % du client, supprimer ces lignes si vous souhaitez que les remises client soient permanentes */ // annuler la remise en % uniquement pour les particuliers if($_SESSION['utilisateur']['priv'] != "reve") mysql_query_override("UPDATE gaia_utilisateurs SET remise_percent = '0' WHERE id_utilisateur = '".$_SESSION['utilisateur']['id_utilisateur']."'"); // annuler l'avoir en euro pour tout le monde mysql_query_override("UPDATE gaia_utilisateurs SET avoir = '0' WHERE id_utilisateur = '".$_SESSION['utilisateur']['id_utilisateur']."'"); /********************************************************************************/ /********************************************************************/ /******************* GESTION PROMOTIONS 1 ***************************/ /* if($active_promo1 && $_SESSION['utilisateur']['priv'] != "reve" && $_SESSION['caddie']->total_produit >= $ca_promo) { mysql_query_override("UPDATE gaia_utilisateurs SET remise_percent = '".$remise_ca_promo."' WHERE id_utilisateur = '".$_SESSION['utilisateur']['id_utilisateur']."'"); } */ /********************************************************************/ /********************************************************************/ $_SESSION['utilisateur']['remise_percent'] = 0; $_SESSION['utilisateur']['avoir'] = 0; $_SESSION['utilisateur']['id_parrain'] = 0; $_SESSION['utilisateur']['type'] = ''; #- Suppression du statut filleul return $commandeid; } function newsletter_mark($commandeid, $email) { global $wwwroot, $sendingblue_key, $lg; $rec = mysql_query_override("select l.external_id from gaia_commandes_articles ca, gaia_produits_labels pl, gaia_labels l where ca.produit_id = pl.produit_id and pl.value_id = l.id and l.external_id >0 and ca.commande_id = '".$commandeid."'"); if(mysql_num_rows_override($rec)>0) : while ($label = mysql_fetch_array_override($rec)) : $list = $label['external_id']; $config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', $sendingblue_key); $config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('partner-key', $sendingblue_key); $apiInstance = new SendinBlue\Client\Api\ContactsApi(new GuzzleHttp\Client(),$config); $createContact = new \SendinBlue\Client\Model\CreateContact(); // \SendinBlue\Client\Model\CreateContact | Values to create a contact try { $createContact['email'] = $email; $createContact['listIds'] = array($list); $result = $apiInstance->createContact($createContact); } catch (Exception $e) {} endwhile; endif; } function email_commande(&$commandeid) { global $wwwroot; global $site; global $support; global $support2; global $langfile; $result = mysql_query_override("SELECT * FROM gaia_commandes WHERE id ='".$commandeid."'"); $com = mysql_fetch_object_override($result); $timestamp = $com->o_timestamp; $montant = $com->montant; $goto = "/factures/facture_html.php?mode=proforma&id=$commandeid×tamp=".urlencode($timestamp).""; $urlcommande = $wwwroot.$goto; # Mail d'information envoyé à l'administrateur - ENVOYER EN LANGUE FRANCAISE UNIQUEMENT mail_confirm( $support, "Nouvelle commande sur votre site web $site", "Une commande portant le numéro $commandeid vient d'être enregistrée sur le site $site.", "FROM:$support"); if(!empty($support2)) { mail_confirm( $support2, "Nouvelle commande sur votre site web $site", "Une commande portant le numéro $commandeid vient d'être enregistrée sur le site $site.", "FROM:$support2"); } $email_subject = EMAIL_ORDER_CONFIRMATION; $email_object = EMAIL_ORDER_MESSAGE."\n\r"; $email_object .= "\n\r"; $email_object .= EMAIL_ORDER_DATE." : ".return_date_fr($timestamp)."\n\r"; $email_object .= "\n\r"; $email_object .= EMAIL_ORDER_NUMBER." : ".$commandeid."\n\r"; $email_object .= "\n\r"; $email_object .= EMAIL_ORDER_AMOUNT." : ".fprix($montant)." EUR TTC\n\r"; $email_object .= "\n\r"; if ($com->paiement != CB) { $email_object .= EMAIL_ORDER_PROFORMA." : ".$urlcommande."\n\r"; $email_object .= "\n\r"; } $email_object .= EMAIL_THANKS."\n\r"; mail_confirm($com->email,$email_subject,nl2br($email_object)); } function frmvalide(&$var, $true_value = "checked", $false_value = "") { /* Affiche le mot "checked" si la variable est vraie sinon rien */ if ($var) { echo $true_value; } else { echo $false_value; } } function valide(&$var, $init_valeur = 1, $vide_valeur = 0) { /* Si var est défini, place init_valeur dedans, sinon place vide_valeur.*/ if (empty($var)) { $var = $vide_valeur; } else { $var = $init_valeur; } } function vb(&$var, $default="") { // Variable blanche /* if $var n'est pas défini, retourne $default, sinon retourne $var */ return isset($var) ? $var : $default; } function vn(&$var, $default=0) { // Variable nulle /* if $var n'est pas défini, retourne $default, sinon retourne $var */ return isset($var) ? $var : $default; } function pv(&$var) { // print var /* retourne $var avec les caractères HTML correctement traité (comme "<", ">", etc.), * ou si $var n'est pa défini, retourne une chaîne vide. * Cette fonction doit être appelée avec une variable, utilisez la fonction p() */ p(vb($var)); } function t($var) { // Traitement des variables textes /* returns $var with HTML characters (like "<", ">", etc.) properly quoted, * or if $var is empty, will return an empty string. */ return empty($var) ? "" : addslashes(stripslashes($var)); } function p($var) { //print /* prints $var with HTML characters (like "<", ">", etc.) properly quoted, * or if $var is empty, will print an empty string. */ echo t($var); } function jstring($var) { /* returns string that is quoted for javascript */ return addslashes($var); } /* Fonction de contrôle pour l'upload de fichiers */ function validate_upload($the_file) { global $my_max_file_size; global $image_max_width; global $image_max_height; global $allowed_types; global $registered_types; $error = ""; $the_file_type = $the_file['type']; $start_error = "\n<font color=\"red\"><b>Attention :</b></font>\n<ul>"; if (in_array($the_file_type,$allowed_types)) {} if ($the_file == "none") { $error .= "\n<li>Vous n'avez rien uploadé.</li>"; } else { # Vérification du type de fichier uploadé if (!in_array($the_file_type,$allowed_types)) { $error .= "\n<li>Le type de fichier que vous essayez d'uploader n'est pas autorisé, vous ne pouvez télécharger des fichiers que du type : \n<ul>"; while ($type = current($allowed_types)) { $error .= "\n<li>" . $registered_types[$type] . " (" . $type . ")</li>"; next($allowed_types); } $error .= "\n</ul>"; } if (in_array($the_file_type,$allowed_types)) { list($width, $height, $type, $attr) = getimagesize($the_file['tmp_name']); if ($width > $image_max_width) { $error .= "\n<li>Votre image ne devrait être plus large que " . $image_max_width . " Pixels</li>"; } if ($height > $image_max_height) { $error .= "\n<li>Votre image ne devrait être plus haute que " . $image_max_height . " Pixels</li>"; } } if ($error) { $error = $start_error . $error . "\n</ul>"; return $error; } else { return false; } } } // Fin de la fonction validate upload /*Fonction d'upload de fichiers */ function move_upload_pict($f_file, $sort='') { global $the_path; $file_name = rand(0,1000).validName($f_file['name']); move_uploaded_file($f_file['tmp_name'], $the_path.$sort.$file_name); return $file_name; } function upload_pict($f_file, $width=1300, $height=1300, $sort='zoom_') { global $the_path; //ZOOM : taille d'entrée (limité 900*900) //NORMAL : taille fournie resizée //MIN : taille fournie / 4 - 5px //################## IMAGE 1 ################## $aimg=new img($f_file['tmp_name']); $file_name = validName($f_file['name']); $chk = $aimg->check($width,$height); if($chk == -1) { $aimg->resampled($width,$height,1,'width'); } else if ($chk == -2) { $aimg->resampled($width,$height,1,'height'); } $chk = $aimg->check($width,$height); if($chk == -2) { $aimg->resampled($width,$height,1,'height'); } if(file_exists($the_path.$file_name)) { $file_name=rand(1,100).$file_name; } $aimg->save($the_path.$sort.$file_name); //############################################# if(file_exists($the_path.$file_name)) { chmod($the_path.$sort.$file_name, 0777); } move_uploaded_file($f_file['tmp_name'], $the_path.'zoom_'.$file_name); $background = imagecreatetruecolor($width,$height); $whiteBackground = imagecolorallocate($background, 255, 255, 255); imagefill($background,0,0,$whiteBackground); $source = imagecreatefromjpeg($the_path.$sort.$file_name); list($imageWidth,$imageHeight) = getimagesize($the_path.$sort.$file_name); $decalx = ($width - $imageWidth)/2; $decaly = ($height - $imageHeight)/2; imagecopymerge($background,$source, $decalx, $decaly, 0, 0,$imageWidth,$imageHeight,85); imagejpeg ($background,$the_path.$sort.$file_name, 85); //genere_min ($file_name,300, 300); return $file_name; } function createImg($f_file, $width=1300, $height=1300, $sort='zoom_') { global $the_path,$dirroot; $file_name = rand(0,1000000000).'_'.mb_strtolower(validName($f_file['name'])); //$img_file = $f_file['name']; $ext = pathinfo($file_name, PATHINFO_EXTENSION); $dest_small = $dirroot.'/upload/'.$sort.$file_name; if(empty($sort)) $dest_small_webp = $dirroot.'/upload/'.$sort.str_replace($ext,'webp',$file_name); $imgfile = $f_file['tmp_name']; if($ext=='png') $img = imagecreatefrompng($imgfile); else $img = imagecreatefromjpeg($imgfile); $originwidth = imagesx( $img ); $originheight = imagesy( $img ); // calculate thumbnail size $dst_x = $dst_y = 0; if ($originwidth > $originheight) { if($width<$originwidth) $new_width = $width; else $new_width = $originwidth; $new_height = floor($originheight * ($new_width / $originwidth)); } else { if($height<$originheight) $new_height = $height; else $new_height = $originheight; $new_width = floor($originwidth * ($new_height / $originheight)); } if(empty($sort)) { if ($new_width != $width) $dst_x = ($width - $new_width) / 2; if ($new_height != $height) $dst_y = ($height - $new_height) / 2; } // create a new temporary image $tmp_img = imagecreatetruecolor( $new_width, $new_height ); //FOND BLANC / FOND TRANSPARENT if($ext!='png') { $color = imagecolorallocate($tmp_img, 255, 255, 255); } else { imagesavealpha($tmp_img, true); $color = imagecolorallocatealpha($tmp_img, 0, 0, 0, 127); } imagefill($tmp_img, 0, 0, $color); //---------- // copy and resize old image into new image imagecopyresampled( $tmp_img, $img, $dst_x, $dst_y, 0, 0, $new_width, $new_height, $originwidth, $originheight ); // save thumbnail into a file if($ext=='png') imagepng( $tmp_img, $dest_small, 9 ); else imagejpeg( $tmp_img, $dest_small, 100 ); if(empty($sort)) imagewebp($tmp_img, $dest_small_webp, 100); if(file_exists($the_path.$sort.$file_name)) { chmod($the_path.$sort.$file_name, 0777); } return $file_name; } function upload_pict_($f_file, $width=1300, $height=1300, $sort='zoom_') { global $the_path; //ZOOM : taille d'entrée (limité 900*900) //NORMAL : taille fournie resizée //MIN : taille fournie / 4 - 5px $exif = exif_read_data($f_file['tmp_name']); //print_r($exif); $orientation = $exif['Orientation']; //################## IMAGE 1 ################## $aimg=new img($f_file['tmp_name']); $file_name = validName($f_file['name']); switch($orientation) { case 3: $aimg->rotate(180, 0); break; case 6: $aimg->rotate(-90, 0); break; case 8: $aimg->rotate(90, 0); break; } $chk = $aimg->check($width,$height); if($chk == -1) { $aimg->resampled($width,$height,1,'width'); } else if ($chk == -2) { $aimg->resampled($width,$height,1,'height'); } $chk = $aimg->check($width,$height); if($chk == -2) { $aimg->resampled($width,$height,1,'height'); } if(file_exists($the_path.$file_name)) { $file_name=rand(1,100).$file_name; } $aimg->save($the_path.$sort.$file_name); //############################################# if(file_exists($the_path.$file_name)) { chmod($the_path.$sort.$file_name, 0777); } return $file_name; } function genere_min($f_file, $width=100, $height=100, $sort='min_') { global $the_path; //ZOOM : taille d'entrée (limité 900*900) //NORMAL : taille fournie resizée //MIN : taille fournie / 4 - 5px //################## IMAGE 1 ################## $aimg=new img($the_path.$f_file); $file_name = validName($f_file); $chk = $aimg->check($width,$height); if($chk == -1) { $aimg->resampled($width,$height,1,'width'); } else if ($chk == -2) { $aimg->resampled($width,$height,1,'height'); } $chk = $aimg->check($width,$height); if($chk == -2) { $aimg->resampled($width,$height,1,'height'); } if(file_exists($the_path.$sort.$file_name)) { $file_name=rand(1,100).$file_name; } $aimg->save($the_path.$sort.$file_name); //############################################# if(file_exists($the_path.$sort.$file_name)) { chmod($the_path.$sort.$file_name, 0777); } return $file_name; } function upload($f_file) { global $the_path; //################## IMAGE 1 ################## $aimg=new img($f_file['tmp_name']); $file_name = validName($f_file['name']); $chk = $aimg->check('400','400'); if($chk == -1) { $aimg->resampled('400','400',1,'width'); } else if ($chk == -2) { $aimg->resampled('400','400',1,'height'); } $chk = $aimg->check('400','400'); if($chk == -2) { $aimg->resampled('400','400',1,'height'); } if(file_exists($the_path.$file_name)) { $file_name=rand(1,100).$file_name; } $aimg->save($the_path."big_".$file_name); //############################################# //################## IMAGE 1 ################## $chk = $aimg->check('220','220'); if($chk == -1) { $aimg->resampled('220','220',1,'width'); } else if ($chk == -2) { $aimg->resampled('220','220',1,'height'); } $chk = $aimg->check('220','220'); if($chk == -2) { $aimg->resampled('220','220',1,'height'); } $aimg->save($the_path.$file_name); //############################################# //################## IMAGE 1 ################## $chk = $aimg->check('120','120'); if($chk == -1) { $aimg->resampled('120','120',1,'width'); } else if ($chk == -2) { $aimg->resampled('120','120',1,'height'); } $chk = $aimg->check('120','120'); if($chk == -2) { $aimg->resampled('120','120',1,'height'); } $aimg->save($the_path."min_".$file_name); //############################################# if(file_exists($the_path.$file_name)) { chmod($the_path.$file_name, 0777); chmod($the_path.'min_'.$file_name, 0777); chmod($the_path.'big_'.$file_name, 0777); } return $file_name; } function upload_lifetsyle($f_file_tmp, $f_file_name) { global $the_path; //################## IMAGE 1 ################## $aimg=new img($f_file_tmp); $file_name = validName($f_file_name); /* $chk = $aimg->check('800','600'); if($chk == -1) { $aimg->resampled('800','600',1,'width'); } else if ($chk == -2) { $aimg->resampled('800','600',1,'height'); } $chk = $aimg->check('800','600'); if($chk == -2) { $aimg->resampled('800','600',1,'height'); } if(file_exists($the_path.$file_name)) { $file_name=rand(1,100).$file_name; } $aimg->save($the_path."big_".$file_name); */ //############################################# //################## IMAGE 1 ################## $chk = $aimg->check('900','900'); if($chk == -1) { $aimg->resampled('900','900',1,'width'); } else if ($chk == -2) { $aimg->resampled('900','900',1,'height'); } $chk = $aimg->check('900','900'); if($chk == -2) { $aimg->resampled('900','900',1,'height'); } if(file_exists($the_path.$file_name)) { $file_name=rand(1,100).$file_name; } $aimg->save($the_path.$file_name); //############################################# //############################################# if(file_exists($the_path.$file_name)) { chmod($the_path.$file_name, 0777); //chmod($the_path.'big_'.$file_name, 0777); } return $file_name; } function MDP() // Fonction utiliser pour le renommage des fichiers images { $chrs = 6 ; // Fixe le nombre de caractères $pwd = "" ; mt_srand ((double) microtime() * 1000000); while (strlen($pwd)<$chrs) { $chr = chr(mt_rand (0,255)); if (preg_match("/^[a-hj-km-np-z2-9]$/i", $chr)) $pwd = $pwd.$chr; }; return $pwd; } function send_email ($to, $subject , $msg , $format , $id) { global $support; global $wwwroot; $subject=stripslashes($subject); $msg=stripslashes($msg); if(mail_confirm2($to ,$subject,$msg, $id)) { return 1; } else { return 0;} } function mail_confirm2 ($destinataire,$subject,$message, $news) { global $wwwroot, $support, $site; $headers = "Return-Path: ".$support." \n"; $headers .= "From: ".$site." <".$support."> \n"; $headers .= "X-Mailer: PHP ".phpversion()."\n"; $headers .= "Reply-To: ".$support." \n"; $headers .= "Organization: ".$wwwroot." \n"; $headers .= "X-Priority: 3 (Normal) \n"; $headers .= "Mime-Version: 1.0 \n"; $headers .="Content-Type: text/html; charset=\"utf-8\" \n"; $headers .= "Content-Transfer-Encoding: 8bit \n"; $msg = ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body marginheight="0" style=" background-color:#eee;" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <center> <span style="padding:10px; color:#000; font-family:Tahoma, Geneva, sans-serif; font-size:11px">Si vous ne voyez pas la newsletter, <a href="'.$wwwroot.'/visu_news.php?id='.$news.'" style="color:#000">Cliquez ici</a></span><br><br> <table bgcolor="#ffffff" width="800" border="0" cellpadding="0" cellspacing="0"> <tr> <td align="center"> <img src="'.$wwwroot.'/images/topnews.jpg" width="800" /></td> </tr> <tr> <td width="634" valign="top" bgcolor="#FFFFFF" style="padding:10px; font-family:Tahoma, Geneva, sans-serif; font-size:11px">'.$message.'</td> </tr> <tr> <td width="634" valign="top" bgcolor="#E1007A" style="padding:10px;"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="right" style=" color:#fff; font-family:Tahoma, Geneva, sans-serif; font-size:11px"> Retrouvez nous sur <b><a href="http://www.plum-deco.com/" style=" color:#fff;">www.plum-deco.com</a></b> </td> </tr> </table> </td> </tr> </table> <br><a href="'.$wwwroot.'" style="font-family:verdana; font-size:11px; color:#acacac; text-decoration:none">Copyright © '.$site.'</a> <br /><br /> <a href="'.$wwwroot.'/desinscription.php?mail='.$destinataire.'" style="color:#000; font-family:Tahoma, Geneva, sans-serif; font-size:11px">Pour ne plus recevoir nos offres, cliquez sur ce lien</a> </center> </body> </html> '; $result = mail ($destinataire,html_entity_decode($subject) ,utf8_encode($msg),$headers); return $result; } function mail_transform($type, $texte='', $id=0, $return = 1) { global $lg, $wwwroot, $color1, $color2; //$type 1 : enregistrement client / type 2 : validation de commande / type 3 : commande expédiée $suivre['fr'] = 'Suivre mon colis'; $suivre['en'] = 'Follow my package'; $facture['fr'] = 'Voir ma facture'; $facture['en'] = 'See my invoice'; $proforma['fr'] = 'Voir ma proforma'; $proforma['en'] = 'See my proforma'; $devis['fr'] = 'Voir mon devis'; $devis['en'] = 'See my estimate'; $style = 'style="color:'.$color1.'; text-decoration:none; font-weight:bold;"'; $items = array(); //user $items[] = array('titre'=>'Prénom','value'=>'prenom'); $items[] = array('titre'=>'Nom','value'=>'nom'); $items[] = array('titre'=>'User ID','value'=>'identifiant'); if($type ==5 ) { $items[] = array('titre'=>'Numéro du devis','value'=>'numdevis'); $items[] = array('titre'=>'Date du devis','value'=>'datedevis'); $items[] = array('titre'=>'Lien de devis','value'=>'liendevis'); } elseif($type >1 ) { //commande $items[] = array('titre'=>'Date commande','value'=>'datecommande'); $items[] = array('titre'=>'Réf. commande','value'=>'refcommande'); $items[] = array('titre'=>'Type de livraison','value'=>'typetransport'); $items[] = array('titre'=>'Récap. commande','value'=>'recapcommande'); $items[] = array('titre'=>'Lien de la facture','value'=>'lienfacture'); $items[] = array('titre'=>'Lien de suivi','value'=>'liensuivicolis'); $items[] = array('titre'=>'Numéro de suivi','value'=>'numcolis'); $items[] = array('titre'=>'Lien de proforma','value'=>'lienproforma'); } if($return==1) return $items; elseif(!empty($texte)) { //id user if($type==1) { $getuser = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur='".$id."'"); $user = mysql_fetch_array_override($getuser); //id devis } elseif ($type==5) { $getcommande = mysql_query_override("select * from gaia_devis where id='".$id."'"); $com = mysql_fetch_array_override($getcommande); $getuser = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur='".$com['id_utilisateur']."'"); $user = mysql_fetch_array_override($getuser); $texte = str_replace ('{datedevis}',date('d/m/Y',strtotime($com['o_timestamp'])), $texte); $texte = str_replace ('{numdevis}',$com['id'], $texte); $texte = str_replace ('{liendevis}','<a href="'.$wwwroot.'/factures/devis_html.php?id='.$com['id'].'×tamp='.urlencode($com['o_timestamp']).'&mode=devis" '.$style.'>'.$devis[$lg].'</a>', $texte); //id commande } else { $getcommande = mysql_query_override("select * from gaia_commandes where id='".$id."'"); $com = mysql_fetch_array_override($getcommande); $getuser = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur='".$com['id_utilisateur']."'"); $user = mysql_fetch_array_override($getuser); $texte = str_replace ('{datecommande}',$com['a_timestamp'], $texte); $texte = str_replace ('{refcommande}',$com['id'], $texte); $texte = str_replace ('{typetransport}',($com['type']), $texte); $texte = str_replace ('{numcolis}',($com['colis']), $texte); $texte = str_replace ('{lienfacture}','<a href="'.$wwwroot.'/factures/facture_html.php?id='.$com['id'].'×tamp='.urlencode($com['o_timestamp']).'&mode=facture" '.$style.'>'.$facture[$lg].'</a>', $texte); $texte = str_replace ('{lienproforma}','<a href="'.$wwwroot.'/factures/facture_html.php?id='.$com['id'].'×tamp='.urlencode($com['o_timestamp']).'&mode=proforma" '.$style.'>'.$proforma[$lg].'</a>', $texte); $recapcommande = get_commande_info($com['id']); $texte = str_replace ('{recapcommande}',$recapcommande, $texte); $gettype = mysql_query_override("select * from gaia_types where nom_".$com['lang']." = '".$com['type']."'"); $type = mysql_fetch_array_override($gettype); $texte = str_replace ('{liensuivicolis}','<a href="'.$type['link_'.$com['lang']].'/'.$com['colis'].'" '.$style.'>'.$suivre[$lg].'</a>', $texte); } $texte = str_replace ('{prenom}',($user['prenom']), $texte); $texte = str_replace ('{nom}',($user['nom_famille']), $texte); $texte = str_replace ('{identifiant}',$user['code_client'], $texte); $texte = str_replace ('<a ','<a '.$style.' ', $texte); return ($texte); } } function get_commande_info($commandeid) { global $wwwroot; $qid = mysql_query_override("SELECT * FROM gaia_commandes WHERE id ='".$commandeid."'"); $c = mysql_fetch_object_override($qid); $message .='<table cellspacing="0" cellpadding="0" style="width:100%; font-family:Tahoma, Geneva, sans-serif;">'; $recprod = mysql_query_override("SELECT ca.*, p.image1 FROM gaia_commandes_articles ca, gaia_produits p WHERE ca.produit_id = p.id and ca.commande_id ='".$commandeid."'"); while ($prods = mysql_fetch_array_override($recprod)) { $imga1 = first_img($prods['image1'], $prods['produit_id'],0); $message .= ' <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; "><img src="'.$wwwroot.'/upload/'.($imga1).'" width="200" /><br /><strong>'.($prods['nom_produit']).' x '.$prods['quantite'].'</strong></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.$prods['total_prix'].' €</td> </tr>'; } $message .= '</table><br />'; $message .='<table cellspacing="0" cellpadding="0" style="width:100%; font-family:Tahoma, Geneva, sans-serif;">'; $message .= ' <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif;" colspan=2 align="left"><b>'.TOTAL_TTC.'</b></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.number_format($c->montant - $c->cout_transport,2,',','').' €</td> </tr> <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif;" colspan=2 align="left"><b>'.SHIPPING_COST.'</b></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.fprix($c->cout_transport).' €</td> </tr> <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif;" colspan=2 align="left"><b>'.CODE_PROMO_REMISE.'</b></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.fprix($c->remise_code).' €</td> </tr> <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; " colspan=2 align="left"><b>'.WVAT.'</b></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.fprix($c->total_tva).' €</td> </tr> <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; border-bottom:1px solid #333" colspan=2 align="left"><b>'.TOTAL_TTC.'</b></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; border-bottom:1px solid #333">'.number_format($c->montant,2,',','').' €</td> </tr>'; $message .= '</table><br /><br />'; $message .=MAILCONFIRM11.'<br /><br />'; $message .=MAILCONFIRM15.'<br /><br />'; if(empty($c->point_relais)) $livraison = (nl2br($c->client_info2)); else { $livraison = explode('|',$c->point_relais); $livraison = $livraison[0]; } $message .='<table cellspacing="0" cellpadding="0" style="width:100%; font-family:Tahoma, Geneva, sans-serif;"> <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif;" width="50%" ><b>'.SHIP_ADDRESS.'</b></td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif;" width="50%" ><b>'.BILL_ADDRESS.'</b></td> </tr> <tr> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.$livraison.'</td> <td style="padding:5px; font-family:Tahoma, Geneva, sans-serif; ">'.(nl2br($c->client_info1)).'</td> </tr> </table>'; return $message; } function get_commande_info_($commandeid) { global $wwwroot; $qid = mysql_query_override("SELECT * FROM gaia_commandes WHERE id ='".$commandeid."'"); $c = mysql_fetch_object_override($qid); $message .='<table cellspacing="0" cellpadding="0" style="width:100%; font-family:Tahoma, Geneva, sans-serif; font-size:12px"> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333"> </td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px"><b>'.DESCRIPTION_WEBSITE.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px"><b>'.UNIT_PRICE.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px"><b>'.QUANTITY.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333"><b>'.TOTAL_TTC.'</td> </tr>'; $recprod = mysql_query_override("SELECT ca.*, p.image1 FROM gaia_commandes_articles ca, gaia_produits p WHERE ca.produit_id = p.id and ca.commande_id ='".$commandeid."'"); while ($prods = mysql_fetch_array_override($recprod)) { $imga1 = first_img($prods['image1'], $prods['produit_id'],0); $message .= ' <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px"><img src="'.$wwwroot.'/upload/'.utf8_decode($imga1).'" width="200" /></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px">'.utf8_decode($prods['nom_produit']).'</td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px">'.$prods['prix'].' €</td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px">'.$prods['quantite'].'</td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333">'.$prods['total_prix'].' €</td> </tr>'; } $message .= ' <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px" colspan=4 align="right"><b>'.TOTAL_TTC.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333">'.number_format($c->montant - $c->cout_transport,2,',','').' €</td> </tr> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px" colspan=4 align="right"><b>'.SHIPPING_COST.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333">'.fprix($c->cout_transport).' €</td> </tr> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px" colspan=4 align="right"><b>'.CODE_PROMO_REMISE.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333">'.fprix($c->remise_code).' €</td> </tr> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px" colspan=4 align="right"><b>'.WVAT.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333">'.fprix($c->total_tva).' €</td> </tr> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-bottom:1px solid #333" colspan=4 align="right"><b>'.TOTAL_TTC.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333; border-bottom:1px solid #333">'.number_format($c->montant,2,',','').' €</td> </tr>'; $message .= '</table><br /><br />'; $message .=MAILCONFIRM11.'<br /><br />'; $message .=MAILCONFIRM15.'<br /><br />'; if(empty($c->point_relais)) $livraison = utf8_decode(nl2br($c->client_info2)); else { $livraison = explode('|',$c->point_relais); $livraison = $livraison[0]; } $message .='<table cellspacing="0" cellpadding="0" style="width:100%; font-family:Tahoma, Geneva, sans-serif; font-size:12px"> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px" width="50%" ><b>'.SHIP_ADDRESS.'</b></td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333" width="50%" ><b>'.BILL_ADDRESS.'</b></td> </tr> <tr> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-bottom:1px solid #333">'.$livraison.'</td> <td style="padding:5px;border-top:1px solid #333; border-left:1px solid #333; font-family:Tahoma, Geneva, sans-serif; font-size:12px; border-right:1px solid #333; border-bottom:1px solid #333">'.utf8_decode(nl2br($c->client_info1)).'</td> </tr> </table>'; return $message; } function mail_confirm ($destinataire,$subject,$message, $tr='') { global $wwwroot, $support, $sendingblue_key, $site, $logo, $color1, $color2; $isok = false; $headers = "Return-Path: ".$support." \n"; $headers .= "From: ".$site." <".$support."> \n"; $headers .= "X-Mailer: PHP ".phpversion()."\n"; $headers .= "Reply-To: ".$support." \n"; $headers .= "Organization: ".$wwwroot." \n"; $headers .= "X-Priority: 3 (Normal) \n"; $headers .= "Mime-Version: 1.0 \n"; $headers .="Content-Type: text/html; charset=\"utf-8\" \n"; $headers .= "Content-Transfer-Encoding: 8bit \n"; $headers = "MIME-Version: 1.0 \n"; $headers .="Content-Type: text/html; charset=utf-8 \n"; $headers .= "From: $support \n"; $headers .= "Disposition-Notification-To: $support \n"; $headers .= "X-Priority: 1 \n"; $headers .= "X-MSMail-Priority: High \n"; $recs = mysql_query_override("select * from gaia_societe where id = 1"); $societe = mysql_fetch_array_override($recs); $msg = ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body marginheight="0" style=" background-color:#fff;" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <center> <table bgcolor="#ffffff" width="95%" border="0" cellpadding="10" cellspacing="0"> <tr> <td align="center"> <img src="'.$wwwroot.'/images/spec/logo/logo_gris.png" width="250" /></td> </tr> <tr> <td valign="top" bgcolor="#FFFFFF" style="padding:10px; font-family:Tahoma, Geneva, sans-serif;">'.($message).'</td> </tr> <tr> <td valign="top" bgcolor="'.$color1.'" style="padding:10px;"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="right" style=" color:#fff; font-family:Tahoma, Geneva, sans-serif;"> '.RETROUVEZNOUSSUR.' <b><a href="'.$wwwroot.'" style=" color:#fff;">'.($site).'</a></b> </td> </tr> </table> </td> </tr> </table> <br /> '.(!empty($societe['instagram'])?'<a href="'.$societe['instagram'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-insta.png" width="20" /></a>':'').' '.(!empty($societe['facebook'])?'<a href="'.$societe['facebook'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-facebook.png" width="20" /></a>':'').' '.(!empty($societe['youtube'])?'<a href="'.$societe['youtube'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-youtube.png" width="20" /></a>':'').' '.(!empty($societe['pinterest'])?'<a href="'.$societe['pinterest'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-pinterest.png" width="20" /></a>':'').' <br /><a href="'.$wwwroot.'" style="font-family:verdana;color:#acacac; text-decoration:none">Copyright © '.($site).'</a> </center> </body> </html> '; $result = mail ($destinataire,html_entity_decode($subject) ,($msg),$headers); return $result; /* $config = SendinBlue\Client\Configuration::getDefaultConfiguration()->setApiKey('api-key', $sendingblue_key); $apiInstance = new SendinBlue\Client\Api\TransactionalEmailsApi(new GuzzleHttp\Client(),$config); $sendSmtpEmail = new \SendinBlue\Client\Model\SendSmtpEmail(); // \SendinBlue\Client\Model\SendSmtpEmail | Values to send a transactional email $sendSmtpEmail['sender'] = (array('name' => 'Café Dosette', 'email' => $support)); $sendSmtpEmail['to'] = array(array('email' => $destinataire)); $sendSmtpEmail['subject'] = html_entity_decode($subject); $sendSmtpEmail['htmlContent'] = $msg; try { $result = $apiInstance->sendTransacEmail($sendSmtpEmail); //print_r($result); $isok = true; } catch (Exception $e) { echo 'Exception when calling TransactionalEmailsApi->sendTransacEmail: ', $e->getMessage(), PHP_EOL; } return $isok; */ } function mail_confirm_BKP ($destinataire,$subject,$message, $tr='') { global $wwwroot, $support, $site, $logo, $color1, $color2; $recs = mysql_query_override("select * from gaia_societe where id = 1"); $societe = mysql_fetch_array_override($recs); $headers = "Return-Path: ".$support." \n"; $headers .= "From: ".$site." <".$support."> \n"; $headers .= "X-Mailer: PHP ".phpversion()."\n"; $headers .= "Reply-To: ".$support." \n"; $headers .= "Organization: ".$wwwroot." \n"; $headers .= "X-Priority: 3 (Normal) \n"; $headers .= "Mime-Version: 1.0 \n"; $headers .="Content-Type: text/html; charset=\"utf-8\" \n"; $headers .= "Content-Transfer-Encoding: 8bit \n"; $msg = ' <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body marginheight="0" style=" background-color:#fff;" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0"> <center> <table bgcolor="#ffffff" width="95%" border="0" cellpadding="10" cellspacing="0"> <tr> <td align="center"> <img src="'.$wwwroot.'/upload/'.$logo.'" width="200" /></td> </tr> <tr> <td valign="top" bgcolor="#FFFFFF" style="padding:10px; font-family:Tahoma, Geneva, sans-serif;">'.($message).'</td> </tr> <tr> <td valign="top" bgcolor="'.$color1.'" style="padding:10px;"> <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td align="right" style=" color:#fff; font-family:Tahoma, Geneva, sans-serif;"> '.RETROUVEZNOUSSUR.' <b><a href="'.$wwwroot.'" style=" color:#fff;">'.($site).'</a></b> </td> </tr> </table> </td> </tr> </table> <br /> '.(!empty($societe['instagram'])?'<a href="'.$societe['instagram'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-insta.png" width="20" /></a>':'').' '.(!empty($societe['facebook'])?'<a href="'.$societe['facebook'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-facebook.png" width="20" /></a>':'').' '.(!empty($societe['youtube'])?'<a href="'.$societe['youtube'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-youtube.png" width="20" /></a>':'').' '.(!empty($societe['pinterest'])?'<a href="'.$societe['pinterest'].'" style="text-decoration:none"><img src="'.$wwwroot.'/images/picto-pinterest.png" width="20" /></a>':'').' <br /><a href="'.$wwwroot.'" style="font-family:verdana;color:#acacac; text-decoration:none">Copyright © '.utf8_decode($site).'</a> </center> </body> </html> '; $result = mail ($destinataire,html_entity_decode($subject) ,($msg),$headers); return $result; } function send_email2($to, $subject , $msg , $format ,$bcc="") { global $support; global $wwwroot; /* Création des pieds des messages */ $piedtxt ="\n\n------------------------------------------------------------------------------\n"; $piedtxt .= "Pour vous désinscrire, allez dans Mon compte > Modifier mes paramètres.\n"; $piedhtm = "<br /><br /><br />"; $piedhtm .= "Pour vous désinscrire, allez dans <a href=\"".$wwwroot."/compte.php\">Mon compte > Modifier mes paramètres</a>"; $subject=stripslashes($subject); $msg=stripslashes($msg); //création du header du mail $mail_header = "From: $support\r\n"; $mail_header .= "Reply-To: $support\r\n"; $mail_header .= "Return-Path:".$support."\r\n"; $mail_header .= "Content-Transfer-Encoding: 8bit\r\n"; $mail_header .= "MIME-Version: 1.0\r\n"; $mail_header .= "X-Mailer: PHP/" . phpversion()."\r\n"; if ($format=="text") { $mail_header .= "Content-Type: text/plain; charset=iso-8859-1\r\n"; $msg .= $piedtxt; } else { $mail_header.="Content-Type: text/html; charset=iso-8859-1\r\n"; $msg .= $piedhtm; } if(mail_confirm($to ,$subject,$msg,$mail_header)) { return 1; } else { return 0;} } function cree_devis() { // Enregistre la commande dans la base global $site; global $support; global $wwwroot; $sql = " INSERT INTO gaia_devis ( email , id_utilisateur , o_timestamp , a_timestamp , statut , statut_details , montant , montant_ht , total_tva , tva_transport , total_produit_avant_promo , total_produit_avant_promo_ht , total_produit , type , zone , zone_tva , pays , transport , cout_transport , cout_transport_ht , lang , points , points_etat , poids , prenom_bill , nom_bill , adresse_bill , zip_bill , ville_bill , pays_bill , email_bill , telephone_bill , prenom_ship , nom_ship , adresse_ship , zip_ship , ville_ship , pays_ship , email_ship , telephone_ship ) VALUES ( '{$_SESSION['utilisateur']['email']}' ,'".intval($_SESSION['utilisateur']['id_utilisateur'])."' ,now() ,now() ,0 ,'commande initialisée' ,'".$_SESSION['caddie']->total."' ,'".$_SESSION['caddie']->total_ht."' ,'".$_SESSION['caddie']->total_tva."' ,'".$_SESSION['caddie']->tva_transport."' ,'".$_SESSION['caddie']->total_produit_avant_promo."' ,'".$_SESSION['caddie']->total_produit_avant_promo_ht."' ,'".$_SESSION['caddie']->total_produit."' ,'".addslashes($_SESSION['caddie']->type)."' ,'".addslashes($_SESSION['caddie']->zone)."' ,'".intval($_SESSION['caddie']->zoneTva)."' ,'".addslashes($_SESSION['caddie']->pays)."' ,'".addslashes($_SESSION['caddie']->zone)." - ".addslashes($_SESSION['caddie']->type)."' ,'".$_SESSION['caddie']->cout_transport."' ,'".$_SESSION['caddie']->cout_transport_ht."' ,'".$_SESSION['langue']."' ,'".$_SESSION['caddie']->total_points."' ,'0' ,'".$_SESSION['caddie']->total_poids."' , '".addslashes($_SESSION['utilisateur']['prenom'])."' , '".addslashes($_SESSION['utilisateur']['nom_famille'])."' , '".addslashes($_SESSION['utilisateur']['adresse'])."' , '".addslashes($_SESSION['utilisateur']['code_postal'])."' , '".addslashes($_SESSION['utilisateur']['ville'])."' , '".addslashes($_SESSION['utilisateur']['pays'])."' , '".addslashes($_SESSION['utilisateur']['email'])."' , '".addslashes($_SESSION['utilisateur']['telephone'])."' , '".addslashes($_SESSION['utilisateur']['prenom'])."' , '".addslashes($_SESSION['utilisateur']['nom_famille'])."' , '".addslashes($_SESSION['utilisateur']['adresse'])."' , '".addslashes($_SESSION['utilisateur']['code_postal'])."' , '".addslashes($_SESSION['utilisateur']['ville'])."' , '".addslashes($_SESSION['utilisateur']['pays'])."' , '".addslashes($_SESSION['utilisateur']['email'])."' , '".addslashes($_SESSION['utilisateur']['telephone'])."' )"; /* $sql = " INSERT INTO gaia_devis ( email ,id_utilisateur , o_timestamp , montant , commentaires ) VALUES ( '{$_SESSION['utilisateur']['email']}' ,'{$_SESSION['utilisateur']['id_utilisateur']}' ,now() ,'".$_SESSION['caddie']->total."' , '".addslashes($_SESSION['caddie']->commentaires)."' )"; */ $qid = mysql_query_override($sql); $devisid = mysql_insert_id_override(); $prods = array(); /* ajout des articles à la table commandes_articles */ foreach ($_SESSION['caddie']->articles as $i => $produitid) { $qid = mysql_query_override("SELECT * FROM gaia_produits WHERE id= '$produitid'"); if ($qid) { if (mysql_num_rows_override($qid) > 0) { $article=mysql_fetch_array_override($qid); $prix_cat = $article['prix']; $prix_cat_ht = $article['prix'] / (1+$article['tva']/100); $prix_ht = $total_ht = $total_ttc = ''; if($_SESSION['caddie']->prix_ht[$i]>0) { $prix_ht = number_format($_SESSION['caddie']->prix_ht[$i],2,'.',' ').' €'; $total_ht = number_format(($_SESSION['caddie']->prix_ht[$i]*$_SESSION['caddie']->quantite[$i]),2,'.',' ').' €'; $total_ttc = number_format(($_SESSION['caddie']->prix[$i]*$_SESSION['caddie']->quantite[$i]),2,'.',' ').' €'; } $prods[] = '<tr><td style="font-size:13px">'.$article['nom_'.$_SESSION['langue'].'']. (!empty($_SESSION['caddie']->reference[$i])?'<br />Ref. : '.$_SESSION['caddie']->reference[$i]:''). (!empty($_SESSION['caddie']->taille[$i])?'<br />Dimensions : '.$_SESSION['caddie']->taille[$i]:'').'</td> <td style="font-size:13px">'.$prix_ht.'</td> <td style="font-size:13px">'.$_SESSION['caddie']->quantite[$i].'</td> <td style="font-size:13px">'.$total_ht.'</td> <td style="font-size:13px">'.$total_ttc.'</td></tr>'; $requete = "INSERT INTO gaia_devis_articles ( devis_id, produit_id, reference, nom_produit, prix, prix_ht, prix_cat, prix_cat_ht, quantite, promotion, tva, couleur, taille, comment ) VALUES ( '$devisid' ,'".$article['id']."' ,'".$_SESSION['caddie']->reference[$i]."' ,'".addslashes($article['nom_'.$_SESSION['langue'].''])."' ,'". $_SESSION['caddie']->prix[$i]."' ,'". $_SESSION['caddie']->prix_ht[$i]."' ,'".$prix_cat."' ,'".$prix_cat_ht."' ,'".$_SESSION['caddie']->quantite[$i]."' ,'".$_SESSION['caddie']->remise_produit_percent[$i]."' ,'".$_SESSION['caddie']->tva_percent[$i]."' ,'".$_SESSION['caddie']->couleur[$i]."' ,'".$_SESSION['caddie']->taille[$i]."' ,'".addslashes($_SESSION['caddie']->comment[$i])."' )" ; mysql_query_override($requete); } } } $total_ht = $total_ttc = ''; if($_SESSION['caddie']->total_ht>0) { $total_ht = number_format(($_SESSION['caddie']->total_ht),2,'.',' ').' € HT'; $total_ttc = number_format($_SESSION["caddie"]->total,2,'.',' ').' € TTC'; } $recuser = mysql_query_override("select * from gaia_utilisateurs where id_utilisateur = '".$_SESSION['utilisateur']['id_utilisateur']."'"); $user = mysql_fetch_array_override($recuser); //envoi de la fiche client au commercial $message = 'Bonjour,<br /><br /> Nouveau devis sur le site : <br />'. '<br />Devis : '.$devisid. '<br />Email : '.mb_strtolower($user['email']). '<br />Civilité : '.vb($user['civilite']). '<br />Prénom : '.mb_strtoupper(addslashes($user['prenom'])). '<br />Nom : '.mb_strtoupper(addslashes($user['nom_famille'])). '<br />Société : '.(addslashes($user['societe'])). '<br />Fonction : '.$user['portable']. '<br />Téléphone : '.$user['telephone']. '<br />Adresse : '.addslashes($user['adresse']). '<br />Code postal : '.$user['code_postal']. '<br />Ville : '.addslashes($user['ville']). '<br />Commentaires :<br /> '.(addslashes($_SESSION['caddie']->commentaires)); $message .="<br /><br/><b>Produits du devis :</b> <br />"; $message .= "<table width=\"100%\"><tr><td style='background:#F08A00; color:#fff; font-size:13px'>Produits</td><td style='background:#F08A00; color:#fff; font-size:13px'>PU HT</td><td style='background:#F08A00; color:#fff; font-size:13px'>QTE</td><td style='background:#F08A00; color:#fff; font-size:13px'>Total HT</td><td style='background:#F08A00; color:#fff; font-size:13px'>Total TTC</td></tr> "; $message .= implode('',$prods); $message .= "<tr><td colspan='2'></td><td style=\"font-size:15px\"><strong>TOTAL</strong></td><td style=\"font-size:15px\">".$total_ht." </td><td style=\"font-size:15px\">".$total_ttc."</td> </tr>"; $message .= "</table>"; $commercial = get_commercial($user['code_postal']); if(isset($commercial['email'])) mail_confirm($commercial['email'],'Nouveau devis sur Kassiope.fr',($message),"From:$support"); else $message .= '<br /><br />ATTENTION, aucun commercial n\'a reçu ce message !!!'; mail_confirm($support,'Nouveau devis sur Kassiope.fr',($message),"From:$support"); $mail = get_static(431); $mailSubject = $mail['nom_fr']; $mailObjet = mail_transform(5,$mail['description_fr'], intval($devisid), 0 ); mail_confirm($user['email'],$mailSubject,$mailObjet,"From:$support"); /* mail_confirm('jsabat@wagaia.com',$mailSubject,$mailObjet,"From:$support"); */ //mail_confirm('jsabat@wagaia.com','Nouveau devis sur Kassiope.fr',$commercial['email'].($message),"From:$support"); return $devisid; } function email_commande_cb(&$commandeid) { global $wwwroot; global $site; global $support; global $langfile; $result = mysql_query_override("SELECT email, o_timestamp, montant FROM gaia_commandes WHERE id ='".$commandeid."'"); $com = mysql_fetch_object_override($result); $timestamp = $com->o_timestamp; $montant = $com->montant; mail_confirm( $support, "Nouvelle commande par carte bancaire sur votre site web $site", "Une commande portant le numéro $commandeid vient d'être enregistrée sur le site $site.", "FROM:$support"); if (file_exists($langfile)){ require ($langfile); } /* Mail à l'adresse de facturation */ mail_confirm($com->email,SUBJECT_EMAIL_BILLING_CB,MSG_EMAIL_BILLING_CB,"FROM:$support"); } function verifier_authentification($email, $mot_passe) { $requete = " SELECT * FROM gaia_utilisateurs WHERE priv <> 'stop' and LOWER(email) = '".mb_strtolower($email)."' AND mot_passe = '".md5($mot_passe)."' "; $qid = mysql_query_override($requete); // or DIE('Une erreur de connexion à la base s est produite ' . __LINE__ . '.<p>' . MYSQL_ERROR());; if (mysql_num_rows_override($qid) > 0) { return mysql_fetch_array_override($qid); } else { return; } } function mydate($format, $publictime) { $sec = substr($publictime, 12, 2); $min = substr($publictime, 10, 2); $hour = substr($publictime, 8, 2); $day = substr($publictime, 6, 2); $month = substr($publictime, 4, 2); $year = substr($publictime, 0, 4); return date($format, mktime($hour, $min, $sec, $month, $day, $year)); } function filtre_pdf($chaine) { $chaine = str_replace("è","è",$chaine); $chaine = str_replace("é","é",$chaine); $chaine = str_replace("é","é",$chaine); $chaine = str_replace("Ã","à",$chaine); $chaine = str_replace("'","'",$chaine); $chaine = str_replace("°","°",$chaine); return $chaine; } function calcul_nbprod_parcat($catid) { $sqlCount = "SELECT COUNT(*) FROM gaia_produits p, gaia_produits_categories pc WHERE p.id = pc.produit_id AND pc.categorie_id = '".intval($catid)."'"; $resCount = mysql_query_override($sqlCount); $Count = mysql_fetch_row_override($resCount); return $Count[0]; } function validName($fileName) { $fileName=stripslashes($fileName); $trans = array("ó" => "o", "s" => "s" ," " => "_","n" => "n","l" => "l","a" => "a","é" => "e","z" => "z","z" => "z","c" => "c","Ó" => "O", "S" => "S" ,"N" => "N","L" => "L","A" => "A","E" => "E","Z" => "Z","Z" => "Z","C" => "C","\""=>"","'"=>""); $fileName=strtr($fileName, $trans); return strtolower($fileName); } function propre($mot) { $mot = stripslashes($mot); $mot = utf8_decode($mot); $mot = mb_convert_encoding($mot,'HTML-ENTITIES','iso-8859-1'); $mot = preg_replace( array('/ß/','/&(..)lig;/', '/&([aouAOU])uml;/','/&(.)[^;]*;/'), array('ss',"$1","$1".'e',"$1"), $mot); //$mot = eregi_replace("[^a-z0-9]",'',$mot); $mot = str_replace('#','-',$mot); $mot = str_replace('&','-',$mot); $mot = str_replace('%','-',$mot); $mot = str_replace(':','',$mot); $mot = str_replace(',','',$mot); $mot = str_replace('?','',$mot); $mot = str_replace('!','',$mot); $mot = str_replace('/','',$mot); $mot = str_replace(' ','-',$mot); $mot = str_replace("'",'-',$mot); $mot = str_replace(".",'',$mot); $mot = str_replace("(",'',$mot); $mot = str_replace(")",'',$mot); $mot = str_replace('---','-',$mot); $mot = str_replace('--','-',$mot); $mot = strtolower($mot); return $mot; } ?>