-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathURLHandler.php
80 lines (61 loc) · 2.16 KB
/
URLHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/***********************************************************************************/
/* (C) 2020 - Skyfallen */
/* Skyfallen Secure Forms Developed by */
/* The Skyfallen Company */
/* */
/* File Since: SFR-301009 */
/* This file is where all URL Requests are translated to in-app paths. */
/***********************************************************************************/
// Prevent direct execution of the file
defined("SSF_ABSPATH") or die("Don't mess!");
// Set custom Powered by Header
header('X-Powered-By: SkyfallenSecureForms');
// Check if Web Server has set the path parameter
if(isset($_GET["path"])) {
// Get full request url
define("REQUEST", $_GET["path"]);
} else {
// We are on the '/' directory
define("REQUEST","/");
}
// Get our installed web url
$web_url = DBSettings::getKeyValue("WEB_URL");
// Make Sure WEB_URL ends with '/'
if(substr($web_url,-1) != "/"){
// Resave the url with trailing slash at the end
DBSettings::setKey("WEB_URL",$web_url."/");
}
// Define the WEB_URL
define("WEB_URL",DBSettings::getKeyValue("WEB_URL"));
// Try to extract data from our WEB_URL
// Seperate the web_url to parts by '/'
$subfolders = explode("/",WEB_URL);
$s_subfolders = array();
$i = 0;
$rootDomain = $subfolders[2];
$protocol = $subfolders[0];
// Define the domain name
define("ROOT_DOMAIN",$rootDomain);
// Check if SSL is enabled
if($protocol = "http:"){
define("IS_SSL",false);
} elseif($protocol = "https:") {
define("IS_SSL",true);
}
// Iterate through each part and get rid of first two
foreach ($subfolders as $subfolder){
if($i > 2){
array_push($s_subfolders,$subfolder);
}
$i = $i+1;
}
unset($i);
$subdir = "";
foreach ($s_subfolders as $s_subfolder){
$subdir = $subdir."/".$subfolder;
}
// Add / to the end
$subdir = $subdir."/";
// Define the sub-directory
define("SSF_SUBDIR",$subdir);