Location: PHPKode > scripts > WH Social > wh_social/admin/newsletter.php
<?php

    if(file_exists('handler/stay.php') == TRUE) {

        require('handler/stay.php');

        }else{

        echo '<p class="red_span" align="center">Error - Fehler</p>';
        exit;
        }

?>

<?php define('INCLUDE_CHECK',1); define('MYSQL_CHECK',1); ?>

<?php require('../framework/config.php'); ?>
<?php require('../framework/mysql.php'); ?>
<?php require('../framework/constants.php'); ?>
<?php require('../framework/class/cache_class.php'); no_cache(); ?>
<?php require('../framework/security.php'); ?>
<?php require('handler/language.php'); ?>

<?php require('structure/header.inc.php'); ?>

    <div class="menu">
        <div class="menu_left">
            <ul id="admin_navi">
                <li><a href="index.php"><?php echo $lang['blank_admin_area']; ?></a></li>
                <li><a href="members.php"><?php echo $lang['admin_members']; ?></a></li>
                <li><a href="discussions.php"><?php echo $lang['discussions']; ?></a></li>
                <li><a href="topics.php"><?php echo $lang['blank_topics']; ?></a></li>
                <li><a href="news.php"><?php echo $lang['news']; ?></a></li>
                <li><a href="events.php"><?php echo $lang['events']; ?></a></li>
                <li class="active"><a href="newsletter.php"><?php echo $lang['newsletter']; ?></a></li>
                <li><a href="statistic.php"><?php echo $lang['statistic']; ?></a></li>
            </ul>
        </div>
        <div class="menu_right">
            <?php

            if(isset($_SESSION['admin']) && $_SESSION['admin'] == TRUE) {

            echo '<div class="admin_settings">
            <a class="admin_account"><span>' . $lang['blank_navigation'] . '</span></a>
            <div class="admin_submenu" style="display: none;">
                <ul class="root">
                    <li><a href="' . $url . '" target="_blank">' . $lang['goto_network'] . '</a></li>
                    <li><a href="signout.php">' . $lang['signout'] . '</a></li>
                </ul>
            </div>
            </div>';
            }

            ?>
        </div>
    </div>
</div>

<div class="clear"></div>

<div id="content_wrapper">
    <div class="content">

    <?php

        echo '<h1 class="p_space">' . $lang['newsletter'] . '</h1>';

        if($_SERVER['REQUEST_METHOD'] != 'POST') {

        echo '<form action="" method="post" name="newsletter">
        <p><input type="text" name="subject" class="textfields" required size="40" maxlength="80"> ' . $lang['subject'] . '</p>
        <p>' . $lang['news_for_members'] . '<br>
        <textarea cols="45" rows="8" name="content" id="content" class="textareas"></textarea></p>
        <input type="submit" name="send" id="send" value="' . $lang['admin_send_newsletter'] . '" class="buttons">
        </form>';

        }else{

        $errors = array();

		if(isset($_POST['subject'])) {
		if(trim($_POST['subject']) == "") {
		$errors[] = $lang['enter_a_title'];
		}

			}else{
			$errors[] = $lang['enter_a_title'];
			}

        if(isset($_POST['content'])) {
		if(trim($_POST['content']) == "") {
		$errors[] = $lang['enter_a_text'];
		}

			}else{
			$errors[] = $lang['enter_a_text'];
			}

        if(!empty($errors)) {

        echo '<p>' . $lang['not_filled_in_all_fields'] . ' - <a href="javascript:history.back();">' . $lang['back'] . '</a></p>';
		echo '<ul>';

		foreach($errors as $key => $value) {
		echo '<li>&#8226; ' . $value . '</li>';
		}
		echo '</ul>';

		}else{

        $mail_subject = htmlentities($_POST['subject']);
        $mail_content = htmlentities($_POST['content']);
        $mail_writers = $title;

        $result = mysql_query("SELECT id, name, email FROM members") OR die(mysql_error());

        $sendet = array();

        while($row = mysql_fetch_assoc($result)) {

            if(mail("$row[email]", "$mail_subject", "$mail_content", "From: $mail_writers")) {

            $sendet[] = htmlentities($row['email'], ENT_QUOTES);

            echo '<p class="success">' . $lang['newsletter_sendet'] . ' ' . htmlentities($row['name'], ENT_QUOTES) . ' ' . $lang['newsletter_second'] . '</p>';

                }else{

                echo '<p class="false">' . $lang['newsletter_not_sendet'] . ' ' . htmlentities($row['name'], ENT_QUOTES) . ' ' . $lang['newsletter_not_second'] . '</p>';
                }
            }

        $success_receivers = count($sendet);

        echo '<div class="clear_long"></div>
        <h1>' . $lang['admin_result'] . '</h1>
        <p class="success">' . $lang['newsletter_count_first'] . ' ' . (int)$success_receivers . ' ' . $lang['newsletter_count_second'] . '</p>';
        }
        }

        echo '<div class="clear"></div>';

    ?>

<?php require('structure/footer.inc.php'); ?>
Return current item: WH Social