Source of trunk/parseurl.php at revision HEAD (05/07/2008 10:05:26, 2228 bytes, 83 lines, language: php) [download]:
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | ** Path URL Parsing Functions |
| 5 | ** for CodewiseBlog Multi-User |
| 6 | ** |
| 7 | |
| 8 | ** Copyright (c) 2007-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 | /* |
| 30 | * Ultra-Experimental Warning: MAY CAUSE MAJOR BORKAGE |
| 31 | * -WRF |
| 32 | */ |
| 33 | |
| 34 | function path_parse_url() |
| 35 | { |
| 36 | global $db; |
| 37 | |
| 38 | $parts = explode("/", $_SERVER['PATH_INFO']); |
| 39 | |
| 40 | // first entry is empty... |
| 41 | array_shift($parts); |
| 42 | |
| 43 | if (!SUBDOMAIN_MODE || $_GET['subdomain_mode'] === 0) { |
| 44 | array_shift($parts); |
| 45 | } |
| 46 | |
| 47 | if (count($parts) == 0 || (count($parts) == 1 && $parts[0] == "")) { |
| 48 | // PATH_INFO contains nothing |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | switch ($parts[0]) { |
| 53 | case "article": |
| 54 | $title = str_replace("_", "%", $db->prepare_value($parts[1], false)); |
| 55 | $q = $db->issue_query("SELECT tid FROM topics WHERE title LIKE \"$title\""); |
| 56 | if ($db->num_rows[$q] == 1) { |
| 57 | $tid = $db->fetch_var($q); |
| 58 | if ($parts[2] == "reply") { |
| 59 | $_GET['reply'] = $tid; |
| 60 | } else { |
| 61 | if (is_numeric($parts[2])) |
| 62 | $_GET['pid'] = $parts[2]; |
| 63 | $_GET['tid'] = $tid; |
| 64 | } |
| 65 | } else { |
| 66 | $_GET['tid'] = -1; |
| 67 | } |
| 68 | break; |
| 69 | case "archive": |
| 70 | $_GET['year'] = $parts[1]; |
| 71 | $_GET['month'] = $parts[2]; |
| 72 | break; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | function string_to_url_goodness($string) |
| 77 | { |
| 78 | $string = strtolower(preg_replace("/[^a-zA-Z0-9-]+/", "_", $string)); |
| 79 | return $string; |
| 80 | } |
| 81 | |
| 82 | ?> |
| 83 |