Пример #1
0
 public function tearDown()
 {
     foreach ($this->ids as $id) {
         saveWikiText($id, '', 'deleted in tearDown()');
         @unlink(metaFN($id, '.meta'));
     }
 }
Пример #2
0
 /**
  * Handle the match
  */
 function handle($match, $state, $pos, &$handler)
 {
     global $ID;
     global $ACT;
     // don't show linkback section on blog mainpages
     if (defined('IS_BLOG_MAINPAGE')) {
         return false;
     }
     // don't allow usage of syntax in comments
     if (isset($_REQUEST['comment'])) {
         return false;
     }
     // get linkback meta file name
     $file = metaFN($ID, '.linkbacks');
     $data = array('send' => false, 'receive' => false, 'display' => false, 'sentpings' => array(), 'receivedpings' => array(), 'number' => 0);
     if (@file_exists($file)) {
         $data = unserialize(io_readFile($file, false));
     }
     if ($match == '~~LINKBACK~~') {
         $data['receive'] = true;
         $data['display'] = true;
     } else {
         if ($match == '~~LINKBACK:off~~') {
             $data['receive'] = false;
             $data['display'] = false;
         } else {
             $data['receive'] = false;
             $data['display'] = true;
         }
     }
     io_saveFile($file, serialize($data));
 }
Пример #3
0
 /**
  * Handle the match
  */
 function handle($match, $state, $pos, &$handler)
 {
     global $ID, $ACT;
     // strip markup
     $match = substr($match, 12, -2);
     // split title (if there is one)
     list($match, $title) = explode('|', $match, 2);
     // assign discussion state
     if ($match == ':off') {
         $status = 0;
     } else {
         if ($match == ':closed') {
             $status = 2;
         } else {
             $status = 1;
         }
     }
     if ($ACT == 'preview') {
         return;
     }
     // get discussion meta file name
     $file = metaFN($ID, '.comments');
     $data = array();
     if (@file_exists($file)) {
         $data = unserialize(io_readFile($file, false));
     }
     $data['title'] = $title;
     $data['status'] = $status;
     io_saveFile($file, serialize($data));
     return $status;
 }
 function handle_approve(&$event, $param)
 {
     global $ID, $REV, $INFO;
     if ($event->data == 'show' && isset($_GET['approve'])) {
         if (!$this->can_approve()) {
             return;
         }
         //change last commit comment to Approved
         $meta = p_read_metadata($ID);
         $meta[current][last_change][sum] = $meta[persistent][last_change][sum] = APPROVED;
         $meta[current][last_change][user] = $meta[persistent][last_change][user] = $INFO[client];
         if (!array_key_exists($INFO[client], $meta[current][contributor])) {
             $meta[current][contributor][$INFO[client]] = $INFO[userinfo][name];
             $meta[persistent][contributor][$INFO[client]] = $INFO[userinfo][name];
         }
         p_save_metadata($ID, $meta);
         //update changelog
         //remove last line from file
         $changelog_file = metaFN($ID, '.changes');
         $changes = file($changelog_file, FILE_SKIP_EMPTY_LINES);
         $lastLogLine = array_pop($changes);
         $info = parseChangelogLine($lastLogLine);
         $info[user] = $INFO[client];
         $info[sum] = APPROVED;
         $logline = implode("\t", $info) . "\n";
         array_push($changes, $logline);
         io_saveFile($changelog_file, implode('', $changes));
         header('Location: ?id=' . $ID);
     }
 }
Пример #5
0
 function __construct()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     if ($this->is_excluded($ip, true)) {
         exit("403: Not Available");
     }
     $this->ipaddr = $ip;
     $today = getdate();
     $ns_prefix = "quickstats:";
     $ns = $ns_prefix . $today['mon'] . '_' . $today['year'] . ':';
     $this->page_file = metaFN($ns . 'pages', '.ser');
     $this->ua_file = metaFN($ns . 'ua', '.ser');
     $this->ip_file = metaFN($ns . 'ip', '.ser');
     $this->misc_data_file = metaFN($ns . 'misc_data', '.ser');
     $this->qs_file = metaFN($ns . 'qs_data', '.ser');
     $this->page_users_file = metaFN($ns . 'page_users', '.ser');
     $this->page_totals_file = metaFN($ns_prefix . 'page_totals', '.ser');
     $this->year_month = $today['mon'] . '_' . $today['year'];
     if (preg_match('/WINNT/i', PHP_OS)) {
         $this->SEP = '\\';
     }
     $this->show_date = $this->getConf('show_date');
     $this->dw_tokens = array('do', 'sectok', 'page', 's[]', 'id', 'rev', 'idx');
     $conf_tokens = $this->getConf('xcl_name_val');
     if (!empty($conf_tokens)) {
         $conf_tokens = explode(',', $conf_tokens);
         if (!empty($conf_tokens)) {
             $this->dw_tokens = array_merge($this->dw_tokens, $conf_tokens);
         }
     }
     $this->helper = $this->loadHelper('quickstats', true);
 }
Пример #6
0
 function __construct()
 {
     $this->script_file = metaFN('epub:cache', '.ser');
     $this->cache = unserialize(io_readFile($this->script_file, false));
     if (!$this->cache) {
         $this->cache = array();
     }
 }
