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

72 lines
2.1 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
{
2014-10-18 20:52:51 +08:00
\define('RAINLOOP_APP_PATH', \rtrim(\realpath(__DIR__), '\\/').'/');
\define('RAINLOOP_APP_LIBRARIES_PATH', RAINLOOP_APP_PATH.'libraries/');
\define('RAINLOOP_MB_SUPPORTED', \function_exists('mb_strtoupper'));
2013-09-25 03:04:44 +08:00
2014-10-15 23:11:50 +08:00
/**
* @param string $sClassName
2014-10-18 20:52:51 +08:00
*
2014-10-15 23:11:50 +08:00
* @return mixed
*/
function RainLoopSplAutoloadRegisterFunction($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
{
2014-10-18 20:52:51 +08:00
return include RAINLOOP_APP_PATH.'src/RainLoop/'.\str_replace('\\', '/', \substr($sClassName, 9)).'.php';
2013-09-25 03:04:44 +08:00
}
else if (0 === \strpos($sClassName, 'Facebook') && false !== \strpos($sClassName, '\\'))
{
return include RAINLOOP_APP_LIBRARIES_PATH.'Facebook/'.\str_replace('\\', '/', \substr($sClassName, 9)).'.php';
}
else if (0 === \strpos($sClassName, 'GuzzleHttp') && false !== \strpos($sClassName, '\\'))
{
return include RAINLOOP_APP_LIBRARIES_PATH.'GuzzleHttp/'.\str_replace('\\', '/', \substr($sClassName, 11)).'.php';
}
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;
2014-10-15 23:11:50 +08:00
}
\spl_autoload_register('RainLoopSplAutoloadRegisterFunction', false);
}
2013-09-25 03:04:44 +08:00
if (\class_exists('RainLoop\Service'))
{
if (!\class_exists('MailSo\Version'))
2013-09-25 03:04:44 +08:00
{
2014-10-15 23:11:50 +08:00
include APP_VERSION_ROOT_PATH.'app/libraries/MailSo/MailSo.php';
}
2013-09-25 03:04:44 +08:00
2014-10-15 23:11:50 +08:00
if (\class_exists('MailSo\Version'))
{
2014-10-15 23:11:50 +08:00
if (isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API'] && !\defined('APP_API_STARTED'))
2013-09-25 03:04:44 +08:00
{
2014-10-15 23:11:50 +08:00
\define('APP_API_STARTED', true);
\RainLoop\Api::Handle();
}
else if (!\defined('APP_STARTED'))
{
\define('APP_STARTED', true);
2014-10-15 23:11:50 +08:00
\RainLoop\Api::Handle();
\RainLoop\Service::Handle();
2013-09-25 03:04:44 +08:00
}
}
}
2014-10-15 23:11:50 +08:00
else if (\function_exists('RainLoopSplAutoloadRegisterFunction'))
{
\spl_autoload_unregister('RainLoopSplAutoloadRegisterFunction');
}
return '';