");
include_once("modules/" . $GLOBALS["module_name"] . "/config.php");
include_once("modules/" . $GLOBALS["module_name"] . "/bbfunctions.php");
include_once("modules/" . $GLOBALS["module_name"] . "/functions.php");
mxGetLangfile($GLOBALS["module_name"]);
$GLOBALS["userinfo"] = array();
$totalmembers = 0;
if (!MX_IS_USER) {
notloggedin();
exit;
}
$GLOBALS["userinfo"] = mxGetUserData();
// SQL-bedingung fuer excluded Users erstellen
$exusers = explode (",", $GLOBALS["excludedusers"]);
if (!MX_IS_ADMIN) {
while (list($key, $val) = each($exusers)) {
$xexusers[] = trim($val);
}
}
$xexusers[] = $GLOBALS['anonymous'];
$GLOBALS["excludedusers"] = "'" . implode("','", mxAddSlashesForSQL($xexusers)) . "'";
function create_headerforall($pagetitle)
{
global $bgcolor2, $textcolor2, $ThemeSel;
echo "\n";
echo "\n
\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
echo "" . $pagetitle . "\n";
echo '', "\n";
echo '', "\n";
}
function create_bodyforall($extensions = "") // schliesst und oeffnet
{
echo "\n", '', "\n";
}
function pmSetOnline() // schliesst und oeffnet
{
global $prefix, $user_prefix;
$last = mxSessionGetVar("lasttime"); // Zurücksetzen, damit Online ausgeführt wird
$past = time() - MX_SETINACTIVE_MINS ;
// $GLOBALS["mxSqlDebug"] = 1;
if ($last <= $past) {
if ($GLOBALS["dbtype"] == "MySQL") sql_query("LOCK TABLES {$user_prefix}_users WRITE");
$qry = "UPDATE {$user_prefix}_users set user_lastvisit=" . time() . " where uname='" . mxAddSlashesForSQL($GLOBALS['userinfo']['uname']) . "'";
$result = sql_query($qry);
if ($GLOBALS["dbtype"] == "MySQL") sql_query("UNLOCK TABLES");
mxSessionSetVar("lasttime", time());
}
}
function get_userslist($mode)
{
global $prefix, $user_prefix;
if ($mode == "all") {
$qry = "SELECT DISTINCT a.aid, u.uname
FROM {$user_prefix}_users AS u
LEFT JOIN ${prefix}_authors AS a
ON u.uid = a.user_uid
WHERE u.uname Not In (" . $GLOBALS["excludedusers"] . ") AND u.user_stat=1;";
} else {
pmSetOnline();
$past = time() - MX_SETINACTIVE_MINS ;
$qry = "SELECT DISTINCTROW a.aid, u.uname
FROM {$user_prefix}_users AS u
LEFT JOIN ${prefix}_authors AS a
ON u.uid = a.user_uid
WHERE (((u.uname) Not In (" . $GLOBALS["excludedusers"] . ")
And (u.uname) Is Not Null)
AND (u.user_stat=1)
AND (u.user_lastvisit >= " . $past . ")
AND (u.user_lastmod<>'logout'));";
}
$result = sql_query($qry);
while (list($adminname, $uname) = sql_fetch_row($result)) {
$showname = (empty($adminname)) ? $uname : " " . $adminname . " " . $GLOBALS["showAdminPrefix"];
$showname = mxCutString($showname, 20, "..", ""); # Kurzen Usernamen erstellen
$out[ucfirst($showname) . " "] = $uname;
}
if (isset($out)) {
ksort($out);
return $out;
} else {
return array();
}
}
function create_footerforall()
{
echo "\n";
}
function compose($to, $subject, $to_userid = 0)
{
global $module_name, $bgcolor1, $bgcolor2, $textcolor1, $textcolor2, $prefix, $user_prefix;
$selectfield = "subject";
if (empty($to_userid)) {
$res = sql_query("SELECT uid, uname FROM {$user_prefix}_users WHERE uname='" . mxAddSlashesForSQL($to) . "'");
list($to_userid, $to_user) = sql_fetch_row($res);
}
if ($subject) {
$subject = mxStripSlashes($subject);
$subject = msg_desmile($subject);
$subject = str_replace("" . _PMSRE . ": " . _PMSRE . ": ", _PMSRE . ": ", $subject);
$selectfield = "msg_text";
}
$extensions = " onload=\"document.pmsubmit." . $selectfield . ".focus(); document.pmsubmit." . $selectfield . ".select();\"";
create_headerforall(_PMSTITLE);
create_bodyforall($extensions);
/* PM Begrenzung */
global $url_images;
$status = mxPmBoxstatus();
$sendbox = $status['send'];
if ($sendbox['limit'] && $sendbox['error']) {
echo "
" . _SENTPMBOXVOLL . "";
create_footerforall();
exit;
}
$status = mxPmBoxstatus($to_userid);
$getbox_recipient = $status['get'];
if ($getbox_recipient['limit'] && $getbox_recipient['error']) {
echo "
" . _EMPFPMBOXVOLL . "";
create_footerforall();
exit;
}
/* Ende PM Begrenzung */
echo "
';
create_footerforall();
}
function sendm($to, $to_userid, $msg_text, $subject)
{
global $bgcolor1, $bgcolor2, $textcolor1, $textcolor2, $prefix, $user_prefix;
/* Senderdaten */
$sender = mxGetUserData();
/* Empfaengerdaten */
$recipient = mxGetUserDataFromUid($to_userid);
/* PM Begrenzung */
global $url_images;
$status = mxPmBoxstatus($recipient['uid']);
$getbox_recipient = $status['get'];
$status = mxPmBoxstatus($sender['uid']);
$sendbox = $status['send'];
/* Ende PM Begrenzung */
$timeout = 15000;
switch (true) {
case empty($recipient['uid']):
$msg = _ERRMSGNOUSER;
break;
case (!$msg_text):
$msg = _ERRMSGNOMESSAGE;
break;
case mxPmIsRecipientIgnored($recipient['uid'], $sender['uid']):
/* ignore Funktion */
$msg = $recipient['uname'] . ' ' . _NOMESSAGE;
break;
case ($getbox_recipient['limit'] && $getbox_recipient['error']):
/* PM Begrenzung */
$msg = _EMPFPMBOXVOLL;
break;
case ($sendbox['limit'] && $sendbox['error']):
/* PM Begrenzung */
$msg = _SENTPMBOXVOLL;
break;
default:
$subject = strip_tags($subject);
if (!$subject) {
$subject = _PMNOSUBJECT;
}
$qry = "INSERT INTO {$prefix}_priv_msgs (msg_image, subject, from_userid, to_userid, msg_time, msg_text)
VALUES ('" . mxAddSlashesForSQL($GLOBALS["subjectdefaulticon"]) . "', '" . mxAddSlashesForSQL($subject) . "', '" . intval($sender["uid"]) . "', '" . intval($to_userid) . "', now(), '" . mxAddSlashesForSQL($msg_text) . "')";
if (sql_query($qry)) {
$msg = _PMSSENDED1 . " " . $to . " " . _PMSSENDED2;
$timeout = 1000;
/* Gesendete PM´S speichern */
if (isset($_POST['save_copy'])) {
$newid = sql_insert_id();
$qry = "INSERT INTO {$prefix}_priv_msgs_send (msg_id, msg_image, subject, from_userid, to_userid, msg_time, msg_text)
VALUES (" . intval($newid) . ", '" . mxAddSlashesForSQL($GLOBALS["subjectdefaulticon"]) . "', '" . mxAddSlashesForSQL($subject) . "', '" . intval($sender["uid"]) . "', '" . intval($to_userid) . "', now(), '" . mxAddSlashesForSQL($msg_text) . "')";
$qry = sql_query($qry);
// mxDebugFuncVars(intval($qry));
}
/* Email bei neuer PN wenn User offline ist */
mxPmMailNote($recipient, $sender);
} else {
$msg = _PMSBUDDYERROR;
if (MX_IS_ADMIN) {
$msg .= '
' . mysql_error();
}
}
}
create_headerforall(_PMSTITLE);
create_bodyforall();
echo "
\n";
echo "\n";
create_footerforall();
}
function readm($msg_id)
{
global $bgcolor1, $bgcolor2, $textcolor1, $textcolor2, $prefix, $user_prefix;
$msg_id = (int)$msg_id;
$qry = "SELECT p.*, UNIX_TIMESTAMP(p.msg_time) as msgtimestamp , u.uname, u.user_avatar
FROM {$prefix}_priv_msgs AS p
LEFT JOIN {$user_prefix}_users AS u
ON p.from_userid = u.uid
WHERE (msg_id=$msg_id)
AND (to_userid=" . intval($GLOBALS["userinfo"]["uid"]) . ")
";
$result = sql_query($qry);
$row = sql_fetch_array($result);
if (empty($row["msg_id"])) { // falls Nachricht in Zwischenzeit geloescht..
closewindow();
} else {
$delcheck = (MX_IS_ADMIN) ? '' : ' checked="checked"';
$replysubject = msg_desmile($row["subject"]);
$row["subject"] = strip_tags($row["subject"]);
$row["subject"] = msg_smile($row["subject"]);
$row["msg_text"] = pmPrepDisplay($row["msg_text"]);
$row["msgtimestamp"] = mx_strftime(_PMSTIMESTRING, $row["msgtimestamp"]);
sql_query("UPDATE {$prefix}_priv_msgs SET read_msg='1' WHERE msg_id='" . $row["msg_id"] . "'");
create_headerforall(_PMSTITLE);
create_bodyforall();
echo "\n";
echo " \n" . _PMSINCOME . " " . $row["uname"] . "
\n";
echo "\n";
echo '' . mxCreateImage($GLOBALS['url_icons'] . '/' . $row['msg_image'], '', 0, 'align="left"') . '' . _PMSSUBJECT . ': | ' . msg_smile($row['subject']) . ' | ';
echo "" . _PMSMESSAGE . ": | \n\n" . $row["msg_text"] . " | \n \n";
echo "" . _PMSSENT . ": | \n\n" . $row["msgtimestamp"] . " | \n \n";
echo " \n";
// Buttons
echo "\n";
echo " | \n
\n
\n";
create_footerforall();
}
}
function checkmsg()
{
global $prefix;
if (!MX_IS_USER) return;
$left = 390;
$top = 150;
$qry = "SELECT msg_id, from_userid FROM {$prefix}_priv_msgs WHERE (to_userid='" . intval($GLOBALS["userinfo"]["uid"]) . "') AND (read_msg='0');";
$result = sql_query($qry);
while (list($msg_id, $from_userid) = sql_fetch_row($result)) {
if (empty($from_userid)) { // fehlerhaft gesendete Messages loeschen
$qry = "DELETE FROM {$prefix}_priv_msgs WHERE (from_userid is null or from_userid <=1);";
sql_query($qry);
}
if (!empty($msg_id)) {
echo "\n";
$left = $left + 20;
$top = $top + 20;
}
}
}
function onlycheckmsg($refreshtime)
{
if (!MX_IS_USER) return;
echo "\n";
echo "check-pm\n";
echo "\n";
echo "\n";
echo "\n";
echo "\n";
if ($refreshtime > 0) {
pmSetOnline();
create_refreshJS($refreshtime);
}
checkmsg();
echo "\n\n";
}
function create_composeJS()
{
echo "
\n";
}
function buddy($mode = "online")
{
global $bgcolor1, $bgcolor2, $textcolor1, $textcolor2, $prefix, $user_prefix;
$filebuddyfoot = "modules.php?name=" . $GLOBALS["module_name"] . "&file=buddy&op=check&ref_intervall=" . $GLOBALS["buddycheckpm"];
if ($mode == "online") {
$img = mxCreateImage($GLOBALS['url_images'] . '/guy_hand.gif', _PMSNOWON, 0, 'align="middle" style="background-color: transparent;"') . mxCreateImage($GLOBALS['url_images'] . '/girl_hand.gif', _PMSNOWON, 0, 'align="middle" style="background-color: transparent;"');
$linking = "" . _PMSNOWON . "" . $img . " | " . _PMSALLUSERS . "";
$winheigth = 290;
} else {
$img = mxCreateImage($GLOBALS['url_images'] . '/people.gif', _PMSALLUSERS, 0, 'align="middle" style="background-color: transparent;"');
$linking = "" . _PMSALLUSERS . " | " . $img . " | " . _PMSNOWON . "";
$winheigth = 350;
}
$listing = get_userslist($mode);
$ref = "";
foreach($listing as $showname => $uname) {
$newref = substr($showname, 0, 1);
$newref = ($newref == " ") ? "Admins" : $newref;
$link = "";
if ($ref != $newref) {
$ref = $newref;
$refs[] = "" . $newref . "";
$link = " name=\"" . $newref . "\"";
}
$out[] = " " . $showname . "";
}
$listing = "";
if (isset($out)) {
$listing = implode("\n", $out);
$ref = implode(" \n", $refs);
}
create_headerforall($GLOBALS["sitename"]);
create_composeJS();
create_bodyforall(); # style="width: 100%; height: 100%; overflow : auto;"
$jsvar = (isset($_REQUEST['noresize'])) ? '' : '&noresize=1';
if ($mode == "online") {
?>
\n\n\n\n\n\n";
die();
}
function create_refreshJS($refreshtime)
{
$content = "";
if ($refreshtime > 0) {
$content .= "\n";
}
echo $content;
}
function notloggedin()
{
global $url_images;
create_headerforall(_PMSTITLE);
create_bodyforall();
echo "\n
\n
" . _PMSPLSLOGIN . "!
\n";
echo '' . mxCreateImage($url_images . '/cancel.png', '', 0, 'style="background-color: transparent;"') . ' ' . _PMSCLOSE . '
';
create_footerforall();
die("");
}
function notallowed()
{
global $url_images;
create_headerforall(_PMSTITLE);
create_bodyforall();
echo "\n
\n
" . _GROUPRESTRICTEDAREA . "!
\n";
echo '' . mxCreateImage($url_images . '/cancel.png', '', 0, 'style="background-color: transparent;"') . ' ' . _PMSCLOSE . '
';
create_footerforall();
die("");
}
/* ########### mainprog ####################################### */
if (empty($op)) $op = "buddy";
if (empty($ref_intervall)) {
$ref_intervall = 0;
}
if (empty($subject)) $subject = "";
// mxdebugfuncvars($_POST);
switch ($op) {
case "read":
readm($msg_id);
break;
case "send":
sendm($to, $to_userid, $message, $subject);
break;
case "compose":
if (isset($deletemsg) && isset($msg_id)) {
$result = sql_query("delete FROM {$prefix}_priv_msgs WHERE (to_userid='" . intval($GLOBALS["userinfo"]["uid"]) . "') AND (msg_id=" . intval($msg_id) . ") or (from_userid is null)");
}
if (isset($closewin)) {
closewindow();
die();
} else {
compose($to, $subject);
}
break;
case "check":
onlycheckmsg($ref_intervall);
break;
case "allusers":
buddy("all");
break;
case "list":
buddy();
break;
case "buddy":
buddy();
break;
default:
buddy();
break;
}
?> |