<?php
/*
*
** MyBux mod
** Copyright © Matthew Jeffers 2006 (http://www.coolestech.com/)
** Special Thanks: DrPoodle (http://www.drpoodle.com/) for allowing me to update war mod originally for cash mod
** MiNT (www.mintspad.com), for helping with PHP errors
** Zaher1988(http://www.thetechex.net/), for helping with some errors in my PHP and MySQL coding
** Snake (http://www.blakemiller.org) fixed some problems
** Chris Boulton(http://www.mybboard.com/), for helping with the MyBB hooks
** Darkteller for helping with the plugin
** Tikitiki (http://www.rct3x.net/) for cleaning up the code. :)
*
*/
if(!defined("IN_MYBB"))
{
die("This file cannot be accessed directly.");
}
// Hooks
$plugins->add_hook('postbit', 'mybux_bux_total');
$plugins->add_hook('datahandler_post_insert_post', 'mybux_post_bux');
$plugins->add_hook('datahandler_post_insert_thread', 'mybux_thread_bux');
$plugins->add_hook("pre_output_page", "mybux_copywrite_function");
// Plugin Info
function mybux_info()
{
global $db;
return array(
"name" => "MyBux",
"description" => "A plugin for allowing members to collect virtual cash.",
"website" => "http://www.mybboard.com",
"author" => "Coolest Tech",
"authorsite" => "http://www.coolestech.com",
"version" => "0.0.2.4 Beta",
);
}
function mybux_copywrite_function($page)
{
$page = str_replace("Copyright © 2002-2007 <strong><a href=\"http://www.mybboard.com\" target=\"_blank\">MyBB Group</a></strong>", "Copyright © 2002-2007 <strong><a href=\"http://www.mybboard.com\" target=\"_blank\">MyBB Group</a></strong> <br />
MyBux by <a href=\"http://www.coolestech.com/\">Coolest Tech</a> <a href=\"http://forums.coolestech.com/\">Forums</a> <br />", $page);
return $page;
}
function mybux_activate()
{
global $db;
require MYBB_ROOT.'inc/adminfunctions_templates.php';
// Alter Users Table
$db->query("ALTER TABLE `".TABLE_PREFIX."users` ADD `bux` INT( 10 ) NOT NULL DEFAULT '100' AFTER `postnum`");
$bux_group = array(
"gid" => NULL,
"name" => "mybux",
"title" => "MyBux",
"description" => "Settings for MyBux",
"disporder" => "99",
"isdefault" => "no",
);
// Insert The Setting Group
$db->insert_query("settinggroups", $bux_group);
$gid = $db->insert_id();
// Gather Settings Information
$mybux_setting_1 = array(
"sid" => NULL,
"name" => "bux_post",
"title" => "Bux for new replies?",
"description" => "How much bux should users get for replying to threads?",
"optionscode" => "text",
"value" => "10",
"disporder" => "1",
"gid" => $gid,
);
$mybux_setting_2 = array(
"sid" => NULL,
"name" => "bux_thread",
"title" => "Bux for New Threads?",
"description" => "How much should users get for new threads?",
"optionscode" => "text",
"value" => "20",
"disporder" => "2",
"gid" => $gid,
);
$mybux_setting_3 = array(
"sid" => NULL,
"name" => "bux_poll",
"title" => "Bux for New Polls?",
"description" => "How much should users get for new threads?",
"optionscode" => "text",
"value" => "20",
"disporder" => "3",
"gid" => $gid,
);
$mybux_setting_4 = array(
"sid" => NULL,
"name" => "bux_reg",
"title" => "Bux for registering?",
"description" => "How much bux should users get for registering?",
"optionscode" => "text",
"value" => "100",
"disporder" => "4",
"gid" => $gid,
);
$mybux_setting_5 = array(
"sid" => NULL,
"name" => "bux_symbol",
"title" => "Currency Symbol?",
"description" => "Choose a symbol that your forums will be using to define your currency.",
"optionscode" => "text",
"value" => "$",
"disporder" => "5",
"gid" => $gid,
);
$mybux_setting_6 = array(
"sid" => NULL,
"name" => "bux_name",
"title" => "Currency Name?",
"description" => "What is the name of your currency?",
"optionscode" => "text",
"value" => "Bux",
"disporder" => "6",
"gid" => $gid,
);
$mybux_setting_7 = array(
"sid" => NULL,
"name" => "bux_pollvote",
"title" => "Bux for Poll Vote?",
"description" => "How much bux should users get poll voting?",
"optionscode" => "text",
"value" => "1",
"disporder" => "7",
"gid" => $gid,
);
$mybux_setting_8 = array(
"sid" => NULL,
"name" => "bux_pollvotemultiple",
"title" => "Bux for multiple Poll Vote?",
"description" => "How much bux should users get for multiple poll voting? Set to -1 for 0, to normalize +1.",
"optionscode" => "text",
"value" => "-0",
"disporder" => "8",
"gid" => $gid,
);
$mybux_setting_9 = array(
"sid" => NULL,
"name" => "bux_pollvote",
"title" => "Bux for multiple Poll Vote?",
"description" => "How much bux should users get for multiple poll voting? Set to -1 for 0, to normalize +1.",
"optionscode" => "text",
"value" => "-0",
"disporder" => "9",
"gid" => $gid,
);
$mybux_setting_10 = array(
"sid" => NULL,
"name" => "bux_bbcode",
"title" => "BB code",
"description" => "Should BB code count toward money?",
"optionscode" => "text",
"value" => "yes",
"disporder" => "10",
"gid" => $gid,
);
// Insert the Settings
$db->insert_query('settings', $mybux_setting_1);
$db->insert_query('settings', $mybux_setting_2);
$db->insert_query('settings', $mybux_setting_3);
$db->insert_query('settings', $mybux_setting_4);
$db->insert_query('settings', $mybux_setting_5);
$db->insert_query('settings', $mybux_setting_6);
$db->insert_query('settings', $mybux_setting_7);
$db->insert_query('settings', $mybux_setting_8);
$db->insert_query('settings', $mybux_setting_9);
$db->insert_query('settings', $mybux_setting_10);
// Modify the Templates - For the future...
}
// Deinstall the mod!!!!!
// Deinstall! ---------------------------------- err
function mybux_deactivate()
{
global $db;
$db->delete_query('settinggroups', "name='mybux_group'");
// Remove User Table Stuff
$db->query("ALTER TABLE `".TABLE_PREFIX."users` DROP `bux`;");
// Remove Templates
// Delete The Settings
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN (
'bux_post',
'bux_thread',
'bux_poll',
'bux_reg',
'bux_symbol',
'bux_name',
'bux_pollvote',
'bux_pollvotemultiple',
'bux_pollvote',
'bux_bbcode'
)");
$db->delete_query('settinggroups', "name='mybux'");
}
function mybux_bux_total(&$post)
{
global $mybb, $db;
$query = $db->simple_select("users", "bux", "uid='{$post['uid']}'");
$bux = $db->fetch_field($query, 'bux');
$post['user_details'] = "{$post['user_details']} ".$mybb->settings['bux_name'].": ".$mybb->settings['bux_symbol']."<b>{$bux}</b>";
}
function mybux_thread_bux()
{
global $db, $mybb;
$db->query("UPDATE ".TABLE_PREFIX."users SET bux=bux+'".$mybb->settings['bux_thread']."' WHERE uid='".$mybb->user['uid']."'");
}
function mybux_post_bux()
{
global $db, $mybb;
$db->query("UPDATE ".TABLE_PREFIX."users SET bux=bux+'".$mybb->settings['bux_post']."' WHERE uid='".$mybb->user['uid']."'");
}
?>