index.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="icon" type="image/png" href="./favicon.png" />
  9. <title>Control Panel | Zoraxy</title>
  10. <link rel="stylesheet" href="script/semantic/semantic.min.css">
  11. <script src="script/jquery-3.6.0.min.js"></script>
  12. <script src="../script/ao_module.js"></script>
  13. <script src="script/semantic/semantic.min.js"></script>
  14. <script src="script/tablesort.js"></script>
  15. <script src="script/countryCode.js"></script>
  16. <script src="script/chart.js"></script>
  17. <script src="script/utils.js"></script>
  18. <link rel="stylesheet" href="main.css">
  19. </head>
  20. <body>
  21. <div class="menubar">
  22. <div class="item">
  23. <img class="logo" src="img/logo.svg">
  24. </div>
  25. <div class="ui right floated buttons menutoggle" style="padding-top: 2px;">
  26. <button class="ui basic icon button" onclick="$('.toolbar').fadeToggle('fast');"><i class="content icon"></i></button>
  27. </div>
  28. <div class="ui right floated buttons" style="padding-top: 2px;">
  29. <button class="ui basic icon button" onclick="logout();"><i class="sign-out icon"></i></button>
  30. </div>
  31. </div>
  32. <div class="wrapper">
  33. <div class="toolbar">
  34. <div id="mainmenu" class="ui secondary vertical menu">
  35. <a class="item active" tag="status">
  36. <i class="simplistic info circle icon"></i>Status
  37. </a>
  38. <a class="item" tag="vdir">
  39. <i class="simplistic folder icon"></i> Virtual Directory
  40. </a>
  41. <a class="item" tag="subd">
  42. <i class="simplistic sitemap icon"></i> Subdomain Proxy
  43. </a>
  44. <a class="item" tag="rules">
  45. <i class="simplistic plus square icon"></i> Create Proxy Rules
  46. </a>
  47. <a class="item" tag="setroot">
  48. <i class="simplistic home icon"></i> Set Proxy Root
  49. </a>
  50. <div class="ui divider menudivider">Access & Connections</div>
  51. <a class="item" tag="cert">
  52. <i class="simplistic lock icon"></i> TLS / SSL certificate
  53. </a>
  54. <a class="item" tag="redirectset">
  55. <i class="simplistic level up alternate icon"></i> Redirection
  56. </a>
  57. <a class="item" tag="access">
  58. <i class="simplistic ban icon"></i> Access Control
  59. </a>
  60. <div class="ui divider menudivider">Bridging</div>
  61. <a class="item" tag="gan">
  62. <i class="simplistic globe icon"></i> Global Area Network
  63. </a>
  64. <a class="item" tag="">
  65. <i class="simplistic podcast icon"></i> Service Expose Proxy
  66. </a>
  67. <a class="item" tag="tcpprox">
  68. <i class="simplistic exchange icon"></i> TCP Proxy
  69. </a>
  70. <div class="ui divider menudivider">Others</div>
  71. <a class="item" tag="webserv">
  72. <i class="simplistic globe icon"></i> Static Web Server
  73. </a>
  74. <a class="item" tag="utm">
  75. <i class="simplistic time icon"></i> Uptime Monitor
  76. </a>
  77. <a class="item" tag="networktool">
  78. <i class="simplistic terminal icon"></i> Network Tools
  79. </a>
  80. <a class="item" tag="stats">
  81. <i class="simplistic database icon"></i> Statistical Analysis
  82. </a>
  83. <a class="item" tag="utils">
  84. <i class="simplistic paperclip icon"></i> Utilities
  85. </a>
  86. <!-- Add more components here -->
  87. </div>
  88. </div>
  89. <div class="contentWindow">
  90. <!-- Status Tab -->
  91. <div id="status" class="functiontab" target="status.html" style="display: block ;">
  92. <br><br><div class="ui active centered inline loader"></div>
  93. </div>
  94. <!-- Virtual Directory Tab -->
  95. <div id="vdir" class="functiontab" target="vdir.html"></div>
  96. <!-- Subdomain Proxy -->
  97. <div id="subd" class="functiontab" target="subd.html"></div>
  98. <!-- Create Rules -->
  99. <div id="rules" class="functiontab" target="rules.html"></div>
  100. <!-- Set proxy root -->
  101. <div id="setroot" class="functiontab" target="rproot.html"></div>
  102. <!-- Set TLS cert -->
  103. <div id="cert" class="functiontab" target="cert.html"></div>
  104. <!-- Redirections -->
  105. <div id="redirectset" class="functiontab" target="redirection.html"></div>
  106. <!-- Blacklist -->
  107. <div id="access" class="functiontab" target="access.html"></div>
  108. <!-- Global Area Networking -->
  109. <div id="gan" class="functiontab" target="gan.html"></div>
  110. <!-- TCP Proxy -->
  111. <div id="tcpprox" class="functiontab" target="tcpprox.html"></div>
  112. <!-- Web Server -->
  113. <div id="webserv" class="functiontab" target="webserv.html"></div>
  114. <!-- Up Time Monitor -->
  115. <div id="utm" class="functiontab" target="uptime.html"></div>
  116. <!-- Network Tools -->
  117. <div id="networktool" class="functiontab" target="networktools.html"></div>
  118. <!-- Statistic Tools -->
  119. <div id="stats" class="functiontab" target="stats.html"></div>
  120. <!-- Utilities -->
  121. <div id="utils" class="functiontab" target="utils.html"></div>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="sideWrapper" style="display:none;">
  126. <div class="fadingBackground" onclick="hideSideWrapper();"></div>
  127. <div class="content">
  128. <div class="sideWrapperMenu"></div>
  129. <iframe src="snippet/placeholder.html"></iframe>
  130. </div>
  131. </div>
  132. <br><br>
  133. <div class="ui divider"></div>
  134. <div class="ui container" style="color: grey; font-size: 90%">
  135. <p>CopyRight Zoraxy project and its author, 2022 - <span class="year"></span></p>
  136. </div>
  137. <div id="messageBox" class="ui green floating big compact message">
  138. <p><i class="green check circle icon"></i> There are no message</p>
  139. </div>
  140. <div id="confirmBox" style="display:none;">
  141. <div class="ui top attached progress">
  142. <div class="bar" style="width: 100%; min-width: 0px;"></div>
  143. </div>
  144. <div class="confirmBoxBody">
  145. <button class="ui red basic mini circular icon right floated button" style="margin-left: 0.4em;"><i class="ui times icon"></i></button>
  146. <button class="ui green basic mini circular icon right floated button"><i class="ui check icon"></i></button>
  147. <div class="questionToConfirm">Confirm Exit?</div>
  148. </div>
  149. </div>
  150. <br><br>
  151. <script>
  152. $(".year").text(new Date().getFullYear());
  153. /*
  154. Loader function
  155. Load all the components view from the
  156. components/ directory into their corrisponding divs
  157. */
  158. let loadingComponents = 0;
  159. function initTabs(callback=undefined){
  160. $('.functiontab').each(function(){
  161. let loadTarget = $(this).attr("target");
  162. if (loadTarget != undefined){
  163. $(this).load("./components/" + loadTarget, function(){
  164. loadingComponents--;
  165. });
  166. loadingComponents++;
  167. }else{
  168. $(this).html(`<p>Unable to load components for this tab</p>`);
  169. }
  170. })
  171. if (callback != undefined){
  172. waitInit(callback);
  173. }
  174. }
  175. function waitInit(callback = undefined, retryCount = 0){
  176. if (loadingComponents > 0 && retryCount < 5){
  177. setTimeout(function(){
  178. waitInit(callback, retryCount++);
  179. }, 300);
  180. }else if (loadingComponents == 0){
  181. callback();
  182. }else{
  183. alert("Missing component. Please check if your installation is complete.")
  184. }
  185. }
  186. initTabs(function(){
  187. initRPStaste();
  188. if (window.location.hash.length > 1){
  189. let tabID = window.location.hash.substr(1);
  190. openTabById(tabID);
  191. }else{
  192. openTabById("status");
  193. }
  194. $(".ui.dropdown").dropdown();
  195. $(".ui.checkbox").checkbox();
  196. //Click on the current tab
  197. $("#mainmenu").find(".item").each(function(){
  198. $(this).on("click", function(event){
  199. let tabid = $(this).attr("tag");
  200. openTabById(tabid);
  201. });
  202. });
  203. //Initialize all table that is sortable
  204. $('table').tablesort();
  205. });
  206. function logout() {
  207. $.get("/api/auth/logout", function(response) {
  208. if (response === "OK") {
  209. setTimeout(function(){
  210. window.location.href = "/";
  211. }, 300);
  212. }
  213. });
  214. }
  215. function getTabButtonById(targetTabId){
  216. let targetTabBtn = undefined;
  217. $("#mainmenu").find(".item").each(function(){
  218. let tabid = $(this).attr("tag");
  219. if (tabid == targetTabId){
  220. targetTabBtn = $(this);
  221. }
  222. });
  223. return targetTabBtn;
  224. }
  225. //Select and open a tab by its tag id
  226. let tabSwitchEventBind = {}; //Bind event to tab switch by tabid
  227. function openTabById(tabID){
  228. let targetBtn = getTabButtonById(tabID);
  229. if (targetBtn == undefined){
  230. alert("Invalid tabid given");
  231. return;
  232. }
  233. if (window.innerWidth < 750){
  234. //RWD mode, hide toolbar
  235. $(".toolbar").fadeOut('fast');
  236. }
  237. $("#mainmenu").find(".item").removeClass("active");
  238. $(targetBtn).addClass("active");
  239. $(".functiontab").hide();
  240. $("#" + tabID).fadeIn('fast', function(){
  241. if (tabSwitchEventBind[tabID]){
  242. tabSwitchEventBind[tabID]();
  243. }
  244. });
  245. $('html,body').animate({scrollTop: 0}, 'fast');
  246. window.location.hash = tabID;
  247. }
  248. $(window).on("resize", function(){
  249. if (window.innerWidth >= 750 && $(".toolbar").is(":visible") == false){
  250. $(".toolbar").show();
  251. }
  252. });
  253. function msgbox(message, succ=true, delayDuration=3000){
  254. let icon = `<i class="ui info circle icon"></i>`;
  255. if (succ){
  256. $("#messageBox").attr("class", "ui green floating compact message")
  257. icon = `<i class="ui green circle check icon"></i>`;
  258. }else{
  259. message = message.capitalize();
  260. $("#messageBox").attr("class", "ui red floating compact message")
  261. icon = `<i class="ui red circle times icon"></i>`;
  262. }
  263. $("#messageBox").html(`${icon} ${message}`);
  264. $("#messageBox").stop().finish().fadeIn("fast").delay(delayDuration).fadeOut("fast");
  265. }
  266. function confirmBox(question_to_confirm, callback, delaytime=15) {
  267. var progressBar = $("#confirmBox .bar");
  268. var questionElement = $("#confirmBox .questionToConfirm");
  269. //Just to make sure there are no animation runnings
  270. progressBar.stop();
  271. // Update the question to confirm
  272. questionElement.text(question_to_confirm);
  273. // Start the progress bar animation
  274. progressBar.css("width", "100%");
  275. progressBar.animate({ width: "0%", easing: "linear" }, delaytime * 1000, function() {
  276. // Animation complete, invoke the callback with undefined
  277. callback(undefined);
  278. //Unset the event listener
  279. $("#confirmBox .ui.green.button").off("click");
  280. // Hide the confirm box
  281. $("#confirmBox").hide();
  282. });
  283. // Bind click event to "Yes" button
  284. $("#confirmBox .ui.green.button").on("click", function() {
  285. // Stop the progress bar animation
  286. progressBar.stop();
  287. // Invoke the callback with true
  288. callback(true);
  289. // Hide the confirm box
  290. $("#confirmBox").hide();
  291. //Unset the event listener
  292. $("#confirmBox .ui.green.button").off("click");
  293. });
  294. // Bind click event to "No" button
  295. $("#confirmBox .ui.red.button").on("click", function() {
  296. // Stop the progress bar animation
  297. progressBar.stop();
  298. // Invoke the callback with false
  299. callback(false);
  300. // Hide the confirm box
  301. $("#confirmBox").hide();
  302. //Unset the event listener
  303. $("#confirmBox .ui.red.button").off("click");
  304. });
  305. // Show the confirm box
  306. $("#confirmBox").show().transition('jiggle');
  307. }
  308. /*
  309. Toggles for side wrapper
  310. */
  311. function showSideWrapper(scriptpath=""){
  312. if (scriptpath != ""){
  313. $(".sideWrapper iframe").attr("src", scriptpath);
  314. }
  315. if ($(".sideWrapper .content").transition("is animating") || $(".sideWrapper .content").transition("is visible")){
  316. return
  317. }
  318. $(".sideWrapper").show();
  319. $(".sideWrapper .fadingBackground").fadeIn("fast");
  320. $(".sideWrapper .content").transition('slide left in', 300);
  321. $("body").css("overflow", "hidden");
  322. }
  323. function hideSideWrapper(discardFrameContent = false){
  324. if (discardFrameContent){
  325. $(".sideWrapper iframe").attr("src", "snippet/placeholder.html");
  326. }
  327. if ($(".sideWrapper .content").transition("is animating") || !$(".sideWrapper .content").transition("is visible")){
  328. return
  329. }
  330. $(".sideWrapper .content").transition('slide left out', 300, function(){
  331. $(".sideWrapper .fadingBackground").fadeOut("fast", function(){
  332. $(".sideWrapper").hide();
  333. });
  334. });
  335. $("body").css("overflow", "auto");
  336. }
  337. </script>
  338. </body>
  339. </html>