MyBB Community Forums

Full Version: Plugin 'Ad Randomizer' problem after PHP7.2 -upgrade
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
During upgrading to PHP 7.2 I noticed some problems with (older) plugins. I could upgrade most of them with help from this forum.

But there's one problem left:
I use this Ad Randomizer for many years now, it works great!
https://mods.mybb.com/view/ad-randomizer-system

It looks like it's not compatible with PHP7.2 because I get this strange error-massage:

[Image: Adsproblem.jpg]
Any ideas what it excactly means, or better, how I should solve this problem?

Thanks a lot for helping again!
If you are brave enough open the ads.php file and edit on line 83
Replace the MYSQL_BOTH with FETCH_BOTH

I need to note that the plugin you use is old very old. 2009 latest update. It's not made for PHP v7.2
Upgrading PHP to a higher version in the future might completely break it.
Thanks for your reply Burnacid, I rep[laced the mentioned line, but now the following error appears:

[Image: error-ads.jpg]
@wageral

The error tells you exactly what the issue is, it is looking for 'MYSQL_BOTH' when the plugin has MYSQL_BOTH and it tells you that line 83 is where it is located..., thus you would simply go to that line:


While ($row = $db->fetch_array($count, MYSQL_BOTH)){

and provide what it was assuming:
While ($row = $db->fetch_array($count, 'MYSQL_BOTH')){


Also you need to fix the submenu function for it to display in acp...

Instead of:
function ads_nav($sub_menu){

        $sub_menu[] = array(
                      "id" => "ads",
                      "title" => "Ad Rotation Manager",
                      "link" => "index.php?module=config/ads"
                      );
}

Do something like so:


function ads_nav(&$sub_menu){

 global $mybb;

 if(is_super_admin((int)$mybb->user['uid']))
 {
        $sub_menu['310'] = array(
                      "id" => "ads",
                      "title" => "Ad Rotation Manager",
                      "link" => "index.php?module=config/ads"
                      );
  }    
}

You also will need to modify this:

function ads_activate(){ 
 require MYBB_ROOT.'/inc/adminfunctions_templates.php';
 find_replace_templatesets(
 "footer",
 '#'.preg_quote('<div class="bottommenu">').'#',
 '<center>{$banner}</center><div class="bottommenu">'
 );
}
function ads_deactivate(){ 
 require MYBB_ROOT.'/inc/adminfunctions_templates.php'; 
 find_replace_templatesets(
 "header",
 '#'.preg_quote('<center>{$banner}</center><div class="bottommenu">').'#',
 '<div class="bottommenu">',
 0
 );
}


And change to something like this for example if you want it in the footer below  the bottom menu:
function ads_activate(){ 
 require MYBB_ROOT.'/inc/adminfunctions_templates.php';
 find_replace_templatesets(
 "footer",
 '#'.preg_quote('{$auto_dst_detection}').'#',
 '<br /><center>{$banner}</center><br />{$auto_dst_detection}'
 );
}
function ads_deactivate(){ 
 require MYBB_ROOT.'/inc/adminfunctions_templates.php'; 
 find_replace_templatesets(
 "footer",
 '#'.preg_quote('<br /><center>{$banner}</center><br />{$auto_dst_detection}').'#',
 '{$auto_dst_detection}',
 0
 );
}


or change to something like this for example if you want it in the footer above the bottom menu:


function ads_activate(){ 
 require MYBB_ROOT.'/inc/adminfunctions_templates.php';
 find_replace_templatesets(
 "footer",
 '#'.preg_quote('<div id="footer">').'#',
 '<center>{$banner}</center><br /><br /><div id="footer">'
 );
}
function ads_deactivate(){ 
 require MYBB_ROOT.'/inc/adminfunctions_templates.php'; 
 find_replace_templatesets(
 "footer",
 '#'.preg_quote('<center>{$banner}</center><br /><br /><div id="footer">').'#',
 '<div id="footer">',
 0
 );
}


The reason this must be done is that the bottom menu name is not the same in 1.8 as it was in 1.4 so that should get the ads to display in the footer again and also allow it to uninstall in the template as the old deactivate function was looking in header template for footer items???.... thus not uninstalling in the template

This has the previous things already simply to get you started:

[attachment=41599]

There is one issue I did notice but did not have the time to look into and perhaps another member that has more free time can focus on that and that is the the null entry issue on max because it will error if max input is empty so you may want to fix that and I currently do not have the free time to look at that further.

As far as any other changes that might or might not need to be made please note: * I did not look at this further nor does my current allotted free-time allow me to do so, apologies...

*** Also note: the tablespace notice you have in your screenshot should not be present if you are using the fixed prostats https://community.mybb.com/thread-222168...pid1325417
Thanks al lot again Vintagedaddyo, ik wil try to replace/install these files.

Ger

I changed the file and now it works fine again with PHP7.2. Thanks for making / adjusting that file.

But now the settings-link in the left column of the configuration-file is gone: I tried to make a new one with the xml-file but that is a little to complicated for me I guess......

[Image: problem-ADS.jpg]
(2019-03-06, 11:31 AM)wageral Wrote: [ -> ]Thanks al lot again Vintagedaddyo, ik wil try to replace/install these files.

Ger

I changed the file and now it works fine again with PHP7.2. Thanks for making / adjusting that file.

But now the settings-link in the left column of the configuration-file is gone: I tried to make a new one with the xml-file but that is a little to complicated for me I guess......

[Image: problem-ADS.jpg]

No worries. Hmmm... The included edited file has the sub menu edit already as without it the submenu was not displaying in 1.8... , and it displays menu item fine for me via localhost? is it that one that you are saying is not showing the menu item? If so is there any other plugin using 310? Have you tried changing 310 to a higher number?


[Image: 140iz2a.png]
This is how it should like before I replaced the file:

[Image: probleem-6.jpg]

I'm just testing in a test envirement, not on my real forum. Just change 'oriste' on my official URL to 'oris1820' en you're there......
What do you mean with 'If so is there any other plugin using 310? Have you tried changing 310 to a higher number?' Where can I checq that?
As you can see, I'm not a big coder, but I keep learning every time again  Wink
(2019-03-06, 06:56 PM)wageral Wrote: [ -> ]This is how it should like before I replaced the file:

[Image: probleem-6.jpg]

I'm just testing in a test envirement, not on my real forum. Just change 'oriste' on my official URL to 'oris1820' en you're there......
What do you mean with 'If so is there any other plugin using 310? Have you tried changing 310 to a higher number?' Where can I checq that?
As you can see, I'm not a big coder, but I keep learning every time again  Wink

Hey, no worries, everything is a learning experience for us all, haha, and I am also not really a big coder either, haha.., so I feel ya on that sentiment..., anyhoo..., let me see if I can explain this more clearly....

This is the new replacement sub-menu function:

function ads_nav(&$sub_menu){

 global $mybb;

 if(is_super_admin((int)$mybb->user['uid']))
 {
        $sub_menu['310'] = array(
                      "id" => "ads",
                      "title" => "Ad Rotation Manager",
                      "link" => "index.php?module=config/ads"
                      );
  }    
}


Also what happens if you remove the 310 completely? for example:

function ads_nav(&$sub_menu){

 global $mybb;

 if(is_super_admin((int)$mybb->user['uid']))
 {
        $sub_menu[''] = array(
                      "id" => "ads",
                      "title" => "Ad Rotation Manager",
                      "link" => "index.php?module=config/ads"
                      );
  }    
}


Primarily I ask this because I am curious if other plugin submenu # is conflicting perhaps?

Here is a preview when I remove the 310 and menu item still displays

[Image: amz23n.png]

So in theory menu # is not necessary unless you want to specify exactly where the menu item will display in the order


For example I will show submenu from my plugin mydevel generate simply to further understand why I set a sub menu #:


function mydevel_generate_admin_config_menu(&$sub_menu)
{
 global $mybb, $lang;

    $lang->load("mydevel_generate");
 if(is_super_admin((int)$mybb->user['uid']))
 {
 $sub_menu['300'] = array("id" => "mydevel_generate", "title" => $lang->mydevel_generate_Name, "link" => "index.php?module=config-mydevel_generate");
 }
}


Notice the 300? hence why for me adding 310 to ad plugin works fine as it sets the sub menu below my existing mydevel plugin at 300 and sets the ad sub menu to 310  suggesting it needs to go after previous sub menu items 309 and less...

also why I asked if removing the sub menu assignment number corrects it for your specific issue and or if changing sub menu # to not conflict with say other plugin sub menu item # if they are also defined?

Let me show an example of sub menu # conflict:

lets change the sub menu # to 300 even though i know my other plugin has 300:

and ...., bam:
[Image: 1z57wux.png]

Notice my other plugin with 300 is not appearing?

thats because it can't display both on the same # so only one is displayed...., hopefully that makes sense...


Font-end preview:

[Image: nxqb10.png]
Thanks for your explanation, I thing I begin to understand how it works. However; I've tried both of your scripts (wit and without '310' but the link stil does'nt show up ........
(2019-03-06, 08:49 PM)wageral Wrote: [ -> ]Thanks for your explanation, I thing I begin to understand how it works. However; I've tried both of your scripts (wit and without '310' but the link stil does'nt show up ........

do you have & in the function?

ie:


function ads_nav(&$sub_menu)


instead of the old:


function ads_nav($sub_menu)
I ask that because if you remove the added & the menu will not appear....
Pages: 1 2 3 4