<?php
/****************************************************************************************
 * SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV
 *
 * Version 1.0.4
 *
 * Copyright (C) 2006-2016  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
 ****************************************************************************************/


// Vérification des tentatives de hack
$pos = strpos($_SERVER['PHP_SELF'], 'inc.php');
if ($pos !== FALSE) {
    header('Location: ../index.php');
}

/*******************************************************/
/* Fonctions pour les accès aux fichiers mots de passe */
/* et comptes utilisateurs                             */
/*******************************************************/

/**
 * Vérifie si un compte est désactivé
 *
 * @param $code
 * @param bool $open
 * @return bool
 */
function account_locked($code, $open = TRUE)
{
    global
    $db;
    $locked = FALSE;

    if ($open == TRUE) {
        $db = open_database(DBUSER, DBPASS, DBNAME, DBHOST, 'utf8');
    }
    $rexist = 'SELECT COUNT(*) FROM `' . TBPW . "` WHERE `pw_code` = '" . $db->escape($code) . "' AND `pw_actif` = '0'";
    $nbres = $db->get_var($rexist);
    if ($nbres > 0) {
        $locked = TRUE;
    }
    if ($open == TRUE) {
        close_database();
    }

    return $locked;
}
