src/Controller/Fonctions/Fonctions.php line 135

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Fonctions;
  3. class Fonctions
  4. {
  5.     // renvoie le nom de domaine du site pour le partage des lien 
  6.     function FonctionUrl()
  7.     {
  8.         $url 'localhost:8000';
  9.         return $url;
  10.     }
  11.     function FonctionLogo()
  12.     {
  13.         $logo '1';
  14.         return $logo;
  15.     }
  16.     // fonction comparer les id 
  17.     function FonctionSecurite($userOpe$iduser)
  18.     {
  19.         $idteste 0;
  20.         $villeteste '';
  21.         $logement '';
  22.         $superficie '';
  23.         $usersByRole $userOpe->findByuser($iduser);
  24.         foreach ($usersByRole as $user) {
  25.             $idteste $user->getUser();
  26.             $logement $user->getLogement();
  27.             $superficie $user->getSuperficie();
  28.             $villeteste $user->getVille();
  29.             $somme $user->getSomme();
  30.             $transaction $user->getTransaction();
  31.         }
  32.         return array('idteste' => $idteste'villeteste' => $villeteste'logement' => $logement'superficie' => $superficie'somme' => $somme'transaction' => $transaction);
  33.     }
  34.     // fonction pour crer la date
  35.     function FonctionDate()
  36.     {
  37.         $today date("Y-m-d");
  38.         $format 'Y-m-d';
  39.         // Création de la date de l'operation 
  40.         $date \DateTime::createFromFormat($format$today);
  41.         $annee   =    $date->format('Y');
  42.         $mois   =    $date->format('m');
  43.         $jour   =    $date->format('d');
  44.         $moisenr =  '' $annee '' $mois '' $jour '';
  45.         return $moisenr;
  46.     }
  47.     // fonction pour crer un token 
  48.     function random($var)
  49.     {
  50.         $string "";
  51.         $chaine "a0b1c2d3e4f5g6h7i8j9klmnpqrstuvwxy123456789";
  52.         srand((float)microtime() * 1000000);
  53.         for ($i 0$i $var$i++) {
  54.             $string .= $chaine[rand() % strlen($chaine)];
  55.         }
  56.         return $string;
  57.     }
  58.     function CalculVPM($mensualite$pourcent_annuel$prix)
  59.     {
  60.         $t_mensuel $pourcent_annuel 12;
  61.         $t_mensuel $t_mensuel 100;
  62.         $R = (pow(($t_mensuel), -$mensualite)) / $t_mensuel;
  63.         $VPM = (($prix) / $R);
  64.         return $VPM;
  65.     }
  66.     function NomLocalite($nom)
  67.     {
  68.         $nom ucwords($nom);
  69.         $message '( prise de vue: ' $nom ') ';
  70.         return $message;
  71.     }
  72.     // fonction pour recupoere l'adresse IP.
  73.     function NomIp()
  74.     {
  75.         $ip $_SERVER['REMOTE_ADDR'];
  76.         if ($ip == '127.0.0.1') {
  77.             $ip '84.100.177.102';
  78.         }
  79.         return $ip;
  80.     }
  81.     // fonction pour trouver la ville de l'utulisateur 
  82.     function FonctionOujesuis($ip)
  83.     {
  84.         // recherche ip et adresse 
  85.         // https://ipinfo.io/
  86.         // https://qastack.fr/programming/409999/getting-the-location-from-an-ip-address
  87.         $details json_decode(file_get_contents("http://ipinfo.io/{$ip}?token=8e662a92ab261a"));
  88.         $ville $details->city// -> "Mountain View"
  89.         $postal $details->postal;
  90.         $country $details->country;
  91.         return array('ville' =>  $ville'postal' =>  $postal'country' =>  $country);
  92.     }
  93.     // fonction pour importer une image
  94.     function FonctionImage($lieux$rechimage)
  95.     {
  96.         $nbr 0;
  97.         $re $lieux;
  98.         $tagliste = array();
  99.         $largeImageURL '0';
  100.         $webformatURL '0';
  101.         $tag '';
  102.         $people_json file_get_contents("https://pixabay.com/api/?key=26307686-649627882781f3a30d2540fa1&q={$re}+france&lang=fr&image_type=photo");
  103.         $decoded_json json_decode($people_jsontrue);
  104.         $customers $decoded_json['hits'];
  105.         $premiereimage '';
  106.         $premieretag '';
  107.         foreach ($customers as $customer) {
  108.             $nbr++;
  109.             // recuperation de la premiere image 
  110.             $premiereimage =  $customer['webformatURL'];
  111.             // recuperation du premier tag.
  112.             $premieretag =  $customer['tags'];
  113.             $pieces explode(","$premieretag);
  114.             $tagliste $pieces;
  115.             $premieretag $pieces[0];
  116.             // condition pour prendre la primiere image 
  117.             if ($nbr == $rechimage) {
  118.                 $chaine $customer['tags'];
  119.                 $chaine str_replace(", "","$chaine);
  120.                 $pieces explode(","$chaine);
  121.                 $tagliste $pieces;
  122.                 $tag $pieces[0];
  123.                 $largeImageURL $customer['largeImageURL'];
  124.                 $webformatURL $customer['webformatURL'];
  125.             }
  126.         }
  127.         return array('largeImageURL' => $largeImageURL'webformatURL' => $webformatURL'tag' => $tag'tagliste' => $tagliste'premiereimage' => $premiereimage'premieretag' => $premieretag);
  128.     }
  129.     // fonction pour importer une image
  130.     function FonctionImageVille($lieux$rechimage$departement)
  131.     {
  132.         if ($departement  !=  0) {
  133.             $image '+ville';
  134.         } else {
  135.             $image '';
  136.         }
  137.         $image '+ville';
  138.         $rest0 substr($lieux,  01); // retourne "le premier caractaire"
  139.         $rest1 strtolower($rest0);
  140.         $re str_replace($rest0$rest1$lieux);
  141.         $imageliste1 0;
  142.         $imageliste2 0;
  143.         $tagliste = array();
  144.         $largeImageURL '0';
  145.         $webformatURL '0';
  146.         $tag '';
  147.         $nbr 0;
  148.         $people_json file_get_contents("https://pixabay.com/api/?key=26307686-649627882781f3a30d2540fa1&q={$re}{$image}&lang=fr&image_type=photo");
  149.         $decoded_json json_decode($people_jsontrue);
  150.         $customers $decoded_json['hits'];
  151.         $premiereimage 0;
  152.         $premieretag '';
  153.         foreach ($customers as $customer) {
  154.             $chaine $customer['tags'];
  155.             $chaine str_replace(", "","$chaine);
  156.             $pieces explode(","$chaine);
  157.             $tagliste $pieces;
  158.             $tag $pieces[0];
  159.             $imageliste1 $customer['largeImageURL'];
  160.             $imageliste2 $customer['webformatURL'];
  161.             // condition pour prendre la primiere image 
  162.             if ($tag == $re) {
  163.                 $nbr++;
  164.                 $largeImageURL $customer['largeImageURL'];
  165.                 $webformatURL $customer['webformatURL'];
  166.                 if ($nbr == 1) {
  167.                     $premiereimage $webformatURL;
  168.                 }
  169.             }
  170.         }
  171.         return array('largeImageURL' => $largeImageURL'webformatURL' => $webformatURL'tag' => $tag'tagliste' => $tagliste'premiereimage' => $premiereimage'premieretag' => $premieretag'imageliste1' => $imageliste1'imageliste2' => $imageliste2);
  172.     }
  173.     // fonction pour importer une image
  174.     function FonctionDepartement($departement)
  175.     {
  176.         $array = array("1" => " Ain""2" => " Aisne""3" => " Allier""4" => " Alpes-de-Haute-Provence""6" => " Alpes-Maritimes""7" => " Ardèche""8" => " Ardennes""9" => " Ariège""10" => " Aube""11" => " Aude""12" => " Aveyron""67" => " Bas-Rhin""13" => " Bouches-du-Rhône""14" => " Calvados""15" => " Cantal""16" => " Charente""17" => " Charente-Maritime""18" => " Cher""19" => " Corrèze""2A" => " Corse-du-Sud""21" => " Côte-d'Or""22" => " Côtes-d'Armor""23" => " Creuse""79" => " Deux-Sèvres""24" => " Dordogne""25" => " Doubs""26" => " Drôme""91" => " Essonne""27" => " Eure""28" => " Eure-et-Loir""29" => " Finistère""30" => " Gard""32" => " Gers""33" => " Gironde""971" => " Guadeloupe""973" => " Guyane""68" => " Haut-Rhin""2B" => " Haute-Corse""31" => " Haute-Garonne""43" => " Haute-Loire""52" => " Haute-Marne""70" => " Haute-Saône""74" => " Haute-Savoie""87" => " Haute-Vienne""05" => " Hautes-Alpes""65" => " Hautes-Pyrénées""92" => " Hauts-de-Seine""34" => " Hérault""35" => " Ille-et-Vilaine""36" => " Indre""37" => " Indre-et-Loire""38" => " Isère""39" => " Jura""974" => " La Réunion""40" => " Landes""41" => " Loir-et-Cher""42" => " Loire""44" => " Loire-Atlantique""45" => " Loiret""46" => " Lot""47" => " Lot-et-Garonne""48" => " Lozère""49" => " Maine-et-Loire""50" => " Manche""51" => " Marne""972" => " Martinique""53" => " Mayenne""976" => " Mayotte""54" => " Meurthe-et-Moselle""55" => " Meuse""56" => " Morbihan""57" => " Moselle""58" => " Nièvre""59" => " Nord""60" => " Oise""61" => " Orne""75" => " Paris""62" => " Pas-de-Calais""63" => " Puy-de-Dôme""64" => " Pyrénées-Atlantiques""66" => " Pyrénées-Orientales""69" => " Rhône""71" => " Saône-et-Loire""72" => " Sarthe""73" => " Savoie""77" => " Seine-et-Marne""76" => " Seine-Maritime""93" => " Seine-Saint-Denis""80" => " Somme""81" => " Tarn""82" => " Tarn-et-Garonne""Belfort" => " Territoire""95" => " Val-d'Oise""94" => " Val-de-Marne""83" => " Var""84" => " Vaucluse""85" => " Vendée""86" => " Vienne""88" => " Vosges""89" => " Yonne""78 " => " Yvelines",);
  177.         $departement $departement  1;
  178.         $departement $array[$departement];
  179.         return $departement;
  180.     }
  181.     // fonction pour importer une image
  182.     function FonctionRegion($numdepartement)
  183.     {
  184.         $array = array("1" => "RhôneAlpes""2" => "Picardie""3" => "Auvergne""4" => "Provence-Alpes-Côted'Azur""5" => "Provence-Alpes-Côted'Azur""6" => "Provence-Alpes-Côted'Azur""7" => "RhôneAlpes""8" => "Ardenne""9" => "Midi-Pyrénées""10" => "Champagne-Ardenne""11" => "LanguedocRoussillon""12" => "Midi-Pyrénées""13" => "Provence-Alpes-Côted'Azur""14" => "Normandie""15" => "Auvergne""16" => "Poitou-Charentes""17" => "Poitou-Charentes"" 18" => "Centre-ValdeLoire""19" => "Limousin"" 2A" => "Corse"" 2B" => "Corse""21" => "Bourgogne""22" => "Bretagne""23" => "Limousin""24" => "Aquitaine""25" => "Franche-Comté""26" => "Rhône-Alpes""27" => "Normandie""28" => "Centre-ValdeLoire""29" => "Bretagne""30" => "LanguedocRoussillon""31" => "Midi-Pyrénées""32" => "Midi-Pyrénées""33" => "Aquitaine""34" => "LanguedocRoussillon""35" => "Bretagne""36" => "Centre-ValdeLoire""37" => "Centre-ValdeLoire""38" => "Rhône-Alpes""39" => "Franche-Comté""40" => "Aquitaine""41" => "Centre-ValdeLoire""42" => "Rhône-Alpes""43" => "Auvergne""44" => "PaysdelaLoire""45" => "Centre-ValdeLoire""46" => "Midi-Pyrénées""47" => "Aquitaine""48" => "LanguedocRoussillon""49" => "PaysdelaLoire""50" => "Manche""51" => "Champagne-Ardenne""52" => "Champagne-Ardenne""53" => "PaysdelaLoire""54" => "Lorraine""55" => "Lorraine""56" => "Bretagne""57" => "Lorraine""58" => "Bourgogne""59" => "Nord-Pas-de-Calais""60" => "Picardie""61" => "Normandie""62" => "Nord-Pas-de-Calais""63" => "Auvergne""64" => "Midi-Pyrénées""65" => "Occitanie""66" => "LanguedocRoussillon""67" => "Alsace""68" => "Alsace""69" => "Rhône-Alpes""70" => "Franche-Comté""71" => "Bourgogne""72" => "PaysdelaLoire""73" => "Rhône-Alpes""74" => "Rhône-Alpes""75" => "Île-de-France""76" => "Normandie""77" => "Île-de-France""78" => "Île-de-France""79" => "Poitou-Charentes""80" => "Picardie""81" => "Midi-Pyrénées""82" => "Midi-Pyrénées""83" => "Provence-Alpes-Côted'Azur""84" => "Provence-Alpes-Côted'Azur""85" => "PaysdelaLoire""86" => "Poitou-Charentes""87" => "Limousin""88" => "Vosges""89" => "Bourgogne""90" => "Franche-Comté""91" => "Île-de-France""92" => "Île-de-France""93" => "Île-de-France""94" => "Île-de-France""95" => "Île-de-France""971" => "Guadeloupe""972" => "Martinique""973" => "Guyane""974" => "LaRéunion""976" => "Mayotte ",);
  185.         $numdepartement $numdepartement  1;
  186.         $region $array[$numdepartement];
  187.         return $region;
  188.     }
  189.     // fonction pour calculer la distance gps
  190.     function Distance($lat1$lng1$lat2$lng2$miles false)
  191.     {
  192.         $pi80 M_PI 180;
  193.         $lat1 *= $pi80;
  194.         $lng1 *= $pi80;
  195.         $lat2 *= $pi80;
  196.         $lng2 *= $pi80;
  197.         $r 6372.797// rayon moyen de la Terre en km
  198.         $dlat $lat2 $lat1;
  199.         $dlng $lng2 $lng1;
  200.         $a sin($dlat 2) * sin($dlat 2) + cos($lat1) * cos($lat2) * sin(
  201.             $dlng 2
  202.         ) * sin($dlng 2);
  203.         $c atan2(sqrt($a), sqrt($a));
  204.         $km $r $c;
  205.         return ($miles ? ($km 0.621371192) : $km);
  206.     }
  207.     // fonction générer le tableau des adresses
  208.     function Overpass($lat$lon$around$typen)
  209.     {
  210.         $tabligne = array();
  211.         $highway '';
  212.         if ($typen == 1) {
  213.             $typereq '"amenity"="school"';
  214.             $nomfr 'Education';
  215.             $type '1';
  216.             $typenbr '1';
  217.         }
  218.         if ($typen == 2) {
  219.             $typereq '"amenity"="doctors"';
  220.             $nomfr 'Santé';
  221.             $type '2';
  222.             $typenbr '2';
  223.         }
  224.         if ($typen == 3) {
  225.             $typereq 'shop=supermarket';
  226.             $nomfr 'Supermarché';
  227.             $type '3';
  228.             $typenbr '3';
  229.         }
  230.         if ($typen == 4) {
  231.             $typereq 'bus';
  232.             $highway 'bus';
  233.             $nomfr 'Transports';
  234.             $type 'bus';
  235.             $typenbr '4';
  236.         }
  237.         if ($typen == 5) {
  238.             $typereq 'tram';
  239.             $highway 'tram';
  240.             $nomfr 'Transports';
  241.             $type '5';
  242.             $typenbr '5';
  243.         }
  244.         if ($typen == 6) {
  245.             $typereq 'subway';
  246.             $highway 'métro';
  247.             $nomfr 'Transports';
  248.             $type 'métro';
  249.             $typenbr '6';
  250.         }
  251.         $lien "https://www.overpass-api.de/api/interpreter?data=[out:json];node[{$typereq}](around:{$around},{$lat},{$lon});out%20center;";
  252.         $fields_string file_get_contents($lien);
  253.         $data json_decode($fields_stringtrue); // return array not object
  254.         // var_dump($data);
  255.         $trolley 0;
  256.         $nbr 0;
  257.         foreach ($data['elements'] as  $customer) {
  258.             $nbr++;
  259.             if (isset($customer['tags']['name']) == 1) {
  260.                 $name $customer['tags']['name'];
  261.             } else {
  262.                 $name =  $nomfr;
  263.             }
  264.             if (isset($customer['tags']['brand']) == 1) {
  265.                 $brand $customer['tags']['brand'];
  266.             } else {
  267.                 $brand =  0;
  268.             }
  269.             if (isset($customer['tags']['school:FR']) == 1) {
  270.                 $typesenseing $customer['tags']['school:FR'];
  271.             } else {
  272.                 $typesenseing =  0;
  273.             }
  274.             if (isset($customer['tags']['highway']) == 'bus_stop') {
  275.                 $highway 'bus';
  276.             }
  277.             if (isset($customer['tags']['railway']) == 'tram_stop') {
  278.                 $highway 'tram';
  279.             }
  280.             if (isset($customer['tags']['trolleybus']) == 'yes') {
  281.                 $trolley 'trolleybus';
  282.             }
  283.             $tabligne[$nbr] = array('lat' => $customer['lat'], 'lon' => $customer['lon'], 'name' => $name'nomfr' => $nomfr'type' => $type'typenbr' => $typenbr'nbr' => $nbr'brand' => $brand'typesensei' => $typesenseing'highway' => $highway'amenity' => '''trolley' => $trolley);
  284.         }
  285.         $array $tabligne;
  286.         return $array;
  287.     }
  288.     // fonction générer le tableau des adresses
  289.     function Openstreetmap($ville$type$typen)
  290.     {
  291.         $limit 100;
  292.         $locSearch "https://nominatim.openstreetmap.org/?addressdetails=1&q={$type}+in+{$ville}&format=json&limit={$limit}";
  293.         $options = array(
  294.             "http" => array(
  295.                 "header" => "User-Agent: StevesCleverAddressScript 3.7.6\r\n"
  296.             )
  297.         );
  298.         $context stream_context_create($options);
  299.         $fields_string file_get_contents($locSearchfalse$context);
  300.         $data json_decode($fields_stringtrue); // return array not object
  301.         $nbr 0;
  302.         foreach ($data as  $customer) {
  303.             $nbr++;
  304.             $highway '';
  305.             $amenity '';
  306.             $name '';
  307.             if (isset($customer['address']['highway']) == 1) {
  308.                 $highway =   $customer['address']['highway'];
  309.             }
  310.             if (isset($customer['address']['display_name']) == 1) {
  311.                 $name =   $customer['address']['display_name'];
  312.             }
  313.             if (isset($customer['address']['shop']) == 1) {
  314.                 $name =   $customer['address']['shop'];
  315.             }
  316.             if ($type == 'school') {
  317.                 if (isset($customer['address']['amenity']) == 1) {
  318.                     $amenity =   $customer['address']['amenity'];
  319.                 } else {
  320.                     $amenity 0;
  321.                 }
  322.             }
  323.             $tabligne[$nbr] = array('lat' => $customer["lat"], 'lon' => $customer["lon"], 'name' => $name'highway' =>  $highway'nomfr' =>  $typen'type' => $type'typenbr' => $typen'nbr' => $nbr'brand' => $typen'highway' =>  $highway'typesensei' => $typen'highway' => $highway'amenity' => $amenity'trolley' => '');
  324.         }
  325.         $array $tabligne;
  326.         return $array;
  327.     }
  328.     // fonction générer le tableau des adresses
  329.     function Transport($lat$lon$type$around)
  330.     {
  331.         $type1 $type;
  332.         if ($type1 == 'subway') {
  333.             $type1 'métro';
  334.         }
  335.         $tabligne = array();
  336.         $lien "https://www.overpass-api.de/api/interpreter?data=[out:json];node[route={$type}];way[route={$type}];relation[route={$type}](around:{$around},{$lat},{$lon});out%20center;";
  337.         $fields_string file_get_contents($lien);
  338.         $data json_decode($fields_stringtrue); // return array not object
  339.         // var_dump($data);
  340.         $nbr 0;
  341.         foreach ($data['elements'] as  $customer) {
  342.             //  var_dump($customer);
  343.             $colour '';
  344.             $networkshort '';
  345.             $network '';
  346.             $operatorshort '';
  347.             $from '';
  348.             $name '';
  349.             $nbr++;
  350.             $name $customer['tags']['name'];
  351.             $from =  '';
  352.             if (isset($customer['tags']['from']) == 1) {
  353.                 $from =   $customer['tags']['from'];
  354.             }
  355.             $lat =   $customer['center']['lat'];
  356.             $lon =   $customer['center']['lon'];
  357.             $ligne $customer['tags']['ref'];
  358.             if (isset($customer['tags']['operator:short']) == 1) {
  359.                 $operatorshort =   $customer['tags']['operator:short'];
  360.             }
  361.             if (isset($customer['tags']['network']) == 1) {
  362.                 $network =  $customer['tags']['network'];
  363.             }
  364.             if (isset($customer['tags']['network:short']) == 1) {
  365.                 $networkshort =   $customer['tags']['network:short'];
  366.             }
  367.             if (isset($customer['tags']['colour']) == 1) {
  368.                 $colour $customer['tags']['colour'];
  369.             }
  370.             $tabligne[$nbr] = array('colour' => $colour'network:short' => $networkshort'network' => $network'operator:short' =>  $operatorshort'from' => $from'name' => $name'ligne' => $ligne'lat' => $lat'lon' => $lon'type' => $type1);
  371.         }
  372.         $array $tabligne;
  373.         return $array;
  374.     }
  375.     // fonction pour importer une image
  376.     function FonctionRayon($lat$long$meters)
  377.     {
  378.         $equator_circumference 6371000//meters
  379.         $polar_circumference 6356800//meters
  380.         $m_per_deg_long 360 $polar_circumference;
  381.         $rad_lat = ($lat M_PI 180); //convert to radians, cosine takes a radian argument and not a degree argument
  382.         $m_per_deg_lat 360 / (cos($rad_lat) * $equator_circumference);
  383.         $deg_diff_long $meters $m_per_deg_long;  //Number of degrees latitude as you move north/south along the line of longitude
  384.         $deg_diff_lat $meters $m_per_deg_lat//Number of degrees longitude as you move east/west along the line of latitude
  385.         //changing north/south moves along longitude and alters latitudinal coordinates by $meters * meters per degree longitude, moving east/west moves along latitude and changes longitudinal coordinates in much the same way.
  386.         $coordinates['north']['lat'] = $lat $deg_diff_long;
  387.         $coordinates['north']['long'] = $long;
  388.         $coordinates['south']['lat'] = $lat $deg_diff_long;
  389.         $coordinates['south']['long'] = $long;
  390.         $coordinates['east']['lat'] = $lat;
  391.         $coordinates['east']['long'] = $long $deg_diff_lat;  //Might need to swith the long equations for these two depending on whether coordinates are east or west of the prime meridian
  392.         $coordinates['west']['lat'] = $lat;
  393.         $coordinates['west']['long'] = $long $deg_diff_lat;
  394.         $array = array('SouthLat' => $coordinates['south']['lat'], 'WestLong' => $coordinates['west']['long'], 'NorthLat' => $coordinates['north']['lat'], 'EastLong' =>  $coordinates['east']['long']);
  395.         return $array;
  396.     }
  397.     // comparaison de dates
  398.     function Compardates($date)
  399.     {
  400.         if (strlen($date) == 10) {
  401.  
  402.             $date str_replace("-""",  $date);
  403.             if (strlen($date) == 8) {
  404.                 $jourj =  '' date(" Y") . '' .  date('m') .  '' date('d') . '';
  405.  
  406.  
  407.                 $annemax =  date(" Y") + 2;
  408.                 $datemax '' $annemax '' .  date('m') .  '' date('d') . '';
  409.  
  410.                 if ($jourj <= $date) {
  411.                     if ($datemax >= $date) {
  412.                         $jour 1;
  413.                     } else {
  414.                         $jour 0;
  415.                     }
  416.                 } else {
  417.                     $jour 0;
  418.                 }
  419.             } else {
  420.                 $jour 0;
  421.             }
  422.         } else {
  423.             $jour 0;
  424.         }
  425.         return $jour;
  426.     }
  427.     function Convertiondate($date)
  428.     {
  429.         $pieces explode("-"$date);
  430.         $date '' .  $pieces[0] . '' .  $pieces[1] .  '' .  $pieces[2] . '';
  431.         return  $date;
  432.     }
  433.     
  434.     function Remplacedate($date)
  435.     {
  436.         $date str_replace("-""",  $date);
  437.         $date str_replace(" 00:00:00"""$date);
  438.  
  439.         return  $date;
  440.     }
  441.     function demain($annee ,$mois$jour)
  442.     {
  443.  
  444.         $nbrjour $jour;
  445.        
  446.             if ($mois == 1) {
  447.                 $nbrjour =  31;
  448.             }
  449.             if ($mois == 2) {
  450.                 if ((is_int($annee 4) && !is_int($annee 100)) || is_int($annee 400)) {
  451.                     // Année bissextile
  452.                     // vous remplacez le retour par ce que vou voulez
  453.                     $nbrjour 29;
  454.                 } else {
  455.                     // Année NON bissextile
  456.                     // vous remplacez le retour par ce que vou voulez
  457.                     $nbrjour 28;
  458.                 }
  459.             }
  460.             if ($mois == 3) {
  461.                 $nbrjour 31;
  462.             }
  463.             if ($mois == 4) {
  464.                 $nbrjour 30;
  465.             }
  466.             if ($mois == 5) {
  467.                 $nbrjour =  31;
  468.             }
  469.             if ($mois == 6) {
  470.                 $nbrjour 30;
  471.             }
  472.             if ($mois == 7) {
  473.                 $nbrjour 31;
  474.             }
  475.             if ($mois == 8) {
  476.                 $nbrjour =  31;
  477.             }
  478.             if ($mois == 9) {
  479.                 $nbrjour 30;
  480.             }
  481.             if ($mois == 10) {
  482.                 $nbrjour 31;
  483.             }
  484.             if ($mois == 11) {
  485.                 $nbrjour 30;
  486.             }
  487.             if ($mois == 12) {
  488.                 $nbrjour 31;
  489.             }
  490.         
  491.  
  492.         if ($nbrjour <= $jour) {
  493.             $jour 01;
  494.             $mois =  $mois 1;
  495.             if ($mois == 12) {
  496.                 $jour 01;
  497.                 $mois == 1;
  498.                 $annee $annee 1;
  499.             }
  500.         } else {
  501.             $jour $jour  1;
  502.         }
  503.         if ($mois 10) {
  504.             $mois '0'  .  $mois '';
  505.         }
  506.         if ($jour 10) {
  507.             $jour '0'  .  $jour '';
  508.         }
  509.  
  510.         $date '' $annee '-' .  $mois .  '-' .  $jour '';
  511.         return  $date;
  512.     }
  513.     function dateDiff($date1$date2){
  514.         $diff abs($date1 $date2); // abs pour avoir la valeur absolute, ainsi éviter d'avoir une différence négative
  515.         $retour = array();
  516.      
  517.         $tmp $diff;
  518.         $retour['second'] = $tmp 60;
  519.      
  520.         $tmp floor( ($tmp $retour['second']) /60 );
  521.         $retour['minute'] = $tmp 60;
  522.      
  523.         $tmp floor( ($tmp $retour['minute'])/60 );
  524.         $retour['hour'] = $tmp 24;
  525.      
  526.         $tmp floor( ($tmp $retour['hour'])  /24 );
  527.         $retour  $tmp;
  528.      
  529.         return $retour;
  530.     }
  531.      
  532. }