Exemple #1
0
 public function __construct($appid = '', $appsecret = '')
 {
     $this->appid = $appid;
     $this->appsecret = $appsecret;
     $this->_check_apps();
     $this->host = \mysoft\pubservice\Conf::getConfig('api_site');
 }
Exemple #2
0
 public function sms($content, $smsto = [])
 {
     $to = [];
     if ($smsto) {
         $to = $smsto;
     } else {
         $to = $this->smsto;
     }
     if (empty($to)) {
         throw new \Exception('发送对象为空');
     }
     if (empty($content)) {
         throw new \Exception('内容发送不能为空');
     }
     //追加消息尾部
     $content .= "[{$this->_randomCode()}]";
     $receiveMobileTel = implode(';', $to);
     $conf = Conf::getConfig('sms_verify_code');
     $conf = json_decode($conf, true);
     $sender = new HttpSmsSender(new \mysoft\http\Curl());
     $sender->SendUrl = 'http://sms3.mobset.com/SDK/Sms_Send.asp';
     $sender->CompanyId = $conf['CompanyId'];
     $sender->LoginName = $conf['LoginName'];
     $sender->Password = $conf['Password'];
     $sender->MockMode = false;
     return $sender->send($receiveMobileTel, $content);
 }
Exemple #3
0
 public function init()
 {
     parent::init();
     //identityclass在controller里面显示的指定
     \Yii::$container->set('yii\\web\\User', ['identityClass' => 'mysoft\\user\\MicroIdentity']);
     \Yii::$app->user->identityClass = 'mysoft\\user\\MicroIdentity';
     //针对autologin的场景
     $this->from = I('__from');
     if (empty($this->from)) {
         $this->from = cookie('__from@' . $this->orgcode);
     } else {
         cookie('__from@' . $this->orgcode, $this->from);
     }
     \mysoft\pubservice\PageVisitService::start($this->orgcode);
     if (IS_UPGRADING == true) {
         $demo_tenants = \mysoft\pubservice\Conf::getConfig('demo_tenants');
         $demo_tenants = json_decode($demo_tenants, true);
         if (empty($demo_tenants)) {
             $demo_tenants = [];
         }
         if (!in_array($this->orgcode, $demo_tenants)) {
             $this->redirect('/systemupgrade/index.html');
             \Yii::$app->end();
         }
     }
 }
Exemple #4
0
 public function __construct($config = [])
 {
     $this->email_cfg = \mysoft\pubservice\Conf::getConfig('site_email');
     $this->email_cfg = json_decode($this->email_cfg, true);
     $config = array_merge($this->email_cfg, $config);
     parent::__construct($config);
 }
Exemple #5
0
 private function _getHost()
 {
     $hostinfo = Conf::getConfig('http_server');
     if (empty($hostinfo)) {
         throw new \Exception("请核查http-server配置!");
     }
     return $hostinfo;
 }
Exemple #6
0
 /**
  * 初始化配置
  */
 protected function _init()
 {
     //读系统配置 from conf
     $conf_hosts = \mysoft\pubservice\Conf::getConfig('elastic_hosts');
     $this->params['hosts'] = explode(',', $conf_hosts);
     if ($this->hosts && is_array($this->hosts)) {
         //如果有外部设置则直接替代,便于local调试
         $this->params['hosts'] = $this->hosts;
     }
     $this->client = new Client($this->params);
 }
Exemple #7
0
 public function __construct($orgcode = '')
 {
     $conf = Conf::getConfig('sms_verify_code');
     $conf = json_decode($conf, true);
     $this->_sender = new HttpSmsSender(new \mysoft\http\Curl());
     $this->_sender->SendUrl = 'http://sms3.mobset.com/SDK/Sms_Send.asp';
     $this->_sender->CompanyId = $conf['CompanyId'];
     $this->_sender->LoginName = $conf['LoginName'];
     $this->_sender->Password = $conf['Password'];
     $this->_sender->MockMode = false;
     $this->_tenant_id = $orgcode;
 }
