Beschreibung:
Aaaaalso, mit dieser neuen Funktion möchte ich nun endlich meinen Einstieg in die LotGD Community zurück heißen. Und veröffentlichte d.h. eine brandneue Systemmitteilungs Funktion. Eine Beschreibung wie man das ganze nutzt, ist natürlich direkt am anfang unter example erklärt.
Installation:
Datei: common.php
Suche:
[php]<?php
function systemmail($to,$subject,$body,$from=0,$noemail=false){
$subject = safeescape($subject);
$subject=str_replace("\n","",$subject);
$subject=str_replace("`n","",$subject);
$body = safeescape($body);
//echo $subject."<br>".$body;
$sql = "SELECT prefs,emailaddress FROM accounts WHERE acctid='$to'";
$result = db_query($sql);
$row = db_fetch_assoc($result);
db_free_result($result);
$prefs = unserialize($row['prefs']);
if ($prefs['dirtyemail']){
//output("Not cleaning: $prefs[dirtyemail]");
}else{
//output("Cleaning: $prefs[dirtyemail]");
$subject=soap($subject);
$body=soap($body);
}
$sql = "INSERT INTO mail (msgfrom,msgto,subject,body,sent) VALUES ('".(int)$from."','".(int)$to."','$subject','$body',now())";
db_query($sql);
$email=false;
if ($prefs['emailonmail'] && $from>0){
$email=true;
}elseif($prefs[emailonmail] && $from==0 && $prefs[systemmail]){
$email=true;
}
if (!is_email($row['emailaddress'])) $email=false;
if ($email && !$noemail){
$sql = "SELECT name FROM accounts WHERE acctid='$from'";
$result = db_query($sql);
$row1=db_fetch_assoc($result);
db_free_result($result);
if ($row1['name']!="") $fromline="From: ".preg_replace("'[`].'","",$row1[name])."\n";
// We've inserted it into the database, so.. strip out any formatting
// codes from the actual email we send out... they make things
// unreadable
$body = preg_replace("'[`]n'", "\n", $body);
$body = preg_replace("'[`].'", "", $body);
mail($row['emailaddress'],"Neue LoGD Mail","Du hast eine neue Nachricht von LoGD @
http://".$_SERVER[HTTP_HOST].dirname($_SERVER[SCRIPT_NAME])." empfangen.\n\n$fromline"
."Betreff: ".preg_replace("'[`].'","",stripslashes($subject))."\n"
."Body: ".stripslashes($body)."\n"
."\nDu kannst diese Meldungen in deinen Einstellungen abschalten.",
"From: ".getsetting("gameadminemail","postmaster@localhost")
);
}
}
?>[/php]
Ersetze durch:
[php]<?php
/**
*
* Systemmail, again revision with Kevz personal.
*
* @author Kevz
* @version 1.0.0
* @copyright 2007 Kevz
* @link
http://www.lotgd.dyndns.biz/
*
* @desc The function makes it possible to
* implement on the basis the parameters
* different possibilities.
* Among other things also the dispatch of
* HTML eMails and better execution by owing
* to code the optimization of me.
*
* @example Private message dispatch, WITHOUT eMail dispatch:
* <code>
* systemmail('MySubject', 'MyBodyText', $receiverAcctID, $senderAcctID);
* </code>
*
* Private message dispatch, WITH email dispatch:
* <code>
* systemmail('MySubject', 'MyBodyText', $receiverAcctID, $senderAcctID, 'Server Name', true);
* </code>
*
*/
function systemmail() {
$args = func_get_args();
$last = array_pop($args);
$eMail = false;
// The last operation element examined
// always whether eMail a course and to
// become is or not!
// * Examine whether eMail send or not
// * Examines how many function parameters is available
if ( !is_bool($last) && func_num_args() < 5 ) {
$eMailSend = false;
// If operation element of only four
// or fewer elements possesses the
// author in the array back adds.
// * Author only in the array back insert,
// if four parameters are present.
array_push($args, $last);
}
elseif ( is_string($last) ) {
$eMailSend = false;
}
elseif ( func_num_args() == 5 ) {
$eMailSend = false;
}
else {
$eMailSend = true;
// The server title Backslashes
// add as well as again remove.
$args[4] = addslashes(stripslashes($args[4]));
}
// Finely tuning the private message!
// * too many Backslashes remove
// * too many single quotes remove
$mailSubject = safeescape($args[0]);
$mailSubject = str_ireplace(array('\n', '`n'), '', $mailSubject);
$mailBody = safeescape($args[1]);
//$mailBody = $mailBody = preg_replace("/\<br(.*?)\>/si", '', $mailBody);
// Examines whether the player is present,
// at whom the private message is to be sent.
$sql = 'SELECT
`prefs`
,`emailaddress`
FROM
`accounts`
WHERE
`acctid` = '.(int)$args[2];
$result = db_query($sql) or die(db_error($sql));
// Examine whether the indicated
// receiver is available.
// *The expenditure to the variable leave
// * Occupied memory (resources) again releases
if ( db_num_rows($result) ) {
$Player = &db_fetch_assoc($result);
}
db_free_result($result);
// Personal players characteristics
// concerning to personal message of
// the filter and among other things
// email send.
// * The stored data formats into a PHP value produce
// * Examine whether private message filter is activated
$prefs = unserialize($Player['prefs']);
if ( !$prefs['dirtyemail'] ) {
$mailSubject = soap($mailSubject);
$mailBody = soap($mailBody);
}
// The topic and the text Backslashes
// add and again remove.
$mailSubject = addslashes(stripslashes($mailSubject));
$mailBody = addslashes(stripslashes($mailBody));
// The private message to the player
// send, if it is available!
// * Add Backslashes in the text.
// * Remove Backslashes in the text.
if ( is_array($Player) ) {
$sql = 'INSERT INTO `mail`
(`subject`
,`body`
,`msgto`
,`msgfrom`
,`sent`
)
VALUES
("'.$mailSubject.'"
,"'.$mailBody.'"
,'.(int)$args[2].'
,'.(int)$args[3].'
,NOW()
)
';
db_query($sql);
// Examine whether the player eMail
// an address indicated. Subsequently,
// examine it email with private messages
// or reports of system received would like.
if ( $prefs['emailonmail'] && $args[3] ) {
$eMail = true;
}
elseif ( $prefs['emailonmail'] && !$args[3] && $prefs['systemmail']) {
$eMail = true;
}
elseif ( !is_email($Player['emailaddress']) ) {
$eMail = false;
}
// eMail to the player pass on,
// if it received a private message
// or a system averaging.
// * Apostrophe grave accent removing
// * Single Quotes removing
// * Occupied memory (resources) again releases
if ($eMail && $eMailSend){
$sql = 'SELECT
`name`
FROM
`accounts`
WHERE
`acctid` = '.(int)$args[3];
$result = db_query($sql);
if ( db_num_rows($result) ) {
$row = &db_fetch_assoc($result);
}
db_free_result($result);
// Sender (player) name select
// and color codes remove.
// * Remove color codes
if ($row['name'] > '') {
$senderLine = "Absender: ".preg_replace("'[`].'", '', $row['name'])."<br />\n";
}
// The topic and text contents
// on bad indications examining
// and remove.
$mailSubject = preg_replace("'[`].'", "", $mailSubject);
$mailBody = preg_replace("'[`].'", "", $mailBody);
$mailBody = preg_replace("'[`]n'", "\n", $mailBody);
// The eMail for the player
// prepare and to end script
// of the run dispatch.
mail($Player['emailaddress']
,'Neue LotGD Mail erhalten!'
,'Du hast eine neue Nachricht auf dem LotGD Server '
."(<a href=\"http://".getenv('HTTP_HOST').dirname(getenv('SCRIPT_NAME'))."\">{$args[4]}</a>) empfangen. "
."<br /><br />\n\n{$senderLine}Betreff: <b>{$mailSubject}</b><br />\nText: <br />\n<i>{$mailBody}</i><br /><br /><br />\n\n\n"
."<i>Du kannst diese Meldungen in deinen Profil Einstellungen abschalten.</i>"
,"MIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\n"
."From: LotGD Server ({$args[4]}) <".getsetting('gameadminemail', 'postmaster@localhost').">"
);
}
// After variable one end
// the Scripts delete!
unset($sql, $result, $eMail
,$eMailSend, $args, $senderLine
,$mailSubject, $mailBody, $last
);
}
}
?>[/php]
Feedback sowie Kritik & Verbesserungsvorschläge sind natürlich erwünscht!