Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Dec 1999
Posts: 158
Enthusiast
Enthusiast
Offline
Joined: Dec 1999
Posts: 158
so this is standard invocation code for phpadsnew to display ads from a certain zone, which I have running in UBBT´s header.php:

Code
     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) { <br />        if (!isset($phpAds_context)) $phpAds_context = array(); <br />        $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context); <br />        echo $phpAds_raw['html']; <br />    } 


can anyone please give me a hint on how to abort this, if the viewer belongs to a certain group?

I have already found this useful piece of code,
Code
 if (preg_match("/-6-/",$postergroup))  { <br />   	 echo "wiu wiu wiu"; <br />    } 


but I really don´t know how to combine these too.
I´m busy RTFM, but I still can´t figure out how to do this, I´m more of a photoshop person

Sponsored Links
Joined: Feb 2002
Posts: 295
Member
Member
Offline
Joined: Feb 2002
Posts: 295
Hi,

Not tested, but my guess would be something like this:

Code
<br />if (preg_match("/-6-/",$postergroup))  {<br />     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) {<br />        if (!isset($phpAds_context)) $phpAds_context = array();<br />        $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context);<br />        echo $phpAds_raw['html'];<br />    } <br />} <br />


On a related note, how would I allow this usergroup to set whether or not they want to see the ads?

Sanuk!

Joined: Dec 1999
Posts: 158
Enthusiast
Enthusiast
Offline
Joined: Dec 1999
Posts: 158
[]ksanuk said:
Hi,

Not tested, but my guess would be something like this:

Code
<br />if (preg_match("/-6-/",$postergroup))  {<br />     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) {<br />        if (!isset($phpAds_context)) $phpAds_context = array();<br />        $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context);<br />        echo $phpAds_raw['html'];<br />    } <br />} <br />

[/]

just tested it, unfortunately it won´t execute anymore at all, regardless of the group you´re in. Strange ...

[] On a related note, how would I allow this usergroup to set whether or not they want to see the ads? [/]
I have one usergroup called supporters, which are added automatically through mypaymentpal.
Surprisingly, many still want to see ads, because most of our ads are very content related, and not randomly picked.

So I decided to create another group called "noads", and i would allow supporters to choose themselve if they wanted to be part of that group.

For now I´d do it manually, cause we have very few supporters. I could imagine making a switch one day, and only allowing "supporters" to use that switch.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
The header might not know what group you're in, in ubbt.inc.php - find the authenticate function, and add U_Groups to the end of the $Query listed in that function.

Joined: Feb 2002
Posts: 295
Member
Member
Offline
Joined: Feb 2002
Posts: 295
Hi,

"I have one usergroup called supporters, which are added automatically through mypaymentpal.
Surprisingly, many still want to see ads, because most of our ads are very content related, and not randomly picked."

Yes, I am in a similar situation, just trying to come up with as much benefits for paying members as possible.

Sanuk!

Sponsored Links
Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
The following assumes that your donators are in usergroup 6, and that the ads are also supposed to be seen no matter what by everyone else not in the donator group.

Ok...

You'll have to create a new field in the users table. Run this query...

ALTER TABLE w3t_users ADD U_Ads tinyint(1) NOT NULL default '0'


...and then add a config option in their display preferences section.

editdisplay.php...

Code
$adsyes = ""; <br />$adsno = ""; <br /> <br />if ($ads == 1) { <br />   $adsyes = "selected=\"selected\""; <br />else { <br />   $adsno = "selected=\"selected\""; <br />} 



...which will only appear if they belong to that group and default that selection to 0 (No). You can add the PHP in the template for that.

editdisplay.tmpl...


Code
UBBTPRINT; <br />if ((preg_match("/-6-/",$postergroup)) { <br />echo "Do you wish to see ads?<br /> <br /><select name = \"Adselect\" class=\"formboxes\"> <br /><option value = \"1\"  $adsyes>Yes</option> <br /><option value = \"0\" $adsno>No</option> <br /></select> <br /><br /><br />"; <br />} <br />echo <<<UBBTPRINT 



In changedisplay.php add in the necessary stuff...

Code
// ------------- <br />// Get the input <br />	$Adselect = get_input("Adselect","post"); <br />             if ((empty($Adselect)) || (!Adselect)) { <br />               $Adselect = 0; <br />             } <br /> <br />// ----------------------- <br />// Format the query words <br />   $Adselect_q   = addslashes($Adselect); <br /> <br />// -------------------------- <br />// Update the User's profile <br />   $query = " <br />    UPDATE {$config['tbprefix']}Users <br />    SET U_Ads       = '$Adselect_q', <br />



You'd also have to make sure to authenticate U_Ads in ubbt.inc.php and assign it a variable ($ads).

Then in the header.php ad code, you'd modify it to say something like...

Code
if ( ((preg_match("/-6-/",$postergroup)) && ($ads == 1)) || (!preg_match("/-6-/",$postergroup)) ) { <br />     if (@include(getenv('DOCUMENT_ROOT').'/php/phpadsnew/phpadsnew.inc.php')) { <br />         if (!isset($phpAds_context)) $phpAds_context = array(); <br />         $phpAds_raw = view_raw ('zone:3', 0, '_blank', '', '0', $phpAds_context); <br />         echo $phpAds_raw['html']; <br />    } <br />}   

Joined: Feb 2002
Posts: 295
Member
Member
Offline
Joined: Feb 2002
Posts: 295
Hi,

Thanks. Might give this a go over the weekend.

Sanuk!

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
Ok, btw I just changed a couple things in the code that weren't quite right.

Joined: Dec 1999
Posts: 158
Enthusiast
Enthusiast
Offline
Joined: Dec 1999
Posts: 158
Twisty, thanks a million for the code, but can you think of a method that´s based on groups?
I´m a little bit afraid of making changes to the w3t_ fields, bacause one lucky or unlucky day there´ll be an import script, which moves this to a totally different format, I fear.

Joined: Sep 2003
Posts: 488
Code Monkey
Code Monkey
Joined: Sep 2003
Posts: 488
[]flint said:
Twisty, thanks a million for the code, but can you think of a method that´s based on groups?
[/]

You'd still add the option in their prefs (but forget about creating the new field and authenticating it in ubbt.inc.php as that would no longer be necessary).

What you would then have to do is create a new donars group (-7- in this example), and then in changedisplay.php, do a query and move them from group 6 to group 7 if they selected 'Yes' for wanting ads.

Then in the header code you would limit the ads to be displayed for everyone in group 7, and every not in group 6.

Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)