Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
couldn't see a hack for this, so thought i'd ask.
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?
So adverts based on groups...

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Well, lets say your "paid" usergroup is group #5.

(SELECT * FROM w3t_Groups will show you all groups and their numbers)

Then code like this:

First on the page, find the bit that STARTS like this:

$user = $userob -> authenticate("...

Often there are a list of User table fields in the quotes inside the authenticate() function. Add in U_Groups to that list.

Then in your page, code like this (assuming we don't want to show ads to group #5):


if (!strstr($user['U_Groups'],"-5-")) {
// Display your ads here
}


Hope that helps.

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
Cheers josh, i'll take a look into that tonight, see if i can figure it out

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
ok, i tried it on addpost.php, but it didnt make any difference. I could still the advert.
As you know, 1 is the admin usergroup.

Is this part correct?

[]
// Grab the tablewrapper
list($tbopen,$tbclose) = $html -> table_wrapper();
if (!strstr($user['U_Groups'],"-1-")) {
// Adsense hack start
$adsense = "";
if ( stristr(",{$config['adsense']},", ",$Board,") ) {
include("$thispath/templates/$tempstyle/adsense.tmpl");
}
// Adsense hack finish
}
[/]

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
anybody?

Sponsored Links
Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
Hmmm, i'll try it on showflat.php tonight.
I shall not be beaten!

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
ok, i've got it working!!!!
I re-read your instructions, and tweaked a bit, and viola!

Thanks josh.

I now have google adsense displaying ONLY for my non-premium members!

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
How do I add extra groups?
I tried:

if (!strstr($user['U_Groups'],"-5-","-2-")) {

but that gave me this error on the screen.

Warning: Wrong parameter count for strstr() in /home/fordmond/public_html/ubbthreads/showflat.php on line 1324

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
if (!strstr($user['U_Groups'],"-1-")) {

becomes

if (!strstr($user['U_Groups'],"-1-") && !strstr($user['U_Groups'],"-2-") && !strstr($user['U_Groups'],"-3-")) {

or you could do a

if (strstr($user['U_Groups'],"-4-")) {

to include just the group you want.

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
aha. I wouldnt have got that in a million years!
Thanks again scroungr, I think I must owe you some beers now!

Sponsored Links
Joined: Feb 2001
Posts: 2,268
Junior Member
Junior Member
Offline
Joined: Feb 2001
Posts: 2,268
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

Joined: Aug 2004
Posts: 82
Power User
Power User
Offline
Joined: Aug 2004
Posts: 82
wow this is a nice little tweak i might have to add this baby to my site

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
Am A bit stuck trying to get this to function correctly on addpost.php

This is the code which is wrong

[]
// ---------------------
// Grab the tablewrapper
list($tbopen,$tbclose) = $html -> table_wrapper();
if (!strstr($user['U_Groups'],"-9-")) {
// Adsense hack start

$adsense = "";
if ( stristr(",{$config['adsense']},", ",$Board,") ) {
include("$thispath/templates/$tempstyle/adsense.tmpl");
}
// Adsense hack finish
[/]

I get a parse error, saying theres an unexpected $ on line 1147.

But when I go to line 1147 all thats on that line is
[]
} else {
[/]

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
theres an open { on that first if but you are not closing it.. there is no } for it

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
Ok, I've sorted out the parse error.
In the bold part of the code below you'll see I missed off the } after the adsense finished.
Only problem now is that it's not removing the adverts for group 9.
Is this because the U_groups code is below the adsense code?

[]
<?
/*
# UBB.threads, Version 6
# Official Release Date for UBB.threads Version6: 06/05/2002

# First version of UBB.threads created July 30, 1996 (by Rick Baker).
# This entire program is copyright Infopop Corporation, 2002.
# For more info on the UBB.threads and other Infopop
# Products/Services, visit: http://www.infopop.com

# Program Author: Rick Baker.
# File Version 6.5b6

# You may not distribute this program in any manner, modified or otherwise,
# without the express, written written consent from Infopop Corporation.

# Note: if you modify ANY code within UBB.threads, we at Infopop Corporation
# cannot offer you support-- thus modify at your own peril
# ---------------------------------------------------------------------------
*/

// Require the library
require ("./includes/main.inc.php");
require ("languages/{$myprefs['language']}/addpost.php");
require ("imagesizes.php");

// Define the default language varialbe, required for PHP3
$Language = $myprefs['language'];

// -------------
// Get the input
$Board = get_input("Board","post");
$Cat = get_input("Cat","post");
$Reged = get_input("Reged","post");
$page = get_input("page","post");
$what = get_input("what","post");
$vc = get_input("vc","post");
$Subject = get_input("Subject","post");
$Body = get_input("Body","post");
$preview = get_input("preview","post");
$textcont = get_input("textcont","post");
$Icon = get_input("Icon","post");
$convert = get_input("convert","post");
$postername = get_input("postername","post");
$Main = get_input("Main","post");
$Parent = get_input("Parent","post");
$ParentUser = get_input("ParentUser","post");
$oldnumber = get_input("oldnumber","post");
$fpart = get_input("fpart","post");
$replyto = get_input("replyto","post");
$IP = get_input("IP","post");
$frompreview = get_input("frompreview","post");
$PStatus = get_input("PStatus","post");
$dofav = get_input("dofav","post");
$questions = get_input("questions","post");
$day = get_input("day","post");
$month = get_input("month","post");
$year = get_input("year","post");
$hour = get_input("hour","post");
$min = get_input("min","post");
$ampm = get_input("ampm","post");
$stopday = get_input("stopday","post");
$stopmonth = get_input("stopmonth","post");
$stopyear = get_input("stopyear","post");
$stophour = get_input("stophour","post");
$stopmin = get_input("stopmin","post");
$stopampm = get_input("stopampm","post");
$enablestart = get_input("enablestart","post");
$enablestop = get_input("enablestop","post");
$noview = get_input("noview","post");
$mustvote = get_input("mustvote","post");
$addpoll = get_input("addpoll","post");
$addevent = get_input("addevent","post");
$calmonth = get_input("calmonth","post");
$calday = get_input("calday","post");
$calyear = get_input("calyear","post");
$Sticky = get_input("Sticky","post");
$announcement = get_input("announcement","post");
$addsig = get_input("addsig","post");
$quickreply = get_input("quickreply","post");

if (!$addpoll) { $questions = 0; }

// -------------------------
// Predefine a few variables
$parentboard = "";
$RealSubject = "";
$attachfile = "";
$fileinput = "";
$Pselected = "";
$canattach = "";
$PollId = "";
$extra = "";
$okay = "";
$previewpoll = "";
$Main = addslashes($Main);

$html = new html;
include("checkimages.php");

// Censor the input?
if ($config['docensor']) {
$Body = $html->do_censor($Body);
$Subject = $html->do_censor($Subject);
}

// ---------------------
// Grab the tablewrapper
list($tbopen,$tbclose) = $html -> table_wrapper();

if (!strstr($user['U_Groups'],"-9-")) {
// Adsense hack start
$adsense = "";
if ( stristr(",{$config['adsense']},", ",$Board,") ) {
include("$thispath/templates/$tempstyle/adsense.tmpl");
}
// Adsense hack finish
}

// Add a space to the end of $Body, for auto-url encoding
$Body .= " ";

$userob = new user;
$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");
if ($Reged == "y") {
$Username = $user['U_Username'];
$Username_q = addslashes($Username);
$posterid = $user['U_Number'];
$postername = $Username;
}
else {
if (!$postername) {
$postername = $ubbt_lang['ANON_TEXT'];
}
$Username_q = addslashes($postername);
$posterid = "1";
$user['U_Number'] = 1;
}

// -----------------
// Get the user info
$IP = find_environmental('REMOTE_ADDR');

// See if they are banned
$userob -> check_ban();

// Flood control settings
if (!empty($user['U_FloodControl'])) {
if ($user['U_FloodControl'] == "-1") {
$floodcontrol = $config['floodcontrol'];
}
else {
$floodcontrol = $user['U_FLoodControl'];
}
}

// ----------------------------------------------
// Let's get the groups and default flood control
if (!$user['U_Groups']) {
$user['U_Groups'] = "-4-";
$floodcontrol = $config['floodcontrol'];
$lastposttime = get_input("lastposttime","cookie");
} else {
$floodcontrol = $user['U_FloodControl'];
$lastposttime = $user['U_LastPostTime'];
}

// ---------------------------------
// Check if they can make a post yet
if ($user['U_Status'] != "Administrator" && $user['U_Status'] != "Moderator") {
if (($html->get_date() - $lastposttime) < $floodcontrol) {
$ubbt_lang['FLOODCONTROL'] = sprintf($ubbt_lang['FLOODCONTROL'],$floodcontrol);
$html->not_right($ubbt_lang['FLOODCONTROL']);
}
}

// ------------------
// Check the referer
if (!$config['disablerefer']) {
$html -> check_refer($Cat);
}

//


<----snip
[/]

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
look at your logic

if (!strstr($user['U_Groups'],"-9-")) {
// Adsense hack start
$adsense = "";
if ( stristr(",{$config['adsense']},", ",$Board,") ) {
include("$thispath/templates/$tempstyle/adsense.tmpl");
}
// Adsense hack finish
}


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..

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
but that exact code works perfectly on showflat.php....
hence my confusion.

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
so its working in showflat.php but NOT in addpost.php? whats in the

$userob = new user;
$user = $userob -> authenticate();

function? is it any different in YOUR showflat.php and addpost.php? does the addpost includ the U_Groups field?

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
This is in showflat.php
[] $userob = new user;
$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");
[/]

and this is whats in my addpost.php
[]$userob = new user;
$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");
[/]

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.
I don't know if that will affect it or not?

Joined: Oct 2003
Posts: 2,305
Old Hand
Old Hand
Joined: Oct 2003
Posts: 2,305
it will.. see your calling the U_Groups after it in the addpost.. put your code in the addpost AFTER it and try that

Joined: Jun 2001
Posts: 356
Junior Member
Junior Member
Offline
Joined: Jun 2001
Posts: 356
Yep, that fixed it.
Thanks scroungr!


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
JAISP
JAISP
PA
Posts: 449
Joined: February 2008
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
WebGuy 2
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)