StoreRemoteMediaPlugin.php

Summary
StoreRemoteMediaPlugin.php
StoreRemoteMediaCaches remote images linked in notices
StoreRemoteMediaPluginMain StoreRemoteMedia plugin class
initalizeInitialize the plugin
onStartFileSaveNewSave embedding information for a File, if applicable.
onCreateFileImageThumbnailSourceCreate a thumbnail from remote media, adhering to applicable whitelists and blacklists.
checkBlackListCheck if a given url matches one of the domains in the blacklist if $check_blacklist is set to true, otherwise just allow any url.
checkWhiteListCheck if a given url mathes one of the domains in the whitelist if $check_whitelist is set to true, otherwise just allow any url.
onPluginVersionModify a versions array to provide the plugin version info.

StoreRemoteMedia

Caches remote images linked in notices

postActiv

the micro-blogging software

Copyright

Copyright © 2016-2017, Maiyannah Bishop

Derived from code copyright various sources

  • GNU Social © 2013-2016, Free Software Foundation, Inc
  • StatusNet © 2008-2012, StatusNet, Inc

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program.  If not, see http://www.gnu.org/licenses/.

https://www.gnu.org/licenses/agpl.html

About

Caches remote images linked in notices

PHP version

Tested with PHP 7

File Authors

Web

StoreRemoteMediaPlugin

Main StoreRemoteMedia plugin class

FIXME

  • To support remote video/whatever files, this plugin needs reworking.

Variables

  • $domain_whitelist - array of domains to allow media from
  • $append_whitelist - additional domains to allow media from
  • $check_whitelist - whether to enforce a whitelist
  • $domain_blacklist - array of domains to block media from
  • $check_blacklist - whether to enforce a blacklist
  • $max_image_bytes - maximum image size in bytes
  • $imgData - raw image data
Summary
initalizeInitialize the plugin
onStartFileSaveNewSave embedding information for a File, if applicable.
onCreateFileImageThumbnailSourceCreate a thumbnail from remote media, adhering to applicable whitelists and blacklists.
checkBlackListCheck if a given url matches one of the domains in the blacklist if $check_blacklist is set to true, otherwise just allow any url.
checkWhiteListCheck if a given url mathes one of the domains in the whitelist if $check_whitelist is set to true, otherwise just allow any url.
onPluginVersionModify a versions array to provide the plugin version info.

initalize

Initialize the plugin

onStartFileSaveNew

public function onStartFileSaveNew(File &$file)

Save embedding information for a File, if applicable.

Normally this event is called through File::saveNew()

Parameters

  • File $file - The about-to-be-inserted File object.

Returns

  • boolean success

onCreateFileImageThumbnailSource

public function onCreateFileImageThumbnailSource(File $file,  
 &$imgPath,  
 $media = null)

Create a thumbnail from remote media, adhering to applicable whitelists and blacklists.

Parameters

  • File $file - A File object
  • string $imgPath - where to save the image file
  • string $media - media type

Returns

  • boolean true on success; false otherwise

checkBlackList

protected function checkBlackList($url)

Check if a given url matches one of the domains in the blacklist if $check_blacklist is set to true, otherwise just allow any url.

Parameters

  • string $url - url to check

Returns

  • boolean true if given url passes blacklist check

checkWhiteList

protected function checkWhiteList($url)

Check if a given url mathes one of the domains in the whitelist if $check_whitelist is set to true, otherwise just allow any url.

Parameters

  • string $url - url to check

Returns

  • boolean true if given url passes whitelist check

onPluginVersion

public function onPluginVersion(array &$versions)

Modify a versions array to provide the plugin version info.

Parameters

  • array $versions - versions array to modify

Returns

  • boolean true
public function onStartFileSaveNew(File &$file)
Save embedding information for a File, if applicable.
public function onCreateFileImageThumbnailSource(File $file,  
 &$imgPath,  
 $media = null)
Create a thumbnail from remote media, adhering to applicable whitelists and blacklists.
protected function checkBlackList($url)
Check if a given url matches one of the domains in the blacklist if $check_blacklist is set to true, otherwise just allow any url.
protected function checkWhiteList($url)
Check if a given url mathes one of the domains in the whitelist if $check_whitelist is set to true, otherwise just allow any url.
public function onPluginVersion(array &$versions)
Modify a versions array to provide the plugin version info.