summaryrefslogtreecommitdiff
path: root/utils/admin_news.php
blob: b27cf3102a8ae5593b665a2592657b5efc6f0d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<h2>News</h2>
<?php
include_once($UTIL_DIR."/news.php");
include_once($UTIL_DIR."/convert.php");
include_once($UTIL_DIR."/newsletter.php");
include_once($UTIL_DIR."/rss.php");

if($task == "confirmnews") {
	$time = strtotime($month."/" .$day . "/" . $year . " " . $hour . ":" . $minute . ":" . $second);

	$title = convert($title);
	$description = convert($description);

	$newsentry = new NewsEntry($title, $time, $category, $description);
	$newsentry->show();

	echo "<p>Category: " . $category . "</p>\n";
	if($newsletter) echo "<p><strong>WARNING:</strong> This news will be sent out a newsletter if <em>yes</em> is pressed.</p>\n";
?>
Is this news correct?<br/>
<form method="post" action="?page=admin&amp;module=news&amp;task=postnews">
	<input name="title" type="hidden" value="<?php echo $title ?>"/>
	<input name="category" type="hidden" value="<?php echo $category ?>"/>
	<input name="newsletter" type="hidden" value="<?php echo $newsletter ?>"/>
  <input name="day" type="hidden" value="<?php echo $day ?>"/>
	<input name="month" type="hidden" value="<?php echo $month ?>"/>
	<input name="year" type="hidden" value="<?php echo $year ?>"/>
  <input name="hour" type="hidden" value="<?php echo $hour ?>"/>
  <input name="minute" type="hidden" value="<?php echo $minute ?>"/>
  <input name="second" type="hidden" value="<?php echo $second ?>"/>
  <input name="description" type="hidden" value="<?php echo $description ?>"/>
  <button type="submit">Yes</button>
</form>
<form method="post" action="?page=admin&amp;module=news">
	<input name="title" type="hidden" value="<?php echo $title ?>"/>
	<input name="category" type="hidden" value="<?php echo $category ?>"/>
	<input name="newsletter" type="hidden" value="<?php echo $newsletter ?>"/>
  <input name="day" type="hidden" value="<?php echo $day ?>"/>
	<input name="month" type="hidden" value="<?php echo $month ?>"/>
	<input name="year" type="hidden" value="<?php echo $year ?>"/>
  <input name="hour" type="hidden" value="<?php echo $hour ?>"/>
  <input name="minute" type="hidden" value="<?php echo $minute ?>"/>
  <input name="second" type="hidden" value="<?php echo $second ?>"/>
  <input name="description" type="hidden" value="<?php echo $description ?>"/>
  <button type="submit">No</button>
</form>
<?php
	
	$title = "";
  $category = ""; 
	$newsletter = "";
  $day = "";
  $month = "";
  $year = "";
  $hour  = "";
  $minute = "";
	$second = "";
  $description  = "";
}
?>

<?php
if($task == "postnews") {
	$time = strtotime($month."/" .$day . "/" . $year . " " . $hour . ":" . $minute . ":" . $second);

	$title = convert($title);
	$description = convert($description);

	$news = new News($DATA_DIR."/news.xml");
	$newsentry = new NewsEntry($title, $time, $category, $description);
	$news->add($newsentry);
	$news->write();

	// Now update the RSS feed.
	$rss = new RSS($DATA_DIR."/news.xml", "rss.xml");
	$rss->write();
	
	echo "<p>News posted successfully.</p>";

	//	if($newsletter == "on") sendNewsLetter($title, $description);

	$title = "";
  $category = ""; 
	$newsletter = "";
  $day = "";
  $month = "";
  $year = "";
  $hour  = "";
  $minute = "";
	$second = "";
  $description  = "";
}
?>

<?php
$now = time();
if($day == "") $day = date("j", $now);
if($month =="") $month = date("n", $now);
if($year == "") $year = date("Y", $now);
if($hour == "") $hour  = date("G", $now);
if($minute == "") $minute = date("i", $now);
if($second == "") $second = date("s", $now);
?>

<div class="small_header">Post news</div>
<form method="post" action="?page=admin&amp;module=news&amp;task=confirmnews">
  Title: <input name="title" width="40" value="<?php echo convert($title) ?>"/><br/>
  Category:
  <select name="category">
    <option value="main" <?php if($category == "main") echo "selected"; ?>>main</option>
    <option value="site" <?php if($category == "site") echo "selected"; ?>>site</option>
  </select><br/>
  Date: <input name="day" maxlength="2" style="width: 20px;" value="<?php echo $day ?>"/>/
  <input name="month" maxlength="2" style="width: 20px;" value="<?php echo $month ?>"/>-
  <input name="year" maxlength="4" style="width: 40px;" value="<?php echo $year ?>"/><br/>
  Time: <input name="hour" maxlength="2" style="width: 20px;" value="<?php echo $hour ?>"/>:
  <input name="minute" maxlength="2" style="width: 20px;" value="<?php echo $minute ?>"/>:
  <input name="second" maxlength="2" style="width: 20px;" value="<?php echo $second ?>"/><br/>
  Description: <textarea name="description"><?php echo convert($description) ?></textarea><br/>
  <button type="submit">Post news</button>
</form>