function WysiwygEdit_Wikiwyg() { global $request, $LANG; $this->_transformer_tags = false; $this->BasePath = DATA_PATH . '/themes/default/Wikiwyg'; $this->_htmltextid = "edit-content"; $this->_wikitextid = "editareawiki"; $script_url = deduce_script_name(); if (DEBUG & _DEBUG_REMOTE and isset($_GET['start_debug'])) { $script_url .= "?start_debug=" . $_GET['start_debug']; } $this->_jsdefault = ""; }
function initGlobals() { global $request; static $already = 0; if (!$already) { $script_url = deduce_script_name(); $script_url .= '/' . $GLOBALS['group_name']; if (DEBUG & _DEBUG_REMOTE and isset($_GET['start_debug'])) { $script_url .= "?start_debug=" . $_GET['start_debug']; } $folderArrowPath = dirname($this->_findData('images/folderArrowLoading.gif')); $pagename = $request->getArg('pagename'); $this->addMoreHeaders(JavaScript('', array('src' => $this->_findData("wikilens.js")))); $js = "var data_path = '" . javascript_quote_string(DATA_PATH) . "';\n" . "var script_url= '" . javascript_quote_string($script_url) . "';\n" . "var stylepath = data_path+'/" . javascript_quote_string($this->_theme) . "/';\n" . "var folderArrowPath = '" . javascript_quote_string($folderArrowPath) . "';\n" . "var use_path_info = " . (USE_PATH_INFO ? "true" : "false") . ";\n"; $this->addMoreHeaders(JavaScript($js)); $already = 1; } }
/** * Define constants which are client or request specific and should not be dumped statically. * Such as the language, and the virtual and server paths, which might be overridden * by startup scripts for wiki farms. */ function fixup_dynamic_configs($file) { global $WikiNameRegexp; global $HTTP_SERVER_VARS, $DBParams, $LANG; if (defined('INCLUDE_PATH') and INCLUDE_PATH) { @ini_set('include_path', INCLUDE_PATH); } if (defined('SESSION_SAVE_PATH') and SESSION_SAVE_PATH) { @ini_set('session.save_path', SESSION_SAVE_PATH); } if (!defined('DEFAULT_LANGUAGE')) { // not needed anymore define('DEFAULT_LANGUAGE', ''); } // detect from client update_locale(isset($LANG) ? $LANG : DEFAULT_LANGUAGE); if (empty($LANG)) { if (!defined("DEFAULT_LANGUAGE") or !DEFAULT_LANGUAGE) { // TODO: defer this to WikiRequest::initializeLang() $LANG = guessing_lang(); guessing_setlocale(LC_ALL, $LANG); } else { $LANG = DEFAULT_LANGUAGE; } } // Set up (possibly fake) gettext() // Todo: this could be moved to fixup_static_configs() // Bug #1381464 with php-5.1.1 if (!function_exists('bindtextdomain') and !function_exists('gettext') and !function_exists('_')) { $locale = array(); function gettext($text) { global $locale; if (!empty($locale[$text])) { return $locale[$text]; } return $text; } function _($text) { return gettext($text); } } else { // Working around really weird gettext problems: (4.3.2, 4.3.6 win) // bindtextdomain() returns the current domain path. // 1. If the script is not index.php but something like "de", on a different path // then bindtextdomain() fails, but after chdir to the correct path it will work okay. // 2. But the weird error "Undefined variable: bindtextdomain" is generated then. $bindtextdomain_path = FindFile("locale", false, true); $chback = 0; if (isWindows()) { $bindtextdomain_path = str_replace("/", "\\", $bindtextdomain_path); } $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain_path); if (realpath($bindtextdomain_real) != realpath($bindtextdomain_path)) { // this will happen with virtual_paths. chdir and try again. chdir($bindtextdomain_path); $chback = 1; $bindtextdomain_real = @bindtextdomain("phpwiki", $bindtextdomain_path); } // tell gettext not to use unicode. PHP >= 4.2.0. Thanks to Kai Krakow. if (defined('CHARSET') and function_exists('bind_textdomain_codeset')) { @bind_textdomain_codeset("phpwiki", CHARSET); } textdomain("phpwiki"); if ($chback) { // change back chdir($bindtextdomain_real . (isWindows() ? "\\.." : "/..")); } } // language dependent updates: $WikiNameRegexp = pcre_fix_posix_classes($WikiNameRegexp); //if ($KeywordLinkRegexp) $KeywordLinkRegexp = pcre_fix_posix_classes($KeywordLinkRegexp); if (!defined('CATEGORY_GROUP_PAGE')) { define('CATEGORY_GROUP_PAGE', _("CategoryGroup")); } if (!defined('WIKI_NAME')) { define('WIKI_NAME', _("An unnamed PhpWiki")); } if (!defined('HOME_PAGE')) { define('HOME_PAGE', _("HomePage")); } ////////////////////////////////////////////////////////////////// // Autodetect URL settings: // foreach (array('SERVER_NAME', 'SERVER_PORT') as $var) { //FIXME: for CGI without _SERVER if (!defined($var) and !empty($HTTP_SERVER_VARS[$var])) { define($var, $HTTP_SERVER_VARS[$var]); } } if (!defined('SERVER_NAME')) { define('SERVER_NAME', '127.0.0.1'); } if (!defined('SERVER_PORT')) { define('SERVER_PORT', 80); } if (!defined('SERVER_PROTOCOL')) { if (empty($HTTP_SERVER_VARS['HTTPS']) || $HTTP_SERVER_VARS['HTTPS'] == 'off') { define('SERVER_PROTOCOL', 'http'); } else { define('SERVER_PROTOCOL', 'https'); } } if (!defined('SCRIPT_NAME')) { define('SCRIPT_NAME', deduce_script_name()); } if (!defined('USE_PATH_INFO')) { if (isCGI()) { define('USE_PATH_INFO', false); } else { /* * If SCRIPT_NAME does not look like php source file, * or user cgi we assume that php is getting run by an * action handler in /cgi-bin. In this case, * I think there is no way to get Apache to pass * useful PATH_INFO to the php script (PATH_INFO * is used to the the php interpreter where the * php script is...) */ switch (php_sapi_name()) { case 'apache': case 'apache2handler': define('USE_PATH_INFO', true); break; case 'cgi': case 'apache2filter': define('USE_PATH_INFO', false); break; default: define('USE_PATH_INFO', ereg('\\.(php3?|cgi)$', SCRIPT_NAME)); break; } } } if (SERVER_PORT && SERVER_PORT != (SERVER_PROTOCOL == 'https' ? 443 : 80)) { define('SERVER_URL', SERVER_PROTOCOL . '://' . SERVER_NAME . ':' . SERVER_PORT); } else { define('SERVER_URL', SERVER_PROTOCOL . '://' . SERVER_NAME); } if (!defined('VIRTUAL_PATH')) { // We'd like to auto-detect when the cases where apaches // 'Action' directive (or similar means) is used to // redirect page requests to a cgi-handler. // // In cases like this, requests for e.g. /wiki/HomePage // get redirected to a cgi-script called, say, // /path/to/wiki/index.php. The script gets all // of /wiki/HomePage as it's PATH_INFO. // // The problem is: // How to detect when this has happened reliably? // How to pick out the "virtual path" (in this case '/wiki')? // // (Another time an redirect might occur is to a DirectoryIndex // -- the requested URI is '/wikidir/', the request gets // passed to '/wikidir/index.php'. In this case, the // proper VIRTUAL_PATH is '/wikidir/index.php', since the // pages will appear at e.g. '/wikidir/index.php/HomePage'. // $REDIRECT_URL =& $HTTP_SERVER_VARS['REDIRECT_URL']; if (USE_PATH_INFO and isset($REDIRECT_URL) and !IsProbablyRedirectToIndex()) { // FIXME: This is a hack, and won't work if the requested // pagename has a slash in it. $temp = strtr(dirname($REDIRECT_URL . 'x'), "\\", '/'); if ($temp == '/' || $temp == '\\') { $temp = ''; } define('VIRTUAL_PATH', $temp); } else { define('VIRTUAL_PATH', SCRIPT_NAME); } } if (!defined('PATH_INFO_PREFIX')) { if (VIRTUAL_PATH != SCRIPT_NAME) { // Apache action handlers are used. define('PATH_INFO_PREFIX', VIRTUAL_PATH . '/'); } else { define('PATH_INFO_PREFIX', '/'); } } define('PHPWIKI_BASE_URL', SERVER_URL . (USE_PATH_INFO ? VIRTUAL_PATH . '/' : SCRIPT_NAME)); // Detect PrettyWiki setup (not loading index.php directly) // $SCRIPT_FILENAME should be the same as __FILE__ in index.php if (!isset($SCRIPT_FILENAME)) { $SCRIPT_FILENAME = @$HTTP_SERVER_VARS['SCRIPT_FILENAME']; } if (!isset($SCRIPT_FILENAME)) { $SCRIPT_FILENAME = @$HTTP_ENV_VARS['SCRIPT_FILENAME']; } if (!isset($SCRIPT_FILENAME)) { $SCRIPT_FILENAME = dirname(__FILE__ . '/../') . '/index.php'; } if (isWindows()) { $SCRIPT_FILENAME = str_replace('\\\\', '\\', strtr($SCRIPT_FILENAME, '/', '\\')); } define('SCRIPT_FILENAME', $SCRIPT_FILENAME); // Get remote host name, if apache hasn't done it for us if (empty($HTTP_SERVER_VARS['REMOTE_HOST']) and !empty($HTTP_SERVER_VARS['REMOTE_ADDR']) and ENABLE_REVERSE_DNS) { $HTTP_SERVER_VARS['REMOTE_HOST'] = gethostbyaddr($HTTP_SERVER_VARS['REMOTE_ADDR']); } }