コード例 #1
0
ファイル: RegisterEdit.php プロジェクト: richmahn/Door43
 public function handle_ajax_call()
 {
     global $INPUT;
     header('Content-Type: text/plain');
     $langCode = $INPUT->str('lang');
     $text = $INPUT->str('text');
     $dir = DOKU_CONF . 'lang/' . $langCode;
     $file = $dir . '/register.txt';
     // make sure the directory exists
     if (!file_exists($dir)) {
         if (mkdir($dir, 0755) === false) {
             echo $this->getLang('makeDirError');
             return;
         }
     }
     // save the file
     if (file_put_contents($file, $text) === false) {
         echo $this->getLang('saveFileError');
         return;
     }
     // set file permissions
     chmod($file, 0644);
     // log the change
     $timestamp = time();
     $id = $langCode . ':register';
     addLogEntry($timestamp, $id);
     // save this revision in the attic
     $atticFile = wikiFN($id, $timestamp, true);
     io_saveFile($atticFile, $text, false);
     // send OK to the browser
     echo 'OK';
 }
コード例 #2
0
 function pagefromtemplate(&$event, $param)
 {
     if (strlen(trim($_REQUEST['newpagetemplate'])) > 0) {
         global $conf;
         global $INFO;
         global $ID;
         $tpl = io_readFile(wikiFN($_REQUEST['newpagetemplate']));
         if ($this->getConf('userreplace')) {
             $stringvars = array_map(create_function('$v', 'return explode(",",$v,2);'), explode(';', $_REQUEST['newpagevars']));
             foreach ($stringvars as $value) {
                 $tpl = str_replace(trim($value[0]), trim($value[1]), $tpl);
             }
         }
         if ($this->getConf('standardreplace')) {
             // replace placeholders
             $file = noNS($ID);
             $page = strtr($file, '_', ' ');
             $tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl);
             // we need the callback to work around strftime's char limit
             $tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
         }
         $event->result = $tpl;
         $event->preventDefault();
     }
 }
コード例 #3
0
function _getMenu($menu, $edit)
{
    global $conf, $ID, $REV, $INFO, $lang;
    $currID = false;
    // Remember $ID and $REV
    $svID = $ID;
    $svREV = $REV;
    // Parent side ID
    $sub = substr($ID, 0, strpos($ID, ":"));
    $menuOutput = "";
    if (file_exists(wikiFN($ID . "/" . $menu))) {
        $menuOutput = p_wiki_xhtml($ID . "/" . $menu, '', false);
        $currID = $ID;
        $menuID = $currID . ":" . $menu;
    } else {
        if (file_exists(wikiFN($sub . "/" . $menu))) {
            $menuOutput = p_wiki_xhtml($sub . "/" . $menu, '', false);
            $currID = $sub;
            $menuID = $currID . ":" . $menu;
        }
    }
    if ($INFO['perm'] > AUTH_READ && true == $edit) {
        $menuOutput = '<ul><li><a href="?id=' . $menuID . '&amp;do=edit" class="wikilink1" title="Edit Menu"><b>Edit Menu</b></a></li></ul>';
    }
    $ID = $svID;
    $REV = $svREV;
    return $menuOutput;
}
コード例 #4
0
ファイル: action.php プロジェクト: raster/DokuWiki-randompage
 function action_randompage(&$event, $args)
 {
     global $conf;
     global $ID;
     $data = array();
     $dir = $conf['savedir'];
     $data = file($dir . '/index/page.idx');
     //We loops through ten random page...
     $i = 1;
     while ($i <= 10 & $i != "ok") {
         //echo $i;
         $i++;
         $id = rtrim($data[array_rand($data, 1)]);
         $testACL = auth_aclcheck($id, $_SERVER['REMOTE_USER'], $USERINFO['grps']);
         if ($testACL > 1 and file_exists(wikiFN($id))) {
             $i = "ok";
             //echo $id;
         }
     }
     if ($testACL < 1) {
         $id = $ID;
     }
     header("Location: " . wl($id, '', true));
     //echo wl($page,'',true);
     exit;
 }
コード例 #5
0
ファイル: renderer.php プロジェクト: virk/dokuwiki-strata
 function document_start()
 {
     global $ID;
     if (!@file_exists(wikiFN($ID))) {
         $this->persistent['date']['created'] = time();
     }
     parent::document_start();
 }
