示例#1
0
<?php

!cfip() ? header('HTTP/1.1 401 Unauthorized') : 0;
class Mail extends Base
{
    /**
     * Mail form contact site admin
     * @param senderName string senderName
     * @param senderEmail string senderEmail
     * @param senderSubject string senderSubject
     * @param senderMessage string senderMessage
     * @param email string config Email address
     * @param subject string header subject
     * @return bool
     **/
    public function contactform($senderName, $senderEmail, $senderSubject, $senderMessage)
    {
        $this->debug->append("STA " . __METHOD__, 4);
        if (preg_match('/[^a-z_\\.\\!\\?\\-0-9\\s ]/i', $senderName)) {
            $this->setErrorMessage($this->getErrorMsg('E0024'));
            return false;
        }
        if (empty($senderEmail) || !filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) {
            $this->setErrorMessage($this->getErrorMsg('E0023'));
            return false;
        }
        if (preg_match('/[^a-z_\\.\\!\\?\\-0-9\\s ]/i', $senderSubject)) {
            $this->setErrorMessage($this->getErrorMsg('E0034'));
            return false;
        }
        if (strlen(strip_tags($senderMessage)) < strlen($senderMessage)) {
示例#2
0
<?php

$defflip = !cfip() ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
// Check user to ensure they are admin
if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
    header("HTTP/1.1 404 Page not found");
    die("404 Page not found");
}
// Include markdown library
use Michelf\Markdown;
if ($setting->getValue('notifications_disable_pool_newsletter', 0) == 1) {
    $_SESSION['POPUP'][] = array('CONTENT' => 'Pool newsletters are disabled.', 'TYPE' => 'alert alert-info');
    $smarty->assign("CONTENT", "");
} else {
    if (@$_REQUEST['do'] == 'send') {
        if (!$config['csrf']['enabled'] || $config['csrf']['enabled'] && $csrftoken->valid) {
            $iFailed = 0;
            $iSuccess = 0;
            foreach ($user->getAllAssoc() as $aData) {
                $aUserNotificationSettings = $notification->getNotificationSettings($aData['id']);
                if ($aData['is_locked'] != 0 || $aUserNotificationSettings['newsletter'] != 1 || empty($aData['email'])) {
                    continue;
                }
                $aData['subject'] = $_REQUEST['data']['subject'];
                $aData['CONTENT'] = $_REQUEST['data']['content'];
                if (!$mail->sendMail('newsletter/body', $aData, true)) {
                    $iFailed++;
                } else {
                    $iSuccess++;
                }
            }