Permalink
Browse files

.

  • Loading branch information...
steven-copley
steven-copley committed Oct 3, 2018
1 parent 346083c commit 64055317359bf4c341300441ba6f05808626bde2
Showing with 905 additions and 639 deletions.
  1. +59 −244 index.php
  2. +9 −8 nuapi.php
  3. +28 −38 nubuilder4.php
  4. +65 −0 nubuilder_session_data.php
  5. +43 −0 nuchoosesetup.php
  6. +13 −20 nucommon.php
  7. +17 −22 nudatabase.php
  8. +2 −2 nuform.php
  9. +86 −0 nuindexlibs.php
  10. +29 −14 nupmalogin.php
  11. +268 −0 nuprocesslogins.php
  12. +30 −291 nusession.php
  13. +28 −0 nustandalonesetuplibs.php
  14. +228 −0 nuwordpresssetuplibs.php
303 index.php

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,12 +1,14 @@
<?php
header("Content-Type: application/json");
header("Cache-Control: no-cache, must-revalidate");
require_once('nusession.php');
header("Cache-Control: no-cache, must-revalidate");
require_once('nuconfig.php');
require_once('nusession.php');
require_once('nucommon.php');
require_once('nuform.php');
require_once('nuform.php');
require_once('nudata.php');
require_once('nudrag.php');
require_once('nudatabase.php');
require_once('nudrag.php');
require_once('nudatabase.php');
$_POST['nuCounter'] = rand(0, 999);
$_POST['nuErrors'] = array();
@@ -78,7 +80,6 @@
$j = json_encode($f->forms[0]);
print $j;
?>
?>
@@ -15,34 +15,44 @@
defined( 'ABSPATH' ) or die();
require_once('nuwordpresssetuplibs.php');
function nu_set_menu() {
add_menu_page('nuBuilder Forte', 'nuBuilder', 'read', 'nubuilder4-slug', 'nu_menu_function', 'dashicons-chart-bar');
}
function nu_start_session() {
if(!session_id()) {
session_start();
}
if(!session_id()) {
// start a session if there is no session
session_start();
} else {
// if there is a session the destroy and start a new one
session_destroy();
session_start();
}
}
function nu_end_session() {
session_destroy();
}
//function nu_end_session() {
// session_destroy();
//}
class nuBuilderForte{
function __construct() {
add_action('auth_redirect', 'nu_set_menu');
add_action('init', 'nu_start_session', 1);
add_action('wp_logout', 'nu_end_session');
add_action('wp_login', 'nu_end_session');
//add_action('wp_logout', 'nu_end_session');
//add_action('wp_login', 'nu_end_session');
}
function activate() {
nuWPImportNewDB();
nuWPSetWPFlagDB();
nu_construct_access_levels_WPcoupled();
flush_rewrite_rules();
wp_register_script('nubuilder4', plugins_url('nubuilder4.php', __FILE__));
@@ -63,9 +73,15 @@ function deactivate() {
register_deactivation_hook( __FILE__, array( $nuBuilderForte, 'deactivate' ) );
function nu_menu_function() {
nu_start_session();
$iframe_url = plugin_dir_url( __FILE__ ).'index.php';
$_SESSION['nuWPSessionData'] = nu_construct_session_data();
nu_construct_session_data_WPcoupled();
nu_construct_access_levels_WPcoupled();
$j = "
<iframe id='nubuilder4_iframe' style='margin:20px;border-style:solid;border-width:2px;border-color:lightgrey;width:1300px;height:1000px' src='$iframe_url'></iframe>
<script>
@@ -86,30 +102,4 @@ function nuResize(){
echo $j;
}
function nu_construct_session_data() {
$auth_info = wp_get_current_user();
$nubuilder_session_data = new stdClass;
$nubuilder_session_data->PLUGIN = true;
$nubuilder_session_data->GLOBEADMIN = false;
if ( in_array('administrator',$auth_info->roles) ) {
$nubuilder_session_data->GLOBEADMIN = true;
}
$nubuilder_session_data->USER_LOGIN = $auth_info->user_login;
$nubuilder_session_data->USER_PASS = $auth_info->user_pass;
$nubuilder_session_data->USER_EMAIL = $auth_info->user_email;
$nubuilder_session_data->USER_DISPLAY_NAME = $auth_info->display_name;
$nubuilder_session_data->USER_ROLES = $auth_info->roles;
$nubuilder_session_data->DB_NAME = DB_NAME;
$nubuilder_session_data->DB_USER = DB_USER;
$nubuilder_session_data->DB_PASSWORD = DB_PASSWORD;
$nubuilder_session_data->DB_HOST = DB_HOST;
$nubuilder_session_data->DB_CHARSET = DB_CHARSET;
$nubuilder_session_data->NU_SITE_URL = plugin_dir_url( __FILE__ );
$nubuilder_session_data->WP_ADMIN_URL = admin_url();
$nubuilder_session_data->USER_LOGGED_IN = is_user_logged_in();
$json = json_encode($nubuilder_session_data);
$encode = base64_encode($json);
return $encode;
}
?>
@@ -0,0 +1,65 @@
<?php
class nubuilder_session_data {
var $PLUGIN = false;
var $GLOBEADMIN = false;
var $GLOBEADMIN_NAME = '';
var $GLOBEADMIN_PASS = '';
var $USER_LOGIN = '';
var $USER_PASS = '';
var $USER_EMAIL = '';
var $USER_DISPLAY_NAME = '';
var $USER_ROLES = '';
var $DB_NAME = '';
var $DB_USER = '';
var $DB_PASSWORD = '';
var $DB_HOST = '';
var $DB_CHARSET = '';
var $NU_SITE_URL = '';
var $WP_ADMIN_URL = '';
var $IS_DEMO = false;
var $WP_ROLES = '';
function __construct() {
}
function construct_wordpress($wpdata) {
$this->PLUGIN = true;
$this->DB_NAME = $wpdata->DB_NAME;
$this->DB_USER = $wpdata->DB_USER;
$this->DB_PASSWORD = $wpdata->DB_PASSWORD;
$this->DB_HOST = $wpdata->DB_HOST;
$this->DB_CHARSET = $wpdata->DB_CHARSET;
if ( $wpdata->GLOBEADMIN === true ) {
$this->GLOBEADMIN_NAME = $wpdata->USER_LOGIN;
$this->GLOBEADMIN_PASS = $wpdata->USER_PASS;
$this->GLOBEADMIN = true;
}
$this->USER_LOGIN = $wpdata->USER_LOGIN;
$this->USER_PASS = $wpdata->USER_PASS;
$this->USER_EMAIL = $wpdata->USER_EMAIL;
$this->USER_DISPLAY_NAME = $wpdata->USER_DISPLAY_NAME;
$this->USER_ROLES = $wpdata->USER_ROLES;
$this->NU_SITE_URL = $wpdata->NU_SITE_URL;
$this->WP_ADMIN_URL = $wpdata->WP_ADMIN_URL;
$this->IS_DEMO = false;
$this->WP_ROLES = $wpdata->WP_ROLES;
}
function construct_standalone($nuConfigDBHost, $nuConfigDBName, $nuConfigDBUser, $nuConfigDBPassword, $nuConfigDBGlobeadminUsername, $nuConfigDBGlobeadminPassword, $nuConfigIsDemo = false) {
$this->PLUGIN = false;
$this->DB_NAME = $nuConfigDBName;
$this->DB_USER = $nuConfigDBUser;
$this->DB_PASSWORD = $nuConfigDBPassword;
$this->DB_HOST = $nuConfigDBHost;
$this->DB_CHARSET = 'utf8';
$this->GLOBEADMIN_NAME = $nuConfigDBGlobeadminUsername;
$this->GLOBEADMIN_PASS = $nuConfigDBGlobeadminPassword;
$this->IS_DEMO = $nuConfigIsDemo;
}
}
?>
@@ -0,0 +1,43 @@
<?php
if ( !session_id() ) {
session_start();
}
require_once('nuconfig.php'); // nuconfig must be loaded before using nubuilder_session_data
require_once('nubuilder_session_data.php');
$nubuilder_session_data = new nubuilder_session_data();
if ( isset($_SESSION['nuWPSessionData']) ) {
$decode = base64_decode($_SESSION['nuWPSessionData']);
$wpdata = json_decode($decode);
$nubuilder_session_data->construct_wordpress($wpdata);
} else {
nuDieIfWeAreInsideWordpress();
$nubuilder_session_data->construct_standalone($nuConfigDBHost,$nuConfigDBName,$nuConfigDBUser,$nuConfigDBPassword,$nuConfigDBGlobeadminUsername,$nuConfigDBGlobeadminPassword,$nuConfigIsDemo);
}
$_SESSION['nuconfig'] = $nubuilder_session_data;
// nudatabase will not work without $_SESSION['nuconfig'] loaded
require_once('nudatabase.php');
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();
}
}
?>
@@ -2,19 +2,16 @@
error_reporting( error_reporting() & ~E_NOTICE );
require_once('nuconfig.php');
require_once('nuchoosesetup.php');
require_once('nubuilders.php');
require_once dirname(__FILE__) . '/nusqlclass.php';
require_once dirname(__FILE__) . '/nusearchclass.php';
require_once('nudatabase.php');
set_time_limit(0);
mb_internal_encoding('UTF-8');
$GLOBALS['nuSetup'] = db_setup();
$setup = $GLOBALS['nuSetup']; //-- setup php code just used for this database
$setup = $GLOBALS['nuSetup']; //-- setup php code just used for this database
nuClientTimeZone();
@@ -1586,26 +1583,22 @@ function db_setup(){
}
function nuTranslate($t){
$l = nuGetJSONData('nuLanguage');
$s = "
SELECT *
FROM zzzzsys_translate
WHERE trl_language = ?
AND trl_english = ?
function nuTranslate($t){
$l = nuGetJSONData('nuLanguage');
$s = "
SELECT *
FROM zzzzsys_translate
WHERE trl_language = ?
AND trl_english = ?
";
$t = nuRunQuery($s, [$l, $t]);
return db_fetch_object($t)->trl_translation;
";
}
$t = nuRunQuery($s, [$l, $t]);
return db_fetch_object($t)->trl_translation;
}
?>
@@ -1,28 +1,16 @@
<?php
require_once('nuconfig.php');
//require_once('nuconfig.php');
mb_internal_encoding('UTF-8');
$_POST['RunQuery'] = 0;
if ( isset($_SESSION['wp']) ) {
$DBHost = $_SESSION['wp']->DB_HOST;
$DBName = $_SESSION['wp']->DB_NAME;
$DBUser = $_SESSION['wp']->DB_USER;
$DBPassword = $_SESSION['wp']->DB_PASSWORD;
$DBCharset = $_SESSION['wp']->DB_CHARSET;
} else {
$DBHost = $nuConfigDBHost;
$DBName = $nuConfigDBName;
$DBUser = $nuConfigDBUser;
$DBPassword = $nuConfigDBPassword;
$DBCharset = 'utf8';
}
$nuDB = new PDO("mysql:host=$DBHost;dbname=$DBName;charset=$DBCharset", $DBUser, $DBPassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES $DBCharset"));
$_POST['RunQuery'] = 0;
$DBHost = $_SESSION['nuconfig']->DB_HOST;
$DBName = $_SESSION['nuconfig']->DB_NAME;
$DBUser = $_SESSION['nuconfig']->DB_USER;
$DBPassword = $_SESSION['nuconfig']->DB_PASSWORD;
$DBCharset = $_SESSION['nuconfig']->DB_CHARSET;
$nuDB = new PDO("mysql:host=$DBHost;dbname=$DBName;charset=$DBCharset", $DBUser, $DBPassword, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES $DBCharset"));
$nuDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
function nuRunQuery($s, $a = array(), $isInsert = false){
@@ -244,8 +232,15 @@ function nuDebug($a){
$f = $b[0]['file'];
$l = $b[0]['line'];
$m = "$date - $f line $l\n\n<br>\n";
$nuSystemEval = $_POST['nuSystemEval'];
$nuProcedureEval = $_POST['nuProcedureEval'];
$nuSystemEval = '';
if ( isset($_POST['nuSystemEval']) ) {
$nuSystemEval = $_POST['nuSystemEval'];
}
$nuProcedureEval = '';
if ( isset($_POST['nuProcedureEval']) ) {
$nuProcedureEval = $_POST['nuProcedureEval'];
}
if($_POST['RunQuery'] == 1){
$m = "$date - SQL Error in <b>nuRunQuery</b>\n\n<br>\n" ;
@@ -1292,7 +1292,7 @@ function nuFormAccess($s, $a){
require('nuconfig.php');
if($_POST['session']->zzzzsys_user_id == $nuConfigDBGlobeadminUsername){
if( $_POST['session']->zzzzsys_user_id == $_SESSION['nuconfig']->GLOBEADMIN_NAME ){
return array('1', '1', '1', '1', '1');
}
@@ -1472,4 +1472,4 @@ function nuPreloadImages($a){
}
?>
?>
Oops, something went wrong.

0 comments on commit 6405531

Please sign in to comment.