Пример #7
0
function numberingDB()
{
    $db = metaFN("numbering:seqnum", '.ser');
    if (!file_exists($db)) {
        io_saveFile($db, "", array());
    }
    return $db;
}
Пример #8
0
 function __construct()
 {
     $this->script_file = metaFN('quickstats:cache', '.ser');
     $this->cache = unserialize(io_readFile($this->script_file, false));
     if (!$this->cache) {
         $this->cache = array();
     }
     $this->cc_arrays = new ccArraysDat();
 }
Пример #9
0
 /**
  */
 function process_feed(&$event, $param)
 {
     global $ID;
     if ($this->helper->pageUpdated()) {
         $metafile = metaFN('newsfeed:wasupdated', '.meta');
         io_saveFile($metafile, time() . "\n" . $ID . "\n");
         $this->helper->saveFeedData($ID);
     }
 }
Пример #10
0
 /**
  * Return the subscription meta file for the given ID
  *
  * @author Adrian Lang <*****@*****.**>
  *
  * @param string $id The target page or namespace, specified by id; Namespaces
  *                   are identified by appending a colon.
  * @return string
  */
 protected function file($id)
 {
     $meta_fname = '.mlist';
     if (substr($id, -1, 1) === ':') {
         $meta_froot = getNS($id);
         $meta_fname = '/' . $meta_fname;
     } else {
         $meta_froot = $id;
     }
     return metaFN((string) $meta_froot, $meta_fname);
 }
Пример #11
0
/**
 * Get the name of the metafile tracking subscriptions to target page or
 * namespace
 *
 * @param string $id The target page or namespace, specified by id; Namespaces
 *                   are identified by appending a colon.
 *
 * @author Adrian Lang <*****@*****.**>
 */
function subscription_filename($id)
{
    $meta_fname = '.mlist';
    if (substr($id, -1, 1) === ':') {
        $meta_froot = getNS($id);
        if ($meta_froot === false) {
            $meta_fname = '/' . $meta_fname;
        }
    } else {
        $meta_froot = $id;
    }
    return metaFN($meta_froot, $meta_fname);
}
Пример #12
0
function epub_get_progress_dir($temp_user = null)
{
    static $dir;
    $seed = md5(rawurldecode($_POST['user']) . time());
    if (!$dir) {
        if (isset($_POST['client'])) {
            $user = rawurldecode($_POST['client']) . ":{$seed}";
        } else {
            $user = $temp_user ? "{$temp_user}:{$seed}" : $seed;
        }
        $dir = dirname(metaFN("epub:{$user}:tmp", '.meta')) . '/';
    }
    return $dir;
}
 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;
 }
Пример #14
0
function _index($id)
{
    global $INDEXER;
    global $CLEAR;
    global $QUIET;
    // if not cleared only update changed and new files
    if ($CLEAR) {
        $idxtag = metaFN($id, '.indexed');
        if (@file_exists($idxtag)) {
            @unlink($idxtag);
        }
    }
    _quietecho("{$id}... ");
    idx_addPage($id, !$QUIET);
    _quietecho("done.\n");
}
Пример #15
0
/**
 * function for the search callback
 */
function search_discussionpages(&$data, $base, $file, $type, $lvl, $opts)
{
    global $conf;
    if ($type == 'd') {
        return true;
    }
    // recurse into directories
    if (!preg_match('#' . preg_quote('/' . DISCUSSION_NS . '/', '#') . '#u', $file)) {
        return false;
    }
    if (!preg_match('#\\.txt$#', $file)) {
        return false;
    }
    $id = pathID(str_replace(DISCUSSION_NS . '/', '', $file));
    $data[] = array('id' => $id, 'old' => $conf['datadir'] . $file, 'new' => metaFN($id, '.comments'));
    return true;
}
Пример #16
0
	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();
		}
	}
Пример #17
0
 /**
  * Create output
  */
 function render($mode, &$renderer, $data)
 {
     if (empty($data)) {
         return false;
     }
     global $ID;
     if ($mode == 'xhtml') {
         list($state, $match) = $data;
         switch ($state) {
             case DOKU_LEXER_SPECIAL:
                 $this->helper->setUpdate($match);
                 $metafile = metaFN('newsfeed:timestamp', '.meta');
                 io_saveFile($metafile, time());
                 $renderer->doc .= "";
                 break;
         }
         return true;
     }
     return false;
 }
 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();
             if (!isset($_SESSION[DOKU_COOKIE]['redirect']) || $redirect == 1) {
                 $_SESSION[DOKU_COOKIE]['redirect'] = $ID;
             }
         }
         // redirect
         resolve_pageid(getNS($ID), $page, $exists);
         header("Location: " . wl($page, array('redirect' => $redirect), TRUE, '&'));
         exit;
     }
 }
Пример #19
0
 /**
  * Handle the match
  */
 function handle($match, $state, $pos, &$handler)
 {
     global $ID, $ACT, $REV;
     // strip markup
     $match = substr($match, 12, -2);
     // split title (if there is one)
     list($match, $title) = explode('|', $match, 2);
     // assign discussion state
     if ($match == ':off') {
         $status = 0;
     } else {
         if ($match == ':closed') {
             $status = 2;
         } else {
             $status = 1;
         }
     }
     if ($ACT == 'preview' || $REV) {
         return false;
     }
     // get discussion meta file name
     $file = metaFN($ID, '.comments');
     $data = array();
     if (@file_exists($file)) {
         $data = unserialize(io_readFile($file, false));
     }
     // only save when the status or title was actually changed, the timestamp of the .comments file is used
     // as sorting criteria for the threads view!
     // note that isset can't be used for the first test as isset returns false for NULL values!
     if (!array_key_exists('title', $data) || $data['title'] !== $title || !isset($data['status']) || $data['status'] !== $status) {
         $data['title'] = $title;
         $data['status'] = $status;
         io_saveFile($file, serialize($data));
     }
     return $status;
 }
Пример #20
0
/**
 * read the metadata from source/cache for $id
 * (internal use only - called by p_get_metadata & p_set_metadata)
 *
 * this function also converts the metadata from the original format to
 * the current format ('current' & 'persistent' arrays)
 *
 * @author   Christopher Smith <*****@*****.**>
 *
 * @param    string   $id      absolute wiki page id
 * @param    bool     $cache   whether or not to cache metadata in memory
 *                             (only use for metadata likely to be accessed several times)
 *
 * @return   array             metadata
 */
function p_read_metadata($id, $cache = false)
{
    global $cache_metadata;
    if (isset($cache_metadata[(string) $id])) {
        return $cache_metadata[(string) $id];
    }
    $file = metaFN($id, '.meta');
    $meta = @file_exists($file) ? unserialize(io_readFile($file, false)) : array('current' => array(), 'persistent' => array());
    // convert $meta from old format to new (current+persistent) format
    if (!isset($meta['current'])) {
        $meta = array('current' => $meta, 'persistent' => $meta);
        // remove non-persistent keys
        unset($meta['persistent']['title']);
        unset($meta['persistent']['description']['abstract']);
        unset($meta['persistent']['description']['tableofcontents']);
        unset($meta['persistent']['relation']['haspart']);
        unset($meta['persistent']['relation']['references']);
        unset($meta['persistent']['date']['valid']);
        if (empty($meta['persistent']['description'])) {
            unset($meta['persistent']['description']);
        }
        if (empty($meta['persistent']['relation'])) {
            unset($meta['persistent']['relation']);
        }
        if (empty($meta['persistent']['date'])) {
            unset($meta['persistent']['date']);
        }
        // save converted metadata
        io_saveFile($file, serialize($meta));
    }
    if ($cache) {
        $cache_metadata[(string) $id] = $meta;
    }
    return $meta;
}
Пример #21
0
    function registerOnLoad($js)
    {
        global $ID;
        global $lang;
        global $skip_styling;
        $preview_button = $lang['btn_preview'];
        $ckgedit_conf_direction = $this->getConf('direction');
        if ($ckgedit_conf_direction == "dokuwiki") {
            $ckgedit_lang_direction = $lang['direction'];
        } else {
            $ckgedit_lang_direction = $ckgedit_conf_direction;
        }
        $ImageUploadAllowedExtensions = $this->get_ckgedit_ImageAllowedExtensions();
        $media_tmp_ns = preg_match('/:/', $ID) ? preg_replace('/:\\w+$/', "", $ID, 1) : "";
        $locktimer_msg = "Your lock for editing this page is about to expire in a minute.\\n" . "You can reset the timer by clicking the Back-up button.";
        $meta_fn = metaFN($ID, '.ckgedit');
        $meta_id = 'meta/' . str_replace(':', '/', $ID) . '.ckgedit';
        global $INFO;
        global $conf;
        global $USERINFO;
        $_OS = strtolower(PHP_OS);
        $cname = getCacheName($INFO['client'] . $ID, '.draft');
        $useheading = $conf['useheading'];
        if ($useheading && $useheading != 'content' && $useheading != '0') {
            $useheading = 'y';
        } else {
            $useheading = 'n';
        }
        //msg('uh='.$useheading);
        $open_upload = $this->getConf('open_upload');
        $editor_backup = $this->getConf('editor_bak');
        $create_folder = $this->getConf('create_folder');
        $interface_lang = $this->getConf('other_lang');
        $scayt_lang = $this->getConf('scayt_lang');
        list($name, $scayt_lang) = explode('/', $scayt_lang);
        $scayt_auto = $this->getConf('scayt_auto');
        $color_opts = $this->getConf('color_options');
        $font_opts = $this->getConf('font_options');
        $toolbar_opts = $this->getConf('alt_toolbar');
        $mfiles = $this->getConf('mfiles');
        if (!isset($INFO['userinfo']) && !$open_upload) {
            $user_type = 'visitor';
        } else {
            $user_type = 'user';
        }
        $save_dir = DOKU_URL . ltrim($conf['savedir'], '/.\\/');
        // if no ACL is used always return upload rights
        if ($conf['useacl']) {
            $client = $_SERVER['REMOTE_USER'];
        } else {
            $client = "";
        }
        $user_name = $USERINFO['name'];
        $user_email = $USERINFO['mail'];
        $fnencode = isset($conf['fnencode']) ? $conf['fnencode'] : 'url';
        $user_groups = $USERINFO['grps'];
        if (!$user_groups) {
            $user_groups = array();
        }
        if (@in_array("guest", $user_groups)) {
            $create_folder = 'n';
            $user_type = 'visitor';
        }
        $user_groups = implode(";;", $user_groups);
        if ($INFO['isadmin'] || $INFO['ismanager']) {
            $client = "";
        }
        $ver_anteater = mktime(0, 0, 0, 11, 7, 2010);
        $dwiki_version = mktime(0, 0, 0, 01, 01, 2008);
        if (isset($conf['fnencode'])) {
            $ver_anteater = mktime(0, 0, 0, 11, 7, 2010);
            $dwiki_version = mktime(0, 0, 0, 11, 7, 2010);
        } else {
            if (function_exists('getVersionData')) {
                $verdata = getVersionData();
                if (isset($verdata) && preg_match('/(\\d+)-(\\d+)-(\\d+)/', $verdata['date'], $ver_date)) {
                    if ($ver_date[1] >= 2005 && ($ver_date[3] > 0 && $ver_date[3] < 31) && ($ver_date[2] > 0 && $ver_date[2] <= 12)) {
                        // month        day               year
                        $dwiki_version = @mktime(0, 0, 0, $ver_date[2], $ver_date[3], $ver_date[1]);
                        if (!$dwiki_version) {
                            $dwiki_version = mktime(0, 0, 0, 01, 01, 2008);
                        }
                        $ver_anteater = mktime(0, 0, 0, 11, 7, 2010);
                    }
                }
            }
        }
        $default_fb = $this->getConf('default_fb');
        if ($default_fb == 'none') {
            $client = "";
        }
        $doku_base = DOKU_BASE;
        return <<<end_of_string


<script type='text/javascript'>
 //<![CDATA[

if(window.dw_locktimer) {
   var locktimer = dw_locktimer;
} 
var FCKRecovery = "";
var oldonload = window.onload;
var ourLockTimerINI = false;
var oldBeforeunload;

  var ckgedit_onload = function() { {$js} };
  
      jQuery(window).bind('load',{},ckgedit_onload);
  
 function ckgeditEditorTextChanged() {
   window.textChanged = false;   
   oldBeforeunload(); 
   if(window.dwfckTextChanged) {        
      return LANG.notsavedyet;
   }  
 }

  function getCurrentWikiNS() {
        var DWikiMediaManagerCommand_ns = '{$media_tmp_ns}';
        return DWikiMediaManagerCommand_ns;
  }
 
 var ourLockTimerRefreshID;
 var ourLockTimerIsSet = true;
 var ourLockTimerWarningtimerID;
 var ourFCKEditorNode = null;
 var ourLockTimerIntervalID;
 var dwfckTextChanged = false;

   /**
    *    event handler
    *    handles both mousepresses and keystrokes from FCKeditor window
    *    assigned in fckeditor.html
  */
 
 function handlekeypress (e) {  
 
 
   if(ourLockTimerIsSet) {
         lockTimerRefresh();        
   }
   window.dwfckTextChanged = true;
 }

 function unsetDokuWikiLockTimer() {
     
    if(window.locktimer && !ourLockTimerINI) {
        locktimer.old_reset = locktimer.reset;
        locktimer.old_warning = locktimer.warning;        
        ourLockTimerINI=true;
    }
    else {
        window.setTimeout("unsetDokuWikiLockTimer()", 600);

    }
  
  locktimer.reset = function(){
        locktimer.clear();  // alert(locktimer.timeout);
        window.clearTimeout(ourLockTimerWarningtimerID);
        ourLockTimerWarningtimerID =  window.setTimeout(function () { locktimer.warning(); }, locktimer.timeout);
   };

   locktimer.warning = function(){    
        window.clearTimeout(ourLockTimerWarningtimerID);

        if(ourLockTimerIsSet) {
            if(locktimer.msg.match(/{$preview_button}/i)) {
                locktimer.msg = locktimer.msg.replace(/{$preview_button}/i, "Back-up");      
             }
            alert(locktimer.msg);
        }
        else {
            alert("{$locktimer_msg}");
        }
     };
     

    locktimer.ourLockTimerReset = locktimer.reset;
    locktimer.our_lasttime = new Date();
    lockTimerRefresh();

 }

 function lockTimerRefresh(bak) {
        var now = new Date();
        if(!ourLockTimerINI)  unsetDokuWikiLockTimer();

        if((now.getTime() - locktimer.our_lasttime.getTime() > 45*1000) || bak){            
           var dwform = GetE('dw__editform');
            window.clearTimeout(ourLockTimerWarningtimerID);
            var params = 'call=lock&id='+locktimer.pageid;
            if(CKEDITOR.instances) {  
                dwform.elements.wikitext.value = CKEDITOR.instances.wiki__text.getData();
                params += '&prefix='+encodeURIComponent(dwform.elements.prefix.value);
                params += '&wikitext='+encodeURIComponent(dwform.elements.wikitext.value);
                params += '&suffix='+encodeURIComponent(dwform.elements.suffix.value);
                params += '&date='+encodeURIComponent(dwform.elements.date.value);
            }
            locktimer.our_lasttime = now;  
            jQuery.post(
                DOKU_BASE + 'lib/exe/ajax.php',
                params,
                function (data) {
                    data = data.replace(/auto/,"")  + ' by ckgeditLite';
                    locktimer.response = data; 
                    locktimer.refreshed(data);
                },
                'html'
            );
       }
        
 }


 /**
   Legacy function has no current use
 */
 function getRecoveredText() {
    return FCKRecovery;
 }

 function resetDokuWikiLockTimer(delete_checkbox) {

        var dom_checkbox = document.getElementById('ckgedit_timer');
        var dom_label = document.getElementById('ckgedit_timer_label');
        locktimer.clear();     
        if(ourLockTimerIsSet) {

             ourLockTimerIsSet = false;             
             locktimer.reset = locktimer.old_reset; 
             locktimer.refresh(); 
             return;
        }
      
     if(delete_checkbox) {
       dom_checkbox.style.display = 'none';
       dom_label.style.display = 'none';
     }

       ourLockTimerIsSet = true;
       locktimer.reset = locktimer.ourLockTimerReset;     
       lockTimerRefresh();
          
 }


function renewLock(bak) {
  if(ourLockTimerIsSet) {
         lockTimerRefresh(true);
   }
   else { 
    locktimer.refresh();
   }
   locktimer.reset();


    if(bak) {
        var id = "{$ID}"; 
        parse_wikitext('bakup');

        var dwform = GetE('dw__editform');
        if(dwform.elements.fck_wikitext.value == '__false__' ) return;
         GetE('saved_wiki_html').innerHTML = CKEDITOR.instances.wiki__text.getData(); // ourFCKEditorNode.innerHTML; 
        if(({$editor_backup}) == 0 ) {           
           return; 
        }
       
        var params = "rsave_id=" + encodeURIComponent("{$meta_fn}");       
        params += '&wikitext='+encodeURIComponent(dwform.elements.fck_wikitext.value);      
        jQuery.post(
                DOKU_BASE + 'lib/plugins/ckgedit/scripts/refresh_save.php',
                params,
                function (data) {                    
                    if(data == 'done') {
                        show_backup_msg("{$meta_id}");  
                    }
                    else {
                      alert("error saving: " + id);
                    }
                },
                'html'
            );
    }

}


function revert_to_prev() {
  if(!(GetE('saved_wiki_html').innerHTML.length)) {
            if(!confirm(backup_empty)) {
                           return;
            }
  }
  CKEDITOR.instances.wiki__text.setData( GetE('saved_wiki_html').innerHTML);
   
}


function draft_delete() {

        var debug = false;
        var params = "draft_id={$cname}";
        jQuery.ajax({
           url: DOKU_BASE + 'lib/plugins/ckgedit/scripts/draft_delete.php',
           async: false,
           data: params,    
           type: 'POST',
           dataType: 'html',         
           success: function(data){                 
               if(debug) {            
                  alert(data);
               }
              
    }
    });

}

function disableDokuWikiLockTimer() {
  resetDokuWikiLockTimer(false);
  if(ourLockTimerIntervalID) {
     window.clearInterval(ourLockTimerIntervalID);
  }
  if(ourLockTimerIsSet) { 
    ourLockTimerIntervalID = window.setInterval(function () { locktimer.refresh(); }, 30000);   
  }
}

function dwfckKeypressInstallHandler() {
  if(window.addEventListener){    
      oDokuWiki_FCKEditorInstance.EditorDocument.addEventListener('keyup', handlekeypress , false) ;
  }
  else {   
     oDokuWiki_FCKEditorInstance.EditorDocument.attachEvent('onkeyup', handlekeypress ) ;
  }
}

var DWFCK_EditorWinObj;
function FCKEditorWindowObj(w) { 
  DWFCK_EditorWinObj = w;
}

function ckgedit_isRTL() { 
var direction = "{$ckgedit_lang_direction}";

return direction == 'rtl';
  
}

function remove_styling() {
//'TextColor,BGColor, FontAssist,Font,FontSize';
var opts = "";
var color_opts = parseInt( "{$color_opts}");
var font_opts =  parseInt("{$font_opts}");
var skip_styling=parseInt("{$skip_styling}");
if(color_opts) {
  opts ='TextColor,BGColor,FontAssist';
}
else if(!skip_styling) {
     opts = 'FontAssist';
}
if(font_opts) {
  if(color_opts || !skip_styling) opts+=',';
  opts +='Font,FontSize';
}
if("{$toolbar_opts}") {
  if(opts) opts+=',';
  opts+="{$toolbar_opts}";
}

return opts;

}


function ckgedit_language_chk(config) { 
    if("{$scayt_auto}" == 'on') {
        config.scayt_autoStartup = true;      
    }
    else config.scayt_autoStartup = false;
    config.scayt_sLang="{$scayt_lang}";  
   var lang = "{$interface_lang}"; 
   if(lang ==  'default') return; ;
   config.language = lang;
}

var oDokuWiki_FCKEditorInstance;
function FCKeditor_OnComplete( editorInstance )
{

  oDokuWiki_FCKEditorInstance = editorInstance;
  editorInstance.on( 'key', handlekeypress, editorInstance );
  oDokuWiki_FCKEditorInstance.dwiki_user = "******";   
  oDokuWiki_FCKEditorInstance.dwiki_client = "{$client}";    
  oDokuWiki_FCKEditorInstance.dwiki_usergroups = "{$user_groups}";  
  oDokuWiki_FCKEditorInstance.dwiki_doku_base = "{$doku_base}";  
  oDokuWiki_FCKEditorInstance.dwiki_create_folder = "{$create_folder}"; 
  oDokuWiki_FCKEditorInstance.dwiki_fnencode = "{$fnencode}"; 
  oDokuWiki_FCKEditorInstance.dwiki_version = {$dwiki_version}; 
  oDokuWiki_FCKEditorInstance.dwiki_anteater = {$ver_anteater}; 
  oDokuWiki_FCKEditorInstance.isLocalDwikiBrowser = false;
  oDokuWiki_FCKEditorInstance.isUrlExtern = false; 
  oDokuWiki_FCKEditorInstance.isDwikiMediaFile = false; 
  oDokuWiki_FCKEditorInstance.imageUploadAllowedExtensions="{$ImageUploadAllowedExtensions}";
  oDokuWiki_FCKEditorInstance.fckgUserName = "******";
  oDokuWiki_FCKEditorInstance.fckgUserMail="{$user_email}"; 
  oDokuWiki_FCKEditorInstance.useheading = "{$useheading}"; 
  oDokuWiki_FCKEditorInstance.mfiles = parseInt("{$mfiles}");
  
 
  var index = navigator.userAgent.indexOf('Safari'); 
  if(index == -1  || (navigator.userAgent.indexOf('Chrome'))) {
    oldBeforeunload = window.onbeforeunload;
    window.onbeforeunload = ckgeditEditorTextChanged;
  }
 
  
}

   
 var DWikifnEncode = "{$fnencode}";

/* Make sure that show buttons in top and/or bottom clear the fckl file */  
 function get_showButtons() {\t
\tvar inputs = document.getElementsByTagName('input');
    
     for(var i=0; i<inputs.length; i++) {\t    
        if(inputs[i].type && inputs[i].type.match(/submit/i)) {\t\t           \t\t    
\t\t\tif(inputs[i].value.match(/Show/i) || (inputs[i].form &&  inputs[i].form.className.match(/btn_show/) ) )
    \t\t\tinputs[i].onmouseup = draft_delete;
        }
     }
  }

 /* make sure the entire page has been loaded */
 setTimeout("get_showButtons()", 3000);
 //]]>
 
</script>
end_of_string;
    }
Пример #22
0
/**
 * sets metadata elements of a page
 *
 * @author Esther Brunner <*****@*****.**>
 */
function p_set_metadata($id, $data, $render = false)
{
    if (!is_array($data)) {
        return false;
    }
    $orig = p_get_metadata($id);
    // render metadata first?
    if ($render) {
        $meta = p_render_metadata($id, $orig);
    } else {
        $meta = $orig;
    }
    // now add the passed metadata
    $protected = array('description', 'date', 'contributor');
    foreach ($data as $key => $value) {
        // be careful with sub-arrays of $meta['relation']
        if ($key == 'relation') {
            foreach ($value as $subkey => $subvalue) {
                $meta[$key][$subkey] = array_merge($meta[$key][$subkey], $subvalue);
            }
            // be careful with some senisitive arrays of $meta
        } elseif (in_array($key, $protected)) {
            if (is_array($value)) {
                #FIXME not sure if this is the intended thing:
                if (!is_array($meta[$key])) {
                    $meta[$key] = array($meta[$key]);
                }
                $meta[$key] = array_merge($meta[$key], $value);
            }
            // no special treatment for the rest
        } else {
            $meta[$key] = $value;
        }
    }
    // save only if metadata changed
    if ($meta == $orig) {
        return true;
    }
    // check if current page metadata has been altered - if so sync the changes
    global $INFO;
    if ($id == $INFO['id'] && isset($INFO['meta'])) {
        $INFO['meta'] = $meta;
    }
    return io_saveFile(metaFN($id, '.meta'), serialize($meta));
}
Пример #23
0
 /**
  * Changes the status of a comment
  */
 function _changeStatus($new)
 {
     global $ID;
     // get discussion meta file name
     $file = metaFN($ID, '.comments');
     $data = unserialize(io_readFile($file, false));
     $old = $data['status'];
     if ($old == $new) {
         return true;
     }
     // save the comment metadata file
     $data['status'] = $new;
     io_saveFile($file, serialize($data));
     // look for ~~DISCUSSION~~ command in page file and change it accordingly
     $patterns = array('~~DISCUSSION:off\\2~~', '~~DISCUSSION\\2~~', '~~DISCUSSION:closed\\2~~');
     $replace = $patterns[$new];
     $wiki = preg_replace('/~~DISCUSSION([\\w:]*)(\\|?.*?)~~/', $replace, rawWiki($ID));
     saveWikiText($ID, $wiki, $this->getLang('statuschanged'), true);
     return true;
 }
Пример #24
0
/**
 * Return a string with the email addresses of all the
 * users subscribed to a page
 *
 * @author Steven Danz <*****@*****.**>
 */
function subscriber_addresslist($id)
{
    global $conf;
    global $auth;
    $emails = '';
    if (!$conf['subscribers']) {
        return;
    }
    $mlist = array();
    $file = metaFN($id, '.mlist');
    if (@file_exists($file)) {
        $mlist = file($file);
    }
    if (count($mlist) > 0) {
        foreach ($mlist as $who) {
            $who = rtrim($who);
            $info = $auth->getUserData($who);
            $level = auth_aclcheck($id, $who, $info['grps']);
            if ($level >= AUTH_READ) {
                if (strcasecmp($info['mail'], $conf['notify']) != 0) {
                    if (empty($emails)) {
                        $emails = $info['mail'];
                    } else {
                        $emails = "{$emails}," . $info['mail'];
                    }
                }
            }
        }
    }
    return $emails;
}
Пример #25
0
/**
 * Return a list of page revisions numbers
 * Does not guarantee that the revision exists in the attic,
 * only that a line with the date exists in the changelog.
 * By default the current revision is skipped.
 *
 * id:    the page of interest
 * first: skip the first n changelog lines
 * num:   number of revisions to return
 *
 * The current revision is automatically skipped when the page exists.
 * See $INFO['meta']['last_change'] for the current revision.
 *
 * For efficiency, the log lines are parsed and cached for later
 * calls to getRevisionInfo. Large changelog files are read
 * backwards in chunks until the requested number of changelog
 * lines are recieved.
 *
 * @author Ben Coburn <*****@*****.**>
 * @author Kate Arzamastseva <*****@*****.**>
 */
function getRevisions($id, $first, $num, $chunk_size = 8192, $media = false)
{
    global $cache_revinfo;
    $cache =& $cache_revinfo;
    if (!isset($cache[$id])) {
        $cache[$id] = array();
    }
    $revs = array();
    $lines = array();
    $count = 0;
    if ($media) {
        $file = mediaMetaFN($id, '.changes');
    } else {
        $file = metaFN($id, '.changes');
    }
    $num = max($num, 0);
    $chunk_size = max($chunk_size, 0);
    if ($first < 0) {
        $first = 0;
    } else {
        if (!$media && @file_exists(wikiFN($id)) || $media && @file_exists(mediaFN($id))) {
            // skip current revision if the page exists
            $first = max($first + 1, 0);
        }
    }
    if (!@file_exists($file)) {
        return $revs;
    }
    if (filesize($file) < $chunk_size || $chunk_size == 0) {
        // read whole file
        $lines = file($file);
        if ($lines === false) {
            return $revs;
        }
    } else {
        // read chunks backwards
        $fp = fopen($file, 'rb');
        // "file pointer"
        if ($fp === false) {
            return $revs;
        }
        fseek($fp, 0, SEEK_END);
        $tail = ftell($fp);
        // chunk backwards
        $finger = max($tail - $chunk_size, 0);
        while ($count < $num + $first) {
            fseek($fp, $finger);
            $nl = $finger;
            if ($finger > 0) {
                fgets($fp);
                // slip the finger forward to a new line
                $nl = ftell($fp);
            }
            // was the chunk big enough? if not, take another bite
            if ($nl > 0 && $tail <= $nl) {
                $finger = max($finger - $chunk_size, 0);
                continue;
            } else {
                $finger = $nl;
            }
            // read chunk
            $chunk = '';
            $read_size = max($tail - $finger, 0);
            // found chunk size
            $got = 0;
            while ($got < $read_size && !feof($fp)) {
                $tmp = @fread($fp, max($read_size - $got, 0));
                if ($tmp === false) {
                    break;
                }
                //error state
                $got += strlen($tmp);
                $chunk .= $tmp;
            }
            $tmp = explode("\n", $chunk);
            array_pop($tmp);
            // remove trailing newline
            // combine with previous chunk
            $count += count($tmp);
            $lines = array_merge($tmp, $lines);
            // next chunk
            if ($finger == 0) {
                break;
            } else {
                $tail = $finger;
                $finger = max($tail - $chunk_size, 0);
            }
        }
        fclose($fp);
    }
    // skip parsing extra lines
    $num = max(min(count($lines) - $first, $num), 0);
    if ($first > 0 && $num > 0) {
        $lines = array_slice($lines, max(count($lines) - $first - $num, 0), $num);
    } else {
        if ($first > 0 && $num == 0) {
            $lines = array_slice($lines, 0, max(count($lines) - $first, 0));
        } else {
            if ($first == 0 && $num > 0) {
                $lines = array_slice($lines, max(count($lines) - $num, 0));
            }
        }
    }
    // handle lines in reverse order
    for ($i = count($lines) - 1; $i >= 0; $i--) {
        $tmp = parseChangelogLine($lines[$i]);
        if ($tmp !== false) {
            $cache[$id][$tmp['date']] = $tmp;
            $revs[] = $tmp['date'];
        }
    }
    return $revs;
}
 /**
  * Returns original filename if exists
  */
 function _getOriginalFileName($id)
 {
     $metaFilePath = mediaMetaFN($id, '.filename');
     $meta = unserialize(io_readFile($metaFilePath, false));
     if (empty($meta['filename'])) {
         // check old meta file (for backward compatibility)
         $filename = parent::_getOriginalFileName($id);
         // move old meta file to media_meta directory
         if ($filename !== false) {
             $oldMetaFilePath = metaFN($id, '.filename');
             io_rename($oldMetaFilePath, $metaFilePath);
         }
         return $filename;
     } else {
         return $this->common->_sanitizeFileName($meta['filename']);
     }
 }
Пример #27
0
/**
 * This is the backend function to save a metadata array to a file
 *
 * @param    string   $id      absolute wiki page id
 * @param    array    $meta    metadata
 *
 * @return   bool              success / fail
 */
function p_save_metadata($id, $meta)
{
    // sync cached copies, including $INFO metadata
    global $cache_metadata, $INFO;
    if (isset($cache_metadata[$id])) {
        $cache_metadata[$id] = $meta;
    }
    if (!empty($INFO) && $id == $INFO['id']) {
        $INFO['meta'] = $meta['current'];
    }
    return io_saveFile(metaFN($id, '.meta'), serialize($meta));
}
Пример #28
0
/**
 * returns an array of full paths to all metafiles of a given ID
 *
 * @author Esther Brunner <*****@*****.**>
 */
function metaFiles($id)
{
    $name = noNS($id);
    $ns = getNS($id);
    $dir = $ns ? metaFN($ns, '') . '/' : metaFN($ns, '');
    $files = array();
    $files = glob($dir . $name . '.*');
    return $files;
}
/**
 * Adds/updates the search index for the given page
 *
 * Locking is handled internally.
 *
 * @param string        $page   name of the page to index
 * @param boolean       $verbose    print status messages
 * @param boolean       $force  force reindexing even when the index is up to date
 * @return boolean              the function completed successfully
 * @author Tom N Harris <*****@*****.**>
 */
function enhanced_idx_addPage($page, $verbose = false, $force = false)
{
    $idxtag = metaFN($page, '.indexed');
    // check if page was deleted but is still in the index
    if (!page_exists($page)) {
        if (!@file_exists($idxtag)) {
            if ($verbose) {
                print "Indexer: {$page} does not exist, ignoring" . DOKU_LF;
            }
            return false;
        }
        $Indexer = enhanced_idx_get_indexer();
        $result = $Indexer->deletePage($page);
        if ($result === "locked") {
            if ($verbose) {
                print "Indexer: locked" . DOKU_LF;
            }
            return false;
        }
        @unlink($idxtag);
        return $result;
    }
    // check if indexing needed
    if (!$force && @file_exists($idxtag)) {
        if (trim(io_readFile($idxtag)) == idx_get_version()) {
            $last = @filemtime($idxtag);
            if ($last > @filemtime(wikiFN($page))) {
                if ($verbose) {
                    print "Indexer: index for {$page} up to date" . DOKU_LF;
                }
                return false;
            }
        }
    }
    $indexenabled = p_get_metadata($page, 'internal index', METADATA_RENDER_UNLIMITED);
    if ($indexenabled === false) {
        $result = false;
        if (@file_exists($idxtag)) {
            $Indexer = enhanced_idx_get_indexer();
            $result = $Indexer->deletePage($page);
            if ($result === "locked") {
                if ($verbose) {
                    print "Indexer: locked" . DOKU_LF;
                }
                return false;
            }
            @unlink($idxtag);
        }
        if ($verbose) {
            print "Indexer: index disabled for {$page}" . DOKU_LF;
        }
        return $result;
    }
    $Indexer = enhanced_idx_get_indexer();
    $pid = $Indexer->getPID($page);
    if ($pid === false) {
        if ($verbose) {
            print "Indexer: getting the PID failed for {$page}" . DOKU_LF;
        }
        return false;
    }
    $body = '';
    $metadata = array();
    $metadata['title'] = p_get_metadata($page, 'title', METADATA_RENDER_UNLIMITED);
    if (($references = p_get_metadata($page, 'relation references', METADATA_RENDER_UNLIMITED)) !== null) {
        $metadata['relation_references'] = array_keys($references);
    } else {
        $metadata['relation_references'] = array();
    }
    if (($media = p_get_metadata($page, 'relation media', METADATA_RENDER_UNLIMITED)) !== null) {
        $metadata['relation_media'] = array_keys($media);
    } else {
        $metadata['relation_media'] = array();
    }
    $data = compact('page', 'body', 'metadata', 'pid');
    $evt = new Doku_Event('INDEXER_PAGE_ADD', $data);
    if ($evt->advise_before()) {
        $data['body'] = $data['body'] . " " . rawWiki($page);
    }
    $evt->advise_after();
    unset($evt);
    extract($data);
    $result = $Indexer->addPageWords($page, $body);
    if ($result === "locked") {
        if ($verbose) {
            print "Indexer: locked" . DOKU_LF;
        }
        return false;
    }
    if ($result) {
        $result = $Indexer->addMetaKeys($page, $metadata);
        if ($result === "locked") {
            if ($verbose) {
                print "Indexer: locked" . DOKU_LF;
            }
            return false;
        }
    }
    if ($result) {
        io_saveFile(metaFN($page, '.indexed'), idx_get_version());
    }
    if ($verbose) {
        print "Indexer: finished" . DOKU_LF;
        return true;
    }
    return $result;
}
Пример #30
0
/**
 * returns an array of full paths to all metafiles of a given ID
 *
 * @author Esther Brunner <*****@*****.**>
 * @author Michael Hamann <*****@*****.**>
 *
 * @param string $id page id
 * @return array
 */
function metaFiles($id)
{
    $basename = metaFN($id, '');
    $files = glob($basename . '.*', GLOB_MARK);
    // filter files like foo.bar.meta when $id == 'foo'
    return $files ? preg_grep('/^' . preg_quote($basename, '/') . '\\.[^.\\/]*$/u', $files) : array();
}