First of all the credits go to - hellix - stonebreath - putyn
Put this is you sql database.
PHP Code:
CREATE TABLE `countdow` (
`month` text NOT NULL,
`day` text NOT NULL,
`year` year(4) NOT NULL,
`countdow` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Now you name this cimage.php and put it in your root
PHP Code:
<?
require_once ("include/bittorrent.php");
dbconn();
$res = mysql_query("SELECT month, day, year, countdow FROM countdow") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
echo("<b>Countdown is empty</b>\n");
else
while ($arr = mysql_fetch_assoc($res))
{
$target = mktime(0,0,0,$arr['month'],$arr['day'],$arr['year']);
$diff = $target - time();
$days = ($diff - ($diff % 86400)) / 86400;
$diff = $diff - ($days * 86400);
$hours = ($diff - ($diff % 3600)) / 3600;
$diff = $diff - ($hours * 3600);
$minutes = ($diff - ($diff % 60)) / 60;
$diff = $diff - ($minutes * 60);
$seconds = ($diff - ($diff % 1)) / 1;
header ("Content-type: image/png");
$imgname = "pic/countdown.png";
$im = @imagecreatefrompng ($imgname);
$background_color = imagecolorallocate ($im, 0, 0, 0);
$orange = imagecolorallocate ($im, 255, 127, 36);
$yellow = imagecolorallocate ($im, 247, 246, 201);
imagestring ($im, 2, 60, 5, $arr['countdow'], $yellow);
imagestring ($im, 3, 65, 18, "[ $days day(s) ] [ $hours hour(s) ] [ $minutes minute(s) ] [ $seconds second(s) ]", $orange);
imagepng ($im);
imagedestroy ($im);
} {
}
?>
Now this countdown.php also in your root.
PHP Code:
<?php
require_once ("include/bittorrent.php");
dbconn();
loggedinorreturn();
//referer();
if (get_user_class() < UC_SYSOP) stderr("Error", "Permission denied");
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if ($_POST["delete"])
mysql_query("DELETE FROM countdow");
header("Location: $BASEURL/countdown.php");
if ($_POST["month"] == "" || $_POST["day"] == "" || $_POST["year"] == "" || $_POST["countdow"] == "")
stderr("Error", "Missing form data.");
$month = htmlspecialchars($_POST["month"]);
$day = htmlspecialchars($_POST["day"]);
$year = htmlspecialchars($_POST["year"]);
$countdow = htmlspecialchars($_POST["countdow"]);
$sql = "INSERT INTO countdow (month, day, year, countdow) VALUES ('$month', '$day', '$year', '$countdow')";
$result = mysql_query($sql);
header("Location: $BASEURL/countdown.php");
die;
}
stdhead("Countdown");
$res = mysql_query("SELECT month, day, year, countdow FROM countdow") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) == 0)
echo("<h1>Add countdown</h1>
<form method=post action=countdown.php>
<table border=1 width=95% cellspacing=0 cellpadding=5>
<tr><td class=rowhead>Month of the countdown</td><td><input type=text name=month size=5></td></tr>
<tr><td class=rowhead>Day of the countdown</td><td><input type=text name=day size=5></td></tr>
<tr><td class=rowhead>Year of the countdown</td><td><input type=text name=year size=10></td></tr>
<tr><td class=rowhead>Countdown to</td><td><input type=text name=countdow size=70></td></tr></select></td></tr><tr><td colspan=2 align=center><input type=submit class='groovybutton' value='Okay' class=btn></td></tr>
</table>
</form>\n");
else
{
while ($arr = mysql_fetch_assoc($res))
{
echo("<table border=1 cellspacing=0 width=95% cellpadding=5>\n");
echo("<tr><td align=left><b>Month</b></td><td align=left><b>Day</b></td><td align=left><b>Year</b></td><td align=left><b>Countdow to</b></td></tr>\n");
echo("<tr><td><font color=black>".htmlspecialchars($arr['month'])."</td><td><font color=black>".htmlspecialchars($arr['day'])."</td><td align=left><font color=black>".htmlspecialchars($arr['year'])."</font><td align=left><font color=black>".htmlspecialchars($arr['countdow'])."</font></font></font></td></tr>\n");
}
echo("</table><p></p>");
echo("<form method=post action=countdown.php><tr><td colspan=2 align=center><input type=submit name='delete' class='groovybutton' value='Delete'></td></tr>");
}
?>
<?php stdfoot(); ?>
put this where you want it to show
PHP Code:
echo("<img src='cimage.php'>");
Finally put this image in your pic folder.