Log.class.php 763 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Log selected action in database with ip, datetime and optional logged user.
  4. *
  5. * @author valentin carruesco
  6. *
  7. * @category Core
  8. *
  9. * @license copyright
  10. */
  11. class Log extends Entity
  12. {
  13. public $id,$label,$user,$date,$ip;
  14. protected $fields =
  15. array(
  16. 'id' => 'key',
  17. 'label' => 'longstring',
  18. 'user' => 'string',
  19. 'date' => 'string',
  20. 'ip' => 'string',
  21. );
  22. public static function put($label)
  23. {
  24. global $myUser;
  25. $log = new self();
  26. $log->label = $label;
  27. if (is_object($myUser) && $myUser->getLogin() != '') {
  28. $log->user = $myUser->getLogin();
  29. }
  30. $log->date = time();
  31. $log->ip = Functions::getIP();
  32. $log->save();
  33. }
  34. }