1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Added import from URL to Media-Manager.

This commit is contained in:
Cameron 2013-11-06 16:07:58 -08:00
parent ba192508b7
commit 4f470bde4c
2 changed files with 34 additions and 2 deletions

View File

@ -937,6 +937,8 @@ class media_admin_ui extends e_admin_ui
$mes->addDebug("For:".$cat);
$mes->addDebug("Bbcode: ".$this->getQuery('bbcode'));
if($file)
{
@ -976,12 +978,26 @@ class media_admin_ui extends e_admin_ui
function uploadPage()
{
if(!ADMIN){ exit; } //TODO check for upload-access in perms.
// if 'for' has no value, files are placed in /temp and not added to the db.
$text = '<div id="uploader" rel="'.e_JS.'plupload/upload.php?for='.$this->getQuery('for').'">
<p>No HTML5 support.</p>
</div>';
$frm = e107::getForm();
$text .= $frm->open('upload-url-form','post');
$text .= '<div class="plupload_header_content">';
$text .= "<div class='plupload_header_text form-inline' style='padding:20px'>Or upload a remote image or file ";
$text .= "<input type='text' name='upload_url' size='255' style='width:70%' placeholder='eg. http://website.com/some-image.jpg' />";
$text .= $frm->admin_button('upload_remote_url',1,'create','Start Upload');
$text .= "</div>";
$text .= "</div>";
return $text;
}
@ -1588,7 +1604,16 @@ class media_admin_ui extends e_admin_ui
$frm = e107::getForm();
$mes = e107::getMessage();
$fl = e107::getFile();
if(vartrue($_POST['upload_remote_url']))
{
if(!$fl->getRemoteFile($_POST['upload_url'], basename($_POST['upload_url']), 'import'))
{
$mes->addError("There was a problem grabbing the file");
}
}
$fl->setFileInfo('all');
$rejectArray = array('^\.ftpquota$','^index\.html$','^null\.txt$','\.bak$','^.tmp','.*\.xml$','^\.$','^\.\.$','^\/$','^CVS$','thumbs\.db','.*\._$','^\.htaccess$','index\.html','null\.txt');
$fl->setFileFilter($rejectArray);

View File

@ -318,7 +318,9 @@ class e_file
/**
* Grab a remote file and save it in the /temp directory. requires CURL
*
* @param $remote_url
* @param $local_file
* @param $type media, temp, or import
* @return boolean TRUE on success, FALSE on failure (which includes absence of CURL functions)
*/
function getRemoteFile($remote_url, $local_file, $type='temp')
@ -335,6 +337,11 @@ class e_file
$path = ($type == 'media') ? e_MEDIA : e_TEMP;
if($type == 'import')
{
$path = e_IMPORT;
}
$fp = fopen($path.$local_file, 'w'); // media-directory is the root.
$cp = curl_init($remote_url);