forked from steven-copley/nubuilder4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuchoosesetup.php
72 lines (51 loc) · 2.33 KB
/
nuchoosesetup.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
<?php
require_once('nuconfig.php'); // nuconfig must be loaded before using nubuilder_session_dat
require_once('nubuilder_session_data.php');
require_once('nusanitize.php');
if ( !session_id() ) {
nuCheckGarbageCollector();
session_start();
}
if ( !isset($_SESSION['nubuilder_session_data']) ) {
nuLoadNewSession();
}
//Sanitize All Input
nu_sanitize();
// nudatabase will not work without $_SESSION['nubuilder_session_data'] loaded
require_once('nudatabase.php');
function nuLoadNewSession() {
global $nuConfigDBHost, $nuConfigDBName, $nuConfigDBUser, $nuConfigDBPassword, $nuConfigDBGlobeadminUsername, $nuConfigDBGlobeadminPassword, $nuConfigIsDemo;
$nubuilder_session_data = new nubuilder_session_data();
if ( isset($_SESSION['nubuilder_wordpress_session_data']) ) {
$decode = base64_decode($_SESSION['nubuilder_wordpress_session_data']);
$wpdata = json_decode($decode);
$nubuilder_session_data->construct_wordpress($wpdata);
unset($_SESSION['nubuilder_wordpress_session_data']);
} else {
nuDieIfWeAreInsideWordpress();
$nubuilder_session_data->construct_standalone($nuConfigDBHost,$nuConfigDBName,$nuConfigDBUser,$nuConfigDBPassword,$nuConfigDBGlobeadminUsername,$nuConfigDBGlobeadminPassword,$nuConfigIsDemo);
}
$_SESSION['nubuilder_session_data'] = $nubuilder_session_data->get_nubuilder_session_data();
}
function nuCheckGarbageCollector() {
global $nuConfigTimeOut;
if ( isset($nuConfigTimeOut) ) {
if ( is_int($nuConfigTimeOut) ) {
$gcLifetime = 60 * $nuConfigTimeOut;
ini_set("session.gc_maxlifetime", $gcLifetime);
}
}
}
function nuDieIfWeAreInsideWordpress() {
// at various points there is no other reliable way to check if nuBuilder is installed in the wordpress eco system
// other than checking for the file path
// this extra check is to prevent nubuilder working from the outside of wordpress if it is inside wordpress folder structure
$needle = '/wp-content/plugins/';
$haystack = $_SERVER['PHP_SELF'];
if ( strpos($haystack, $needle) !== false ) {
echo "It appears that you have placed nuBuilder inside of Wordpress as a plugin.<br>";
echo "To login to nuBuilder, you need to login through your Wordress admin.<br>";
die();
}
}
?>