Example #1
0
    return $x;
}
// Use the patchwork/utf8 library to:
// 1) set all PHP defaults to UTF-8
// 2) create shims for missing mb_string functions such as mb_strlen()
// 3) check that requests are valid UTF-8
\Patchwork\Utf8\Bootup::initAll();
// Enables the portablity layer and configures PHP for UTF-8
\Patchwork\Utf8\Bootup::filterRequestUri();
// Redirects to an UTF-8 encoded URL if it's not already the case
\Patchwork\Utf8\Bootup::filterRequestInputs();
// Normalizes HTTP inputs to UTF-8 NFC
// Use the fisharebest/ext-calendar library to
// 1) provide shims for the PHP ext/calendar extension, such as JewishToJD()
// 2) provide calendar conversions for the Arabic and Persian calendars
\Fisharebest\ExtCalendar\Shim::create();
// Split the request protocol://host:port/path/to/script.php?var=value into parts
// WT_SERVER_NAME  = protocol://host:port
// WT_SCRIPT_PATH  = /path/to/   (begins and ends with /)
// WT_SCRIPT_NAME  = script.php  (already defined in the calling script)
$https = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off';
define('WT_SERVER_NAME', ($https ? 'https://' : 'http://') . (empty($_SERVER['SERVER_NAME']) ? '' : $_SERVER['SERVER_NAME']) . (empty($_SERVER['SERVER_PORT']) || !$https && $_SERVER['SERVER_PORT'] == 80 || $https && $_SERVER['SERVER_PORT'] == 443 ? '' : ':' . $_SERVER['SERVER_PORT']));
// REDIRECT_URL should be set in the case of Apache following a RedirectRule
// SCRIPT_NAME should always be correct, but is not always present.
// PHP_SELF should always be present, but may have trailing path: /path/to/script.php/FOO/BAR
if (!empty($_SERVER['REDIRECT_URL'])) {
    define('WT_SCRIPT_PATH', substr($_SERVER['REDIRECT_URL'], 0, stripos($_SERVER['REDIRECT_URL'], WT_SCRIPT_NAME)));
} elseif (!empty($_SERVER['SCRIPT_NAME'])) {
    define('WT_SCRIPT_PATH', substr($_SERVER['SCRIPT_NAME'], 0, stripos($_SERVER['SCRIPT_NAME'], WT_SCRIPT_NAME)));
} elseif (!empty($_SERVER['PHP_SELF'])) {
    define('WT_SCRIPT_PATH', substr($_SERVER['PHP_SELF'], 0, stripos($_SERVER['PHP_SELF'], WT_SCRIPT_NAME)));
Example #2
0
 * @license   This program is free software: you can redistribute it and/or modify
 *            it under the terms of the GNU General Public License as published by
 *            the Free Software Foundation, either version 3 of the License, or
 *            (at your option) any later version.
 *
 *            This program is distributed in the hope that it will be useful,
 *            but WITHOUT ANY WARRANTY; without even the implied warranty of
 *            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *            GNU General Public License for more details.
 *
 *            You should have received a copy of the GNU General Public License
 *            along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
use Fisharebest\ExtCalendar\Shim;
if (!defined('CAL_GREGORIAN')) {
    Shim::create();
    define('CAL_GREGORIAN', 0);
    define('CAL_JULIAN', 1);
    define('CAL_JEWISH', 2);
    define('CAL_FRENCH', 3);
    define('CAL_NUM_CALS', 4);
    define('CAL_DOW_DAYNO', 0);
    define('CAL_DOW_SHORT', Shim::shouldEmulateBug67960() ? 1 : 2);
    define('CAL_DOW_LONG', Shim::shouldEmulateBug67960() ? 2 : 1);
    define('CAL_MONTH_GREGORIAN_SHORT', 0);
    define('CAL_MONTH_GREGORIAN_LONG', 1);
    define('CAL_MONTH_JULIAN_SHORT', 2);
    define('CAL_MONTH_JULIAN_LONG', 3);
    define('CAL_MONTH_JEWISH', 4);
    define('CAL_MONTH_FRENCH', 5);
    define('CAL_EASTER_DEFAULT', 0);