コード例 #6
0
 function getAllPages()
 {
     $namespace = $this->getConf("translationns");
     $dir = dirname(wikiFN("{$namespace}:foo"));
     $pages = array();
     search($pages, $dir, 'search_allpages', array());
     return $pages;
 }
コード例 #7
0
ファイル: action.php プロジェクト: omusico/isle-web-framework
 function get_epub($event, $param)
 {
     global $ID;
     global $USERINFO;
     if (!isset($USERINFO)) {
         return;
     }
     $user = $USERINFO['name'];
     global $ACT;
     global $INFO;
     if ($ACT != 'show') {
         return;
     }
     if (!$this->helper) {
         $this->helper = $this->loadHelper('epub', true);
     }
     if (!$this->helper->is_inCache($INFO['id'])) {
         return;
     }
     //cache set in syntax.php
     if (strpos($INFO['id'], 'epub') === false) {
         return;
     }
     $wiki_file = wikiFN($INFO['id']);
     if (!@file_exists($wiki_file)) {
         return;
     }
     $epub_group = $this->getConf('group');
     $groups = $USERINFO['grps'];
     $auth = auth_quickaclcheck('epub:*');
     if ($auth < 8 && !in_array($epub_group, $groups)) {
         return;
     }
     $auth = auth_quickaclcheck($INFO['id']);
     if ($auth < 4) {
         return;
     }
     $client = $INFO['client'];
     $button_name = $this->getLang('button_start');
     //"Start"; //$this->getLang('btn_generate');
     $button = "<form class='button'>";
     $button .= "<div class='no' id='show_throbberbutton'><input type='button' value='{$button_name}' class='button' title='start'  onclick=\"_epub_show_throbber('{$user}','{$client}');\"/>";
     $button .= "&nbsp;&nbsp;";
     $button .= $this->getLang('label_start');
     //"Click the Start Button to Create your eBook";
     $button .= "</div></form>";
     echo $button;
     $id = $INFO['id'];
     $button_name = $this->getLang('button_remove');
     $button = "<p><form class='button'>";
     $button .= "<div class='no' id='epub_remove_button'><input type='button' value='{$button_name}' class='button' title='start'  onclick=\"epub_remove_creator('{$id}');\"/></div></form>";
     $button .= '</br>' . $this->locale_xhtml('remove') . '</p>';
     echo $button;
 }
コード例 #8
0
 /**
  * test a future revision
  *
  */
 function test_futurerev()
 {
     $rev = 1385051947;
     $revsexpected = '';
     //set a known timestamp
     touch(wikiFN($this->pageid), $rev);
     $rev += 1;
     $pagelog = new PageChangeLog($this->pageid, $chunk_size = 8192);
     $revs = $pagelog->getLastRevisionAt($rev);
     $this->assertEquals($revsexpected, $revs);
 }
コード例 #9
0
 protected function cleanPage($pageId)
 {
     $filename = wikiFN($pageId);
     if (!file_exists($filename)) {
         throw new \Exception('Cannot delete page. It does not exist');
     }
     $this->logger('delete', $filename);
     unlink($filename);
     $this->logger('sweepNS', '[datadir]');
     io_sweepNS($pageId, 'datadir');
 }
コード例 #10
0
 function test_rename_to_new_page()
 {
     $newid = 'new_id_1';
     $oldpid = $this->indexer->getPID($this->old_id);
     $this->assertTrue($this->indexer->renamePage($this->old_id, $newid), 'Renaming the page to a new id failed');
     io_rename(wikiFN($this->old_id), wikiFN($newid));
     $this->assertNotEquals($this->indexer->getPID($this->old_id), $oldpid, 'PID for the old page unchanged after rename.');
     $this->assertEquals($this->indexer->getPID($newid), $oldpid, 'New page has not the old pid.');
     $query = array('old');
     $this->assertEquals(array('old' => array($newid => 1)), $this->indexer->lookup($query), '"Old" doesn\'t find the new page');
 }
