<?php

// +-------------------------------------------------+
// © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net)
// +-------------------------------------------------+
// $Id: IpWhiteListOrm.php,v 1.2.2.2 2025/05/20 14:00:05 qvarin Exp $

namespace Pmb\Security\Orm;

if (stristr($_SERVER['REQUEST_URI'], basename(__FILE__))) {
    die("no access");
}

use Pmb\Common\Orm\Orm;

class IpWhiteListOrm extends Orm
{
    public static $instances = [];

    /**
     *
     * @var \ReflectionClass
     */
    protected static $reflectionClass = null;

    /**
     *
     * @var string
     */
    public static $tableName = "ip_whitelist";

    /**
     *
     * @var string
     */
    public static $idTableName = "id_ip_whitelist";

    /**
     * ID
     *
     * @var int
     */
    public $id_ip_whitelist = 0;

    /**
     * Address IP
     *
     * @var string
     */
    public $ip_whitelist_ip = "";

    /**
     * Date d'ajout
     *
     * @var string
     */
    public $ip_whitelist_time = "";

    /**
     * Renvoie le nombre d'enregistrement
     *
     * @return int
     */
    public static function count()
    {
        $result = pmb_mysql_query("SELECT COUNT(".self::$idTableName.") FROM ".self::$tableName);
        if (pmb_mysql_num_rows($result)) {
            return intval(pmb_mysql_result($result, 0, 0));
        }

        return 0;
    }
}
