-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
process.php
86 lines (78 loc) · 2.51 KB
/
process.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
use ProjectSend\Classes\Session as Session;
use ProjectSend\Classes\Download;
use ProjectSend\Classes\ActionsLog;
/** Process an action */
$allowed_levels = array(9, 8, 7, 0);
require_once 'bootstrap.php';
log_in_required($allowed_levels);
global $auth;
global $logger;
extend_session();
if (!isset($_GET['do'])) {
exit_with_error_code(403);
}
switch ($_GET['do']) {
case 'social_login':
if (Session::has('SOCIAL_LOGIN_NETWORK')) {
Session::remove('SOCIAL_LOGIN_NETWORK');
}
Session::add('SOCIAL_LOGIN_NETWORK', $_GET['provider']);
$login = $auth->socialLogin($_GET['provider']);
break;
case 'login_ldap':
/*
$login = $auth->loginLdap($_POST['ldap_email'], $_POST['ldap_password']);
$auth->setLanguage($_POST['language']);
echo $login;
break;
*/
exit;
case 'logout':
force_logout();
break;
case 'change_language':
$auth->setLanguage(html_output($_GET['language']));
$location = 'index.php';
if (!empty($_GET['return_to']) && strpos($_GET['return_to'], BASE_URI) === 0) {
$location = str_replace(BASE_URI, '', $_GET['return_to']);
}
ps_redirect(BASE_URI . $location);
break;
case 'get_preview':
$return = [];
if (!empty($_GET['file_id'])) {
if (!user_can_download_file(CURRENT_USER_ID, $_GET['file_id'])) {
exit_with_error_code(403);
}
$file = new \ProjectSend\Classes\Files($_GET['file_id']);
if ($file->existsOnDisk() && $file->embeddable) {
$return = json_decode($file->getEmbedData());
}
}
echo json_encode($return);
exit;
break;
case 'download':
$download = new Download;
$download->download($_GET['id']);
break;
case 'dismiss_upgraded_notice':
redirect_if_not_logged_in();
redirect_if_role_not_allowed([9,8,7]);
save_option('show_upgrade_success_message', 'false');
ps_redirect(BASE_URI.'dashboard.php');
case 'return_files_ids':
redirect_if_not_logged_in();
redirect_if_role_not_allowed($allowed_levels);
$download = new Download;
$download->returnFilesIds($_GET['files']);
break;
case 'download_zip':
redirect_if_not_logged_in();
redirect_if_role_not_allowed($allowed_levels);
$download = new Download;
$download->downloadZip($_GET['files']);
break;
}
exit;