mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Uploading and preparing the repository to the dev version.
Original unminified source code (dev folder - js, css, less) (fixes #6) Grunt build system Multiple identities correction (fixes #9) Compose html editor (fixes #12) New general settings - Loading Description New warning about default admin password Split general and login screen settings
This commit is contained in:
parent
afad45137e
commit
4cc2207513
846 changed files with 99453 additions and 2123 deletions
|
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop\Config;
|
||||
|
||||
abstract class AbstractConfig
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sFile;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aData;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sFilePrefix;
|
||||
|
||||
/**
|
||||
* @param string $sFileName
|
||||
* @param string $sFilePrefix = ''
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($sFileName, $sFilePrefix = '')
|
||||
{
|
||||
$this->sFile = \APP_PRIVATE_DATA.'configs/'.$sFileName;
|
||||
$this->sFilePrefix = $sFilePrefix;
|
||||
$this->aData = $this->defaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected abstract function defaultValues();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function IsInited()
|
||||
{
|
||||
return is_array($this->aData) && 0 < count($this->aData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sSection
|
||||
* @param string $sName
|
||||
* @param mixed $mDefault = null
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function Get($sSection, $sName, $mDefault = null)
|
||||
{
|
||||
$mResult = $mDefault;
|
||||
if (isset($this->aData[$sSection][$sName][0]))
|
||||
{
|
||||
$mResult = $this->aData[$sSection][$sName][0];
|
||||
}
|
||||
return $mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sSectionKey
|
||||
* @param string $sParamKey
|
||||
* @param mixed $mParamValue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function Set($sSectionKey, $sParamKey, $mParamValue)
|
||||
{
|
||||
if (isset($this->aData[$sSectionKey][$sParamKey][0]))
|
||||
{
|
||||
$sType = gettype($this->aData[$sSectionKey][$sParamKey][0]);
|
||||
switch ($sType)
|
||||
{
|
||||
default:
|
||||
case 'string':
|
||||
$this->aData[$sSectionKey][$sParamKey][0] = (string) $mParamValue;
|
||||
break;
|
||||
case 'int':
|
||||
case 'integer':
|
||||
$this->aData[$sSectionKey][$sParamKey][0] = (int) $mParamValue;
|
||||
break;
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
$this->aData[$sSectionKey][$sParamKey][0] = (bool) $mParamValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ('custom' === $sSectionKey)
|
||||
{
|
||||
$this->aData[$sSectionKey][$sParamKey] = array((string) $mParamValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function Load()
|
||||
{
|
||||
if (\file_exists($this->sFile) && \is_readable($this->sFile))
|
||||
{
|
||||
$aData = @\parse_ini_file($this->sFile, true);
|
||||
if (\is_array($aData) && 0 < count($aData))
|
||||
{
|
||||
foreach ($aData as $sSectionKey => $aSectionValue)
|
||||
{
|
||||
if (\is_array($aSectionValue))
|
||||
{
|
||||
foreach ($aSectionValue as $sParamKey => $mParamValue)
|
||||
{
|
||||
$this->Set($sSectionKey, $sParamKey, $mParamValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function Save()
|
||||
{
|
||||
if (\file_exists($this->sFile) && !\is_writable($this->sFile))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$sNewLine = "\n";
|
||||
|
||||
$aResultLines = array();
|
||||
|
||||
foreach ($this->aData as $sSectionKey => $aSectionValue)
|
||||
{
|
||||
if (\is_array($aSectionValue))
|
||||
{
|
||||
$aResultLines[] = '';
|
||||
$aResultLines[] = '['.$sSectionKey.']';
|
||||
$bFirst = true;
|
||||
|
||||
foreach ($aSectionValue as $sParamKey => $mParamValue)
|
||||
{
|
||||
if (\is_array($mParamValue))
|
||||
{
|
||||
if (!empty($mParamValue[1]))
|
||||
{
|
||||
$sDesk = \str_replace("\r", '', $mParamValue[1]);
|
||||
$aDesk = \explode("\n", $sDesk);
|
||||
$aDesk = \array_map(function (&$sLine) {
|
||||
return '; '.$sLine;
|
||||
}, $aDesk);
|
||||
|
||||
if (!$bFirst)
|
||||
{
|
||||
$aResultLines[] = '';
|
||||
}
|
||||
|
||||
$aResultLines[] = \implode($sNewLine, $aDesk);
|
||||
}
|
||||
|
||||
$bFirst = false;
|
||||
|
||||
$sValue = '""';
|
||||
switch (\gettype($mParamValue[0]))
|
||||
{
|
||||
default:
|
||||
case 'string':
|
||||
$sValue = '"'.$mParamValue[0].'"';
|
||||
break;
|
||||
case 'int':
|
||||
case 'integer':
|
||||
$sValue = $mParamValue[0];
|
||||
break;
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
$sValue = $mParamValue[0] ? 'On' : 'Off';
|
||||
break;
|
||||
}
|
||||
|
||||
$aResultLines[] = $sParamKey.' = '.$sValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false !== \file_put_contents($this->sFile,
|
||||
(0 < \strlen($this->sFilePrefix) ? $this->sFilePrefix : '').
|
||||
$sNewLine.\implode($sNewLine, $aResultLines));
|
||||
}
|
||||
}
|
||||
225
rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php
Normal file
225
rainloop/v/0.0.0/app/libraries/RainLoop/Config/Application.php
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop\Config;
|
||||
|
||||
class Application extends \RainLoop\Config\AbstractConfig
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('application.ini',
|
||||
'; RainLoop Webmail configuration file
|
||||
; Please don\'t add custom parameters here, those will be overwritten');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPassword
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function SetPassword($sPassword)
|
||||
{
|
||||
return $this->Set('security', 'admin_password', \md5(APP_SALT.$sPassword.APP_SALT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sPassword
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function ValidatePassword($sPassword)
|
||||
{
|
||||
$sPassword = (string) $sPassword;
|
||||
$sConfigPassword = (string) $this->Get('security', 'admin_password', '');
|
||||
|
||||
return 0 < \strlen($sPassword) &&
|
||||
($sPassword === $sConfigPassword || \md5(APP_SALT.$sPassword.APP_SALT) === $sConfigPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function Save()
|
||||
{
|
||||
$this->Set('version', 'current', APP_VERSION);
|
||||
$this->Set('version', 'saved', \gmdate('r'));
|
||||
|
||||
return parent::Save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function defaultValues()
|
||||
{
|
||||
return array(
|
||||
'webmail' => array(
|
||||
|
||||
'title' => array('RainLoop Webmail', 'Text displayed as page title'),
|
||||
'loading_description' => array('RainLoop', 'Text displayed on startup'),
|
||||
|
||||
'theme' => array('Default', 'Theme used by default'),
|
||||
'allow_themes' => array(true, 'Allow theme selection on settings screen'),
|
||||
'allow_custom_theme' => array(true, ''),
|
||||
|
||||
'language' => array('en', 'Language used by default'),
|
||||
'allow_languages_on_settings' => array(true, 'Allow language selection on settings screen'),
|
||||
|
||||
'allow_additional_accounts' => array(true, ''),
|
||||
'allow_identities' => array(false, ''),
|
||||
|
||||
'use_preview_pane' => array(true, 'Whether message preview pane should be used'),
|
||||
|
||||
'messages_per_page' => array(20, ' Number of messages displayed on page by default'),
|
||||
|
||||
'editor_default_type' => array('Html', 'Editor mode used by default (Html or Plain)'),
|
||||
|
||||
'attachment_size_limit' => array(5,
|
||||
'File size limit (MB) for file upload on compose screen
|
||||
0 for unlimited.')
|
||||
),
|
||||
|
||||
'security' => array(
|
||||
'csrf_protection' => array(true,
|
||||
'Enable CSRF protection (http://en.wikipedia.org/wiki/Cross-site_request_forgery)'),
|
||||
|
||||
'custom_server_signature' => array('RainLoop'),
|
||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||
'admin_password' => array('12345')
|
||||
),
|
||||
|
||||
'login' => array(
|
||||
|
||||
'allow_custom_login' => array(false,
|
||||
'Enable additional Login field on webmail login screen'),
|
||||
|
||||
'default_domain' => array('', ''),
|
||||
|
||||
'allow_languages_on_login' => array(true,
|
||||
'Allow language selection on webmail login screen'),
|
||||
|
||||
'sign_me_auto' => array(\RainLoop\Enumerations\SignMeType::DEFAILT_OFF,
|
||||
'This option allows webmail to remember the logged in user
|
||||
once they closed the browser window.
|
||||
|
||||
Values:
|
||||
"DefaultOff" - can be used, disabled by default;
|
||||
"DefaultOn" - can be used, enabled by default;
|
||||
"Unused" - cannot be used')
|
||||
),
|
||||
|
||||
'plugins' => array(
|
||||
'enable' => array(false, 'Enable plugin support'),
|
||||
'enabled_list' => array('', 'List of enabled plugins'),
|
||||
),
|
||||
|
||||
'logs' => array(
|
||||
|
||||
'enable' => array(false, 'Enable logging'),
|
||||
|
||||
'write_on_error_only' => array(false, 'Logs entire request only if error occured'),
|
||||
|
||||
'filename' => array('log-{date:Y-m-d}.txt',
|
||||
'Log filename.
|
||||
For security reasons, some characters are removed from filename.
|
||||
Allows for pattern-based folder creation (see examples below).
|
||||
|
||||
Patterns:
|
||||
{date:Y-m-d} - Replaced by pattern-based date
|
||||
Detailed info: http://www.php.net/manual/en/function.date.php
|
||||
{user:email} - Replaced by user\'s email address
|
||||
If user is not logged in, value is set to "unknown"
|
||||
{user:login} - Replaced by user\'s login
|
||||
If user is not logged in, value is set to "unknown"
|
||||
{user:domain} - Replaced by user\'s domain name
|
||||
If user is not logged in, value is set to "unknown"
|
||||
{user:uid} - Replaced by user\'s UID regardless of account currently used
|
||||
|
||||
Examples:
|
||||
filename = "log-{date:Y-m-d}.txt"
|
||||
filename = "{date:Y-m-d}/{user:domain}/{user:email}_{user:uid}.log"
|
||||
filename = "{user:email}-{date:Y-m-d}.txt"')
|
||||
),
|
||||
|
||||
'debug' => array(
|
||||
'enable' => array(false, 'Special option required for development purposes'),
|
||||
),
|
||||
|
||||
'version' => array(
|
||||
'current' => array(''),
|
||||
'saved' => array('')
|
||||
),
|
||||
|
||||
'social' => array(
|
||||
'google_enable' => array(false, 'Google'),
|
||||
'google_client_id' => array(''),
|
||||
'google_client_secret' => array(''),
|
||||
|
||||
'fb_enable' => array(false, 'Facebook'),
|
||||
'fb_app_id' => array(''),
|
||||
'fb_app_secret' => array(''),
|
||||
|
||||
'twitter_enable' => array(false, 'Twitter'),
|
||||
'twitter_consumer_key' => array(''),
|
||||
'twitter_consumer_secret' => array(''),
|
||||
|
||||
'dropbox_enable' => array(false, 'Dropbox'),
|
||||
'dropbox_api_key' => array(''),
|
||||
),
|
||||
|
||||
'cache' => array(
|
||||
'enable' => array(true,
|
||||
'The section controls caching of the entire application.
|
||||
|
||||
Enables caching in the system'),
|
||||
|
||||
'index' => array('v1', 'Additional caching key. If changed, cache is purged'),
|
||||
|
||||
'fast_cache_driver' => array('files', 'Can be: files, APC, memcache'),
|
||||
'fast_cache_index' => array('v1', 'Additional caching key. If changed, fast cache is purged'),
|
||||
|
||||
'http' => array(true, 'Browser-level cache. If enabled, caching is maintainted without using files'),
|
||||
'server_uids' => array(false, 'Caching message UIDs when searching and sorting (threading)')
|
||||
),
|
||||
|
||||
'labs' => array(
|
||||
'ignore_folders_subscription' => array(false,
|
||||
'Experimental settings. Handle with care.
|
||||
'),
|
||||
'allow_message_append' => array(false),
|
||||
'date_from_headers' => array(false),
|
||||
'cache_system_data' => array(true),
|
||||
'use_app_debug_js' => array(false),
|
||||
'use_app_debug_css' => array(false),
|
||||
'login_fault_delay' => array(1),
|
||||
'log_ajax_response_write_limit' => array(300),
|
||||
'suggestions_limit' => array(50),
|
||||
'determine_user_language' => array(true),
|
||||
'use_imap_sort' => array(false),
|
||||
'use_imap_list_status' => array(false),
|
||||
'use_imap_list_subscribe' => array(true),
|
||||
'use_imap_thread' => array(true),
|
||||
'use_imap_move' => array(true),
|
||||
'use_imap_auth_plain' => array(false),
|
||||
'custom_repo' => array(''),
|
||||
'additional_repo' => array(''),
|
||||
'cdn_static_domain' => array(''),
|
||||
'in_iframe' => array(false),
|
||||
'custom_login_link' => array(''),
|
||||
'custom_logout_link' => array(''),
|
||||
'allow_contacts' => array(true),
|
||||
'allow_external_login' => array(false),
|
||||
'allow_admin_panel' => array(true),
|
||||
'fast_cache_memcache_host' => array('127.0.0.1'),
|
||||
'fast_cache_memcache_port' => array(11211),
|
||||
'fast_cache_memcache_expire' => array(43200),
|
||||
'usage_statistics' => array(true),
|
||||
'dev_email' => array(''),
|
||||
'dev_login' => array(''),
|
||||
'dev_password' => array('')
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
59
rainloop/v/0.0.0/app/libraries/RainLoop/Config/Plugin.php
Normal file
59
rainloop/v/0.0.0/app/libraries/RainLoop/Config/Plugin.php
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace RainLoop\Config;
|
||||
|
||||
class Plugin extends \RainLoop\Config\AbstractConfig
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aMap;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($sPluginName, $aMap = array())
|
||||
{
|
||||
$this->aMap = is_array($aMap) ? $this->convertConfigMap($aMap) : array();
|
||||
|
||||
parent::__construct('plugin-'.$sPluginName.'.ini', '; RainLoop Webmail plugin ('.$sPluginName.')');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aMap
|
||||
* @return array
|
||||
*/
|
||||
private function convertConfigMap($aMap)
|
||||
{
|
||||
if (0 < count($aMap))
|
||||
{
|
||||
$aResultMap = array();
|
||||
foreach ($aMap as /* @var $oProperty \RainLoop\Plugins\Property */ $oProperty)
|
||||
{
|
||||
if ($oProperty)
|
||||
{
|
||||
$mValue = $oProperty->DefaultValue();
|
||||
$sValue = is_array($mValue) && isset($mValue[0]) ? $mValue[0] : $mValue;
|
||||
$aResultMap[$oProperty->Name()] = array($sValue, '');
|
||||
}
|
||||
}
|
||||
|
||||
if (0 < count($aResultMap))
|
||||
{
|
||||
return array(
|
||||
'plugin' => $aResultMap
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function defaultValues()
|
||||
{
|
||||
return $this->aMap;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue