mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-17 10:19:55 +09:00
git-svn-id: http://xe-core.googlecode.com/svn/trunk@1448 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
bf509404b4
commit
43de485436
2 changed files with 38 additions and 8 deletions
|
|
@ -125,6 +125,35 @@
|
|||
return sprintf("%0.2fMB",$size / (1024*1024));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 원격파일을 다운받아서 특정 위치에 저장
|
||||
**/
|
||||
function getRemoteFile($url, $target_filename) {
|
||||
$url_info = parse_url($url);
|
||||
|
||||
if(!$url_info['port']) $url_info['port'] = 80;
|
||||
|
||||
$fp = fsockopen($url_info['host'], $url_info['port']);
|
||||
if(!$fp) return;
|
||||
|
||||
$header = sprintf("GET %s HTTP/1.0\r\nHost: %s\r\nReferer: %s://%s\r\n\r\n", $url_info['path'], $url_info['host'], $url_info['scheme'], $url_info['host']);
|
||||
fwrite($fp, $header);
|
||||
|
||||
$ft = fopen($target_filename, 'w');
|
||||
if(!$ft) return;
|
||||
|
||||
$begin = false;
|
||||
while(!feof($fp)) {
|
||||
$str = fgets($fp, 1024);
|
||||
if($begin) fwrite($ft, $str);
|
||||
if(!trim($str)) $begin = true;
|
||||
}
|
||||
fclose($ft);
|
||||
fclose($fp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 특정 이미지 파일을 특정 위치로 옮김 (옮길때 이미지의 크기를 리사이징할 수 있음..)
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -237,16 +237,17 @@
|
|||
if($files && !is_array($files)) $files = array($files);
|
||||
if(count($files)) {
|
||||
foreach($files as $key => $val) {
|
||||
$filename = $val->attrs->name;
|
||||
$downloaded_count = (int)$val->downloaded_count->body;
|
||||
$file_buff = base64_decode($val->buff->body);
|
||||
$filename = $val->filename->body;
|
||||
$url = $val->url->body;
|
||||
$download_count = (int)$val->download_count->body;
|
||||
|
||||
$tmp_filename = './files/cache/tmp_uploaded_file';
|
||||
FileHandler::writeFile($tmp_filename, $file_buff);
|
||||
|
||||
$file_info['tmp_name'] = $tmp_filename;
|
||||
$file_info['name'] = $filename;
|
||||
$this->oFileController->insertFile($file_info, $this->module_srl, $args->document_srl, $downloaded_count);
|
||||
if(FileHandler::getRemoteFile($url, $tmp_filename)) {
|
||||
$file_info['tmp_name'] = $tmp_filename;
|
||||
$file_info['name'] = $filename;
|
||||
$this->oFileController->insertFile($file_info, $this->module_srl, $args->document_srl, $download_count);
|
||||
}
|
||||
@unlink($tmp_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue