SystemPemServices.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\system;
  12. use app\dao\system\SystemPemDao;
  13. use app\services\BaseServices;
  14. class SystemPemServices extends BaseServices
  15. {
  16. public function __construct(SystemPemDao $dao)
  17. {
  18. $this->dao = $dao;
  19. }
  20. public function savePem($data)
  21. {
  22. $this->dao->savePem($data);
  23. return true;
  24. }
  25. public function getPemPath($name)
  26. {
  27. $path = '';
  28. $info = $this->dao->get(['name' => $name]);
  29. if ($info) {
  30. $path = root_path('runtime/pem') . $info['path'] . '.pem';
  31. if (!file_exists($path)) {
  32. // 如果runtime/pem文件夹不存在,创建文件夹
  33. if (!file_exists(root_path('runtime/pem'))) {
  34. mkdir(root_path('runtime/pem'), 0777, true);
  35. }
  36. file_put_contents($path, $info['content']);
  37. }
  38. }
  39. return $path;
  40. }
  41. }