<?
/** LoudMouth Open Source Edition Version 2.4
  * 09-07-2001
  *
  * Copyright (C) 2000 - 2001 Miro Contruct Pty Ltd
  * Distributed under the terms of the GNU General Public License
  * This software may be used without warranty provided these statements are left intact
  * and the "Powered by LoudMouth" logo appears at the bottom of each page.
  * This code is Available at http://sourceforge.net/projects/mambo
  *
  * Site Name: LoudMouth Open Source Edition Version 2.4
  *    File Name: privateEmail.php
  *    Developers: Nicole Anderson - nicole@miro.com.au
  *                Danny Younes - danny@miro.com.au
  *    Date: 27/07/2001
  *    Version #: 2.4
  *    Comments:
**/

    
require ("classes/html/privateEmailHTML.php");
    
$emailHTML=new privateEmail();

    if (
$sendEmail==1){
        if (
$emailFrom==""){
            
$emailFrom=$emailFromDisp;
        }
        
$query="select email from users where id='$authorid'";
        
$result=$database->openConnectionWithReturn($query);
        list (
$emailAddress)=mysql_fetch_array($result);

        
$query="select email from users where id='$senderid'";
        
$result=$database->openConnectionWithReturn($query);
        list (
$userEmailAddress)=mysql_fetch_array($result);

        
$recipient $emailAddress;
        
$headers .= "X-Sender: <$userEmailAddress> \n";
        
$headers .= "From: $emailFrom <$userEmailAddress>\n";
        
$headers .= "X-Mailer: PHP\n"// mailer
        
mail($recipient$subject$message$headers);

        
$sendmail=0;
        echo 
"<SCRIPT LANGUAGE='JAVASCRIPT'>window.history.go(-2);</SCRIPT>\n";
    }else{

        
$query "SELECT * FROM forum WHERE archive=0 AND published=1 AND usertype='$usertype'";
        
$resultForum $database->openConnectionWithReturn($query);

        if (
trim($authorid)!=""){
            
$query="select username from users where id='$authorid'";
            
$result=$database->openConnectionWithReturn($query);
            list (
$author)=mysql_fetch_array($result);

            
$sessionID=$HTTP_COOKIE_VARS["forumusercookie"];
            
$sessionID=md5($sessionID);
            
$query="select username, userid from session where session_id='$sessionID'";
            
$result=$database->openConnectionWithReturn($query);
            list (
$sendername$senderid)=mysql_fetch_array($result);

            
$emailHTML->emailForm($author$authorid$sendername$senderid$forumid);
        }else{
            
$emailHTML->unauthorised();

        }
    }
?>