<?php
/**
 * pragmaMx  Content Management System
 * Copyright (c) 2008 pragmaMx Dev Team - http://pragmaMx.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

if (!defined("mxMainFileLoaded")) die ("You can't access this file directly...");
if (!defined("mxYALoaded")) define("mxYALoaded", 1);

mxGetLangfile("Your_Account");
require_once("modules/Your_Account/config.php");
require_once("includes/mx_userfunctions.php");

/**
 * Startfunktion des Moduls
 */

function showlastforumposts()
{
/**
 * // //////////  EINSTELLUNGEN DES BLOCKS ////////////////////////////////////
 */
// der Modulname (Ordner des Moduls)
$boardname = 'Forum';
// Anzahl der angezeigten neuesten Threads
$num_threads = 5;
// Boards die nicht angezeigt werden sollen, als Array
$exclude_boards = null;

// Farben des Blocks
global $bgcolor1, $bgcolor2, $bgcolor3, $textcolor1, $textcolor2;
// Rahmen um die Liste
$color['border'] = $bgcolor2;
// Hintergrund Überschriften
$color['row1'] = $bgcolor1;
// Hintergrund normaler Thread
$color['row2'] = $bgcolor3;
// Textfarbe Überschriften
$color['txtrow1'] = $textcolor1;
// Textfarbe normaler Thread
$color['txtrow2'] = $textcolor2;
/**
 * //////////  ENDE DER EINSTELLUNGEN /////////////////////////////////////////
 */

/**
 * versch. globale Variablen vorher initialisieren, weil in Funktionen aufgerufen
 */
global $db_prefix, $settings, $context, $scripturl, $mxsmf;

/**
 * die SSI-Datei includen
 */
@include(dirname(dirname(__FILE__)) . '/modules/' . $boardname . '/mx_SSI.php');
if (!defined('SMF')) {
    // falls Bridge nicht installiert, oder Datei nicht gefunden, hier beenden
    return $content = @$mx_ssi_content;
}

// die Threads und Posts
$posts = ssi_recentTopics(intval($num_threads), $exclude_boards, 'array');
    // / alle Thread-ID's vorher auslesen, für Datenbankbedingung
    foreach ($posts as $post) {
        $topics[$post['topic']] = $post['topic'];
    }
    if (isset($topics)) {
        // / zusätzliche Daten, die nicht von SSI bereitgestellt werden ermitteln
        $qry = "SELECT DISTINCT m.ID_MEMBER, m.posterName, t.numReplies, t.numViews, t.ID_TOPIC
                                FROM {$db_prefix}topics AS t
                                LEFT JOIN {$db_prefix}messages AS m ON ( m.ID_MSG = t.ID_FIRST_MSG )
                                WHERE t.ID_TOPIC IN (" . implode(',', $topics) . ")
                                LIMIT " . intval($num_threads) . "";
        $result = sql_query($qry);
        // / die zusätzlichen Daten sind dann über den Index des Arrays ansprechbar, dieser index entspricht der Thread-ID
        while ($row = sql_fetch_assoc($result)) {
            $row['link'] = (empty($row['ID_MEMBER'])) ? $row['posterName'] : '<a href="modules.php?name=' . $boardname . '&amp;action=profile;u=' . $row['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['posterName'] . '">' . $row['posterName'] . '</a>';
            $posts_more[$row['ID_TOPIC']] = $row;
        }
    }

// Der Tabellenkopf für die Threads und Posts
$content = '<table width="100%" border="0" cellspacing="1" cellpadding="2" style="background: ' . $color['border'] . ';">
<tr valign="top" style="background: ' . $color['row1'] . '; color: ' . $color['txtrow1'] . ';">';
$content .= '<th colspan="' . (($show_icons) ? 2 : 1) . '">' . $txt['319'] . '</th>'; # Thema
$content .= '<th>' . $txt['110'] . '</th>'; # Antworten
$content .= '<th>' . $txt['111'] . '</th>'; # Letzter Beitrag
$content .= '
</tr>
';
// die Hauptliste der einzelnen Threads
foreach ($posts as $post) {
    $new = (!$post['new']) ? ' <a href="modules.php?name=' . $boardname . '&amp;topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" align="right"></a> ': '';
    $content .= '<tr style="background: ' . $color['row2'] . '; color: ' . $color['txtrow2'] . ';">';
    if ($show_starter)
        $content .= '<td width="1%" style="white-space: nowrap;">' . ((isset($posts_more[$post['topic']]['link'])) ? $posts_more[$post['topic']]['link'] : '') . '</td>';
        $content .= '<td width="1%" align="center">' . ((isset($posts_more[$post['topic']]['numReplies'])) ? $posts_more[$post['topic']]['numReplies'] : 0) . '</td>';
        $content .= '<td width="1%" align="center">' . ((isset($posts_more[$post['topic']]['numViews'])) ? $posts_more[$post['topic']]['numViews'] : 0) . '</td>';
    $content .= '<td>' . $post['time'] . '<br />' . $txt[525] . ' ' . $post['poster']['link'] . '</td>';
    $content .= '</tr>';
}
// Der Tabellenfuss für die Threads und Posts
$content .= '</table>';
// Den Output für pragmaMx aufbereiten (links usw. anpassen)
$content = mxSmfPrepareOutput($content);

echo "$content";
}
function showlastarticels($maxarticels = 3)
{
// die ersten Teile des Artikeltextes anzeigen,
// - 0 fuer nein, oder
// - eine beliebige Zahl, die die Menge der angezeigten Zeichen definiert
// HTML-Tags, ausser <br> werden entfernt und nicht mitgerechnet
$showintro = 150;

// Bilder im Text anzeigen, wenn $showintro angeschaltet ist
$showpics = false;

// Buttonleiste anzeigen
$showbuttons = 1;

// Veroeffentlichungsdatum anzeigen
$showdate = 1;

// Kategorie zusammen mit der Artikelueberschrift anzeigen
$showcattitle = 0;

// Anzahl der Spalten
$showcolumns = 1;

// Anzahl der angezeigten Artikel
// - eine beliebige Zahl, oder
// - die globale Variable $GLOBALS['storyhome']
$storynum = $maxarticels;

// Blockcache erlauben
$mxblockcache = true;

global $prefix, $bgcolor1, $bgcolor2, $bgcolor3;

if ($GLOBALS["multilingual"] == 1) {
    if (ereg("german", $GLOBALS["currentlang"])) $thislang = "german";
    else $thislang = $GLOBALS["currentlang"];
    $querylang = "AND (alanguage LIKE '" . $thislang . "%' OR alanguage='')";
} else {
    $querylang = "";
}

$qry = "SELECT sid, cat.catid, aid, s.title, time, DATE_ADD(time, INTERVAL 2 DAY) AS expire, now() AS jetzt, hometext, bodytext, comments, s.counter, topic, informant, notes, acomm, cat.title AS title1
        FROM ${prefix}_stories AS s LEFT JOIN ${prefix}_stories_cat AS cat ON s.catid = cat.catid
        WHERE (ihome='0' OR s.catid='0') AND time <= now() $querylang
        ORDER BY s.time DESC
        limit 0,$storynum";

$result = sql_query($qry);
if (!$result) {
   echo "<div align=\"center\" style=\"color:Gray;font-style:italic;\">Keine Artikel zum anzeigen</div>";
    return ;
}

// $empty = "<img src=\"images/menu/empty.gif\" border=0 >";
$count = 0;
$out = '';
$width = ceil(100 / $showcolumns);
while ($story = sql_fetch_assoc($result)) {
    // Textlaengen
    // $introcount = strlen(strip_tags($story['hometext']));
    // $fullcount = strlen(strip_tags($story['bodytext']));
    $totalcount = strlen(strip_tags($story['hometext'])) + strlen(strip_tags($story['bodytext']));

    $introtext = '';
    if ($showintro) {
        if ($showpics) {
            // Alle Tags ausser <br> & <img> entfernen
            $introtext = trim(strip_tags($story['hometext'], '<br><img>'));
            // <br> am Textbeginn entfernen
            $introtext = preg_replace('#^(?:<br\s*/*>\s*)*#is', '', $introtext);
            // array zuruecksetzen
            $replaces = array();
            $textlentemp = $showintro;
            // alle Imagetags suchen und zwischenspeichern
            if (preg_match_all('#<img[^>]*>#si', $introtext, $images)) {
                foreach($images[0] as $i => $img) {
                    // einen alternativen String zum Ersetzen erstellen
                    $alternate = md5($img);
                    // die gewuenschte Textlaenge um die Textlaenge des alternativen String erweitern
                    $textlentemp = $showintro + strlen($alternate);
                    // den gefundenen Imagetag in das array stellen
                    $replaces[$alternate] = $img;
                    // den gefundenen Imagetag aus dem Text entfernen und dafuer den alternativen String einsetzen
                    $introtext = trim(str_replace($img, $alternate, $introtext));
                }
            }
            // Text auf die gewuenschte Laenge kuerzen
            $introtext = mxCutString($introtext, $textlentemp, "&nbsp;...", " ");
            // wenn imagetags gefunden wurden, die alternativen Textteile wieder
            // durch die im Array zwischengespeicherten Imagetags ersetzen
            if (count($replaces)) {
                $introtext = str_replace(array_keys($replaces), array_values($replaces), $introtext);
            }
            // Text auf die gewuenschte Laenge kuerzen
            $introtext = trim(mxCutString($introtext, $showintro, "&nbsp;...", " "));
        } else {
            // Alle Tags ausser <br> entfernen
            $introtext = trim(strip_tags($story['hometext'], '<br>'));
            // <br> am Textbeginn entfernen
            $introtext = preg_replace('#^(?:<br\s*/*>\s*)*#is', '', $introtext);
            // Text auf die gewuenschte Laenge kuerzen
            $introtext = trim(mxCutString($introtext, $showintro, "&nbsp;...", " "));
        }
        if ($introtext) {
            $introtext = '<div class="content">' . $introtext . '</div>';
        }
    }
    // das formatierte Datum
    $datetime = '';
    if ($showdate) {
        $datetime = '<td width="96%">' . mx_strftime(_SHORTDATESTRING, mxSqlDate2UnixTime($story['time'])) . '</td>';
    }
    // die Buttons
    $buttons = array();
    if ($showbuttons) {
        $buttons[] = '<a href="modules.php?name=News&amp;file=print&amp;sid=' . $story['sid'] . '"><img src="images/menu/print.gif" width=12 height=13 border=0 alt="' . _BMXPRINTER . '"  title="' . _BMXPRINTER . '" ></a>';
        if (mxModuleAllowed('Recommend_Us')) {
            $buttons[] = '<a href="modules.php?name=News&amp;file=friend&amp;sid=' . $story['sid'] . '"><img src="images/menu/friend.gif" width=12 height=13 border=0 alt="' . _BMXFRIEND . '" title="' . _BMXFRIEND . '" ></a>';
        }
        $buttons[] = '<a href="modules.php?name=News&amp;file=article&amp;sid=' . $story['sid'] . '"><img src="images/menu/bytesmore.gif" border=0 width=12 height=13 alt="' . _BMXBYTESMORE . ' ' . $totalcount . '" title="' . _BMXBYTESMORE . ' ' . $totalcount . '" ></a>';
        $buttons[] = '<a href="modules.php?name=News&amp;file=article&amp;sid=' . $story['sid'] . '#comments"><img src="images/menu/comments2.gif" width=12 height=13 border=0  alt="' . _COMMENTS . ' ' . $story['comments'] . '"  title="' . _COMMENTS . ' ' . $story['comments'] . '" ></a>';
        if (mxModuleAllowed('Userinfo')) {
            $buttons[] = '<a href="modules.php?name=Userinfo&amp;uname=' . $story['informant'] . '"><img src="images/menu/informant.gif" width=12 height=13 border=0 alt="' . $story['informant'] . '" title="' . _UNICKNAME . ': ' . $story['informant'] . '" ></a>';
        }
        $buttons[] = '<img src="images/menu/counter.gif" width=12 height=13 border=0 alt="' . $story['counter'] . ' ' . _READS . '" title="' . $story['counter'] . ' ' . _READS . '" >';
    }
    $colspan = count($buttons) + 1;
    // $buttons = '<table border="0" cellspacing="1" cellpadding="1" align="right"><tr><td>'.implode('</td><td>', $button).'</td></tr></table>';
    $buttons = '<td>' . implode('</td><td>', $buttons) . '</td>';
    // der Titel des Artikels
    $story['title'] = '<a href="modules.php?name=News&amp;file=article&amp;sid=' . $story['sid'] . '">' . $story['title'] . '</a>';
    // den Kategoriename mit anzeigen
    if ($showcattitle && $story['catid']) {
        $story['title'] = $story['title'] . '&nbsp; [<a href="modules.php?name=News&amp;file=categories&amp;op=newindex&catid=' . $story['catid'] . '">' . $story['title1'] . '</a>]';
    }
    // $image = ($story['jetzt'] > $story['expire']) ? 'sign' : 'new';
    // $out .= '<td colspan="'.$colspan.'"><img src="images/menu/' . $image . '.gif" align="middle" alt="">&nbsp;'.$story['title'].'</td>';
    if ($count == 0) {
        $out .= '<tr valign="top">';
    }
    $out .= '
    <td width="' . $width . '%" valign="top" style="border: 1px solid #CCCCCC;">
        <table border="0" cellspacing="0" cellpadding="2" width="100%">';
    if ($datetime || $buttons) {
        $out .= '
            <tr valign="top" style="height: 10px;">
                ' . $datetime . $buttons . '
            </tr>
            ';
    }
    $out .= '
            <tr valign="top" style="height: 35px;">
                <td colspan="' . $colspan . '"><p><b>' . $story['title'] . '</b></p>' . $introtext . '</td>
            </tr>
        </table>
    </td>
    ';

    $count++;
    if ($count * $width == 100) {
        $out .= '</tr>';
        $count = 0;
    }
}
// falls nicht alle Tabellenspalten am Ende gefuellt sind, eine zus. anfuegen
if ($count && $out) {
    $out .= '<td colspan="' . ($showcolumns - $count) . '">&nbsp;</td>';
}


echo $out;

}
function viewusercommunity($uinfo)
{
  global $prefix, $user_prefix, $bgcolor1, $bgcolor2, $bgcolor3, $useuserpoints;
  global $istheuser, $privmsgactive, $gbactiv, $showall, $sitename; // fuer Unterfunktionen in mx_userfunctions_options.php
  if (!isset($useuserpoints)) include("modules/Your_Account/config.php");
  // Fï¿½r die Fotoalbum Funktion
  if (@is_file("modules/Avatar/index.php"))
  {
    if (file_exists("modules/Avatar/settings.php"))
    {
      include("modules/Avatar/settings.php");
      // Fï¿½r die neue Version:
      if (($album) && file_exists("modules/Avatar/thumb.php"))
      {
        if (!defined("AV_ALBUM")) define("AV_ALBUM", 1);
      }
    }
  }
  mxGetLangfile("Your_Account");

  $uinfo = mxPrepareCensored($uinfo);
  $istheuser = vkpUserIsThisTheUser($uinfo['uid']);
  $showall = ($istheuser || MX_IS_ADMIN) ? 1 : 0;
  $privmsgactive = (mxModuleAllowed("Private_Messages")) ? 1 : 0; # feststellen ob pm-modul aktiv ist
  $gbactiv = (mxModuleAllowed("UserGuest")) ? 1 : 0; # feststellen ob gaestebuch vorhanden
  $uinfo['url'] = mxCutHTTP($uinfo['url']);
  // Signatur
  if (!empty($uinfo['user_sig']))
  {
    if (@file_exists('modules/Private_Messages/bbfunctions.php'))
    {
      include_once('modules/Private_Messages/bbfunctions.php');
      $uinfo['user_sig'] = msg_smile(msg_bbencode(make_clickable(pmxSigBbCode($uinfo['user_sig']))));
    }
    $uinfo['user_sig'] = mxNL2BR(mxPrepareToDisplay($uinfo['user_sig']));
  }
  // Modul erlaubt? :
  // Prï¿½fem ob ein Avatar hochgeladen wurde:
  $isAvatarUploaded = mxIsAvatarUploaded($uinfo['uname'], false, true);
  // Prï¿½fem ob ein Avatar hochgeladen wurde:
  if (!$isAvatarUploaded['werist'])
  {
    $uinfo['user_avatar'] = (empty($uinfo['user_avatar']) || $uinfo['user_avatar'] == "blank.gif") ? "" : mxCreateImage(MX_PATH_AVATAR . "/" . $uinfo['user_avatar'], $uinfo['user_avatar']);
  } else
  {
    $uinfo['user_avatar'] = mxCreateImage(MX_PATH_MEMBERAVATAR . "/" . $isAvatarUploaded['werist']);
  }
  // Private Nachrichten
  if ($privmsgactive && $istheuser)
  { // falls pm-modul aktiv ist
    $uinfo['countpm'] = 0;
    $uinfo['countpmread'] = 0;
    $uinfo['countpmunread'] = 0;
    $qry = "SELECT read_msg, Count(msg_id) FROM ${prefix}_priv_msgs WHERE to_userid='" . intval($uinfo['uid']) . "' group by read_msg;";
    $result = sql_query($qry);
    while (list($read_msg, $nums) = sql_fetch_row($result))
    {
      if ($read_msg == 0)
      { // wenn angemeldeter User
        $uinfo['countpmunread'] = $nums; # Anzahl ungelesene ermitteln
      } else
      {
        $uinfo['countpmread'] = $nums; # Anzahl gelesener pm's ermitteln
      }
    }
    $uinfo['countpm'] = $uinfo['countpmread'] + $uinfo['countpmunread'];
    $uinfo['contpm'] = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td nowrap><a href=\"modules.php?name=Private_Messages\"><b>" . $uinfo['countpm'] . "</b></a>&nbsp;<a href=\"modules.php?name=Private_Messages\">" . _YA_BWOPMSGALL . "</a>";
    if ($uinfo['countpmunread'])
    {
      $uinfo['contpm'] .= "</td><td>,&nbsp;</td><td nowrap><a href=\"modules.php?name=Private_Messages\"><marquee behavior='alternate' direction='left' width='100' hspace='0' vspace='0' loop=''><b>" . $uinfo['countpmunread'] . "</b>&nbsp;<b>" . _YA_BWOPMSGUNREAD . "</b></marquee></a>\n";
    }
    $uinfo['contpm'] .= "</td><td>&nbsp;&nbsp;*</td></tr></table>";
  }
    // Online oder Offline
    $uinfo['online'] = ($istheuser) ? true : mxIsUserOnline($uinfo['uname']);
    $uinfo['lastonline'] = ($uinfo['online']) ? "" : mx_strftime(_DATESTRING, $uinfo['user_lastvisit']);
    if ($uinfo['online']) {
        $uinfo['online'] = mxCreateImage("images/online.gif", _YES) . '&nbsp;' . _YES;
    } else {
        $uinfo['online'] = mxCreateImage("images/offline.gif", _NO) . '&nbsp;' . _NO;
    }
    // Newsletter
    if (mxModuleAllowed("Newsletter")) {
        $resultx = sql_query("SELECT status FROM ${prefix}_newsletter WHERE email='" . mxAddSlashesForSQL($uinfo['email']) . "' OR email='" . mxAddSlashesForSQL($uinfo['femail']) . "'");
        list($status) = sql_fetch_row($resultx);
        $uinfo['newsletter'] = (empty($status) || $status == 3) ? _NOTSUBSCRIBED : _SUBSCRIBED;
        $img = (empty($status) || $status == 3) ? "images/td.gif" : "images/tu.gif";
        $uinfo['newsletter'] = mxCreateImage($img, $uinfo['newsletter']) . "&nbsp;" . $uinfo['newsletter'] . "\n";
    }
    // Userpunkte
    // $uinfo['userpoints'] = 0;
    $uinfo['hasuserpoints'] = "";
    $uinfo['userpointsfaq'] = "";
    if ($useuserpoints) {
        if (@file_exists("modules/Your_Account/userpoints.php")) {
            $uname = $uinfo['uname'];
            include_once("modules/Your_Account/userpoints.php");
            $uinfo['hasuserpoints'] = $hasuserpoints;
            // $uinfo['userpoints']    = $userpoints;
            $uinfo['userpointsfaq'] = $userpointsfaq;
        }
    }
    // Usergaestebuch
    $uinfo['gbnewentries'] = 0;
    if ($gbactiv) { // falls gaestebuch vorhanden
        $qry = "SELECT Count(gid) FROM ${prefix}_userguest WHERE touserid='" . intval($uinfo['uid']) . "' and dummy=0;";
        $result = sql_query($qry);
        list($uinfo['gbnewentries']) = sql_fetch_row($result);
    }
        // Geburtstag
    $bday = explode('-', $uinfo['user_bday']);
    $uinfo['user_bday'] = (@checkdate($bday[1], $bday[2], $bday[0])) ? vkpGetBdayString($uinfo['user_bday']) : "";
    // Benutzergruppe
    if (MX_IS_ADMIN) {
        $result = sql_query("SELECT access_title FROM " . $prefix . "_groups_access WHERE access_id = " . intval($uinfo['user_ingroup']));
        list($uinfo['usergroup']) = sql_fetch_row($result);
    }

  // //////////////////////// Ausgabe der Daten /////////////////////////////////////////////////////
  include("header.php");

  include_once("modules/Your_Account/navbar.php");


 // viewuserinfo_option_1($uinfo);
  OpenTable();


  $menuitems[] = array("modules/Your_Account/images/id_card.gif", "modules.php?name=Userinfo", "Dein Profil </a><br> Hier kommst du zu deinem Profil");
  $menuitems[] = array("modules/Your_Account/images/user1_monitor.gif", "modules.php?name=mx_ma_useronline", "Wer ist Online</a><br> Hier kannst du sehen, wer gerade Online ist.");
  $menuitems[] = array("modules/Your_Account/images/mailbox_full.gif", "modules.php?name=Private_Messages", "Deine privaten Nachrichten </a><br> Deine Mailbox - PM´s schreiben und lesen");
  $menuitems[] = array("modules/Your_Account/images/usermap.gif", "modules.php?name=Usermap", "Die Landkarte</a><br> Woher kommen unsere angemeldeten User?");
  $menuitems[] = array("modules/Your_Account/images/photo_portrait.gif", "modules.php?name=Avatar", "Deine Fotos </a><br> Hier kannst du deine Fotos und Avatare verwalten.");
  $menuitems[] = array("modules/Your_Account/images/forum.gif", "modules.php?name=Forum", "Forum</a><br> Zum Forum.");
  $menuitems[] = array("modules/Your_Account/images/users2.gif", "modules.php?name=UserGuest", "Dein G&auml;stebuch </a><br> Hier kannst du dein G&auml;stebuch verwalten.");


  $menuitems[] = array("modules/Your_Account/images/user1_preferences.gif", "modules.php?name=Your_Account&op=edituser", "Deine Daten </a><br> Hier kannst du deine pers&ouml;nlichen Daten ver&auml;ndern.");
  $menuitems[] = array("modules/Your_Account/images/nickpage.gif", "modules.php?name=Nickpage", "Deine Nickpage</a><br> Deine Nickpage bearbeiten und ver&ouml;ffentlichen.");
  $menuitems[] = array("modules/Your_Account/images/users2.gif", "modules.php?name=Members_List", "Mitgliederliste </a><br> Unsere angemeldeten User");
  $menuitems[] = array("modules/Your_Account/images/socialseek.gif", "modules.php?name=SocialSeek", "Freunde finden</a><br> Leute mit gleichen / ähnlichen Interessen finden.");
  $menuitems[] = array("modules/Your_Account/images/user1_preferences.gif", "modules.php?name=Your_Account&op=edithome", "Deine Einstellungen </a><br> Hier kannst du weitere Einstellungen vornehmen.");
  $menuitems[] = array("modules/Your_Account/images/hilfe.gif", "modules.php?name=TicketSystem", "Hilfe (Ticketsystem) </a><br> Fragen, Probleme und Kontakt");
  $menuitems[] = array("modules/Your_Account/images/exit.gif", "modules.php?name=Your_Account&amp;op=logout", "Abmelden (Logout) </a><br>Hier kannst Du Dich abmelden. Willst Du wirklich schon gehen?");


  //$menuitems[] = array("modules/Your_Account/images/calendar.gif", "modules.php?name=Surveys", "Geburtstage</a><br> Wissen wer Geburtstag hat.");
  //$menuitems[] = array("modules/Your_Account/images/messages.gif", "modules.php?name=SPChat", "Chat</a><br> Lerne nette neue Leute kennen.");
  //$menuitems[] = array("modules/Your_Account/images/user1_monitor.gif", "modules.php?name=mx_ma_useronline", "Wer ist Online</a><br> Hier kannst du sehen, wer gerade Online ist.");
  //$menuitems[] = array("modules/Your_Account/images/hilfe.gif", "modules.php?name=Ticketsystem", "Hilfe (Ticketsystem) </a><br> Fragen, Probleme und Ratlosigkeit.");




  $menuitemsoutput = "";
  $c_menuitemsoutput=0;
  $ca_menuitemsoutput= count($menuitems);
  $ca_menuitemsoutputb=ceil($ca_menuitemsoutput/2);
  while($ca_menuitemsoutput > $c_menuitemsoutput)
  {
    $menuitemsoutput .= "\n
    <table width=\"285\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
      <tr>
        <td width=\"78\"><div align=\"center\">" . mxCreateImage($menuitems[$c_menuitemsoutput][0], "") . "</div></td>
        <td width=\"222\" height=\"60\">
          <div align=\"center\">
            <a href=\"".$menuitems[$c_menuitemsoutput][1]."\">
            ".$menuitems[$c_menuitemsoutput][2]."
          </div>
        </td>
      </tr>
    </table>";
     $c_menuitemsoutput++;
    if($ca_menuitemsoutputb==$c_menuitemsoutput) $menuitemsoutput .= "</td>\n<td width=\"50%\" align=\"center\" valign=\"top\">";
  }

echo "
<table width=\"588\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <td width=\"588\" align=\"center\" valign=\"top\">
      <table width=\"580\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
        <tr>
          <td height=\"24\" background=\"modules/Your_Account/images/reiter_bg.gif\" style=\"border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC;\">
            <div align=\"center\"><strong>".$sitename." - Community</strong></div>
          </td>
        </tr>
      </table>
      <table width=\"580\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;\">
        <tr>
          <td align=\"center\" valign=\"top\">
           ".$menuitemsoutput."
          </td>
        </tr>
      </table>
      <br>
      <table width=\"580\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
        <tr>
          <td width=\"50%\" height=\"24\" background=\"modules/Your_Account/images/reiter_bg.gif\" style=\"border-left: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC;\">
            <div align=\"center\">Forum Themen</div></td>
          <td background=\"modules/Your_Account/images/reiter_bg.gif\" style=\"border-right: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC;\"><div align=\"center\">Community
              News</div></td>
        </tr>
      </table>
      <table width=\"580\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-left: 1px solid #CCCCCC; border-right: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC;\">
        <tr>
          <td align=\"center\" valign=\"top\">
            <table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"5\" align=\"center\"><tr><td>
";
showlastforumposts();
echo "
            </td></tr></table>
          </td>
          <td width=\"50%\" align=\"center\" valign=\"top\">
            <table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"5\" align=\"center\">
";
showlastarticels();
echo "
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>";


  CloseTable();
  include("footer.php");
}
function main()
{
    if (MX_IS_USER) {

       // include_once("modules/Userinfo/view.php");
       // viewuserinfo($uinfo);
       viewusercommunity(mxGetUserData());
    } else {
        include_once("modules/Your_Account/loginout.php");
        loginscreen();
    }
}

/**
 * alten Nuke-Cookie in Session speichern
 */
function docookie($setuid, $setuname, $setpass, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax)
{
    mxSetUserSession("$setuid:$setuname:$setpass:$setstorynum:$setumode:$setuorder:$setthold:$setnoscore:$setublockon:$settheme:$setcommentmax");
}

/**
 * Liste aller Avatare anzeigen
 */
function avatarlist()
{
    $temcount = 1;
    $filelist = vkpYaGetAvatars();
    foreach($filelist as $varname => $value) {
        $nextline = "";
        if ($temcount == 10) {
            $nextline = "</tr><tr>";
            $temcount -= 10;
        }
        $size = @getimagesize("" . MX_PATH_AVATAR . "/" . $value . "");
        $alt = $value;
        $xavatar[] = "<td align=\"center\"><img src=\"" . MX_PATH_AVATAR . "/" . $value . "\" border=\"0\" $size[3] alt=\"$alt\"><br>$alt</td>$nextline";
        $temcount ++;
    }
    $avOptions = implode("", $xavatar);

    include("header.php");
    Opentable();
    echo "<center><font class=\"option\"><b>" . _AVAILABLEAVATARS . "</b></font><br><br>";
    echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"7\"><tr>$avOptions</tr></table>";
    CloseTable();
    include("footer.php");
}

/**
 * Auswahl der Funktionen
 */
switch ($op) {
    case "userinfo":
        Header("Location: modules.php?name=Userinfo&uname=" . urlencode($_REQUEST['uname']) . "");
        break;

    case "login":
        include_once("modules/Your_Account/loginout.php");
        $nextpage = (isset($_POST['redirect'])) ? $_POST['redirect'] : ((empty($yastartpage)) ? "modules.php?name=Userinfo" : $yastartpage);
        douserlogin($_POST, $nextpage);
        break;

    case "logout":
        include_once("modules/Your_Account/loginout.php");
        logout();
        break;

    case "logoutfin":
        include_once("modules/Your_Account/loginout.php");
        logoutfinisch();
        break;

    case "new_user":
        Header("Location: modules.php?name=User_Registration");
        break;

    case "confirm":
        Header("Location: modules.php?name=User_Registration");
        break;

    case "finish":
        Header("Location: modules.php?name=User_Registration");
        break;

    case "edituser":
        $pagetitle = _CHANGEYOURINFO;
        include_once("modules/Your_Account/edituser.php");
        edituser();
        break;

    case "saveuser":
        $pagetitle = _CHANGEYOURINFO;
        include_once("modules/Your_Account/edituser.php");
        saveuser($_POST);
        break;

    case "edithome":
    case "editcomm":
    case "chgtheme":
        $pagetitle = _CHANGEHOME;
        include_once("modules/Your_Account/edithome.php");
        edithome();
        break;

    case "savehome":
    case "savetheme":
    case "savecomm":
        $pagetitle = _CHANGEHOME;
        include_once("modules/Your_Account/edithome.php");
        savehome($_POST);
        break;

    case "delete":
        $pagetitle = _DELETEACCT;
        include_once("modules/Your_Account/deleteuser.php");
        deleteuser();
        break;

    case "delconfirm":
        $pagetitle = _DELETEACCT;
        include_once("modules/Your_Account/deleteuser.php");
        delconfirm($_GET);
        break;

    case "deletefinisch":
        $pagetitle = _DELETEACCT;
        include_once("modules/Your_Account/deleteuser.php");
        deletefinisch($_GET);
        break;

    case "lost_pass":
    case "pass_lost":
        $pagetitle = _PASSWORDLOST;
        include_once("modules/Your_Account/passlost.php");
        pass_lost();
        break;

    case "mailpasswd":
        $pagetitle = _PASSWORDLOST;
        include_once("modules/Your_Account/passlost.php");
        mail_password($_POST);
        break;

   case "avatarlist":
        $pagetitle = _AVAILABLEAVATARS;
        avatarlist();
        break;

    default:
        $pagetitle = _THISISYOURPAGE;
        main();
        break;
}