<?php
if (!class_exists('crm_hardlock')) require_once("common_cadline_libraries/crm_hardlock.class.php");
if (!class_exists('crm_users')) require_once("common_cadline_libraries/crm_users.class.php");

function setUserStatus($nUserID = 0, $newStatus = 0) // Megszuntetni
{
  crm_users::SetUserStatus($nUserID, $newStatus);
}

function addUser($tomb = array()) // Megszuntetni
{
  crm_users::AddUser($tomb, 1);
}

function addUserHistory($tomb = array(), $newsletter = 1) // Megszuntetni
{
  return crm_users::AddUserHistory($tomb, $newsletter);
}

function updateUserHistory($tomb = array(), $nEventID = 0) // Megszuntetni
{
  return crm_users::UpdateUserHistory($tomb, $nEventID);
}


function getValidLease($nUserID = 0, $level = 0) // Megszuntetni
{

  return crm_users::GetValidLease($nUserID, $level);
}


function tryToAlloc($min = 0, $max = 0) // Megszuntetni
{
  return crm_hardlock::GetTheFirstNotUsedHlNumFromInterval($min, $max);
}

function generatePassword($hlNum, $lan, $type, $version = 64) // Megszuntetni
{
  $lan = crm_hardlock::GetLanSignFromLanUserNumber($lan);
  return Codegen::GeneratePassword($hlNum, $lan, $type, $version);
}

function generateTimeCode($pass, $isid, $numOfDays) // Megszuntetni
{
  return Codegen::GenerateTimeCode($pass, $isid, $numOfDays);
}

function generateTimeCodeForSoftwareKey($pass, $isid, $numOfDays) // Nincs sehol se hasznalva
{
  $ret = generateTimeCode($pass, $isid, $numOfDays);
  return ($ret);
}

function generateTimeCodeForHardwareKey($pass, $numOfDays) // Nincs sehol se hasznalva
{
  $isid = substr($pass, 0, 2) . substr($pass, 7, 2);
  $ret = generateTimeCode($pass, $isid, $numOfDays);
  return ($ret);
}


function conv($str) // Nincs sehol se hasznalva
{
  $ret = str_replace(
    array('u00e1', 'u00c1', 'u00e9', 'u00c9', 'u00ed', 'u00cd', 'u00f3', 'u00d3', 'u00f6', 'u00d6', 'u0151', 'u0150', 'u00fa', 'u00da', 'u00fc', 'u00dc', 'u0171', 'u0170', '\\', '"'),
    array('á', 'Á', 'é', 'É', 'í', 'Í', 'ó', 'Ó', 'ö', 'Ö', 'ő', 'Ő', 'ú', 'Ú', 'ü', 'Ü', 'ű', 'Ű', '', '',),
    $str
  );
  $ret = trim(iconv('latin2', 'utf-8', $ret));
  return ($ret);
}

function reconv($str) // Nincs sehol se hasznalva
{
  $ret = str_replace(
    array('u00e1', 'u00c1', 'u00e9', 'u00c9', 'u00ed', 'u00cd', 'u00f3', 'u00d3', 'u00f6', 'u00d6', 'u0151', 'u0150', 'u00fa', 'u00da', 'u00fc', 'u00dc', 'u0171', 'u0170', '\\', '"'),
    array('á', 'Á', 'é', 'É', 'í', 'Í', 'ó', 'Ó', 'ö', 'Ö', 'ő', 'Ő', 'ú', 'Ú', 'ü', 'Ü', 'ű', 'Ű', '', '',),
    $str
  );
  return ($ret);
}

function AddOrUpdateComputer($npID) // Megszuntetni
{
  crm_hardlock::AddOrUpdateComputer($npID);
}
