snappymail/rainloop/v/0.0.0/app/handle.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2013-09-25 03:04:44 +08:00
<?php
if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
2013-09-25 03:04:44 +08:00
{
\define('RAINLOOP_APP_LIBRARIES_PATH', \rtrim(\realpath(__DIR__), '\\/').'/libraries/');
\define('RAINLOOP_MB_SUPPORTED', \function_exists('mb_strtoupper'));
2013-09-25 03:04:44 +08:00
\spl_autoload_register(function ($sClassName) {
2013-10-03 06:14:31 +08:00
if (0 === \strpos($sClassName, 'RainLoop') && false !== \strpos($sClassName, '\\'))
2013-09-25 03:04:44 +08:00
{
2013-10-03 06:14:31 +08:00
return include RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/'.\str_replace('\\', '/', \substr($sClassName, 9)).'.php';
2013-09-25 03:04:44 +08:00
}
2013-12-20 00:04:56 +08:00
else if (0 === \strpos($sClassName, 'Sabre') && false !== \strpos($sClassName, '\\'))
{
if (!RAINLOOP_MB_SUPPORTED && !defined('RL_MB_FIXED'))
{
\define('RL_MB_FIXED', true);
include_once RAINLOOP_APP_LIBRARIES_PATH.'RainLoop/Common/MbStringFix.php';
}
2013-12-20 00:04:56 +08:00
return include RAINLOOP_APP_LIBRARIES_PATH.'Sabre/'.\str_replace('\\', '/', \substr($sClassName, 6)).'.php';
}
2013-09-25 03:04:44 +08:00
return false;
});
}
2013-09-25 03:04:44 +08:00
if (\class_exists('RainLoop\Service'))
{
$oException = null;
if (!\class_exists('MailSo\Version'))
2013-09-25 03:04:44 +08:00
{
try
{
include APP_VERSION_ROOT_PATH.'app/libraries/MailSo/MailSo.php';
}
catch (\Exception $oException) {}
}
2013-09-25 03:04:44 +08:00
if (!$oException)
{
if (isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API'])
2013-09-25 03:04:44 +08:00
{
$_ENV['RAINLOOP_INCLUDE_AS_API'] = false;
\RainLoop\Api::Handle();
}
else if (!\defined('APP_STARTED'))
{
\define('APP_STARTED', true);
\RainLoop\Service::NewInstance()->Handle();
2013-09-25 03:04:44 +08:00
}
}
}
return '';