mirror of
https://github.com/friendica/friendica
synced 2025-04-22 19:50:11 +00:00
several fixes for attachments
This commit is contained in:
parent
d0b7723bbc
commit
ad1e827169
6 changed files with 24 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
if(!function_exists('mime_content_type')) {
|
||||
function mime_content_type($filename) {
|
||||
|
||||
function z_mime_content_type($filename) {
|
||||
|
||||
$mime_types = array(
|
||||
|
||||
|
@ -61,8 +61,9 @@ function mime_content_type($filename) {
|
|||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
);
|
||||
|
||||
if(strpos($filename,'.') !== false) {
|
||||
$ext = strtolower(array_pop(explode('.',$filename)));
|
||||
$dot = strpos($filename,'.');
|
||||
if($dot !== false) {
|
||||
$ext = strtolower(substr($filename,$dot+1));
|
||||
if (array_key_exists($ext, $mime_types)) {
|
||||
return $mime_types[$ext];
|
||||
}
|
||||
|
@ -76,5 +77,5 @@ function mime_content_type($filename) {
|
|||
else {
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ function get_atom_elements($feed,$item) {
|
|||
if(! $type)
|
||||
$type = 'application/octet-stream';
|
||||
|
||||
$att_arr[] = '[attach]href="' . $link . '" size="' . $len . '" type="' . $type . '" title="' . $title . '"[/attach]';
|
||||
$att_arr[] = '[attach]href="' . $link . '" length="' . $len . '" type="' . $type . '" title="' . $title . '"[/attach]';
|
||||
}
|
||||
$res['attach'] = implode(',', $att_arr);
|
||||
}
|
||||
|
@ -1725,11 +1725,11 @@ function item_getfeedattach($item) {
|
|||
if(count($arr)) {
|
||||
foreach($arr as $r) {
|
||||
$matches = false;
|
||||
$cnt = preg_match('|\[attach\]href=\"(.*?)\" size=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
|
||||
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
|
||||
if($cnt) {
|
||||
$ret .= '<link rel="enclosure" href="' . xmlify($matches[1]) . '" type="' . xmlify($matches[3]) . '" ';
|
||||
if(intval($matches[2]))
|
||||
$ret .= 'size="' . intval($matches[2]) . '" ';
|
||||
$ret .= 'length="' . intval($matches[2]) . '" ';
|
||||
if($matches[4] !== ' ')
|
||||
$ret .= 'title="' . xmlify(trim($matches[4])) . '" ';
|
||||
$ret .= ' />' . "\r\n";
|
||||
|
|
|
@ -746,7 +746,7 @@ function prepare_body($item,$attach = false) {
|
|||
foreach($arr as $r) {
|
||||
$matches = false;
|
||||
$icon = '';
|
||||
$cnt = preg_match('|\[attach\]href=\"(.*?)\" size=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
|
||||
$cnt = preg_match('|\[attach\]href=\"(.*?)\" length=\"(.*?)\" type=\"(.*?)\" title=\"(.*?)\"\[\/attach\]|',$r,$matches);
|
||||
if($cnt) {
|
||||
$icontype = strtolower(substr($matches[3],0,strpos($matches[3],'/')));
|
||||
switch($icontype) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue