Skip to content

Commit

Permalink
added init.php - may have broken something! (related to #153)
Browse files Browse the repository at this point in the history
darcs-hash:20050219102055-9977f-575d654e742934c911ffab855d82aa91f198b5cf.gz
  • Loading branch information
splitbrain committed Feb 19, 2005
1 parent f840b65 commit ed7b5f0
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 208 deletions.
19 changes: 10 additions & 9 deletions doku.php
Expand Up @@ -5,14 +5,15 @@
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/

require_once("conf/dokuwiki.php");
require_once("inc/common.php");
require_once("inc/html.php");
require_once("inc/parser.php");
require_once("lang/en/lang.php");
require_once("lang/".$conf['lang']."/lang.php");
require_once("inc/auth.php");

if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/');
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/common.php');
require_once(DOKU_INC.'inc/html.php');
require_once(DOKU_INC.'inc/parser.php');
require_once(DOKU_INC.'lang/en/lang.php');
require_once(DOKU_INC.'lang/'.$conf['lang'].'/lang.php');
require_once(DOKU_INC.'inc/auth.php');

//import variables
$QUERY = trim($_REQUEST['id']);
Expand Down Expand Up @@ -73,7 +74,7 @@
//unlock it
unlock($id);
//show it
header("Location: ".wl($ID, '','doku.php',true));
header("Location: ".wl($ID,'',true));
exit();
}
}
Expand Down
15 changes: 8 additions & 7 deletions feed.php
Expand Up @@ -6,7 +6,8 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/

ini_set('short_open_tag',"1");
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/');
require_once(DOKU_INC.'inc/init.php');
require_once("inc/common.php");
require_once("inc/parser.php");
require_once("inc/feedcreator.class.php");
Expand Down Expand Up @@ -42,15 +43,15 @@
//some defaults for the feed
$CACHEGROUP = 'feed';
$conf['typography'] = false;
$conf['canonical'] = true;
# $conf['canonical'] = true;
$parser['toc'] = false;

$rss = new UniversalFeedCreator();
$rss = new DokuWikiFeedCreator();
$rss->title = $conf['title'];
$rss->link = wl();
$rss->syndicationURL = getBaseURL().'/feed.php';
$rss->cssStyleSheet = getBaseURL().'/feed.css';
$rss->link = DOKU_URL;
$rss->syndicationURL = DOKU_URL.'/feed.php';
$rss->cssStyleSheet = DOKU_URL.'/feed.css';

if($mode == 'list'){
rssListNamespace($rss,$ns);
Expand All @@ -77,7 +78,7 @@ function rssRecentChanges(&$rss,$num){
}
$item = new FeedItem();
$item->title = $id;
$item->link = wl($id,'rev='.$recents[$id]['date']);
$item->link = wl($id,'rev='.$recents[$id]['date'],true);
$item->description = $desc;
$item->date = date('r',$recents[$id]['date']);
if(strpos($id,':')!==false){
Expand Down Expand Up @@ -115,7 +116,7 @@ function rssListNamespace(&$rss,$ns){
$desc = cleanDesc(parsedWiki($id));
$item = new FeedItem();
$item->title = $id;
$item->link = wl($id,'rev='.$date);
$item->link = wl($id,'rev='.$date,true);
$item->description = $desc;
$item->date = date('r',$date);
$rss->addItem($item);
Expand Down
15 changes: 8 additions & 7 deletions inc/auth.php
@@ -1,4 +1,4 @@
<?
<?php
/**
* Authentication library
*
Expand All @@ -9,12 +9,13 @@
* @author Andreas Gohr <andi@splitbrain.org>
*/

require_once("inc/common.php");
require_once("inc/io.php");
require_once("inc/blowfish.php");
require_once("inc/mail.php");
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
require_once(DOKU_INC.'inc/common.php');
require_once(DOKU_INC.'inc/io.php');
require_once(DOKU_INC.'inc/blowfish.php');
require_once(DOKU_INC.'inc/mail.php');
// load the the auth functions
require_once('inc/auth_'.$conf['authtype'].'.php');
require_once(DOKU_INC.'inc/auth_'.$conf['authtype'].'.php');

// some ACL level defines
define('AUTH_NONE',0);
Expand Down Expand Up @@ -324,7 +325,7 @@ function auth_sendPassword($user,$password){
if(!$userinfo['mail']) return false;

$text = rawLocale('password');
$text = str_replace('@DOKUWIKIURL@',getBaseURL(true),$text);
$text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
$text = str_replace('@FULLNAME@',$userinfo['name'],$text);
$text = str_replace('@LOGIN@',$user,$text);
$text = str_replace('@PASSWORD@',$password,$text);
Expand Down
128 changes: 22 additions & 106 deletions inc/common.php
@@ -1,105 +1,16 @@
<?
<?php
/**
* Common DokuWiki functions
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/

require_once("conf/dokuwiki.php");
require_once("inc/io.php");
require_once('inc/utf8.php');
require_once('inc/mail.php');

//set up error reporting to sane values
error_reporting(E_ALL ^ E_NOTICE);

//make session rewrites XHTML compliant
ini_set('arg_separator.output', '&amp;');

//init session
session_name("DokuWiki");
session_start();

//kill magic quotes
if (get_magic_quotes_gpc()) {
if (!empty($_GET)) remove_magic_quotes($_GET);
if (!empty($_POST)) remove_magic_quotes($_POST);
if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE);
if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
if (!empty($_SESSION)) remove_magic_quotes($_SESSION);
ini_set('magic_quotes_gpc', 0);
}
set_magic_quotes_runtime(0);
ini_set('magic_quotes_sybase',0);

//disable gzip if not available
if($conf['usegzip'] && !function_exists('gzopen')){
$conf['usegzip'] = 0;
}

//remember original umask
$conf['oldumask'] = umask();

//make absolute mediaweb
if(!preg_match('#^(https?://|/)#i',$conf['mediaweb'])){
$conf['mediaweb'] = getBaseURL().$conf['mediaweb'];
}

/**
* remove magic quotes recursivly
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function remove_magic_quotes(&$array) {
foreach (array_keys($array) as $key) {
if (is_array($array[$key])) {
remove_magic_quotes($array[$key]);
}else {
$array[$key] = stripslashes($array[$key]);
}
}
}

/**
* Returns the full absolute URL to the directory where
* DokuWiki is installed in (includes a trailing slash)
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function getBaseURL($abs=false){
global $conf;
//if canonical url enabled always return absolute
if($conf['canonical']) $abs = true;

$dir = dirname($_SERVER['PHP_SELF']).'/';

$dir = str_replace('\\','/',$dir); #bugfix for weird WIN behaviour
$dir = preg_replace('#//+#','/',$dir);

//finish here for relative URLs
if(!$abs) return $dir;

$port = ':'.$_SERVER['SERVER_PORT'];
//remove port from hostheader as sent by IE
$host = preg_replace('/:.*$/','',$_SERVER['HTTP_HOST']);

// see if HTTPS is enabled - apache leaves this empty when not available,
// IIS sets it to 'off', 'false' and 'disabled' are just guessing
if (preg_match('/^(|off|false|disabled)$/i',$_SERVER['HTTPS'])){
$proto = 'http://';
if ($_SERVER['SERVER_PORT'] == '80') {
$port='';
}
}else{
$proto = 'https://';
if ($_SERVER['SERVER_PORT'] == '443') {
$port='';
}
}

return $proto.$host.$port.$dir;
}
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
require_once(DOKU_INC.'conf/dokuwiki.php');
require_once(DOKU_INC.'inc/io.php');
require_once(DOKU_INC.'inc/utf8.php');
require_once(DOKU_INC.'inc/mail.php');

/**
* Return info about the current document as associative
Expand Down Expand Up @@ -257,20 +168,23 @@ function idfilter($id,$ue=true){
}

/**
* This builds a link to a wikipage (using getBaseURL)
* This builds a link to a wikipage
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function wl($id='',$more='',$script='doku.php',$canonical=false){
function wl($id='',$more='',$abs=false){
global $conf;
$more = str_replace(',','&amp;',$more);

$id = idfilter($id);
$xlink = getBaseURL($canonical);
if($abs){
$xlink = DOKU_URL;
}else{
$xlink = DOKU_BASE;
}

if(!$conf['userewrite']){
$xlink .= $script;
$xlink .= '?id='.$id;
$xlink .= DOKU_SCRIPT.'?id='.$id;
if($more) $xlink .= '&amp;'.$more;
}else{
$xlink .= $id;
Expand All @@ -283,12 +197,14 @@ function wl($id='',$more='',$script='doku.php',$canonical=false){
/**
* Just builds a link to a script
*
* @todo maybe obsolete
* @author Andreas Gohr <andi@splitbrain.org>
*/
function script($script='doku.php'){
$link = getBaseURL();
$link .= $script;
return $link;
# $link = getBaseURL();
# $link .= $script;
# return $link;
return DOKU_BASE.DOKU_SCRIPT;
}

/**
Expand Down Expand Up @@ -825,14 +741,14 @@ function notify($id,$rev="",$summary=""){
$text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text);
$text = str_replace('@IPADDRESS@',$_SERVER['REMOTE_ADDR'],$text);
$text = str_replace('@HOSTNAME@',gethostbyaddr($_SERVER['REMOTE_ADDR']),$text);
$text = str_replace('@NEWPAGE@',wl($id,'','doku.php',true),$text);
$text = str_replace('@DOKUWIKIURL@',getBaseURL(true),$text);
$text = str_replace('@NEWPAGE@',wl($id,'',true),$text);
$text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text);
$text = str_replace('@SUMMARY@',$summary,$text);
$text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text);

if($rev){
$subject = $lang['mail_changed'].' '.$id;
$text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",'doku.php',true),$text);
$text = str_replace('@OLDPAGE@',wl($id,"rev=$rev",true),$text);
require_once("inc/DifferenceEngine.php");
$df = new Diff(split("\n",rawWiki($id,$rev)),
split("\n",rawWiki($id)));
Expand Down
15 changes: 8 additions & 7 deletions inc/format.php
@@ -1,13 +1,14 @@
<?
<?php
/**
* link format functions
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Andreas Gohr <andi@splitbrain.org>
*/

require_once("conf/dokuwiki.php");
require_once("inc/common.php");
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
require_once(DOKU_INC.'conf/dokuwiki.php');
require_once(DOKU_INC.'inc/common.php');


/**
Expand Down Expand Up @@ -248,7 +249,7 @@ function format_link_interwiki($link){
$iwlinks = file('conf/interwiki.conf');

//add special case 'this'
$iwlinks[] = 'this '.getBaseURL(true).'{NAME}';
$iwlinks[] = 'this '.DOKU_URL.'{NAME}';

//go through iwlinks and find URL for wiki
foreach ($iwlinks as $line){
Expand All @@ -266,13 +267,13 @@ function format_link_interwiki($link){

//if ico exists set additonal style
if(@file_exists('interwiki/'.$ico.'.png')){
$link['style']='background: transparent url('.getBaseURL().'interwiki/'.$ico.'.png) 0px 1px no-repeat;';
$link['style']='background: transparent url('.DOKU_BASE.'interwiki/'.$ico.'.png) 0px 1px no-repeat;';
}elseif(@file_exists('interwiki/'.$ico.'.gif')){
$link['style']='background: transparent url('.getBaseURL().'interwiki/'.$ico.'.gif) 0px 1px no-repeat;';
$link['style']='background: transparent url('.DOKU_BASE.'interwiki/'.$ico.'.gif) 0px 1px no-repeat;';
}

//do we stay at the same server? Use local target
if( strpos($url,getBaseURL(true)) === 0 ){
if( strpos($url,DOKU_URL) === 0 ){
$link['target'] = $conf['target']['wiki'];
}

Expand Down

0 comments on commit ed7b5f0

Please sign in to comment.