Project

General

Profile

« Previous | Next » 

Revision 1064

Added by Matthias over 15 years ago

Fixed some validiation bugs in news modul (Thanks to Luisehahne)

View differences:

modify.php
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Must include code to stop this file being access directly
27
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
28
$database->query("DELETE FROM ".TABLE_PREFIX."mod_news_posts  WHERE page_id = '$page_id' and section_id = '$section_id' and title=''"); 
29
$database->query("DELETE FROM ".TABLE_PREFIX."mod_news_groups  WHERE page_id = '$page_id' and section_id = '$section_id' and title=''"); 
30

  
31
?>
32
<table cellpadding="0" cellspacing="0" border="0" width="100%">
33
<tr>
34
	<td align="left" width="33%">
35
		<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['POST']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/news/add_post.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
36
	</td>
37
	<td align="left" width="33%">
38
		<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['GROUP']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/news/add_group.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
39
	</td>
40
	<td align="right" width="33%">
41
		<input type="button" value="<?php echo $TEXT['SETTINGS']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/news/modify_settings.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
42
	</td>
43
</tr>
44
</table>
45

  
46
<br />
47

  
48
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['POST']; ?></h2>
49

  
50
<?php
51

  
52
// Loop through existing posts
53
$query_posts = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_posts` WHERE section_id = '$section_id' ORDER BY position DESC");
54
if($query_posts->numRows() > 0) {
55
	$num_posts = $query_posts->numRows();
56
	$row = 'a';
57
	?>
58
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
59
	<?php
60
	while($post = $query_posts->fetchRow()) {
61
		?>
62
		<tr class="row_<?php echo $row; ?>" height="20">
63
			<td width="20" style="padding-left: 5px;">
64
				<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
65
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="Modify - " />
66
				</a>
67
			</td>
68
			<td>
69
				<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>">
70
					<?php echo ($post['title']); ?>
71
				</a>
72
			</td>
73
			<td width="180">
74
				<?php echo $TEXT['GROUP'].': ';
75
				// Get group title
76
				$query_title = $database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_groups WHERE group_id = '".$post['group_id']."'");
77
				if($query_title->numRows() > 0) {
78
					$fetch_title = $query_title->fetchRow();
79
					echo ($fetch_title['title']);
80
				} else {
81
					echo $TEXT['NONE'];
82
				}
83
				?>
84
			</td>
85
			<td width="120">
86
				<?php echo $TEXT['COMMENTS'].': ';
87
				// Get number of comments
88
				$query_title = $database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".$post['post_id']."'");
89
				echo $query_title->numRows();
90
				?>
91
			</td>
92
			<td width="80">
93
				<?php echo $TEXT['ACTIVE'].': '; if($post['active'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; } ?>
94
			</td>
95
			<td width="20">
96
			<?php
97
			$start = $post['published_when'];
98
			$end = $post['published_until'];
99
			$t = time();
100
			$icon = '';
101
			if($start<=$t && $end==0)
102
				$icon=THEME_URL.'/images/noclock_16.png';
103
			elseif(($start<=$t || $start==0) && $end>=$t)
104
				$icon=THEME_URL.'/images/clock_16.png';
105
			else
106
				$icon=THEME_URL.'/images/clock_red_16.png';
107
			?>
108
			<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
109
				<img src="<?php echo $icon; ?>" border="0" alt="" />
110
			</td>
111
			<td width="20">
112
			<?php if($post['position'] != $num_posts) { ?>
113
				<a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
114
					<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
115
				</a>
116
			<?php } ?>
117
			</td>
118
			<td width="20">
119
			<?php if($post['position'] != 1) { ?>
120
				<a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
121
					<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
122
				</a>
123
			<?php } ?>
124
			</td>
125
			<td width="20">
126
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_post.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&post_id=<?php echo $post['post_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
127
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
128
				</a>
129
			</td>
130
		</tr>
131
		<?php
132
		// Alternate row color
133
		if($row == 'a') {
134
			$row = 'b';
135
		} else {
136
			$row = 'a';
137
		}
138
	}
139
	?>
140
	</table>
141
	<?php
142
} else {
143
	echo $TEXT['NONE_FOUND'];
144
}
145

  
146
?>
147

  
148
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['GROUP']; ?></h2>
149

  
150
<?php
151

  
152
// Loop through existing groups
153
$query_groups = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_groups` WHERE section_id = '$section_id' ORDER BY position ASC");
154
if($query_groups->numRows() > 0) {
155
	$num_groups = $query_groups->numRows();
156
	$row = 'a';
157
	?>
158
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
159
	<?php
160
	while($group = $query_groups->fetchRow()) {
161
		?>
162
		<tr class="row_<?php echo $row; ?>" height="20">
163
			<td width="20" style="padding-left: 5px;">
164
				<a href="<?php echo WB_URL; ?>/modules/news/modify_group.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&group_id=<?php echo $group['group_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
165
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="Modify - " />
166
				</a>
167
			</td>		
168
			<td>
169
				<a href="<?php echo WB_URL; ?>/modules/news/modify_group.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&group_id=<?php echo $group['group_id']; ?>">
170
					<?php echo $group['title']; ?>
171
				</a>
172
			</td>
173
			<td width="80">
174
				<?php echo $TEXT['ACTIVE'].': '; if($group['active'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; } ?>
175
			</td>
176
			<td width="20">
177
			<?php if($group['position'] != 1) { ?>
178
				<a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&group_id=<?php echo $group['group_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
179
					<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
180
				</a>
181
			<?php } ?>
182
			</td>
183
			<td width="20">
184
			<?php if($group['position'] != $num_groups) { ?>
185
				<a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&section_id=<?php echo $section_id; ?>&group_id=<?php echo $group['group_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
186
					<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
187
				</a>
188
			<?php } ?>
189
			</td>
190
			<td width="20">
191
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_group.php?page_id=<?php echo $page_id; ?>&group_id=<?php echo $group['group_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
192
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
193
				</a>
194
			</td>
195
		</tr>
196
		<?php
197
		// Alternate row color
198
		if($row == 'a') {
199
			$row = 'b';
200
		} else {
201
			$row = 'a';
202
		}
203
	}
204
	?>
205
	</table>
206
	<?php
207
} else {
208
	echo $TEXT['NONE_FOUND'];
209
}
1
<?php
2

  
3
// $Id$
4

  
5
/*
6

  
7
 Website Baker Project <http://www.websitebaker.org/>
8
 Copyright (C) 2004-2009, Ryan Djurovich
9

  
10
 Website Baker is free software; you can redistribute it and/or modify
11
 it under the terms of the GNU General Public License as published by
12
 the Free Software Foundation; either version 2 of the License, or
13
 (at your option) any later version.
14

  
15
 Website Baker is distributed in the hope that it will be useful,
16
 but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 GNU General Public License for more details.
19

  
20
 You should have received a copy of the GNU General Public License
21
 along with Website Baker; if not, write to the Free Software
22
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23

  
24
*/
25

  
26
// Must include code to stop this file being access directly
27
if(!defined('WB_PATH')) { exit("Cannot access this file directly"); }
28
$database->query("DELETE FROM ".TABLE_PREFIX."mod_news_posts  WHERE page_id = '$page_id' and section_id = '$section_id' and title=''"); 
29
$database->query("DELETE FROM ".TABLE_PREFIX."mod_news_groups  WHERE page_id = '$page_id' and section_id = '$section_id' and title=''"); 
30

  
31
//overwrite php.ini on Apache servers for valid SESSION ID Separator
32
if(function_exists('ini_set')) {
33
	ini_set('arg_separator.output', '&amp;');
34
}
35

  
36
?>
37
<table cellpadding="0" cellspacing="0" border="0" width="100%">
38
<tr>
39
	<td align="left" width="33%">
40
		<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['POST']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/news/add_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
41
	</td>
42
	<td align="left" width="33%">
43
		<input type="button" value="<?php echo $TEXT['ADD'].' '.$TEXT['GROUP']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/news/add_group.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
44
	</td>
45
	<td align="right" width="33%">
46
		<input type="button" value="<?php echo $TEXT['SETTINGS']; ?>" onclick="javascript: window.location = '<?php echo WB_URL; ?>/modules/news/modify_settings.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>';" style="width: 100%;" />
47
	</td>
48
</tr>
49
</table>
50

  
51
<br />
52

  
53
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['POST']; ?></h2>
54

  
55
<?php
56

  
57
// Loop through existing posts
58
$query_posts = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_posts` WHERE section_id = '$section_id' ORDER BY position DESC");
59
if($query_posts->numRows() > 0) {
60
	$num_posts = $query_posts->numRows();
61
	$row = 'a';
62
	?>
63
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
64
	<?php
65
	while($post = $query_posts->fetchRow()) {
66
		?>
67
		<tr class="row_<?php echo $row; ?>">
68
			<td width="20" style="padding-left: 5px;">
69
				<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
70
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="Modify - " />
71
				</a>
72
			</td>
73
			<td>
74
				<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post['post_id']; ?>">
75
					<?php echo ($post['title']); ?>
76
				</a>
77
			</td>
78
			<td width="180">
79
				<?php echo $TEXT['GROUP'].': ';
80
				// Get group title
81
				$query_title = $database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_groups WHERE group_id = '".$post['group_id']."'");
82
				if($query_title->numRows() > 0) {
83
					$fetch_title = $query_title->fetchRow();
84
					echo ($fetch_title['title']);
85
				} else {
86
					echo $TEXT['NONE'];
87
				}
88
				?>
89
			</td>
90
			<td width="120">
91
				<?php echo $TEXT['COMMENTS'].': ';
92
				// Get number of comments
93
				$query_title = $database->query("SELECT title FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".$post['post_id']."'");
94
				echo $query_title->numRows();
95
				?>
96
			</td>
97
			<td width="80">
98
				<?php echo $TEXT['ACTIVE'].': '; if($post['active'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; } ?>
99
			</td>
100
			<td width="20">
101
			<?php
102
			$start = $post['published_when'];
103
			$end = $post['published_until'];
104
			$t = time();
105
			$icon = '';
106
			if($start<=$t && $end==0)
107
				$icon=THEME_URL.'/images/noclock_16.png';
108
			elseif(($start<=$t || $start==0) && $end>=$t)
109
				$icon=THEME_URL.'/images/clock_16.png';
110
			else
111
				$icon=THEME_URL.'/images/clock_red_16.png';
112
			?>
113
			<a href="<?php echo WB_URL; ?>/modules/news/modify_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
114
				<img src="<?php echo $icon; ?>" border="0" alt="" />
115
			</a>
116
			</td>
117
			<td width="20">
118
			<?php if($post['position'] != $num_posts) { ?>
119
				<a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
120
					<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
121
				</a>
122
			<?php } ?>
123
			</td>
124
			<td width="20">
125
			<?php if($post['position'] != 1) { ?>
126
				<a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post['post_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
127
					<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
128
				</a>
129
			<?php } ?>
130
			</td>
131
			<td width="20">
132
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_post.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;post_id=<?php echo $post['post_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
133
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
134
				</a>
135
			</td>
136
		</tr>
137
		<?php
138
		// Alternate row color
139
		if($row == 'a') {
140
			$row = 'b';
141
		} else {
142
			$row = 'a';
143
		}
144
	}
145
	?>
146
	</table>
147
	<?php
148
} else {
149
	echo $TEXT['NONE_FOUND'];
150
}
151

  
152
?>
153

  
154
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['GROUP']; ?></h2>
155

  
156
<?php
157

  
158
// Loop through existing groups
159
$query_groups = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_groups` WHERE section_id = '$section_id' ORDER BY position ASC");
160
if($query_groups->numRows() > 0) {
161
	$num_groups = $query_groups->numRows();
162
	$row = 'a';
163
	?>
164
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
165
	<?php
166
	while($group = $query_groups->fetchRow()) {
167
		?>
168
		<tr class="row_<?php echo $row; ?>">
169
			<td width="20" style="padding-left: 5px;">
170
				<a href="<?php echo WB_URL; ?>/modules/news/modify_group.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $group['group_id']; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
171
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="Modify - " />
172
				</a>
173
			</td>		
174
			<td>
175
				<a href="<?php echo WB_URL; ?>/modules/news/modify_group.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $group['group_id']; ?>">
176
					<?php echo $group['title']; ?>
177
				</a>
178
			</td>
179
			<td width="80">
180
				<?php echo $TEXT['ACTIVE'].': '; if($group['active'] == 1) { echo $TEXT['YES']; } else { echo $TEXT['NO']; } ?>
181
			</td>
182
			<td width="20">
183
			<?php if($group['position'] != 1) { ?>
184
				<a href="<?php echo WB_URL; ?>/modules/news/move_up.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $group['group_id']; ?>" title="<?php echo $TEXT['MOVE_UP']; ?>">
185
					<img src="<?php echo THEME_URL; ?>/images/up_16.png" border="0" alt="^" />
186
				</a>
187
			<?php } ?>
188
			</td>
189
			<td width="20">
190
			<?php if($group['position'] != $num_groups) { ?>
191
				<a href="<?php echo WB_URL; ?>/modules/news/move_down.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php echo $section_id; ?>&amp;group_id=<?php echo $group['group_id']; ?>" title="<?php echo $TEXT['MOVE_DOWN']; ?>">
192
					<img src="<?php echo THEME_URL; ?>/images/down_16.png" border="0" alt="v" />
193
				</a>
194
			<?php } ?>
195
			</td>
196
			<td width="20">
197
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php echo WB_URL; ?>/modules/news/delete_group.php?page_id=<?php echo $page_id; ?>&amp;group_id=<?php echo $group['group_id']; ?>');" title="<?php echo $TEXT['DELETE']; ?>">
198
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
199
				</a>
200
			</td>
201
		</tr>
202
		<?php
203
		// Alternate row color
204
		if($row == 'a') {
205
			$row = 'b';
206
		} else {
207
			$row = 'a';
208
		}
209
	}
210
	?>
211
	</table>
212
	<?php
213
} else {
214
	echo $TEXT['NONE_FOUND'];
215
}
210 216
?>

Also available in: Unified diff