2020-03-10 00:04:17 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
if (!\defined('RAINLOOP_APP_LIBRARIES_PATH'))
|
|
|
|
{
|
|
|
|
\define('RAINLOOP_APP_PATH', \rtrim(\realpath(__DIR__), '\\/').'/');
|
|
|
|
\define('RAINLOOP_APP_LIBRARIES_PATH', RAINLOOP_APP_PATH.'libraries/');
|
|
|
|
|
|
|
|
\define('RAINLOOP_INCLUDE_AS_API_DEF', isset($_ENV['RAINLOOP_INCLUDE_AS_API']) && $_ENV['RAINLOOP_INCLUDE_AS_API']);
|
|
|
|
|
|
|
|
function rainLoopSplAutoloadNamespaces() : array
|
|
|
|
{
|
2020-03-12 02:36:43 +08:00
|
|
|
return RAINLOOP_INCLUDE_AS_API_DEF ? array('RainLoop', 'Predis', 'MailSo') :
|
2020-03-20 00:01:49 +08:00
|
|
|
array('RainLoop', 'PHPThumb', 'Predis', 'SabreForRainLoop', 'Imagine', 'MailSo');
|
2020-03-10 00:04:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $sClassName
|
|
|
|
*/
|
2020-03-11 01:45:00 +08:00
|
|
|
function rainLoopSplAutoloadRegisterFunction($sClassName) : void
|
2020-03-10 00:04:17 +08:00
|
|
|
{
|
|
|
|
if ($sClassName && '\\' === $sClassName[0])
|
|
|
|
{
|
|
|
|
$sClassName = \substr($sClassName, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (rainLoopSplAutoloadNamespaces() as $sNamespaceName)
|
|
|
|
{
|
|
|
|
if (0 === \strpos($sClassName, $sNamespaceName.'\\'))
|
|
|
|
{
|
2020-03-20 21:53:12 +08:00
|
|
|
include RAINLOOP_APP_LIBRARIES_PATH.\strtr($sClassName, '\\', '/').'.php';
|
2020-03-11 01:45:00 +08:00
|
|
|
break;
|
2020-03-10 00:04:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
\spl_autoload_register('rainLoopSplAutoloadRegisterFunction', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (\class_exists('RainLoop\Api'))
|
|
|
|
{
|
2020-03-12 02:36:43 +08:00
|
|
|
\MailSo\Base\Loader::Init();
|
2020-03-10 00:04:17 +08:00
|
|
|
|
2020-04-03 17:32:07 +08:00
|
|
|
if (!\function_exists('yaml_parse')) {
|
|
|
|
function yaml_parse(string $input) {
|
2020-07-07 19:47:19 +08:00
|
|
|
require_once RAINLOOP_APP_LIBRARIES_PATH.'spyc/Spyc.php';
|
|
|
|
return \Spyc::YAMLLoadString(\str_replace(array(': >-', ': |-', ': |+'), array(': >', ': |', ': |'), $input));
|
2020-04-03 17:32:07 +08:00
|
|
|
}
|
|
|
|
function yaml_parse_file(string $filename) {
|
2020-07-07 19:47:19 +08:00
|
|
|
return yaml_parse(\file_get_contents($filename));
|
2020-04-03 17:32:07 +08:00
|
|
|
}
|
2020-03-10 00:04:17 +08:00
|
|
|
}
|
|
|
|
|
2020-03-12 02:36:43 +08:00
|
|
|
if (RAINLOOP_INCLUDE_AS_API_DEF)
|
2020-03-10 00:04:17 +08:00
|
|
|
{
|
2020-03-12 02:36:43 +08:00
|
|
|
if (!\defined('APP_API_STARTED'))
|
2020-03-10 00:04:17 +08:00
|
|
|
{
|
2020-03-12 02:36:43 +08:00
|
|
|
\define('APP_API_STARTED', true);
|
2020-03-10 00:04:17 +08:00
|
|
|
|
2020-03-12 02:36:43 +08:00
|
|
|
\RainLoop\Api::Handle();
|
2020-03-10 00:04:17 +08:00
|
|
|
}
|
2020-03-12 02:36:43 +08:00
|
|
|
}
|
|
|
|
else if (!\defined('APP_STARTED'))
|
|
|
|
{
|
|
|
|
\define('APP_STARTED', true);
|
2020-03-10 00:04:17 +08:00
|
|
|
|
2020-03-12 02:36:43 +08:00
|
|
|
\RainLoop\Api::Handle();
|
|
|
|
\RainLoop\Service::Handle();
|
2020-03-10 00:04:17 +08:00
|
|
|
|
2020-03-12 02:36:43 +08:00
|
|
|
\RainLoop\Api::ExitOnEnd();
|
2020-03-10 00:04:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (\function_exists('rainLoopSplAutoloadRegisterFunction'))
|
|
|
|
{
|
|
|
|
\spl_autoload_unregister('rainLoopSplAutoloadRegisterFunction');
|
|
|
|
}
|