コード例 #11
0
 /**
  * Handler to load page template.
  *
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function get_template(Doku_Event &$event, $param)
 {
     if (strlen($_REQUEST['copyfrom']) > 0) {
         $template_id = $_REQUEST['copyfrom'];
         if (auth_quickaclcheck($template_id) >= AUTH_READ) {
             $tpl = io_readFile(wikiFN($template_id));
             $event->data['tpl'] = $tpl;
             $event->preventDefault();
         }
     }
 }
コード例 #12
0
function indexmenu_search_index(&$data, $base, $file, $type, $lvl, $opts)
{
    global $conf;
    $ret = true;
    $item = array();
    if ($type == 'f' && !preg_match('#\\.txt$#', $file)) {
        // don't add
        return false;
    }
    // get page id by filename
    $id = pathID($file);
    // check hiddens
    if ($type == 'f' && isHiddenPage($id)) {
        return false;
    }
    //  bugfix for the
    //  /ns/
    //  /<ns>.txt
    //  case, need to force the 'directory' type
    if ($type == 'f' && file_exists(dirname(wikiFN($id . ":" . noNS($id))))) {
        $type = 'd';
    }
    // page target id = global id
    $target = $id;
    if ($type == 'd') {
        // this will check 3 kinds of headpage:
        // 1. /<ns>/<ns>.txt
        // 2. /<ns>/
        //    /<ns>.txt
        // 3. /<ns>/
        //    /<ns>/<start_page>
        $nsa = array($id . ":" . noNS($id), $id, $id . ":" . $conf['start']);
        $nspage = false;
        foreach ($nsa as $nsp) {
            if (@file_exists(wikiFN($nsp)) && auth_quickaclcheck($nsp) >= AUTH_READ) {
                $nspage = $nsp;
                break;
            }
        }
        //headpage exists
        if ($nspage) {
            $target = $nspage;
        } else {
            // open namespace index, if headpage does not exists
            $target = $target . ':';
        }
    }
    $data[] = array('id' => $id, 'date' => @filectime(wikiFN($target)), 'type' => $type, 'target' => $target, 'title' => $conf['useheading'] && ($title = p_get_first_heading($target)) ? $title : $id, 'level' => $lvl);
    if (substr_count($id, ":") > 2) {
        $ret = 0;
    }
    return $ret;
}
コード例 #13
0
ファイル: number.php プロジェクト: omusico/isle-web-framework
 /**
  * Executed after performing the action hooks
  *
  * Increases counter and purge cache
  */
 public function after_action()
 {
     if ($this->autoinc) {
         global $ID;
         p_set_metadata($ID, array('bureaucracy' => array($this->get_key() => $this->opt['value'] + 1)));
         // Force rerendering by removing the instructions cache file
         $cache_fn = getCacheName(wikiFN($ID) . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . 'i');
         if (file_exists($cache_fn)) {
             unlink($cache_fn);
         }
     }
 }
コード例 #14
0
 public function handle_dokuwiki_started(&$event, $param)
 {
     global $ID, $ACT, $REV;
     if ($ACT != 'show' && $ACT != '' || $REV) {
         return;
     }
     $page = p_get_metadata($ID, 'relation isreplacedby');
     // return if no redirection data
     if (empty($page)) {
         return;
     }
     if (isset($_GET['redirect'])) {
         // return if redirection is temporarily disabled,
         // or we have been redirected 5 times in a row
         if ($_GET['redirect'] == 'no' || $_GET['redirect'] > 4) {
             return;
         } elseif ($_GET['redirect'] > 0) {
             $redirect = $_GET['redirect'] + 1;
         } else {
             $redirect = 1;
         }
     } else {
         $redirect = 1;
     }
     // verify metadata currency
     if (@filemtime(metaFN($ID, '.meta')) < @filemtime(wikiFN($ID))) {
         return;
     }
     // preserve #section from $page
     list($page, $section) = explode('#', $page, 2);
     if (isset($section)) {
         $section = '#' . $section;
     } else {
         $section = '';
     }
     // prepare link for internal redirects, keep external targets
     if (!preg_match('#^https?://#i', $page)) {
         $page = wl($page, array('redirect' => $redirect), TRUE, '&');
         if (!headers_sent() && $this->getConf('show_note')) {
             // remember to show note about being redirected from another page
             session_start();
             $_SESSION[DOKU_COOKIE]['redirect'] = $ID;
         }
     }
     // redirect
     header("HTTP/1.1 301 Moved Permanently");
     header("Location: " . $page . $section . $_SERVER['QUERY_STRING']);
     exit;
 }
