View Single Post
  #1  
Old 26th February 2013, 17:17
Chez's Avatar
Chez Chez is offline
Senior Member
 
Join Date: Sep 2011
P2P
Posts: 278
Default Countdown to event
First of all the credits go to - hellix - stonebreath - putyn


Put this is you sql database.

PHP Code:
CREATE TABLE `countdow` (
  `
monthtext NOT NULL,
  `
daytext NOT NULL,
  `
yearyear(4NOT NULL,
  `
countdowtext 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 ($im000);
$orange imagecolorallocate ($im25512736);
$yellow imagecolorallocate ($im247246201);

imagestring ($im2605$arr['countdow'], $yellow);
imagestring ($im36518"[ $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_SYSOPstderr("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.

Click the image to open in full size.
__________________
http://www.bvlist.com/images/avatars/signaturepics/sigpic16443_2.gif

Last edited by Krypto; 4th August 2013 at 02:03. Reason: Removed Hot Linked Images from TorrentStrike
Reply With Quote
The Following User Says Thank You to Chez For This Useful Post:
ratza (4th August 2013)