1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

new module creation

This commit is contained in:
mcfly
2006-12-02 04:36:16 +00:00
commit e149b35fcc
2196 changed files with 182987 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,389 @@
<?php
/*
POP Before SMTP Authentication Class
Version 1.0
Author: Richard Davey (rich@corephp.co.uk)
License: LGPL, see PHPMailer License
Specifically for PHPMailer to allow POP before SMTP authentication.
Does not yet work with APOP - if you have an APOP account, contact me
and we can test changes to this script.
This class is based on the structure of the SMTP class by Chris Ryan
This class is rfc 1939 compliant and implements all the commands
required for POP3 connection, authentication and disconnection.
@package PHPMailer
@author Richard Davey
*/
class POP3
{
// Default POP3 port
var $POP3_PORT = 110;
// Default Timeout
var $POP3_TIMEOUT = 30;
// Carriage Return + Line Feed
var $CRLF = "\r\n";
// Displaying Debug warnings? (0 = now, 1+ = yes)
var $do_debug = 2;
// Socket connection resource handle
var $pop_conn;
// Boolean state of connection
var $connected;
// Error log array
var $error;
// POP3 Server Connection Required values
// Mail Server
var $host;
// Port
var $port;
// Timeout Value
var $tval;
// POP3 Username
var $username;
// POP3 Password
var $password;
/**
* Our constructor, sets the initial values
*
* @return POP3
*/
function POP3 ()
{
$this->pop_conn = 0;
$this->connected = false;
$this->error = null;
}
/**
* Combination of public events - connect, login, disconnect
*
* @param string $host
* @param integer $port
* @param integer $tval
* @param string $username
* @param string $password
*/
function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0)
{
$this->host = $host;
// If no port value is passed, retrieve it
if ($port == false)
{
$this->port = $this->POP3_PORT;
}
else
{
$this->port = $port;
}
// If no port value is passed, retrieve it
if ($tval == false)
{
$this->tval = $this->POP3_TIMEOUT;
}
else
{
$this->tval = $tval;
}
$this->do_debug = $debug_level;
$this->username = $username;
$this->password = $password;
// Refresh the error log
$this->error = null;
// Connect
$result = $this->Connect($this->host, $this->port, $this->tval);
if ($result)
{
$login_result = $this->Login($this->username, $this->password);
if ($login_result)
{
$this->Disconnect();
return true;
}
}
// We need to disconnect regardless if the login succeeded
$this->Disconnect();
return false;
}
/**
* Connect to the POP3 server
*
* @param string $host
* @param integer $port
* @param integer $tval
* @return boolean
*/
function Connect ($host, $port = false, $tval = 30)
{
// Are we already connected?
if ($this->connected)
{
return true;
}
/*
On Windows this will raise a PHP Warning error if the hostname doesn't exist.
Rather than supress it with @fsockopen, let's capture it cleanly instead
*/
set_error_handler(array(&$this, 'catchWarning'));
// Connect to the POP3 server
$this->pop_conn = fsockopen($host, // POP3 Host
$port, // Port #
$errno, // Error Number
$errstr, // Error Message
$tval); // Timeout (seconds)
// Restore the error handler
restore_error_handler();
// Does the Error Log now contain anything?
if ($this->error && $this->do_debug >= 1)
{
$this->displayErrors();
}
// Did we connect?
if ($this->pop_conn == false)
{
// It would appear not...
$this->error = array(
'error' => "Failed to connect to server $host on port $port",
'errno' => $errno,
'errstr' => $errstr
);
if ($this->do_debug >= 1)
{
$this->displayErrors();
}
return false;
}
// Increase the stream time-out
// Check for PHP 4.3.0 or later
if (version_compare(phpversion(), '4.3.0', 'ge'))
{
stream_set_timeout($this->pop_conn, $tval, 0);
}
else
{
// Does not work on Windows
if (substr(PHP_OS, 0, 3) !== 'WIN')
{
socket_set_timeout($this->pop_conn, $tval, 0);
}
}
// Get the POP3 server response
$pop3_response = $this->getResponse();
// Check for the +OK
if ($this->checkResponse($pop3_response))
{
// The connection is established and the POP3 server is talking
$this->connected = true;
return true;
}
}
/**
* Login to the POP3 server (does not support APOP yet)
*
* @param string $username
* @param string $password
* @return boolean
*/
function Login ($username = '', $password = '')
{
if ($this->connected == false)
{
$this->error = 'Not connected to POP3 server';
if ($this->do_debug >= 1)
{
$this->displayErrors();
}
}
if (empty($username))
{
$username = $this->username;
}
if (empty($password))
{
$password = $this->password;
}
$pop_username = "USER $username" . $this->CRLF;
$pop_password = "PASS $password" . $this->CRLF;
// Send the Username
$this->sendString($pop_username);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response))
{
// Send the Password
$this->sendString($pop_password);
$pop3_response = $this->getResponse();
if ($this->checkResponse($pop3_response))
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
/**
* Disconnect from the POP3 server
*
*/
function Disconnect ()
{
$this->sendString('QUIT');
fclose($this->pop_conn);
}
/*
---------------
Private Methods
---------------
*/
/**
* Get the socket response back.
* $size is the maximum number of bytes to retrieve
*
* @param integer $size
* @return string
*/
function getResponse ($size = 128)
{
$pop3_response = fgets($this->pop_conn, $size);
return $pop3_response;
}
/**
* Send a string down the open socket connection to the POP3 server
*
* @param string $string
* @return integer
*/
function sendString ($string)
{
$bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
return $bytes_sent;
}
/**
* Checks the POP3 server response for +OK or -ERR
*
* @param string $string
* @return boolean
*/
function checkResponse ($string)
{
if (substr($string, 0, 3) !== '+OK')
{
$this->error = array(
'error' => "Server reported an error: $string",
'errno' => 0,
'errstr' => ''
);
if ($this->do_debug >= 1)
{
$this->displayErrors();
}
return false;
}
else
{
return true;
}
}
/**
* If debug is enabled, display the error message array
*
*/
function displayErrors ()
{
echo '<pre>';
foreach ($this->error as $single_error)
{
print_r($single_error);
}
echo '</pre>';
}
/**
* Takes over from PHP for the socket warning handler
*
* @param integer $errno
* @param string $errstr
* @param string $errfile
* @param integer $errline
*/
function catchWarning ($errno, $errstr, $errfile, $errline)
{
$this->error[] = array(
'error' => "Connecting to the POP3 server raised a PHP warning: ",
'errno' => $errno,
'errstr' => $errstr
);
}
// End of class
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
mod_gzip_on Off

View File

@@ -0,0 +1,21 @@
<?php
/**
* PHPMailer language file.
* English Version
*/
$PHPMAILER_LANG = array();
$PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . 'recipient email address.';
$PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.';
$PHPMAILER_LANG["execute"] = 'Could not execute: ';
$PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.';
$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.';
$PHPMAILER_LANG["from_failed"] = 'The following From address failed: ';
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . 'recipients failed: ';
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.';
$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.';
$PHPMAILER_LANG["file_access"] = 'Could not access file: ';
$PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: ';
$PHPMAILER_LANG["encoding"] = 'Unknown encoding: ';
?>

View File

@@ -0,0 +1,364 @@
<?php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
| ©Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/phpmailer/mailout_process.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:34:04 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
require_once("../../class2.php");
if(!getperms("W")){ header("location:".e_BASE."index.php"); }
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/admin/lan_mailout.php");
$HEADER = "";
$FOOTER = "";
define("e_PAGETITLE",MAILAN_60);
require_once(HEADERF);
set_time_limit(18000);
session_write_close();
if($_POST['cancel_emails']){
$sql -> db_Delete("generic", "gen_datestamp='".intval($_POST['mail_id'])."' ");
$text = "<div style='text-align:center;width:220px'><br />".MAILAN_66; // Cancelled Successfully;
$text .= "<div style='text-align:center;margin-left:auto;margin-right:auto;position:absolute;left:10px;top:110px'>
<br /><input type='button' class='button' name='close' value='Close' onclick=\"window.close()\" />
</div></div>";
$ns -> tablerender(MAILAN_59, $text);
echo "</body></html>";
exit;
}
ob_implicit_flush();
/*
if (ob_get_level() == 0) {
ob_start();
}
*/
// -------------------- Configure PHP Mailer ------------------------------>
require(e_HANDLER."phpmailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->From = ($_POST['email_from_email'])? $_POST['email_from_email']: $pref['siteadminemail'];
$mail->FromName = ($_POST['email_from_name'])? $_POST['email_from_name']: $pref['siteadmin'];
// $mail->Host = "smtp1.site.com;smtp2.site.com";
if ($pref['mailer']== 'smtp')
{
$mail->Mailer = "smtp";
$mail->SMTPKeepAlive = (isset($pref['smtp_keepalive']) && $pref['smtp_keepalive']==1) ? TRUE : FALSE;
if($pref['smtp_server'])
{
$mail->Host = $pref['smtp_server'];
}
if($pref['smtp_username'] && $pref['smtp_password'])
{
$mail->SMTPAuth = TRUE;
$mail->Username = $pref['smtp_username'];
$mail->Password = $pref['smtp_password'];
$mail->PluginDir = e_HANDLER."phpmailer/";
}
}
elseif ($pref['mailer']== 'sendmail')
{
$mail->Mailer = "sendmail";
$mail->Sendmail = ($pref['sendmail']) ? $pref['sendmail'] : "/usr/sbin/sendmail -t -i -r ".$pref['siteadminemail'];
}
else
{
$mail->Mailer = "mail";
}
$mail->AddCC = ($_POST['email_cc']);
$mail->WordWrap = 50;
$mail->Charset = CHARSET;
$mail->Subject = $_POST['email_subject'];
$mail->IsHTML(TRUE);
$mail->SMTPDebug = (e_MENU == "debug") ? TRUE : FALSE;
if($_POST['email_cc'])
{
$tmp = explode(",",$_POST['email_cc']);
foreach($tmp as $addc)
{
$mail->AddCC($addc);
}
}
if($_POST['email_bcc'])
{
$tmp = explode(",",$_POST['email_bcc']);
foreach($tmp as $addbc)
{
$mail->AddBCC($addbc);
}
}
if($pref['mail_bounce_email'] !='')
{
$mail->Sender = $pref['mail_bounce_email'];
}
$attach = chop($_POST['email_attachment']);
if (($temp = strrchr($attach,'/')) !== FALSE)
{
$attach = substr($attach,$temp + 1);
}
if(is_readable(e_DOWNLOAD.$attach))
{
$attach_link = e_DOWNLOAD.$attach;
}
else
{
$attach_link = e_FILE.'public/'.$attach;
}
if ($attach != "" && !$mail->AddAttachment($attach_link, $attach))
{
$mss = MAILAN_58."<br />$attach_link"; // problem with attachment.
$ns->tablerender("Error", $mss);
require_once(e_ADMIN."footer.php");
exit;
}
// ---------------------------- Setup the Email ----------------------------->
$message_subject = stripslashes($tp -> toHTML($_POST['email_subject']));
$mail_head = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n";
$mail_head .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n";
$mail_head .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n";
if (isset($_POST['use_theme']))
{
$theme = $THEMES_DIRECTORY.$pref['sitetheme']."/";
// $mail_head .= "<link rel=\"stylesheet\" href=\"".SITEURL.$theme."style.css\" type=\"text/css\" />\n";
$style_css = file_get_contents(e_THEME.$pref['sitetheme']."/style.css");
$mail_head .= "<style>\n".$style_css."\n</style>";
$message_body = $mail_head;
$message_body .= "</head>\n<body>\n";
$message_body .= "<div style='padding:10px;width:97%'><div class='forumheader3'>\n";
$message_body .= $tp -> toEmail($_POST['email_body'])."</div></div></body></html>";
}
else
{
$message_body = $mail_head;
$message_body .= "</head>\n<body>\n";
$message_body .= $tp -> toEmail($_POST['email_body'])."</body></html>";
$message_body = str_replace("&quot;", '"', $message_body);
$message_body = str_replace('src="', 'src="'.SITEURL, $message_body);
}
$message_body = stripslashes($message_body);
// ---------------- Display Progress and Send Emails. ----------------------->
echo "<div class='fcaption'>&nbsp;".MAILAN_59."</div>";
$qry = "SELECT g.*,u.* FROM #generic AS g LEFT JOIN #user AS u ON g.gen_user_id = u.user_id WHERE g.gen_type='sendmail' and g.gen_datestamp = '".intval($_POST['mail_id'])."' ";
$count = $sql -> db_Select_gen($qry);
if(!$count)
{
echo "<div style='text-align:center;width:200px'><br />".MAILAN_61."</div>";
echo "</body></html>";
echo "<div style='text-align:center;margin-left:auto;margin-right:auto;position:absolute;left:10px;top:110px'>
<input type='button' class='button' name='close' value='Close' onclick=\"window.close()\" />
</div>";
exit;
}
$c = 0; $d=0;
$pause_count = 1;
$pause_amount = ($pref['mail_pause']) ? $pref['mail_pause'] : 10;
$pause_time = ($pref['mail_pausetime']) ? $pref['mail_pausetime'] : 1;
$sent = array();
$failed = array();
$unit = (1/$count)* 100;
echo "<div class='blocks' style='text-align:left;width:199px'><div id='bar' class='bar' style='border:0px;;width:".$cur."%' >&nbsp;</div></div>";
stopwatch();
while($row = $sql-> db_Fetch()){
// ---------------------- Mailing Part. -------------------------------------->
$activator = (substr(SITEURL, -1) == "/" ? SITEURL."signup.php?activate.".$row['user_id'].".".$row['user_sess'] : SITEURL."/signup.php?activate.".$row['user_id'].".".$row['user_sess']);
$signup_link = ($row['user_sess']) ? "<a href='$activator'>$activator</a>" : "";
$search = array("|USERNAME|","|USERID|","|SIGNUP_LINK|");
$replace = array($row['user_name'],$row['user_id'],$signup_link);
$mes_body = str_replace($search,$replace,$message_body);
$alt_body = str_replace($search,$replace,stripslashes($tp->toText($_POST['email_body'])));
$mail->Body = $mes_body;
$mail->AltBody = $alt_body;
$mail->AddAddress($row['user_email'], $row['user_name']);
$mail->AddCustomHeader("X-e107-id: ".$row['user_id']);
if ($mail->Send()) {
$sent[] = $row['user_id'];
} else {
$failed[] = $row['user_id'];
}
$mail->ClearAddresses();
// --------- End of the mailing. --------------------------------------------->
$cur = round((($c / $count) * 100) + $unit);
echo str_pad(' ',4096)."<br />\n";
$d = ($c==0) ? 10 : round($width + $d);
echo "<div class='percents'>".($c+1)." / ".$count." (" . $cur . "%) &nbsp;complete</div>";
if($cur != $prev){
echo "<script type='text/javascript'>inc('".$cur."%');</script>\n";
}
$prev = $cur;
ob_flush();
flush();
if($pause_count > $pause_amount){
sleep($pause_time);
$pause_count = 1;
}
// Default sleep to reduce server-load: 1 second.
sleep(1);
$c++;
$pause_count++;
}
ob_end_flush();
echo "<div style='position:absolute;left:10px;top:50px'><br />";
echo MAILAN_62." ".count($sent)."<br />";
echo MAILAN_63." ".count($failed)."<br />";
echo MAILAN_64." ".stopwatch()." ".MAILAN_65."<br />";
echo "</div>";
$message = $sql -> db_Delete("generic", "gen_datestamp='".intval($_POST['mail_id'])."' ") ? "deleted" : "deleted_failed";
$mail->ClearAttachments();
if ($pref['mailer']== 'smtp') {
$mail->SmtpClose();
}
echo "<div style='text-align:center;margin-left:auto;margin-right:auto;position:absolute;left:10px;top:110px'>
<br /><input type='button' class='button' name='close' value='Close' onclick=\"window.close()\" />
</div>";
echo "</body></html>";
function headerjs(){
$text = "
<style type='text/css'><!--
div.percents div.blocks img.blocks{
margin: 1px;
height: 20px;
padding: 1px;
border: 1px solid #000;
width: 199px;
background: #fff;
color: #000;
float: left;
clear: right;
z-index: 9;
position:relative;
}
.percents {
background: #FFF;
border: 1px solid #CCC;
margin: 1px;
height: 20px;
position:absolute;
vertical-align:middle;
width:199px;
z-index:10;
left: 10px;
top: 38px;
text-align: center;
color:black;
}
.blocks {
margin-top: 1px;
height: 21px;
position: absolute;
z-index:11;
left: 12px;
top: 38px;
}
.bar {
background: #EEE;
background-color:red;
filter: alpha(opacity=50);
height:21px;
-moz-opacity: 0.5;
opacity: 0.5;
-khtml-opacity: .5
}
-->
</style>";
$text .= "
<script type='text/javascript'>
function inc(amount){
document.getElementById('bar').style.width= amount;
}
</script>";
return $text;
}
function stopwatch(){
static $mt_previous = 0;
list($usec, $sec) = explode(" ",microtime());
$mt_current = (float)$usec + (float)$sec;
if (!$mt_previous) {
$mt_previous = $mt_current;
return "";
} else {
$mt_diff = ($mt_current - $mt_previous);
$mt_previous = $mt_current;
return round(sprintf('%.16f',$mt_diff),2);
}
}
?>