mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
parent
e82108ac85
commit
4a47796781
29 changed files with 724 additions and 195 deletions
29
build/owncloud/rainloop-app/INSTALL
Normal file
29
build/owncloud/rainloop-app/INSTALL
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
************************************************************************
|
||||
*
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*
|
||||
************************************************************************
|
||||
|
||||
INSTALL:
|
||||
- Unpack the RainLoop Webmail application package in the apps directory of your OwnCloud instance
|
||||
|
||||
CONFIGURATION:
|
||||
|
||||
RainLoop:
|
||||
1) Open ../_default_/configs/application.ini
|
||||
2) Find:
|
||||
|
||||
[labs]
|
||||
allow_external_sso = On
|
||||
external_sso_key = "super-secret-key"
|
||||
|
||||
ownCloud:
|
||||
1) In the Apps > Enable 'RainLoop' plugin
|
||||
2) In the Settings > Admin > Enter "RainLoop Webmail URL" and "SSO key"
|
||||
3) In the Settings > Personal > Type your mail server email and password
|
||||
|
||||
19
build/owncloud/rainloop-app/admin.php
Normal file
19
build/owncloud/rainloop-app/admin.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
OCP\User::checkAdminUser();
|
||||
|
||||
OCP\Util::addScript('rainloop', 'admin');
|
||||
|
||||
$oTemplate = new OCP\Template('rainloop', 'admin');
|
||||
$oTemplate->assign('rainloop-url', OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
||||
$oTemplate->assign('rainloop-sso-key', OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', ''));
|
||||
return $oTemplate->fetchPage();
|
||||
33
build/owncloud/rainloop-app/ajax/admin.php
Normal file
33
build/owncloud/rainloop-app/ajax/admin.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
OCP\JSON::checkAdminUser();
|
||||
OCP\JSON::checkAppEnabled('rainloop');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$sUrl = '';
|
||||
$sSsoKey = '';
|
||||
if (isset($_POST['appname'], $_POST['rainloop-url'], $_POST['rainloop-sso-key']) && 'rainloop' === $_POST['appname'])
|
||||
{
|
||||
OCP\Config::setAppValue('rainloop', 'rainloop-url', $_POST['rainloop-url']);
|
||||
OCP\Config::setAppValue('rainloop', 'rainloop-sso-key', $_POST['rainloop-sso-key']);
|
||||
|
||||
$sUrl = OCP\Config::getAppValue('rainloop', 'rainloop-url', '');
|
||||
$sSsoKey = OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', '');
|
||||
}
|
||||
else
|
||||
{
|
||||
OC_JSON::error(array('Message' => 'Invalid Argument(s)', 'Url' => $sUrl, 'SsoKey' => $sSsoKey));
|
||||
return false;
|
||||
}
|
||||
|
||||
OCP\JSON::success(array('Message' => 'Saved successfully', 'Url' => $sUrl, 'SsoKey' => $sSsoKey));
|
||||
return true;
|
||||
45
build/owncloud/rainloop-app/ajax/personal.php
Normal file
45
build/owncloud/rainloop-app/ajax/personal.php
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
OCP\JSON::checkLoggedIn();
|
||||
OCP\JSON::checkAppEnabled('rainloop');
|
||||
OCP\JSON::callCheck();
|
||||
|
||||
$sEmail = '';
|
||||
$sLogin = '';
|
||||
if (isset($_POST['appname'], $_POST['rainloop-password'], $_POST['rainloop-email']) && 'rainloop' === $_POST['appname'])
|
||||
{
|
||||
$sUser = OCP\User::getUser();
|
||||
|
||||
$sPostEmail = $_POST['rainloop-email'];
|
||||
$sPostLogin = isset($_POST['rainloop-login']) ? $_POST['rainloop-login'] : '';
|
||||
|
||||
OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-email', $sPostEmail);
|
||||
|
||||
$sPass = $_POST['rainloop-password'];
|
||||
if ('******' !== $sPass && '' !== $sPass)
|
||||
{
|
||||
include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php';
|
||||
OCP\Config::setUserValue($sUser, 'rainloop', 'rainloop-password',
|
||||
OC_RainLoop_Helper::encodePassword($sPass, md5($sPostEmail.$sPostLogin)));
|
||||
}
|
||||
|
||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
||||
$sLogin = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-login', '');
|
||||
}
|
||||
else
|
||||
{
|
||||
OC_JSON::error(array('Message' => 'Invalid argument(s)', 'Email' => $sEmail, 'Login' => $sLogin));
|
||||
return false;
|
||||
}
|
||||
|
||||
OCP\JSON::success(array('Message' => 'Saved successfully', 'Email' => $sEmail, 'Login' => $sLogin));
|
||||
return true;
|
||||
23
build/owncloud/rainloop-app/appinfo/app.php
Normal file
23
build/owncloud/rainloop-app/appinfo/app.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/owncloud
|
||||
*/
|
||||
|
||||
OCP\App::registerAdmin('rainloop', 'admin');
|
||||
OCP\App::registerPersonal('rainloop', 'personal');
|
||||
|
||||
OCP\Util::addScript('rainloop', 'rainloop');
|
||||
|
||||
OCP\App::addNavigationEntry(array(
|
||||
'id' => 'rainloop_index',
|
||||
'order' => 10,
|
||||
'href' => OCP\Util::linkTo('rainloop', 'index.php'),
|
||||
'icon' => OCP\Util::imagePath('rainloop', 'mail.png'),
|
||||
'name' => 'RainLoop'
|
||||
));
|
||||
10
build/owncloud/rainloop-app/appinfo/info.xml
Normal file
10
build/owncloud/rainloop-app/appinfo/info.xml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0"?>
|
||||
<info>
|
||||
<id>rainloop</id>
|
||||
<name>RainLoop</name>
|
||||
<description>RainLoop Webmail</description>
|
||||
<version>0.0.0</version>
|
||||
<licence>CC BY-NC-SA 3.0</licence>
|
||||
<author>RainLoop Team</author>
|
||||
<require>6.0</require>
|
||||
</info>
|
||||
BIN
build/owncloud/rainloop-app/img/logo-64x64.png
Normal file
BIN
build/owncloud/rainloop-app/img/logo-64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 832 B |
BIN
build/owncloud/rainloop-app/img/mail.png
Normal file
BIN
build/owncloud/rainloop-app/img/mail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
41
build/owncloud/rainloop-app/index.php
Normal file
41
build/owncloud/rainloop-app/index.php
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
OCP\User::checkLoggedIn();
|
||||
OCP\App::checkAppEnabled('rainloop');
|
||||
OCP\App::setActiveNavigationEntry('rainloop_index');
|
||||
|
||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
||||
$sSsoKey = trim(OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', ''));
|
||||
|
||||
if ('' === $sUrl || '' === $sSsoKey)
|
||||
{
|
||||
$oTemplate = new OCP\Template('rainloop', 'index-empty', 'user');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sUser = OCP\User::getUser();
|
||||
|
||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
||||
$sLogin = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-login', '');
|
||||
$sPassword = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', '');
|
||||
|
||||
include_once OC_App::getAppPath('rainloop').'/lib/RainLoopHelper.php';
|
||||
$sPassword = OC_RainLoop_Helper::decodePassword($sPassword, md5($sEmail.$sLogin));
|
||||
$sSsoHash = OC_RainLoop_Helper::getSsoHash($sUrl, $sSsoKey, $sEmail, $sPassword, $sLogin);
|
||||
|
||||
$sResultUrl = empty($sSsoHash) ? $sUrl : $sUrl.'?sso&hash='.$sSsoHash;
|
||||
|
||||
$oTemplate = new OCP\Template('rainloop', 'index', 'user');
|
||||
$oTemplate->assign('rainloop-url', $sResultUrl);
|
||||
}
|
||||
|
||||
$oTemplate->printpage();
|
||||
13
build/owncloud/rainloop-app/js/admin.js
Normal file
13
build/owncloud/rainloop-app/js/admin.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
RainLoopFormHelper('#mail-rainloop-admin-form', 'admin.php');
|
||||
});
|
||||
13
build/owncloud/rainloop-app/js/personal.js
Normal file
13
build/owncloud/rainloop-app/js/personal.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
RainLoopFormHelper('#mail-rainloop-personal-form', 'personal.php');
|
||||
});
|
||||
76
build/owncloud/rainloop-app/js/rainloop.js
Normal file
76
build/owncloud/rainloop-app/js/rainloop.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
function RainLoopFormHelper(sID, sAjaxFile, fCallback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var
|
||||
oForm = $(sID),
|
||||
oSubmit = $('#rainloop-save-button', oForm),
|
||||
sSubmitValue = oSubmit.val(),
|
||||
oDesc = oForm.find('.rainloop-result-desc')
|
||||
;
|
||||
|
||||
oSubmit.click(function (oEvent) {
|
||||
|
||||
var oDefAjax = null;
|
||||
|
||||
oEvent.preventDefault();
|
||||
|
||||
oForm
|
||||
.addClass('rainloop-ajax')
|
||||
.removeClass('rainloop-error')
|
||||
.removeClass('rainloop-success')
|
||||
;
|
||||
|
||||
oDesc.text('');
|
||||
oSubmit.val('...');
|
||||
|
||||
oDefAjax = $.ajax({
|
||||
'type': 'POST',
|
||||
'async': true,
|
||||
'url': OC.filePath('rainloop', 'ajax', sAjaxFile),
|
||||
'data': oForm.serialize(),
|
||||
'dataType': 'json',
|
||||
'global': true
|
||||
});
|
||||
|
||||
oDefAjax.always(function (oData) {
|
||||
|
||||
var bResult = false;
|
||||
|
||||
oForm.removeClass('rainloop-ajax');
|
||||
oSubmit.val(sSubmitValue);
|
||||
|
||||
if (oData)
|
||||
{
|
||||
bResult = 'success' === oData['status'];
|
||||
if (oData['Message'])
|
||||
{
|
||||
oDesc.text(oData['Message']);
|
||||
}
|
||||
}
|
||||
|
||||
if (bResult)
|
||||
{
|
||||
oForm.addClass('rainloop-success');
|
||||
}
|
||||
else
|
||||
{
|
||||
oForm.addClass('rainloop-error');
|
||||
if ('' === oDesc.text())
|
||||
{
|
||||
oDesc.text('Error');
|
||||
}
|
||||
}
|
||||
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback(bResult, oData);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
catch(e) {}
|
||||
}
|
||||
62
build/owncloud/rainloop-app/lib/RainLoopHelper.php
Normal file
62
build/owncloud/rainloop-app/lib/RainLoopHelper.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
class OC_RainLoop_Helper
|
||||
{
|
||||
public static function getSsoHash($sUrl, $sSsoKey, $sEmail, $sPassword, $sLogin = '')
|
||||
{
|
||||
if (!function_exists('curl_init'))
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$oCurl = curl_init();
|
||||
curl_setopt_array($oCurl, array(
|
||||
CURLOPT_URL => $sUrl.'?ExternalSso',
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_FAILONERROR => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_USERAGENT => 'RainLoop SSO User Agent (ownCloud)',
|
||||
CURLOPT_POSTFIELDS => http_build_query(array(
|
||||
'SsoKey' => $sSsoKey,
|
||||
'Email' => $sEmail,
|
||||
'Password' => $sPassword,
|
||||
'Login' => $sLogin
|
||||
), '', '&'),
|
||||
CURLOPT_TIMEOUT => 5
|
||||
));
|
||||
|
||||
$mResult = curl_exec($oCurl);
|
||||
if (is_resource($oCurl))
|
||||
{
|
||||
curl_close($oCurl);
|
||||
}
|
||||
|
||||
return is_string($mResult) ? $mResult : '';
|
||||
}
|
||||
|
||||
public static function encodePassword($sPassword, $sSalt)
|
||||
{
|
||||
if (function_exists('mcrypt_encrypt') && function_exists('mcrypt_create_iv') && function_exists('mcrypt_get_iv_size') &&
|
||||
defined('MCRYPT_RIJNDAEL_256') && defined('MCRYPT_MODE_ECB') && defined('MCRYPT_RAND'))
|
||||
{
|
||||
return @trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($sSalt), $sPassword,
|
||||
MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
|
||||
}
|
||||
|
||||
return @trim(base64_encode($sPassword));
|
||||
}
|
||||
|
||||
public static function decodePassword($sPassword, $sSalt)
|
||||
{
|
||||
if (function_exists('mcrypt_encrypt') && function_exists('mcrypt_create_iv') && function_exists('mcrypt_get_iv_size') &&
|
||||
defined('MCRYPT_RIJNDAEL_256') && defined('MCRYPT_MODE_ECB') && defined('MCRYPT_RAND'))
|
||||
{
|
||||
return @mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($sSalt), base64_decode(trim($sPassword)),
|
||||
MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND));
|
||||
}
|
||||
|
||||
return @base64_decode(trim($sPassword));
|
||||
}
|
||||
}
|
||||
39
build/owncloud/rainloop-app/personal.php
Normal file
39
build/owncloud/rainloop-app/personal.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RainLoop mail plugin
|
||||
*
|
||||
* @author RainLoop Team
|
||||
* @copyright 2014 RainLoop Team
|
||||
*
|
||||
* https://github.com/RainLoop/rainloop-webmail/tree/master/build/owncloud
|
||||
*/
|
||||
|
||||
OCP\User::checkLoggedIn();
|
||||
OCP\App::checkAppEnabled('rainloop');
|
||||
|
||||
OCP\Util::addScript('rainloop', 'personal');
|
||||
|
||||
$sUrl = trim(OCP\Config::getAppValue('rainloop', 'rainloop-url', ''));
|
||||
$sSsoKey = trim(OCP\Config::getAppValue('rainloop', 'rainloop-sso-key', ''));
|
||||
|
||||
if ('' === $sUrl || '' === $sSsoKey)
|
||||
{
|
||||
$oTemplate = new OCP\Template('rainloop', 'empty');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sUser = OCP\User::getUser();
|
||||
|
||||
$oTemplate = new OCP\Template('rainloop', 'personal');
|
||||
|
||||
$sEmail = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-email', '');
|
||||
|
||||
$oTemplate->assign('rainloop-email', $sEmail);
|
||||
$oTemplate->assign('rainloop-login', OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-login', ''));
|
||||
|
||||
$sPass = OCP\Config::getUserValue($sUser, 'rainloop', 'rainloop-password', '');
|
||||
$oTemplate->assign('rainloop-password', 0 === strlen($sPass) && 0 === strlen($sEmail) ? '' : '******');
|
||||
}
|
||||
|
||||
return $oTemplate->fetchPage();
|
||||
23
build/owncloud/rainloop-app/templates/admin.php
Normal file
23
build/owncloud/rainloop-app/templates/admin.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<form id="mail-rainloop-admin-form" action="#" method="post">
|
||||
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
|
||||
<input type="hidden" name="appname" value="rainloop">
|
||||
|
||||
<fieldset class="personalblock">
|
||||
<h2><?php p($l->t('RainLoop Webmail')); ?></h2>
|
||||
<br />
|
||||
<p>
|
||||
<?php p($l->t('RainLoop Webmail URL')); ?>:
|
||||
<br />
|
||||
<input type="text" style="width:300px;" id="rainloop-url" name="rainloop-url" value="<?php echo $_['rainloop-url']; ?>" placeholder="https://" />
|
||||
<br />
|
||||
<br />
|
||||
<?php p($l->t('SSO key')); ?>:
|
||||
<br />
|
||||
<input type="text" style="width:300px;" id="rainloop-url" name="rainloop-sso-key" value="<?php echo $_['rainloop-sso-key']; ?>" />
|
||||
<br />
|
||||
<br />
|
||||
<input type="button" id="rainloop-save-button" name="rainloop-save-button" value="<?php p($l->t('Save')); ?>" />
|
||||
<span class="rainloop-result-desc"></span>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
1
build/owncloud/rainloop-app/templates/empty.php
Normal file
1
build/owncloud/rainloop-app/templates/empty.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<!-- empty -->
|
||||
1
build/owncloud/rainloop-app/templates/index-empty.php
Normal file
1
build/owncloud/rainloop-app/templates/index-empty.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
EMPTY
|
||||
3
build/owncloud/rainloop-app/templates/index.php
Normal file
3
build/owncloud/rainloop-app/templates/index.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<div style="box-sizing: border-box; width: 100%; height: 100%; padding: 0 0 5px 5px; background-color: #383c43;">
|
||||
<iframe src="<?php echo $_['rainloop-url']; ?>" style="width: 100%; height: 100%;" tabindex="-1" frameBorder="0"></iframe>
|
||||
</div>
|
||||
18
build/owncloud/rainloop-app/templates/personal.php
Normal file
18
build/owncloud/rainloop-app/templates/personal.php
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<form id="mail-rainloop-personal-form" action="#" method="post">
|
||||
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken">
|
||||
<input type="hidden" name="appname" value="rainloop">
|
||||
|
||||
<fieldset class="personalblock">
|
||||
<h2><?php p($l->t('RainLoop Webmail')); ?></h2>
|
||||
<p>
|
||||
<input type="text" id="rainloop-email" name="rainloop-email"
|
||||
value="<?php echo $_['rainloop-email']; ?>" placeholder="<?php p($l->t('Email')); ?>" />
|
||||
|
||||
<input type="password" id="rainloop-password" name="rainloop-password"
|
||||
value="<?php echo $_['rainloop-password']; ?>" placeholder="<?php p($l->t('Password')); ?>" />
|
||||
|
||||
<input type="button" id="rainloop-save-button" name="rainloop-save-button" value="<?php p($l->t('Save')); ?>" />
|
||||
<span class="rainloop-result-desc"></span>
|
||||
</p>
|
||||
</fieldset>
|
||||
</form>
|
||||
Loading…
Add table
Add a link
Reference in a new issue