| 1 | 1 | simandl | <?php |
| 2 | | | // WebSVN - Subversion repository viewing via the web using PHP |
| 3 | | | // Copyright (C) 2004-2006 Tim Armes |
| 4 | | | // |
| 5 | | | // This program is free software; you can redistribute it and/or modify |
| 6 | | | // it under the terms of the GNU General Public License as published by |
| 7 | | | // the Free Software Foundation; either version 2 of the License, or |
| 8 | | | // (at your option) any later version. |
| 9 | | | // |
| 10 | | | // This program is distributed in the hope that it will be useful, |
| 11 | | | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | | | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | | | // GNU General Public License for more details. |
| 14 | | | // |
| 15 | | | // You should have received a copy of the GNU General Public License |
| 16 | | | // along with this program; if not, write to the Free Software |
| 17 | | | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | | | // |
| 19 | | | // -- |
| 20 | | | // |
| 21 | | | // wsvn.php |
| 22 | | | // |
| 23 | | | // Glue for MultiViews |
| 24 | | | |
| 25 | | | // --- CONFIGURE THIS VARIABLE --- |
| 26 | | | |
| 27 | | | // Location of websvn directory via HTTP |
| 28 | | | // |
| 29 | | | // e.g. For http://servername/websvn use /websvn |
| 30 | | | // |
| 31 | | | // Note that wsvn.php need not be in the /websvn directory (and normally isn't). |
| 32 | | | // If you want to use the root server directory, just use a blank string (''). |
| 33 | | | //$locwebsvnhttp = "/websvn"; |
| 34 | | | $locwebsvnhttp = ''; |
| 35 | | | |
| 36 | | | // Physical location of websvn directory. Change this if your wsvn.php is not in the |
| 37 | | | // same folder as the rest of the distribution |
| 38 | | | $locwebsvnreal = dirname(__FILE__); |
| 39 | | | |
| 40 | | | // --- DON'T CHANGE BELOW HERE --- |
| 41 | | | |
| 42 | | | chdir($locwebsvnreal); |
| 43 | | | |
| 44 | | | // this tells files that we are in multiviews if they are unable to access |
| 45 | | | // the $config variable |
| 46 | | | if (!defined('WSVN_MULTIVIEWS')) { |
| 47 | | | define('WSVN_MULTIVIEWS', 1); |
| 48 | | | } |
| 49 | | | |
| 50 | | | ini_set("include_path", $locwebsvnreal); |
| 51 | | | |
| 52 | | | require_once("include/setup.php"); |
| 53 | | | require_once("include/svnlook.php"); |
| 54 | | | |
| 55 | | | if (!isset($_REQUEST["sc"])) { |
| 56 | | | $_REQUEST["sc"] = 1; |
| 57 | | | } |
| 58 | | | |
| 59 | | | if ($config->multiViews) { |
| 60 | | | // If this is a form handling request, deal with it |
| 61 | | | if (@$_REQUEST["op"] == "form") { |
| 62 | | | include("$locwebsvnreal/form.php"); |
| 63 | | | exit; |
| 64 | | | } |
| 65 | | | |
| 66 | | | $origPathInfo = isset($_SERVER['ORIG_PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : ''; |
| 67 | | | $pathInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; |
| 68 | | | $path = trim(empty($pathInfo) ? $origPathInfo : $pathInfo); |
| 69 | | | |
| 70 | | | // Remove initial slash |
| 71 | | | $path = substr($path, 1); |
| 72 | | | if (empty($path)) { |
| 73 | | | include("$locwebsvnreal/index.php"); |
| 74 | | | exit; |
| 75 | | | } |
| 76 | | | |
| 77 | | | // Split the path into repository and path elements |
| 78 | | | // Note: we have to cope with the repository name |
| 79 | | | // having a slash in it |
| 80 | | | |
| 81 | | | $found = false; |
| 82 | | | |
| 83 | | | $pos = strpos($path, '/'); |
| 84 | | | if ($pos === false) { |
| 85 | | | $pos = strlen($path); |
| 86 | | | } |
| 87 | | | $name = substr($path, 0, $pos); |
| 88 | | | |
| 89 | | | foreach ($config->getRepositories() as $rep) { |
| 90 | | | if (strcasecmp($rep->getDisplayName(), $name) == 0) { |
| 91 | | | $found = true; |
| 92 | | | $path = substr($path, $pos); |
| 93 | | | if ($path == '') { |
| 94 | | | $path = '/'; |
| 95 | | | } |
| 96 | | | break; |
| 97 | | | } |
| 98 | | | } |
| 99 | | | |
| 100 | | | if ($found == false) { |
| 101 | | | include("$locwebsvnreal/index.php"); |
| 102 | | | exit; |
| 103 | | | } |
| 104 | | | |
| 105 | | | createProjectSelectionForm(); |
| 106 | | | createRevisionSelectionForm(); |
| 107 | | | $vars["allowdownload"] = $rep->getAllowDownload(); |
| 108 | | | |
| 109 | | | // find the operation type |
| 110 | | | $op = @$_REQUEST["op"]; |
| 111 | | | switch ($op) { |
| 112 | | | case "dir": |
| 113 | | | $file = "listing.php"; |
| 114 | | | break; |
| 115 | | | case "revision": |
| 116 | | | $file = "revision.php"; |
| 117 | | | break; |
| 118 | | | case "file": |
| 119 | | | $file = "filedetails.php"; |
| 120 | | | break; |
| 121 | | | case "log": |
| 122 | | | $file = "log.php"; |
| 123 | | | break; |
| 124 | | | case "diff": |
| 125 | | | $file = "diff.php"; |
| 126 | | | break; |
| 127 | | | case "blame": |
| 128 | | | $file = "blame.php"; |
| 129 | | | break; |
| 130 | | | case "rss": |
| 131 | | | $file = "rss.php"; |
| 132 | | | break; |
| 133 | | | case "dl": |
| 134 | | | $file = "dl.php"; |
| 135 | | | break; |
| 136 | | | case "comp": |
| 137 | | | $file = "comp.php"; |
| 138 | | | break; |
| 139 | | | default: |
| 140 | | | if ($path[strlen($path) - 1] == "/") { |
| 141 | | | $file = "listing.php"; |
| 142 | | | } else { |
| 143 | | | $file = "filedetails.php"; |
| 144 | | | } |
| 145 | | | break; |
| 146 | | | } |
| 147 | | | |
| 148 | | | // Now include the file that handles it |
| 149 | | | include("$locwebsvnreal/$file"); |
| 150 | | | |
| 151 | | | } else { |
| 152 | | | print "<p>MultiViews must be configured in config.php in order to use this file"; |
| 153 | | | exit; |
| 154 | | | } |