コード例 #15
0
ファイル: latex.php プロジェクト: omusico/isle-web-framework
 function label_document()
 {
     //For links
     if (isset($this->info['current_file_id'])) {
         $cleanid = $this->info['current_file_id'];
     } else {
         $cleanid = noNS(cleanID($this->info['current_id'], TRUE));
     }
     $this->putcmd("label{" . md5($cleanid) . "}");
     if (isset($this->info['current_file_id'])) {
         $this->putnl("%%Start: " . $cleanid . ' => ' . $this->info['current_file_id']);
     } else {
         $this->putnl("%%Start: " . $cleanid . ' => ' . wikiFN($cleanid));
     }
 }
コード例 #16
0
ファイル: example.php プロジェクト: roverrobot/components
 protected function call($params)
 {
     $id = cleanID($params['id']);
     if (!file_exists(wikiFN($id))) {
         // return an error and exit;
         $this->error(404);
     }
     $range = $params['range'];
     if (!isset($range['from']) || !isset($range['to'])) {
         // an error with a specific message, and exit
         $this->error(400, "range must have a from proterty and a to property");
     }
     // return the slice
     return rawWikiSlices($range['from'] . '-' . $range['to'], $id)[1];
 }
コード例 #17
0
function getSidebarFN($ns, $file)
{
    // check for wiki page = $ns:$file (or $file where no namespace)
    $nsFile = $ns ? "{$ns}:{$file}" : $file;
    if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile)) {
        return $nsFile;
    }
    // remove deepest namespace level and call function recursively
    // no namespace left, exit with no file found
    if (!$ns) {
        return '';
    }
    $i = strrpos($ns, ":");
    $ns = $i ? substr($ns, 0, $i) : false;
    return getSidebarFN($ns, $file);
}
コード例 #18
0
ファイル: cache_use.test.php プロジェクト: richmahn/Door43
 function setUp()
 {
     global $ID, $conf;
     parent::setUp();
     $ID = 'cached';
     $file = wikiFN($ID);
     $conf['cachetime'] = 0;
     // ensure the value is not -1, which disables caching
     saveWikiText($ID, 'Content', 'Created');
     $this->cache = new cache_renderer($ID, $file, 'xhtml');
     $this->cache->storeCache('Test');
     // set the modification times explicitly (overcome Issue #694)
     $time = time();
     touch($file, $time - 1);
     touch($this->cache->cache, $time);
 }
コード例 #19
0
    function print_overlay(&$event, $param)
    {
        global $ID;
        $overlay = '';
        $paths = $this->getConf('nsoverlays');
        $namespace = getNS($ID);
        $sort_paths = $this->_natsort_ns($paths);
        $sort_paths = explode(',', $sort_paths);
        $overlays = $this->_get_overlays($sort_paths);
        $parent_ns = $this->_get_parent_ns($namespace);
        foreach ($overlays as $key => $val) {
            // first check if was specified an overlay for a specific namespace
            if ($val[1] != '') {
                if ($val[1] == ':') {
                    $overlay = $overlays[$key][0];
                } elseif (strpos($namespace, $val[1]) === 0) {
                    $overlay = $overlays[$key][0];
                    break;
                }
            } else {
                if ($overlay == '') {
                    if ('' == $val[1]) {
                        foreach ($parent_ns as $ns) {
                            $wikifile = wikiFN($ns . ':' . $val[0]);
                            if (file_exists($wikifile)) {
                                $overlay = str_replace('/', ':', $ns) . ':' . $val[0];
                                break 2;
                            }
                        }
                    }
                }
            }
        }
        if (auth_quickaclcheck($ID) >= AUTH_READ) {
            $insert = p_wiki_xhtml($overlay);
        }
        if (!$insert) {
            return;
        }
        $close = trim($this->getLang('close'));
        $text = <<<TEXT
<div id='overlay'><div  class = "close">
<a href="javascript:jQuery('#overlay').toggle();void(0);" rel="nofollow" title="{$close}">{$close}</a>
</div> {$insert}</div>
TEXT;
        echo $text;
    }
