function get_all_source_files($dir = "") { global $TPL; $dir or $dir = ALLOC_MOD_DIR; if (path_under_path($dir, ALLOC_MOD_DIR) && is_dir($dir)) { $dir = realpath($dir); $handle = opendir($dir); while (false !== ($file = readdir($handle))) { clearstatcache(); if ($file == ".") { continue; } if ($file == ".." && realpath($dir) == realpath(ALLOC_MOD_DIR)) { continue; } if (is_file($dir . DIRECTORY_SEPARATOR . $file)) { $image = "<img border=\"0\" alt=\"icon\" src=\"" . $TPL["url_alloc_images"] . "/fileicons/unknown.gif\">"; $files[$file] = "<a href=\"" . $TPL["url_alloc_sourceCodeView"] . "dir=" . urlencode($dir) . "&file=" . urlencode($file) . "\">" . $image . $file . "</a>"; } else { if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) { $image = "<img border=\"0\" alt=\"icon\" src=\"" . $TPL["url_alloc_images"] . "/fileicons/directory.gif\">"; $dirs[$file] = "<a href=\"" . $TPL["url_alloc_sourceCodeList"] . "dir=" . urlencode($dir . DIRECTORY_SEPARATOR . $file) . "\">" . $image . $file . "</a>"; } else { #echo "<br>wtf: ".$dir.DIRECTORY_SEPARATOR.$file; } } } } $files or $files = array(); $dirs or $dirs = array(); asort($files); asort($dirs); $rtn = array_merge($dirs, $files); return $rtn; }
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"); } }
<?php /* * Copyright (C) 2006-2011 Alex Lance, Clancy Malcolm, Cyber IT Solutions * Pty. Ltd. * * This file is part of the allocPSA application <*****@*****.**>. * * allocPSA is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or (at * your option) any later version. * * allocPSA is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 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"; $prohibited[] = "alloc_config.php"; if ($_GET["dir"] && $_GET["file"]) { $path = realpath($_GET["dir"] . DIRECTORY_SEPARATOR . $_GET["file"]); $TPL["path"] = $path; if (path_under_path($path, ALLOC_MOD_DIR) && is_file($path) && !in_array(basename($path), $prohibited)) { $TPL["results"] = page::htmlentities(file_get_contents($path)); } } include_template("templates/sourceCodeView.tpl");
* Pty. Ltd. * * This file is part of the allocPSA application <*****@*****.**>. * * allocPSA is free software: you can redistribute it and/or modify it * under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or (at * your option) any later version. * * allocPSA is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 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/>. */ define("NO_REDIRECT", 1); require_once "../alloc.php"; $file = realpath(wiki_module::get_wiki_path() . $_GET["file"]); if (path_under_path(dirname($file), wiki_module::get_wiki_path())) { $fp = fopen($file, "rb"); $mimetype = get_mimetype($file); $disposition = "attachment"; preg_match("/jpe?g|gif|png/i", basename($file)) and $disposition = "inline"; header('Content-Type: ' . $mimetype); header("Content-Length: " . filesize($file)); header('Content-Disposition: ' . $disposition . '; filename="' . basename($file) . '"'); fpassthru($fp); exit; }
$TPL["str"] = $text; $TPL["commit_msg"] = $_POST["commit_msg"]; alloc_redirect($TPL["url_alloc_wiki"] . "target=" . urlencode($file)); } } } // Else non-vcs save } else { wiki_module::file_save(wiki_module::get_wiki_path() . $editName, $text); $TPL["message_good"][] = "File saved: " . $editName; alloc_redirect($TPL["url_alloc_wiki"] . "target=" . urlencode($editName)); } } } else { if ($_REQUEST["delete"]) { 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($file)) or $errors[] = "Path is not writeable."; strlen($file) or $errors[] = "Filename empty."; $_POST["commit_msg"] and $_POST["commit_msg"] .= " "; $_POST["commit_msg"] .= "File deleted: " . $file; if (!$errors && !is_dir(wiki_module::get_wiki_path() . $file)) { // If we're using version control if (is_object($vcs)) { wiki_module::file_delete(wiki_module::get_wiki_path() . $file); $vcs->rm(wiki_module::get_wiki_path() . $file, $_POST["commit_msg"]); $TPL["message_good"][] = "File deleted: " . $file; $TPL["file"] = $file; $TPL["str"] = $text; $TPL["commit_msg"] = $_POST["commit_msg"]; alloc_redirect($TPL["url_alloc_wiki"] . "target=" . urlencode(dirname($file))); // Else non-vcs save
* allocPSA is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 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/>. */ define("NO_REDIRECT", 1); require_once "../alloc.php"; $dont_print_these_dirs = array(".", "..", "CVS", ".hg", ".bzr", "_darcs", ".git"); // relative path $DIR = urldecode($_POST['dir']); // full path $PATH = realpath(wiki_module::get_wiki_path() . $DIR) . DIRECTORY_SEPARATOR; if (path_under_path($PATH, wiki_module::get_wiki_path()) && is_dir($PATH)) { $files = scandir($PATH); natcasesort($files); $str .= "\n<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if (!in_array($file, $dont_print_these_dirs) && is_dir($PATH . $file)) { $str .= "\n <li class=\"directory collapsed\"><a class=\"file\" href=\"#\" rel=\"" . page::htmlentities($DIR . $file . DIRECTORY_SEPARATOR) . "\">" . page::htmlentities($file) . "</a></li>"; } } // All files foreach ($files as $file) { if (file_exists($PATH . $file) && $file != '.' && $file != '..' && !is_dir($PATH . $file) && is_readable($PATH . $file)) { unset($extra); !is_writable($PATH . $file) and $extra = "(ro) "; $ext = strtolower(preg_replace('/^.*\\./', '', $file));