snappymail/rainloop/v/1.3.10.490/index.php

153 lines
5.3 KiB
PHP
Raw Normal View History

2013-09-25 03:04:44 +08:00
<?php
if (defined('APP_VERSION'))
{
define('APP_START', microtime(true));
2013-10-28 02:12:54 +08:00
define('APP_INDEX_FILE', 'index.php');
2013-09-25 03:04:44 +08:00
define('APP_VERSION_ROOT_PATH', APP_INDEX_ROOT_PATH.'rainloop/v/'.APP_VERSION.'/');
if (function_exists('date_default_timezone_set'))
{
date_default_timezone_set('UTC');
}
$sSite = strtolower(trim(empty($_SERVER['HTTP_HOST']) ? (empty($_SERVER['SERVER_NAME']) ? '' : $_SERVER['SERVER_NAME']) : $_SERVER['HTTP_HOST']));
$sSite = 'www.' === substr($sSite, 0, 4) ? substr($sSite, 4) : $sSite;
2013-10-08 06:52:30 +08:00
$sSite = preg_replace('/^.+@/', '', preg_replace('/:[\d]+$/', '', $sSite));
2013-09-25 03:04:44 +08:00
$sSite = in_array($sSite, array('localhost', '127.0.0.1', '::1', '::1/128', '0:0:0:0:0:0:0:1')) ? 'localhost' : $sSite;
define('APP_SITE', $sSite);
define('APP_SITE_CLEAR', 0 < strlen(APP_SITE) ? trim(preg_replace('/[^a-zA-Z0-9_.\-]+/', '_', trim(strtolower(APP_SITE))), ' _') : '');
define('APP_DEFAULT_PRIVATE_DATA_NAME', '_default_');
2013-10-11 05:56:33 +08:00
$sPrivateDataFolderInternalName = function_exists('__get_private_data_folder_internal_name') ?
trim(__get_private_data_folder_internal_name(APP_SITE)) : '';
define('APP_PRIVATE_DATA_NAME', 0 === strlen($sPrivateDataFolderInternalName) ? APP_DEFAULT_PRIVATE_DATA_NAME : $sPrivateDataFolderInternalName);
define('APP_MULTIPLY', 0 < strlen($sPrivateDataFolderInternalName) && APP_DEFAULT_PRIVATE_DATA_NAME !== APP_PRIVATE_DATA_NAME);
2013-10-03 06:14:31 +08:00
2013-09-25 03:04:44 +08:00
define('APP_CORE_INSTALL_ACCESS_SITE', function_exists('__get_core_install_access_site') ?
2013-10-07 04:19:50 +08:00
__get_core_install_access_site(APP_SITE) : APP_SITE);
2013-09-25 03:04:44 +08:00
define('APP_DUMMY', '********');
define('APP_DEV_VERSION', '0.0.0');
2013-09-25 03:04:44 +08:00
define('APP_API_PATH', 'http://api.rainloop.net/');
define('APP_REP_PATH', 'http://repository.rainloop.net/v1/');
define('APP_WEB_PATH', 'rainloop/v/'.APP_VERSION.'/');
define('APP_WEB_STATIC_PATH', APP_WEB_PATH.'static/');
define('APP_DATA_FOLDER_PATH_UNIX', str_replace('\\', '/', APP_DATA_FOLDER_PATH));
2013-10-11 05:56:33 +08:00
2013-09-25 03:04:44 +08:00
$sSalt = @file_get_contents(APP_DATA_FOLDER_PATH.'SALT.php');
$sData = @file_get_contents(APP_DATA_FOLDER_PATH.'DATA.php');
$sInstalled = @file_get_contents(APP_DATA_FOLDER_PATH.'INSTALLED');
// installation checking data folder
2013-10-31 05:03:32 +08:00
if (APP_VERSION !== $sInstalled)
2013-09-25 03:04:44 +08:00
{
include APP_VERSION_ROOT_PATH.'check.php';
$sCheckName = 'delete_if_you_see_it_after_install';
$sCheckFolder = APP_DATA_FOLDER_PATH.$sCheckName;
$sCheckFilePath = APP_DATA_FOLDER_PATH.$sCheckName.'/'.$sCheckName.'.file';
@unlink($sCheckFilePath);
@rmdir($sCheckFolder);
if (!@is_dir(APP_DATA_FOLDER_PATH))
{
@mkdir(APP_DATA_FOLDER_PATH, 0755);
2013-09-25 03:04:44 +08:00
}
else
{
@chmod(APP_DATA_FOLDER_PATH, 0755);
2013-09-25 03:04:44 +08:00
}
if (
!@is_dir(APP_DATA_FOLDER_PATH) || !is_readable(APP_DATA_FOLDER_PATH) || !is_writable(APP_DATA_FOLDER_PATH) ||
!@mkdir($sCheckFolder, 0755) ||
2013-09-25 03:04:44 +08:00
false === @file_put_contents($sCheckFilePath, time()) ||
!@unlink($sCheckFilePath) ||
!@rmdir($sCheckFolder)
)
{
echo '[202] Data folder permisions error';
2013-09-25 03:04:44 +08:00
exit(202);
}
unset($sCheckName, $sCheckFilePath, $sCheckFolder);
}
if (false === $sSalt || false === $sData)
{
if (false === $sSalt)
{
// random salt
$sSalt = '<'.'?php //'
.md5(microtime(true).rand(1000, 5000))
.md5(microtime(true).rand(5000, 9999))
.md5(microtime(true).rand(1000, 5000));
@file_put_contents(APP_DATA_FOLDER_PATH.'SALT.php', $sSalt);
}
if (false === $sData)
{
// random data folder name
$sData = '<'.'?php //'.md5(microtime(true).rand(1000, 9999));
@file_put_contents(APP_DATA_FOLDER_PATH.'DATA.php', $sData);
}
}
define('APP_SALT', md5($sSalt.APP_PRIVATE_DATA_NAME.$sSalt));
define('APP_PRIVATE_DATA', APP_DATA_FOLDER_PATH.'_data_'.md5($sData).'/'.APP_PRIVATE_DATA_NAME.'/');
define('APP_PLUGINS_PATH', APP_PRIVATE_DATA.'plugins/');
2013-10-31 05:03:32 +08:00
if (APP_VERSION !== $sInstalled || (APP_MULTIPLY && !@is_dir(APP_PRIVATE_DATA)))
2013-09-25 03:04:44 +08:00
{
define('APP_INSTALLED_START', true);
define('APP_INSTALLED_VERSION', $sInstalled);
@file_put_contents(APP_DATA_FOLDER_PATH.'INSTALLED', APP_VERSION);
@file_put_contents(APP_DATA_FOLDER_PATH.'index.html', 'Forbidden');
@file_put_contents(APP_DATA_FOLDER_PATH.'index.php', 'Forbidden');
@file_put_contents(APP_DATA_FOLDER_PATH.'.htaccess',
'Deny from all
<IfModule mod_autoindex.c>
Options -Indexes
</ifModule>');
if (!@is_dir(APP_PRIVATE_DATA))
{
@mkdir(APP_PRIVATE_DATA, 0755, true);
2013-09-25 03:04:44 +08:00
}
foreach (array('logs', 'cache', 'configs', 'plugins', 'storage') as $sName)
{
if (!@is_dir(APP_PRIVATE_DATA.$sName))
{
@mkdir(APP_PRIVATE_DATA.$sName, 0755, true);
2013-09-25 03:04:44 +08:00
}
}
if (!@file_exists(APP_PRIVATE_DATA.'domains/default.ini'))
{
if (!@is_dir(APP_PRIVATE_DATA.'domains'))
{
@mkdir(APP_PRIVATE_DATA.'domains', 0755);
2013-09-25 03:04:44 +08:00
@copy(APP_VERSION_ROOT_PATH.'app/domains/disabled', APP_PRIVATE_DATA.'domains/disabled');
@copy(APP_VERSION_ROOT_PATH.'app/domains/gmail.com.ini', APP_PRIVATE_DATA.'domains/gmail.com.ini');
@copy(APP_VERSION_ROOT_PATH.'app/domains/yahoo.com.ini', APP_PRIVATE_DATA.'domains/yahoo.com.ini');
2013-10-17 02:52:37 +08:00
@copy(APP_VERSION_ROOT_PATH.'app/domains/outlook.com.ini', APP_PRIVATE_DATA.'domains/outlook.com.ini');
2013-09-25 03:04:44 +08:00
}
@copy(APP_VERSION_ROOT_PATH.'app/domains/default.ini.dist', APP_PRIVATE_DATA.'domains/default.ini');
}
}
unset($sSite, $sSalt, $sData, $sInstalled, $sPrivateDataFolderInternalName);
2013-09-25 03:04:44 +08:00
include APP_VERSION_ROOT_PATH.'app/handle.php';
}