Example #1
0
 function log($file)
 {
     if (is_file(wiki_module::get_wiki_path() . DIRECTORY_SEPARATOR . $file)) {
         $this->log .= " -f ";
         // follow renames to files
     }
     return $this->run($this->log . " " . escapeshellarg($file));
 }
Example #2
0
 public static function get_list($_FORM)
 {
     global $TPL;
     $current_user =& singleton("current_user");
     $wiki_path = wiki_module::get_wiki_path();
     $files = search::get_recursive_dir_list($wiki_path);
     foreach ($files as $row) {
         $file = str_replace($wiki_path, "", $row);
         if ($_FORM["starred"] && $current_user->prefs["stars"]["wiki"][base64_encode($file)]) {
             $rows[] = array("filename" => $file);
         }
     }
     return (array) $rows;
 }
Example #3
0
 function update_search_index_doc(&$index, $file)
 {
     // Attempt to parse pdfs
     if (strtolower(substr($file, -4)) == ".pdf") {
         $pdfstr = file_get_contents(wiki_module::get_wiki_path() . $file);
         $pdf_reader = new pdf_reader();
         $pdfstr = $pdf_reader->pdf2txt($pdfstr);
         // Else regular text
     } else {
         $str = file_get_contents(wiki_module::get_wiki_path() . $file);
     }
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $file));
     $doc->addField(Zend_Search_Lucene_Field::Text('name', $file, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::Text('desc', $str, "utf-8"));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('pdfstr', $pdfstr, "utf-8"));
     $index->addDocument($doc);
 }
Example #4
0
<?php

// Create a search index for Wiki documents. This patch may take a long time to apply.
ini_set('max_execution_time', 180000);
ini_set('memory_limit', "256M");
$index = Zend_Search_Lucene::create(ATTACHMENTS_DIR . 'search/wiki');
$allowed_suffixes = array("", ".text", ".txt", ".html", ".xml", ".mdwn", ".pdf");
$files = search::get_recursive_dir_list(wiki_module::get_wiki_path());
foreach ($files as $file) {
    // check that the file is of an allowable type.
    preg_match("/(\\.\\w{3,4}\$)/", $file, $m);
    if (!in_array($m[1], $allowed_suffixes)) {
        continue;
    }
    wiki_module::update_search_index_doc($index, str_replace(wiki_module::get_wiki_path(), "", $file));
}
$index->commit();
Example #5
0
 * 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;
}
Example #6
0
            }
            if ($_REQUEST["file"]) {
                $TPL["editName"] = $_REQUEST["file"];
            }
            include_template("templates/fileM.tpl");
        } else {
            if ($file && is_file(wiki_module::get_wiki_path() . $file) && is_readable(wiki_module::get_wiki_path() . $file)) {
                $TPL['current_path'] = dirname($file);
                //dirname may return '.' if there's no dirname, need to get rid of it
                if ($TPL['current_path'] == '.') {
                    $TPL['current_path'] = '';
                } else {
                    $TPL['current_path'] .= DIRECTORY_SEPARATOR;
                }
                $TPL["editName"] = $file;
                wiki_module::get_file($file, $_GET["rev"]);
            } else {
                if ($_REQUEST["loadErrorPage"]) {
                    $TPL["loadErrorPage"] = $_REQUEST["loadErrorPage"];
                    $TPL["str"] = $_REQUEST["str"];
                    $TPL["commit_msg"] = $_REQUEST["commit_msg"];
                    $TPL["file"] = $_REQUEST["file"];
                    $TPL["editName"] = $_REQUEST["file"];
                    $TPL["msg"] = $_REQUEST["msg"];
                    include_template("templates/fileGetM.tpl");
                }
            }
        }
    }
}
$TPL["file"] = $file;
Example #7
0
 function _doWikiLinkAnchors_reference_callback($matches)
 {
     global $TPL;
     $file = $matches[2];
     $name = $matches[1];
     $file = str_ireplace("javascript:", "", $file);
     // added by alla
     $name = str_ireplace("javascript:", "", $name);
     if (!empty($name)) {
         $name = substr($name, 0, -1);
         //trim the trailing |
     } else {
         $name = $file;
     }
     if (file_exists(wiki_module::get_wiki_path() . $file . ".mdwn")) {
         return $this->hashPart('<a href="' . $TPL['url_alloc_wiki'] . 'target=' . urlencode($TPL['current_path'] . $file) . '.mdwn">' . $name . '</a>');
     } else {
         if (file_exists(wiki_module::get_wiki_path() . $file)) {
             return $this->hashPart('<a href="' . $TPL['url_alloc_wiki'] . 'target=' . urlencode($TPL['current_path'] . $file) . '">' . $name . '</a>');
         } else {
             return $this->hashPart($name . '<a href="?op=new&target=' . urlencode($TPL['current_path'] . $file) . '" title="Click here to create this file.">?</a>');
         }
     }
     return $matches[1];
 }
Example #8
0
 * 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));
Example #9
0
                $bits = explode("/", $dirName);
                $str = wiki_module::get_wiki_path();
                foreach ((array) $bits as $bit) {
                    $str .= $slash . $bit;
                    mkdir($str);
                    $slash = "/";
                }
                $TPL["message_good"][] = "Directory created: " . $dirName;
                alloc_redirect($TPL["url_alloc_wiki"] . "target=" . urlencode($dirName));
            }
        }
    }
} else {
    if ($_REQUEST["newDirectory"]) {
        if ($_REQUEST["p"]) {
            if (is_file(wiki_module::get_wiki_path() . $_REQUEST["p"])) {
                $_REQUEST["p"] = dirname($_REQUEST["p"]);
                $_REQUEST["p"] && substr($_REQUEST["p"], -1, 1) != DIRECTORY_SEPARATOR and $_REQUEST["p"] .= "/";
                $_REQUEST["p"] == "." . DIRECTORY_SEPARATOR and $_REQUEST["p"] = "";
            }
            $TPL["dirName"] = $_REQUEST["p"];
        }
        include_template("templates/newDirectoryM.tpl");
    } else {
        if ($_REQUEST["loadErrorPageDir"]) {
            $TPL["loadErrorPageDir"] = $_REQUEST["loadErrorPageDir"];
            $TPL["dirName"] = $_REQUEST["dirName"];
            $TPL["msg"] = $_REQUEST["msg"];
            include_template("templates/newDirectoryM.tpl");
        }
    }
Example #10
0
 function cat($file, $revision)
 {
     $lines = $this->run(sprintf($this->cat, escapeshellarg($file), escapeshellarg($revision), escapeshellarg(str_replace(wiki_module::get_wiki_path(), "", $file))));
     $lines or $lines = array();
     return implode("\n", $lines);
 }