4 Star 11 Fork 0

故梦/typecho_Oauth

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
console.php 5.44 KB
一键复制 编辑 原始数据 按行查看 历史
故梦 提交于 2021-11-08 16:25 . 新增登陆方式 修改已知BUG
<?php
define('__PLUGIN_ROOT__', __DIR__);
include_once 'common.php';
include 'header.php';
include 'menu.php';
?>
<style>
svg{
margin-bottom: -5px;
}
</style>
<div style="text-align:center;">
<?php
$db = Typecho_Db::get();
Typecho_Widget::widget('Widget_User')->to($user);
$iconfile = __PLUGIN_ROOT__."/icon.json";
$icon = @fopen($iconfile, "r") or die("登陆按钮图标文件丢失!");
$site = json_decode(fread($icon,filesize($iconfile)),true);
fclose($icon);
$plugin = Typecho_Widget::widget('Widget_Options')->plugin('GmOauth');
$arr = [];
for ($i = 0; $i < count($site); $i++) {
$c = $site[$i]['site'];
if($plugin->$c){
$arr[] = $site[$i];
}
}
if($_GET['del']){
$a = $_GET['del'];
if($plugin->$a){
if($db->query($db->delete('table.gm_oauth')->where('uid = ?',$user->uid)->where('app = ?',$_GET['del']))){
exit('<script>alert("解绑成功");window.location.href="'.$options->adminUrl.'extending.php?panel=GmOauth/console.php";</script>');
}else{
exit('<script>window.location.href="'.$options->adminUrl.'extending.php?panel=GmOauth/console.php";</script>');
}
}else{
throw new Typecho_Exception(_t('未开通此第三方登陆'));
}
}
if($_GET['add']){
$a = $_GET['add'];
if($plugin->$a){
exit(header('location:https://sso.gmit.vip/'.$_GET['add'].'/redirect?redirect_url='.Typecho_Common::url('GmOauth/Bind', Helper::options()->index)));
}else{
throw new Typecho_Exception(_t('未开通此第三方登陆'));
}
}
$data = [];
for ($i = 0; $i < count($arr); $i++) {
if($res = $db->fetchAll($db->select('app','uid','openid','time')->from('table.gm_oauth')->where('app = ?',$arr[$i]['site'])->where('uid = ?',$user->uid))){
$data[$arr[$i]['site']] = $res;
}else{
$data[$arr[$i]['site']] = 0;
}
}
?>
</div>
<div class="main">
<div class="body container">
<div class="typecho-page-title">
<h2>第三方登录设置</h2>
</div>
<div class="container typecho-page-main">
<div class="col-mb-12 typecho-list">
<div class="typecho-table-wrap">
<table class="typecho-list-table">
<colgroup>
<col width="20%">
<col width="20%">
<col width="20%">
<col width="30%">
<col width="20%">
</colgroup>
<thead>
<tr>
<th>#</th>
<th>站点</th>
<th>状态</th>
<th>绑定时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php
for ($i = 0; $i < count($arr); $i++) {
?>
<tr>
<td><?php echo $arr[$i]['ico']?></td>
<td><?php echo $arr[$i]['name']?>账号</td>
<td>
<?php
if($data[$arr[$i]['site']]){
?>
<font style="color:green">已绑定</font>
<?php
}else{
?>
未绑定
<?php
}
?>
</td>
<td>
<?php
if($data[$arr[$i]['site']]){
echo date('Y-m-d',$data[$arr[$i]['site']][0]['time']);
}else{
?>
<?php
}
?>
</td>
<td style="font-weight:bold">
<?php
if($data[$arr[$i]['site']]){
echo '<a href="'.$options->adminUrl.'extending.php?panel=GmOauth/console.php&del='.$arr[$i]['site'].'" style="color:#FF0000;">解绑</a>';
}else{
echo '<a href="'.$options->adminUrl.'extending.php?panel=GmOauth/console.php&add='.$arr[$i]['site'].'">绑定</a>';
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
include 'copyright.php';
include 'common-js.php';
include 'table-js.php';
?>
<?php
include 'footer.php';
?>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/isgm/typecho_Oauth.git
git@gitee.com:isgm/typecho_Oauth.git
isgm
typecho_Oauth
typecho_Oauth
main

搜索帮助