<?php
require_once"../template/start.php";
require_once"../template/regglobals.php";
require_once"../template/config.php";
require_once"setforum.php";
require_once"../template/functions.php";
require_once"../template/antidos.php";
require_once"../template/cookies.php";
require_once"../template/gzip.php";
require_once"../template/header.php";
require_once"../template/referer.php";
require_once"dopmail.php";
include_once"../themes/$config_themes/index.php";
//----Настройки----//
/*
//---Старые настройки----//
$m_file="600";
$f_mail="on";
$mail_uz="on";
$f_temp="5";
*/
$m_file = $config_mail_file; //Максимальный размер файла к отправке на E-mail (Kb)
$f_mail = $config_mail_file_on; //on - Включить отправку файлов на E-mail, off - выключить
$mail_uz = $config_mail_file_uz; //on - отправка файлов на E-mail из анкеты юзера, off - любой
$f_temp = $config_mail_file_time; //Время жизни временных файлов (мин.)
extract($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
$text = file("../local/profil/$log.prof");
if ($text!=""){
$udata = explode(":||:",$text[0]);
$provlog=trim($udata[0]);
$provpar=trim($udata[1]);
$privat=trim($udata[10]);
$uz_mail=trim($udata[4]);}
/////////////////////////////удаление временных файлов/////////////////////////////////
$odir = opendir("../local/tmpforum");
while ($files = readdir($odir)){
if (($files!==".")&&($files!=="..")){
$ftime = filectime("../local/tmpforum/$files");
$ttime = time();
if ($ttime >= $ftime+$f_temp*60){
unlink("../local/tmpforum/$files");
}}}
closedir($odir);
///////////////////////////////////////////////////////////////////////////////////////////
if($f_mail=='on'){
/////////////////////////////
$did=str_replace("../","",$did);
$did=str_replace("./","",$did);
$did=str_replace("..","",$did);
$did=str_replace(".","",$did);
if (is_dir("$did")==false or is_file("$did/$fid")==false){
echo "<center><font color=\"red\">ДАННЫЙ СЕРВИС В РАЗРАБОТКЕ</font></center><br /><br />";
echo'<br><img src="../images/imgfor/barrow.gif" alt=""> <a href="attache.php?'.SID.'">К категориям</a><br>';
echo '<img src="../images/img/barrow.gif" alt=""> <a href="index.php?'.SID.'">На форум</a><br>';echo'<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
include_once"../themes/$config_themes/foot.php";
exit;}
/////////////////////////////
echo '<img src="../images/img/mails.gif" alt=""> <b>Отправка файла на E-mail</b><br><br>';
if($config_forum_off=="1"){
if ($provlog==$_SESSION['log'] && $provpar==md5($_SESSION['par']) && $_SESSION['log']!="" && md5($_SESSION['par'])!=""){
if($config_file_post=="1"){
if($udata[36]>$config_file_usball){
$Host=preg_replace('/:\d+/s','',getenv('HTTP_HOST'));
$user = $brow;
$file="$did/$fid";
$maxfile=$m_file*1024;
while($file[0]=='/')
$sd=substr($file,1,strlen($file));
$dirname=dirname($file);
$basename=basename($file);
$filesize=@filesize($file);
if($filesize>1024)
$filesize=round($filesize/1024,2).' Кб';
else
$filesize=$filesize.' бт';
if(!strstr($dirname,"..") and file_exists($file) and filesize($file)<=$maxfile)
{
echo'<img src="../images/img/dir.gif" alt=""> ';
print "Папка: $did<br/>";
echo'<img src="../images/img/files2.gif" alt=""> ';
print "Файл: $fid<br/>";
print "Размер: $filesize<br/>";
class Mail
{
var $sendto = array();
var $acc = array();
var $abcc = array();
var $aattach = array();
var $xheaders = array();
var $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
var $charset = "utf-8";
var $ctencoding = "7bit";
var $receipt = 0;
function Mail()
{
$this->autoCheck( true );
$this->boundary= "--" . md5( uniqid("myboundary") );
}
function autoCheck( $bool )
{
if( $bool )
$this->checkAddress = true;
else
$this->checkAddress = false;
}
function Subject( $subject )
{
$this->xheaders['Subject'] = strtr( $subject, "\r\n" , " " );
}
function From( $from )
{
if( ! is_string($from) ) {
echo "Class Mail: error, From is not a string";
exit;
}
$this->xheaders['From'] = $from;
}
function ReplyTo( $address )
{
if( ! is_string($address) )
return false;
$this->xheaders["Reply-To"] = $address;
}
function Receipt()
{
$this->receipt = 1;
}
function To( $to )
{
if( is_array( $to ) )
$this->sendto= $to;
else
$this->sendto[] = $to;
if( $this->checkAddress == true )
$this->CheckAdresses( $this->sendto );
}
function Cc( $cc )
{
if( is_array($cc) )
$this->acc= $cc;
else
$this->acc[]= $cc;
if( $this->checkAddress == true )
$this->CheckAdresses( $this->acc );
}
function Bcc( $bcc )
{
if( is_array($bcc) ) {
$this->abcc = $bcc;
} else {
$this->abcc[]= $bcc;
}
if( $this->checkAddress == true )
$this->CheckAdresses( $this->abcc );
}
function Body( $body, $charset="" )
{
$this->body = $body;
if( $charset != "" ) {
$this->charset = strtolower($charset);
if( $this->charset != "us-ascii" )
$this->ctencoding = "8bit";
}
}
function Organization( $org )
{
if( trim( $org != "" ) )
$this->xheaders['Organization'] = $org;
}
function Priority( $priority )
{
if( ! intval( $priority ) )
return false;
if( ! isset( $this->priorities[$priority-1]) )
return false;
$this->xheaders["X-Priority"] = $this->priorities[$priority-1];
return true;
}
function Attach( $filename, $filetype = "", $disposition = "inline" )
{
if( $filetype == "" )
$filetype = "application/x-unknown-content-type";
$this->aattach[] = $filename;
$this->actype[] = $filetype;
$this->adispo[] = $disposition;
}
function BuildMail()
{
$this->headers = "";
if( count($this->acc) > 0 )
$this->xheaders['CC'] = implode( ", ", $this->acc );
if( count($this->abcc) > 0 )
$this->xheaders['BCC'] = implode( ", ", $this->abcc );
if( $this->receipt ) {
if( isset($this->xheaders["Reply-To"] ) )
$this->xheaders["Disposition-Notification-To"] = $this->xheaders["Reply-To"];
else
$this->xheaders["Disposition-Notification-To"] = $this->xheaders['From'];
}
if( $this->charset != "" ) {
$this->xheaders["Mime-Version"] = "1.0";
$this->xheaders["Content-Type"] = "text/plain; charset=$this->charset";
$this->xheaders["Content-Transfer-Encoding"] = $this->ctencoding;
}
$this->xheaders["X-Mailer"] = "Php/libMailv1.3";
if( count( $this->aattach ) > 0 ) {
$this->_build_attachement();
} else {
$this->fullBody = $this->body;
}
reset($this->xheaders);
while( list( $hdr,$value ) = each( $this->xheaders ) ) {
if( $hdr != "Subject" )
$this->headers .= "$hdr: $value\n";
}
}
function Send()
{
$this->BuildMail();
$this->strTo = implode( ", ", $this->sendto );
$res = @mail( $this->strTo, $this->xheaders['Subject'], $this->fullBody, $this->headers );
}
function Get()
{
$this->BuildMail();
$mail = "To: " . $this->strTo . "\n";
$mail .= $this->headers . "\n";
$mail .= $this->fullBody;
return $mail;
}
function ValidEmail($address)
{
if( ereg( ".*<(.+)>", $address, $regs ) ) {
$address = $regs[1];
}
if(ereg( "^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int|ru|ua|eu)\$",$address) )
return true;
else
return false;
}
function CheckAdresses( $aad )
{
for($i=0;$i< count( $aad); $i++ ) {
if( ! $this->ValidEmail( $aad[$i]) ) {
echo "Class Mail, method Mail : invalid address $aad[$i]";
exit;
}
}
}
function _build_attachement()
{
$this->xheaders["Content-Type"] = "multipart/mixed;\n boundary=\"$this->boundary\"";
$this->fullBody = "This is a multi-part message in MIME format.\n--$this->boundary\n";
$this->fullBody .= "Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" . $this->body ."\n";
$sep= chr(13) . chr(10);
$ata= array();
$k=0;
for( $i=0; $i < count( $this->aattach); $i++ ) {
$filename = $this->aattach[$i];
$basename = basename($filename);
$ctype = $this->actype[$i]; // content-type
$disposition = $this->adispo[$i];
if( ! file_exists( $filename) ) {
echo "Class Mail, method attach : file $filename can't be found"; exit;
}
$subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n filename=\"$basename\"\n";
$ata[$k++] = $subhdr;
$linesz= filesize( $filename)+1;
$fp= fopen( $filename, 'r' );
$ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
fclose($fp);
}
$this->fullBody .= implode($sep, $ata);
}
} //class mail
if(!$act)
{
print "
<br/><form action=\"mail.php?act=nar&did=$did&fid=$fid\" method=\"post\">
E-mail: ";
if ($mail_uz=="off"){
echo $uz_mail.'<br>';
$mail = $uz_mail;
}else{
print "<br/><input name=\"mail\" maxlength=\"25\" value=\"\" size=16 /><br/>";}
print "Комментарий:<br/>
<textarea name=\"komm\" maxlength=\"450\" rows=5 cols=20></textarea><br/>
<input type=\"submit\" name=\"a\" value=\"Отправить\"/>
</form>";
}
else
{
$dir = opendir("$did");
while ($filess = readdir($dir)){
if ($filess==$provlog.'.txt'){
echo "<br><font color='red'>Ошибка!!! Вы не можете отправлять файл чаше чем раз в ".$f_temp." минут.</font><br>";
echo'<br><img src="../images/img/back.gif" alt=""> <a href="down.php?action=ob&did='.$did.'&fid='.$fid.'&'.SID.'">К файлу</a>';
echo'<br><img src="../images/imgfor/barrow.gif" alt=""> <a href="attache.php?'.SID.'">К категориям</a><br>';
echo '<img src="../images/img/barrow.gif" alt=""> <a href="index.php?'.SID.'">На форум</a><br>';echo'<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
include_once"../themes/$config_themes/foot.php";
exit;}
}
if ($mail_uz=="off"){$mail = $uz_mail;}
$err='';
if(0==preg_match("/^[0-9a-z\-._]+@[0-9a-z_\-.]+\.[a-z]{2,3}$/si", $mail))
$err.='<br/><font color="red">Ошибка!Введите адрес e-mail в виде [email protected]</font><br/>';
if($err)
print $err;
else
{
$format=format($fid);
if($format==".txt")$o="text/plain";
if($format=="gif")$o="image/gif";
if($format=="jpg" || $format=="jpeg")$o="image/jpeg";
if($format=="png")$o="image/png";
if($format=="zip")$o="archive/zip";
if($format=="rar")$o="archive/rar";
if($format=="mid")$o="media/midi";
if($format=="mmf")$o="media/mmf";
if($format=="jar")$o="application/java-archive";
if($format=="jad")$o="archive/jar";
if($format=="thm")$o="archive/vnd.eri";
if($format=="nth")$o="archive/vnh.nth";
if($format=="3gp")$o="video/3gpp";
if($format=="avi")$o="video/avi";
if($format=="mp3")$o="media/mp3";
if($format=="sdt")$o="application/vnd.siemens-mp.theme";
if($format=="scs")$o="application/vnd.siemens-mp.skin";
if($format=="sis")$o="application/vnd.symbian.install";
$subj="Вам файл от $provlog с сайта $Host";
$mess='Вы получили это письмо потому что кто-то, возможно Вы, указал этот E-mail в качестве получателя файла отправленного с сайта http://'.$Host.'. Если это было сделано по ошибке, то пожалуйста удалите это сообщение. С уважением Администрация сайта: "'.$Host.'"
Комментарий к файлу: '.$komm;
$m=new Mail;
$m->From("forum_files@$Host");
$m->To("$mail");
$m->Subject("$subj");
$m->Body($mess);
$m->Priority(3);
$m->Attach(@realpath("$file"),"$o");
$m->Send();
print '<br/><font color="aqua">Файл успешно отправлен на E-mail</font><br/>';
$fp = fopen('../local/tmpforum/'.$provlog.'.txt','w');
fputs($fp,$mail);
fclose($fp);
///////////////////////запись счетчика отправок/////////////////////////
///if($did!="" && $fid!=""){
////if(file("$did/$fid")){if($_SESSION['download']!="$did/$fid"){$_SESSION['download']="$did/$fid";
if (is_file("$did/$fid")){
if(file("$did/$fid")){
////$fid=str_replace("/", "", $did);
if (is_file("../local/downfor/$fid.dat")){
////$fn=file("../local/downfor/$fid.dat");
////$fp=fopen("../local/downfor/$fid.dat","a+");
////flock ($fp,LOCK_EX);ftruncate ($fp,0); foreach ($fn as $n=>$f){
///$data = explode("|",$fn[$n]);
////$data = explode("|",$fn[$n]);
///if ( $data[4]=="$did"){$kol=$data[5]+1;
///$zap="$data[0]|$data[1]|$data[2]|$data[3]|$data[4]|$kol|$data[6]|\r\n";
///fputs($fp,"$zap");}
///else{fputs($fp,$fn[$n]);}
///fflush ($fp);
///}
///flock ($fp,LOCK_UN);
////fclose($fp);
///@chmod("$fp", 0666);
////}}
$f = file("../local/downfor/$fid.dat");
$u = explode("|",$f[0]);
$u[5]++;
$t=$u[0].'|'.$u[1].'|'.$u[2].'|'.$u[3].'|'.$did.'|'.$u[5].'|'.$sitetime.'|';
$t=preg_replace ("|[\r\n]+|si","",$t);
$rd=0;
$file=file("../local/downfor/$fid.dat");
$fp=fopen("../local/downfor/$fid.dat","a+");flock ($fp,LOCK_EX);ftruncate ($fp,0);
for ($i=0;$i< sizeof($file);$i++) {if ($rd!=$i) {fputs($fp,$file[$i]);} else {fputs($fp,"$t\r\n");}}
fflush ($fp);
flock ($fp,LOCK_UN);fclose($fp);chmod ($fp, 0777);chmod ("../local/downfor/$fid.dat", 0777);
}}}
/////////////////////////////////////////////////////////////////////
}
}
}
else
{
print '<br/><font color="red"><b><blink>Ошибка!</blink></b> Неверно указан файл, или его размер превышает лимит!</font><br/>';
}
$t=explode('/',dirname($file));
$t[0]='';
//unset($t[0]);
}else{echo'<center><font color="red">У вас недостаточно баллов для просмотра файлов! <br>Необходимо набрать '.$config_file_usball.' баллов!</font></center>'; }}
if($config_file_post=="0"){echo'<center><font color="red">Добавление и просмотр файлов форума отключено администрацией!!!</font></center>'; }
}else{ echo "<br/><font color='red'>Этот сервис доступен только зарегестрированным пользователям сайта!!!</font>";}
}
if($config_forum_off=="0"){echo'<center><font color="red">Форум сайта отключен!</font></center>';}}
echo'<br><img src="../images/img/back.gif" alt=""> <a href="down.php?action=ob&did='.$did.'&fid='.$fid.'&'.SID.'">К файлу</a>';
echo'<br><img src="../images/imgfor/barrow.gif" alt=""> <a href="attache.php?'.SID.'">К категориям</a><br>';
echo '<img src="../images/imgfor/barrow.gif" alt=""> <a href="index.php?'.SID.'">На форум</a><br>';
echo'<img src="../images/img/homepage.gif" alt=""> <a href="../index.php?'.SID.'">На главную</a>';
include_once"../themes/$config_themes/foot.php";
?>