discourse-legacysite-perl/site/slowtwitch.com/www/tick/ticks.php
2024-06-17 22:30:36 +10:00

219 lines
6.8 KiB
PHP

<?require ("global.php");?>
<?php
$userID = 0;
if (isset($_COOKIE['userID'])) { $userID = $_COOKIE['userID']; }
else { header("Location: /tick/login.html"); }
$stageID = 0;
if (isset($_COOKIE['stageID'])) { $stageID = $_COOKIE['stageID']; }
else { header("Location: /tick/stages.php"); }
$query = "SELECT events.name as event_name, stages.*, DATE_FORMAT(stages.date, '%b %e, %Y') AS datef FROM events, stages WHERE events.ID = stages.eventID AND stages.ID = $stageID AND events.userID = $userID";
$result = mysql_query($query, $db);
if ($result)
{
while ($r = mysql_fetch_array($result))
{
$event_name = $r['event_name'];
$stage_string = "[${r['datef']}] ${event_name} ${r['name']}";
}
}
mysql_free_result($result);
$ID = 0;
$timestamp = ''; $year = 0; $month = 0; $day = 0;
$hour = 0; $minute = 0; $second = 0;
$headline = '';
$body = '';
if (isset($_GET['ID']))
{
$ID = $_GET["ID"];
$query = "SELECT * FROM ticks WHERE ID = $ID";
$result = mysql_query($query, $db);
if ($result)
{
while ($r = mysql_fetch_array($result))
{
$stageID = $r['stageID'];
$timestamp = $r['timestamp'];
list($date, $time) = split(" ", $timestamp);
list($year, $month, $day) = split("-", $date);
list($hour, $minute, $second) = split(":", $time);
$headline = $r['headline'];
$body = $r['body'];
}
}
mysql_free_result($result);
}
?>
<html>
<head>
<title>OneTicker :: Ticks</title>
<link rel=stylesheet type="text/css" href="tick.css">
<script src="banner.js" type="text/javascript"></script>
</head>
<body bgcolor=#000000 marginheight=4 marginwidth=15 leftmargin=15 topmargin=4>
<script type="text/javascript">banner(3);</script>
<form name="ticks" action="ticks_add.php" method="post">
<input type="hidden" name="ID" value="<? echo $ID ?>">
<input type="hidden" name="stageID" value="<? echo $stageID ?>">
<table border=0 cellspacing=1 cellpadding=1 width="480">
<tr>
<td><div class=text><b>Stage:</b></div></td>
<td><div class=text><? echo "$stage_string"; ?></div></td>
</tr>
<tr>
<td><div class=text><b>Date:</b></div></td>
<td><div class=text>
<select class=blacktext name=month>
<option value="1"<? if (($ID == 0 && date('m') == '01') || ($month == 1)) { echo " selected"; } ?>>January</option>
<option value="2"<? if (($ID == 0 && date('m') == '02') || ($month == 2)) { echo " selected"; } ?>>February</option>
<option value="3"<? if (($ID == 0 && date('m') == '03') || ($month == 3)) { echo " selected"; } ?>>March</option>
<option value="4"<? if (($ID == 0 && date('m') == '04') || ($month == 4)) { echo " selected"; } ?>>April</option>
<option value="5"<? if (($ID == 0 && date('m') == '05') || ($month == 5)) { echo " selected"; } ?>>May</option>
<option value="6"<? if (($ID == 0 && date('m') == '06') || ($month == 6)) { echo " selected"; } ?>>June</option>
<option value="7"<? if (($ID == 0 && date('m') == '07') || ($month == 7)) { echo " selected"; } ?>>July</option>
<option value="8"<? if (($ID == 0 && date('m') == '08') || ($month == 8)) { echo " selected"; } ?>>August</option>
<option value="9"<? if (($ID == 0 && date('m') == '09') || ($month == 9)) { echo " selected"; } ?>>September</option>
<option value="10"<? if (($ID == 0 && date('m') == '10') || ($month == 10)) { echo " selected"; } ?>>October</option>
<option value="11"<? if (($ID == 0 && date('m') == '11') || ($month == 11)) { echo " selected"; } ?>>November</option>
<option value="12"<? if (($ID == 0 && date('m') == '12') || ($month == 12)) { echo " selected"; } ?>>December</option>
</select>&nbsp;
<select class=blacktext name=day>
<?
for ($i=1; $i<32;$i++)
{
$selected = "";
if (($ID == 0 && date('d') == $i) || ($i == $day)) { $selected = " selected"; }
echo "<option value=\"$i\"$selected>$i</option>";
}
?>
</select>&nbsp;
<select class=blacktext name=year>
<?
for ($i=2006; $i<2015;$i++)
{
$selected = "";
if (($ID == 0 && date('Y') == $i) || ($i == $year)) { $selected = " selected"; }
echo "<option value=\"$i\"$selected>$i</option>";
}
?>
</select>
</div></td>
</tr>
<tr>
<td><div class=text><b>Time:</b></div></td>
<td><div class=text>
<select class=blacktext name=hour>
<?
for ($i=0; $i<24;$i++)
{
$selected = "";
if (($ID == 0 && date('H') == $i) || ($i == $hour)) { $selected = " selected"; }
echo "<option value=\"$i\"$selected>$i</option>";
}
?>
</select>:
<select class=blacktext name=minute>
<?
for ($i=0; $i<60;$i++)
{
$selected = "";
$display = $i;
if ($i < 10) { $display = "0${i}"; }
if (($ID == 0 && date('i') == $i) || ($i == $minute)) { $selected = " selected"; }
echo "<option value=\"$i\"$selected>$display</option>";
}
?>
</select>&nbsp;or&nbsp;
<?
$checked = "";
if ($ID == 0) { $checked = " checked"; }
echo "<input type=checkbox name=current_time value=yes${checked}>current time on server";
?>
</div></td>
</tr>
<tr>
<td><div class=text><b>Headline:</b></div></td>
<td><input class=blacktext type=text name="headline" value="<? echo $headline ?>" size=60 maxlength=200></td>
</tr>
<tr valign=top>
<td><div class=text><b>Body:</b></div></td>
<td><div class=blacktext>
<textarea class=blacktext name="body" cols=70 rows=12 wrap="virtual"><? echo $body ?></textarea>
</div></td>
</tr>
<tr>
<td colspan="2" align=center>
<input class=boldtext type="submit" name="submit" value="add/update tick"></td>
</tr>
</table>
</form>
<p><table border=0 cellpadding=0 cellspacing=0 bgcolor="#000000" width="700">
<tr><td>
<table border=0 cellpadding=3 cellspacing=1 bgcolor="#000000" width=100%>
<tr>
<td bgcolor=#cccccc align=center width="26%"><span class=blacktext><b>TIMESTAMP</b></span></td>
<td bgcolor=#cccccc align=center width="25%"><span class=blacktext><b>HEADLINE</b></span></td>
<td bgcolor=#cccccc align=center><span class=blacktext><b>BODY</b></span></td>
<td bgcolor=#cccccc align=center width="2%"><span class=blacktext>&nbsp;</span></td>
</tr>
<?php
$query = "SELECT *, DATE_FORMAT(ticks.timestamp, '%b %e, %Y at %l:%i %p') AS timef FROM ticks WHERE ticks.stageID = $stageID ORDER BY timestamp DESC";
$result = mysql_query($query, $db);
if ($result)
{
while ($r = mysql_fetch_array($result))
{
$tickID = $r['ID'];
$timestamp = $r['timef'];
$headline = $r['headline'];
$body = $r['body'];
if (strlen($body) > 100) { $body = substr($body, 0, 99) . '...'; }
if ($tickID == $ID) { echo "<tr valign=top bgcolor=#ffaaaa>"; }
else { echo "<tr valign=top bgcolor=#ffffff>"; }
echo "<td><div class=blacktext>&nbsp;<a href=\"ticks.php?ID=${tickID}\">$timestamp</a></div></td>";
echo "<td><div class=blacktext>$headline</div></td>";
echo "<td><div class=blacktext>$body</div></td>";
echo "<td><a href=\"javascript:popup('ticks_remove.php?ID=${tickID}&stageID=${stageID}', 'tick');\"><img src=\"images/x.gif\" border=0></a></td>";
echo "</tr>";
}
}
mysql_free_result($result);
?>
<tr valign=top>
<td bgcolor=#aaaaaa colspan=7><div class=blacktext>&nbsp;
</div></td>
</tr>
</table></td></tr>
</table>
</body>
</html>