Mouchard.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "Mouchard.h"
  2. #include "Identifiant.h"
  3. #include <time.h>
  4. Mouchard::Mouchard() : Singleton< Mouchard >()
  5. {
  6. if ( DLL_LIMITEE )
  7. {
  8. unsigned long p = (unsigned long)VALEUR_DU_MOUCHARD;
  9. int a = (int)( p / 100000 );
  10. int m = (int)( ( p % 100000 ) / 1000 );
  11. time_t ct = time( NULL );
  12. struct tm* ts = localtime( &ct );
  13. struct tm t;
  14. t.tm_sec = 0;
  15. t.tm_min = 0;
  16. t.tm_hour = 0;
  17. t.tm_mday = 1;
  18. t.tm_mon = m - 1;
  19. t.tm_year = a - 1900;
  20. t.tm_isdst = ts->tm_isdst;
  21. mt = mktime( &t );
  22. }
  23. }
  24. unsigned long Mouchard::GetMouchard()
  25. {
  26. return (unsigned long)VALEUR_DU_MOUCHARD;
  27. }
  28. bool Mouchard::IsDLLValid()
  29. {
  30. if ( DLL_LIMITEE )
  31. {
  32. time_t ct = time( NULL );
  33. if ( ct >= mt )
  34. {
  35. return false;
  36. }
  37. }
  38. return true;
  39. }
  40. std::string Mouchard::GetExpirationDate()
  41. {
  42. if ( DLL_LIMITEE )
  43. {
  44. char buf[ 32 ];
  45. struct tm* ts = localtime( &mt );
  46. strftime( buf, sizeof( buf ), "%d %B %Y", ts );
  47. return buf;
  48. }
  49. return "Unlimited";
  50. }