2006-08-26, 12:56 AM
How do I do it? I can't seem to get any progress on this plugin I am trying to make.
I have tried this for 3 hours with no luck. Not even close to executing. I get nothing each and every time. This is getting frustrating. Some better plugin help would be nice if you want more developers here.
<?php
/*
Plugin Ads after first post
(c) 2005 by MyBBoard.de
Website: http://www.mybboard.de
*/
$plugins->add_hook("postbit","adsafp");
// $adsafp = $plugins->run_hooks("postbit", $adsafp); //didn't work
// $plugins->add_hook("postbit", "adsafp", 10, "adsafp.php"); //didn't work
//Informationen zum Plugin
function adsafp_info()
{
return array(
"name" => "Ads after first post",
"description" => "Displays ads after the posts in your forums.",
"website" => "http://www.mybboard.de",
"author" => "MyBBoard.de",
"authorsite" => "http://www.mybboard.de",
"version" => "1.5",
);
}
// Aktivierung
function adsafp_activate() {
global $db;
// Variablen für dieses Plugin einfügen
require "./inc/adminfunctions_templates.php";
find_replace_templatesets("postbit", '#\$seperator#', "\$adsafp");
// Einstellungsgruppe hinzufügen
$adsafp_group = array(
"gid" => "NULL",
"name" => "Ads after first post",
"description" => "Settings for the plugin.",
"disporder" => "1",
"isdefault" => "no",
);
$db->insert_query(TABLE_PREFIX."settinggroups", $adsafp_group);
$gid = $db->insert_id();
// Einstellungen hinzufügen
$adsafp_1 = array(
"sid" => "NULL",
"name" => "adsafp_code_onoff",
"title" => "Activate/Deactivate",
"description" => "Do you want to show ads after posts?",
"optionscode" => "yesno",
"value" => "no",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $adsafp_1);
$adsafp_2 = array(
"sid" => "NULL",
"name" => "adsafp_align",
"title" => "Alignment",
"description" => "Choose the alignment.",
"optionscode" => "radio\r\n1=Left\r\n2=Center\r\n3=Right",
"value" => "2",
"disporder" => "2",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $adsafp_2);
$adsafp_3 = array(
"sid" => "NULL",
"name" => "adsafp_mode",
"title" => "Mode",
"description" => "Where do you want to show the ads?",
"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", $adsafp_3);
$adsafp_4 = array(
"sid" => "NULL",
"name" => "adsafp_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", $adsafp_4);
$adsafp_5 = array(
"sid" => "NULL",
"name" => "adsafp_code",
"title" => "Code",
"description" => "Enter the HTML code for the ads.",
"optionscode" => "textarea",
"value" => "",
"disporder" => "5",
"gid" => intval($gid),
);
$db->insert_query(TABLE_PREFIX."settings", $adsafp_5);
// settings.php erneuern
rebuild_settings();
}
// Deaktivierung
function adsafp_deactivate() {
global $db;
// Variablen von dieses Plugin entfernen
require "./inc/adminfunctions_templates.php";
find_replace_templatesets("postbit", '#\$adsafp#', "\$seperator", 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 adsafp($adsafp)
{
global $post, $db, $mybb, $postbit, $adsafp; // covering all possible globals
$adsafp = "<tr><td class=\"trow_sep\" colspan=\"2\">Test Code</td></tr>";
return $adsafp;
}
// 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("./inc/settings.php", "w");
fwrite($file, $settings);
fclose($file);
}
}
?>
I have tried this for 3 hours with no luck. Not even close to executing. I get nothing each and every time. This is getting frustrating. Some better plugin help would be nice if you want more developers here.