-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.php
More file actions
62 lines (59 loc) · 1.87 KB
/
index.php
File metadata and controls
62 lines (59 loc) · 1.87 KB
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
<?php
define('IOS_ADHOC_OTA', true);
define('IS_PHP_CLI', PHP_SAPI == 'cli');
require_once('etc/config.php');
require_once('lib/adhocotalib.php');
if ( IS_PHP_CLI ) {
error_reporting(E_ALL);
ini_set('display_errors', true);
$username = $argv[1];
$password = $argv[2];
} else {
// E_NONE is not a predefined constant
error_reporting(E_ALL);
ini_set('display_errors', false);
webui_session_start();
$username = $_POST['usr'];
$password = $_POST['pwd'];
}
if ( $_SERVER['QUERY_STRING'] == 'logout' ) {
webui_logout();
}
if ( webui_loggedin() ) {
$username = webui_loggedin();
$apps = adhocota_find_apps($username);
webui_forward('apps', compact('apps', 'username'));
} else {
if ( empty($username) || empty($password) ) {
if ( IS_PHP_CLI ) {
cliui_exit('Missing username and password!');
} else {
webui_logout();
if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
$error_message = 'You must specify both a username and a password to log in';
}
webui_forward('login', compact('error_message'));
}
} else {
$access = false;
$accountPasswordFile = "$IOSADHOC_BASE_DIR/$username/__password.php";
if ( file_exists($accountPasswordFile) ) {
require($accountPasswordFile);
if ( $password === $accountPassword ) {
$access = true;
}
}
if ( $access ) {
webui_login($username);
webui_forward('standin');
} else {
if ( IS_PHP_CLI ) {
cliui_exit('Wrong username and/or password!');
} else {
webui_logout();
$error_message = 'Your access credentials are incorrect. Try again!';
webui_forward('login', compact('error_message'));
}
}
}
}