MyBB Community Forums

Full Version: Only guest can see the adsense ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how can i edit this plug-in ? can you help me about it ? please Sad
i wanna only guest can see adsense
sorry my english very bad
Plugins code
<?php
/*
Plugin Ads after first post
(c) 2005-2006 by MyBBoard.de
Website: http://www.mybboard.de
Türkce ceviri arno düzenleme yemudira
*/
$plugins->add_hook("postbit", "adsafp2");

//Informationen zum Plugin
function adsafp2_info()
{
	return array(
		"name"        => "İlk mesajdan Sonra reklam",
		"description" => "İlk mesajlardan sonra reklamlarınızı gösterir.",
		"website"     => "http://www.mybboard.de",
		"author"      => "MyBBoard.de",
		"authorsite"  => "http://www.mybboard.de",
		"version"     => "2.0",
		);
}

// Aktivierung
function adsafp2_activate() {

    global $db;

	// Variablen für dieses Plugin einfügen
	require MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("postbit", '#<p>#', "{\$post['adsaf']}<br />");
		
	// Einstellungsgruppe hinzufügen
	$adsafp2_group = array(
		"gid" => "NULL",
		"name" => "İlk mesajda Reklam",
		"title" => "İlk mesajda Reklam ",
		"description" => "Plugin Ayarları.",
		"disporder" => "1",
		"isdefault" => "no",
		);
	$db->insert_query(TABLE_PREFIX."settinggroups", $adsafp2_group);
	$gid = $db->insert_id();
	
	// Einstellungen hinzufügen
	$adsafp2_1 = array(
		"sid" => "NULL",
		"name" => "adsafp2_code_onoff",
		"title" => "Aktif/AktifDeğil",
		"description" => "Birinci mesajdan sonra reklamlarınızın gözükmesini istiyor musunuz?",
		"optionscode" => "yesno",
		"value" => "no",
		"disporder" => "1",
		"gid" => intval($gid),
		);
	$db->insert_query(TABLE_PREFIX."settings", $adsafp2_1);
	
	$adsafp2_2 = array(
		"sid" => "NULL",
		"name" => "adsafp2_align",
		"title" => "Siralama",
		"description" => "Sıralamayı seçiniz.",
		"optionscode" => "radio\r\n1=Left\r\n2=Center\r\n3=Right",
		"value" => "2",
		"disporder" => "2",
		"gid" => intval($gid),
		);
	$db->insert_query(TABLE_PREFIX."settings", $adsafp2_2);
	
	$adsafp2_3 = array(
		"sid" => "NULL",
		"name" => "adsafp2_mode",
		"title" => "Mode",
		"description" => "Reklamlarınızın nerede gözükmesini istiyorusunuz?",
		"optionscode" => "radio\r\n1=After first post on each page (Default)\r\n2=After the first post and then after every x posts\r\n3=After every x posts",
		"value" => "1",
		"disporder" => "3",
		"gid" => intval($gid),
		);
	$db->insert_query(TABLE_PREFIX."settings", $adsafp2_3);
	
	$adsafp2_4 = array(
		"sid" => "NULL",
		"name" => "adsafp2_afterxposts",
		"title" => "Number of posts",
		"description" => "Enter the number of posts after that you want to display the ads (only necessary for the second mode)",
		"optionscode" => "text",
		"value" => "5",
		"disporder" => "4",
		"gid" => intval($gid),
		);
	$db->insert_query(TABLE_PREFIX."settings", $adsafp2_4);
	
	$adsafp2_5 = array(
		"sid" => "NULL",
		"name" => "adsafp2_code",
		"title" => "Code",
		"description" => "Adslenin HTML kodlarını giriniz.",
		"optionscode" => "textarea",
		"value" => "",
		"disporder" => "5",
		"gid" => intval($gid),
		);
	$db->insert_query(TABLE_PREFIX."settings", $adsafp2_5);
	
	// settings.php erneuern
	rebuild_settings();
}

