Beispiel #1
0
function uddeIMdeleteMessagePostboxMultiple($myself, $userid, $arcmes, $limit, $limitstart, $item_id, $config) {
	$n = count($arcmes);
	if (!$n) {
		echo _UDDEIM_NOMSGSELECTED."<br /><a href='javascript:history.go(-1)'>"._UDDEIM_BACK."</a>";
		return;
	}

	for ($i = 0; $i <= ($n-1); $i++) {
		$deletetime=uddetime($config->timezone);
		if ($arcmes[$i]>0) {
			$allmessages = uddeIMselectMessage($myself, $arcmes[$i], $config, $trashed=-1);
			foreach($allmessages as $themessage) {
				if ($myself==$themessage->toid && $myself!=$themessage->fromid) {
					uddeIMupdateToread($myself, $themessage->id, 1);
					uddeIMdeleteMessageFromInbox($myself, $themessage->id, $deletetime);
				} elseif ($myself==$themessage->fromid && $myself!=$themessage->toid) {
					uddeIMdeleteMessageFromOutbox($myself, $themessage->id, $deletetime);
				} else {	// this case appears when a copy to me message has been trashed my myself
					uddeIMupdateToread($myself, $themessage->id, 1);
					uddeIMdeleteMessageFromInbox($myself, $themessage->id, $deletetime);
				}
			}
		}
	}
	uddeJSEFredirect("index.php?option=com_uddeim&task=postboxuser&Itemid=".$item_id."&recip=".$userid."&limit=".$limit."&limitstart=".$limitstart);
}
Beispiel #2
0
function uddeIMdeleteInbox($myself, $item_id, $arcmes, $limit, $limitstart, $config) {
	$n = count($arcmes);
	if (!$n) {
		echo _UDDEIM_NOMSGSELECTED."<br /><a href='javascript:history.go(-1)'>"._UDDEIM_BACK."</a>";
		return;
	}
	for ($i = 0; $i <= ($n-1); $i++) {
		$rightnow=uddetime($config->timezone);
		if ($arcmes[$i]>0) {
			// uddeIMupdateToread($myself, $arcmes[$i], 1);
			uddeIMdeleteMessageFromInbox($myself, $arcmes[$i], $rightnow);
			// when it is a message from me to me and I trash the message then also trash the message from the outbox
//			$sql="UPDATE #__uddeim SET totrashoutbox=1, totrashdateoutbox=".$rightnow." WHERE toid=fromid AND toid=".(int)$myself." AND id=".(int)$arcmes[$i];
//			$___atabase->setQuery($sql);
//			if (!$___atabase->query()) {
//				die("SQL error when attempting to trash a message" . $___atabase->stderr(true));
//			}
		}
	}
	uddeJSEFredirect("index.php?option=com_uddeim&task=inbox&Itemid=".$item_id."&limit=".$limit."&limitstart=".$limitstart);
}
Beispiel #3
0
function uddeIMtoPublicSaveMessage($myself, $pmessage, $tobedeleted, $tobedeletedsent, $forceembedded, $item_id, $messageid, $copytome, $cryptpass, $backto, $config) {
	$mosConfig_sitename = uddeIMgetSitename();
	$pathtosite  = uddeIMgetPath('live_site');

	$database = uddeIMgetDatabase();
	$my_gid = $config->usergid;

	if($config->inboxlimit) {
		if ($config->allowarchive) {		// have an archive and an "archive and inbox" limit, so get number of messages in inbox and archive
			$total = uddeIMgetInboxArchiveCount($myself);
		} else {							// user has switched of archive but there is an limit for "inbox and archive", so count inbox messages only
			$total = uddeIMgetInboxCount($myself);
		}
		if($total>$config->maxarchive && !uddeIMisAdmin($my_gid) && !uddeIMisAdmin2($my_gid, $config)) {
			$mosmsg=_UDDEIM_MSGLIMITREACHED;
			uddeJSEFredirect("index.php?option=com_uddeim&task=inbox&Itemid=".$item_id, $mosmsg);
		}
	}

	$lastsent = uddeIMgetEMNlastsent($myself);
	$flooding = 0;
	if ($config->timedelay>0) {
		if (uddeIMisReggedOnly($config->usergid)) {
			if ($lastsent) {
				$delay = uddetime($config->timezone) - $lastsent;
				if ($delay <= $config->timedelay)
					$flooding = 1;
			}
		}
	}
	if($flooding) {
		// write the uddeim menu
		uddeIMprintMenu($myself, 'new', $item_id, $config);
		echo "<div id='uddeim-m'>\n";
		$pmessage=stripslashes($pmessage);
		uddeIMdrawWriteform($myself, $my_gid, $item_id, "", "", $pmessage, $messageid, 1, 14, 0, $config);	// reply!!!
		echo "</div>\n<div id='uddeim-bottomborder'>".uddeIMcontentBottomborder($myself, $item_id, 'standard', 'none', $config)."</div>\n";
		return;
	}
	
	// select the message I write a reply to
	// I need the email address and the sender name of the public user (the message id is $messageid and I am $myself)
	// das war vorher... a.toid=b.id??? richtig sollte a.fromid=b.id sein, also selectInboxMessage nehmen
	// $sql = "SELECT a.*, b.".($config->realnames ? "name" : "username")." AS fromname FROM #__uddeim AS a LEFT JOIN #__users AS b ON a.toid=b.id WHERE a.toid=".(int)$myself." AND a.id=".(int)$messageid;
	$displaymessages = 	uddeIMselectInboxMessage($myself, $messageid, $config);
	if (count($displaymessages)<1) {
		echo _UDDEIM_MESSAGENOACCESS;
		return;
	}
	foreach($displaymessages as $displaymessage) {
		$var_toname = $displaymessage->publicname;
		$var_tomail = $displaymessage->publicemail;
	}
	if (!$var_toname || $var_toname==NULL)
		$var_toname = _UDDEIM_PUBLICUSER;
	
	if(!$pmessage) {
		// write the uddeim menu
		uddeIMprintMenu($myself, 'new', $item_id, $config);
		echo "<div id='uddeim-m'>\n";
		$pmessage=stripslashes($pmessage);
		uddeIMdrawWriteform($myself, $my_gid, $item_id, "", "", $pmessage, $messageid, 1, 4, 0, $config);	// reply!!!
		echo "</div>\n<div id='uddeim-bottomborder'>".uddeIMcontentBottomborder($myself, $item_id, 'standard', 'none', $config)."</div>\n";
		return;
	}

	// CAPTCHA (first check for all other errors and then the CAPTCHA)
	if (!uddeIMcheckCAPTCHA($my_gid, $config)) {
		uddeIMprintMenu($myself, 'new', $item_id, $config);
		echo "<div id='uddeim-m'>\n";
		$pmessage=stripslashes($pmessage);
		uddeIMdrawWriteform($myself, $my_gid, $item_id, "", "", $pmessage, $messageid, 1, 7, 0, $config);	// reply!!!
		echo "</div>\n<div id='uddeim-bottomborder'>".uddeIMcontentBottomborder($myself, $item_id, 'standard', 'none', $config)."</div>\n";
		return;
	}

	if (!uddeIMcheckCSRF($config)) {
		uddeIMprintMenu($myself, 'new', $item_id, $config);
		echo "<div id='uddeim-m'>\n";
		$pmessage=stripslashes($pmessage);
		uddeIMdrawWriteform($myself, $my_gid, $item_id, "", "", $pmessage, $messageid, 1, 15, 0, $config);	// reply!!!
		echo "</div>\n<div id='uddeim-bottomborder'>".uddeIMcontentBottomborder($myself, $item_id, 'standard', 'none', $config)."</div>\n";
		return;
	}

	$savedatum  = uddetime($config->timezone);
	$savetoid   = 0;			// reveiver is a public user

	// CRYPT
	if ($config->cryptmode>=1) {	// because of encoding do not use slashes
		$savemessage=strip_tags($pmessage);
	} else {
		$savemessage=addslashes(strip_tags($pmessage));   // original 0.6+
	}
	// strip XSS code
	$savemessage = uddeIMRemoveXSS($savemessage);

	// strip bbcodes
	if (!$config->allowbb)
		$savemessage=uddeIMbbcode_strip($savemessage);

	// set message max length
	if ($config->maxlength>0)		// because if 0 do not use any maxlength
		$savemessage=uddeIM_utf8_substr($config->languagecharset, $savemessage, 0, $config->maxlength);

	uddeIMemit("onSavePublicMessage", Array( "fromid" => $myself, "toid" => $savetoid, "replyid" => $replyid ) );
	// we have all we need, now save it
	// CRYPT
	// maybe its an reply to a message from a public user
	$replyid = $messageid;
	$fromname=addslashes(strip_tags($var_toname));
	$fromemail=addslashes(strip_tags($var_tomail));
	if ($config->cryptmode==1) {
		$cm = uddeIMencrypt($savemessage,$config->cryptkey,CRYPT_MODE_BASE64);
		$sql="INSERT INTO #__uddeim (publicname, publicemail, fromid, toid, replyid, message, datum, totrash, totrashdate, toread, cryptmode, crypthash) VALUES ('".$fromname."', '".$fromemail."', ".(int)$myself.", ".(int)$savetoid.", ".(int)$replyid.", '".$cm."', ".$savedatum.",1,".$savedatum.",1,1,'".md5($config->cryptkey)."')";
	} elseif ($config->cryptmode==2) {
		$themode=2;
		$thepass=$cryptpass;
		if (!$thepass) {	// no password entered, then fallback to obfuscating
			$themode=1;
			$thepass=$config->cryptkey;
		}
		$cm = uddeIMencrypt($savemessage,$thepass,CRYPT_MODE_BASE64);
		$sql="INSERT INTO #__uddeim (publicname, publicemail, fromid, toid, replyid, message, datum, totrash, totrashdate, toread, cryptmode, crypthash) VALUES ('".$fromname."', '".$fromemail."', ".(int)$myself.", ".(int)$savetoid.", ".(int)$replyid.", '".$cm."', ".$savedatum.",1,".$savedatum.",1,".$themode.",'".md5($thepass)."')";
	} elseif ($config->cryptmode==3) {
		$cm = uddeIMencrypt($savemessage,"",CRYPT_MODE_STOREBASE64);
		$sql="INSERT INTO #__uddeim (publicname, publicemail, fromid, toid, replyid, message, datum, totrash, totrashdate, toread, cryptmode) VALUES ('".$fromname."', '".$fromemail."', ".(int)$myself.", ".(int)$savetoid.", ".(int)$replyid.", '".$cm."', ".$savedatum.",1,".$savedatum.",1,3)";
	} elseif ($config->cryptmode==4) {
		$themode=4;
		$thepass=$cryptpass;
		$cipher = CRYPT_MODE_3DESBASE64;
		if (!$thepass) {	// no password entered, then fallback to obfuscating
			$themode=1;
			$thepass=$config->cryptkey;
			$cipher = CRYPT_MODE_BASE64;
		}
		$cm = uddeIMencrypt($savemessage,$thepass,$cipher);
		$sql="INSERT INTO #__uddeim (publicname, publicemail, fromid, toid, replyid, message, datum, totrash, totrashdate, toread, cryptmode, crypthash) VALUES ('".$fromname."', '".$fromemail."', ".(int)$myself.", ".(int)$savetoid.", ".(int)$replyid.", '".$cm."', ".$savedatum.",1,".$savedatum.",1,".$themode.",'".md5($thepass)."')";
	} else {
		$sql="INSERT INTO #__uddeim (publicname, publicemail, fromid, toid, replyid, message, datum, totrash, totrashdate, toread) VALUES ('".$fromname."', '".$fromemail."', ".(int)$myself.", ".(int)$savetoid.", ".(int)$replyid.", '".$savemessage."', ".$savedatum.",1,".$savedatum.",1)";
	}
	$database->setQuery($sql);
	if (!$database->query()) {
		die("SQL error when attempting to save a message" . $database->stderr(true));
	}
	$insID = $database->insertid();

	// update lastsent field (record already exists since we check this at the very beginning of this component)
	uddeIMupdateEMNlastsent($myself, uddetime($config->timezone));

	// copy to myself?
	if($copytome && $config->allowcopytome) {

		$temp = (($config->cryptmode>=1) ? $var_toname : addslashes($var_toname));
		if ($config->allowbb)
			$copyheader="\n\n[i]("._UDDEIM_THISISACOPY.$temp.")[/i]";
		else
			$copyheader="\n\n("._UDDEIM_THISISACOPY.$temp.")";

		// also copy2me messages can be replies
		$replyid = $messageid;
		$savemessagecopy = $savemessage.$copyheader;
		$copyname = _UDDEIM_TO_SMALL." ".$temp;			// "to username" in systemmsg
		// if($config->allowarchive) { $archiveflag=1; }

		// it is a copy to myself, so assume that the message has already been trashed in the senders outbox (remember: system messages are not shown in the outbox)
		// so set totrashoutbox=1, totrashdateoutbox=uddetime($config->timezone)
		// CRYPT
		if ($config->cryptmode==1) {
			$cm = uddeIMencrypt($savemessagecopy,$config->cryptkey,CRYPT_MODE_BASE64);
			$sql="INSERT INTO #__uddeim (fromid, toid, replyid, toread, message, datum, disablereply, systemflag, systemmessage, archived, totrashoutbox, totrashdateoutbox, cryptmode, crypthash) VALUES (".(int)$myself.", ".(int)$myself.", ".(int)$replyid.", 1, '".$cm."', ".$savedatum.", 1, 2, '".$copyname."', 0, 1,".$savedatum.",1,'".md5($config->cryptkey)."')";
		} elseif ($config->cryptmode==2) {
			$themode=2;
			$thepass=$cryptpass;
			if (!$thepass) {	// no password entered, then fallback to obfuscating
				$themode=1;
				$thepass=$config->cryptkey;
			}
			$cm = uddeIMencrypt($savemessagecopy,$thepass,CRYPT_MODE_BASE64);
			$sql="INSERT INTO #__uddeim (fromid, toid, replyid, toread, message, datum, disablereply, systemflag, systemmessage, archived, totrashoutbox, totrashdateoutbox, cryptmode, crypthash) VALUES (".(int)$myself.", ".(int)$myself.", ".(int)$replyid.", 1, '".$cm.             "', ".$savedatum.", 1, 2, '".$copyname."', 0, 1,".$savedatum.",".$themode.",'".md5($thepass)."')";
		} elseif ($config->cryptmode==3) {
			$cm = uddeIMencrypt($savemessagecopy,"",CRYPT_MODE_STOREBASE64);
			$sql="INSERT INTO #__uddeim (fromid, toid, replyid, toread, message, datum, disablereply, systemflag, systemmessage, archived, totrashoutbox, totrashdateoutbox, cryptmode) VALUES (".(int)$myself.", ".(int)$myself.", ".(int)$replyid.", 1, '".$cm."', ".$savedatum.", 1, 2, '".$copyname."', 0, 1,".$savedatum.",3)";
		} elseif ($config->cryptmode==4) {
			$themode=4;
			$thepass=$cryptpass;
			$cipher = CRYPT_MODE_3DESBASE64;
			if (!$thepass) {	// no password entered, then fallback to obfuscating
				$themode=1;
				$thepass=$config->cryptkey;
				$cipher = CRYPT_MODE_BASE64;
			}
			$cm = uddeIMencrypt($savemessagecopy,$thepass,$cipher);
			$sql="INSERT INTO #__uddeim (fromid, toid, replyid, toread, message, datum, disablereply, systemflag, systemmessage, archived, totrashoutbox, totrashdateoutbox, cryptmode, crypthash) VALUES (".(int)$myself.", ".(int)$myself.", ".(int)$replyid.", 1, '".$cm.             "', ".$savedatum.", 1, 2, '".$copyname."', 0, 1,".$savedatum.",".$themode.",'".md5($thepass)."')";
		} else {
			$sql="INSERT INTO #__uddeim (fromid, toid, replyid, toread, message, datum, disablereply, systemflag, systemmessage, archived, totrashoutbox, totrashdateoutbox) VALUES (".(int)$myself.", ".(int)$myself.", ".(int)$replyid.", 1, '".$savemessagecopy."', ".$savedatum.", 1, 2, '".$copyname."', 0, 1,".$savedatum.")";
		}
		$database->setQuery($sql);
		if (!$database->query()) {
			die("SQL error when attempting to save a message" . $database->stderr(true));
		}
	}

	// send notification (message) to public user
	// check if we have an email address
	//	uddeIMdispatchEMN(msgid, $myself, 0, $savemessage, 0, $config);
	// if e-mail traffic stopped, don't send.
	if($config->emailtrafficenabled && $var_tomail) {

		$var_fromname = uddeIMgetNameFromID($myself, $config);
		if (!$var_fromname)
			$var_fromname=$config->sysm_username;

		$var_body = _UDDEIM_EMN_BODY_PUBLICWITHMESSAGE;
		$var_body = str_replace("%livesite%", $pathtosite, $var_body);
		$var_body = str_replace("%you%", $var_toname, $var_body);
		$var_body = str_replace("%site%", $mosConfig_sitename, $var_body);
		$var_body = str_replace("%user%", $var_fromname, $var_body);
		$var_body = str_replace("%pmessage%", $savemessage, $var_body);

		$subject = _UDDEIM_EMN_SUBJECT;
		$subject = str_replace("%livesite%", $pathtosite, $subject);
		$subject = str_replace("%site%", $mosConfig_sitename, $subject);
		$subject = str_replace("%you%", $var_toname, $subject);
		$subject = str_replace("%user%", $var_fromname, $subject);

		$replyto = $var_tomail;
		$replytoname = "";

		if(uddeIMsendmail($config->emn_sendername, $config->emn_sendermail, $var_toname, $var_tomail, $subject, $var_body, $replyto, $replytoname, "", $config)) {
			// maybe a code here that the email cound not have been sent
		}
	}

	if ($tobedeletedsent) {
		$deletetime=uddetime($config->timezone);
		uddeIMdeleteMessageFromOutbox($myself, $insID, $deletetime);
	}

	// delete the original message?
	if ($tobedeleted) {
		$deletetime=uddetime($config->timezone);
		uddeIMdeleteMessageFromInbox($myself, $messageid, $deletetime);
	}

	if($messageid) {
		$mosmsg=_UDDEIM_MESSAGE_REPLIEDTO;
	} else {
		$mosmsg=_UDDEIM_MESSAGE_SENT;
	}
	if ($tobedeleted) {
		$mosmsg.=_UDDEIM_MOVEDTOTRASH;
	}

	if($backto) {
		uddeIMmosRedirect($backto, $mosmsg);
	}
	uddeJSEFredirect("index.php?option=com_uddeim&task=inbox&Itemid=".$item_id, $mosmsg);
}