SMFHacks.com

Ad Seller Pro => Support => Topic started by: kohai.raul on March 01, 2016, 11:38:06 am

Title: problem adding ads on specifical boards / adseller2.php
Post by: kohai.raul on March 01, 2016, 11:38:06 am
Hi all!

My site makes use of TinyPortal and PrettyURL. I tried for some days adding some ads to specifical boards, without luck!.

So I decided to test the source code and I've seen some strange behavior on ShowAdLocation() function (at Sources/adseller2.php)

Around line 2480, we can see:

Code: [Select]

if (isset($_REQUEST['board']) || !empty($board))
{

if (!empty($board))
$bID = (int) $board;
else
$bID = (int) $_REQUEST['board'];



$boardCheck = " AND ((l.showinallboards = 1 OR  FIND_IN_SET($bID, l.boards)) AND (a.showinallboards = 1 OR  FIND_IN_SET($bID, a.boards))) ";
}

By testing the values of  REQUEST['board'] and bID, I've seen the following:

Code: [Select]
       

            [REQUEST_board] => 150
            [board] => Array
                (
                    [id] => 62
                    [name] => Cliparts imágenes longitudinales
                    [child_level] => 2
                    [selected] =>
                )

the correct value is on Request_board. I don't understand why bID = 62, because it does not corresponds to the current board.

The solution applied was to substitute this portion of code by:

Code: [Select]
if (isset($_REQUEST['board']))
{

  $bID = (int) $_REQUEST['board'];



$boardCheck = " AND ((l.showinallboards = 1 OR  FIND_IN_SET($bID, l.boards)) AND (a.showinallboards = 1 OR  FIND_IN_SET($bID, a.boards))) ";
}

Depending totally on board parameter from request.

Has anyone experienced a similar situation?

Best Regards,
Title: Re: problem adding ads on specifical boards / adseller2.php
Post by: SMFHacks on March 01, 2016, 12:00:13 pm
The request [board] should never be an array.
Not sure where [REQUEST_board] is coming from is that from Tiny Portal?
Title: Re: problem adding ads on specifical boards / adseller2.php
Post by: kohai.raul on March 01, 2016, 12:07:59 pm
Hi,

I think it corresponds to the "board" parameter,

http://mydomain.com?board=X

I've needed move the adSeller snippets from Themes/default/messageindex.template.php to Themes/reseller/messageindex.template.php

maybe it's a problem introduced by Reseller  (a responsive theme)...

Title: Re: problem adding ads on specifical boards / adseller2.php
Post by: kohai.raul on March 01, 2016, 12:09:53 pm
I'm Sorry!

when I said about [board] => array (...) I meant $board at the following portion of code:

Code: [Select]
...
if (!empty($board))
$bID = (int) $board;
...



Title: Re: problem adding ads on specifical boards / adseller2.php
Post by: kohai.raul on March 02, 2016, 04:51:02 am
Hi all!

By now, basing on original code on ShowAdLocation:

Code: [Select]
global ..., $board, ...;


if (isset($_REQUEST['board']) || !empty($board))
{

if (!empty($board))
$bID = (int) $board;
else
$bID = (int) $_REQUEST['board'];



$boardCheck = " AND ((l.showinallboards = 1 OR  FIND_IN_SET($bID, l.boards)) AND (a.showinallboards = 1 OR  FIND_IN_SET($bID, a.boards))) ";
}

By reviewing default/MessageIndex.template.php and reseller/MessageIndex.template.php, the only $board var I've seen in both, corresponds to a previous iteration:

Code: [Select]
...
foreach ($context['boards'] as $board)
{

...
                 } //end foreach


 showAdLocation(...);


And it's always empty. But this global var applies to BoardsIndex.template.php, where $boards gets the following structure:

Quote
[boards] => Array
                        (
                            [150] => Array
                                (
                                    [new] =>
                                    [id] => 150
                                    [name] => Preséntate. El sitio de partida
                                    [description] => Visible sólo para usuarios registrados. Preséntate y cuéntanos cuál es tu relación o expectativas con respecto a la permacultura.
                                    [moderators] => Array
                                        (
                                        )

                                    [link_moderators] => Array
                                        (
                                        )

                                    [children] => Array
                                        (
                                        )

                                    [link_children] => Array
                                        (
                                        )

                                    [children_new] =>
                                    [topics] => 42
                                    [posts] => 478
                                    [is_redirect] => 0
                                    [unapproved_topics] => 0
                                    [unapproved_posts] => 0
                                    [can_approve_posts] => 1
                                    [href] =>index.php?board=150.0
                                    [link] => Preséntate. El sitio de partida
                                    [last_post] => Array
                                        (
                                            [id] => 11279
                                            [time] => 19 Agosto de 2014, 03:55:26 pm
                                            [timestamp] => 1408456526
                                            [subject] => Re:Nuevo en el foro
                                            [member] => Array
                                                (
                                                    [id] => 9803
                                                    [username] => Isma
                                                    [name] => Isma
                                                    [href] => index.php?action=profile;u=9803
                                                    [link] => Isma
                                                )

                                            [start] => msg11951
                                            [topic] => 2553
                                            [href] => index.php?topic=2553.msg11951#new
                                            [link] => Re:Nuevo en el foro
                                        )

                                )

                            [151] => Array
                                (...)
    )

But it's not usable by ShowAdLocation in this situation...

So, from this point I don't understand the reason why ShowAdLocation makes use of global $board... it seems an unusable case...

what do you think about this???

Best Regards,
Title: Re: problem adding ads on specifical boards / adseller2.php
Post by: SMFHacks on March 02, 2016, 07:57:07 am
Hmm never noticed it before
What you can do is change your ShowAdLocation(###)
To

ShowAdLocation(###,$_REQUEST['board'])

In the messageindex area at least and that will fix that issue.
Title: Re: problem adding ads on specifical boards / adseller2.php
Post by: kohai.raul on March 03, 2016, 03:11:11 am
Thanks, but I tested before. It works well in case of "Top Message Index" and " Bottom Message Index", but I've detected that another ads on Tiny-Portal's Blocks and customised locations that must be visible in the context of MessageIndex, they were not.

Definitely by changing the mentioned piece of code for the following, works great in my case:

Code: [Select]


        if (isset($_REQUEST['board'])){
$bID = (int) $_REQUEST['board'];
}


I'm not sure, but maybe this behavior is connected with my own scenario and it don't applies to common situations.  It's a behavior don't detected before on AdSeller and this seems strange.

best regards,