To jest tylko wersja do druku, aby zobaczyć pełną wersję tematu, kliknij TUTAJ
phpBB2 by Przemo
Support forów phpBB2 modified by Przemo

English version - Google Adsense as second post in a topic

JA$ON - 17-12-2006, 19:02
Temat postu: Google Adsense as second post in a topic
Hi, i have a really usefull Mod here that is really easy to install..
This is what it does:
Whenever someone creates a topic, an answer is automatically created which contains google adsense advertisemend.
It looks like this: Demo

You only need to register at Google Adsense and then do this:

Open viewtopic.php and search for:
Kod:
   $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

replace with:
Kod:
//
   // Google Ad Mod
   //
   /* deleted
   $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
   $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
   */
   $row_color = ( !($num_post % 2) ) ? $theme['td_color1'] : $theme['td_color2']; 
   $row_class = ( !($num_post % 2) ) ? $theme['td_class1'] : $theme['td_class2']; 
   $num_post ++;
   // Ende

Search for:
Kod:
 'U_MINI_POST' => $mini_post_url,
      'U_POST_ID' => $postrow[$i]['post_id'])
   );

after that, add:
Kod:
// Google Ad Mod
if (!($userdata['session_logged_in']))
{
if($i == 0)
   {
       $row_color = ( !($num_post % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
       $row_class = ( !($num_post % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
       $num_post ++;
       $message = '
      <script type="text/javascript"><!--
google_ad_client = "pub-4267689453885886";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="";
google_color_border = "DEE3E7";
google_color_bg = "DEE3E7";
google_color_link = "006699";
google_color_url = "006699";
google_color_text = "000000";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
';
       $template->assign_block_vars('postrow', array(
           'ROW_COLOR' => '#' . $row_color,
           'ROW_CLASS' => $row_class,
           'POSTER_NAME' => 'Google',
           'POST_DATE' => '',
           'POST_SUBJECT' => 'Anzeige',
           'MESSAGE' => $message,
           'MINI_POST_IMG' => $mini_post_img,
           'U_POST_ID' => '0'
       ));
   }
}
// Ende Google Ad Mod

Replace the Script part with your Google Adsense Code!


It works with normal phpBB but I have a problem trying to get it work with Przemo's phpBB because of this part:
Kod:
   $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

It does not exist.. :?
Can someone please take a look at the Mod and tell me how to use with Przemo's phpBB..
Thanks.

riverkqj - 22-01-2007, 15:19

yes in would love to know this too :)
DarksterV2 - 22-01-2007, 17:33

Why not just use this mod here.

See a demo at my forum here.

riverkqj - 23-01-2007, 20:55

Darkster ive used the adsense you recommended but how do you make it look like a post, if you look at mine it looks horrible

www.tottenhamhotspurs.tv/forum/

DarksterV2 - 24-01-2007, 13:23

You can easily set it in the ACP to look like a normal post, I just went a little extra and added a rank and avatar.
JA$ON - 24-01-2007, 13:28

DarksterV2 napisał/a:
Why not just use this mod here.

See a demo at my forum here.

thanks i'll try this! :D
edit: I tryed that Mod but I have a problem with the installation, I cant follow the instructions because i cant find some things in my files because they are different from the original phpbb files and because i already modded a lot...
can someone maybe help me with installing this mod please? i could send you the files in which i have a problem per PM or Email. I think its only 2 files, the other ones seem to be correct.

i need to get this mod installed but i really need some help with this..

DarksterV2 - 24-01-2007, 20:59

Funny, I found all the codes, which files are you having a problem with and I'll give you a hand.
JA$ON - 26-01-2007, 10:05

As I said, i can find all the code pieces exept from this one:
Kod:
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

but i found a similar piece of code that looks like this:
Kod:
'ROW_COLOR' => '#' . (!($i % 2)) ? $theme['td_color1'] : $theme['td_color2'],
'ROW_CLASS' => (!$row_class) ? (!($i % 2)) ? $theme['td_class1'] : $theme['td_class2'] : $row_class,

can i send you my viewtopic.php file so that you can take a look at it please?
im desperately trying to get this mod working but i dont know how...

riverkqj - 26-01-2007, 13:32

Darkster the missing threads arnt there , you managed to find another way of doing it for me about 4-5 months ago....

Cytat:
You can easily set it in the ACP to look like a normal post, I just went a little extra and added a rank and avatar.


How do i do that ?

Ja$on here is a copy of my viewtopic.php ,

Just find the part you cant find and do the same in yours

DarksterV2 - 27-01-2007, 15:56

Sorry guys here's what I did.

Open viewtopic.php

Find:

Kod:
$user_agent = ($board_config['cagent'] && $postrow[$i]['user_agent'] && !$ignore_this_post && $show_post && $userdata['cagent']) ? unserialize($postrow[$i]['user_agent']) : '';


After Add:

Kod:
$inline_ad_code = '';
    $display_ad = ($i == $board_config['ad_after_post'] - 1) || (($board_config['ad_every_post'] != 0) && ($i + 1) % $board_config['ad_every_post'] == 0);
       //This if statement should keep server processing down a bit
       if ($display_ad)
       {
           $display_ad = ($board_config['ad_who'] == ALL) || ($board_config['ad_who'] == ANONYMOUS && $userdata['user_id'] == ANONYMOUS) || ($board_config['ad_who'] == USER && $userdata['user_id'] != ANONYMOUS);
           $ad_no_forums = explode(",", $board_config['ad_no_forums']);
        for ($a=0; $a < count($ad_no_forums); $a++){
            if ($forum_id == $ad_no_forums[$a]){
                $display_ad = false;
                break;   
            }
        }
        if ($board_config['ad_no_groups'] != '')
        {
        $ad_no_groups = explode(",", $board_config['ad_no_groups']);
           $sql = "SELECT 1
                   FROM " . USER_GROUP_TABLE . "
                   WHERE user_id=" . $userdata['user_id'] . " AND (group_id=0";
           for ($a=0; $a < count($ad_no_groups); $a++){
            $sql .= " OR group_id=" . $ad_no_groups[$a];
           }
           $sql .= ")";
           if ( !($result = $db->sql_query($sql)) )
           {
            message_die(GENERAL_ERROR, 'Could not query ad information', '', __LINE__, __FILE__, $sql);
           }
           if ($row = $db->sql_fetchrow($result)){
               $display_ad = false;
           }
        }
        if (($board_config['ad_post_threshold'] != '') &&($userdata['user_posts'] >= $board_config['ad_post_threshold']))
        {
            $display_ad = false;   
        }
       }
       //check once more, for server performance
      
       if ($display_ad)
       {
           $sql = "SELECT a.ad_code
                FROM " . ADS_TABLE . " a";
           if ( !($result = $db->sql_query($sql)) )
        {
            message_die(GENERAL_ERROR, 'Could not query ad information', '', __LINE__, __FILE__, $sql);
        }
        $adRow = array();
        $adRow = $db->sql_fetchrowset($result);
        srand((double)microtime()*1000000);
        $adindex = rand(1, $db->sql_numrows($result)) - 1;
        $db->sql_freeresult($result);
           $inline_ad_code = $adRow[$adindex]['ad_code'];
       }

JA$ON - 27-01-2007, 17:49

DarksterV2 napisał/a:
Sorry guys here's what I did.

Open viewtopic.php

Find:

Kod:
$user_agent = ($board_config['cagent'] && $postrow[$i]['user_agent'] && !$ignore_this_post && $show_post && $userdata['cagent']) ? unserialize($postrow[$i]['user_agent']) : '';


After Add:

Kod:
$inline_ad_code = ' I HAVE PUT MY ADSENSE CODE HERE! WAS THAT RIGHT?';
    $display_ad = ($i == $board_config['ad_after_post'] - 1) || (($board_config['ad_every_post'] != 0) && ($i + 1) % $board_config['ad_every_post'] == 0);
       //This if statement should keep server processing down a bit
       if ($display_ad)
       {
           $display_ad = ($board_config['ad_who'] == ALL) || ($board_config['ad_who'] == ANONYMOUS && $userdata['user_id'] == ANONYMOUS) || ($board_config['ad_who'] == USER && $userdata['user_id'] != ANONYMOUS);
           $ad_no_forums = explode(",", $board_config['ad_no_forums']);
        for ($a=0; $a < count($ad_no_forums); $a++){
            if ($forum_id == $ad_no_forums[$a]){
                $display_ad = false;
                break;   
            }
        }
        if ($board_config['ad_no_groups'] != '')
        {
        $ad_no_groups = explode(",", $board_config['ad_no_groups']);
           $sql = "SELECT 1
                   FROM " . USER_GROUP_TABLE . "
                   WHERE user_id=" . $userdata['user_id'] . " AND (group_id=0";
           for ($a=0; $a < count($ad_no_groups); $a++){
            $sql .= " OR group_id=" . $ad_no_groups[$a];
           }
           $sql .= ")";
           if ( !($result = $db->sql_query($sql)) )
           {
            message_die(GENERAL_ERROR, 'Could not query ad information', '', __LINE__, __FILE__, $sql);
           }
           if ($row = $db->sql_fetchrow($result)){
               $display_ad = false;
           }
        }
        if (($board_config['ad_post_threshold'] != '') &&($userdata['user_posts'] >= $board_config['ad_post_threshold']))
        {
            $display_ad = false;   
        }
       }
       //check once more, for server performance
      
       if ($display_ad)
       {
           $sql = "SELECT a.ad_code
                FROM " . ADS_TABLE . " a";
           if ( !($result = $db->sql_query($sql)) )
        {
            message_die(GENERAL_ERROR, 'Could not query ad information', '', __LINE__, __FILE__, $sql);
        }
        $adRow = array();
        $adRow = $db->sql_fetchrowset($result);
        srand((double)microtime()*1000000);
        $adindex = rand(1, $db->sql_numrows($result)) - 1;
        $db->sql_freeresult($result);
           $inline_ad_code = $adRow[$adindex]['ad_code'];
       }


when i did that in my viewtopic.php nothing changed.. theres no adnsese showing up after every first post.. :(

DarksterV2 - 28-01-2007, 15:54

Did you do the rest of the edits in that file?
JA$ON - 28-01-2007, 16:21

you mean the rest of the instructions that i postet on the first post?
if so: yes i did them.

DarksterV2 - 28-01-2007, 21:30

Hmm.

1. Make sure you followed the instructions in the install file completely.

2. Make sure you made the SQL changes in your database

3. Make sure you set the banner code,etc via the ACP.

If you do all this it will work because I've had it working for months at my site.

JA$ON - 29-01-2007, 00:36

i cant do the following step:

Cytat:
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_header.tpl
#
#-----[ FIND ]------------------------------------------
#
.helpline { background-color: {T_TR_COLOR2}; border-style: none; }
#
#-----[ AFTER, ADD ]------------------------------------------
#
td.inlineadtitle {
background-color: {T_TR_COLOR3}; border: {T_TH_COLOR3}; border-style: solid; border-width: 1px;
}
td.inlinead {
background-color: {T_TR_COLOR3}; border: {T_TH_COLOR3}; border-style: solid; border-width: 1px; text-align: center;
}
#


because i dont have this line:
Cytat:
.helpline { background-color: {T_TR_COLOR2}; border-style: none; }


what should i do?

edit:

It does work now even though i didnt do the step above.
but it looks strange, it looks like this:
View Example
and as you can see, the google mod gets the statistics of the profile of the first poster. but the google bot is not supposed to have any level, hp, mp, country flag etc.
what can i do so that the bot doesn't steal the statistics of the poster above it??



Powered by phpBB modified by Przemo © 2003 phpBB Group