コード例 #20
0
ファイル: dwpage.php プロジェクト: stretchyboy/dokuwiki
function clearLock($WIKI_ID)
{
    global $USERNAME;
    if (!file_exists(wikiFN($WIKI_ID))) {
        fwrite(STDERR, "{$WIKI_ID} does not yet exist\n");
    }
    $_SERVER['REMOTE_USER'] = $USERNAME;
    if (checklock($WIKI_ID)) {
        fwrite(STDERR, "Page {$WIKI_ID} is locked by another user\n");
        exit(1);
    }
    unlock($WIKI_ID);
    if (file_exists(wikiLockFN($WIKI_ID))) {
        fwrite(STDERR, "Unable to clear lock for {$WIKI_ID}\n");
        exit(1);
    }
}
コード例 #21
0
 public function test_move_wiki_namespace()
 {
     $this->markTestSkipped('This test is failing.');
     global $AUTH_ACL;
     $AUTH_ACL[] = "wiki:*\t@ALL\t16";
     idx_addPage('wiki:dokuwiki');
     idx_addPage('wiki:syntax');
     /** @var helper_plugin_move $move  */
     $move = plugin_load('helper', 'move');
     $opts = array('ns' => 'wiki', 'newns' => 'foo', 'contenttomove' => 'both');
     $this->assertSame(3, $move->start_namespace_move($opts));
     $this->assertSame(1, $move->continue_namespace_move());
     $this->assertSame(0, $move->continue_namespace_move());
     $this->assertFileExists(wikiFN('foo:dokuwiki'));
     $this->assertFileNotExists(wikiFN('wiki:syntax'));
     $this->assertFileExists(mediaFN('foo:dokuwiki-128.png'));
 }
コード例 #22
0
ファイル: tpl_functions.php プロジェクト: hannesdorn/newday
/**
 * Renders the topbar
 *
 * @author Michael Klier <*****@*****.**>
 * @author Louis Wolf <*****@*****.**>
 */
function tpl_topbar()
{
    global $ID;
    $found = false;
    $tbar = '';
    $path = explode(':', $ID);
    while (!$found && count($path) >= 0) {
        $tbar = implode(':', $path) . ':' . 'topbar';
        $found = @file_exists(wikiFN($tbar));
        array_pop($path);
        // check if nothing was found
        if (!$found && $tbar == ':topbar') {
            return;
        }
    }
    if ($found && auth_quickaclcheck($tbar) >= AUTH_READ) {
        $toolbar = p_wiki_xhtml($tbar, '', false);
        $lines = explode("\n", $toolbar);
        $nr = count($lines);
        $open_ul = 0;
        $primary_ul = 0;
        $positions = array();
        for ($i = 0; $i < $nr; $i++) {
            if (trim($lines[$i]) == '<ul>') {
                $open_ul = $open_ul + 1;
                if ($open_ul == 1) {
                    $primary_ul++;
                    $lines[$i] = '<ul class="primary">' . "\n";
                    array_push($positions, $i);
                }
            } else {
                if (strpos($lines[$i], '</ul>') !== false) {
                    $open_ul = $open_ul - 1;
                }
            }
        }
        $first_position = $positions[0];
        $last_position = $positions[count($positions) - 1];
        $lines[$first_position] = '<ul class="primary start">' . "\n";
        $lines[$last_position] = '<ul class="primary end">' . "\n";
        $width = $primary_ul * 150;
        print '<div id="tpl_simple_navi" style="width:' . $width . 'px;">';
        print implode($lines);
        print '</div>';
    }
}
コード例 #23
0
ファイル: wantedpages.php プロジェクト: jotttt/ttu-wiki
 /**
  * Your main program
  *
  * Arguments and options have been parsed when this is run
  *
  * @param DokuCLI_Options $options
  * @return void
  */
 protected function main(DokuCLI_Options $options)
 {
     if ($options->args) {
         $startdir = dirname(wikiFN($options->args[0] . ':xxx'));
     } else {
         $startdir = dirname(wikiFN('xxx'));
     }
     $this->info("searching {$startdir}");
     $wanted_pages = array();
     foreach ($this->get_pages($startdir) as $page) {
         $wanted_pages = array_merge($wanted_pages, $this->internal_links($page));
     }
     $wanted_pages = array_unique($wanted_pages);
     sort($wanted_pages);
     foreach ($wanted_pages as $page) {
         print $page . "\n";
     }
 }
