/** * Adds client id and signature to the User object array * * @return array */ protected function signJsConnect() { $queryArray = array_merge($this->user->toArray(), $this->properties); ksort($queryArray); $queryString = http_build_query($queryArray, null, '&'); $signature = md5($queryString . $this->config->getSecret()); $queryArray['client_id'] = $this->config->getClientID(); $queryArray['signature'] = $signature; return $queryArray; }
private function __construct() { $this->_config = Config::getSecret('mail'); $this->_smtp = new Smtp(); $server = $this->_config['server']; $this->_smtp->setServer($server['smtp'], $server['port'], $server['secure']); }
protected function init() { if (Input::post('key', $apikey, 'string') && $apikey == Config::getSecret('api', 'card')) { parent::init(); } else { $this->response(-3, 'API key无效'); exit; } }
/** * 发送短信 * @method send * @param [type] $phone [手机] * @param [type] $msg [内容参数] * @param [type] $tplName [模板名] * @author NewFuture */ private static function send($phone, $msg, $tplName) { if (null == self::$_handler) { $config = Config::getSecret('sms'); self::$_handler = new Service\Ucpaas($config['account'], $config['appid'], $config['token']); self::$_template = $config['template']; } return self::$_handler->send($phone, $msg, self::$_template[$tplName]); }
/** * 添加打印任务 * @param [type] $key [description] * @return [type] [description] */ public static function addTask($uri) { list($bucket, $key) = explode(':', $uri, 2); $saveas = Config::getSecret('qiniu', 'task') . ':' . $bucket . '/' . $key; $ext = strrchr($uri, '.'); if (in_array($ext, ['.doc', '.docx', '.odt', '.rtf', '.wps', '.ppt', '.pptx', '.odp', '.dps', '.xls', '.xlsx', '.ods', '.csv', '.et'])) { /*office系列 转pdf*/ $saveas .= '.pdf'; return Qiniu::has($saveas) || Qiniu::toPdf($bucket, $key, $saveas) ? $saveas : false; } else { /*其他文件直接复制*/ return Qiniu::has($saveas) || Qiniu::copy($uri, $saveas) ? $saveas : false; } }
/** * 获取url签名 * @method sign * @param [type] $url [description] * @return [type] [description] * @author NewFuture */ private static function sign($url) { $config = self::$_config ?: (self::$_config = \Config::getSecret('qiniu')); $sign = hash_hmac('sha1', $url, $config['secretkey'], true); $ak = $config['accesskey']; return $ak . ':' . self::qiniuEncode($sign); }
/** * 删除上传token,放弃上传 * DELETE /file/token/tmp_ae1233 * @method POST_token * @param name 文件名 */ public function DELETE_tokenAction($key = null) { if ($key && ($name = Cache::get($key))) { list(, $userid) = explode('_', $key, 3); $userid = $this->auth($userid); Cache::del($key); $bucket = Config::getSecret('qiniu', 'file'); File::del($bucket . ':' . $key); $this->response(1, '已经成功删除' . $name); } else { $this->response(0, '此上传信息不存在'); } }