Browse Source

temp update plugin repo

CauseFX 4 years ago
parent
commit
73672a5d68

+ 0 - 38
ngxc/api/plugins/api/ngxc.php

@@ -1,38 +0,0 @@
-<?php
-if(isset($_POST['data']['plugin'])){
-    switch ($_POST['data']['plugin']) {
-        case 'ngxc/settings/get':
-            if(qualifyRequest(1)){
-                $result['status'] = 'success';
-                $result['statusText'] = 'success';
-                $result['data'] = NGXCGetSettings();
-            }else{
-                $result['status'] = 'error';
-                $result['statusText'] = 'API/Token invalid or not set';
-                $result['data'] = null;
-            }
-            break;
-        case 'ngxc/settings/save':
-            if(qualifyRequest(1)){
-                $save = NGXCWriteConfig();
-                if ($save == true) {
-                    $result['status'] = 'success';
-                    $result['statusText'] = 'success';
-                    $result['data'] = true;
-                }
-                else { 
-                    $result['status'] = 'error';
-                    $result['statusText'] = 'There was an error with saving the configuration';
-                    $result['data'] = null;
-                }
-            }else{
-                $result['status'] = 'error';
-                $result['statusText'] = 'API/Token invalid or not set';
-                $result['data'] = null;
-            }
-            break;
-        default:
-            //DO NOTHING!!
-            break;
-    }
-}

+ 0 - 9
ngxc/api/plugins/config/ngxc.php

@@ -1,9 +0,0 @@
-<?php
-return array(
-	'ngxc-enabled' => false,
-	'NGXC_SAVE_PATH' => '',
-	'NGXC_SETTINGS_TYPE' => '',
-	'NGXC_SETTINGS_URL' => '',
-	'NGXC_HOMEPAGE_TYPE' => '',
-	'NGXC_HOMEPAGE_URL' => ''
-);

+ 0 - 31
ngxc/api/plugins/js/ngxc.js

@@ -1,31 +0,0 @@
-$(document).on('click', '#ngxc-settings-button', function() {
-    var post = {
-        plugin:'ngxc/settings/get', // used for switch case in your API call
-    };
-    ajaxloader(".content-wrap","in");
-    organizrAPI('POST','api/?v1/plugin',post).success(function(data) {
-        var response = JSON.parse(data);
-        $('#ngxc-settings-items').html(buildFormGroup(response.data));
-    }).fail(function(xhr) {
-        console.error("Organizr Function: API Connection Failed");
-    });
-    ajaxloader();
-});
-
-$(document).on('click', '.ngxc-write-config', function() {
-    var post = {
-        plugin:'ngxc/settings/save', // used for switch case in your API call
-    };
-    ajaxloader(".content-wrap","in");
-    organizrAPI('POST','api/?v1/plugin',post).success(function(data) {
-        var response = JSON.parse(data);
-        if(response.data == true){
-            message('',window.lang.translate('Write Successful'),activeInfo.settings.notifications.position,'#FFF','success','5000');
-        }else{
-            message('',response.statusText,activeInfo.settings.notifications.position,'#FFF','error','5000');
-        }
-    }).fail(function(xhr) {
-        console.error("Organizr Function: API Connection Failed");
-    });
-    ajaxloader();
-});

+ 0 - 609
ngxc/api/plugins/ngxc.php

@@ -1,609 +0,0 @@
-<?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'
-);
-###############
-## 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 _ngxcGetAllTabs()
-{
-	return allTabs();
-}
-
-function _ngxcGetTabs()
-{
-	$tabs = _ngxcGetAllTabs();
-	$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' => 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;
-	}
-}
-
-###############
-## CONFIGURATION WRITERS
-###############
-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; 
-        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-        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 \"\";
-        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 {
-                auth_request off;
-                proxy_pass $url/api;
-        }
-}";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabAirSonicConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_set_header X-Real-IP         \$remote_addr;
-                proxy_set_header X-Forwarded-For   \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-                proxy_set_header X-Forwarded-Host  \$http_host;
-                proxy_set_header Host              \$http_host;
-                proxy_max_temp_file_size           0;
-                proxy_pass                         $url/;
-                proxy_redirect                     http:// https://;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabCalibreWebConfig($url, $path, $name, $group, $theme = false)
-{
-	$data = "
-
-        location $path {
-                proxy_bind \$server_addr;
-                proxy_pass $url;
-                proxy_set_header Host \$http_host;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Scheme \$scheme;
-                proxy_set_header X-Script-Name $path;
-                ";
-	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)') {
-                    set \$filter_output '</head>';
-                }
-                if (\$request_uri ~* '(\/read\/)') {
-                    set \$filter_output '</head>';
-                }
-            
-                proxy_set_header Accept-Encoding \"\";
-                sub_filter '</head>' \$filter_output;
-                sub_filter_once on;\n";
-	}
-	$data .= "}";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabDelugeConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header X-Deluge-Base \"$path\";
-                proxy_set_header Host \$host;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto https;
-                proxy_redirect  http://  \$scheme://;
-                proxy_http_version 1.1;
-                proxy_set_header Connection \"\";
-                proxy_cache_bypass \$cookie_session;
-                proxy_no_cache \$cookie_session;
-                proxy_buffers 32 4k;
-                add_header X-Frame-Options SAMEORIGIN;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabGuacamoleConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_buffering off;
-                proxy_set_header Upgrade \$http_upgrade;
-                proxy_set_header Connection \$http_connection;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-                proxy_http_version 1.1;
-                proxy_no_cache \$cookie_session;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabJackettConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header Host \$host;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto https;
-                proxy_redirect  http://  \$scheme://;
-                proxy_http_version 1.1;
-                proxy_set_header Connection \"\";
-                proxy_cache_bypass \$cookie_session;
-                proxy_no_cache \$cookie_session;
-                proxy_buffers 32 4k;
-              }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabMylarConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header Host \$host;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabNetdataConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_redirect off;
-                proxy_set_header Host \$host;
-                proxy_set_header X-Forwarded-Host \$host;
-                proxy_set_header X-Forwarded-Server \$host;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_http_version 1.1;
-                proxy_pass_request_headers on;
-                proxy_set_header Connection \"keep-alive\";
-                proxy_store off;
-                proxy_pass $url/;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabNowshowingConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_set_header Host \$host;
-                proxy_set_header X-Forwarded-Host \$host;
-                proxy_set_header X-Forwarded-Server \$host;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_http_version 1.1;
-                proxy_pass_request_headers on;
-                proxy_set_header Connection \"keep-alive\";
-                proxy_pass $url/;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabNzbGetConfig($url, $path, $name, $group, $theme = false)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-                proxy_http_version 1.1;
-                proxy_no_cache \$cookie_session;
-                proxy_set_header Accept-Encoding \"\";
-                proxy_set_header Host \$host;
-        ";
-	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 .= "
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabNzbHydraConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-                proxy_http_version 1.1;
-                proxy_no_cache \$cookie_session;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabOmbiConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass  $url/;
-                proxy_cache_bypass \$http_upgrade;
-                proxy_set_header Connection keep-alive;
-                proxy_set_header Upgrade \$http_upgrade;
-                proxy_set_header X-Forwarded-Host \$server_name;
-                proxy_set_header X-Forwarded-Ssl on;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-                proxy_http_version 1.1;
-                proxy_no_cache \$cookie_session;
-                proxy_set_header Host \$host;
-        }
-        location /dist/ {
-                return 301 $path\$request_uri;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabPlexConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                return 301 /web;
-        }
-        location ~ ^/(\?(?:.*)(X-Plex-Device=)|web|video|photo|library|web|status|system|updater|clients|:|playQueues)(.*) {
-                proxy_pass $url;
-                proxy_redirect  $url /;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_redirect off;
-                proxy_set_header Host \$host;
-                proxy_http_version 1.1;
-                proxy_set_header Upgrade \$http_upgrade;
-                proxy_set_header Connection \"upgrade\";
-                proxy_read_timeout 36000s;
-                proxy_pass_request_headers on;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabQbittorrentConfig($url, $path, $name, $group)
-{
-	$data = "
-        location ~ $path(?<url>.*) {
-                auth_request /auth-$group;
-                proxy_pass  $path\$url;
-                proxy_set_header X-Forwarded-Host \$host;
-                proxy_hide_header Referer;
-                proxy_hide_header Origin;
-                proxy_set_header Referer '';
-                proxy_set_header Origin '';
-                add_header X-Frame-Options \"SAMEORIGIN\";
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabRutorrentConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header Host \$server_name;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-Host \$server_name;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_redirect off;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabTautulliConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header X-Forwarded-Host \$server_name;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header X-Forwarded-Proto \$scheme;
-                proxy_http_version 1.1;
-                proxy_no_cache \$cookie_session;
-                location " . $path . "api/ {
-                        auth_request off;
-                        proxy_pass $url/api/;
-                }
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabTransmissionConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-                proxy_set_header Host \$http_host;
-                proxy_set_header X-NginX-Proxy true;
-                proxy_http_version 1.1;
-                proxy_set_header Connection \"\";
-                proxy_pass_header X-Transmission-Session-Id;
-                add_header Front-End-Https   on;
-                location " . $path . "rpc {
-                  proxy_pass $url/rpc;
-                }
-                location " . $path . "web {
-                  proxy_pass $url/web;
-                }
-                location " . $path . "upload {
-                  proxy_pass $url/upload;
-                }
-                location /transmission {
-                  return 301 https://\$server_name" . $path . "web;
-                }
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $name . '.conf', $data) !== false);
-	return $result;
-}
-
-function _ngxcWriteTabUbooquityConfig($url, $path, $name, $group)
-{
-	$data = "
-        location $path {
-                auth_request /auth-$group;
-                proxy_pass $url/;
-                proxy_set_header Host \$host;
-                proxy_set_header X-Real-IP \$remote_addr;
-                proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
-        }";
-	$result = (file_put_contents(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy') . DIRECTORY_SEPARATOR . $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(
-		array(
-			'type' => 'button',
-			'label' => 'Write Config',
-			'class' => 'ngxc-write-config',
-			'icon' => 'fa fa-save',
-			'text' => 'Write Config'
-		)
-	);
-	return $data;
-}
-
-function NGXCWriteConfig()
-{
-	$prepath = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH']);
-	$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $GLOBALS['NGXC_SAVE_PATH'] . DIRECTORY_SEPARATOR . 'proxy');
-	if (@!mkdir($path, 0777, true)) {
-		//writeLog("error", "organizr could not create folder");
-	}
-	if (!is_writable($path)) {
-		return false;
-	}
-	$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 " . $path . DIRECTORY_SEPARATOR . "*.conf;\n";
-	if ($return) {
-		$result = (file_put_contents($prepath . '/ngxc.conf', $file_contents) !== false);
-		return (bool)$result;
-	}
-	return $return;
-}

BIN
ngxc/plugins/images/ngxc.png


+ 1 - 27
plugins.json

@@ -11,35 +11,9 @@
     "last_updated": "2018-07-12",
     "github_folder": "test",
     "license": "personal,business",
-    "files": {
-      "/": "test.pdf",
-      "/plugins/images/test": "test.png",
-      "/api/plugins/api/test": "index.php"
-    },
     "images": {
       "Main": "https://www.bloggingalways.com/wp-content/uploads/2017/11/Test-Logo.svg.png",
       "Alternative": "https://lakeridgenewsonline.com/wp-content/uploads/2018/03/Testing.jpg"
     }
-  },
-  "Nginx Configurator": {
-    "author": "vertig0ne",
-    "category": "Utilities",
-    "description": "\r\nSo some notes to be prepared for.\r\n\r\nOrganizr v2 introduces groups for permissions, so you can have minimum permissions levels on services and be able to adjust users accordingly. This allows for levels of Something is wronguration of nginx. So if you were to change the permissions level on a tab inside Organizr, this plugin would make it so nginx is the same.\r\n\r\nNginx reload each time the Something is wronguration file is saved may be necessary. Will be looking into options for that in the future.\r\n\r\n\r\n<pre>\r\nlocation ~ \/auth-(.*) {\r\n internal;\r\n rewrite ^\/auth-(.*) \/api\/?v1\/auth&group=$1;\r\n}\r\n<\/pre>\r\n\r\n\r\nThis is how the nginx authentication works. In the same way as Organizr v1 worked with a few minor changes. Only one authentication block is necessary now. As we can call this via auth_request \/auth-0. The number is the group_id for the group with the lowest permission allowed to access.\r\n\r\n",
-    "icon": "https://raw.githubusercontent.com/causefx/Organizr/v2-plugins/ngxc/plugins/images/ngxc.png",
-    "contact": null,
-    "website": "https://github.com/vertig0ne/organizr-ngxc/issues",
-    "version": "1.0.1",
-    "release_date": "2018-07-12",
-    "last_updated": "2018-07-17",
-    "github_folder": "ngxc",
-    "license": "personal,business",
-    "files": {
-      "/plugins/images": "ngxc.png",
-	  "/api/plugins": "ngxc.php",
-      "/api/plugins/api": "ngxc.php",
-	  "/api/plugins/config": "ngxc.php",
-	  "/api/plugins/js": "ngxc.js"
-    },
-    "images": {}
   }
-}
+}

+ 13 - 0
test/api.php

@@ -0,0 +1,13 @@
+<?php
+$app->get('/plugins/test/settings', function ($request, $response, $args) {
+	$TestPlugin = new TestPlugin();
+	if ($TestPlugin->checkRoute($request)) {
+		if ($TestPlugin->qualifyRequest(1, true)) {
+			$GLOBALS['api']['response']['data'] = $TestPlugin->_pluginGetSettings();
+		}
+	}
+	$response->getBody()->write(jsonE($GLOBALS['api']));
+	return $response
+		->withHeader('Content-Type', 'application/json;charset=UTF-8')
+		->withStatus($GLOBALS['responseCode']);
+});

+ 0 - 1
test/api/plugins/api/test/index.php

@@ -1 +0,0 @@
-/* TEST */

+ 11 - 0
test/config.php

@@ -0,0 +1,11 @@
+<?php
+/*
+ * Always include PLUGINNAME-enabled
+ * Along with all your other settings from plugin.php
+ */
+return array(
+	'TEST-enabled' => false,
+	'TEST-pass-alt' => '',
+	'TEST-pass' => '',
+	'TEST-text' => ''
+);

BIN
test/logo.png


+ 11 - 0
test/main.js

@@ -0,0 +1,11 @@
+/* TEST PLUGIN JS FILE */
+/* This file is loaded when Organizr is loaded */
+// Load once Organizr loads
+$('body').arrive('#activeInfo', {onceOnly: true}, function() {
+	testPluginLaunch();
+});
+// FUNCTIONS
+function testPluginLaunch(){
+
+}
+// EVENTS and LISTENERS

+ 54 - 0
test/plugin.php

@@ -0,0 +1,54 @@
+<?php
+// PLUGIN INFORMATION
+$GLOBALS['plugins'][]['Test'] = array( // Plugin Name
+	'name' => 'Test', // Plugin Name
+	'author' => 'CauseFX', // Who wrote the plugin
+	'category' => 'Testing', // One to Two Word Description
+	'link' => '', // Link to plugin info
+	'license' => 'personal', // License Type use , for multiple
+	'idPrefix' => 'TEST', // html element id prefix (All Uppercase)
+	'configPrefix' => 'TEST', // config file prefix for array items without the hypen (All Uppercase)
+	'version' => '1.0.0', // SemVer of plugin
+	'image' => 'api/plugins/test/logo.png', // 1:1 non transparent image for plugin
+	'settings' => true, // does plugin need a settings modal?
+	'bind' => true, // use default bind to make settings page - true or false
+	'api' => 'api/v2/plugins/test/settings', // api route for settings page (All Lowercase)
+	'homepage' => false // Is plugin for use on homepage? true or false
+);
+
+class TestPlugin extends Organizr
+{
+	public function _pluginGetSettings()
+	{
+		return array(
+			'Sample Settings' => array(
+				array(
+					'type' => 'password-alt',
+					'name' => 'TEST-pass-alt',
+					'label' => 'Test Plugin Pass Alt',
+					'value' => $this->config['TEST-pass-alt'],
+				),
+				array(
+					'type' => 'password',
+					'name' => 'TEST-pass',
+					'label' => 'Test Plugin Password',
+					'value' => $this->config['TEST-pass'],
+				),
+				array(
+					'type' => 'text',
+					'name' => 'TEST-text',
+					'label' => 'Test Plugin Text',
+					'value' => $this->config['TEST-text'],
+					'placeholder' => 'All'
+				),
+			),
+			'FYI' => array(
+				array(
+					'type' => 'html',
+					'label' => 'Note',
+					'html' => 'just a note...'
+				)
+			)
+		);
+	}
+}

+ 20 - 0
test/settings.js

@@ -0,0 +1,20 @@
+/* TEST PLUGIN SETTINGS JS FILE */
+/* This file is only loaded on the Organizr settings page */
+
+// FUNCTIONS
+
+// EVENTS and LISTENERS
+
+// If you setup the plugin not use the bind settings function ('bind' => false) - You can override the js settings pane if you wish like this:
+// REPLACE PLUGINNAME and pluginname with the actual name
+$(document).on('click', '#PLUGINNAME-settings-button', function() {
+	ajaxloader(".content-wrap","in");
+	organizrAPI2('GET','api/v2/plugins/pluginname/settings').success(function(data) {
+		let response = data.response;
+		$('#PLUGINNAME-settings-items').html(buildFormGroup(response.data));
+		// And any other items you want to do things with
+	}).fail(function(xhr) {
+		OrganizrApiError(xhr);
+	});
+	ajaxloader();
+});

+ 0 - 0
test/plugins/images/test/test.png → test/test.png