|
|
@@ -1,178 +1,180 @@
|
|
|
<?php
|
|
|
$GLOBALS['plugins'][]['ngxc'] = array(
|
|
|
- 'name'=>'NGXConfigurator',
|
|
|
- 'author'=>'Vertig0ne',
|
|
|
- 'category'=>'Web Server',
|
|
|
- 'link'=>'https://github.com/vertig0ne/organizr-ngxc',
|
|
|
- 'idPrefix'=>'ngxc',
|
|
|
- 'configPrefix'=>'ngxc',
|
|
|
- 'version'=>'0.2.0',
|
|
|
- 'image'=>'plugins/images/ngxc.png',
|
|
|
- 'settings'=>true,
|
|
|
- 'homepage'=>false,
|
|
|
- 'license'=>'personal,business'
|
|
|
+ 'name' => 'NGXConfigurator',
|
|
|
+ 'author' => 'Vertig0ne',
|
|
|
+ 'category' => 'Web Server',
|
|
|
+ 'link' => 'https://github.com/vertig0ne/organizr-ngxc',
|
|
|
+ 'idPrefix' => 'ngxc',
|
|
|
+ 'configPrefix' => 'ngxc',
|
|
|
+ 'version' => '0.2.0',
|
|
|
+ 'image' => 'plugins/images/ngxc.png',
|
|
|
+ 'settings' => true,
|
|
|
+ 'homepage' => false,
|
|
|
+ 'license' => 'personal,business'
|
|
|
);
|
|
|
-
|
|
|
###############
|
|
|
## INTERNAL FUNCTIONS
|
|
|
###############
|
|
|
-
|
|
|
-function _ngxcTypeOptions() {
|
|
|
- $_ngxcTypes = array(
|
|
|
- 'none' => 'None',
|
|
|
- 'airsonic' => 'AirSonic',
|
|
|
- 'calibre-web' => 'Calibre-Web',
|
|
|
- 'calibre-webBlur' => 'Calibre-Web (Blur Theme)',
|
|
|
- 'deluge' => 'Deluge',
|
|
|
- 'guacamole' => 'Guacamole',
|
|
|
- 'jackett' => 'Jackett',
|
|
|
- 'lazylibrarian' => 'LazyLibrarian',
|
|
|
- 'lidarr' => 'Lidarr',
|
|
|
- 'mylar' => 'Mylar',
|
|
|
- 'netdata' => 'NetData',
|
|
|
- 'nowshowing' => 'NowShowing',
|
|
|
- 'nzbget' => 'NZBGet',
|
|
|
- 'nzbgetDark' => 'NZBGet (Dark Theme)',
|
|
|
- 'nzbhydra' => 'NZBHydra',
|
|
|
- 'ombi' => 'Ombi',
|
|
|
- 'plex' => 'Plex',
|
|
|
- 'qbittorrent' => 'qbittorrent',
|
|
|
- 'radarr' => 'Radarr',
|
|
|
- 'radarrDarker' => 'Radarr (Darkerr Theme)',
|
|
|
- 'rutorrent' => 'rUtorrent',
|
|
|
- 'sonarr' => 'Sonarr',
|
|
|
- 'sonarrDarker' => 'Sonarr (Darkerr Theme)',
|
|
|
- 'tautulli' => 'Tautulli',
|
|
|
- 'ubooquity' => 'Ubooquity',
|
|
|
- 'youtube-dl' => 'YouTube-DL Server'
|
|
|
- );
|
|
|
- $data = array();
|
|
|
- $t = 0;
|
|
|
- foreach ($_ngxcTypes as $key => $value) {
|
|
|
- $data[$t] = array(
|
|
|
- "name" => $value,
|
|
|
- "value" => $key
|
|
|
- );
|
|
|
- $t++;
|
|
|
- }
|
|
|
- return $data;
|
|
|
+function _ngxcTypeOptions()
|
|
|
+{
|
|
|
+ $_ngxcTypes = array(
|
|
|
+ 'none' => 'None',
|
|
|
+ 'airsonic' => 'AirSonic',
|
|
|
+ 'calibre-web' => 'Calibre-Web',
|
|
|
+ 'calibre-webBlur' => 'Calibre-Web (Blur Theme)',
|
|
|
+ 'deluge' => 'Deluge',
|
|
|
+ 'guacamole' => 'Guacamole',
|
|
|
+ 'jackett' => 'Jackett',
|
|
|
+ 'lazylibrarian' => 'LazyLibrarian',
|
|
|
+ 'lidarr' => 'Lidarr',
|
|
|
+ 'mylar' => 'Mylar',
|
|
|
+ 'netdata' => 'NetData',
|
|
|
+ 'nowshowing' => 'NowShowing',
|
|
|
+ 'nzbget' => 'NZBGet',
|
|
|
+ 'nzbgetDark' => 'NZBGet (Dark Theme)',
|
|
|
+ 'nzbhydra' => 'NZBHydra',
|
|
|
+ 'ombi' => 'Ombi',
|
|
|
+ 'plex' => 'Plex',
|
|
|
+ 'qbittorrent' => 'qbittorrent',
|
|
|
+ 'radarr' => 'Radarr',
|
|
|
+ 'radarrDarker' => 'Radarr (Darkerr Theme)',
|
|
|
+ 'rutorrent' => 'rUtorrent',
|
|
|
+ 'sonarr' => 'Sonarr',
|
|
|
+ 'sonarrDarker' => 'Sonarr (Darkerr Theme)',
|
|
|
+ 'tautulli' => 'Tautulli',
|
|
|
+ 'ubooquity' => 'Ubooquity',
|
|
|
+ 'youtube-dl' => 'YouTube-DL Server'
|
|
|
+ );
|
|
|
+ $data = array();
|
|
|
+ $t = 0;
|
|
|
+ foreach ($_ngxcTypes as $key => $value) {
|
|
|
+ $data[$t] = array(
|
|
|
+ "name" => $value,
|
|
|
+ "value" => $key
|
|
|
+ );
|
|
|
+ $t++;
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
}
|
|
|
|
|
|
-function _ngxcGetAllTabs() {
|
|
|
+function _ngxcGetAllTabs()
|
|
|
+{
|
|
|
return allTabs();
|
|
|
}
|
|
|
|
|
|
-function _ngxcGetTabs() {
|
|
|
+function _ngxcGetTabs()
|
|
|
+{
|
|
|
$tabs = _ngxcGetAllTabs();
|
|
|
- $types = _ngxcTypeOptions();
|
|
|
+ $types = _ngxcTypeOptions();
|
|
|
$data = array();
|
|
|
- foreach ($tabs["tabs"] as $tab) {
|
|
|
- if ($tab['name'] != "Homepage" && $tab['name'] != "Settings") {
|
|
|
- $name = strtoupper(str_replace(' ','_',$tab['name']));
|
|
|
- $data[$tab['name']] = array(
|
|
|
- array(
|
|
|
- 'type' => 'select',
|
|
|
- 'name' => 'NGXC_'.$name.'_TYPE',
|
|
|
- 'label' => 'Type of Proxy',
|
|
|
- 'value' => $GLOBALS['NGXC_'.$name.'_TYPE'] ?: 'None',
|
|
|
- 'options' => $types
|
|
|
- ),
|
|
|
- array(
|
|
|
- 'type' => 'input',
|
|
|
- 'name' => 'NGXC_'.$name.'_URL',
|
|
|
- 'label' => 'Proxy URL',
|
|
|
- 'value' => $GLOBALS['NGXC_'.$name.'_URL'] ?: '',
|
|
|
- )
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
+ foreach ($tabs["tabs"] as $tab) {
|
|
|
+ if ($tab['name'] != "Homepage" && $tab['name'] != "Settings") {
|
|
|
+ $name = strtoupper(str_replace(' ', '_', $tab['name']));
|
|
|
+ $data[$tab['name']] = array(
|
|
|
+ array(
|
|
|
+ 'type' => 'select',
|
|
|
+ 'name' => 'NGXC_' . $name . '_TYPE',
|
|
|
+ 'label' => 'Type of Proxy',
|
|
|
+ 'value' => isset($GLOBALS['NGXC_' . $name . '_TYPE']) ? $GLOBALS['NGXC_' . $name . '_TYPE'] : 'None',
|
|
|
+ 'options' => $types
|
|
|
+ ),
|
|
|
+ array(
|
|
|
+ 'type' => 'input',
|
|
|
+ 'name' => 'NGXC_' . $name . '_URL',
|
|
|
+ 'label' => 'Proxy URL',
|
|
|
+ 'value' => isset($GLOBALS['NGXC_' . $name . '_URL']) ? $GLOBALS['NGXC_' . $name . '_URL'] : '',
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabConfig($tab) {
|
|
|
- $name = strtoupper(str_replace(' ','_',$tab["name"]));
|
|
|
- $nameLower = strtolower(str_replace(' ','_',$tab["name"]));
|
|
|
- $type = $GLOBALS['NGXC_'.$name.'_TYPE'];
|
|
|
- $path = $tab["url"];
|
|
|
- $url = $GLOBALS['NGXC_'.$name.'_URL'];
|
|
|
- switch($type) {
|
|
|
- case "sonarr":
|
|
|
- case "radarr":
|
|
|
- case "lidarr":
|
|
|
- return _ngxcWriteTabSonarrConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "sonarrDarker":
|
|
|
- case "radarrDarker":
|
|
|
- return _ngxcWriteTabSonarrConfig($url, $path, $nameLower, $tab["group_id"], true);
|
|
|
- break;
|
|
|
- case "airsonic":
|
|
|
- return _ngxcWriteTabAirSonicConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "calibre-web":
|
|
|
- return _ngxcWriteTabCalibreWebConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "calibre-webBlur":
|
|
|
- return _ngxcWriteTabCalibreWebConfig($url, $path, $nameLower, $tab["group_id"], true);
|
|
|
- break;
|
|
|
- case "deluge":
|
|
|
- return _ngxcWriteTabDelugeConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "guacamole":
|
|
|
- return _ngxcWriteTabGuacamoleConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "jackett":
|
|
|
- return _ngxcWriteTabJackettConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "mylar":
|
|
|
- case "lazylibrarian":
|
|
|
- return _ngxcWriteTabMylarConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "netdata":
|
|
|
- return _ngxcWriteTabNetdataConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "nowshowing":
|
|
|
- return _ngxcWriteTabNowshowingConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "nzbget":
|
|
|
- return _ngxcWriteTabNzbGetConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "nzbgetDark":
|
|
|
- return _ngxcWriteTabNzbGetConfig($url, $path, $nameLower, $tab["group_id"], true);
|
|
|
- break;
|
|
|
- case "nzbhydra":
|
|
|
- _ngxcWriteTabNzbHydraConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "ombi":
|
|
|
- return _ngxcWriteTabOmbiConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "plex":
|
|
|
- return _ngxcWriteTabPlexConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "qbittorrent":
|
|
|
- return _ngxcWriteTabQbittorrentConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "tautulli":
|
|
|
- return _ngxcWriteTabTautulliConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "transmission":
|
|
|
- return _ngxcWriteTabTransmissionConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "ubooquity":
|
|
|
- return _ngxcWriteTabUbooquityConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- case "rutorrent":
|
|
|
- return _ngxcWriteTabRutorrentConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
- break;
|
|
|
- }
|
|
|
+function _ngxcWriteTabConfig($tab)
|
|
|
+{
|
|
|
+ $name = strtoupper(str_replace(' ', '_', $tab["name"]));
|
|
|
+ $nameLower = strtolower(str_replace(' ', '_', $tab["name"]));
|
|
|
+ $type = $GLOBALS['NGXC_' . $name . '_TYPE'];
|
|
|
+ $path = $tab["url"];
|
|
|
+ $url = $GLOBALS['NGXC_' . $name . '_URL'];
|
|
|
+ switch ($type) {
|
|
|
+ case "sonarr":
|
|
|
+ case "radarr":
|
|
|
+ case "lidarr":
|
|
|
+ return _ngxcWriteTabSonarrConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "sonarrDarker":
|
|
|
+ case "radarrDarker":
|
|
|
+ return _ngxcWriteTabSonarrConfig($url, $path, $nameLower, $tab["group_id"], true);
|
|
|
+ break;
|
|
|
+ case "airsonic":
|
|
|
+ return _ngxcWriteTabAirSonicConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "calibre-web":
|
|
|
+ return _ngxcWriteTabCalibreWebConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "calibre-webBlur":
|
|
|
+ return _ngxcWriteTabCalibreWebConfig($url, $path, $nameLower, $tab["group_id"], true);
|
|
|
+ break;
|
|
|
+ case "deluge":
|
|
|
+ return _ngxcWriteTabDelugeConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "guacamole":
|
|
|
+ return _ngxcWriteTabGuacamoleConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "jackett":
|
|
|
+ return _ngxcWriteTabJackettConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "mylar":
|
|
|
+ case "lazylibrarian":
|
|
|
+ return _ngxcWriteTabMylarConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "netdata":
|
|
|
+ return _ngxcWriteTabNetdataConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "nowshowing":
|
|
|
+ return _ngxcWriteTabNowshowingConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "nzbget":
|
|
|
+ return _ngxcWriteTabNzbGetConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "nzbgetDark":
|
|
|
+ return _ngxcWriteTabNzbGetConfig($url, $path, $nameLower, $tab["group_id"], true);
|
|
|
+ break;
|
|
|
+ case "nzbhydra":
|
|
|
+ _ngxcWriteTabNzbHydraConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "ombi":
|
|
|
+ return _ngxcWriteTabOmbiConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "plex":
|
|
|
+ return _ngxcWriteTabPlexConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "qbittorrent":
|
|
|
+ return _ngxcWriteTabQbittorrentConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "tautulli":
|
|
|
+ return _ngxcWriteTabTautulliConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "transmission":
|
|
|
+ return _ngxcWriteTabTransmissionConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "ubooquity":
|
|
|
+ return _ngxcWriteTabUbooquityConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ case "rutorrent":
|
|
|
+ return _ngxcWriteTabRutorrentConfig($url, $path, $nameLower, $tab["group_id"]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
###############
|
|
|
## CONFIGURATION WRITERS
|
|
|
###############
|
|
|
-
|
|
|
-function _ngxcWriteTabSonarrConfig($url, $path, $name, $group, $theme = false) {
|
|
|
- $data =
|
|
|
-"location $path {
|
|
|
+function _ngxcWriteTabSonarrConfig($url, $path, $name, $group, $theme = false)
|
|
|
+{
|
|
|
+ $data =
|
|
|
+ "location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
|
@@ -180,26 +182,25 @@ function _ngxcWriteTabSonarrConfig($url, $path, $name, $group, $theme = false) {
|
|
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
|
|
proxy_http_version 1.1;
|
|
|
proxy_no_cache \$cookie_session;";
|
|
|
-
|
|
|
- if ($theme) {
|
|
|
- $data .=
|
|
|
- "proxy_set_header Accept-Encoding \"\";
|
|
|
+ if ($theme) {
|
|
|
+ $data .=
|
|
|
+ "proxy_set_header Accept-Encoding \"\";
|
|
|
sub_filter '</head>' '<link rel=\"stylesheet\" type=\"text/css\" href=\"https://rawgit.com/iFelix18/Darkerr/master/darkerr.css\"></head>';
|
|
|
sub_filter_once on;\n";
|
|
|
- }
|
|
|
- $data .=
|
|
|
- "location ".$path."api {
|
|
|
+ }
|
|
|
+ $data .=
|
|
|
+ "location " . $path . "api {
|
|
|
auth_request off;
|
|
|
proxy_pass $url/api;
|
|
|
}
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabAirSonicConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabAirSonicConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
|
@@ -211,13 +212,13 @@ function _ngxcWriteTabAirSonicConfig($url, $path, $name, $group) {
|
|
|
proxy_pass $url/;
|
|
|
proxy_redirect http:// https://;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabCalibreWebConfig($url, $path, $name, $group, $theme = false) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabCalibreWebConfig($url, $path, $name, $group, $theme = false)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
|
|
|
location $path {
|
|
|
proxy_bind \$server_addr;
|
|
|
@@ -227,8 +228,8 @@ function _ngxcWriteTabCalibreWebConfig($url, $path, $name, $group, $theme = fals
|
|
|
proxy_set_header X-Scheme \$scheme;
|
|
|
proxy_set_header X-Script-Name $path;
|
|
|
";
|
|
|
- if ($theme) {
|
|
|
- $data .="
|
|
|
+ if ($theme) {
|
|
|
+ $data .= "
|
|
|
set \$filter_output '<link rel=\"stylesheet\" type=\"text/css\" href=\"https://rawgit.com/leram84/layer.Cake/dev/CSS/caliBlur-Demo.css\"></head>';
|
|
|
|
|
|
if (\$http_user_agent ~* '(iPhone|iPod|android|blackberry)') {
|
|
|
@@ -241,15 +242,15 @@ function _ngxcWriteTabCalibreWebConfig($url, $path, $name, $group, $theme = fals
|
|
|
proxy_set_header Accept-Encoding \"\";
|
|
|
sub_filter '</head>' \$filter_output;
|
|
|
sub_filter_once on;\n";
|
|
|
- }
|
|
|
- $data .= "}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ }
|
|
|
+ $data .= "}";
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabDelugeConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabDelugeConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -266,13 +267,13 @@ function _ngxcWriteTabDelugeConfig($url, $path, $name, $group) {
|
|
|
proxy_buffers 32 4k;
|
|
|
add_header X-Frame-Options SAMEORIGIN;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabGuacamoleConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabGuacamoleConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -285,13 +286,13 @@ function _ngxcWriteTabGuacamoleConfig($url, $path, $name, $group) {
|
|
|
proxy_http_version 1.1;
|
|
|
proxy_no_cache \$cookie_session;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabJackettConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabJackettConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -306,13 +307,13 @@ function _ngxcWriteTabJackettConfig($url, $path, $name, $group) {
|
|
|
proxy_no_cache \$cookie_session;
|
|
|
proxy_buffers 32 4k;
|
|
|
}";
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
+}
|
|
|
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
- }
|
|
|
-
|
|
|
-function _ngxcWriteTabMylarConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabMylarConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -321,13 +322,13 @@ function _ngxcWriteTabMylarConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabNetdataConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabNetdataConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_redirect off;
|
|
|
@@ -341,13 +342,13 @@ function _ngxcWriteTabNetdataConfig($url, $path, $name, $group) {
|
|
|
proxy_store off;
|
|
|
proxy_pass $url/;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabNowshowingConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabNowshowingConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_set_header Host \$host;
|
|
|
@@ -359,13 +360,13 @@ function _ngxcWriteTabNowshowingConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header Connection \"keep-alive\";
|
|
|
proxy_pass $url/;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabNzbGetConfig($url, $path, $name, $group, $theme = false) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabNzbGetConfig($url, $path, $name, $group, $theme = false)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -377,21 +378,21 @@ function _ngxcWriteTabNzbGetConfig($url, $path, $name, $group, $theme = false) {
|
|
|
proxy_set_header Accept-Encoding \"\";
|
|
|
proxy_set_header Host \$host;
|
|
|
";
|
|
|
- if ($theme) {
|
|
|
- $data .= "
|
|
|
+ if ($theme) {
|
|
|
+ $data .= "
|
|
|
sub_filter '</head>' '<link rel=\"stylesheet\" type=\"text/css\" href=\"https://rawgit.com/ydkmlt84/DarkerNZBget/develop/nzbget_custom_darkblue.css\"></head>';
|
|
|
sub_filter_once on;
|
|
|
";
|
|
|
- }
|
|
|
- $data .= "
|
|
|
+ }
|
|
|
+ $data .= "
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabNzbHydraConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabNzbHydraConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -401,13 +402,13 @@ function _ngxcWriteTabNzbHydraConfig($url, $path, $name, $group) {
|
|
|
proxy_http_version 1.1;
|
|
|
proxy_no_cache \$cookie_session;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabOmbiConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabOmbiConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -426,13 +427,13 @@ function _ngxcWriteTabOmbiConfig($url, $path, $name, $group) {
|
|
|
location /dist/ {
|
|
|
return 301 $path\$request_uri;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabPlexConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabPlexConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
return 301 /web;
|
|
|
}
|
|
|
@@ -449,13 +450,13 @@ function _ngxcWriteTabPlexConfig($url, $path, $name, $group) {
|
|
|
proxy_read_timeout 36000s;
|
|
|
proxy_pass_request_headers on;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabQbittorrentConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabQbittorrentConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location ~ $path(?<url>.*) {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $path\$url;
|
|
|
@@ -466,13 +467,13 @@ function _ngxcWriteTabQbittorrentConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header Origin '';
|
|
|
add_header X-Frame-Options \"SAMEORIGIN\";
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabRutorrentConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabRutorrentConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -482,13 +483,13 @@ function _ngxcWriteTabRutorrentConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
|
proxy_redirect off;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabTautulliConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabTautulliConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -498,18 +499,18 @@ function _ngxcWriteTabTautulliConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header X-Forwarded-Proto \$scheme;
|
|
|
proxy_http_version 1.1;
|
|
|
proxy_no_cache \$cookie_session;
|
|
|
- location ".$path."api/ {
|
|
|
+ location " . $path . "api/ {
|
|
|
auth_request off;
|
|
|
proxy_pass $url/api/;
|
|
|
}
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabTransmissionConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabTransmissionConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
|
@@ -520,26 +521,26 @@ function _ngxcWriteTabTransmissionConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header Connection \"\";
|
|
|
proxy_pass_header X-Transmission-Session-Id;
|
|
|
add_header Front-End-Https on;
|
|
|
- location ".$path."rpc {
|
|
|
+ location " . $path . "rpc {
|
|
|
proxy_pass $url/rpc;
|
|
|
}
|
|
|
- location ".$path."web {
|
|
|
+ location " . $path . "web {
|
|
|
proxy_pass $url/web;
|
|
|
}
|
|
|
- location ".$path."upload {
|
|
|
+ location " . $path . "upload {
|
|
|
proxy_pass $url/upload;
|
|
|
}
|
|
|
location /transmission {
|
|
|
- return 301 https://\$server_name".$path."web;
|
|
|
+ return 301 https://\$server_name" . $path . "web;
|
|
|
}
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
-function _ngxcWriteTabUbooquityConfig($url, $path, $name, $group) {
|
|
|
- $data = "
|
|
|
+function _ngxcWriteTabUbooquityConfig($url, $path, $name, $group)
|
|
|
+{
|
|
|
+ $data = "
|
|
|
location $path {
|
|
|
auth_request /auth-$group;
|
|
|
proxy_pass $url/;
|
|
|
@@ -547,59 +548,60 @@ function _ngxcWriteTabUbooquityConfig($url, $path, $name, $group) {
|
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
|
}";
|
|
|
-
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/proxy'.'/'.$name.'.conf', $data) !== false);
|
|
|
- return $result;
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/proxy' . '/' . $name . '.conf', $data) !== false);
|
|
|
+ return $result;
|
|
|
}
|
|
|
|
|
|
###############
|
|
|
## PUBLIC FUNCTIONS
|
|
|
###############
|
|
|
-
|
|
|
-function NGXCGetSettings() {
|
|
|
- $data = array(
|
|
|
- "Core" => array(
|
|
|
- array(
|
|
|
- 'type' => 'input',
|
|
|
- 'name' => 'NGXC_SAVE_PATH',
|
|
|
- 'label' => 'Configuration Save Path',
|
|
|
- 'value' => $GLOBALS['NGXC_SAVE_PATH'] ?: $GLOBALS['dbLocation']
|
|
|
- )
|
|
|
- )
|
|
|
- );
|
|
|
- $data = array_merge($data, _ngxcGetTabs());
|
|
|
- $data['Actions'] = array(
|
|
|
+function NGXCGetSettings()
|
|
|
+{
|
|
|
+ $data = array(
|
|
|
+ "Core" => array(
|
|
|
+ array(
|
|
|
+ 'type' => 'input',
|
|
|
+ 'name' => 'NGXC_SAVE_PATH',
|
|
|
+ 'label' => 'Configuration Save Path',
|
|
|
+ 'value' => $GLOBALS['NGXC_SAVE_PATH'] ?: $GLOBALS['dbLocation']
|
|
|
+ )
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $data = array_merge($data, _ngxcGetTabs());
|
|
|
+ $data['Actions'] = array(
|
|
|
array(
|
|
|
'type' => 'button',
|
|
|
- 'label' => 'Write Config',
|
|
|
- 'class' => 'ngxc-write-config',
|
|
|
- 'icon' => 'fa fa-save',
|
|
|
- 'text' => 'Write Config'
|
|
|
- )
|
|
|
- );
|
|
|
+ 'label' => 'Write Config',
|
|
|
+ 'class' => 'ngxc-write-config',
|
|
|
+ 'icon' => 'fa fa-save',
|
|
|
+ 'text' => 'Write Config'
|
|
|
+ )
|
|
|
+ );
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
-function NGXCWriteConfig() {
|
|
|
- if (!is_writable($GLOBALS['NGXC_SAVE_PATH'])) { return false; }
|
|
|
-
|
|
|
- if (!file_exists($GLOBALS['NGXC_SAVE_PATH'].'/proxy')) {
|
|
|
- mkdir($GLOBALS['NGXC_SAVE_PATH'].'/proxy', 0777, true);
|
|
|
- }
|
|
|
- $tabs = _ngxcGetAllTabs();
|
|
|
- $return = true;
|
|
|
- foreach ($tabs["tabs"] as $tab) {
|
|
|
- $res = _ngxcWriteTabConfig($tab);
|
|
|
- if ($res === false) $return = false;
|
|
|
- }
|
|
|
- $file_contents = "location ~ /auth-(.*) {
|
|
|
+function NGXCWriteConfig()
|
|
|
+{
|
|
|
+ if (!is_writable($GLOBALS['NGXC_SAVE_PATH'])) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (!file_exists($GLOBALS['NGXC_SAVE_PATH'] . '/proxy')) {
|
|
|
+ mkdir($GLOBALS['NGXC_SAVE_PATH'] . '/proxy', 0777, true);
|
|
|
+ }
|
|
|
+ $tabs = _ngxcGetAllTabs();
|
|
|
+ $return = true;
|
|
|
+ foreach ($tabs["tabs"] as $tab) {
|
|
|
+ $res = _ngxcWriteTabConfig($tab);
|
|
|
+ if ($res === false) $return = false;
|
|
|
+ }
|
|
|
+ $file_contents = "location ~ /auth-(.*) {
|
|
|
internal;
|
|
|
rewrite ^/auth-(.*) /api/?v1/auth&group=$1;
|
|
|
}\n";
|
|
|
- $file_contents .= "include ".$GLOBALS['NGXC_SAVE_PATH']."/proxy/*.conf;\n";
|
|
|
- if ($return) {
|
|
|
- $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'].'/ngxc.conf', $file_contents) !== false);
|
|
|
- return (bool)$result;
|
|
|
- }
|
|
|
- return $return;
|
|
|
-}
|
|
|
+ $file_contents .= "include " . $GLOBALS['NGXC_SAVE_PATH'] . "/proxy/*.conf;\n";
|
|
|
+ if ($return) {
|
|
|
+ $result = (file_put_contents($GLOBALS['NGXC_SAVE_PATH'] . '/ngxc.conf', $file_contents) !== false);
|
|
|
+ return (bool)$result;
|
|
|
+ }
|
|
|
+ return $return;
|
|
|
+}
|