BxOpencvAlerts.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup OpenCV OpenCV integration
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxOpencvAlerts extends BxDolAlertsResponse
  12. {
  13. function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function response($o)
  18. {
  19. if ('system' == $o->sUnit && 'store_file' == $o->sAction && in_array($o->aExtras['store_method'], ['Form', 'Xhr', ])) {
  20. $sStorages = getParam('bx_opencv_option_storages');
  21. $aStorages = explode(',', $sStorages);
  22. if (in_array($o->aExtras['storage_object'], $aStorages)) {
  23. $bObfuscateFaces = false;
  24. if(($oProfile = BxDolProfile::getInstance($o->iSender)) !== false) {
  25. $aInfo = bx_srv($oProfile->getModule(), 'get_content_info_by_profile_id', [$o->iSender]);
  26. $bObfuscateFaces = isset($aInfo['obfuscate_faces']) && $aInfo['obfuscate_faces'];
  27. }
  28. if(($mixedObfuscateFaces = bx_get('obfuscate_faces')) !== false)
  29. $bObfuscateFaces = (int)$mixedObfuscateFaces == 1;
  30. if ($bObfuscateFaces)
  31. bx_srv('bx_opencv', 'process_image', [$o->aExtras['file_path'], isset($o->aExtras['ext']) ? $o->aExtras['ext'] : 'jpg']);
  32. }
  33. }
  34. }
  35. }
  36. /** @} */