Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/NS-MailUsers/admin/modules/nukemail.php
<?PHP
// File: $Id: nukemail.php,v 1.21 2001/12/04 13:07:46 jgm Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file:  Christopher Thorjussen <hide@address.com>
// Purpose of file:
// PHP-Nuke MailUsers Module for PHP-Nuke v5.0BETA
// Copyright (c) 2001 by Christopher Thorjussen (hide@address.com)
// http://www.nukemodules.com
// Nuke MailUsers is a hack of the email_user script in
// PHP-Nuke AddOn v5.01
// Copyright (c)2001 Richard Tirtadji (hide@address.com)
// URL: http://www.nukeaddon.com
// ----------------------------------------------------------------------

if (!eregi("admin.php", $PHP_SELF))
{
  die ("Access Denied");
}

$hlpfile = "manual/nukemail.html";

modules_get_language();

if (!(authorised(0, 'Mail users::', '::', ACCESS_ADMIN))) {
    include 'header.php';
    echo _MAILUSERSNOAUTH;
    include 'footer.php';
} else {

/*********************************************************/
/* EMAIL USERS Block Functions                           */
/*********************************************************/

function MailUser($error, $fromname, $from, $subject, $message, $all)
{
    global $hlpfile, $admin, $NM_version, $pntable, $anonymous, $dbconn;
    include ("header.php");

    GraphicAdmin($hlpfile);

    if (!(authorised(0, 'Mail users::', '::', ACCESS_ADMIN))) {
        echo _MAILUSERSNOAUTH;
        include 'footer.php';
        return;
    }
    OpenTable();

    print '<center><font face="arial" size="4">'._NM_MAILUSER.'</font></center>';

    if ($error == 1)
    {
      print '<center><br><b><font color='._NB_ERRORCOLOR.' size="3">'._NM_ERROR1.'</font></b></center><br>';
    }
    elseif ($error == 2)
    {
      print '<center><br><b><font color='._NB_ERRORCOLOR.' size="3">'._NM_ERROR2.'</font></b></center><br>';
    }
    elseif ($error == 3)
    {
      print '<center><br><b><font color='._NB_ERRORCOLOR.' size="3">'._NM_ERROR3.'</font></b></center><br>';
    }
    elseif ($error == 4)
    {
      print '<center><br><b><font color='._NB_ERRORCOLOR.' size="3">'._NM_ERROR4.'</font></b></center><br>';
    }
    elseif ($error == 5)
    {
      print '<center><br><b><font color='._NB_ERRORCOLOR.' size="3">'._NM_ERROR5.'</font></b></center><br>';
    }
?>
    <form action="admin.php" method="post">
    <input type="hidden" name="op" value="send_email_to_user">
    <table border="0">
    <?
    echo"
    <tr><td><font class=\"pn-normal\"><b>"._NM_USERNAME."</b></font></td>
    <td><select name=\"username\">\n";
    $column = &$pntable['users_column'];
    $result = $dbconn->Execute("SELECT $column[uid], $column[uname] 
                              FROM $pntable[users] ORDER BY $column[uname]");
    $tmp1 = 0;

    //FTO : Rewrite the condition loop clearly to test EOF

        if (!$result) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
            die();
        }

    while(!$result->EOF)
 {
        list($uid, $uname) = $result->fields;
        $result->MoveNext();

      if ($tmp1 == 0)
      {
        echo "<option value=\"$uid\">"._NM_CHOOSEUSER."</option>";
      }
      if (($uname =='Anonymous') or ($uname == $anonymous))
      {
   //   echo "<option value=\"$uid\">"._NM_CHOOSEUSER."</option>";
   //   $anonid = $uid;
      }
      else
      {
        echo "<option value=\"$uid\">$uname</option>\n";
      }
      $tmp1 = $tmp1 + 1;
    }
    ?>
    </select></td></tr>
    <tr><td></td><td><font class="pn-normal"><input type="checkbox" name="all" value="1" <?php if ($all==1) { echo "checked"; } ?>><?PHP echo ""._NM_MAILALLUSERS.""; ?></font></td></tr>
    <tr><td><font class="pn-normal"><?php echo "<b>"._NM_FROM."</b>"; ?></font></td><td><input type="text" size="28" name="fromname" value="<?php echo $fromname; ?>"></td></tr>
    <tr><td><font class="pn-normal"><?php echo "<b>"._NM_REPLYTOADDRESS."</b>"; ?></font></td><td><input type="text" size="28" name="from" value="<?php echo $from; ?>"></td></tr>
    <tr><td><font class="pn-normal"><?php echo "<b>"._NM_SUBJECT."</b>"; ?></font></td><td><input type="text" size="28" name="subject" value="<?php echo $subject; ?>"></td></tr>
    <tr><td><font class="pn-normal"><?php echo "<b>"._NM_MESSAGE."</b>"; ?></font></td><td><textarea wrap="virtual" cols="42" rows="12" name="message"><?php echo $message; ?></textarea></td></tr>
    <tr><td>&nbsp;</td><td>
    <input type="hidden" name="anonid" value="<?php echo $anonid; ?>">
    <input type="submit" value="<?php echo _NM_SEND_MAIL; ?>">&nbsp;&nbsp <font class="pn-normal"><b><?php echo ""._NM_REMEMBER.""; ?></b></font></td></tr>
    </table></form>
    <?
    CloseTable();
    include("footer.php");
}

function send_email_to_user($username, $fromname, $from, $subject, $message, $all, $anonid)
{
    global $pntable, $dbconn;
    $message = stripslashes($message);
    $subject = stripslashes($subject);

        if (!(authorised(0, 'Mail users::', '::', ACCESS_ADMIN))) {
            include 'header.php';
            echo _MAILUSERSNOAUTH;
            include 'footer.php';
            return;
        }

    if (($username == $anonid) and (!$all)) {
        pnRedirect('admin.php?op=email_user&error=1');
    } elseif ($fromname == "") {
        pnRedirect('admin.php?op=email_user&error=2');
    } elseif ($from == "") {
        pnRedirect('admin.php?op=email_user&error=3');
    } elseif ($subject == "") {
        pnRedirect('admin.php?op=email_user&error=4');
    } elseif ($message == "") {
        pnRedirect('admin.php?op=email_user&error=5');
    } else {
        if($all) {
        $column = &$pntable['users_column'];
        $result = $dbconn->Execute("SELECT DISTINCT $column[email] FROM $pntable[users]");
      }
      else
      {
        $column = &$pntable['users_column'];
        $result = $dbconn->Execute("SELECT $column[email] 
                                  FROM $pntable[users] 
                                  WHERE $column[uid]='$username'");
      }

    //FTO : Rewrite the condition loop clearly to test EOF
//      if($dbconn->ErrorNo()<>0) {
//          error_log("DB Error: nukemail.php" . $dbconn->ErrorMsg());
//          echo $dbconn->ErrorNo(). ": ".$dbconn->ErrorMsg(). "<br>";
//          exit();
//      }
    


        if (!$result) {
            PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
            die();
        }


      $email = "";
      if($all)
        {
        while(!$result->EOF)
        {
          list($useremail) = $result->fields;
          $result->MoveNext();
          if (!empty($useremail)) {
            $email .= "$useremail, ";
              }
        }
        // An email to all goes out To: the user sending the email,
        // and Bcc: all of the actual recipients
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
//            mail($from, $subject, $message, "From: \"$fromname\" <$from>\nBcc: $email\nX-Mailer: PHP/" . phpversion(), "-f$fromname");
            mail($from, $subject, $message, "From: \"$fromname\" <$from>\nBcc: $email\nX-Mailer: PHP/" . phpversion());
      }
      else
       {
            list($email) = $result->fields;
            $email .= ", ";
// 11-09-01 eugeniobaldi not compliant with PHP < 4.0.5
//        mail($email, $subject, $message, "From: \"$fromname\" <$from>\nX-Mailer: PHP/" . phpversion(), "-f$fromname");
        mail($email, $subject, $message, "From: \"$fromname\" <$from>\nX-Mailer: PHP/" . phpversion());
      }
      pnRedirect('admin.php?op=adminMain');
    }
}

}
?>
Return current item: ProNuke. Postnuke To Oracle