mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 07:57:02 +03:00
Google Drive (first look)
This commit is contained in:
parent
ba1f0403f7
commit
4d2df09946
16 changed files with 492 additions and 263 deletions
|
|
@ -626,6 +626,74 @@ class Utils
|
|||
return \trim($sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sAttrName
|
||||
* @param string $sValue = 'utf-8'
|
||||
* @param string $sCharset = ''
|
||||
* @param string $sLang = ''
|
||||
* @param int $iLen = 78
|
||||
*
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function AttributeRfc2231Encode($sAttrName, $sValue, $sCharset = 'utf-8', $sLang = '', $iLen = 1000)
|
||||
{
|
||||
$sValue = \strtoupper($sCharset).'\''.$sLang.'\''.
|
||||
\preg_replace_callback('/[\x00-\x20*\'%()<>@,;:\\\\"\/[\]?=\x80-\xFF]/', function ($match) {
|
||||
return \rawurlencode($match[0]);
|
||||
}, $sValue);
|
||||
|
||||
$iNlen = \strlen($sAttrName);
|
||||
$iVlen = \strlen($sValue);
|
||||
|
||||
if (\strlen($sAttrName) + $iVlen > $iLen - 3)
|
||||
{
|
||||
$sections = array();
|
||||
$section = 0;
|
||||
|
||||
for ($i = 0, $j = 0; $i < $iVlen; $i += $j)
|
||||
{
|
||||
$j = $iLen - $iNlen - \strlen($section) - 4;
|
||||
$sections[$section++] = \substr($sValue, $i, $j);
|
||||
}
|
||||
|
||||
for ($i = 0, $n = $section; $i < $n; $i++)
|
||||
{
|
||||
$sections[$i] = ' '.$sAttrName.'*'.$i.'*='.$sections[$i];
|
||||
}
|
||||
|
||||
return \implode(";\r\n", $sections);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $sAttrName.'*='.$sValue;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string $sAttrName
|
||||
* @param string $sValue
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function EncodeHeaderUtf8AttributeValue($sAttrName, $sValue)
|
||||
{
|
||||
$sAttrName = \trim($sAttrName);
|
||||
$sValue = \trim($sValue);
|
||||
|
||||
if (0 < \strlen($sValue) && !\MailSo\Base\Utils::IsAscii($sValue))
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_USER_AGENT']) && 0 < \strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
|
||||
{
|
||||
$sValue = $sAttrName.'="'.\preg_replace('/[+\s]+/', '%20', \urlencode($sValue)).'"';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sValue = \MailSo\Base\Utils::AttributeRfc2231Encode($sAttrName, $sValue);
|
||||
}
|
||||
}
|
||||
|
||||
return \trim($sValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
*
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ class Message
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $iDateTime $iDateTime
|
||||
* @param int $iDateTime
|
||||
*
|
||||
* @return \MailSo\Mime\Message
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1129,10 +1129,14 @@ class Actions
|
|||
}
|
||||
|
||||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||
$aResult['GoogleClientID'] = \trim($oConfig->Get('social', 'google_client_id', ''));
|
||||
$aResult['GoogleApiKey'] = \trim($oConfig->Get('social', 'google_api_key', ''));
|
||||
if ($aResult['AllowGoogleSocial'] && (
|
||||
'' === \trim($oConfig->Get('social', 'google_client_id', '')) || '' === \trim($oConfig->Get('social', 'google_client_secret', ''))))
|
||||
{
|
||||
$aResult['AllowGoogleSocial'] = false;
|
||||
$aResult['GoogleClientID'] = '';
|
||||
$aResult['GoogleApiKey'] = '';
|
||||
}
|
||||
|
||||
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
||||
|
|
@ -1189,6 +1193,7 @@ class Actions
|
|||
$aResult['AllowGoogleSocial'] = (bool) $oConfig->Get('social', 'google_enable', false);
|
||||
$aResult['GoogleClientID'] = (string) $oConfig->Get('social', 'google_client_id', '');
|
||||
$aResult['GoogleClientSecret'] = (string) $oConfig->Get('social', 'google_client_secret', '');
|
||||
$aResult['GoogleApiKey'] = (string) $oConfig->Get('social', 'google_api_key', '');
|
||||
|
||||
$aResult['AllowFacebookSocial'] = (bool) $oConfig->Get('social', 'fb_enable', false);
|
||||
$aResult['FacebookAppID'] = (string) $oConfig->Get('social', 'fb_app_id', '');
|
||||
|
|
@ -2394,6 +2399,7 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, 'GoogleEnable', 'social', 'google_enable', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'GoogleClientID', 'social', 'google_client_id', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'GoogleClientSecret', 'social', 'google_client_secret', 'string');
|
||||
$this->setConfigFromParams($oConfig, 'GoogleApiKey', 'social', 'google_api_key', 'string');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'FacebookEnable', 'social', 'fb_enable', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'FacebookAppID', 'social', 'fb_app_id', 'string');
|
||||
|
|
@ -6389,7 +6395,7 @@ class Actions
|
|||
$self = $this;
|
||||
return $this->MailClient()->MessageMimeStream(
|
||||
function($rResource, $sContentType, $sFileName, $sMimeIndex = '') use ($self, $sRawKey, $sContentTypeIn, $sFileNameIn, $bDownload) {
|
||||
if (is_resource($rResource))
|
||||
if (\is_resource($rResource))
|
||||
{
|
||||
$sContentTypeOut = $sContentTypeIn;
|
||||
if (empty($sContentTypeOut))
|
||||
|
|
@ -6409,10 +6415,12 @@ class Actions
|
|||
|
||||
$sFileNameOut = $self->MainClearFileName($sFileNameOut, $sContentTypeOut, $sMimeIndex);
|
||||
|
||||
header('Content-Type: '.$sContentTypeOut);
|
||||
header('Content-Disposition: '.($bDownload ? 'attachment' : 'inline').'; filename="'.$sFileNameOut.'"; charset=utf-8', true);
|
||||
header('Accept-Ranges: none', true);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
\header('Content-Type: '.$sContentTypeOut);
|
||||
\header('Content-Disposition: '.($bDownload ? 'attachment' : 'inline').'; '.
|
||||
\trim(\MailSo\Base\Utils::EncodeHeaderUtf8AttributeValue('filename', $sFileNameOut)), true);
|
||||
|
||||
\header('Accept-Ranges: none', true);
|
||||
\header('Content-Transfer-Encoding: binary');
|
||||
|
||||
$self->cacheByKey($sRawKey);
|
||||
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ Examples:
|
|||
'google_enable' => array(false, 'Google'),
|
||||
'google_client_id' => array(''),
|
||||
'google_client_secret' => array(''),
|
||||
'google_api_key' => array(''),
|
||||
|
||||
'fb_enable' => array(false, 'Facebook'),
|
||||
'fb_app_id' => array(''),
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
Client ID
|
||||
</label>
|
||||
<label class="control-label">
|
||||
Client ID
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: googleClientID, saveTrigger: googleTrigger1" />
|
||||
|
|
@ -28,15 +28,25 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
Client Secret
|
||||
</label>
|
||||
<label class="control-label">
|
||||
Client Secret
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: googleClientSecret, saveTrigger: googleTrigger2" />
|
||||
<div data-bind="saveTrigger: googleTrigger2"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
Client Api Key
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: googleApiKey, saveTrigger: googleTrigger3" />
|
||||
<div data-bind="saveTrigger: googleTrigger3"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="legend">
|
||||
Facebook
|
||||
<span style="color: #ccc; font-size: 14px;" data-bind="visible: !facebookSupported()">(requires PHP 5.4 or greater)</span>
|
||||
|
|
@ -51,9 +61,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
App ID
|
||||
</label>
|
||||
<label class="control-label">
|
||||
App ID
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: facebookAppID, saveTrigger: facebookTrigger1" />
|
||||
|
|
@ -61,9 +71,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
App Secret
|
||||
</label>
|
||||
<label class="control-label">
|
||||
App Secret
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: facebookAppSecret, saveTrigger: facebookTrigger2" />
|
||||
|
|
@ -83,9 +93,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
Consumer Key
|
||||
</label>
|
||||
<label class="control-label">
|
||||
Consumer Key
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: twitterConsumerKey, saveTrigger: twitterTrigger1" />
|
||||
|
|
@ -93,9 +103,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
Consumer Secret
|
||||
</label>
|
||||
<label class="control-label">
|
||||
Consumer Secret
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: twitterConsumerSecret, saveTrigger: twitterTrigger2" />
|
||||
|
|
@ -114,9 +124,9 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
Api Key
|
||||
</label>
|
||||
<label class="control-label">
|
||||
Api Key
|
||||
</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="span5" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="value: dropboxApiKey, saveTrigger: dropboxTrigger1" />
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@
|
|||
<a class="btn" data-tooltip-placement="top" data-bind="visible: dropboxEnabled, command: dropboxCommand, tooltip: 'COMPOSE/DROPBOX'">
|
||||
<i class="icon-dropbox"></i>
|
||||
</a>
|
||||
<a class="btn" data-tooltip-placement="top" data-bind="visible: driveEnabled, command: driveCommand, tooltip: 'COMPOSE/GOOGLE_DRIVE'">
|
||||
<a class="btn" data-tooltip-placement="top" data-bind="visible: driveEnabled() && driveVisible(), command: driveCommand, tooltip: 'COMPOSE/GOOGLE_DRIVE'">
|
||||
<i class="icon-google-drive"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue