Всем доброго времени суток, тут возникла необходимость сделать вывод страницы mail в виде блока. Я попробовал переделать из мода в блок, на вскидку, вроде бы работает. Если кому не сложно, оцените с точки зрения работоспособности.
<?php
<?php
if(!defined("DNREAD")) exit();
global $db,$basepref,$setting,$lang,$usermain,$tm,$api,$s iteglobal,$captcha,$title,$sendnames,$sendtexts,$c id,$respon,$sendfile,$mailto;
if (defined('SETTING')) {
return $bs = '';
}
$legaltodo = array('index','send');
$to = (isset($to) && in_array($api->sitedn($to),$legaltodo)) ? $api->sitedn($to) : 'index';
function send_dopmail($from, $to, $subject, $message, $re, $filename) {
global $setting;
if (!empty($filename)) {
$f = @fopen($filename,"rb");
$un = @strtoupper(@uniqid(@time()));
}
$headers = 'From: '.$from."\n";
$headers.= 'To: '.$re.' <'.$to.'>'."\n";
$headers.= 'Subject: '.$subject."\n";
$headers.= 'X-Mailer: PHP/'.@phpversion()."\n";
$headers.= 'Reply-To: '.$from."\n";
if (!empty($filename)) {
$headers.= 'Mime-Version: 1.0'."\n";
$headers.= 'Content-Type:multipart/mixed;';
$headers.= "boundary=\"----------".$un."\"\n\n";
} else {
$headers.= 'Content-Type: text/html; charset='.$setting['langcharset']."\n";
}
if (!empty($filename)) {
$mesages = "------------".$un."\nContent-Type:text/html;\n";
$mesages.= "Content-Transfer-Encoding: 8bit\n\n$message\n\n";
$mesages.= "------------".$un."\n";
$mesages.= "Content-Type: application/octet-stream;";
$mesages.= "name=\"".@basename($filename)."\"\n";
$mesages.= "Content-Transfer-Encoding:base64\n";
$mesages.= "Content-Disposition:attachment;";
$mesages.= "filename=\"".@basename($filename)."\"\n\n";
$mesages.= @chunk_split(@base64_encode(@fread($f,@filesize($f ilename))))."\n";
} else {
$mesages = $message;
}
@mail($to, $subject, $mesages, $headers);
}
/**
* Метка index
*/
if ($to == 'index') {
$siteglobal['insert']['breadcrumb'] = '<a href="'.$setting['site_url'].'/mail/">'.$siteglobal['modname'].'</a> » Написать письмо';
$inq = $db->query("SELECT * FROM ".$basepref."_mail ORDER BY posit ASC");
$mailto = '<option value="0">Администрация</option>';
while($item = $db->fetchrow($inq)){
$mailto.= '<option value="'.$item['mailid'].'">'.$item['mailname'].'</option>';
}
$tm->unmanule['captcha'] = ($setting['captcha']=='yes' && defined("REMOTE_ADDRS")) ? 'yes' : 'no';
$tm->unmanule['control'] = ($setting['control'] == 'yes') ? 'yes' : 'no';
$control = $cid = '';
if ($setting['control'] == 'yes') {
if (isset($setting['controls']) && is_array($setting['controls'])) {
$controlarray = $setting['controls'];
} else {
$i = 0;
$ci = $db->query("SELECT * FROM ".$basepref."_control",$setting['cachetime']);
while ($cm = $db->fetchrow($ci,$setting['cache'])) {
$controlarray[$i] = array('cid'=>$cm['cid'],'issue'=>$cm['issue']);
$i++;
}
}
$r = @rand(0,sizeof($controlarray)-1);
$control = @$controlarray[$r]['issue'];
$cid = @$controlarray[$r]['cid'];
}
return $tm->parse(
array(
'email_name'=>$lang['email_name'],
'email'=>$lang['e_mail'],
'email_text'=>$lang['email_text'],
'mail_hint'=>$lang['mail_hint'],
'uname'=>$usermain['uname'],
'umail'=>$usermain['umail'],
'all_refresh'=>$lang['all_refresh'],
'control_word'=>$lang['control_word'],
'mailto'=>$mailto,
'control'=>$control,
'cid'=>$cid,
'email_send'=>$lang['email_send']
),
$tm->parsein($tm->create('mod/mail/block.form.mail')));
}
/**
* Метка send
*/
if ($to == 'send') {
$cid = preparse($cid,THIS_INT);
$mailto = preparse($mailto,THIS_INT);
if ($setting['captcha'] == 'yes') {
if (findcaptcha(REMOTE_ADDRS,$captcha) == 1) {
$tm->parseprint(
array(
'isset_error'=>$lang['isset_error'],
'error'=>$lang['bad_captcha'],
'go_back'=>$lang['all_goback']
),
$tm->create('error'));
}
}
if ($setting['control'] == 'yes') {
$valid = $db->fetchrow($db->query("SELECT * FROM ".$basepref."_control WHERE cid='".$cid."'"));
if ($valid['cid'] > 0 && $valid['response'] != $respon || empty($valid)) {
$tm->parseprint(
array(
'isset_error'=>$lang['isset_error'],
'error'=>$lang['bad_control'],
'go_back'=>$lang['all_goback']
),
$tm->create('error'));
}
}
if (verify_name($sendnames) == 0) {
$tm->parseprint(
array(
'isset_error'=>$lang['isset_error'],
'error'=>$lang['bad_login'].''.$lang['bad_login_symbol'],
'minname'=>$setting['minname'],
'maxname'=>$setting['maxname'],
'go_back'=>$lang['all_goback']
),
$tm->create('error'));
}
if (verify_mail($sendmails) == 0) {
$tm->parseprint(
array(
'isset_error'=>$lang['isset_error'],
'error'=>$lang['bad_mail'],
'go_back'=>$lang['all_goback']
),
$tm->create('error'));
}
if (preparse($sendtexts,THIS_STRLEN) < 15 || preparse($sendtexts,THIS_STRLEN) > 500) {
$tm->parseprint(
array(
'isset_error'=>$lang['isset_error'],
'error'=>$lang['email_error_text'],
'go_back'=>$lang['all_goback']
),
$tm->create('error'));
}
if (!empty($_FILES['sendfile']['name'])) {
if ($_FILES['sendfile']['size'] > ($setting['mailsize']*1024*1024)) {
$tm->parseprint(
array(
'isset_error'=>$lang['isset_error'],
'error'=>'Размер файла превышает '.$setting['mailsize'].' Mb!',
'go_back'=>$lang['all_goback']
),
$tm->create('error'));
}
}
if (isset($mailto) && $mailto > 0) {
$inq = $db->fetchrow($db->query("SELECT email FROM ".$basepref."_mail WHERE mailid = '".$mailto."'"));
$mailto = $inq['email'];
} else {
$mailto = $setting['site_mail'];
}
$objdir = $filename = $filenames = '';
if ($objdir == '' || $objdir == '/') $objdir = 'up/mail/';
if (isset($_FILES['sendfile']['name']) && !empty($_FILES['sendfile']['name'])) {
$filenames = @strtolower(@trim($_FILES['sendfile']['name']));
$filenames = @preg_replace('/([ &%§]+)/','',$filenames);
$tmpname = $_FILES['sendfile']['tmp_name'];
$filename = @uniqid(fileencodestring($filenames));
$filename = $objdir.$filename;
if(!@is_dir($objdir)) @mkdir($objdir);
@move_uploaded_file($tmpname,DNBASE.$filename);
}
$sendnames = strtr($sendnames,"\015\012",' ');
$sendmails = strtr($sendmails,"\015\012",' ');
$subject = $lang['contact_subject'].' - '.$setting['site'];
$message = this_text(
array(
"br"=>"",
"sendname"=>$sendnames,
"sendmail"=>$sendmails,
"text"=>$sendtexts
),
$lang['contact_msgtext']);
send_dopmail($sendmails, $mailto, $subject, $message, $setting['site'], $filename);
@unlink(DNBASE.$filename);
$tm->parseprint(
array(
'title'=>$siteglobal['modname'],
'text'=>$lang['email_cong_text'].' <a href="'.$setting['site_url'].'">'.$setting['site'].'</a>.',
),
$tm->create('message'));
}
return $bt;
?>