Exemple #8
0
 public function __construct()
 {
     $setting = \mysoft\pubservice\Conf::getConfig('push_xm');
     $setting = json_decode($setting, true);
     if (is_array($setting) && isset($setting['secret']) && isset($setting['package'])) {
         \xmpush\Constants::setPackage($setting['package']);
         \xmpush\Constants::setSecret($setting['secret']);
         \xmpush\Constants::useOfficial();
     } else {
         throw new \Exception('push_xm配置有误');
     }
     $this->sender = new \xmpush\Sender();
 }
Exemple #9
0
 protected function getAuthAccountId()
 {
     $appId = I('appId');
     $entCode = I('entCode');
     $sign = I('sign');
     if (!empty($appId) && !empty($entCode) && !empty($sign)) {
         $curl = $this->curl ? $this->curl : new \mysoft\http\Curl();
         $wzs2_site = $this->wzs2_site ? $this->wzs2_site : \mysoft\pubservice\Conf::getConfig('wzs2_api_site');
         $ret = $curl->get($wzs2_site . '/api/Enterprise/GetAppKey', ['entcode' => $entCode, 'appId' => $appId]);
         if (empty($ret)) {
             throw new AuthException('wzs2 get_app_key接口无法访问');
         } else {
             $ret = json_decode($ret, true);
         }
         //get_app_key返回为{'data':'xxx'}
         if (!isset($ret['data']) || empty($ret['data'])) {
             throw new AuthException('wzs2 get_app_key返回值为空');
         } else {
             $key = $ret['data'];
         }
         $userinfo = \mysoft\helpers\AesHelper::decrypt($sign, $key);
         $userinfo = json_decode($userinfo, true);
         if (empty($userinfo) || !isset($userinfo['userCode'])) {
             throw new AuthException('sign无法解密出usercode');
         } else {
             if (!isset($userinfo['timeStamp']) || time() * 1000 - $userinfo['timeStamp'] > 24 * 60 * 60) {
                 throw new AuthException('时间戳已经过期');
             } else {
                 $usercode = $userinfo['userCode'];
             }
         }
         if (empty($user_code)) {
             $user_code = cookie('user_code@' . $this->orgcode);
         } else {
             cookie('user_code@' . $this->orgcode, $user_code, time() + 30 * 24 * 60 * 60);
         }
         return $usercode;
     } else {
         throw new AuthException('wzs2 验证方式缺乏必要的appId,entCode,sign参数');
     }
 }
Exemple #10
0
 /**
  * 获取账号信息,页面会跳转,要求之前不能有header输出。
  * 会使用configsetting::auth2_site字段以定位认证页面地址
  * @param string $tenantId
  * @param string $corpId
  * @return Ambigous <string, unknown, \yii\web\array, \yii\web\mixed>
  */
 public static function getAccount($tenantId, $corpId)
 {
     //首先从session中取授权页面传过来的userwxid,存在则设置一下cookie
     $userid = \Yii::$app->session->get('__userwxid@' . $tenantId);
     if (!empty($userid)) {
         cookie('__userwxid@' . $tenantId, $userid, time() + 30 * 24 * 60 * 60);
         return $userid;
     } else {
         //其次从cookie中取
         $userid = cookie('__userwxid@' . $tenantId);
         if (!empty($userid)) {
             return $userid;
         } else {
             //最后做跳转
             $redirect = \Yii::$app->request->getHostInfo() . \Yii::$app->params['static_host'] . \Yii::$app->request->getUrl();
             $redirect_uri = Conf::getConfig('api_site') . '/api/qy-auth2/after-auth?params=' . urlencode(base64_encode(json_encode(['corp_id' => $corpId, 'tenant_id' => $tenantId, 'redirect' => $redirect])));
             $url = str_replace('STATE', uniqid(), str_replace('REDIRECT_URI', urlencode($redirect_uri), str_replace('CORPID', $corpId, self::AUTHORIZE)));
             \Yii::$app->response->redirect($url)->send();
         }
     }
 }
Exemple #11
0
 /**
  * 初始化参数 
  * @example 
  *  new \mysoft\upload\Oss('sales');
  * @param array|string $config
  */
 public function init()
 {
     parent::init();
     $oss = Conf::fromCache('oss');
     $oss = json_decode($oss, true);
     if (!is_array($oss)) {
         throw new \yii\base\InvalidConfigException('oss配置异常');
     }
     $this->bucket = isset($oss['oss_bucket']) ? $oss['oss_bucket'] : '';
     $this->domain = isset($oss['oss_access_uri']) ? $oss['oss_access_uri'] : '';
     //拼接文件返回地址的 http host部分
     $hostname = isset($oss['oss_host']) ? $oss['oss_host'] : '';
     //定义操作的指定节点hostname
     $OSS_ACCESS_ID = isset($oss['oss_access_key_id']) ? $oss['oss_access_key_id'] : '';
     //接入的ID
     $OSS_ACCESS_KEY = isset($oss['oss_access_key_secret']) ? $oss['oss_access_key_secret'] : '';
     //接入的密钥
     if ($this->rootDirName) {
         $this->root = $this->rootDirName;
     }
     $this->oss = new \ALIOSS($OSS_ACCESS_ID, $OSS_ACCESS_KEY, $hostname);
 }
Exemple #12
0
 /**
  * 获取task_db连接的单例对象
  * @return \yii\db\Connection
  */
 public function task_db($auto_open = true)
 {
     static $db;
     //单例task_db对象
     if (empty($db)) {
         $conf = \mysoft\pubservice\Conf::getConfig('task_db_config');
         if (empty($conf)) {
             throw new \Exception("task_db config not in configsettings");
         }
         $conf = json_decode($conf, true);
         $dbname = 'task';
         //默认数据库名
         if (isset($conf['dbname']) && $conf['dbname']) {
             //便于调试如果配置里填写过dbname的话这里直接替换
             $dbname = trim($conf['dbname']);
         }
         $conn_arr = ['dsn' => 'mysql:host=' . $conf["host"] . ';port=' . $conf['port'] . ';dbname=' . $dbname, 'username' => $conf["user_name"], 'password' => $conf["password"]];
         $db = new \yii\db\Connection($conn_arr);
         if ($auto_open) {
             $db->open();
         }
     }
     return $db;
 }
Exemple #13
0
 /**
  * 获取微助手openid
  * @param $cropId 企业ID
  * @param $cropId 微助手设备ID
  * @author 骆兵
  */
 public static function getAccount($tenantId, $cropId)
 {
     $url = Conf::getConfig('api_site') . '/api/qy-auth2/get-wzs-openid' . '?' . http_build_query(['tenant_id' => $tenantId, 'corp_id' => $cropId]);
     $curl = new \mysoft\http\Curl();
     return $curl->get($url . "&rand=" . rand(1, 99999));
 }
Exemple #14
0
 public function __construct()
 {
     $setting = Conf::getConfig('push_apns');
     $setting = json_decode($setting, true);
     $this->init($setting['base_path']);
 }
Exemple #15
0
 public function __construct()
 {
     $setting = Conf::getConfig('push_jpush');
     $setting = json_decode($setting, true);
     $this->init($setting['app_key'], $setting['master_secret']);
 }
Exemple #16
0
/**
 * 
 * @param string $action index/feedback
 * @return string
 */
function feedbackurl($action = 'index')
{
    $orgcode = I("__orgcode");
    $from = I("__from", cookie('__from@' . $orgcode));
    $app_code = \Yii::$app->params['app_code'];
    if ($app_code == '0000') {
        $app_code = '';
    }
    if (empty($orgcode)) {
        return \mysoft\pubservice\Conf::getConfig('api_site') . "/feedback/feedback/{$action}?__from={$from}&app_code={$app_code}";
    } else {
        return \mysoft\pubservice\Conf::getConfig('api_site') . "/{$orgcode}/feedback/feedback/{$action}?__from={$from}&app_code={$app_code}";
    }
}