Hi,
I developed a small plugin for my community's forum. The plugin is the following:
http://casualbananas.com/forums/donationbar.php
Currently I included it into my index page by inserting a iframe. I'd like to actually make it work like a plugin. Could someone please explain me how I could include that into a template using a {<name>}, no idea what it is called.
Could anyone help me with this?
<?php
error_reporting(E_ALL);
define('IN_MYBB', 1);
require "./global.php";
add_breadcrumb("Donation Bar", "communitystats.php");
$goal = 250;
$banana_price = 0.001;
$adjustment = 35.17;
$db->connect;
if(date('m') + 1 > 12)
{
$year_start = date('Y');
$year_end = date('Y') + 1;
}
else
{
$year_start = date('Y');
$year_end = date('Y');
}
if(date('d') >= 19)
{
$month_start = date('m');
$month_end = date('m') + 1;
}
else
{
$month_start = date('m') - 1;
$month_end = date('m');
}
$query = "
SELECT
(SUM(amount) * ".$banana_price.") AS db_amount
FROM
dsHz5_buycredit_logs
WHERE
time > ".strtotime($year_start."-".$month_start."-18")."
AND
time < ".strtotime($year_end."-".$month_end."-19")."";
$result = $db->query($query);
if($db->num_fields($result) >= 1) {
$rows=$db->fetch_array($result);
$amount = $rows['db_amount'];
}else{
$amount = 0;
}
$percentage = round(((($amount+$adjustment) * 96.6 / 100) / $goal) * 100);
if($percentage >= 100) {
$percentage = 100;
$string = "Goal reached";
}else{
$percentage = round(((($amount+$adjustment) / $goal) * 96.6 / 100) * 100);
$string = $percentage."%";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
echo "<link href=\"http://casualbananas.com/query/fonts.css\" type=\"text/css\" rel=\"stylesheet\" />";
echo "<link href=\"http://casualbananas.com/forums/inc/donationbar_css.php?width=".$percentage."\" type=\"text/css\" rel=\"stylesheet\" />";
?>
<title>Donation bar</title></head>
<body width="100%" marginheight="0" marginwidth="0">
<div id="donator_wrapper">
<h1>Donation Goal</h1>
<span><span style="text-decoration: underline;">Note:</span> NEW GOAL! If we reach $250, we'll hand out a $30 AND a $15 game of choice in the raffle. Right now we'll only do $30.</span>
<ul>
<?php
echo "<li class=\"roundbar\"><span class=\"generic_width\"></span><span class=\"generic_text\"><a href=\"http://casualbananas.com/forums/buy.php\" target=\"_blank\">".$string." ($".number_format(($amount+$adjustment)*96.6/100, 2, '.', ',')." / $".number_format($goal, 2, '.', ',').")</a></span></li>";
?>
</ul>
</div>
</body>
</html>
This is my code, I know it's shitty-written, I just started doing PHP and I'll have to clean up my code, move some PHP to MySQL because of it's speed, and these kind of things.
Could you please explain me what I'd have to do for this?
Or are there guides about how to create plugins?