Source of trunk/main_functions.php at revision HEAD (05/07/2008 10:05:26, 6306 bytes, 194 lines, language: php) [download]:

1
<?php
2
3
/*
4
** Main Functions
5
** for CodewiseBlog Multi-User
6
**
7
** by William R. Fraser <wrf@codewise.org>
8
** Copyright (c) 2005-2008 Codewise.org
9
*/
10
11
/*
12
** This file is part of CodewiseBlog
13
**
14
** CodewiseBlog is free software; you can redistribute it and/or modify
15
** it under the terms of the GNU General Public License as published by
16
** the Free Software Foundation; either version 2 of the License, or
17
** (at your option) any later version.
18
**
19
** CodewiseBlog is distributed in the hope that it will be useful,
20
** but WITHOUT ANY WARRANTY; without even the implied warranty of
21
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
** GNU General Public License for more details.
23
**
24
** You should have received a copy of the GNU General Public License
25
** along with CodewiseBlog; if not, write to the Free Software
26
** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27
*/
28
29
function main_page($page)
30
{
31
    global $db$BLOGINFO$TITLE;
32
33
    $TITLE $BLOGINFO['title'];
34
35
    $out "";
36
37
    $q $db->issue_query("SELECT * FROM topics WHERE blogid = '" BLOGID "' ORDER BY timestamp DESC");
38
39
    if($db->num_rows[$q] == || $db->num_rows[$q] < (TOPICS_PER_PAGE * ($page 1)))
40
    {
41
        return "Nothing to show.";
42
    }
43
44
    // skip over topics to get to the appropriate page
45
    if($page 1)
46
        $db->fetch_row($q, (TOPICS_PER_PAGE * ($page 1)) - 1L1SQL_NUM);
47
48
    for($i 0$i TOPICS_PER_PAGE || isset($_GET['all_one_page']); $i++)
49
    {
50
        $topic $db->fetch_row($q0L1SQL_ASSOC);
51
        if($topic === false)
52
            break;
53
54
        if($topic['extra'] == "HIDE")
55
            continue;
56
57
        $out .= display_topic($topic);
58
    }
59
60
    for($i 1$i <= ceil($db->num_rows[$q] / TOPICS_PER_PAGE); $i++)
61
    {
62
        if($i == $page && !isset($_GET['all_one_page']))
63
            $out .= skinvoodoo("pagelink""currpage", array("pageno" => $i));
64
        elseif($i == 1)
65
            $out .= skinvoodoo("pagelink""pagelink", array("url" => INDEX_URL"pageno" => 1));
66
        else
67
            $out .= skinvoodoo("pagelink""pagelink", array("url" => INDEX_URL "?page=$i""pageno" => $i));
68
    }
69
    if(isset($_GET['all_one_page']))
70
        $out .= skinvoodoo("pagelink""allonepage_current");
71
    else
72
        $out .= skinvoodoo("pagelink""allonepage_link", array("url" => INDEX_URL "?all_one_page"));
73
74
    return $out;
75
76
// end of main_page()
77
78
function show_month($month$year$page)
79
{
80
    global $db$BLOGINFO$TITLE;
81
82
    $months = array("null""January""February""March""April""May""June""July""August""September""October""November""December");
83
    $TITLE $BLOGINFO['title'] . " :: " $months[$month] . $year";
84
85
    $out "";
86
87
    $time1 mktime(0,0,0$month1$year);
88
    $day date("t"$time1);
89
    $time2 mktime(23,59,59$month$day$year);
90
91
    $q $db->issue_query("SELECT * FROM topics WHERE timestamp >= '$time1' AND timestamp <= '$time2' AND blogid = '" BLOGID "' ORDER BY timestamp DESC");
92
93
    if($db->num_rows[$q] == || $db->num_rows[$q] < (TOPICS_PER_PAGE * ($page 1)))
94
    {
95
        return "Nothing to show";
96
    }
97
98
    // skip over topics to get to the appropriate page
99
    if($page 1)
100
        $db->fetch_row($q, (TOPICS_PER_PAGE * ($page 1)) - 1L1SQL_NUM);
101
102
    for($i 0$i TOPICS_PER_PAGE || isset($_GET['all_one_page']); $i++)
103
    {
104
        $topic $db->fetch_row($q0L1SQL_ASSOC);
105
        if($topic === false)
106
            break;
107
108
        $out .= display_topic($topic);
109
    }
110
111
    for($i 1$i <= ceil($db->num_rows[$q] / TOPICS_PER_PAGE); $i++)
112
    {
113
        if($i == $page && !isset($_GET['all_one_page']))
114
            $out .= skinvoodoo("pagelink""currpage", array("pageno" => $i));
115
        else
116
            $out .= skinvoodoo("pagelink""pagelink", array("url" => INDEX_URL "?month=$month&amp;year=$year&amp;page=$i""pageno" => $i));
117
    }
118
    if(isset($_GET['all_one_page']))
119
        $out .= skinvoodoo("pagelink""allonepage_current");
120
    else
121
        $out .= skinvoodoo("pagelink""allonepage_link", array("url" => INDEX_URL "?month=$month&amp;year=$year&amp;all_one_page"));
122
123
    return $out;
124
125
// end of show_month()
126
127
function show_topic($tid$page)
128
{
129
    global $db$BLOGINFO$TITLE;
130
131
    $out "";
132
133
    $q $db->issue_query("SELECT * FROM topics WHERE tid = '$tid' AND blogid = '" BLOGID "'");
134
135
    if($db->num_rows[$q] == 0)
136
    {
137
        return "no such entry";
138
    }
139
140
    $topic $db->fetch_row($q0L1SQL_ASSOC);
141
142
   $TITLE $BLOGINFO['title'] . " :: " $topic['title'];
143
144
145
    $out .= display_topic($topicTRUE);
146
    $out .= skinvoodoo("topic""start_comments");
147
148
    $q $db->issue_query("SELECT * FROM replies WHERE tid = '$tid' AND blogid = '" BLOGID "' ORDER BY timestamp ASC");
149
150
    if($db->num_rows[$q] == || $db->num_rows[$q] < (POSTS_PER_PAGE * ($page 1)))
151
    {
152
        $out .= "no comments to show";
153
        return $out ;
154
    }
155
156
    // skip over posts to get to the appropriate page
157
    if($page 1)
158
        $db->fetch_row($q, (POSTS_PER_PAGE * ($page 1)) - 1L1SQL_NUM);
159
160
    $topic_urltitle string_to_url_goodness($topic['title']);
161
162
    for($i 0$i POSTS_PER_PAGE || isset($_GET['all_one_page']); $i++)
163
    {
164
        $post $db->fetch_row($q0L1SQL_ASSOC);
165
166
        if($post === FALSE)
167
            break;
168
169
        if($post['pid'] == $_GET['pid'])
170
            $out .= display_post($postTRUE$topic_urltitle);
171
        else
172
            $out .= display_post($postFALSE$topic_urltitle);
173
    }
174
175
    for($i 1$i <= ceil($db->num_rows[$q] / POSTS_PER_PAGE); $i++)
176
    {
177
        if($i == $page && !isset($_GET['all_one_page']))
178
            $out .= skinvoodoo("pagelink""currpage", array("pageno" => $i));
179
        else
180
            $out .= skinvoodoo("pagelink""pagelink", array("url" => INDEX_URL "?tid=$tid&amp;page=$i""pageno" => $i));
181
    }
182
    if(isset($_GET['all_one_page']))
183
        $out .= skinvoodoo("pagelink""allonepage_current");
184
    else
185
        $out .= skinvoodoo("pagelink""allonepage_link", array("url" => INDEX_URL "?tid=$tid&amp;all_one_page"));
186
187
    $out .= skinvoodoo("topic""topicfooter_addcomment", array("url_addcomment" => INDEX_URL "?reply=$tid#commentform"));
188
189
    return $out;
190
191
// end of show_topic()
192
193
?>
194

powered by Codewise Manager v0.1-DEV :: 59.69ms, 6 ops, 3 queries