Beispiel #1
0
 function get_file($file, $rev = "")
 {
     global $TPL;
     $f = realpath(wiki_module::get_wiki_path() . $file);
     if (path_under_path(dirname($f), wiki_module::get_wiki_path())) {
         $mt = get_mimetype($f);
         if (strtolower($mt) != "text/plain") {
             $s = "<h6>Download File</h6>";
             $s .= "<a href='" . $TPL["url_alloc_fileDownload"] . "file=" . urlencode($file) . "'>" . $file . "</a>";
             $TPL["str_html"] = $s;
             include_template("templates/fileGetM.tpl");
             exit;
         }
         // Get the regular revision ...
         $disk_file = file_get_contents($f) or $disk_file = "";
         $vcs = vcs::get();
         //$vcs->debug = true;
         // Get a particular revision
         if ($vcs) {
             $vcs_file = $vcs->cat($f, $rev);
         }
         if ($vcs && wiki_module::nuke_trailing_spaces_from_all_lines($disk_file) != wiki_module::nuke_trailing_spaces_from_all_lines($vcs_file)) {
             if (!$vcs_file) {
                 $TPL["msg"] = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>\n                          Warning: This file may not be under version control.\n                         </div>";
             } else {
                 $TPL["msg"] = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>\n                          Warning: This file may not be the latest version.\n                         </div>";
             }
         }
         if ($rev && $vcs_file) {
             $TPL["str"] = $vcs_file;
         } else {
             $TPL["str"] = $disk_file;
         }
         $wikiMarkup = config::get_config_item("wikiMarkup");
         $TPL["str_html"] = $wikiMarkup($TPL["str"]);
         $TPL["rev"] = urlencode($rev);
         include_template("templates/fileGetM.tpl");
     }
 }
Beispiel #2
0
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
 * License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with allocPSA. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "../alloc.php";
$file = $_POST["file"] or $file = $_GET["file"];
$TPL["file"] = $file;
$editName = $_POST["editName"];
$TPL["editName"] = $_POST["editName"];
// Decode the wiki document ..
$text = html_entity_decode($_POST["wikitext"]);
$text = str_replace("\r\n", "\n", $text);
// Check if we're using a VCS
$vcs = vcs::get();
if ($_POST["save"]) {
    path_under_path(wiki_module::get_wiki_path() . dirname($editName), wiki_module::get_wiki_path()) or $errors[] = "Bad filename: " . $editName;
    is_writeable(wiki_module::get_wiki_path() . dirname($editName)) or $errors[] = "Path is not writeable.";
    strlen($_POST["wikitext"]) or $errors[] = "File contents empty.";
    strlen($editName) or $errors[] = "Filename empty.";
    strlen($_POST["commit_msg"]) or $errors[] = "No description of changes entered.";
    if ($errors) {
        $error = "<div class='message warn noprint' style='margin-top:0px; margin-bottom:10px; padding:10px;'>";
        $error .= implode("<br>", $errors);
        $error .= "</div>";
        $TPL["loadErrorPage"] = 1;
        $TPL["str"] = urlencode($_POST["wikitext"]);
        $TPL["commit_msg"] = urlencode($_POST["commit_msg"]);
        $TPL["file"] = urlencode($editName);
        $TPL["msg"] = $error;