|
|
<?php
|
|
|
/**
|
|
|
+-------------------------------------------------------------------------+
|
|
|
| Roundcube Webmail IMAP Client |
|
|
|
| Version 1.5.3 |
|
|
|
| |
|
|
|
| Copyright (C) The Roundcube Dev Team |
|
|
|
| |
|
|
|
| This program is free software: you can redistribute it and/or modify |
|
|
|
| it under the terms of the GNU General Public License (with exceptions |
|
|
|
| for skins & plugins) as published by the Free Software Foundation, |
|
|
|
| either version 3 of the License, or (at your option) any later version. |
|
|
|
| |
|
|
|
| This file forms part of the Roundcube Webmail Software for which the |
|
|
|
| following exception is added: Plugins and Skins which merely make |
|
|
|
| function calls to the Roundcube Webmail Software, and for that purpose |
|
|
|
| include it by reference shall not be considered modifications of |
|
|
|
| the software. |
|
|
|
| |
|
|
|
| If you wish to use this file in another project or create a modified |
|
|
|
| version that will not be part of the Roundcube Webmail Software, you |
|
|
|
| may remove the exception above and use this source code under the |
|
|
|
| original version of the license. |
|
|
|
| |
|
|
|
| This program is distributed in the hope that it will be useful, |
|
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
| GNU General Public License for more details. |
|
|
|
| |
|
|
|
| You should have received a copy of the GNU General Public License |
|
|
|
| along with this program. If not, see http://www.gnu.org/licenses/. |
|
|
|
| |
|
|
|
+-------------------------------------------------------------------------+
|
|
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
|
|
| Author: Aleksander Machniak <alec@alec.pl> |
|
|
|
+-------------------------------------------------------------------------+
|
|
|
*/
|
|
|
+-------------------------------------------------------------------------+
|
|
|
| Roundcube Webmail IMAP Client |
|
|
|
| Version 1.5.3 |
|
|
|
| |
|
|
|
| Copyright (C) The Roundcube Dev Team |
|
|
|
| |
|
|
|
| This program is free software: you can redistribute it and/or modify |
|
|
|
| it under the terms of the GNU General Public License (with exceptions |
|
|
|
| for skins & plugins) as published by the Free Software Foundation, |
|
|
|
| either version 3 of the License, or (at your option) any later version. |
|
|
|
| |
|
|
|
| This file forms part of the Roundcube Webmail Software for which the |
|
|
|
| following exception is added: Plugins and Skins which merely make |
|
|
|
| function calls to the Roundcube Webmail Software, and for that purpose |
|
|
|
| include it by reference shall not be considered modifications of |
|
|
|
| the software. |
|
|
|
| |
|
|
|
| If you wish to use this file in another project or create a modified |
|
|
|
| version that will not be part of the Roundcube Webmail Software, you |
|
|
|
| may remove the exception above and use this source code under the |
|
|
|
| original version of the license. |
|
|
|
| |
|
|
|
| This program is distributed in the hope that it will be useful, |
|
|
|
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
| GNU General Public License for more details. |
|
|
|
| |
|
|
|
| You should have received a copy of the GNU General Public License |
|
|
|
| along with this program. If not, see http://www.gnu.org/licenses/. |
|
|
|
| |
|
|
|
+-------------------------------------------------------------------------+
|
|
|
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
|
|
| Author: Aleksander Machniak <alec@alec.pl> |
|
|
|
+-------------------------------------------------------------------------+
|
|
|
*/
|
|
|
|
|
|
// include environment
|
|
|
require_once 'program/include/iniset.php';
|
...
|
...
|
@@ -49,6 +49,44 @@ $RCMAIL->output->common_headers(!empty($_SESSION['user_id'])); |
|
|
// turn on output buffering
|
|
|
ob_start();
|
|
|
|
|
|
// 测试链接
|
|
|
//?_platform=login&platform=2022072201&platform_user_id=1&sign=1
|
|
|
// TODO::测试链接
|
|
|
if(rcube_utils::get_input_value('_task', rcube_utils::INPUT_GET) == 'test'){
|
|
|
header("location:/?_platform=login&platform=2022072201&platform_user_id=1&sign=".(rcube_platform::create_token(1,2022072201,'BMeCgIi367f6lJ53dJI6dQ13u2NxLEqJuVaS8xgcXqw1pDdcjYa7MfWB2V6WWYjY')));
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
// 平台登录
|
|
|
if(rcube_utils::get_input_value('_platform', rcube_utils::INPUT_GET) == 'login'){
|
|
|
// 平台用户id
|
|
|
$platform_user_id = rcube_utils::get_input_value('platform_user_id', rcube_utils::INPUT_GET);
|
|
|
$appid = rcube_utils::get_input_value('platform', rcube_utils::INPUT_GET);
|
|
|
$sign = rcube_utils::get_input_value('sign', rcube_utils::INPUT_GET);
|
|
|
// 验证加密签名
|
|
|
if(rcube_platform::check_token($platform_user_id,$appid,$sign)){
|
|
|
setcookie('platform_user_id',$platform_user_id);
|
|
|
setcookie('platform_appid',$appid);
|
|
|
setcookie('platform_id',(new rcube_platform())->getIdByAppId($appid));
|
|
|
//
|
|
|
}else{
|
|
|
setcookie('platform_user_id','0');
|
|
|
setcookie('platform_appid','0');
|
|
|
setcookie('platform_id','0');
|
|
|
}
|
|
|
}
|
|
|
// 是否验证过平台来源,当前访问回话没有验证来源
|
|
|
if(empty($_COOKIE['platform_user_id'])||empty($_COOKIE['platform_appid'])){
|
|
|
rcmail::raise_error(['code' => 403, 'message' => '你没有权限访问'], false, true);
|
|
|
//}else{
|
|
|
// 验证平台是否正常使用
|
|
|
// $platform = (new rcube_platform())->firstByAppId($_SESSION['platform_appid']);
|
|
|
// if($platform['status'] == rcube_platform::STATUS_DISABLED){
|
|
|
// rcmail::raise_error(['code' => 403, 'message' => '你没有权限访问'], false, true);
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
|
|
|
// check if config files had errors
|
|
|
if ($err_str = $RCMAIL->config->get_error()) {
|
|
|
rcmail::raise_error(['code' => 601, 'message' => $err_str], false, true);
|
...
|
...
|
@@ -120,9 +158,23 @@ if ($RCMAIL->task == 'login' && $RCMAIL->action == 'login') { |
|
|
]);
|
|
|
|
|
|
// Login
|
|
|
if ($auth['valid'] && !$auth['abort']
|
|
|
&& $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'], $auth['cookiecheck'])
|
|
|
) {
|
|
|
$is_login = $auth['valid'] && !$auth['abort'] && $RCMAIL->login($auth['user'], $auth['pass'], $auth['host'], $auth['cookiecheck']);
|
|
|
if($is_login){
|
|
|
// 登录成功,创建绑定关系
|
|
|
$platform_user = (new rcube_platform_users())->create($_COOKIE['platform_id'],$RCMAIL->user->ID,$_COOKIE['platform_user_id']);
|
|
|
// 创建成功
|
|
|
if($platform_user){
|
|
|
// platform_user表的自增id
|
|
|
$_SESSION['table_platform_user_pk_id'] = $platform_user['id'];
|
|
|
// 当前选中操作的用户id
|
|
|
$_SESSION['selected_user_id'] = $RCMAIL->user->ID;
|
|
|
}else{
|
|
|
$RCMAIL->kill_session();
|
|
|
$is_login = false;
|
|
|
$auth['error'] = $RCMAIL->output->show_message('loginfailed', 'warning');
|
|
|
}
|
|
|
}
|
|
|
if ($is_login) {
|
|
|
// create new session ID, don't destroy the current session
|
|
|
// it was destroyed already by $RCMAIL->kill_session() above
|
|
|
$RCMAIL->session->remove('temp');
|
...
|
...
|
|