<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 1.0.0

Copyright (C) 2006-2014  Sylvain FATOME
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smi.no-ip.org
 ****************************************************************************************/

/*****************************************************************************/
/* Récupération département en fonction chaine existante et code département */
/*****************************************************************************/

session_start();
sleep(1);
if (array_key_exists("txt", $_REQUEST)) {
    $tomorrow = 0; //60*60*24; // en nb de secondes
    header("Cache-Control: max-age=$tomorrow");
    print_plain();
} else {
    print "Usage : $_SERVER[PHP_SELF]?txt=dep_pays";
}

function print_plain()
{
    header("Content-type: text/html; charset=UTF-8");
    $tab_req = explode('§',$_REQUEST["txt"]);
    if (count($tab_req)>0)
    {
        $tab_str = explode('%', $_SESSION["txtzc"]);
        del_depzc($tab_req, $tab_str);
    }
    print '';
}

/**
 * @param $tab_req
 * @param $tab_str
 */
function del_depzc($tab_req, $tab_str)
{
    require_once("../lib/gettext/gettext.inc");
    include_once("../inc/config.inc.php");
    include_once("../inc/func_txt.inc.php");

    $new_tab = [];

    if (count($tab_str)>0)
    {
        foreach ($tab_str as $value) {
            if (!in_array($value,$tab_req))
                $new_tab[] = $value;
        }
    }

    if (count($new_tab) > 0)
        $_SESSION["txtzc"] = implode('%', $new_tab);
}

?>