Просмотр файла modules/admin/send.php

Размер файла: 3.29Kb
<?php
include '../../config.php';
include '../../templates/run.php';
include '../../templates/func.php';
$title_page = 'Массовая рассылка';
$m_polozhenie = 'В админке';
include '../../themes/'.$themes.'.php';
if (isset($_SESSION['sespass']) && isset($passw) && $_SESSION['sespass'] == $passw && ($status == '1'))
 {


$name = "$_POST[name]";
$msg = "$_POST[msg]";
$email = "$_POST[email]";

if ($email=='')
  {
    $email = "$emailadmina";
  }

if($name=='')
  {
    $arr = '1';
  }
if($msg=='')
  {
    $arr = '2';
  }
if ($_POST[imgrand]=='')
  {
    $arr = '3';
  }
if($_POST[imgrand]!="$_SESSION[rand]")
  {
    $arr = '4';
  }
if(!empty($arr))
 {
  header ("Location: mail.php?arr=$arr&".session_name()."=".session_id()."");
 }
else
 {
$komu = file('../../data/emails.php');
for($i=0; $i <= sizeof ($komu); $i++)
{

$subject = "$name";
$mail = "$msg";

    $utfwin = array("А"=>"\xC0", "Б"=>"\xC1", "В"=>"\xC2", "Г"=>"\xC3", "Д"=>"\xC4", "Е"=>"\xC5", "Ё"=>"\xA8", "Ж"=>"\xC6", "З"=>"\xC7", "И"=>"\xC8", "Й"=>"\xC9", "К"=>"\xCA", "Л"=>"\xCB", "М"=>"\xCC", "Н"=>"\xCD", "О"=>"\xCE", "П"=>"\xCF", "Р"=>"\xD0", "С"=>"\xD1", "Т"=>"\xD2", "У"=>"\xD3", "Ф"=>"\xD4", "Х"=>"\xD5", "Ц"=>"\xD6", "Ч"=>"\xD7", "Ш"=>"\xD8", "Щ"=>"\xD9", "Ъ"=>"\xDA", "Ы"=>"\xDB", "Ь"=>"\xDC", "Э"=>"\xDD", "Ю"=>"\xDE", "Я"=>"\xDF", "а"=>"\xE0", "б"=>"\xE1", "в"=>"\xE2", "г"=>"\xE3", "д"=>"\xE4", "е"=>"\xE5", "ё"=>"\xB8", "ж"=>"\xE6", "з"=>"\xE7", "и"=>"\xE8", "й"=>"\xE9", "к"=>"\xEA", "л"=>"\xEB", "м"=>"\xEC", "н"=>"\xED", "о"=>"\xEE", "п"=>"\xEF", "р"=>"\xF0", "с"=>"\xF1", "т"=>"\xF2", "у"=>"\xF3", "ф"=>"\xF4", "х"=>"\xF5", "ц"=>"\xF6", "ч"=>"\xF7", "ш"=>"\xF8", "щ"=>"\xF9", "ъ"=>"\xFA", "ы"=>"\xFB", "ь"=>"\xFC", "э"=>"\xFD", "ю"=>"\xFE", "я"=>"\xFF");
    $subject = strtr($subject, $utfwin);
    $mail = strtr($mail, $utfwin);
    $subject = convert_cyr_string($subject, 'w', 'k');
    $mail = convert_cyr_string($mail, 'w', 'k');
    
    $subject = '=?KOI8-R?B?'.base64_encode($subject).'?=';
    
    $headers  = "From: <".$email.">\n"; 
    $headers .= "X-sender: <".$email.">\n";
    $headers .= "Content-Type: text/plain; charset=koi8-r\n";   
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Transfer-Encoding: 8bit\r\n";
    $headers .= "X-Mailer: PHP v.".phpversion();
    mail($komu[$i], $subject, $mail, $headers);
}

$date = date('d.m.Y / H:i:s', time() + ($sdvigclock*3600));
    $adm_log_f = @file('../../data/adm_log.php');
    $adm_log_count = count($adm_log_f) - 2;
    $mes_to_adm_log = "$login|$date|Отправил письмо в Массовой рассылке e-mail\r\n";


    for($i=2; $i < $adm_log_count; $i++)
     {
      $mes_to_adm_log .= $adm_log_f[$i];
     }
    $mes_to_adm_log = trim($mes_to_adm_log);
      
    $adm_log_file = fopen('../../data/adm_log.php','w');
    flock ($adm_log_file,LOCK_EX);
    fputs($adm_log_file,"<?php\r\n/*\r\n$mes_to_adm_log\r\n*/\r\n?>");
    fflush ($adm_log_file);
    flock ($adm_log_file,LOCK_UN);
    fclose($adm_log_file);


header ("Location: mail.php?mailing=1&".session_name()."=".session_id()."");
}

}
else
{
echo'<p class="err">Ошибка!!! Вы не авторизованы. Войдите в личный кабинет.</p>';
}
include '../../templates/foot.php';
?>