diff --git a/SSI.php b/SSI.php index d92ba476..064140af 100644 --- a/SSI.php +++ b/SSI.php @@ -17,7 +17,7 @@ // We're going to want a few globals... these are all set later. global $settings, $context, $sc, $topic, $board, $txt; global $time_start, $maintenance, $msubject, $mmessage, $mbname; -global $boardurl, $boarddir, $webmaster_email, $cookiename; +global $boardurl, $webmaster_email, $cookiename; global $db_server, $db_connection, $db_name, $db_user, $db_prefix, $db_persist; global $db_error_send, $db_last_error, $ssi_db_user, $ssi_db_passwd, $db_passwd; @@ -37,10 +37,6 @@ require_once(dirname(__FILE__) . '/Settings.php'); require_once(dirname(__FILE__) . '/index.php'); -$boarddir = ROOT_DIR; -foreach (array('cache' => 'gz', 'css' => 'gz/css', 'js' => 'gz/js') as $var => $path) - ${$var . 'dir'} = ROOT_DIR . '/' . $path; - $ssi_error_reporting = error_reporting(E_ALL | E_STRICT); /* Set this to one of three values depending on what you want to happen in the case of a fatal error. diff --git a/core/app/Subs-Cache.php b/core/app/Subs-Cache.php index 7690dc03..58d2197c 100644 --- a/core/app/Subs-Cache.php +++ b/core/app/Subs-Cache.php @@ -1659,9 +1659,9 @@ function uncache() */ function clean_cache($extensions = 'php', $filter = '', $force_folder = '', $remove_folder = false) { - global $cache_system, $cachedir; + global $cache_system; - $folder = $cachedir . '/keys'; + $folder = CACHE_DIR . '/keys'; $is_recursive = false; $there_is_another = false; if ($extensions === 'css') @@ -1695,7 +1695,7 @@ function clean_cache($extensions = 'php', $filter = '', $force_folder = '', $rem $filter_is_folder = !$filter || strpos($force_folder, $filter) !== false; // If we're emptying the regular cache, chances are we also want to reset non-file-based cached data if possible. - if ($folder == $cachedir . '/keys') + if ($folder == CACHE_DIR . '/keys') { cache_get_type(); if ($cache_system === 'apc') @@ -1713,8 +1713,8 @@ function clean_cache($extensions = 'php', $filter = '', $force_folder = '', $rem clean_cache('', '', $zend_cache_folder . '/.php_cache_api'); // Also get the source and language caches! - clean_cache('php', '', $cachedir . '/app'); - clean_cache('php', '', $cachedir . '/lang'); + clean_cache('php', '', CACHE_DIR . '/app'); + clean_cache('php', '', CACHE_DIR . '/lang'); } // Remove the files in Wedge's own disk cache, if any. @@ -1738,7 +1738,7 @@ function clean_cache($extensions = 'php', $filter = '', $force_folder = '', $rem // Invalidate cache, to be sure! if (!$force_folder && !is_array($extensions)) { - @fclose(@fopen($cachedir . '/cache.lock', 'w')); + @fclose(@fopen(CACHE_DIR . '/cache.lock', 'w')); clearstatcache(); } elseif ($remove_folder && !$there_is_another) @@ -1811,7 +1811,7 @@ function cache_quick_get($key, $file, $function, $params, $level = 1) function cache_put_data($key, $val, $ttl = 120) { global $cache_system, $cache_hits, $cache_count; - global $settings, $db_show_debug, $cachedir; + global $settings, $db_show_debug; if (empty($settings['cache_enable']) && !empty($settings)) return; @@ -1852,14 +1852,14 @@ function cache_put_data($key, $val, $ttl = 120) else { if ($val === null) - @unlink($cachedir . '/keys/' . $key . '.php'); + @unlink(CACHE_DIR . '/keys/' . $key . '.php'); else { $cache_data = '<' . '?php if(defined(\'WEDGE\')&&$valid=' . ($ttl === PHP_INT_MAX ? '1' : 'time()<' . (time() + $ttl)) . ')$val=\'' . addcslashes($val, '\\\'') . '\';'; // Check that the cache write was successful. If it fails due to low diskspace, remove the cache file. - if (file_put_contents($cachedir . '/keys/' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data)) - @unlink($cachedir . '/keys/' . $key . '.php'); + if (file_put_contents(CACHE_DIR . '/keys/' . $key . '.php', $cache_data, LOCK_EX) !== strlen($cache_data)) + @unlink(CACHE_DIR . '/keys/' . $key . '.php'); } } @@ -1878,8 +1878,7 @@ function cache_put_data($key, $val, $ttl = 120) */ function cache_get_data($orig_key, $ttl = 120, $put_callback = null) { - global $cache_system, $cache_hits, $cache_count; - global $settings, $db_show_debug, $cachedir; + global $cache_system, $cache_hits, $cache_count, $settings, $db_show_debug; if (empty($settings['cache_enable']) && !empty($settings)) return; @@ -1902,11 +1901,11 @@ function cache_get_data($orig_key, $ttl = 120, $put_callback = null) elseif ($cache_system === 'xcache') $val = xcache_get($key); // Otherwise it's the file cache! - elseif (file_exists($cachedir . '/keys/' . $key . '.php') && @filesize($cachedir . '/keys/' . $key . '.php') > 10) + elseif (file_exists(CACHE_DIR . '/keys/' . $key . '.php') && @filesize(CACHE_DIR . '/keys/' . $key . '.php') > 10) { - @include($cachedir . '/keys/' . $key . '.php'); + @include(CACHE_DIR . '/keys/' . $key . '.php'); if (empty($valid)) - @unlink($cachedir . '/keys/' . $key . '.php'); + @unlink(CACHE_DIR . '/keys/' . $key . '.php'); } if (!empty($db_show_debug)) @@ -1928,7 +1927,7 @@ function cache_get_data($orig_key, $ttl = 120, $put_callback = null) function cache_prepare_key($key, $val = '', $type = 'get') { - global $boardurl, $settings, $cache_hits, $cache_count, $db_show_debug, $cachedir; + global $boardurl, $settings, $cache_hits, $cache_count, $db_show_debug; $cache_count = isset($cache_count) ? $cache_count + 1 : 1; if (!empty($db_show_debug)) @@ -1936,9 +1935,9 @@ function cache_prepare_key($key, $val = '', $type = 'get') if (empty($settings['cache_hash'])) { - if (!file_exists($cachedir . '/cache.lock')) - @fclose(@fopen($cachedir . '/cache.lock', 'w')); - $settings['cache_hash'] = md5($boardurl . filemtime($cachedir . '/cache.lock')); + if (!file_exists(CACHE_DIR . '/cache.lock')) + @fclose(@fopen(CACHE_DIR . '/cache.lock', 'w')); + $settings['cache_hash'] = md5($boardurl . filemtime(CACHE_DIR . '/cache.lock')); } return $settings['cache_hash'] . '-' . bin2hex($key); diff --git a/core/app/Subs-Plugins.php b/core/app/Subs-Plugins.php index a328c9a8..8bf8d765 100644 --- a/core/app/Subs-Plugins.php +++ b/core/app/Subs-Plugins.php @@ -184,7 +184,7 @@ function deleteFiletree(&$class, $dir, $delete_dir = true) */ function uploadedPluginValidate() { - global $context, $txt, $cachedir; + global $context, $txt; // It's just possible, however unlikely, that the user has done something silly. if (isset($_SESSION['uploadplugin'])) @@ -266,7 +266,7 @@ function uploadedPluginValidate() // What we do need to do, though, is check against plugins that we have currently enabled. (Not enabled... they can fix that themselves from the main listing.) // And we need to store this and make sure it won't be automatically garbage collected. $new_file = 'post_plugin_' . MID . '.zip'; - if (!move_uploaded_file($_FILES['plugin']['tmp_name'], $cachedir . '/' . $new_file)) + if (!move_uploaded_file($_FILES['plugin']['tmp_name'], CACHE_DIR . '/' . $new_file)) fatal_lang_error('plugins_invalid_upload', false); $id = (string) $manifest['id']; @@ -275,8 +275,8 @@ function uploadedPluginValidate() 'file' => $new_file, 'size' => $_FILES['plugin']['size'], 'name' => $_FILES['plugin']['name'], - 'mtime' => filemtime($cachedir . '/' . $new_file), - 'md5' => md5_file($cachedir . '/' . $new_file), + 'mtime' => filemtime(CACHE_DIR . '/' . $new_file), + 'md5' => md5_file(CACHE_DIR . '/' . $new_file), 'id' => $id, 'manifest' => $idx[0], ); @@ -302,7 +302,7 @@ function uploadedPluginValidate() function uploadedPluginConnection() { - global $cachedir, $settings, $context, $txt; + global $settings, $context, $txt; // If we already have details, pass through to the next stage. if (isset($_SESSION['plugin_ftp'])) @@ -321,7 +321,7 @@ function uploadedPluginConnection() if (isset($_POST['cancel'])) { // OK, so we're not proceeding with this one, fair enough. - @unlink($cachedir . '/' . $_SESSION['uploadplugin']['file']); + @unlink(CACHE_DIR . '/' . $_SESSION['uploadplugin']['file']); unset($_SESSION['uploadplugin']); redirectexit('action=admin;area=plugins'); } @@ -547,7 +547,7 @@ function uploadedPluginPrune() function uploadedPluginFolders() { - global $context, $txt, $cachedir; + global $context, $txt; if (!empty($_SESSION['uploadplugin']['folders'])) redirectexit('action=admin;area=plugins;sa=add;upload;stage=4;' . $context['session_query']); @@ -567,7 +567,7 @@ function uploadedPluginFolders() $file_count = 0; try { - $zip = new wextr($cachedir . '/' . $_SESSION['uploadplugin']['file']); + $zip = new wextr(CACHE_DIR . '/' . $_SESSION['uploadplugin']['file']); $list = $zip->list_contents(); if (!empty($_SESSION['uploadplugin']['trunc'])) @@ -649,7 +649,7 @@ function uploadedPluginFolders() function uploadedPluginFiles() { - global $context, $txt, $cachedir; + global $context, $txt; if (isset($_SESSION['uploadplugin']['flist']) && empty($_SESSION['uploadplugin']['flist'])) { @@ -677,7 +677,7 @@ function uploadedPluginFiles() { try { - $zip = new wextr($cachedir . '/' . $_SESSION['uploadplugin']['file']); + $zip = new wextr(CACHE_DIR . '/' . $_SESSION['uploadplugin']['file']); $list = $zip->list_contents(); $files = array(); @@ -711,7 +711,7 @@ function uploadedPluginFiles() try { if (!isset($zip)) - $zip = new wextr($cachedir . '/' . $_SESSION['uploadplugin']['file']); + $zip = new wextr(CACHE_DIR . '/' . $_SESSION['uploadplugin']['file']); while (!empty($_SESSION['uploadplugin']['flist'])) { @@ -762,12 +762,10 @@ function obfuscate_pass($pass) */ function validate_plugin_session() { - global $cachedir; - if (empty($_SESSION['uploadplugin']) || empty($_SESSION['uploadplugin']['file'])) return 'plugins_unable_read'; - $filename = $cachedir . '/' . $_SESSION['uploadplugin']['file']; + $filename = CACHE_DIR . '/' . $_SESSION['uploadplugin']['file']; if (!file_exists($filename) || filesize($filename) != $_SESSION['uploadplugin']['size']) return 'plugins_uploaded_error'; @@ -902,9 +900,7 @@ function test_hooks_conflict($manifest) function clean_up_plugin_session() { - global $cachedir; - if (!empty($_SESSION['uploadplugin']['file'])) - @unlink($cachedir . '/' . $_SESSION['uploadplugin']['file']); + @unlink(CACHE_DIR . '/' . $_SESSION['uploadplugin']['file']); unset($_SESSION['uploadplugin'], $_SESSION['plugin_ftp']); } diff --git a/install/install.php b/install/install.php index 7484318f..668a12b1 100644 --- a/install/install.php +++ b/install/install.php @@ -1857,10 +1857,12 @@ function fixModSecurity() function init_variables() { global $incontext, $txt, $boardurl; - global $boarddir, $context, $settings; + global $context, $settings; // Load Wedge's default paths and pray that it works... - $boarddir = dirname(__DIR__); + define('ROOT_DIR', str_replace('\\', '/', dirname(__FILE__))); + define('APP_DIR', ROOT_DIR . '/core/app'); + // !!! Dunno if we need to load all of these. Better safe than sorry. loadSource(array('Load', 'Subs-Auth', 'Class-String', 'Class-System', 'QueryString', 'Subs', 'Errors', 'Security')); @@ -1872,11 +1874,13 @@ function init_variables() // Define our constants. (cf. QueryString.php) define('ROOT', $boardurl); define('SCRIPT', $boarddir . '/index.php'); - define('TEMPLATES', $boardurl . '/core/html'); define('TEMPLATES_DIR', $boarddir . '/core/html'); + define('TEMPLATES', ROOT . '/core/html'); define('TEMPLATES_DIR', ROOT_DIR . '/core/html'); define('SKINS', ROOT . '/core/skins'); define('SKINS_DIR', ROOT_DIR . '/core/skins'); define('LANGUAGES', ROOT . '/core/languages'); define('LANGUAGES_DIR', ROOT_DIR . '/core/languages'); define('ASSETS', ROOT . '/assets'); define('ASSETS_DIR', ROOT_DIR . '/assets'); define('CACHE', ROOT . '/gz'); define('CACHE_DIR', ROOT_DIR . '/gz'); + define('SMILEYS', ROOT . '/assets/smileys'); + define('AVATARS', ROOT . '/assets/avatars'); westr::getInstance(); we::getInstance(false); diff --git a/install/ssi_examples.php b/install/ssi_examples.php index 57d00ed0..34d5d6e7 100644 --- a/install/ssi_examples.php +++ b/install/ssi_examples.php @@ -30,7 +30,7 @@

Include Code

To use SSI.php in your page add at the very top of your page before the <html> tag on line 1 of your php file:

-
Code: [Select]
<?php require(""); ?>
+
Code: [Select]
<?php require(""); ?>

Some notes on usage

All the functions have an output method parameter. This can either be "echo" (the default) or "array".

@@ -468,8 +468,6 @@ function template_ssi_below() function template_homepage_sample1($method = 'source') { - global $boarddir; - $header = ' @@ -516,7 +514,7 @@ function template_homepage_sample1($method = 'source') if ($method == 'source') { - $header = '<' . '?php require("' . (we::$is_admin ? addslashes(realpath($boarddir . '/SSI.php')) : 'SSI.php') . '"); ?' . ">\n" . $header; + $header = '<' . '?php require("' . (we::$is_admin ? addslashes(realpath(ROOT_DIR . '/SSI.php')) : 'SSI.php') . '"); ?' . ">\n" . $header; return $header . template_homepage_sample1_html() . $footer; } else