<?php
/*[_X3T4_N!CK_] Muellifdir Silenin Anasin Sikim*/
define('MKTOP', 1);
$title = 'E-mail Message';
require_once('../system/connect.php');
require_once('../system/core.php');
require_once('../system/function.php');
level(3);
require_once('../head.php');
$rassilka = '<form action="mail.php?act=send" method="post">
<div class="text">Mövzu:<br/><input type="text" name="tema" class="input" /></div>
<div class="text">Mesaj:<br/><textarea name="text" cols="38" rows="8"></textarea></div>
<div class="text"><input name="ok" type="submit" value="Gönder" /></div></form>
<div class="text">QEYD: E-mail Mesaj Yalniz Qeydiyyatda Olan Istifadecilere Gonderilecek!</div>';
if(!isset($_POST['ok'])) echo $rassilka;
else{
$tema = filter($_POST['tema']);
$text = filter($_POST['text']);
$error = '';
if(empty($tema) OR empty($text))
$error .= '<div class="error">Butun bolmeleri doldurun!</div>';
else{
if(mb_strlen($tema) < 5)
$error .= '<div class="error">Mövzu ən azı 5 simvol olmalıdır</div>';
if(mb_strlen($text) < 10)
$error .= '<div class="error">Mesaj mətni 10 simvoldan artıq qısa olmalıdır</div>';
}
if(!empty($error)){
echo $error;
echo $rassilka;
}
else{
$headers = '';
$headers .= "From: ".$set['mail']." \n";
$headers .= "Content-Type: text/plain; charset=utf-8\n";
$mails = mysql_query("SELECT DISTINCT `mail` FROM `users` WHERE `mail` <> ''");
if(mysql_num_rows($mails) > 0){
while($row = mysql_fetch_array($mails))
mail($row['mail'], $tema, $text, $headers);
echo '<div class="text">Mesajiniz Ugurla Qeydiyyatli Olan '.mysql_num_rows($mails).' Nefere Gonderildi!</div>';
echo '<a class="link" href="mail.php">E-mail message system</a>';
}
else{
echo '<div class="error">E-mail Mesaj Gonderilmedi! Qeydiyyatli User Yoxdur!</div>';
echo '<a class="link" href="mail.php">E-mail message system</a>';
}
}
}
if($user_data['level'] == 3) echo '<a class="link" href="index.php">Admin Panel</a>';
require_once('../foot.php');
?>