コード例 #24
0
ファイル: metadata.php プロジェクト: lorea/Hydra-dev
 function document_end()
 {
     global $ID;
     // store internal info in metadata (notoc,nocache)
     $this->meta['internal'] = $this->info;
     if (!isset($this->meta['description']['abstract'])) {
         // cut off too long abstracts
         $this->doc = trim($this->doc);
         if (strlen($this->doc) > 500) {
             $this->doc = utf8_substr($this->doc, 0, 500) . '…';
         }
         $this->meta['description']['abstract'] = $this->doc;
     }
     $this->meta['relation']['firstimage'] = $this->firstimage;
     if (!isset($this->meta['date']['modified'])) {
         $this->meta['date']['modified'] = filemtime(wikiFN($ID));
     }
 }
コード例 #25
0
 function test_staleness()
 {
     global $ID;
     $ID = 'stale';
     $file = wikiFN($ID);
     # Prepare test page
     saveWikiText($ID, 'Fresh', 'Created');
     # Create stale cache
     $cache = new cache_renderer($ID, $file, 'xhtml');
     $cache->storeCache('Stale');
     $stale = $cache->retrieveCache();
     # Prepare stale cache for testing
     $time = filemtime($file);
     touch($cache->cache, $time);
     # Make the test
     $fresh = p_cached_output($file, 'xhtml', $ID);
     $this->assertNotEquals($fresh, $stale, 'Stale cache failed to expire');
 }
コード例 #26
0
 public function handle_common_pagetpl_load(Doku_Event &$event, $param)
 {
     global $conf;
     if (empty($event->data['tplfile'])) {
         $path = dirname(wikiFN($event->data['id']));
         $len = strlen(rtrim($conf['datadir'], '/'));
         $dir = substr($path, strrpos($path, '/') + 1);
         $blnFirst = true;
         $blnFirstDir = true;
         while (strLen($path) >= $len) {
             if ($blnFirst == true && @file_exists($path . '/_' . noNS($event->data['id']) . '.txt')) {
                 $event->data['tplfile'] = $path . '/_' . noNS($event->data['id'] . '.txt');
                 break;
             } elseif (@file_exists($path . '/__' . noNS($event->data['id']) . '.txt')) {
                 $event->data['tplfile'] = $path . '/__' . noNS($event->data['id'] . '.txt');
                 break;
             } elseif ($blnFirst == true && @file_exists($path . '/_template.txt')) {
                 $event->data['tplfile'] = $path . '/_template.txt';
                 break;
             } elseif ($blnFirst == false && $blnFirstDir == true && @file_exists($path . '/~_' . $dir . '.txt') && noNS($event->data['id']) == 'start') {
                 $event->data['tplfile'] = $path . '/~_' . $dir . '.txt';
                 break;
             } elseif ($blnFirst == false && $blnFirstDir == true && @file_exists($path . '/~' . $dir . '.txt')) {
                 $event->data['tplfile'] = $path . '/~' . $dir . '.txt';
                 break;
             } elseif ($blnFirst == false && @file_exists($path . '/~~_' . $dir . '.txt') && noNS($event->data['id']) == 'start') {
                 $event->data['tplfile'] = $path . '/~~_' . $dir . '.txt';
                 break;
             } elseif ($blnFirst == false && @file_exists($path . '/~~' . $dir . '.txt')) {
                 $event->data['tplfile'] = $path . '/~~' . $dir . '.txt';
                 break;
             } elseif (@file_exists($path . '/__template.txt')) {
                 $event->data['tplfile'] = $path . '/__template.txt';
                 break;
             }
             $path = substr($path, 0, strrpos($path, '/'));
             if ($blnFirst == false) {
                 $blnFirstDir = false;
             }
             $blnFirst = false;
         }
     }
 }
コード例 #27
0
 /**
  * @group slow
  */
 function test_cache_handling()
 {
     $testid = 'wiki:bar:test';
     saveWikiText($testid, '[[wiki:foo:]]', 'Test setup');
     idx_addPage($testid);
     saveWikiText('wiki:foo:start', 'bar', 'Test setup');
     idx_addPage('wiki:foo:start');
     sleep(1);
     // wait in order to make sure that conditions with < give the right result.
     p_wiki_xhtml($testid);
     // populate cache
     $cache = new cache_renderer($testid, wikiFN($testid), 'xhtml');
     $this->assertTrue($cache->useCache());
     /** @var helper_plugin_move_op $move */
     $move = plugin_load('helper', 'move_op');
     $this->assertTrue($move->movePage('wiki:foo:start', 'wiki:foo2:start'));
     $cache = new cache_renderer($testid, wikiFN($testid), 'xhtml');
     $this->assertFalse($cache->useCache());
 }
コード例 #28
0
ファイル: action.php プロジェクト: neutrinog/Door43
	function handle_pageredirect_redirect(&$event, $param) {
		global $ID, $ACT, $REV;

		if (($ACT == 'show' || $ACT == '') && empty($REV)) {
			$page = p_get_metadata($ID,'relation isreplacedby');

			// return if no redirection data
			if (empty($page)) { return; }

			if (isset($_GET['redirect'])) {
				// return if redirection is temporarily disabled,
				// or we have been redirected 5 times in a row
				if ($_GET['redirect'] == 'no' || $_GET['redirect'] > 4) { return; }
				elseif ($_GET['redirect'] > 0) { $redirect = $_GET['redirect'] +1; }
				else { $redirect = 1; }
			} else {
				$redirect = 1;
			}

			// verify metadata currency
			if (@filemtime(metaFN($ID,'.meta')) < @filemtime(wikiFN($ID))) { return; }

			if (!headers_sent() && $this->getConf('show_note')) {
				// remember to show note about being redirected from another page
				session_start();
				$_SESSION[DOKU_COOKIE]['redirect'] = $ID;
			}

			// preserve #section from $page
			list($page, $section) = explode('#', $page, 2);
			if (isset($section)) {
				$section = '#' . $section;
			} else {
				$section = '';
			}

			// redirect
			header("HTTP/1.1 301 Moved Permanently");
			header("Location: ".wl($page, Array('redirect' => $redirect), TRUE, '&'). $section);
			exit();
		}
	}
コード例 #29
0
function getSidebarFN($ns, $file, $callingID)
{
    // check for wiki page = $ns:$file (or $file where no namespace)
    $nsFile = $ns ? "{$ns}:{$file}" : $file;
    // As a preference, if this is the root directory, check to see if there's a namespace
    // named the same as the page we're currently viewing with a sidebar in
    //	if ($nsFile == $file) $nsFile = "$callingID:$file";
    //	echo "$nsFile;$callingID;$ns;$file";
    if (file_exists(wikiFN($nsFile)) && auth_quickaclcheck($nsFile)) {
        return $nsFile;
    }
    // remove deepest namespace level and call function recursively
    // no namespace left, exit with no file found
    if (!$ns) {
        return '';
    }
    $i = strrpos($ns, ":");
    $ns = $i ? substr($ns, 0, $i) : false;
    return getSidebarFN($ns, $file, $callingID);
}
コード例 #30
0
 /**
  * Checks if 'newentry' was given as action, if so we
  * do handle the event our self and no further checking takes place
  */
 function handle_act_preprocess(&$event, $param)
 {
     //if ($event->data != 'newentry') return; // nothing to do for us
     global $ACT;
     global $ID;
     echo "param={$param}";
     return;
     // we can handle it -> prevent others
     $event->stopPropagation();
     $event->preventDefault();
     $ns = $_REQUEST['ns'];
     $title = str_replace(':', '', $_REQUEST['title']);
     $id = ($ns ? $ns . ':' : '') . cleanID($title);
     // check if we are allowed to create this file
     if (auth_quickaclcheck($id) >= AUTH_CREATE) {
         $back = $ID;
         $ID = $id;
         $file = wikiFN($ID);
         //check if locked by anyone - if not lock for my self
         if (checklock($ID)) {
             $ACT = 'locked';
         } else {
             lock($ID);
         }
         // prepare the new thread file with default stuff
         if (!@file_exists($file)) {
             global $TEXT;
             global $INFO;
             global $conf;
             $TEXT = pageTemplate($ns . ':' . $title);
             if (!$TEXT) {
                 $TEXT = "====== {$title} ======\n\n\n\n" . "~~DISCUSSION~~\n";
             }
             $ACT = 'preview';
         } else {
             $ACT = 'edit';
         }
     } else {
         $ACT = 'show';
     }
 }