- Автор темы
- #1
Код:
<?php
$page = 'contacts';
$file = 'contacts.php';
$idpg = 11;
$templ_name='contacts.tpl';
$smarty->assign('user_mail', $user_mail);
$action = isset($_GET['action']) ? htmlspecialchars(str_replace("'","",substr($_GET['action'],0,6))): false;
if($action == "submit") {
$name = isset($_POST['name'])?htmlspecialchars(str_replace("'","",substr($_POST['name'],0,50))):$login;
$mail = isset($_POST['mail'])?htmlspecialchars(str_replace("'","",substr($_POST['mail'],0,50))):$user_mail;
$subj = isset($_POST['subj'])?htmlspecialchars(str_replace("'","",substr($_POST['subj'],0,100))):false;
$textform = isset($_POST['textform'])?htmlspecialchars(str_replace("'","",substr($_POST['textform'],0,10240))):false;
$code = isset($_POST['code'])?htmlspecialchars(str_replace("'","",substr($_POST['code'],0,5))):false;
$error=false;
if(!$name) {
$_SESSION['messages'][]=array('er',$lang['enter_login']);
$error=true;
}
elseif(!$mail) {
$_SESSION['messages'][]=array('er',$lang['email']);
$error=true;
}
elseif(!$subj) {
$_SESSION['messages'][]=array('er',$lang['enter_subj']);
$error=true;
}
elseif(!$textform) {
$_SESSION['messages'][]=array('er',$lang['enter_message']);
$error=true;
}
elseif(!preg_match("/^[a-z0-9_.-]{1,20}@(([a-z0-9-]+\.)+(com|net|org|mil|edu|gov|arpa|info|biz|[a-z]{2})|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})$/is",$mail)) {
$_SESSION['messages'][]=array('er',$lang['preg_match']);
$error=true;
}
elseif(!mysql_num_rows(mysql_query("SELECT * FROM captcha WHERE sid = '".$sid."' AND ip = '".getip()."' AND code = '".$code."'"))) {
$_SESSION['messages'][]=array('er',$lang['no_captcha']);
$error=true;
}
if(!$error)
{
/*$headers = "From: ".$mail."\n";
$headers .= "Reply-to: ".$mail."\n";
$headers .= "X-Sender: < http://".$cfgURL." >\n";
$headers .= "Content-Type: text/html; charset=windows-1251\n";
$row=mysql_fetch_array(mysql_query("select * from mail_tmp where id=9"));
$subject = $row['subj'];
$text=$row['body'];
//заменим подстановочные теги
$text= str_replace('{%username%}',$name, $text);
$text= str_replace('{%subj%}',$subj, $text);
$text= str_replace('{%ip%}',$_SERVER['REMOTE_ADDR'], $text);
$text= str_replace('{%text%}',$textform, $text);
$text= str_replace('{%URL%}',$cfgURL, $text);
$send = mail($adminmail,$subject,$text,$headers);
*/
$send=user_mail (9,1,array('subj'=>$subj,'text'=>$textform, 'username'=>$name, 'ip'=>$_SERVER['REMOTE_ADDR'],'usermail'=>$mail),$mail); //1 - Id админа
if(!$send) {
$_SESSION['messages'][]=array('er',$lang['mailserver_error']);
} else {
$_SESSION['messages'][]=array('erok',$lang['message_send']);
$name = "";
$mail = "";
$subj = "";
$textform = "";
}
}
}
?>
что может быть? где и как подправить? не отправляются письма