PHPIndex

This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).

controller
i18n
static
app.php
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/oauth/app.php'
View Content
<?php

class oauthPlugin extends PluginBase{
	function __construct(){
		parent::__construct();
	}
	public function regist(){
		$this->hookRegist(array(
			'user.commonJs.insert'			=> 'oauthPlugin.echoJs',
			'user.view.options.after'		=> 'oauthPlugin.updateOption',
			'admin.setting.set.before'		=> 'oauthPlugin.adminSetBefore',

			'user.bind.withApp'				=> 'oauthPlugin.bindHook',	// app登录绑定
			'user.bind.bind.before'			=> 'oauthPlugin.bindHook',
			'user.bind.unbind.before'		=> 'oauthPlugin.bindHook',
			'user.bind.bindmetainfo.before'	=> 'oauthPlugin.bindHook',

			'user.bind.log'					=> 'oauthPlugin.logAdd',
			'admin.log.typelist.after'		=> 'oauthPlugin.logType',
			'admin.log.get.after'			=> 'oauthPlugin.logList',
		));
	}
	public function echoJs(){
		$this->echoFile('static/main.js');
	}

	/**
	 * 第三方登录项重置
	 * @param [type] $options
	 * @return void
	 */
	public function updateOption($options) {
		$regist = Model('SystemOption')->get('regist');
	    if (isset($regist['loginWith'])) {	// 只有定制插件默认安装时后台存在该参数(空),不存在时从插件配置中获取(安装时自动保存默认配置)
	        $loginWith = _get($regist,'loginWith',array());
	    } else {
	        $config = $this->getConfig();
	        $loginWith = explode(',', _get($config, 'loginWith', ''));
	    }
		// $config = $this->getConfig();
		// // 插件配置中该参数是在后台保存时添加,如果不存在,从后台原数据中获取
		// if (!isset($config['loginWith'])) {
		// 	$regist = Model('SystemOption')->get('regist');
		// 	if (!isset($regist['loginWith'])) {
		// 		$loginWith = array('qq', 'weixin');	// 全新安装不含此参数,则赋默认值
		// 	} else {
		// 		$loginWith = _get($regist,'loginWith',array());
		// 	}
		// 	$this->setConfig(array('loginWith' => implode(',', $loginWith)));
		// } else {
		// 	$loginWith = explode(',', _get($config, 'loginWith', ''));
		// }
		$options['system']['options']['loginConfig']['loginWith'] = array_filter($loginWith);
		return $options;
	}

	/**
	 * 后台第三方登录设置
	 * @return void
	 */
	public function adminSetBefore(){
		if(!Action('user.authRole')->authCan('admin.setting.set')){
			show_json(LNG('explorer.noPermissionAction'),false);
		}
		$data = json_decode($this->in['data'], true);
		$loginWith = $data['loginWith'];
		unset($data['loginWith']);
		$this->in['data'] = json_encode($data);
		// 登录项保存至插件配置
		$this->setConfig(array('loginWith' => $loginWith));
	}

	public function action($act = 'bind'){
		return Action($this->pluginName . 'Plugin.'.$act.'.index');
	}
	/**
	 * 绑定相关操作请求
	 * @return void
	 */
	public function bind() {
		$method = Input::get('method', 'require');
		$action = $this->action();
		if (!method_exists($action, $method)) {
			show_json(LNG('common.invalidParam').'[method]', false);
		}
		return $action->$method();
	}
	/**
	 * 兼容app相关调用
	 * @param array $data
	 * @return void
	 */
	public function bindHook($data=array()){
		$act = strtolower(ACT);
		$actions = array(
			'bind' 			=> 'bind',
			'unbind' 		=> 'unbind',
			'bindmetainfo'	=> 'bindInfo',
		);
		if (isset($actions[$act])) {
			$this->in['method'] = $actions[$act];
			return $this->bind();
		}
		// app绑定第三方账号
		if (isset($this->in['third']) && !empty($data)) {
			$this->in['method'] = 'bindWithApp';
			return $this->action()->bindWithApp($data);
		}
		show_json(LNG('common.illegalRequest'), false);
	}
	/**
	 * 认证回调地址
	 * @return void
	 */
	public function callback(){
		$this->display($this->pluginPath.'/static/oauth/index.html');
	}

	// 日志相关
	public function logAdd($action, $data = array()) {
		return $this->action('log')->logAdd($action, $data);
	}
	public function logType($data = array()){
		return $this->action('log')->logType($data);
	}
	public function logList($data = array()){
		return $this->action('log')->logList($data);
	}
}
package.json
wget 'https://sme10.lists2.roe3.org/kodbox/plugins/oauth/package.json'
View Content
{
	"id":"oauth",
	"name":"{{LNG['oauth.meta.name']}}",
	"title":"{{LNG['oauth.meta.title']}}",
	"version":"1.13",
	"category":"tools,others",
	"hidden":1,
	"source":{
		"className":"font-icon ri-shield-user-line bg-blue-6"
	},
	"description":"{{LNG['oauth.meta.desc']}}",
	"auther":{
		"copyright":"kodcloud.",
		"homePage":"http://www.kodcloud.com"
	},
	"meta": {
		"needNetwork": 1
	},
	"networkDesc": "{{LNG['oauth.meta.netwrokDesc']}}",
	"configItem":{
		"pluginAuth":{
			"type":"userSelect",
			"value":{"all":1},
			"display":"{{LNG['admin.plugin.auth']}}",
			"desc":"{{LNG['admin.plugin.authDesc']}}",
			"className":"hidden",
			"require":1
		},
		"desc":{
			"type":"html",
			"value":"{{LNG['oauth.meta.desc']}}",
			"display":"{{LNG['admin.setting.recDesc']}}"
		},
		"sep001":"<hr>",
		"list":{
			"type":"html",
			"value":"",
			"display":"{{LNG['oauth.config.type']}}"
		},
		"loginWith":{
			"type": "input",
			"className": "hidden",
			"value": "qq,weixin"
		}
	}
}