Source of trunk/front_page.php at revision HEAD (04/07/2009 9:04:55, 10069 bytes, 269 lines, language: php) [download]:
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | ** Front Page |
| 5 | ** for CodewiseBlog Multi-User |
| 6 | ** |
| 7 | |
| 8 | ** Copyright (c) 2005-2009 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 | ?> |
| 30 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 31 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 32 | <head> |
| 33 | <title><?php echo SITE_TITLE; ?></title> |
| 34 | <link rel="stylesheet" href="stylesheet.php" /> |
| 35 | </head> |
| 36 | <body> |
| 37 | <?php if (isset($_GET['delsession'])) : delete_session(); ?> |
| 38 | <h1>You have been logged out</h1> |
| 39 | <h5>have a nice day</h5> |
| 40 | <a href="<?php echo INDEX_URL; ?>">back to the front page</a> |
| 41 | </body> |
| 42 | </html> |
| 43 | <?php exit; endif; ?> |
| 44 | |
| 45 | <table style="border:none;width:100%;"> |
| 46 | <tr> |
| 47 | <td style="text-align:center"> |
| 48 | <a href="<?php echo INDEX_URL; ?>"><span class="main-title"><?php echo SITE_TITLE ?></span></a><br /> |
| 49 | <i><?php echo SITE_MOTTO; ?></i> |
| 50 | </td> |
| 51 | <td style="width:100%;text-align:right;font-size:small"> |
| 52 | <i><?php echo fortune(); ?></i> |
| 53 | </td> |
| 54 | </tr> |
| 55 | </table> |
| 56 | |
| 57 | <br /> |
| 58 | |
| 59 | <table width="100%" class="maintable"> |
| 60 | <tr> |
| 61 | <td width="1px" style="vertical-align:top"> |
| 62 | |
| 63 | <table class="sidebar" width="100%"> |
| 64 | <tr> |
| 65 | <td class="sidebar"> |
| 66 | <table style="border:none; text-align:center; width:100%"> |
| 67 | <tr><td><b>Blogs on this site:</b></td></tr> |
| 68 | <?php |
| 69 | |
| 70 | $q = $db->issue_query("SELECT name,realname,title,custom_url FROM blogs WHERE status = 'active' ORDER BY blogid ASC"); |
| 71 | $data = $db->fetch_all($q, L1SQL_ASSOC, "name"); |
| 72 | |
| 73 | foreach($data as $blogname => $blog) |
| 74 | { |
| 75 | if($blog['realname'] != NULL) |
| 76 | { |
| 77 | $name = $blog['realname']; |
| 78 | /* |
| 79 | $parts = explode(" ", $blog['realname']); |
| 80 | $name = array_shift($parts); |
| 81 | $name .= " “" . $blog['name'] . "” "; |
| 82 | $name .= implode(" ", $parts); |
| 83 | */ |
| 84 | } else { |
| 85 | $name = $blog['name']; |
| 86 | } |
| 87 | |
| 88 | if(isset($blog['custom_url'])) { |
| 89 | $link = $blog['custom_url']; |
| 90 | } elseif(SUBDOMAIN_MODE) { |
| 91 | $link = "http://$blogname." . BASE_DOMAIN . INSTALLED_PATH; |
| 92 | } else { |
| 93 | $link = "http://" . (DEFAULT_SUBDOMAIN == "" ? "" : DEFAULT_SUBDOMAIN . ".") . BASE_DOMAIN . INSTALLED_PATH . $blogname . "/"; |
| 94 | } |
| 95 | |
| 96 | // this is dumb, but helpful |
| 97 | $blog['title'] = preg_replace('/([^\x09\x0A\x0D\x20-\x7F]|[\x21-\x2F]|[\x3A-\x40]|[\x5B-\x60])/e', '"&#".ord("$0").";"', html_entity_decode($blog['title'])); |
| 98 | ?> |
| 99 | <tr><td><hr align="center" style="border:1px solid #eee" width="50%" noshade="noshade" /></td></tr> |
| 100 | <tr><td><a href="<?php echo $link; ?>"><?php echo $blog['title']; ?></a><br /> |
| 101 | <span style="font-size:smaller">by <?php echo htmlentities($name); ?></span></td></tr> |
| 102 | <?php |
| 103 | |
| 104 | } // foreach($data as $blogname => $blog) |
| 105 | |
| 106 | ?> |
| 107 | <tr><td style="padding:5px"></td></tr> |
| 108 | </table> |
| 109 | </td> |
| 110 | </tr> |
| 111 | <tr> |
| 112 | <td class="sidebar"> |
| 113 | <?php if ($_SESSION['controlpanel'] == 1 && $_SESSION['blogid'] == 1) : ?> |
| 114 | <b>Logged in as Admin</b><br /> |
| 115 | <a href="?controlpanel">go to the Admin CP</a> |
| 116 | <br /> |
| 117 | <a href="?delsession">Log out</a> |
| 118 | <?php else: ?> |
| 119 | <b>Admin login:</b><br /> |
| 120 | |
| 121 | <form action="<?php echo INDEX_URL; ?>?login" method="post"> |
| 122 | <small>password:</small> <input type="password" name="password" style="font-size:smaller" size="10" /><br /> |
| 123 | <input type="submit" value="enter" style="font-size:smaller" /> |
| 124 | </form> |
| 125 | <?php endif; ?> |
| 126 | </td> |
| 127 | </tr> |
| 128 | </table> |
| 129 | |
| 130 | </td> |
| 131 | <td class="blogbody" style="padding-right: 1em"> |
| 132 | |
| 133 | <?php |
| 134 | |
| 135 | if(file_exists("TERMS")) |
| 136 | { |
| 137 | |
| 138 | ?> |
| 139 | <table style="padding: 0px; border: 1px solid #487393; background: white; width: 100%;"> |
| 140 | <tr> |
| 141 | <td style="padding-left: 3px; width: 1px"> |
| 142 | <a href="?register"> |
| 143 | <img src="cwb/keys.png" style="border:none" alt="Keys" /> |
| 144 | </a> |
| 145 | </td> |
| 146 | <td style="padding: 5px"> |
| 147 | <a href="?register"> |
| 148 | <span style="text-decoration:underline">Register for a blog on this site.</span> |
| 149 | </a> |
| 150 | </td> |
| 151 | </tr> |
| 152 | </table> |
| 153 | <br /> |
| 154 | <?php |
| 155 | |
| 156 | } |
| 157 | |
| 158 | $q = $db->issue_query("SELECT blogid FROM blogs WHERE status = 'active'"); |
| 159 | if ($db->num_rows[$q] == 0) |
| 160 | $activeblogids = "false"; |
| 161 | else |
| 162 | $activeblogids = "blogid = " . implode($db->fetch_column($q), " OR blogid = "); |
| 163 | |
| 164 | $q = $db->issue_query("SELECT tid,blogid,title,timestamp,text FROM topics WHERE $activeblogids ORDER BY timestamp DESC LIMIT 5"); |
| 165 | $data = $db->fetch_all($q, L1SQL_ASSOC, ""); |
| 166 | |
| 167 | foreach($data as $topic) |
| 168 | { |
| 169 | $q = $db->issue_query("SELECT name,realname,photo,title,custom_url FROM blogs WHERE blogid = " . $db->prepare_value($topic['blogid'])); |
| 170 | $blog = $db->fetch_row($q); |
| 171 | |
| 172 | $q = $db->issue_query("SELECT COUNT(*) FROM replies WHERE blogid = " . $db->prepare_value($topic['blogid']) . " AND tid = " . $db->prepare_value($topic['tid'])); |
| 173 | $num_replies = $db->fetch_var($q); |
| 174 | |
| 175 | if($blog['photo'] === NULL) |
| 176 | $blog['photo'] = ""; |
| 177 | |
| 178 | if($blog['realname'] !== NULL) |
| 179 | { |
| 180 | $name = $blog['realname']; |
| 181 | } else { |
| 182 | $name = $blog['name']; |
| 183 | } |
| 184 | |
| 185 | if ($blog['custom_url']) { |
| 186 | $url = preg_replace("/\\/$/", "", $blog['custom_url']); |
| 187 | } elseif (SUBDOMAIN_MODE) { |
| 188 | $url = "http://{$blog['name']}." . BASE_DOMAIN . INSTALLED_PATH; |
| 189 | } else { |
| 190 | $url = "http://" . (DEFAULT_SUBDOMAIN == "" ? "" : DEFAULT_SUBDOMAIN . ".") . BASE_DOMAIN . INSTALLED_PATH . $blog['name']; |
| 191 | } |
| 192 | |
| 193 | $filtered_text = in_text_filter($topic['text']); |
| 194 | |
| 195 | if(is_array($filtered_text)) |
| 196 | { |
| 197 | $filtered_text = $filtered_text[0]; |
| 198 | } |
| 199 | |
| 200 | $text = output_topic_text(text_clip($filtered_text, 1000, " …")); |
| 201 | |
| 202 | // $topic['url'] = $url . "?tid=" . $topic['tid']; |
| 203 | $topic['url'] = $url . "/article/" . string_to_url_goodness($topic['title']); |
| 204 | ?> |
| 205 | |
| 206 | <div class="topicheader"> |
| 207 | <table style="border: none; width: 100%"> |
| 208 | <tr> |
| 209 | <td style="padding-left: 3px; width: 1px"> |
| 210 | <img src="<?php echo INDEX_URL; ?>img.php?blogid=<?php echo $topic['blogid']; ?>" alt="<?php echo $blog['name']; ?>" /> |
| 211 | </td> |
| 212 | <td style="padding: 5px"> |
| 213 | <a href="<?php echo $topic['url']; ?>"><b><?php echo $topic['title']; ?></b></a> :: <?php echo $num_replies; ?> comments |
| 214 | <br /> |
| 215 | <a href="<?php echo $url; ?>"><?php echo $blog['title']; ?></a> by <?php echo $name; ?> |
| 216 | <br /> |
| 217 | <?php echo date(DATE_FORMAT, $topic['timestamp']); ?> |
| 218 | </td> |
| 219 | </tr> |
| 220 | </table> |
| 221 | </div> |
| 222 | <div class="topicbody" style="border-bottom: none"> |
| 223 | <?php echo $text; ?> |
| 224 | </div> |
| 225 | <?php /* this is a cheap (but effective!) way of closing any tags left open by text_clip() */ ?> |
| 226 | <div class="topicbody" style="border-top: none"> |
| 227 | <a href="<?php echo "$url?tid={$topic['tid']}"; ?>"><b>read the whole post</b></a> |
| 228 | </div> |
| 229 | <br /> |
| 230 | <?php |
| 231 | |
| 232 | } // foreach($data as $topic) |
| 233 | |
| 234 | ?> |
| 235 | |
| 236 | </td> |
| 237 | </tr> |
| 238 | </table> |
| 239 | <br /> |
| 240 | <table style="border:none;width:100%"> |
| 241 | <tr> |
| 242 | <td style="width:50%;font-size:small;vertical-align:top"> |
| 243 | <?php echo querycount(); ?> database queries. Page generated in <?php echo runtime(); ?> milliseconds.<br /> |
| 244 | <?php echo skinvoodoo("main", "versionfooter"); ?> |
| 245 | </td> |
| 246 | <td style="width:50%;font-size:small;text-align:right;padding-right:1em;vertical-align:top"> |
| 247 | <?php echo voodoo_varsub("%{copyright}", "front_page", FALSE); ?> |
| 248 | </td> |
| 249 | <td> |
| 250 | <table align="center"> |
| 251 | <tr> |
| 252 | <td> |
| 253 | <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0" style="border:none" /></a> |
| 254 | </td> |
| 255 | |
| 256 | </tr> |
| 257 | <tr> |
| 258 | <td> |
| 259 | <a href="http://jigsaw.w3.org/css-validator/check/referer"><img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS" style="border:none" /></a> |
| 260 | </td> |
| 261 | </tr> |
| 262 | </table> |
| 263 | </td> |
| 264 | </tr> |
| 265 | |
| 266 | </table> |
| 267 | </body> |
| 268 | </html> |
| 269 |