Project:
stupidCMS
Code Location:
https://stupidcms.svn.sourceforge.net/svnroot/stupidcms
categories.php
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
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
<?php /* Copyright (C) 2011 Jacopo Cascioli This file is part of stupidCMS This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ require "layout.php"; require "format.php"; require "settings.php"; /* mysql connection */ $con = mysql_connect($server, $user, $password); mysql_select_db($database, $con); /* finds generic vars */ $query = mysql_query("SELECT * FROM general"); $general = mysql_fetch_array($query); $title = $general[1]; $description = $general[2]; $sentence = $general[3]; $license = $general[4]; $version = $general[5]; $lastupdate = date("l j F Y", $general[6]); $mode = $_GET["mode"]; $show = $_GET["show"]; if ($show == 'categories') {$table_name = 'category';} elseif ($show == 'languages'){$table_name = 'language';} if ($mode == 0) { /* shows a list of categories */ $query = mysql_query("SELECT * FROM $show"); $raw_categories_list = fetch_all($query); if ($show == 'languages'){$main_content = format_generic_list(0, $raw_categories_list);} elseif ($show == 'categories'){$main_content = format_generic_list(1, $raw_categories_list);} $navbar = format_navbar(0, 0, 0); $page_slide = ''; } elseif ($mode == 1) { /* shows posts in a category */ $given_category = $_GET[$table_name]; $from_last = $_GET["fromlast"]; if (!$from_last) { $query = mysql_query("SELECT * FROM posts WHERE $table_name='$given_category' ORDER BY id DESC LIMIT 0,10"); $posts = fetch_all($query); $formatted_posts = format_posts($posts); $page_slide = format_page_slide(1, 2, $given_category); } else { $query = mysql_query("SELECT * FROM posts WHERE $table_name='$given_category' ORDER BY id DESC"); $posts_array = fetch_all($query); $posts = limit_workaround($posts_array, $from_last, 10); $page_slide = format_page_slide($from_last, 2, $given_category); $formatted_posts = format_posts($posts); } $main_content = $formatted_posts.$page_slide; } $navbar = format_navbar($show, $mode, $given_category); $header = sprintf($header, $title, $description, $navbar); $footer = sprintf($footer, $lastupdate, $version, $license); printf($html_base, $title, $header, $main_content, $footer); ?>
