Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Code Snippet and functions - 8

Post your code snippets and functions for v7 here
995 posts | Last Activity on 04-06-2020 03:56 by zizub
zizub 04-06-2020 03:56, 2 months ago
Re: How to fix preg_replace error in php7 Here is a sample code that I got in order to fix the deprecated preg_replace () function and / e modifier. Maybe someone will come in handy.
$text = preg_replace_callback(
 function ($m) use($pathto) {
 $link = $m[2].$m[3];
 return ""
 .trimlink($link, 20)
 .(strlen($link)>30?substr($link, strlen($link)-10, strlen($link)):'')

And here is the old code, for comparison.
$text = preg_replace('#\[url\]([\r\n]*)(http://|ftp://|https://|ftps://)([^\s\'\"]*?)([\r\n]*)\[/url\]#sie', "''.trimlink('\\2\\3', 20).(strlen('\\2\\3')>30?substr('\\2\\3', strlen('\\2\\3')-10, strlen('\\2\\3')):'').''", $text);

There are two more lines of code that are becoming outdated, and I don't know how to fix them.
$guest_msg = '[ link is hidden ] ( registration | input )';

$pathto = ($friendlyurl?BASEDIR.$friendlypath.'?':INCLUDES.'bbcodes/url_bbcode_include.php?');

I have a warning like this:


Warning: Use of undefined constant INCLUDES - assumed 'INCLUDES' (this will throw an Error in a future version of PHP)

If I understand correctly, I need to put quotation marks, but it doesn’t work out for me to do it correctly. Can you help?
zizub 03-06-2020 02:02, 2 months ago
Re: How to fix preg_replace error in php7 RobiNN, - Thank you for participating. I think I managed to fix the part of the code that is responsible for hiding http:// and encryption. There, small errors remain associated with different settings. I don’t need them yet, so I didn’t fix them.

Now I have a different question. How can I use this ... I need this encryption code for ad units. I'm a little at a loss. Need to think. Can you advise something.
RobiNN 02-06-2020 23:16, 2 months ago
Re: How to fix preg_replace error in php7 Try this

$text = preg_replace('#\[url=([\r\n]*)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#si', '\3', $text);

zizub 01-06-2020 11:13, 2 months ago
Re: How to fix preg_replace error in php7 Basically, I want to understand the principle of link encryption using base64_encode, as well as how to use urlencode in php-fusion.
Now I'm trying to fix an old Polarfox mod http://unlogic.info/forum/viewthread....read_id=29 This mod no longer works in php7.
All popular cms have similar plugins for redirecting external links through the go.php page, with encoded links to remove htpps: // and domain_name.com
I just want to keep this mod in order to take the code as a basis in the future.
Now on the site, I use go.php made according to this instruction https://tutorialzine.com/2013/12/quic...nes-of-php
For future plans, I want to try to modify the go.php that I use. My task is to cut out htpps: // and domain_name.com in normal links for go.php without using the bbcode [url] and [img] tags.
The suggested options in this thread https://www.php-fusion.co.uk/infusion...d_id=40062 do not work for me.
RobiNN 31-05-2020 22:58, 2 months ago
Re: How to fix preg_replace error in php7 I assume you're trying to fix v7 on PHP 7. I don't recommend it. But okay, you can use code from v8 https://github.com/php-fusion/PHP-Fus...nclude.php, this code should also work in v7.
zizub 31-05-2020 19:23, 2 months ago
Re: How to fix preg_replace error in php7 How to fix old php code that no longer works in php7.
I know that preg_replace() was outdated and the /e modifier doesn't work anymore in php7.
Here is the old code:
$text = preg_replace('#\[url=([\r\n]*)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#sie', "'\\3'", $text);

I am trying to fix it like this:
$text = preg_replace_callback('#\[url=([\r\n]*)([^\s\'\"]*?)\](.*?)([\r\n]*)\[/url\]#si', function ($m) use($pathto) {$link = $m[2]; return ""\\3';}, $text);

My code is incorrect and causes an error.
I don’t know how to fix

As well as

Can someone give an example of fixing this code?
Re: user_info_panel with warn if inbox, outbox and archive is full, added entypo, checked default, minor Modified the user_info_panel.
Added entypo, warn if inbox, outbox or archive is full, checkbox checked default, minor layout changes */

Warn if inbox, outbox and archive is full!
Add in section Gauges near line 241 in locale/YOURLANGUAGE/global.php
$locale['UM10A'] = "You have reached the limit! Delete some messages to continue using the system."; // English
$locale['UM10A'] = "U heeft de limiet bereikt! Verwijder enkele berichten om van het syteem gebruik te kunnen blijven maken."; // Dutch
$locale['UM10A'] = "Sie haben das Limit erreicht! Löschen Sie einige Nachrichten, um das System weiterhin verwenden zu können."; // German

See attached pictures for the workings.
Download and overwrite the attachment to infusions/user_info_panel/
douwe_yntema 26-04-2019 19:41, 1 year ago
Re: Multi site with one installation I made a multi subdomain site with 1 PHP-Fusion installation, which uses a separate database for each site.

It is V7.03, but can also be V8.xx.

I have multi subdomains like:

On the webserver every subdomain is pointing to the same folder on the webserver.

each site has its own database e.g. databasenames are like mysite_sub1 and mysite_sub2
each site has its own config.php in the root of the site e.g. config_sub1.php and config_sub2.php

In each config.php the settings for the database access are specified for each subdomain.
So in config_sub1.php the name of the database is: mysite_sub1, together with database login credentials, and different cookie prefix to prevent messing up with different login sessions.

In maincore.php I added the following:

function StripSubdomain($Domain) {
 $domain_array = explode('.', $Domain);
 $domain_array = array_reverse($domain_array);
   return $domain_array[2];

$subdomain = StripSubdomain($_SERVER['HTTP_HOST']);
define("SUBDOMAIN", $subdomain);
define("CONFIGPHP", "config_".SUBDOMAIN.".php");

and I modified:

// Locate config.php and set the basedir path
$folder_level = "";
$i = 0;
while (!file_exists($folder_level."config.php")) {
   $folder_level .= "";
   if ($i == 7) {
      die("config.php file not found");


// Locate config.php and set the basedir path
$folder_level = "";
$i = 0;
while (!file_exists($folder_level.CONFIGPHP)) {
   $folder_level .= "";
   if ($i == 7) {
      die("config.php file not found");


require_once BASEDIR."config.php";
// If config.php is empty, activate setup.php script
if (!isset($db_name)) {


// If config.php is empty, activate setup.php script
if (!isset($db_name)) {

I Tested and this is working OK for me.
So now I can run two different sites from one installation, only different databases.

Question is:
Is this a good practice to do?
It probably need some code to prevent $_SERVER['HTTP_HOST'] containing wrong domain name data.

One thing more to do is: there are some cron-jobs executed also, this needs some modification too, to be sure the cron job is executed with the right database.
This can be done by adding a parameter to the cron-job command line, so the con-job php file 'knows' which database to open, or modify the cron-job php file to run through all the databases after each other.
Re: Here is a tool for anyone experiencing the blank white page of death Here is a tool for anyone experiencing a blank white page during, after or under an upgrade session.

Extract error_reporting.zip and place the error_reporting.php in your root folder (same as config.php).
Edit your opening page. Most often it is news.php.
require_once __DIR__."/error_reporting.php";

require_once THEMES."templates/header.php";

Save and refresh ( CTRL+F5 ) and you should have some errors displayed.
outlaw16151 10-07-2018 18:04, 2 years ago
Re: PANEL SNIPPIT:: Some Site Stats Panel i know this is an old thread, but im back. craig, are you around?
Wanabo 09-07-2018 21:29, 2 years ago
Re: Isnum smile
Also in the second preg match?
douwe_yntema 09-07-2018 20:44, 2 years ago
Re: Isnum Thanks, It is working now
Wanabo 08-07-2018 13:52, 2 years ago
Re: Isnum

Just add a -?
See above
Perhaps for the second preg match as well.
douwe_yntema 06-07-2018 21:26, 2 years ago
Re: Isnum This is the function isnum from maincore:

// Validate numeric input
function isnum($value, $decimal=false) {
   if (!is_array($value)) {
      if($decimal==true) return (preg_match("/^[0-9]+(\.{0,1})[0-9]*$/", $value));
      return (preg_match("/^[0-9]+$/", $value));
   } else {
      return false;

How can it be changed to accept negative numbers ass well?
Sladdaren 27-06-2018 13:16, 2 years ago
Re: Avatar showing when you logged in Hi

This site looks strange nowdays i think there is som spam posted in the forum angry. Hope this site is going to be alive and active. Anyway a question

I had facebook connect installed and that infusion showed the users avatar on top of the user_info_panel.
Now i unistalled facebook connect beacasuse it dont work.
I would like to have the users avatar showing when loged in. If there is a chance i can get the avatar to showing on the left/upper side when logged in. And if there is a visitor on the site it shows nothing.

The upper/left corner in this picture i would like to have the users avatar showing when logged in.
Homdax 04-06-2018 08:22, 2 years ago
Re: GDPR Landing page with some check boxes I stumbled over Sweclockers approach and liked it, but I will not do anything fancy. The more I read about it, the simpler I see it can be done. I only really need to consider our own member registrations and that data, writing a few lines about it.
Falk 01-06-2018 16:51, 2 years ago
Re: GDPR Landing page with some check boxes I updated our Cookiebar panel on the site to include privacy,it is also very clear on new registred users. seen many do this as well.

Merged on 06/02/2018:
See screen, This is what ive seen most sites do.
Chan 01-06-2018 14:51, 2 years ago
Re: GDPR Landing page with some check boxes To save the trouble, we just update the privacy policy and send all members a notice. Isn't that easier? All the companies are doing it like this.
Homdax 28-05-2018 09:49, 2 years ago
Re: GDPR Landing page with some check boxes I am struggling with a GDPR related landing page or pop up I need to make for a few 7 sites. The page as such can be simple enough, but there are a few requirements I am finding a bit hard to implement

- It has to show on user logon, only
- It should store info in user profile, so it can be verified also with datestamp, thus db entries
- I guess some kind of admin interface to handle this info might be required, thus it must be an infusion.
- maybe other stuff

I do know we have a number of 7 sites out there waiting with the 9 upgrade so I am certain this is needed and wanted for any and all EU based sites that has any kind of member registration.
Falk 21-05-2018 00:13, 2 years ago
Re: BBCODE on Forum


When i use just the id after de = it download the swf archive

It is the MIME settings on your server environment to not play instead it downloads it.
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.