mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-05 15:37:03 +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(''),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue