<
 
php forum
php mysql forum
php mysql smarty
 
Page 1 of 2 1 2 >
Topic Options
#284583 - 03/30/05 03:18 AM display/not-display adverts according to groups?
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
couldn't see a hack for this, so thought i'd ask.<br />Had an idea about the google adsense adverts, is it possible to only display them to standard members, but hide them for members who have paid a membership fee?<br />So adverts based on groups...

Top
#284584 - 04/04/05 01:36 AM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
JoshPet Offline
I type Like navaho

Registered: 11/29/01
Posts: 11330
Loc: Charlotte, NC
Well, lets say your "paid" usergroup is group #5. <br /><br />(SELECT * FROM w3t_Groups will show you all groups and their numbers)<br /><br />Then code like this:<br /><br />First on the page, find the bit that STARTS like this:<br /><br />$user = $userob -> authenticate("...<br /><br />Often there are a list of User table fields in the quotes inside the authenticate() function. Add in U_Groups to that list.<br /><br />Then in your page, code like this (assuming we don't want to show ads to group #5):<br /><br /><br />if (!strstr($user['U_Groups'],"-5-")) {<br /> // Display your ads here<br />}<br /><br /><br />Hope that helps.
_________________________
Joshua Pettit
www.JoshuaPettit.com
My abilities are for hire.

Top
#284585 - 04/04/05 03:16 AM Re: display/not-display adverts according to groups? [Re: Daine]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
Cheers josh, i'll take a look into that tonight, see if i can figure it out <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" />

Top
#284586 - 04/04/05 04:19 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
ok, i tried it on addpost.php, but it didnt make any difference. I could still the advert.<br />As you know, 1 is the admin usergroup.<br /><br />Is this part correct?<br /> <br />[]<br />// Grab the tablewrapper<br />list($tbopen,$tbclose) = $html -> table_wrapper();<br />if (!strstr($user['U_Groups'],"-1-")) {<br />// Adsense hack start<br /> $adsense = "";<br /> if ( stristr(",{$config['adsense']},", ",$Board,") ) {<br /> include("$thispath/templates/$tempstyle/adsense.tmpl");<br /> }<br />// Adsense hack finish<br />}<br />[/]

Top
#284587 - 04/15/05 01:04 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
anybody?

Top
#284588 - 04/18/05 07:20 AM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
Hmmm, i'll try it on showflat.php tonight.<br />I shall not be beaten!

Top
#284589 - 04/18/05 12:41 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
ok, i've got it working!!!!<br />I re-read your instructions, and tweaked a bit, and viola!<br /><br />Thanks josh.<br /><br />I now have google adsense displaying ONLY for my non-premium members! <img src="http://www.ubbdev.com/forum/images/graemlins/laugh.gif" alt="" />

