src/Biz/CloudPlatform/KeyApplier.php

(开头部分) 2KB

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

<?php

namespace Biz\CloudPlatform;

use Topxia\Service\Common\ServiceKernel;
use AppBundle\Common\CurlToolkit;

class KeyApplier
{
    private $moked;

    public function applyKey($user, $edition = 'opensource', $source = 'apply')
    {
        $setting = $this->getSettingService()->get('storage', array());
        if (!empty($setting['cloud_access_key']) && !empty($setting['cloud_secret_key']) && !empty($setting['cloud_key_applied'])) {
            return array(
                'accessKey' => $setting['cloud_access_key'],
                'secretKey' => $setting['cloud_secret_key'],
            );
        }

        $profile = $this->getUserService()->getUserProfile($user['id']);

        $params = array();
        $site = $this->getSettingService()->get('site');

        $params['siteName'] = empty($site['name']) ? 'EduSoho网络课程' : $site['name'];
        $params['siteUrl'] = 'http://'.$_SERVER['HTTP_HOST'];
        $params['email'] = empty($user['email']) ? '' : $user['email'];
        $params['contact'] = empty($profile['truename']) ? '' : $profile['truename'];
        $params['qq'] = empty($profile['qq']) ? '' : $profile['qq'];
        $params['mobile'] = empty($profile['mobile']) ? '' : $profile['mobile'];
        $params['edition'] = empty($edition) ? 'opensource' : $edition;
        $params['source'] = empty($source) ? 'apply' : $source;

        $url = empty($setting['cloud_api_server']) ? 'http://api.edusoho.net' : rtrim($setting['cloud_api_server'], '/');
        $url = $url.'/v1/keys';

        $curlOptions = array(
            'connectTimeout' => 20,
            'userAgent' => 'EduSoho Install Client 1.0',
            'timeout' => 20,
            'headers' => array(
                'Content-type: application/json',
                'Sign: '.md5(json_encode($params)),
            ),
        );

        $response = empty($this->moked) ? CurlToolkit::request('POST', $url, json_encode($params), $curlOptions) : array(
            'url' => $url,
            'params' => $params,
            'curlOptions' => $curlOptions,
        );
        if (empty($response)) {
            return array('error' => '生成Key失败,请检查服务器的网络设置!');
        }

        return $response;
    }

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

AI 解读 AI

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

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