Skip to content

Commit

Permalink
Merge pull request #716 from causefx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
causefx authored Nov 3, 2017
2 parents 3b3b3a7 + 8b1a822 commit f13725a
Show file tree
Hide file tree
Showing 101 changed files with 9,738 additions and 478 deletions.
30 changes: 25 additions & 5 deletions api.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
// Include functions
require_once('user.php');
$USER = new User('registration_callback');
$USER = new User();
// Get Action
if (isset($_POST['a'])) { $action = $_POST['a']; }
if (isset($_POST['k'])) { $key = $_POST['k']; }
if (isset($_POST['v'])) { $values = $_POST['v']; }
if (isset($_GET['a'])) { $action = $_GET['a']; }
if (isset($_GET['k'])) { $key = $_GET['k']; }
if (isset($_GET['v'])) { $values = explode('|',$_GET['v']); }
if (isset($_GET['v'])) {
$values = (strpos($_GET['v'], '|') !== false ? explode('|',$_GET['v']) : $_GET['v']);
}
unset($_POST['a']);
unset($_POST['k']);
unset($_POST['v']);
Expand All @@ -35,15 +37,33 @@
$email = $values[1];
$server = $values[2];
}
//$USER = new User();
$USER->invite_user("chris", "[email protected]", "plex");
$result['data'] = "User has been invited";
//$result['data'] = "user = $user | email = $email | server = $server";
}else{
$result['error'] = "No Values Were Set For Function";
}
break;
case "2":
$result = "other test";
case "ombi":
if($values){
switch ($values) {
case 'plex-update':
$ombi = ombiAPI('plex-cache');
if($ombi){
$result['data'] = "Plex Content Cache Successful";
}else{
$result['error'] = "Plex Content Cache Error";
}
break;
default:
$result['error'] = "$values is not a valid Ombi function";
break;
}
}else{
$result['error'] = "No Ombi Action Supplied";
}

break;
default:
$result = "$action Not Defined As API Function";
Expand All @@ -57,4 +77,4 @@
}
//return JSON array
exit(json_encode($result));
?>
?>
8 changes: 7 additions & 1 deletion auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$USER = new User("registration_callback");
$ban = isset($_GET['ban']) ? strtoupper($_GET['ban']) : "";
$whitelist = isset($_GET['whitelist']) ? $_GET['whitelist'] : false;
$blacklist = isset($_GET['blacklist']) ? $_GET['blacklist'] : false;
$currentIP = get_client_ip();

if ($whitelist) {
Expand All @@ -14,6 +15,11 @@
$skipped = true;
}
}
if ($blacklist) {
if(in_array($currentIP, getWhitelist($blacklist))) {
!$debug ? exit(http_response_code(401)) : die("$currentIP Blacklisted");
}
}
if (isset($_GET['admin'])) {
if($USER->authenticated && $USER->role == "admin" && !in_array(strtoupper($USER->username), getBannedUsers($ban))) {
!$debug ? exit(http_response_code(200)) : die("$USER->username on $currentIP Authorized At Admin Level");
Expand All @@ -36,4 +42,4 @@
!$debug ? exit(http_response_code(401)) : die("$USER->username on $currentIP Not Authorized Nor On Whitelist");
}

?>
?>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"phpmailer/phpmailer": "^5.2",
"guzzlehttp/guzzle": "^6.2",
"php-http/guzzle6-adapter": "^1.1",
"sparkpost/sparkpost": "^2.1"
"sparkpost/sparkpost": "^2.1",
"lcobucci/jwt": "^3.2"
}
}
60 changes: 59 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions config/configDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@
"smtpHostType" => "tls",
"homepageNoticeTitle" => "",
"homepageNoticeMessage" => "",
"homepageNoticeTitleGuest" => "",
"homepageNoticeMessageGuest" => "",
"homepageNoticeType" => "success",
"homepageNoticeTypeGuest" => "success",
"homepageNoticeAuth" => "false",
"homepageNoticeLayout" => "elegant",
"homepageNoticeLayoutGuest" => "elegant",
"ipInfoToken" => "ddd0c072ad5021",
"historyRefresh" => "120000",
"downloadRefresh" => "30000",
Expand Down Expand Up @@ -132,5 +136,6 @@
"homepageOrderembyrecent" => '11',
"homepageOrderombi" => '12',
"homepageOrdercalendar" => '13',
"homepageOrdernoticeguest" => '14',
'requestedUserOnly' => 'true',
);
20 changes: 10 additions & 10 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@
//error stuff
$requested = $_SERVER['REQUEST_URI'];
$codes = array(
400 => array('Bad Request', 'The server cannot or will not process the request due to an apparent client error.', 'sowwy'),
401 => array('Unauthorized', 'You do not have access to this page.', 'sowwy'),
403 => array('Forbidden', 'The server has refused to fulfill your request.', 'sowwy'),
404 => array('Not Found', $requested . ' was not found on this server.', 'confused'),
405 => array('Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.', 'confused'),
408 => array('Request Timeout', 'Your browser failed to send a request in the time allowed by the server.', 'sowwy'),
500 => array('Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.', 'confused'),
502 => array('Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.', 'confused'),
503 => array('Service Unavailable', 'The server is currently unavailable (because it is overloaded or down for maintenance).', 'confused'),
504 => array('Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.', 'confused'),
400 => array('Bad Request', 'The server cannot or will not process the request due to an apparent client error.', 'sowwy','400'),
401 => array('Unauthorized', 'You do not have access to this page.', 'sowwy','401'),
403 => array('Forbidden', 'The server has refused to fulfill your request.', 'sowwy','403'),
404 => array('Not Found', $requested . ' was not found on this server.', 'confused','404'),
405 => array('Method Not Allowed', 'The method specified in the Request-Line is not allowed for the specified resource.', 'confused','405'),
408 => array('Request Timeout', 'Your browser failed to send a request in the time allowed by the server.', 'sowwy','408'),
500 => array('Internal Server Error', 'The request was unsuccessful due to an unexpected condition encountered by the server.', 'confused','500'),
502 => array('Bad Gateway', 'The server received an invalid response from the upstream server while trying to fulfill the request.', 'confused','502'),
503 => array('Service Unavailable', 'The server is currently unavailable (because it is overloaded or down for maintenance).', 'confused','503'),
504 => array('Gateway Timeout', 'The upstream server failed to send a request in the time allowed by the server.', 'confused','504'),
999 => array('Not Logged In', 'You need to be logged in to access this page.', 'confused', '401'),
);
$errorTitle = ($codes[$status][0]) ? $codes[$status][0] : "Error";
Expand Down
Loading

0 comments on commit f13725a

Please sign in to comment.