Merge branch 'dev' of https://framagit.org/hubzilla/core into xdev_merge
This commit is contained in:
@@ -618,8 +618,6 @@ function get_item_elements($x,$allow_code = false) {
|
||||
$arr['created'] = datetime_convert('UTC','UTC',$x['created']);
|
||||
$arr['edited'] = datetime_convert('UTC','UTC',$x['edited']);
|
||||
|
||||
if($arr['created'] > datetime_convert())
|
||||
$arr['created'] = datetime_convert();
|
||||
if($arr['edited'] > datetime_convert())
|
||||
$arr['edited'] = datetime_convert();
|
||||
|
||||
|
||||
@@ -221,7 +221,11 @@ function oembed_fetch_url($embedurl){
|
||||
|
||||
if(strpos(strtolower($embedurl),'.pdf') !== false) {
|
||||
$action = 'allow';
|
||||
$j = [ 'html' => '<object data="' . $embedurl . '" type="application/pdf" width="500" height="720">' . '<a href="' . $embedurl . '">' . t('View PDF') . '</a></object>', 'width' => 500, 'height' => 720, 'type' => 'pdf' ];
|
||||
$j = [
|
||||
'html' => '<object data="' . $embedurl . '" type="application/pdf" style="width: 100%; height: 300px;"></object>',
|
||||
'title' => t('View PDF'),
|
||||
'type' => 'pdf'
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ abstract class photo_driver {
|
||||
public function saveImage($path) {
|
||||
if(!$this->is_valid())
|
||||
return FALSE;
|
||||
file_put_contents($path, $this->imageString());
|
||||
return (file_put_contents($path, $this->imageString()) ? true : false);
|
||||
}
|
||||
|
||||
|
||||
@@ -330,9 +330,9 @@ abstract class photo_driver {
|
||||
}
|
||||
|
||||
|
||||
public function save($arr) {
|
||||
public function save($arr, $skipcheck = false) {
|
||||
|
||||
if(! $this->is_valid()) {
|
||||
if(! ($skipcheck || $this->is_valid())) {
|
||||
logger('attempt to store invalid photo.');
|
||||
return false;
|
||||
}
|
||||
@@ -344,6 +344,7 @@ abstract class photo_driver {
|
||||
$p['xchan'] = (($arr['xchan']) ? $arr['xchan'] : '');
|
||||
$p['resource_id'] = (($arr['resource_id']) ? $arr['resource_id'] : '');
|
||||
$p['filename'] = (($arr['filename']) ? $arr['filename'] : '');
|
||||
$p['mimetype'] = (($arr['mimetype']) ? $arr['mimetype'] : $this->getType());
|
||||
$p['album'] = (($arr['album']) ? $arr['album'] : '');
|
||||
$p['imgscale'] = ((intval($arr['imgscale'])) ? intval($arr['imgscale']) : 0);
|
||||
$p['allow_cid'] = (($arr['allow_cid']) ? $arr['allow_cid'] : '');
|
||||
@@ -360,6 +361,7 @@ abstract class photo_driver {
|
||||
$p['display_path'] = (($arr['display_path']) ? $arr['display_path'] : '');
|
||||
$p['width'] = (($arr['width']) ? $arr['width'] : $this->getWidth());
|
||||
$p['height'] = (($arr['height']) ? $arr['height'] : $this->getHeight());
|
||||
$p['expires'] = (($arr['expires']) ? $arr['expires'] : gmdate('Y-m-d H:i:s', time() + get_config('system','photo_cache_time', 86400)));
|
||||
|
||||
if(! intval($p['imgscale']))
|
||||
logger('save: ' . print_r($arr,true), LOGGER_DATA);
|
||||
@@ -397,23 +399,24 @@ abstract class photo_driver {
|
||||
allow_cid = '%s',
|
||||
allow_gid = '%s',
|
||||
deny_cid = '%s',
|
||||
deny_gid = '%s'
|
||||
deny_gid = '%s',
|
||||
expires = '%s'
|
||||
where id = %d",
|
||||
|
||||
intval($p['aid']),
|
||||
intval($p['uid']),
|
||||
dbesc($p['xchan']),
|
||||
dbesc($p['resource_id']),
|
||||
dbesc($p['created']),
|
||||
dbesc($p['edited']),
|
||||
dbescdate($p['created']),
|
||||
dbescdate($p['edited']),
|
||||
dbesc(basename($p['filename'])),
|
||||
dbesc($this->getType()),
|
||||
dbesc($p['mimetype']),
|
||||
dbesc($p['album']),
|
||||
intval($p['height']),
|
||||
intval($p['width']),
|
||||
(intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())),
|
||||
intval($p['os_storage']),
|
||||
intval(strlen($this->imageString())),
|
||||
(intval($p['os_storage']) ? @filesize($p['os_syspath']) : strlen($this->imageString())),
|
||||
intval($p['imgscale']),
|
||||
intval($p['photo_usage']),
|
||||
dbesc($p['title']),
|
||||
@@ -424,28 +427,29 @@ abstract class photo_driver {
|
||||
dbesc($p['allow_gid']),
|
||||
dbesc($p['deny_cid']),
|
||||
dbesc($p['deny_gid']),
|
||||
dbescdate($p['expires']),
|
||||
intval($x[0]['id'])
|
||||
);
|
||||
}
|
||||
else {
|
||||
$p['created'] = (($arr['created']) ? $arr['created'] : $p['edited']);
|
||||
$r = q("INSERT INTO photo
|
||||
( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, os_storage, filesize, imgscale, photo_usage, title, description, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid )
|
||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
|
||||
( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, os_storage, filesize, imgscale, photo_usage, title, description, os_path, display_path, allow_cid, allow_gid, deny_cid, deny_gid, expires )
|
||||
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
|
||||
intval($p['aid']),
|
||||
intval($p['uid']),
|
||||
dbesc($p['xchan']),
|
||||
dbesc($p['resource_id']),
|
||||
dbesc($p['created']),
|
||||
dbesc($p['edited']),
|
||||
dbescdate($p['created']),
|
||||
dbescdate($p['edited']),
|
||||
dbesc(basename($p['filename'])),
|
||||
dbesc($this->getType()),
|
||||
dbesc($p['mimetype']),
|
||||
dbesc($p['album']),
|
||||
intval($p['height']),
|
||||
intval($p['width']),
|
||||
(intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())),
|
||||
intval($p['os_storage']),
|
||||
intval(strlen($this->imageString())),
|
||||
(intval($p['os_storage']) ? @filesize($p['os_syspath']) : strlen($this->imageString())),
|
||||
intval($p['imgscale']),
|
||||
intval($p['photo_usage']),
|
||||
dbesc($p['title']),
|
||||
@@ -455,7 +459,8 @@ abstract class photo_driver {
|
||||
dbesc($p['allow_cid']),
|
||||
dbesc($p['allow_gid']),
|
||||
dbesc($p['deny_cid']),
|
||||
dbesc($p['deny_gid'])
|
||||
dbesc($p['deny_gid']),
|
||||
dbescdate($p['expires'])
|
||||
);
|
||||
}
|
||||
logger('photo save ' . $p['imgscale'] . ' returned ' . intval($r));
|
||||
|
||||
@@ -31,8 +31,12 @@ class photo_imagick extends photo_driver {
|
||||
if(! $data)
|
||||
return;
|
||||
|
||||
$this->image->readImageBlob($data);
|
||||
|
||||
try {
|
||||
$this->image->readImageBlob($data);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
logger('imagick readImageBlob() exception:' . print_r($e,true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the image to the format it will be saved to
|
||||
@@ -205,4 +209,4 @@ class photo_imagick extends photo_driver {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1105,23 +1105,33 @@ function linkify($s, $me = false) {
|
||||
* to a local redirector which uses https and which redirects to the selected content
|
||||
*
|
||||
* @param string $s
|
||||
* @param int $uid
|
||||
* @returns string
|
||||
*/
|
||||
function sslify($s) {
|
||||
|
||||
// Local photo cache
|
||||
$str = array(
|
||||
'body' => $s,
|
||||
'uid' => local_channel()
|
||||
);
|
||||
call_hooks('cache_body_hook', $str);
|
||||
|
||||
$s = $str['body'];
|
||||
|
||||
if (strpos(z_root(),'https:') === false)
|
||||
return $s;
|
||||
|
||||
|
||||
// By default we'll only sslify img tags because media files will probably choke.
|
||||
// You can set sslify_everything if you want - but it will likely white-screen if it hits your php memory limit.
|
||||
// The downside is that http: media files will likely be blocked by your browser
|
||||
// Complain to your browser maker
|
||||
|
||||
$allow = get_config('system','sslify_everything');
|
||||
|
||||
$pattern = (($allow) ? "/\<(.*?)src=\"(http\:.*?)\"(.*?)\>/" : "/\<img(.*?)src=\"(http\:.*?)\"(.*?)\>/" );
|
||||
$pattern = (($allow) ? "/\<(.*?)src=[\"|'](http\:.*?)[\"|'](.*?)\>/" : "/\<img(.*?)src=[\"|'](http\:.*?)[\"|'](.*?)\>/" );
|
||||
|
||||
$matches = null;
|
||||
$cnt = preg_match_all($pattern,$s,$matches,PREG_SET_ORDER);
|
||||
$cnt = preg_match_all($pattern, $s, $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $match) {
|
||||
$filename = basename( parse_url($match[2], PHP_URL_PATH) );
|
||||
@@ -3295,7 +3305,7 @@ function cleanup_bbcode($body) {
|
||||
|
||||
$body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body);
|
||||
|
||||
$body = scale_external_images($body,false);
|
||||
$body = scale_external_images($body, false);
|
||||
|
||||
return $body;
|
||||
}
|
||||
@@ -3411,7 +3421,7 @@ function get_forum_channels($uid) {
|
||||
|
||||
$sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 ");
|
||||
|
||||
$r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra order by xchan_name",
|
||||
$r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_addr, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra order by xchan_name",
|
||||
intval($uid)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user