Пример #1
0
 function send($subject)
 {
     $ret = false;
     if (is_string($subject)) {
         $subject = FUNC::str_clear($subject);
         $subject = trim($subject);
         if ($subject != "") {
             $this->_subject = $this->qpheader($subject);
             $ver = true;
             if (!($this->_toaddrs && count($this->_toaddrs) > 0)) {
                 $ver = false;
                 throw new Exception('You must set "To" e-mail address(es) using function "AddTo()", on class SMTP::send()', 512);
             }
             if (!($this->_atext || $this->_ahtml)) {
                 $ver = false;
                 throw new Exception('You must set the mail message using function(s) "Text() or/and Html()", on class SMTP::send()', 512);
             }
             if ($ver) {
                 if ($this->_ccaddrs && count($this->_ccaddrs) > 0) {
                     $clearcc1 = array();
                     foreach ($this->_ccaddrs as $ccaddrs1 => $ccname1) {
                         $vercc1 = true;
                         foreach ($this->_toaddrs as $toaddrs1 => $toname1) {
                             if ($ccaddrs1 == $toaddrs1) {
                                 $vercc1 = false;
                             }
                         }
                         if ($vercc1) {
                             $clearcc1[$ccaddrs1] = $ccname1;
                         } else {
                             throw new Exception('The e-mail address "' . $ccaddrs1 . '" appear in To and Cc, on class SMTP::send()', 512);
                         }
                     }
                     $this->_ccaddrs = $clearcc1;
                 }
                 if ($this->_bccaddrs && count($this->_bccaddrs) > 0) {
                     $clearbcc1 = array();
                     foreach ($this->_bccaddrs as $bccaddrs1 => $bccname1) {
                         $verbcc1 = true;
                         foreach ($this->_toaddrs as $toaddrs2 => $toname2) {
                             if ($bccaddrs1 == $toaddrs2) {
                                 $verbcc1 = false;
                             }
                         }
                         if ($verbcc1) {
                             $clearbcc1[$bccaddrs1] = $bccname1;
                         } else {
                             throw new Exception('The e-mail address "' . $bccaddrs1 . '" appear in To and Bcc, on class SMTP::send()', 512);
                         }
                     }
                     $this->_bccaddrs = $clearbcc1;
                 }
                 if ($this->_bccaddrs && count($this->_bccaddrs) > 0 && $this->_ccaddrs && count($this->_ccaddrs) > 0) {
                     $clearbcc2 = array();
                     foreach ($this->_bccaddrs as $bccaddrs2 => $bccname2) {
                         $verbcc2 = true;
                         foreach ($this->_ccaddrs as $ccaddrs2 => $ccname2) {
                             if ($bccaddrs2 == $ccaddrs2) {
                                 $verbcc2 = false;
                             }
                         }
                         if ($verbcc2) {
                             $clearbcc2[$bccaddrs2] = $bccname2;
                         } else {
                             throw new Exception('The e-mail address "' . $bccaddrs2 . '" appear in Cc and Bcc, on class SMTP::send()', 512);
                         }
                     }
                     $this->_bccaddrs = $clearbcc2;
                 }
                 $group = $alldom = array();
                 foreach ($this->_toaddrs as $toaddrs3 => $toname3) {
                     $exp1 = explode('@', $toaddrs3);
                     $group[$exp1[1]][] = $toaddrs3;
                     $alldom[] = $toaddrs3;
                 }
                 if ($this->_ccaddrs && count($this->_ccaddrs) > 0) {
                     foreach ($this->_ccaddrs as $ccaddrs3 => $ccname3) {
                         $exp2 = explode('@', $ccaddrs3);
                         $group[$exp2[1]][] = $ccaddrs3;
                         $alldom[] = $ccaddrs3;
                     }
                 }
                 if ($this->_bccaddrs && count($this->_bccaddrs) > 0) {
                     foreach ($this->_bccaddrs as $bccaddrs3 => $bccname3) {
                         $exp3 = explode('@', $bccaddrs3);
                         $group[$exp3[1]][] = $bccaddrs3;
                         $alldom[] = $bccaddrs3;
                     }
                 }
                 $this->_content = $this->_writemsg();
                 $success = false;
                 foreach ($this->_smtpconn as $conntype) {
                     if (!$success) {
                         if ($conntype == "local") {
                             $success = $this->_sendtohost('127.0.0.1', $alldom, false);
                         } elseif ($conntype == "relay") {
                             if ($this->_relay) {
                                 $success = $this->_sendtohost($this->_relay['ip'], $alldom, true);
                             } else {
                                 throw new Exception('You must set relay options with function "Relay()" in order to use relay connection, on class SMTP::send()', 512);
                             }
                         } elseif ($conntype == "client") {
                             $back1 = $back2 = true;
                             foreach ($group as $hostname => $domaddrs) {
                                 $back1 = $this->_sendtohost($hostname, $domaddrs, false);
                                 if (!$back1) {
                                     $back2 = false;
                                 }
                             }
                             $success = $back2;
                         }
                     } else {
                         break;
                     }
                 }
                 $ret = $success;
             }
         } else {
             throw new Exception('Invalid subject value, on class SMTP::send()', 512);
         }
     } else {
         throw new Exception('Invalid subject type value, on class SMTP::send()', 512);
     }
     return $ret;
 }
Пример #2
0
function nulluhr()
{
    global $db;
    update_all_ranks();
    $db->query('DELETE FROM ' . DB_PRE . 'ecp_messages WHERE fromdel = 1 AND del = 1');
    $result = $db->query('SELECT ID FROM ' . DB_PRE . 'ecp_user WHERE (ondelete < ' . time() . ' AND ondelete != 0) OR (status = 0 AND registerdate < ' . (time() - DELETE_UNAKTIV * 86400) . ')');
    while ($row = mysql_fetch_assoc($result)) {
        delete_user($row['ID']);
    }
    $result = $db->query('SELECT ID, money FROM ' . DB_PRE . 'ecp_user LEFT JOIN ' . DB_PRE . 'ecp_ranks ON (rID = rankID)');
    while ($row = mysql_fetch_assoc($result)) {
        if ($row['money'] != '') {
            $db->query('UPDATE ' . DB_PRE . 'ecp_user_stats SET money = money + ' . $row['money'] . ' WHERE userID = ' . $row['ID']);
        }
    }
    if (BACKUP_AKTIV) {
        $last = $db->result(DB_PRE . 'ecp_stats', 'lastdbbackup', '1');
        if (BACKUP_CYCLE == 'day' or $last + (BACKUP_CYCLE == 'month' ? 2592000 : 604800) < time()) {
            $backup_obj = new MySQL_Backup();
            $backup_obj->server = MYSQL_HOST;
            $backup_obj->username = MYSQL_USER;
            $backup_obj->password = MYSQL_PASS;
            $backup_obj->database = MYSQL_DATABASE;
            $backup_obj->tables = array();
            $backup_obj->drop_tables = true;
            $backup_obj->struct_only = false;
            $backup_obj->comments = true;
            $backup_obj->fname_format = 'd_m_y__H_i_s';
            $string = get_random_string(8, 2);
            if ($backup_obj->Execute(MSB_SAVE, 'uploads/forum/' . $string . '.sql.gz', true)) {
                $m = new XMail();
                // set from address and name
                $m->From(SITE_EMAIL);
                // add to address and name
                $m->AddTo(BACKUP_EMAIL);
                // set subject
                $m->Subject(BACKUP_AUTO);
                // set text/plain version of message
                $m->Text(DATE . ': ' . date('d.m.Y H:i:s'));
                // add attachment ('text/plain' file)
                $m->Attach(date('Y_m_d') . '.sql.gz', 'application/x-gzip');
                $f = 'uploads/forum/' . $string . '.sql.gz';
                $id = MIME::unique();
                // add inline attachment '$f' file with ID '$id'
                $m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'attachment', $id);
                if (SMTP_AKTIV) {
                    $c = $m->Connect(SMTP_HOST, (int) SMTP_PORT, SMTP_USER, SMTP_PASS, 'tls', 10, 'localhost', null, 'plain');
                    //or die(print_r($m->Result));
                }
                if ($m->Send(SMTP_AKTIV ? $c : null)) {
                    $db->query('UPDATE ' . DB_PRE . 'ecp_stats SET lastdbbackup = ' . strtotime('today 00:00:00'));
                }
                unlink('uploads/forum/' . $string . '.sql.gz');
            }
        }
    }
    $result = $db->query('SELECT attachID, strname FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000));
    while ($row = $db->fetch_assoc()) {
        @unlink('upload/forum/' . $row['attachID'] . '_' . $row['strname']);
    }
    $db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_attachments WHERE (tID = 0 OR bID = 0) AND uploadzeit < ' . (time() - 1000));
    // Buchungen durchf�hren
    $buchresult = $db->query('SELECT `ID`, `verwendung`, `intervall`, `betrag`, `nextbuch`, `tagmonat` FROM ' . DB_PRE . 'ecp_clankasse_auto WHERE nextbuch <= \'' . time() . '\'');
    while ($row = mysql_fetch_assoc($buchresult)) {
        $db->query('INSERT INTO ' . DB_PRE . 'ecp_clankasse_transaktion (`geld`, `verwendung`, `datum`, `userID`) VALUES
                 (-' . $row['betrag'] . ', \'' . mysql_real_escape_string($row['verwendung']) . '\', ' . time() . ', 0)');
        $db->query('UPDATE ' . DB_PRE . 'ecp_clankasse SET kontostand = kontostand - ' . $row['betrag']);
        switch ($row['tagmonat']) {
            case 1:
                $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
                break;
            case 15:
                $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
                break;
            case 28:
                $nextdate = strtotime('+ ' . (int) $row['intervall'] . ' month');
        }
        $db->query('UPDATE ' . DB_PRE . 'ecp_clankasse_auto SET `nextbuch` = \'' . $nextdate . '\'');
    }
    $db->query('DELETE FROM ' . DB_PRE . 'ecp_forum_search WHERE datum < ' . (time() - 86400));
    $result = $db->query('SELECT COUNT(sID) as anzahl, sID FROM ' . DB_PRE . 'ecp_server_stats GROUP BY sID');
    while ($row = mysql_fetch_assoc($result)) {
        if ($row['anzahl'] > SERVER_MAX_LOG) {
            $db->query('DELETE FROM ' . DB_PRE . 'ecp_server_stats WHERE sID = ' . $row['sID'] . ' ORDER BY datum ASC LIMIT ' . ($row['anzahl'] - SERVER_MAX_LOG));
        }
    }
}
Пример #3
0
 function pquit($connection)
 {
     $ret = false;
     if (FUNC::is_connection($connection)) {
         fputs($connection, "QUIT\r\n");
         $rcv = fgets($connection, 1024);
         if (substr($rcv, 0, 3) == '+OK') {
             $ret = true;
         } else {
             trigger_error('Response error "' . $rcv . '", on class POP3::pquit()', 512);
         }
         FUNC::close($connection);
     } else {
         trigger_error('Invalid resource connection, on class POP3::pquit()', 512);
     }
     return $ret;
 }
Пример #4
0
// path to 'MAIL.php' file from XPM4 package
require_once '../MAIL.php';
// get ID value (random) for the embed image
$id = MIME::unique();
// initialize MAIL class
$m = new MAIL();
// set from address and name
$m->From('*****@*****.**', 'My Name');
// add to address and name
$m->AddTo('*****@*****.**', 'Client Name');
// set subject
$m->Subject('Hello World!');
// set text/plain version of message
$m->Text('Text version of message.');
// set text/html version of message
$m->Html('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:' . $id . '">');
// add attachment ('text/plain' file)
$m->Attach('source file', 'text/plain');
$f = 'xpertmailer.gif';
// add inline attachment '$f' file with ID '$id'
$m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'inline', $id);
// send mail
echo $m->Send('client') ? 'Mail sent !' : 'Error !';
// optional for debugging ----------------
echo '<br /><pre>';
// print History
print_r($m->History);
// calculate time
list($tm1, $ar1) = each($m->History[0]);
list($tm2, $ar2) = each($m->History[count($m->History) - 1]);
echo 'The process took: ' . (floatval($tm2) - floatval($tm1)) . ' seconds.</pre>';
Пример #5
0
$Timer1 = microtime();
$Timer1 = explode(" ", $Timer1);
$Timer1 = $Timer1[0] + $Timer1[1];
$corecalls = 0;
if ($string = ob_get_contents()) {
    session_start();
    ob_end_flush();
} else {
    session_start();
}
//--------------------------------
// Classe per funzioni globali
//--------------------------------
require "lib/functions.php";
require "core.php";
$std = new FUNC();
//classe PEAR per file config (XML)
require_once "Config.php";
$xmldata = new Config();
$root =& $xmldata->parseConfig('http://' . $_SERVER['HTTP_HOST'] . '/config/config.xml', 'XML');
if (PEAR::isError($root)) {
    $std->Error('Error reading XML config file: ' . $root->getMessage());
}
$settings = $root->toArray();
// dati del db
require_once 'ez_sql.php';
$_ENV['sql_host'] = $settings['root']['conf']['DB']['host'];
$_ENV['sql_user'] = $settings['root']['conf']['DB']['dbuser'];
$_ENV['sql_passwd'] = $settings['root']['conf']['DB']['dbpassword'];
$_ENV['sql_dbname'] = $settings['root']['conf']['DB']['dbname'];
$_ENV['sql_dbport'] = $settings['root']['conf']['DB']['dbport'];
Пример #6
0
/* Purpose:
   - set Text and HTML version of message
   - add attachment
   - embed image into HTML
*/
// manage errors
error_reporting(E_ALL);
// php errors
define('DISPLAY_XPM4_ERRORS', true);
// display XPM4 errors
//define('LOG_XPM4_ERRORS', serialize(array('type' => 1, 'destination' => '*****@*****.**', 'headers' => 'From: xpm4@domain.tld'))); // <- send mail
//define('LOG_XPM4_ERRORS', serialize(array('type' => 3, 'destination' => '/var/tmp/XPM4.log'))); // <- append file
// path to 'MIME.php' file from XPM4 package
require_once '../MIME.php';
// get ID value (random) for the embed image
$id = MIME::unique();
// set text/plain version of message
$text = MIME::message('Text version of message.', 'text/plain');
// set text/html version of message
$html = MIME::message('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:' . $id . '">', 'text/html');
// add attachment with name 'file.txt'
$at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment');
$file = 'xpertmailer.gif';
// add inline attachment '$file' with name 'XPM.gif' and ID '$id'
$at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), 'XPM.gif', null, 'base64', 'inline', $id);
// compose mail message in MIME format
$mess = MIME::compose($text, $html, $at);
// send mail
$send = mail('*****@*****.**', 'Hello World!', $mess['content'], 'From: me@myaddress.net' . "\n" . $mess['header']);
// print result
echo $send ? 'Sent !' : 'Error !';
Пример #7
0
 function mimetype($filename)
 {
     $retm = "application/octet-stream";
     $mime = array('z' => "application/x-compress", 'xls' => "application/x-excel", 'gtar' => "application/x-gtar", 'gz' => "application/x-gzip", 'cgi' => "application/x-httpd-cgi", 'php' => "application/x-httpd-php", 'js' => "application/x-javascript", 'swf' => "application/x-shockwave-flash", 'tar' => "application/x-tar", 'tgz' => "application/x-tar", 'tcl' => "application/x-tcl", 'src' => "application/x-wais-source", 'zip' => "application/zip", 'kar' => "audio/midi", 'mid' => "audio/midi", 'midi' => "audio/midi", 'mp2' => "audio/mpeg", 'mp3' => "audio/mpeg", 'mpga' => "audio/mpeg", 'ram' => "audio/x-pn-realaudio", 'rm' => "audio/x-pn-realaudio", 'rpm' => "audio/x-pn-realaudio-plugin", 'wav' => "audio/x-wav", 'bmp' => "image/bmp", 'fif' => "image/fif", 'gif' => "image/gif", 'ief' => "image/ief", 'jpe' => "image/jpeg", 'jpeg' => "image/jpeg", 'jpg' => "image/jpeg", 'png' => "image/png", 'tif' => "image/tiff", 'tiff' => "image/tiff", 'css' => "text/css", 'htm' => "text/html", 'html' => "text/html", 'txt' => "text/plain", 'rtx' => "text/richtext", 'vcf' => "text/x-vcard", 'xml' => "text/xml", 'xsl' => "text/xsl", 'mpe' => "video/mpeg", 'mpeg' => "video/mpeg", 'mpg' => "video/mpeg", 'mov' => "video/quicktime", 'qt' => "video/quicktime", 'asf' => "video/x-ms-asf", 'asx' => "video/x-ms-asf", 'avi' => "video/x-msvideo", 'vrml' => "x-world/x-vrml", 'wrl' => "x-world/x-vrml");
     if (is_string($filename)) {
         $filename = FUNC::str_clear($filename);
         $filename = trim($filename);
         if ($filename != "") {
             $expext = explode(".", $filename);
             if (count($expext) >= 2) {
                 $extnam = strtolower($expext[count($expext) - 1]);
                 if (isset($mime[$extnam])) {
                     $retm = $mime[$extnam];
                 }
             }
         } else {
             trigger_error('Invalid parameter value, on class FUNC::mimetype()', 512);
         }
     } else {
         trigger_error('Invalid parameter type value, on class FUNC::mimetype()', 512);
     }
     return $retm;
 }
Пример #8
0
if ($vssl != null && !$extensionLoaded) {
    echo 'Falha no envio. A extensão Open SSL não está habilitada no PHP.';
    exit;
}
error_reporting(E_ALL);
// manage php errors
$from = trim($user);
$to = trim($recipients);
$toArray = explode(",", $recipients);
$subj = trim($subject);
$content = trim($mailBody);
$content = nl2br($content);
$message = MIME::message($content, 'text/html', null, 'UTF-8');
$attachment = null;
foreach ($attachmentFiles as $filename => $path) {
    $attachment[] = MIME::message(file_get_contents($path), FUNC::mime_type($path), $filename, null, 'base64', 'attachment');
}
// compose message in MIME format
$mess = MIME::compose(null, $message, $attachment);
// standard mail message RFC2822
$body = 'From: ' . $from . "\r\n" . 'To: ' . $to . "\r\n" . 'Subject: ' . $subj . "\r\n" . $mess['header'] . "\r\n\r\n" . $mess['content'];
$conn = SMTP::connect($host, $port, $user, $pass, $vssl) or die('Falha na conexão - ' . print_r($_RESULT));
$sent = SMTP::send($conn, array($toArray[0]), $body, $from);
if ($sent) {
    echo 'Email enviado com sucesso!';
} else {
    echo 'Falha no envio - ' . print_r($_RESULT);
}
SMTP::disconnect($conn);
// Fecha a conexão com o banco de dados
$dataConnector->CloseConnection();