Helper file and token prep
This commit is contained in:
		| @@ -1,20 +1,12 @@ | |||||||
| <?php | <?php | ||||||
| $config = json_decode(file_get_contents("/var/www/usergen/secret/config.json", true)); | $config = json_decode(file_get_contents("/var/www/usergen/secret/config.json", true)); | ||||||
|     ini_set('display_errors', 1); |  | ||||||
|     ini_set('display_startup_errors', 1); |  | ||||||
|     error_reporting(E_ALL); |  | ||||||
|  |  | ||||||
| require("/var/www/usergen/secret/oauth.php"); | require_once("/var/www/usergen/secret/helpers.php"); | ||||||
| function flog($log_msg) { |  | ||||||
|     $log_filename = "/var/www/html"; | require_once("/var/www/usergen/secret/oauth.php"); | ||||||
|     $log_file_data = $log_filename.'/log_' . date('d-M-Y') . '.log'; |  | ||||||
|     // if you don't add `FILE_APPEND`, the file will be erased each time you add a log |  | ||||||
|     file_put_contents($log_file_data, $log_msg . "\n", FILE_APPEND); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| if (isset($_REQUEST["act"])){ | if (isset($_REQUEST["act"])){ | ||||||
|     // internal functions such as id request |     // internal functions such as id request | ||||||
|     flog("Ret ACT:16 ✨ ".$_REQUEST["act"]." FROM ".$_SERVER["REMOTE_ADDR"]); |  | ||||||
|     switch($_REQUEST["act"]){ |     switch($_REQUEST["act"]){ | ||||||
|         case "id": |         case "id": | ||||||
|             // return OAUTH app ID |             // return OAUTH app ID | ||||||
| @@ -85,6 +77,7 @@ if (isset($_REQUEST["act"])){ | |||||||
|  |  | ||||||
|                     }else{ |                     }else{ | ||||||
|                         // invalid auth |                         // invalid auth | ||||||
|  |                         // TODO: Replace with direct to index logout with error msg | ||||||
|                         if(isset($_COOKIE["oa_retries"])){ |                         if(isset($_COOKIE["oa_retries"])){ | ||||||
|                             $retries = $_COOKIE["oa_retries"]; |                             $retries = $_COOKIE["oa_retries"]; | ||||||
|                             if($retries >= 3){ |                             if($retries >= 3){ | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								index.js
									
									
									
									
									
								
							| @@ -1,7 +1,6 @@ | |||||||
| var DEBUG = false; | var DEBUG = false; | ||||||
| var isMobile = false; | var isMobile = false; | ||||||
| var USE_ORIGIN = ""; | var USE_ORIGIN = ""; | ||||||
| // TODO: Add check for DOMAIN_OVERRIDE |  | ||||||
|  |  | ||||||
| const dbp = (msg) => { | const dbp = (msg) => { | ||||||
|   if(DEBUG){ |   if(DEBUG){ | ||||||
| @@ -21,7 +20,12 @@ const SwalConfig = { | |||||||
|   buttonsStyling: false, |   buttonsStyling: false, | ||||||
| } | } | ||||||
|  |  | ||||||
| const invalidChars = ['/', '\\', '>', '<', ':', '*', '|', '"', '\'', '?', '\0']; | const invalidChars = [ | ||||||
|  |   '/', '\\', '>', | ||||||
|  |   '<', ':', '*', | ||||||
|  |   '|', '"', '\'', | ||||||
|  |   '?', '\0' | ||||||
|  | ]; | ||||||
|  |  | ||||||
| const replaceInvalid = (str) => { | const replaceInvalid = (str) => { | ||||||
|   var cache = str; |   var cache = str; | ||||||
| @@ -278,7 +282,9 @@ $(() => { | |||||||
|       dbp("Is Mobile 👍🏻"); |       dbp("Is Mobile 👍🏻"); | ||||||
|       disableNonDesktopElements(); |       disableNonDesktopElements(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Auto Retry |     // Auto Retry | ||||||
|  |     // TODO: Replace with redirect to home with logout set if error | ||||||
|     var isRetry = false; |     var isRetry = false; | ||||||
|     if(window.location.pathname.includes("auth")){ |     if(window.location.pathname.includes("auth")){ | ||||||
|       var ErrorMsg = document.getElementById("ErrorResult"); |       var ErrorMsg = document.getElementById("ErrorResult"); | ||||||
| @@ -289,6 +295,7 @@ $(() => { | |||||||
|         beginOauth(); |         beginOauth(); | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Console Welcome |     // Console Welcome | ||||||
|     if(!isRetry){ |     if(!isRetry){ | ||||||
|       console.log("%cWelcome Hacker!", "color: #ff0000; font-size: 7em; font-style: italic; font-family: 'Times New Roman', Times, serif;"); |       console.log("%cWelcome Hacker!", "color: #ff0000; font-size: 7em; font-style: italic; font-family: 'Times New Roman', Times, serif;"); | ||||||
|   | |||||||
							
								
								
									
										16
									
								
								index.php
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								index.php
									
									
									
									
									
								
							| @@ -1,4 +1,18 @@ | |||||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||||
|  | <!-- TODO: Add popup with error if passed to page --> | ||||||
|  | <?php | ||||||
|  |     require_once("/var/www/usergen/secret/helpers.php"); | ||||||
|  |     if (isset($_REQUEST["act"])){ | ||||||
|  |         switch($_REQUEST["act"]){ | ||||||
|  |             case "logout": | ||||||
|  |                 // Logout | ||||||
|  |                 clearCookies(); | ||||||
|  |                 break; | ||||||
|  |             default: | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | ?> | ||||||
| <HTML lang="en"> | <HTML lang="en"> | ||||||
|     <Head> |     <Head> | ||||||
|         <Title>HackersTown Server Access</Title> |         <Title>HackersTown Server Access</Title> | ||||||
| @@ -35,7 +49,7 @@ | |||||||
|                     </span> |                     </span> | ||||||
|                 </div> |                 </div> | ||||||
|                 <div class="row button"> |                 <div class="row button"> | ||||||
|                     <button id="bttn" class="keyButton" onclick="beginOauth()">Log In</button> |                     <button id="bttn" class="keyButton" onclick="beginOauth()">Log In With HTown <!-- img src="/Assets/HTown.png" class="emoji"/ --></button> | ||||||
|                 </div> |                 </div> | ||||||
|                 <?php require("/var/www/usergen/footer.php"); ?> |                 <?php require("/var/www/usergen/footer.php"); ?> | ||||||
|             </div> |             </div> | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								secret/helpers.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								secret/helpers.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | <?php | ||||||
|  | function clearCookies() { | ||||||
|  |     if(count($_COOKIE) > 0) { | ||||||
|  |         foreach ($_COOKIE as $key => $value) { | ||||||
|  |             setcookie($key, "", time()-3600); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | function flog($log_msg) { | ||||||
|  |     $log_filename = "/var/www/html"; | ||||||
|  |     $log_file_data = $log_filename.'/log_' . date('d-M-Y') . '.log'; | ||||||
|  |     file_put_contents($log_file_data, $log_msg . "\n", FILE_APPEND); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function enableDebug(){ | ||||||
|  |     ini_set('display_errors', 1); | ||||||
|  |     ini_set('display_startup_errors', 1); | ||||||
|  |     error_reporting(E_ALL); | ||||||
|  | } | ||||||
|  | ?> | ||||||
		Reference in New Issue
	
	Block a user