The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minimum to access $settings array
#1
Sorry if this has been covered elsewhere...

I'm trying to access the $settings->site_offline element without including the headers and navigation php files because these mess up my page layouts (I don't use bootstrap but other HTML5/CSS templates).

Basically I want to isolate the php code to obtain the $settings array without invoking any US PHP files that will try and paint the screen...

I started to try and follow the various files, but ended up totally lost in the repeated "include"-ing of PHP code in the various helper libraries.

Is there a minimum set of PHP functions/methods that I can access without any presentation stuff being done? I love the UserSpice access model, I just don't want to always have the Bootstrap look and feel. I'm confident the bits are there, but some pointers to which to use would be great!

Thanks
  Reply
#2
Absolutely. None of that stuff is required.

So if you are not using the userspice files, you should definitely leave them where they are because other things might depend on them, but all you need to include is init. So if your files are in the users folder you should put
<?php require_once 'init.php'; ?>
If you're putting your files in the root below users, you should do...
<?php require_once 'users/init.php'; ?>
If you have
root/users
root/myfiles
You should do
<?php require_once '../users/init.php'; ?>
You get the idea.

From there, you have a few things you want to look at...
To control a page with userspice (block people from visiting without permission, you definitely need)
<?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>

So then it's a matter of what's in our header that you might want to include in yours without taking any of the US styling.

At minimum, I would put these lines in your header...
$db = DB::getInstance(); //mandatory if you want to access the database

$settingsQ = $db->query("Select * FROM settings"); //Get access to all settings including site_offline
$settings = $settingsQ->first();
if ($settings->site_offline==1){
die("The site is currently offline.");
}

Then you can decide if you want to include the sections for guest tracking, force ssl, etc. But basically anything you take above line 73 in users/includes/header.php will give you functionality of userspice without any of the look and feel.

I hope that helps and I hope you find the system really flexible.

  Reply
#3
I knew it would be straightforward! Thanks so much for the prompt reply.

I'll have a tinker...
  Reply
#4
Yeah! Let me know if there's anything I can do.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)