src/Biz/CloudPlatform/Service/Impl/EduCloudServiceImpl.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\CloudPlatform\Service\Impl;

use Biz\CloudPlatform\Service\EduCloudService;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Biz\BaseService;
use Topxia\Service\Common\ServiceKernel;
use Biz\CloudPlatform\CloudAPIFactory;

class EduCloudServiceImpl extends BaseService implements EduCloudService
{
    private $cloudApi;

    private $isVisible;

    public function isVisibleCloud()
    {
        if (isset($this->isVisible)) {
            return $this->isVisible;
        }

        $this->isVisible = false;
        try {
            $api = $this->createCloudApi();
            $overview = $api->get("/cloud/{$api->getAccessKey()}/overview");
        } catch (\RuntimeException $e) {
            $logger = new Logger('CloudAPI');
            $logger->pushHandler(new StreamHandler(ServiceKernel::instance()->getParameter('kernel.logs_dir').'/cloud-api.log', Logger::DEBUG));
            $logger->addInfo($e->getMessage());

            return $this->isVisible;
        }

        if (!isset($overview['error'])) {
            $this->isVisible = $overview['accessCloud'] && $overview['enabled'];
        }

        return $this->isVisible;
    }

    public function getOldSmsUserStatus()
    {
        $smsAccount = $this->getSettingService()->get('sms_account');
        if ($this->isReloadSmsAccountFromCloud($smsAccount)) {
            $smsAccount = $this->getUserSmsAccountFromCloud();
        }
        if ('unusual' == $smsAccount['status']) {
            return $smsAccount;
        }

        return false;
    }

    private function isReloadSmsAccountFromCloud($smsAccount)
    {
        if (!$smsAccount || ('normal' != $smsAccount['status'] && $smsAccount['checkTime'] < time())) {
            return true;
        }

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。