Top
#284590 - 04/18/05 01:27 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
How do I add extra groups?<br />I tried:<br /><br />if (!strstr($user['U_Groups'],"-5-","-2-")) {<br /><br />but that gave me this error on the screen.<br /><br />Warning: Wrong parameter count for strstr() in /home/fordmond/public_html/ubbthreads/showflat.php on line 1324

Top
#284591 - 04/18/05 10:23 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
scroungr Offline
Old Hand

Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
if (!strstr($user['U_Groups'],"-1-")) {<br /><br />becomes <br /><br />if (!strstr($user['U_Groups'],"-1-") && !strstr($user['U_Groups'],"-2-") && !strstr($user['U_Groups'],"-3-")) {<br /><br />or you could do a <br /><br />if (strstr($user['U_Groups'],"-4-")) {<br /><br />to include just the group you want.
_________________________
Couchtomatoe - www.couch-tomatoe.cc
My abilities are for hire for installs, upgrades, custom themes and custom modifications.

Top
#284592 - 04/19/05 02:15 AM Re: display/not-display adverts according to groups? [Re: 234234]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
aha. I wouldnt have got that in a million years!<br />Thanks again scroungr, I think I must owe you some beers now! <img src="http://www.ubbdev.com/forum/images/graemlins/wink.gif" alt="" />

Top
#284593 - 04/21/05 12:40 AM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
Dalantech Offline
Junior Member

Registered: 02/11/01
Posts: 2392
Loc: Naples, Italy
Sorry -I've been busy scripting at work and haven't been doing any for myself (or this site) lately. Glad to see you got it working <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" />
_________________________
Da LAN Tech

Threads Dev Moderator

Top
#284594 - 04/21/05 06:04 PM Re: display/not-display adverts according to groups? [Re: jacksonm99]
minto Offline
Power User

Registered: 08/21/04
Posts: 82
wow this is a nice little tweak i might have to add this baby to my site <img src="http://www.ubbdev.com/forum/images/graemlins/laugh.gif" alt="" />
_________________________
[]http://www.leech4free.com/mysigs/rr5vi.gif[/]
uproar1.com - music website

Top
#284595 - 05/14/05 07:21 AM Re: display/not-display adverts according to groups? [Re: square_peg]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
Am A bit stuck trying to get this to function correctly on addpost.php<br /><br />This is the code which is wrong<br /><br />[]<br />// ---------------------<br />// Grab the tablewrapper<br />list($tbopen,$tbclose) = $html -> table_wrapper();<br />if (!strstr($user['U_Groups'],"-9-")) {<br />// Adsense hack start<br /><br /> $adsense = "";<br /> if ( stristr(",{$config['adsense']},", ",$Board,") ) {<br /> include("$thispath/templates/$tempstyle/adsense.tmpl");<br /> }<br />// Adsense hack finish<br />[/]<br /><br />I get a parse error, saying theres an unexpected $ on line 1147.<br /><br />But when I go to line 1147 all thats on that line is <br />[]<br />} else {<br />[/]

Top
#284596 - 05/14/05 09:38 AM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
scroungr Offline
Old Hand

Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
theres an open { on that first if but you are not closing it.. there is no } for it
_________________________
Couchtomatoe - www.couch-tomatoe.cc
My abilities are for hire for installs, upgrades, custom themes and custom modifications.

Top
#284597 - 05/15/05 04:06 AM Re: display/not-display adverts according to groups? [Re: 234234]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
Ok, I've sorted out the parse error.<br />In the bold part of the code below you'll see I missed off the } after the adsense finished.<br />Only problem now is that it's not removing the adverts for group 9.<br />Is this because the U_groups code is below the adsense code?<br /><br />[]<br /><?<br />/*<br /># UBB.threads, Version 6<br /># Official Release Date for UBB.threads Version6: 06/05/2002<br /><br /># First version of UBB.threads created July 30, 1996 (by Rick Baker).<br /># This entire program is copyright Infopop Corporation, 2002.<br /># For more info on the UBB.threads and other Infopop<br /># Products/Services, visit: http://www.infopop.com<br /><br /># Program Author: Rick Baker.<br /># File Version 6.5b6<br /><br /># You may not distribute this program in any manner, modified or otherwise,<br /># without the express, written written consent from Infopop Corporation.<br /><br /># Note: if you modify ANY code within UBB.threads, we at Infopop Corporation<br /># cannot offer you support-- thus modify at your own peril <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" /><br /># ---------------------------------------------------------------------------<br />*/<br /><br />// Require the library<br />require ("./includes/main.inc.php");<br />require ("languages/{$myprefs['language']}/addpost.php");<br />require ("imagesizes.php");<br /><br />// Define the default language varialbe, required for PHP3<br />$Language = $myprefs['language'];<br /><br />// -------------<br />// Get the input<br />$Board = get_input("Board","post");<br />$Cat = get_input("Cat","post");<br />$Reged = get_input("Reged","post");<br />$page = get_input("page","post");<br />$what = get_input("what","post");<br />$vc = get_input("vc","post");<br />$Subject = get_input("Subject","post");<br />$Body = get_input("Body","post");<br />$preview = get_input("preview","post");<br />$textcont = get_input("textcont","post");<br />$Icon = get_input("Icon","post");<br />$convert = get_input("convert","post");<br />$postername = get_input("postername","post");<br />$Main = get_input("Main","post");<br />$Parent = get_input("Parent","post");<br />$ParentUser = get_input("ParentUser","post");<br />$oldnumber = get_input("oldnumber","post");<br />$fpart = get_input("fpart","post");<br />$replyto = get_input("replyto","post");<br />$IP = get_input("IP","post");<br />$frompreview = get_input("frompreview","post");<br />$PStatus = get_input("PStatus","post");<br />$dofav = get_input("dofav","post");<br />$questions = get_input("questions","post");<br />$day = get_input("day","post");<br />$month = get_input("month","post");<br />$year = get_input("year","post");<br />$hour = get_input("hour","post");<br />$min = get_input("min","post");<br />$ampm = get_input("ampm","post");<br />$stopday = get_input("stopday","post");<br />$stopmonth = get_input("stopmonth","post");<br />$stopyear = get_input("stopyear","post");<br />$stophour = get_input("stophour","post");<br />$stopmin = get_input("stopmin","post");<br />$stopampm = get_input("stopampm","post");<br />$enablestart = get_input("enablestart","post");<br />$enablestop = get_input("enablestop","post");<br />$noview = get_input("noview","post");<br />$mustvote = get_input("mustvote","post");<br />$addpoll = get_input("addpoll","post");<br />$addevent = get_input("addevent","post");<br />$calmonth = get_input("calmonth","post");<br />$calday = get_input("calday","post");<br />$calyear = get_input("calyear","post");<br />$Sticky = get_input("Sticky","post");<br />$announcement = get_input("announcement","post");<br />$addsig = get_input("addsig","post");<br />$quickreply = get_input("quickreply","post");<br /><br />if (!$addpoll) { $questions = 0; }<br /><br />// -------------------------<br />// Predefine a few variables<br />$parentboard = "";<br />$RealSubject = "";<br />$attachfile = "";<br />$fileinput = "";<br />$Pselected = "";<br />$canattach = "";<br />$PollId = "";<br />$extra = "";<br />$okay = "";<br />$previewpoll = "";<br />$Main = addslashes($Main);<br /><br />$html = new html;<br />include("checkimages.php");<br /><br />// Censor the input?<br />if ($config['docensor']) {<br /> $Body = $html->do_censor($Body);<br /> $Subject = $html->do_censor($Subject);<br />}<br /><br />// ---------------------<br />// Grab the tablewrapper<br />list($tbopen,$tbclose) = $html -> table_wrapper();<br /><br />if (!strstr($user['U_Groups'],"-9-")) {<br />// Adsense hack start<br /> $adsense = "";<br /> if ( stristr(",{$config['adsense']},", ",$Board,") ) {<br /> include("$thispath/templates/$tempstyle/adsense.tmpl");<br /> }<br />// Adsense hack finish<br />}<br /><br />// Add a space to the end of $Body, for auto-url encoding<br />$Body .= " ";<br /><br />$userob = new user;<br />$user = $userob -> authenticate("U_Username, U_Password,U_Signature,U_Picture,U_Groups,U_Display,U_Language,U_Totalposts,U_Title,U_Color,U_TextCols,U_TextRows,U_EReplies,U_Preview,U_Number,U_Groups");<br />if ($Reged == "y") {<br /> $Username = $user['U_Username'];<br /> $Username_q = addslashes($Username);<br /> $posterid = $user['U_Number'];<br /> $postername = $Username;<br />}<br />else {<br /> if (!$postername) {<br /> $postername = $ubbt_lang['ANON_TEXT'];<br /> }<br /> $Username_q = addslashes($postername);<br /> $posterid = "1";<br /> $user['U_Number'] = 1;<br />}<br /><br />// -----------------<br />// Get the user info<br />$IP = find_environmental('REMOTE_ADDR');<br /><br />// See if they are banned<br />$userob -> check_ban();<br /><br />// Flood control settings<br />if (!empty($user['U_FloodControl'])) {<br /> if ($user['U_FloodControl'] == "-1") {<br /> $floodcontrol = $config['floodcontrol']; <br /> }<br /> else {<br /> $floodcontrol = $user['U_FLoodControl'];<br /> }<br />}<br /><br />// ----------------------------------------------<br />// Let's get the groups and default flood control<br />if (!$user['U_Groups']) {<br /> $user['U_Groups'] = "-4-";<br /> $floodcontrol = $config['floodcontrol'];<br /> $lastposttime = get_input("lastposttime","cookie");<br />} else {<br /> $floodcontrol = $user['U_FloodControl'];<br /> $lastposttime = $user['U_LastPostTime'];<br />}<br /><br />// ---------------------------------<br />// Check if they can make a post yet<br />if ($user['U_Status'] != "Administrator" && $user['U_Status'] != "Moderator") {<br /> if (($html->get_date() - $lastposttime) < $floodcontrol) {<br /> $ubbt_lang['FLOODCONTROL'] = sprintf($ubbt_lang['FLOODCONTROL'],$floodcontrol); <br /> $html->not_right($ubbt_lang['FLOODCONTROL']);<br /> }<br />} <br /><br />// ------------------<br />// Check the referer<br />if (!$config['disablerefer']) {<br /> $html -> check_refer($Cat);<br />}<br /><br />// <br /><br /><br /><----snip<br />[/]

Top
#284598 - 05/16/05 03:03 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
scroungr Offline
Old Hand

Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
look at your logic<br /><br />if (!strstr($user['U_Groups'],"-9-")) {<br />// Adsense hack start<br />$adsense = "";<br />if ( stristr(",{$config['adsense']},", ",$Board,") ) {<br />include("$thispath/templates/$tempstyle/adsense.tmpl");<br />}<br />// Adsense hack finish<br />}<br /><br /><br />you are saying that ONLY if NOT group 9 then check if the board is config[adsense] and include the template for adsense.tmpl and if you are group 9 then don't do anything at all...so it shouldn't ever include the adsense.tmpl..
_________________________
Couchtomatoe - www.couch-tomatoe.cc
My abilities are for hire for installs, upgrades, custom themes and custom modifications.

Top
#284599 - 05/16/05 04:18 PM Re: display/not-display adverts according to groups? [Re: 234234]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
but that exact code works perfectly on showflat.php....<br />hence my confusion.

Top
#284600 - 05/16/05 04:48 PM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
scroungr Offline
Old Hand

Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
so its working in showflat.php but NOT in addpost.php? whats in the <br /><br />$userob = new user;<br />$user = $userob -> authenticate();<br /><br />function? is it any different in YOUR showflat.php and addpost.php? does the addpost includ the U_Groups field?
_________________________
Couchtomatoe - www.couch-tomatoe.cc
My abilities are for hire for installs, upgrades, custom themes and custom modifications.

Top
#284601 - 05/17/05 01:00 AM Re: display/not-display adverts according to groups? [Re: 234234]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
This is in showflat.php<br /> [] $userob = new user;<br />$user = $userob -> authenticate("U_Display, U_Groups, U_PostsPer, U_PicturePosts, U_FlatPosts, U_TimeOffset,U_ShowSigs,U_TimeFormat,U_Ignored,U_SearchSession,U_Preview,U_TextCols,U_TextRows,U_Groups");<br /> [/] <br /><br />and this is whats in my addpost.php<br /> []$userob = new user;<br />$user = $userob -> authenticate("U_Username, U_Password,U_Signature,U_Picture,U_Groups,U_Display,U_Language,U_Totalposts,U_Title,U_Color,U_TextCols,U_TextRows,U_EReplies,U_Preview,U_Number,U_Groups");<br /> [/] <br /><br />The only thing thats different, and I dont know whether it will make a difference or not, is on showflat.php the above statement comes BEFORE the adsense code, on addpost.php the above statement comes AFTER the adsense code.<br />I don't know if that will affect it or not?

Top
#284602 - 05/17/05 07:45 AM Re: display/not-display adverts according to groups? [Re: Luka_dup1]
scroungr Offline
Old Hand

Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
it will.. see your calling the U_Groups after it in the addpost.. put your code in the addpost AFTER it and try that
_________________________
Couchtomatoe - www.couch-tomatoe.cc
My abilities are for hire for installs, upgrades, custom themes and custom modifications.

Top
#284603 - 05/17/05 04:37 PM Re: display/not-display adverts according to groups? [Re: 234234]
monkeyra Offline
Junior Member

Registered: 06/28/01
Posts: 363
Loc: uk
Yep, that fixed it.<br />Thanks scroungr!

Top
Page 1 of 2 1 2 >


Who's Online
0 registered (), 23 Guests and 12 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Wisdom needed
by Gizmo
Today at 10:54 AM
How to hide sub forums from summary page
by blaaskaak
Yesterday at 09:54 AM
Spell Check [beta]
by Bill B
12/01/08 09:16 PM
PhotoPost BB Code Popup
by AllenAyres
12/01/08 09:41 AM
Problems reading a lot of old posts here
by AllenAyres
12/01/08 09:35 AM
Forum 'Trader Ratings'.
by AllenAyres
12/01/08 09:33 AM
Customization needed
by Gizmo
11/12/08 12:28 PM
New Mods
User Authentication Class
by
01/19/07 02:59 PM
Multiple Identity Detector
by
12/30/06 06:39 PM
PhotoPost BB Code Popup
by
11/06/06 05:43 PM
Spell Check [beta]
by
10/17/06 09:24 PM
Newest Members
Truth, David DelMonte, nick1, Begbie, cenk
13364 Registered Users
Top Posters
AllenAyres 25452
JoshPet 11330
Rick 8372
LK 7396
Lord Dexter 6503
Greg Hard 5533
Charles Capps 5438