// Deaktivierung
function adsafp2_deactivate() {

    global $db;

	// Variablen von dieses Plugin entfernen
	require MYBB_ROOT."/inc/adminfunctions_templates.php";
	find_replace_templatesets("postbit", "#{\$post['adsaf']}#", "", 0);
	
	// Einstellungsgruppen löschen
	$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='Ads after first post'");
	$g = $db->fetch_array($query);
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='".$g['gid']."'");

	// Einstellungen löschen
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='".$g['gid']."'");

	// Rebuilt settings.php
	rebuild_settings();
}

// Funktionen
function adsafp2($post) {

    global $mybb, $postcounter;
    
    $post['adsaf'] = "";
    if ($mybb->settings['adsafp2_code_onoff'] != "no") {

        // Alignment
        switch ($mybb->settings['adsafp2_align']) {
        case "1":
            $ads_align = "left";
            break;
        case "2":
            $ads_align = "center";
            break;
        case "3":
            $ads_align = "right";
            break;
        }

        // Ads after first post
        if ($mybb->settings['adsafp2_mode'] == "1") {
            if (($postcounter - 1) % $mybb->settings['postsperpage'] == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }

        // Ads after first post and then every x posts
        if ($mybb->settings['adsafp2_mode'] == "2") {
            if ($postcounter == "1" || ($postcounter - 1) % ($mybb->settings['adsafp2_afterxposts']) == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }
    
        // Ads after every x posts
        if ($mybb->settings['adsafp2_mode'] == "3") {
            if ($postcounter % ($mybb->settings['adsafp2_afterxposts']) == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }
    }
}

// Einstellungen erneuern
if(!function_exists("rebuild_settings")) {
	function rebuild_settings() {
		
        global $db;
		
        $query = $db->query("SELECT * FROM ".TABLE_PREFIX."settings ORDER BY title ASC");
		while($setting = $db->fetch_array($query)) {
			$setting['value'] = addslashes($setting['value']);
			$settings .= "\$settings['".$setting['name']."'] = \"".$setting['value']."\";\n";
		}
		$settings = "<?php\n/*********************************\ \n  DO NOT EDIT THIS FILE, PLEASE USE\n  THE SETTINGS EDITOR\n\*********************************/\n\n$settings\n?>";
		$file = fopen(MYBB_ROOT."/inc/settings.php", "w");
		fwrite($file, $settings);
		fclose($file);
		
	}
}
?>
You can use my inline_ads plugin which has settings for groups that are exempt.
labrocca Wrote:You can use my inline_ads plugin which has settings for groups that are exempt.

i try inline_ads its a great
but i want to
like this
[Image: adszxo5.jpg]
My plugin doesn't do that. Also that might be against adsense TOS.
Find
  // Ads after first post
        if ($mybb->settings['adsafp2_mode'] == "1") {
            if (($postcounter - 1) % $mybb->settings['postsperpage'] == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }

        // Ads after first post and then every x posts
        if ($mybb->settings['adsafp2_mode'] == "2") {
            if ($postcounter == "1" || ($postcounter - 1) % ($mybb->settings['adsafp2_afterxposts']) == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }
    
        // Ads after every x posts
        if ($mybb->settings['adsafp2_mode'] == "3") {
            if ($postcounter % ($mybb->settings['adsafp2_afterxposts']) == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }

Replace with
if(!$mybb->user['uid'])
{

// Ads after first post
        if ($mybb->settings['adsafp2_mode'] == "1") {
            if (($postcounter - 1) % $mybb->settings['postsperpage'] == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }

        // Ads after first post and then every x posts
        if ($mybb->settings['adsafp2_mode'] == "2") {
            if ($postcounter == "1" || ($postcounter - 1) % ($mybb->settings['adsafp2_afterxposts']) == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }
    
        // Ads after every x posts
        if ($mybb->settings['adsafp2_mode'] == "3") {
            if ($postcounter % ($mybb->settings['adsafp2_afterxposts']) == "0") {
                $post['adsaf'] = "<div style=\"text-align:".$ads_align.";\">".stripslashes($mybb->settings['adsafp2_code'])."</div>";
            }
        }
}
else
{
 $post['adsaf'] = "";
}
The new version 2.2 which is waiting for validation atm has the functionality to show ads for certain usergroups only.