Тема: File2mail
Показать сообщение отдельно

  #14  
Старый 12.05.2006, 10:40
grinay
IQ- 137%
Регистрация: 15.06.2004
Сообщений: 441
Провел на форуме:
1212666

Репутация: 662
Отправить сообщение для grinay с помощью ICQ
По умолчанию

Модификация скрипта для скачки файлов без обсолютного пути(тестил только на одной ссылке)
вроде вот таких ссылок http://portal.idknet.com/modules/myd...lid=637&numb=1

PHP код:
<?php
$smtp_server
="192.168.1.197";
set_time_limit(0);
@
ini_set(SMTP,$smtp_server);

function 
get_this($file,$to,$from){
$fp=fopen($file,"rb");
$meta_data=stream_get_meta_data($fp);
foreach(
$meta_data['wrapper_data'] as $response) {
if (
substr(strtolower($response), 021) == 'content-disposition: ') {
$str=substr($response21);
preg_match("/^(attachment; filename=\")?([^\"]+)/i",$str,$por);
}
if (
substr(strtolower($response), 010) == 'location: ') {
$file=substr($response10);}}
if(
$por[2]!=""){
  
$subj="sub";
  
$bound="get_this";
  
$headers="From: \"$from\" <$from>\n";
  
$headers.="To: $to\n";
  
$headers.="Subject: $subj\n";
  
$headers.="Mime-Version: 1.0\n";
  
$headers.="Content-Type: multipart/alternative; boundary=\"$bound\"\n";
  
$body="--$bound\n";
  
$body.="Content-type: text/html; charset=\"windows-1251\"\n";
  
$body.="Content-Transfer-Encoding: 8bit\n\n";
  
$body.="File ".$por[2]." transfer ok";
  
$body.="\n\n--$bound\n";
  
$body.="Content-Type: application/octet-stream; name=\"".$por[2]."\"\n";
  
$body.="Content-Transfer-Encoding:base64\n";
  
$body.="Content-Disposition: attachment; filename=\"".$por[2]."\"\n\n";
  
$body.=base64_encode(file_get_contents($file))."\n";
  
$body.="--$bound--\n\n";
  
mail($to$subj$body$headers);
}
else{
  if(
strpos($file,"http://")!==false)$file=$file;
  else{
$file="http://".$file;}
  
$subj="sub";
  
$bound="get_this";
  
$headers="From: \"$from\" <$from>\n";
  
$headers.="To: $to\n";
  
$headers.="Subject: $subj\n";
  
$headers.="Mime-Version: 1.0\n";
  
$headers.="Content-Type: multipart/alternative; boundary=\"$bound\"\n";
  
$body="--$bound\n";
  
$body.="Content-type: text/html; charset=\"windows-1251\"\n";
  
$body.="Content-Transfer-Encoding: 8bit\n\n";
  
$body.="File ".basename($file)." transfer ok";
  
$body.="\n\n--$bound\n";
  
$body.="Content-Type: application/octet-stream; name=\"".basename($file)."\"\n";
  
$body.="Content-Transfer-Encoding:base64\n";
  
$body.="Content-Disposition: attachment; filename=\"".basename($file)."\"\n\n";
  
copy($file,basename($file));
  
$f=fopen(basename($file),"rb");
  
$body.=base64_encode(fread($f,filesize(basename($file))))."\n";
  
$body.="--$bound--\n\n";
  
fclose($f);
  
mail($to$subj$body$headers);
  
unlink(basename($file));
}}
if(
$_POST['file']!=""){
get_this($_POST['file'],"grinay@mail.ru","grinay@antichat.ru");
}
echo 
"<form method=POST><input type=text name=file><input type=submit></form>";
?>

Последний раз редактировалось grinay; 12.05.2006 в 10:48.. Причина: добавил location
 
Ответить с цитированием