Aktion: Wiki-Messenger

{{messenger}}


Ein einfacher Wiki-Messenger, der es registrierten Nutzern ermöglicht sich innerhalb des Wikis Nachrichten zu schreiben.


Desweiteren hat man die Möglichkeit eine Kontaktliste zu führen und eigene Ordner anzulegen, um die erhaltenen Nachrichten
entsprechend zu verwalten.
Der Absender kann Nachrichten markieren und wird darüber informiert, ob eine Nachricht gelesen wurde.
Ebenfalls vorbereitet ist eine Codezeile, die in der header.php integriert werden kann – um den Nutzer sofort nach der Anmeldung
im Wiki anzuzeigen, dass er neue Nachrichten bekommen hat.


Der Code basiert auf dem Script Wikka Mail und wurde nur etwas angepasst und übersetzt.
Die Filterfunktion wurde komplett entfernt, da sie nur bedingt brauchbar bzw sinvoll ist. Mail wurde der Verwechslung wegen in Messenger umbenannt.
Die Funktion Nachrichten löschen wurde ebenfalls überarbeitet, da die Nachrichten im ursprünglichen Code nicht aus der Datenbank
gelöscht wurden, sondern lediglich nicht mehr im Posteingang angezeigt wurden. Die Nachricht ist dann zwar nicht mehr im 
Posteingang, aber es baut sich eine enorme Datenbank auf – da die Nachrichten ja nicht wirklich gelöscht wurden.


Die implementierte Hilfe für den Wiki-Messenger ist noch nicht ganz fertig, wird aber in kürze vervollständigt.
Da aber so gut wie alle Funktionen selbsterklärend sind steht einem Einsatz eigentlich nichts im Wege.


Um das Message-System zu installieren muss die bestehende SQL Tabelle um 2 Einträge erweitert werden und die beiden
nachfolgenden php-Dateien in den Ordner /actions kopiert werden
Aufgerufen wird der Messenger im Wiki mit {{messenger}}


Dieses Script muss unter dem Namen messenger.php gespeichert werden und in den Ordner /actions kopiert werden.


/actions/messenger.php

<?php
// This messenger.php (Version 1.5d) code is a substantial modification of code originally released by cscartman (Cody Selzer) at www.codewalkers.com
// as freeware. The code has been considerably modified and extended for use in wikka wiki by GmBowen for a SSHRC research project.
// Modifications & additions by GmBowen released under GPL.
// Translation (german) & modifications  by Garfield under GPL. 
// Aufrufen: {{messenger}} (ohne parameter). Benötigt: 2 Tabellen in MYSQL-Datenbank & und die php-Datei "messenger.page.inc.php" die wie diese Datei in den
// Ordner "actions" eingefügt werden muss.
// Die nachfolgende Codezeile kann z.B. in die header.php eingefügt werden. Bekommt der User eine neue Nachricht, wird das dann an der entsprechende Stelle angezeigt sobald er sich einloggt.
// if (mysql_num_rows(mysql_query("SELECT status FROM ".$this->config["table_prefix"]."messenger where UserTo='".$this->GetUserName()."' and folder='inbox' and status='nicht gelesen' and viewrecipient='Y' LIMIT 1"))!=0) {echo "<a title='Du hast neue Nachrichten.'><font color=Red><strong>Neue Nachricht</strong></font></a>";}

// includes functions for doing pagination of "sent" & "inbox" messeges
include_once("messenger.page.inc.php");

$pagename = $this->MiniHref($method, $tag);
$link = $this->config["base_url"].$this->MiniHref($method, $tag);
$userfrom = $this->GetUserName();
$pagenum=$_GET['page'];
$username = $userfrom;
$folder=$_GET['folder'];
$which=$_REQUEST['whichfolder'];
if (!$folder) {$folder=$which;}
$fltrset=$_GET['fltrset'];
$msg_id=$_GET['message_id'];
$filter=$_GET['fltr'];
$move2folder = $_REQUEST[move2folder];
$action=$_GET['action'];
$subject=$_GET[subject];
$message_id=$msg_id;
$id=$_GET['id'];
$to=$_GET['to'];
?>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>

<table><tr><td>|</td><td> <a href="<?php echo $link; ?>&action=inbox">Posteingang</a> </td><td>|</td><td> <a href="<?php echo $link; ?>&action=compose">Verfassen</a> </td><td>|</td><td><b>Ordner</b></td><td></td><td>

<?php
$str = "SELECT DISTINCT info FROM ".$this->config["table_prefix"]."messengerinfo WHERE type='folder' and owner='$username' ORDER BY info ASC";
$resultdrop = mysql_query($str);
echo "<form method='post' action=\"$link\"><select name=\"whichfolder\">";
       while ($row = mysql_fetch_array($resultdrop))
       {
        extract ($row);

            if($_REQUEST[whichfolder] == $info)
            {
               echo "<option selected value=\"$info\">$info</option>";
            }else {
               echo "<option value=\"$info\">$info</option>";
            }
       }
   echo "</select><input type='submit' value='Anzeigen'></form>";
?>
</td><td>|</td><td> <a href="<?php echo $link; ?>&action=sent">Postausgang</a> </td><td>|</td><td> <b>Verwalten: </b><a href="<?php echo $link; ?>&action=folders">Ordner</a> / <a href="<?php echo $link; ?>&action=contacts">Kontaktliste</a> </td><td>| </td><td><a href="<?php echo $link; ?>&action=users">Benutzer</a> <td>| <a href="<?php echo $link; ?>&action=help">Hilfe</a></td> <td>|</td></td></tr></table>

<?php
if ($action=="compose" || $action=="forward" || $action=="contacts" || $action=="folders" || $action=="users" || $action=="help" || $action=="reply" || $action=="delete" || $action=="compose2"){echo "";
    } else {
    if ($action=="inbox" || (($action=="" || $action=="view") && $_REQUEST['whichfolder']=="" && $folder=="")) {$which2= $pagenum."<b>  Posteingang</b>";}
    elseif ($action=="sent" || $action=="view2") {$which2= $pagenum."<b>  gesendete Nachrichten</b>";} elseif (folder!="") {$which=$folder; $which2="<a href=".$link."&folder=".$folder.">".$which."</a>";}
    echo "<br ><b>Ordner: </b>".$which2;
}


// code for moving messages to folders
if ($move2folder) {
 $query="UPDATE ".$this->config["table_prefix"]."messengerl SET folder='$move2folder' WHERE UserTo='$username' AND message_id='$message_id'";
 $query or die("Aufgrund eines Fehlers wurde die Nachricht nicht als gelesen markiert.");
 $rs = mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET folder='$move2folder' WHERE message_id='$message_id' AND UserTo='$username'");
 if($query) {
   echo "<br ><strong>Die Nachricht wurde in Ordner ".$move2folder." verschoben.";
   } else {
   echo "Die Nachricht wurde nicht verschoben!";
   }
}

// shows inbox
elseif(($action=='' || $action=='inbox') && $_REQUEST['whichfolder']=='' && (!$folder)) {
 if ($filter==1) {$search="and fltr1='1' ";} elseif ($filter==2) {$search="and fltr2='1' ";} elseif ($filter==3) {$search="and fltr3='1' ";} elseif ($filter==N) {$search="and fltr1='0' and fltr2='0' and fltr3='0' ";} else {$search="";}
 // setting the filter conditions into the database
 $queryfil="SELECT fltr1,fltr2,fltr3,message_id FROM ".$this->config["table_prefix"]."messenger where UserTo='$username' and folder='inbox' and viewrecipient='Y' ORDER BY DateSent DESC";
 $resultfil=mysql_query($queryfil) or die ("cant do it");
 while ($row=mysql_fetch_array($resultfil)) {
   // code to set filters in database
    if (($fltrset) && ($row[message_id]==$msg_id)) {
       // code to determine setting of filters on server
       if ($row[fltr1]!=1) {$fltrvar1=1;} else {$fltrvar1=0;}
       if ($row[fltr2]!=1) {$fltrvar2=1;} else {$fltrvar2=0;}
       if ($row[fltr3]!=1) {$fltrvar3=1;} else {$fltrvar3=0;}
       // code to set which filter is being set
       if ($fltrset==1) {$fltr="fltr1"; $set=$fltrvar1;} elseif ($fltrset==2) {$fltr="fltr2"; $set=$fltrvar2;} elseif ($fltrset==3) {$fltr="fltr3"; $set=$fltrvar3;}
       mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET ".$fltr."=".$set." WHERE message_id='$msg_id' AND UserTo='$username'");
    }
 }
  $query="SELECT * FROM ".$this->config["table_prefix"]."messenger where UserTo='$username' ".$search."and folder='inbox' and viewrecipient='Y' ORDER BY DateSent DESC";
  $result=mysql_query($query) or die ("kann nicht ausgeführt werden!");
 echo "<table cellpadding='2' cellspacing='3' width='800' valign='top'>";
       //needed for pagination of sent box
       $record_per_page=10;
       $scroll=3;
    $total_records=mysql_num_rows($result);
    $page=new Page(); //creating new instance of Class Page
    $link2=$link."&action=inbox";

    // to paginate the "inbox" page messeges
    echo "<tr><td colspan='4' align='center'>";   
     if ($total_records>$record_per_page) {
         $page->set_page_data($link2,$total_records,$record_per_page,$scroll,true,true,true);
      $result=mysql_query($page->get_limit_query($query));
      echo $page->get_page_nav();
      }
    echo "</td></tr>";
  echo  "<tr bgcolor=#93B2DD>\n";
  echo  "<td width='400'><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td width='100'> <b><b>Betreff:</b></b></td><td align='right'>";
  echo  "</td></tr></table></td>\n";
  echo  "<td width='100'> <b><b>Absender:</b></b></td>\n";
  echo  "<td width='250'><b> Verschieben in Ordner:</b></td>\n";
  echo  "<td width='80'> <b>Löschen:</b></td>\n";
  echo  "</tr>\n";

 while ($row=mysql_fetch_array($result)) {
  // Extracting & formatting date
  $datetime=date("dMy g:i a",strtotime($row['DateSent']));
  // setzt Zeichen für Status der Nachricht (wichtig/gelesen/beantwortet)
  if ($row[status]=="nicht gelesen") {$status="<a title='Diese Nachricht wurde noch nicht gelesen!'><font color=Red>*</font></a>";} else {$status="";}
  if ($row[urgent]=="1") {$urgentmkr="<a title='Dies ist eine dringende Nachricht!'><font color=Red><strong>!</strong></font></a>";} else {$urgentmkr="";}
  if ($row[repliedto]=="1") {$replied="<a title='Auf diese Nachricht wurde bereits geantwortet!'><font color='grey'><strong> beantwortet am: </strong></grey></a>";} else {$replied=" ";}
  echo "<tr><td>$status$urgentmkr <a href=".$link."&action=view&message_id=".$row[message_id]."&page=viewmessage".$pagenum.">".strip_tags($row[Subject])."</a><small>".$replied."(".$datetime.")</small>";
  // put in asterisks if indicated to do so in database
  echo "</td>";
  echo "<td>".$this->Format($row[UserFrom])."<small> [<a href=".$link."&action=contacts&cntct=".$row[UserFrom].">-></a>]</small></td><td align='left' width='155'>";

  // code to put in drop down box to move to a new folder
  $str2 = "SELECT DISTINCT info FROM ".$this->config["table_prefix"]."messengerinfo WHERE type='folder' and owner='$username' ORDER BY info ASC";
  $resultdrop2 = mysql_query($str2);
  echo "<form method=post action=\"$link&message_id=$row[message_id]\"><select name=\"move2folder\">";
    while ($row2 = mysql_fetch_array($resultdrop2))
      {
      extract ($row2);
	     echo "<option value=\"$info\">$info</option>";
         }
    echo "</select><input type='submit' value='Verschieben'></form>";
    echo "</td><td> [<a href=\"javascript: if(confirm('Bist Du sicher, dass Du diesen Eintrag löschen möchtest?')){ window.self.location='".$link."&action=delete&id=".$row[message_id]."' }\">Löschen</a>]<br /></td>";
 }
 echo "</table>";
 if ($total_records!=0) {
 echo "<br ><br >   Um eine Nachricht zu lesen, klick auf den <b>Betreff</b> der jeweiligen Nachricht!";
 echo "<br ><br ><font color= #ff0000>   Durch klicken auf den Pfeil [->] hinter dem Namen des Absenders, wird der User zur Kontaktliste hinzugefügt.<br /></font>";
    }else{
    echo "<br >   Zur Zeit sind keine Nachrichten im Posteingang <br ><br >";
 }
}

// send a new message to a user
elseif($action==compose) {
 $subject2=$_GET[subject];
 echo "<br ><b>Nachricht verfassen....</b><br ><br >";
 echo "<table width='675'><tr><td>";
 echo "<form name='myform' action=".$link."&action=compose2 method='post'>";
 echo "<table>";
 echo "<tr><td>Betreff:</td><td><input type='text' name='subject' maxlength='65' size='30' value='$subject2'></td></tr>";
 echo "<tr><td>Empfänger:</td><td><input type='text' name='to' maxlength='65' size='30' value='$to'></td></tr>";
 echo "<tr><td>Nachricht:</td><td><textarea rows='16' cols='45' name='message' onKeyDown=\"textCounter(this.form.message,this.form.remLen,2000);\" onKeyUp=\"textCounter(this.form.message,this.form.remLen,2000);\"></textarea><br /><input readonly type='text' name='remLen' size='4' maxlength='4' value='2000'> Zeichen stehen noch zur Verfügung.</td></tr>";
 echo "<tr><td><button type='submit'>Abschicken!</button></td><td align='right'>Dringend? <INPUT TYPE='checkbox' NAME='urgent' VALUE='1'></td></tr>";
 echo "<tr><td></td><td><font color= #ff0000>Alle Felder müssen ausgefüllt sein!</font></td></tr></table>";
 echo "</form>";
 echo "</td><td width='200' valign='top'>";
 ?>
 Um einen User zu Deiner Kontaktliste hinzuzufügen bitte <a href="<?php echo $link; ?>&action=users">hier</a> klicken!<br ><br >
 <?php
 echo "<b>Kontakt-Liste:<br /></b><small>(Klick auf den Namen um den User<br >als Empfänger einzusetzen)</small><br ><br >";
 $cntctresult = mysql_query("SELECT info FROM ".$this->config["table_prefix"]."messengerinfo WHERE type='contact' and owner='$username' ORDER BY info ASC");
 while ($row=mysql_fetch_array($cntctresult)) {
   echo "<a href=".$link."&action=compose&to=".urlencode($row[info]).">".$row['info']."</a><br />";
   }
   echo "</td></tr></table>";
}

// Antwort an den Absender einer Nachricht schicken
elseif($action==reply) {
 $subject2=$_GET[subject];
 echo "<br ><b>Antwort erstellen....</b><br ><br >";
 echo "<table width='400'><tr><td>";
 echo "<form name='myform' action=".$link."&action=compose2&replyto=".$msg_id." method='post'>";
 echo "<tr><td>Betreff:</td><td><input readonly type='text' name='subject' maxlength='65' size='30' value='$subject2'></td></tr>";
 echo "<tr><td>Empfänger:</td><td><input readonly type='text' name='to' maxlength='65' size='30' value='$to'></td></tr>";
 $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."messenger WHERE UserTo='$username' AND message_id=$message_id") or die ("cant do it");
 $rowreply=mysql_fetch_array($result);
 $origmsg=" \n \n++++++++++ Original Message ++++++++++\n".strip_tags($rowreply[Message])."\n+++++++++++++++++++++++++++++++++";
 echo "<tr><td>Nachricht:</td><td><textarea rows='16' cols='45' name='message' onKeyDown=\"textCounter(this.form.message,this.form.remLen,2000);\" onKeyUp=\"textCounter(this.form.message,this.form.remLen,2000);\">".$origmsg."</textarea><br /><input readonly type='text' name='remLen' size='4' maxlength='4' value='2000'> Zeichen stehen noch zur Verfügung.</td></tr>";
 echo "<tr><td><button type='submit'>Abschicken!</button></td><td align='right'>Dringend? <INPUT TYPE='checkbox' NAME='urgent' VALUE='1'></td></tr>";
 echo "<tr><td></td><td><font color= #ff0000>Alle Felder müssen ausgefüllt sein!</font></td></tr></table>";
 echo "</form>";
}

// ergänzte Nachricht verschicken
elseif($action==forward && $message_id!="") {
 $username = $this->GetUserName();
 echo "<br ><b>Nachricht ergänzen....</b><br ><br >";
 echo "<table width='675'><tr><td>";
 echo "<form name='myform' action=".$link."&action=compose2 method='post'>";
 echo "<table>";
 $subject2 = "FWD: ".$subject;
 echo "<tr><td>Betreff:</td><td><input type='text' name='subject' maxlength='65' size='30' value='$subject2'></td></tr>";
 echo "<tr><td>Empfänger:</td><td><input type='text' name='to' maxlength='65' size='30' value='$to'></td></tr>";
 $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."messenger WHERE UserTo='$username' AND message_id=$message_id") or die ("cant do it");
 $rowfwd=mysql_fetch_array($result);
 $origmsg=" \n \n++++++++++++ Forward ++++++++++++++\n".strip_tags($rowfwd[Message])."\n+++++++++++++++++++++++++++++++++";
 echo "<tr><td>Nachricht:</td><td><textarea rows='16' cols='45' name='message' onKeyDown=\"textCounter(this.form.message,this.form.remLen,2500);\" onKeyUp=\"textCounter(this.form.message,this.form.remLen,2500);\">$origmsg</textarea><br /><input readonly type='text' name='remLen' size='4' maxlength='4' value='2500'> Zeichen stehen noch zur Verfügung.</td></tr>";
 echo "<tr><td><button type=submit>Abschicken!</button></td><td align='right'>Dringend? <INPUT TYPE='checkbox' NAME='urgent' VALUE='1'></td></tr>";
 echo "<tr><td></td><td><font color= #ff0000>Alle Felder müssen ausgefüllt sein!</font></td></tr></table>";
 echo "</form>";
 echo "</td><td width='200' valign='top'>";
 ?>
 Um einen User zu Deiner Kontaktliste hinzuzufügen bitte <a href="<?php echo $link; ?>&action=users">hier</a> klicken!<br ><br >
 <?php
 echo "<b>Kontakt-Liste:<br /></b><small>(Klick auf den Namen um den User<br >als Empfänger einzusetzen)</small><br ><br >";
 $cntctresult = mysql_query("SELECT info FROM ".$this->config["table_prefix"]."messengerinfo WHERE type='contact' and owner='$username' ORDER BY info ASC");
 while ($row=mysql_fetch_array($cntctresult)) {
    echo "<a href=".$link."&action=forward&to=$row[info]&message_id=$message_id&subject=".urlencode($subject).">".$row['info']."</a><br />";
 }
 echo "</td></tr></table>";
}

 // schreibt versendete Nachrichten (original/ergänzte) in die Datenbank
if($action==compose2) {
 if ($user = $this->GetUser()){
  $urgent=$_POST['urgent'];
  $to=$_POST['to'];
  $to=addslashes($to);
  $subject=$_POST['subject'];
  $subject=addslashes($subject);
  $message=$_POST['message'];
  $message=strip_tags($message);
  $message=addslashes($message);
  $replyto=$_GET['replyto'];
  $date = date(YmdHis);

  // prüft ob der User existiert und versendet die Nachricht

    if($subject=="" || $message=="" || $to==""){
	?>
      <br ><center><font color= #ff0000>Ein Feld wurde nicht ausgefüllt. Es müssen alle Felder ausgefüllt sein!!</font></center><br ><br ><a href="<?php echo $link; ?>&action=compose">Zurück</a>
	<?php
      }else{
       if($this->LoadUser($to)) {
        $create = "INSERT INTO ".$this->config["table_prefix"]."messenger (UserTo, folder, UserFrom, Subject, Message, DateSent, status, urgent)
        VALUES ('$to','inbox','$username','$subject','$message','$date','nicht gelesen','$urgent')";
        $create2 = mysql_query($create) or die("Die Nachricht konnte nicht an $to versendet werden!");
        echo("Nachricht gesendet an $to!<br /><br /><br /><br /><br /><br /><br />");
      //to set the database so that the message has been replied to
         mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET repliedto='1' WHERE message_id='$replyto' AND UserTo='$username'");
    } else {
	?>
        <br ><center><font color= #ff0000>Die Nachricht konnte nicht versendet werden, da der eingetragende Empfänger kein registrierter Benutzer ist.<br ><br >Überprüfe die Schreibweise (Gross- / Kleinschreibung)!</font><br ><br ></center><a href="<?php echo $link; ?>&action=compose">Zurück</a>
	<?php
        }
   }
  }else{
  echo "<br /><font color= #ff0000>Du must registriert und eingeloggt sein um das Message-System nutzen zu können!</font><br />";
 }
}


// zeigt den Ordner "versendete Nachrichten"
elseif($action=='sent') {
 $query="SELECT * from ".$this->config["table_prefix"]."messenger where UserFrom='$username' ORDER BY DateSent DESC";
 $result=mysql_query($query) or die ("cant do it");
 echo "<table cellpadding='2' cellspacing='3' width='750' valign='top'>";
       //needed for pagination of sent box
       $record_per_page=12;
    $total_records=mysql_num_rows($result);
       $scroll=3;
    $page=new Page(); //creating new instance of Class Page
    $link2=$link."&action=sent";
       $page->set_page_data($link2,$total_records,$record_per_page,$scroll,true,true,true);
    $result=mysql_query($page->get_limit_query($query));
    // to paginate the "sent" page messages
    echo "<tr><td colspan='3' align='center'>";   
     if ($total_records>$record_per_page) {echo $page->get_page_nav();}
    echo "</td></tr>";
  echo  "<tr bgcolor=#93B2DD>\n";
  echo  "<td width='400'> <b>Betreff:</b></td>\n";
  echo  "<td width='85'> <b>Empfänger:</b></td>\n";
  echo  "<td width='75'> <b>Gelesen?</b></td>\n";
  echo  "</tr>\n";
  while ($row=mysql_fetch_array($result)) {
   $datetime=date("dMy g:i a",strtotime($row['DateSent']));
   echo "<tr><td><a href=".$link."&action=view2&message_id=".$row[message_id]."&page=view2".$pagenum.">".strip_tags($row[Subject])."</a><small> (".$datetime.")</small></td><td>".$this->Format($row[UserTo])."<small> [<a href=".$link."&action=contacts&cntct=".$row[UserTo].">-></a>]</small></td><td width=50> $row[status]<br /></td></tr>";
  }
  echo "</table>";
  echo "<br ><br ><font color= #ff0000>   Durch klicken auf den Pfeil[->] hinter dem Namen des Absenders, wird der User zur Kontaktliste hinzugefügt.</font><br ><br >   Löscht der Empfänger eine Nachricht, wird sie auch hier automatisch entfernt!";
}

// Code to show folders according to selection
elseif((($_REQUEST['whichfolder']!='') || ($folder)) && ($action!=view)) {
 if ($filter==1) {$search="and fltr1='1' ";} elseif ($filter==2) {$search="and fltr2='1' ";} elseif ($filter==3) {$search="and fltr3='1' ";} elseif ($filter==N) {$search="and fltr1='0' and fltr2='0' and fltr3='0' ";} else {$search="";}
 if ($_REQUEST['whichfolder']!='') {$showfolder = $_REQUEST['whichfolder'];} else {$showfolder=$folder;}
 echo "<table cellpadding='2' cellspacing='3' width='800' valign='top'>";
   echo  "<tr bgcolor=#93B2DD>\n";
   echo  "<td><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td width='400'><b> Betreff:</b></td><td align='right'>";
   if ($filter==1) {$red="<u>*</u>";} else {$red="*";}
   if ($filter==2) {$blue="<u>*</u>";} else {$blue="*";}
   if ($filter==3) {$green="<u>*</u>";} else {$green="*";}
   if ($filter=="N") {$none="<u>N</u>";} else {$none="N";}
   echo  "</td></tr></table></td>\n";
   echo  "<td width='100'><b> Absender:</b></td>\n";
   echo  "<td width='250'><b> In Ordner verschieben:</b></td>\n";
   echo  "<td width='80'><b> Löschen:</b></td>\n";
   echo  "</tr>\n";
  $query="SELECT fltr1,fltr2,fltr3,message_id FROM ".$this->config["table_prefix"]."messenger where UserTo='$username' ".$search."and folder='$folder' and viewrecipient='Y' ORDER BY DateSent DESC";
  $result=mysql_query($query) or die ("cant do it");
  while ($row=mysql_fetch_array($result)) {
   // code to set filters in database
    if (($fltrset) && ($row[message_id]==$msg_id)) {
       // code to determine setting of filters on server
       if ($row[fltr1]!=1) {$fltrvar1=1;} else {$fltrvar1=0;}
       if ($row[fltr2]!=1) {$fltrvar2=1;} else {$fltrvar2=0;}
       if ($row[fltr3]!=1) {$fltrvar3=1;} else {$fltrvar3=0;}
       // code to set which filter is being set
       if ($fltrset==1) {$fltr="fltr1"; $set=$fltrvar1;} elseif ($fltrset==2) {$fltr="fltr2"; $set=$fltrvar2;} elseif ($fltrset==3) {$fltr="fltr3"; $set=$fltrvar3;}
       mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET ".$fltr."=".$set." WHERE message_id='$msg_id' AND UserTo='$username'");
    }
  }

 $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."messenger where UserTo='$username' ".$search."AND folder='$showfolder' ORDER BY DateSent DESC") or die ("cant do it");
 $numrows=mysql_num_rows($result);
    while ($row=mysql_fetch_array($result)) {
    $datetime=date("dMy g:i a",strtotime($row['DateSent']));
    if ($row[status]=="unread") {$status="<a title='This message has not been read yet!'><font color=Red>*</font></a>";} else {$status="";}
       if ($row[urgent]=="1") {$urgentmkr="<a title='This is an urgent message!'><font color=Red><strong>!</strong></font></a>";} else {$urgentmkr="";}
    if ($row[repliedto]=="1") {$replied="<a title='You have replied to this message!'><font color='black'><strong>+</strong></black></a>";} else {$replied=" ";}
    echo "<tr><td>$status$urgentmkr <a href=".$link."&action=view&message_id=$row[message_id]&folder=".$which.">".strip_tags($row[Subject])."</a>".$replied."<small>(".$datetime.")</small>";
      // put in asterisks if indicated to do so in database
      if ($row[fltr1]==1) {echo "<font color='red'><strong>*</strong></font>";} else {echo "  ";}
      if ($row[fltr2]==1) {echo "<font color='blue'><strong>*</strong></font>";} else {echo "  ";}
      if ($row[fltr3]==1) {echo "<font color='green'><strong>*</strong></font>";} else {echo "  ";}
    echo "</td><td width=125>".$this->Format($row[UserFrom])."<small> [<a href=".$link."&action=contacts&cntct=".$row[UserFrom].">-></a>]</small></td><td>";

      // code to put in drop down box to move to a new folder
      $str2 = "SELECT DISTINCT info FROM ".$this->config["table_prefix"]."messengerinfo WHERE type='folder' and owner='$username' ORDER BY info ASC";
      $resultdrop2 = mysql_query($str2);
    echo "<form method=post action=\"$link&message_id=$row[message_id]&folder=$which\"><select name=\"move2folder\">";
       while ($row2 = mysql_fetch_array($resultdrop2))
       {
        extract ($row2);
           echo "<option value=\"$info\">$info</option>";
       }
      echo "</select><input type='submit' value='Verschieben'></form>";
      echo "</td><td> [<a href=\"javascript: if(confirm('Bist Du sicher, dass Du diesen Eintrag löschen möchtest?')){ window.self.location='".$link."&action=delete&id=".$row[message_id]."' }\">Löschen</a>]<br /></td>";
      }
   echo "</table>";
 if ($numrows==0) {echo "<br >   Zur Zeit sind keine Nachrichten in diesem Ordner! <br ><br >"; }
}

// view individual messages
elseif($action==view) {
 $result=mysql_query("select * from ".$this->config["table_prefix"]."messenger where UserTo='$username' and message_id=$msg_id") or die ("cant do it");
 $row=mysql_fetch_array($result);
    if (($fltrset) && ($row[message_id]==$msg_id)) {
       // code to determine setting of filters on server
       if ($row[fltr1]!=1) {$fltrvar1=1;} else {$fltrvar1=0;}
       if ($row[fltr2]!=1) {$fltrvar2=1;} else {$fltrvar2=0;}
       if ($row[fltr3]!=1) {$fltrvar3=1;} else {$fltrvar3=0;}
       // code to set which filter is being set
       if ($fltrset==1) {$fltr="fltr1"; $set=$fltrvar1;} elseif ($fltrset==2) {$fltr="fltr2"; $set=$fltrvar2;} elseif ($fltrset==3) {$fltr="fltr3"; $set=$fltrvar3;}
       mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET ".$fltr."=".$set." WHERE message_id='$msg_id' AND UserTo='$username'");
    }
 $result=mysql_query("select * from ".$this->config["table_prefix"]."messenger where UserTo='$username' and message_id=$msg_id") or die ("cant do it");
 $row=mysql_fetch_array($result);
 $username=strtolower($username);
 $row[UserTo]=strtolower($row[UserTo]);
 if ($row[repliedto]=="1") {$replied="<a title='You have replied to this message at least once!'><font color='black'><small>replied to<small></black></a>";} else {$replied=" ";}
   // code to set filters in database
  if($row[UserTo]==$username) {
    $query="UPDATE ".$this->config["table_prefix"]."messenger SET status='gelesen' WHERE UserTo='$username' AND message_id='$row[message_id]'";
    $query or die("An error occurred resulting that this message has not been marked read.");
    $datetime=date("dMy g:i a",strtotime($row['DateSent']));
    echo "<table border='1' bordercolor='#666699' width='600'><tr><td width='350'><strong> Betreff: </strong>".strip_tags($row[Subject])." ";
      // put in asterisks if indicated to do so in database
      if ($row[fltr1]==1) {echo "<font color='red'><strong>*</strong></font>";} else {echo "  ";}
      if ($row[fltr2]==1) {echo "<font color='blue'><strong>*</strong></font>";} else {echo "  ";}
      if ($row[fltr3]==1) {echo "<font color='green'><strong>*</strong></font>";} else {echo "  ";}
    echo "</td><td>";
    echo "</td><td><strong> Von: </strong>".$this->Format($row[UserFrom])."<small> [<a href=".$link."&action=contacts&cntct=".$row[UserFrom].">-></a>]</small></td></tr>";
    echo "<tr><td colspan='3'><strong> Nachricht: </strong>".strip_tags($row[Message])."</td></tr><tr><td><a href=".$link."&action=reply&to=".$row[UserFrom]."&message_id=".$row[message_id]."&subject=RE:".urlencode($row[Subject])."> Antworten</a> / <a href=".$link."&action=forward&message_id=$row[message_id]&subject=RE:".urlencode($row[Subject]).">Ergänzen</a>";
    echo " / <a href=\"javascript: if(confirm('Bist Du sicher, dass Du diesen Eintrag löschen möchtest?')){ window.self.location='".$link."&action=delete&id=".$row[message_id]."' }\">Löschen</a></td><td>".$replied."</td><td><small><strong> Gesendet am:</strong> $datetime</small></td></tr></table><br />";
    $rs = mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET status='gelesen' WHERE message_id='$msg_id'");
    } else {
    echo "<font face=verdana><strong>Das ist nicht Deine Post!";    
    }
  echo "<br ><br ><font color= #ff0000>   Durch klicken auf den Pfeil[->] hinter dem Namen des Absenders, wird der User zur Kontaktliste hinzugefügt.</font>";
}

// added filter for viewing "folder sorted" messages	
elseif($action==view2) {
 $result=mysql_query("SELECT * from ".$this->config["table_prefix"]."messenger where UserFrom='$username' and message_id='$msg_id'") or die ("cant do it");
 $row=mysql_fetch_array($result);
 $username=strtolower($username);
 $userfrom=strtolower($row[UserFrom]);
 if($userfrom==$username) {
    $datetime=date("dMy g:i a",strtotime($row['DateSent']));
    echo "<table border = '1' bordercolor = 'black' width = '600'><tr><td colspan='2' valign='top'><strong>Betreff:</strong> ".strip_tags($row[Subject])."</td></tr><tr>";
    echo "<td colspan='2'><strong>Empfänger:</strong> ".$this->Format($row[UserTo])."<small> [<a href=".$link."&action=contacts&cntct=".$row[UserTo].">-></a>]</small></td></tr><tr><td colspan='2'><strong>Nachricht: </strong>$row[Message]</td></tr><tr><td colspan='2'><small><strong>Gesendet: </strong>".$datetime."</small></td></tr></table>";
 }
 echo "<br ><br ><font color= #ff0000>   Durch klicken auf den Pfeil[->] hinter dem Namen des Absenders, wird der User zur Kontaktliste hinzugefügt.</font>";
}

// Nachrichten löschen (geändert - Nachrichten werden jetzt komplett aus Datenbank entfernt)
elseif($action==delete) {
    $query="DELETE FROM ".$this->config["table_prefix"]."messenger WHERE UserTo='$username' AND message_id='$id'";
    $query or die("Aufgrund eines Fehlers wurde die Nachricht nicht gelöscht.");
    $rs = mysql_query("DELETE From ".$this->config["table_prefix"]."messenger WHERE message_id='$id'");
    if($query) {
    echo "<font face=verdana>Die Nachricht wurde gelöscht.<br /><br /><br /><br /><br /><br /><br /></font>";
        } else {
        echo "Die Nachricht wurde nicht gelöscht.";
    }
}

// Kontaktliste verwalten
elseif ($action==contacts){
 $addcontact=$_GET['cntct'];
 $table = $this->config["table_prefix"]."messengerinfo";
 $field1 = "info";
 $field1_label = " Name:";
 $field2 = "notes";
 $field2_label = " Bemerkung:";
 $deletecnt = $_GET['deletecnt'];
 $field1_value=$_POST['field1_value'];
 if ($field1_value) {$insert="1";} else {$insert="";}
 $field2_value=$_POST['field2_value'];
 $category="contact";

 if ($user = $this->GetUser()){
   if ($insert) {
    if($this->LoadUser($field1_value)) {
    mysql_query( "INSERT into $table ($field1, $field2, owner, type) values (\"$field1_value\",\"$field2_value\",\"$username\",\"$category\")");
    }
   }
  if ($deletecnt) {
    mysql_query( "DELETE from $table WHERE id=$deletecnt AND owner='$username'");
  } 
  if (mysql_errno()!=0) {
    switch (mysql_errno()) {
      default:
        echo  "Error #".mysql_errno(). " (".mysql_error(). ")<br>";
    }
   }
 }
  $query =  "SELECT * from $table WHERE owner='$username' AND type='$category' ORDER BY info ASC";
  $result = mysql_query($query);
  $rows = mysql_num_rows($result);
  echo  "<br ><b>Kontaktliste:</b><br ><br >";
  echo  "<table border='1' cellspacing='0' width= 70% align=left>\n";
  echo  "<tr>\n";
  echo  "<td><strong>$field1_label</strong></td>\n";
  echo  "<td><strong>$field2_label</strong></td>\n";
  echo  "<td> </td>\n";
  echo  "</tr>\n";
 // This is the entry boxes
  echo  "<form action=\"$link&action=contacts\" method=\"post\">\n";
  echo  "<tr>\n";
  echo  "<input type='hidden' name='insert' value='1'></td>\n";
  echo  "<td><input type='text' size='25' maxlength='65' name='field1_value' value='$addcontact'></td>\n";
  echo  "<td><input type='text' size='35' maxlength='65' name='field2_value'></td>\n";
  echo  "<td colspan=2 align=center>";
  echo  "<input type='submit' value=\"   Hinzufügen    \"></td>\n";
  echo  "</tr>\n";
  echo  "</form>\n";
 
 // This is the data under the entry boxes
      while ($row = mysql_fetch_row($result)) {
      echo  "<tr>\n";
      echo  "<td><a href=".$link."&action=compose&to=".$row[2].">".$row[2]."</a><small>  [<a href=".$this->config["base_url"].$row[2].">Home Page</a>]</small></td>\n";
         echo  "<td>".strip_tags($row[3])."</td>\n";
      echo  "<td><a href=\"javascript: if(confirm('Bist Du sicher, dass Du diesen Eintrag löschen möchtest?')){ window.self.location='".$link."&action=contacts&deletecnt=".$row[4]."' }\"><center>Löschen</center></a></td>\n";
      echo  "</tr>\n";
      }  
  echo "</table>";
  echo "<table>";
  echo "<td width='25' valign='top' ></td>";
  echo "<td width='150' valign='top' >";
  echo "<left><font color= #ff0000>Klick auf den Benutzernamen um einem Benutzer aus der Kontaktliste eine Nachricht zu schreiben.</font></left><br ><br >";
   ?>
 Um einen Benutzer zu Deiner Kontaktliste hinzuzufügen bitte <a href="<?php echo $link; ?>&action=users">hier</a> klicken!<br ><br >Es können <b>nur</b> registrierte Benutzer hinzugefügt werden.
 <?php
  echo "</td></table>";
}

// Ordner verwalten
elseif ($action==folders){
 $table = $this->config["table_prefix"]."messengerinfo";
 $field1 = "info";
 $field1_label = " Ordner:";
 $field2 = "notes";
 $field2_label = " Beschreibung:";
 $deletefldr = $_GET['deletefldr'];
 $fldr = $_GET['fldr'];
 $field1_value=$_POST['field1_value'];
 if ($field1_value) {$insert="1";} else {$insert="";}
 $field2_value=$_POST['field2_value'];
 $category="folder";

 if ($user = $this->GetUser()){
  if ($insert) {
        mysql_query( "INSERT into $table ($field1, $field2, owner, type) values (\"$field1_value\",\"$field2_value\",\"$username\",\"$category\")");
  }

  if ($deletefldr) {
  // delete folder name from messengerinfo
    mysql_query("DELETE from $table WHERE id='$deletefldr' AND owner='$username' AND type='folder'");
  // change files from being stored in folder being deleted to being stored in inbox
    mysql_query("UPDATE ".$this->config["table_prefix"]."messenger SET folder='inbox' WHERE folder='$fldr' AND UserTo='$username'");
  } 
 
  if (mysql_errno()!=0) {
   switch (mysql_errno()) {
    default:
       echo  "Error #".mysql_errno(). " (".mysql_error(). ")<br>";
   }
  }
 }
  $query =  "SELECT * from $table WHERE owner='$username' AND type='$category' ORDER BY info ASC";
  $result = mysql_query($query);   
  $rows = mysql_num_rows($result);
  echo  "<br ><b>Ordner verwalten:</b><br ><br >";
  echo  "<table border='1' cellspacing='0' width= 65% align=left>\n";
  echo  "<tr>\n";
  echo  "<td><strong>$field1_label</strong></td>\n";
  echo  "<td><strong>$field2_label</strong></td>\n";
  echo  "<td> </td>\n";
  echo  "</tr>\n";

 // This is the entry boxes
  echo  "<form action=\"$link&action=folders\" method=\"post\">\n";
  echo  "<tr>\n";
  echo  "<input type='hidden' name='insert' value='1'></td>\n";
  echo  "<td><input type='text' size='25' maxlength='65' name='field1_value'></td>\n";
  echo  "<td><input type='text' size='35' maxlength='65' name='field2_value'></td>\n";
  echo  "<td colspan='2' align='center'>";
  echo  "<input type='submit' value=\"   Hinzufügen    \"></td>\n";
  echo  "</tr>\n";
  echo  "</form>\n";
 // This is the data under the entry boxes
      while ($row = mysql_fetch_row($result)) {
      echo  "<tr>\n";
      echo  "<td><a href=".$link."&folder=".strip_tags($row[2]).">".strip_tags($row[2])."</a></td>\n";
         echo  "<td>".strip_tags($row[3])."</td>\n";
      echo  "<td><a href=\"javascript: if(confirm('Bist Du sicher, dass Du diesen Eintrag löschen möchtest?')){ window.self.location='".$link."&action=folders&deletefldr=".$row[4]."&fldr=".$row[2]."' }\">
  <center>Löschen</center></a></td>\n";
      }
    echo "</table>";
    echo "<table>";
  echo "<td width='25' valign='top' ></td>";
  echo "<td width='200' valign='top' >";
  echo "<left><font color= #ff0000>Klick auf den Ordnernamen um einen Ordner zu öffnen!</font></left><br ><br ><b>Ordner erstellen:</b><br ><br >Gib in das leere Feld unter <b>Ordner:</b> den Namen für den neuen Ordner ein.<br ><br >In das Feld <b>Beschreibung:</b> kannst Du eine Beschreibung für den Ordner eingeben.<br ><br >Nun noch ein Klick auf <b>Hinzufügen</b> und der neue Ordner steht Dir zur Verfügung.";
  echo "</td></table>";
}

// code to display user list
elseif ($action==users){
 echo "<table width='650'><tr><td>"; 
 $last_users = $this->LoadAll("select name from ".$this->config["table_prefix"]."users order by name ASC");
 echo "<br ><b>Benutzer:</b><br ><br >";
  foreach($last_users as $user)
   {
    echo "<a href=".$link."&action=contacts&cntct=".$user["name"].">".$user["name"]."</a> ";
   }
  echo "</td></tr></table>";
  echo "<font color= #ff0000><br ><br >  Klick auf den Namen um den User zu Deiner Kontaktliste hinzuzufügen!</font><br ><br >";
}

//Hilfe
elseif ($action==help){
echo "<table width='700'><tr><td>";
echo "<a name= anfang></a>";
echo "<h3><center>Hilfe für das WackoWiki-Message-System</center></h3>";
echo "<br ><br >Auf dieser Seite gibt es einige Hilfestellungen zu den Funktionen des WackoWiki-Message-Systems. Die Erklärungen sind kurz gehalten, da die meisten Funktionen selbsterklärend sind.<br >Nachfolgend findest Du ein Inhaltsverzeichnis zu den hier erläuterten Funktionen:<br ><br ><br >";

echo "<a href=#post>Posteingang</a><br >";
echo "<a href=#verf>Verfassen</a><br >";
echo "<a href=#vers>Postausgang</a><br >";
echo "<a href=#verw>Verwalten</a><br >";
echo "   - <a href=#ordn>Ordner</a><br >";
echo "   - <a href=#kont>Kontaktliste</a><br >";

echo "<a href=#benu>Benutzer</a><br ><br >";
echo "<a name= post><center><h3>Posteingang</h3></center></a><br ><br >";
echo "Im Posteing werden alle eingetroffenen Nachrichten angezeigt, sowie einige zusätzliche Info`s zu den einzelnen Nachrichten.<br ><br >In der folgenden Darstellung siehst Du ein Beispiel, wie der Posteingangsordner aussehen kann:<br ><br ><br >";

echo "<table>";
echo "<tr bgcolor='#93B2DD'>";
echo "<td width='400'>";
echo "<table border='0' cellspacing='0' cellpadding='0' width='100%'>";
echo "<tr><td width='100'><b> Betreff:</b></td></td></tr></table></td>";
echo "<td width='100'><b> Absender:</b></td>";
echo "<td width='250'><b> Verschieben in Ordner:</b></td>";
echo "<td width='80'><b> Löschen:</b></td></tr></table>";

echo "<table>";
echo "<tr>";
echo "<td width='400'>";
echo "<table border='0' cellspacing='0' cellpadding='0' width='100%'>";
echo "<tr><td width='100'><font color= #ff0000>!*</font><a href=#test>Testnachricht</a> (03Jun06 2:57 pm)</td></td></tr></table></td>";
echo "<td width='100'><a href=#testuser>Testuser</a> [<a href=#pfeil>-></a>]</td>";
echo "<td width='250'><form method=post <select name=\"move2folder\"></select><input type='submit' value='Verschieben'></form></td>";
echo "<td width='80'>[<a href=#loeschen>Löschen</a>]</td></tr></table>";

echo "<table>";
echo "<tr>";
echo "<td width='400'>";
echo "<table border='0' cellspacing='0' cellpadding='0' width='100%'>";
echo "<tr><td width='100'><font color= #ff0000>!</font><a href=#test1>Testnachricht1</a><font color= #808080><small><b> beantwortet am:</b> (01Jun06 1:02 pm)</font></small></td></td></tr></table></td>";
echo "<td width='100'><a href=#testuser>Testuser16</a> [<a href=#pfeil>-></a>]</td>";
echo "<td width='250'><right><form method=post <select name=\"move2folder\"></select><input type='submit' value='Verschieben'></form></right></td>";
echo "<td width='80'>[<a href=#loeschen>Löschen</a>]</td></tr></table><br >";

echo "<a href=#anfang>Seitenanfang</a><br ><br >";
echo "<h4><center>Was bedeuten die Zeichen vor und hinter den Nachrichten?</center></h4><br ><br > - Das <b><font color= #ff0000>!</font></b> vor einer Nachricht erscheint, wenn der Absender die Nachricht als <b>dringend</b> markiert hat.<br ><br > - Das <b><font color= #ff0000>*</font></b> vor der Nachricht zeigt an, das die Nachricht noch nicht gelesen wurde. Sobald die Nachricht gelesen wurde verschwindet<br>   das <b><font color= #ff0000>*</font></b> und der Absender erhält die Information, dass die Nachricht gelesen wurde.<br ><br >";
echo " - Die Daten hinter der Nachricht geben an, wann die Nachricht erhalten bzw. gesendet wurde. Ausserdem wird in einer anderen<br>   Farbe angezeigt ob und wann eine Nachricht beantwortet wurde.<br ><br ><center><h4>Wie kann ich eine Nachricht öffnen?</center></h4><br ><br >Um eine Nachricht zu lesen muss man auf den <b>Betreff</b> der Nachricht klicken, die geöffnet werden soll. Anschliessend wird die Nachricht<br >in einem neuen Fenster dargestellt.<br ><br ><center><h4>Nachrichten in andere Ordner verschieben!</center></h4><br ><br >";
}
?>


Das folgende Script muss unter dem Namen messenger.page.inc.php gespeichert werden und ebenfalls im Ordner /actions gespeichert werden.


/actions/messenger.page.inc.php

<?php


    /*
    ###############################################
    ####                                       ####
    ####    Author : Harish Chauhan            ####
    ####    Date   : 27 Sep,2004               ####
    ####    Updated:                           ####
    ####                                       ####
    ###############################################

    */
// Original class script obtained from http://www.phpclasses.org/browse/package/2012.html distributed as "Freeware"
// Modifications (Ver 1.0b) by GmBowen so that script useable with wikka wiki to support a "messanger" action developed for the wiki.
// Throughout this class "?page" was changed to "&page" as well as other minor modifications throughout the script.

    class Page
    {
      var $total_records=1;   ///Total Records returned by sql query
      var $records_per_page=1;    ///how many records would be displayed at a time
      var $page_name=""; ///page name on which the class is called
      var $start=0;
      var $page=0;
      var $total_page=1;
      var $current_page;
      var $remain_page;
      var $show_prev_next=true;
      var $show_scroll_prev_next=false;
      var $show_first_last=false;
      var $show_disabled_links=true;
      var $scroll_page=0;
      var $qry_str="";
      var $link_para="&";

      /* returns boolean value if it is last page or not*/   
      function is_last_page()
      {
       return $this->page>=$this->total_page-1?true:false;
      }
      /* param : Void
        returns boolean value if it is first page or not*/   
      function is_first_page()
      {
       return $this->page==0?true:false;
      }
      function current_page()
      {
       return $this->page+1;
      }
      function total_page()
      {
       return $this->total_page==0?1:$this->total_page;
      }
     
      //@param : $show = if you want to show disabled links on navigation links.
      //
      function show_disabled_links($show=TRUE)   
      {
          $this->show_disabled_links=$show;
      }
      //@param : $link_para = if you want to pass any parameter to link
      //
      function set_link_parameter($link_para)
      {
          $this->link_para=$link_para;
      }
      function set_page_name($page_name)
      {
       $this->page_name=$page_name;
      }
      //@param : str= query string you want to pass to links.
      function set_qry_string($str="")
      {
       $this->qry_str="&".$str;
      }
      function set_scroll_page($scroll_num=0)
      {
        if($scroll_num!=0)
            $this->scroll_page=$scroll_num;
        else
            $this->scroll_page=$this->total_records;

      }
      function set_total_records($total_records)
      {
       if($total_records<0)
          $total_records=0;
       $this->total_records=$total_records;
      }
      function set_records_per_page($records_per_page)
      {
        if($records_per_page<=0)
              $records_per_page=$this->total_records;
        $this->records_per_page=$records_per_page;
      }
      /* @params
      *     $page_name = Page name on which class is integrated. i.e. $_SERVER['PHP_SELF']
      *      $total_records=Total records returnd by sql query.
      *     $records_per_page=How many projects would be displayed at a time
      *        $scroll_num= How many pages scrolled if we click on scroll page link.
      *                 i.e if we want to scroll 6 pages at a time then pass argument 6.
      *     $show_prev_next= boolean(true/false) to show prev Next Link
      *     $show_scroll_prev_next= boolean(true/false) to show scrolled prev Next Link
      *     $show_first_last= boolean(true/false) to show first last Link to move first and last page.
      */
     
      function set_page_data($page_name,$total_records,$records_per_page=1,$scroll_num=0,$show_prev_next=true,$show_scroll_prev_next=false,$show_first_last=false)
      {
       $this->set_total_records($total_records);
       $this->set_records_per_page($records_per_page);
       $this->set_scroll_page($scroll_num);
       $this->set_page_name($page_name);
       $this->show_prev_next=$show_prev_next;
       $this->show_scroll_prev_next=$show_scroll_prev_next;
       $this->show_first_last=$show_first_last;
      }
      /* @params
      *  $user_link= if you want to display your link i.e if you want to user '>>' instead of [first] link then use
        Page::get_first_page_nav(">>") OR for image
        Page::get_first_page_nav("<img src='' alt='first'>")
        $link_para: link parameters i.e if you want ot use another parameters such as class.
        Page::get_first_page_nav(">>","class=myStyleSheetClass")
      */       
      function get_first_page_nav($user_link="",$link_para="")
      {
        if($this->total_page<=1)
            return;
          if(trim($user_link)=="")
            $user_link="««  ";
        if(!$this->is_first_page()&& $this->show_first_last)
            echo ' <a href="'.$this->page_name.'&page=0'.$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif($this->show_first_last && $this->show_disabled_links)
            echo $user_link;
      }
      function get_last_page_nav($user_link="",$link_para="")
      {
        if($this->total_page<=1)
            return;
          if(trim($user_link)=="")
            $user_link="  »»";
        if(!$this->is_last_page()&& $this->show_first_last)
            echo ' <a href="'.$this->page_name.'&page='.($this->total_page-1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif($this->show_first_last && $this->show_disabled_links)
            echo $user_link;
      }
      function get_next_page_nav($user_link="",$link_para="")
      {
        if($this->total_page<=1)
            return;
          if(trim($user_link)=="")
            $user_link=" »";
        if(!$this->is_last_page()&& $this->show_prev_next)
            echo ' <a href="'.$this->page_name.'&page='.($this->page+1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif($this->show_prev_next && $this->show_disabled_links)
            echo $user_link." ";
      }
      function get_prev_page_nav($user_link="",$link_para="")
      {
        if($this->total_page<=1)
            return;
          if(trim($user_link)=="")
            $user_link="« ";
        if(!$this->is_first_page()&& $this->show_prev_next)
            echo ' <a href="'.$this->page_name.'&page='.($this->page-1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif($this->show_prev_next && $this->show_disabled_links)
            echo " ".$user_link;
      }
      function get_scroll_prev_page_nav($user_link="",$link_para="")
      {
         
        if($this->scroll_page>=$this->total_page)
            return;
        if(trim($user_link)=="")
            $user_link="[-$this->scroll_page]";
        if($this->page>$this->scroll_page &&$this->show_scroll_prev_next)
            echo ' <a href="'.$this->page_name.'&page='.($this->page-$this->scroll_page).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif($this->show_scroll_prev_next && $this->show_disabled_links)
            echo $user_link;
      }
      function get_scroll_next_page_nav($user_link="",$link_para="")
      {
        if($this->scroll_page>=$this->total_page)
            return;
          if(trim($user_link)=="")
            $user_link="[+$this->scroll_page]";
        if($this->total_page>$this->page+$this->scroll_page &&$this->show_scroll_prev_next)
            echo ' <a href="'.$this->page_name.'&page='.($this->page+$this->scroll_page).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif($this->show_scroll_prev_next && $this->show_disabled_links)
            echo $user_link;
      }

      function get_number_page_nav($link_para="")
      {
        $j=0;
        $scroll_page=$this->scroll_page;
        if($this->page>($scroll_page/2))
          $j=$this->page-intval($scroll_page/2);
        if($j+$scroll_page>$this->total_page)
          $j=$this->total_page-$scroll_page;

        if($j<0)
            $i=0;
        else
            $i=$j;
       
        for(;$i<$j+$scroll_page && $i<$this->total_records;$i++)
        {
        if($i==$this->page)
            echo ($i+1);
        else
            echo ' <a href="'.$this->page_name.'&page='.$i.$this->qry_str.'" '.$link_para.'>'.($i+1).'</a> ';
        }
      }

      function get_page_nav()
      {
          if($this->total_records<=0)
        {
            //echo "No Records Found";
//            return false;
        }   
      $this->calculate();
      $this->get_first_page_nav("",$this->link_para);
      $this->get_scroll_prev_page_nav("",$this->link_para);
      $this->get_prev_page_nav("",$this->link_para);
      $this->get_number_page_nav($this->link_para);
      $this->get_next_page_nav("",$this->link_para);
      $this->get_scroll_next_page_nav("",$this->link_para);
      $this->get_last_page_nav("",$this->link_para);
//        return true;
      }
      function calculate()
      {
        $this->page=$_REQUEST['page'];
        if(!is_numeric($this->page))
          $this->page=0;
        $this->start=$this->page*$this->records_per_page;
        $this->total_page=@intval($this->total_records/$this->records_per_page);
        if($this->total_records%$this->records_per_page!=0)
          $this->total_page++;
      }
      function get_limit_query($qry="")
      {
        $this->calculate();
        return $qry." LIMIT $this->start,$this->records_per_page";
      }
    }
?>


Variante: « mit <, «« mit <<, » mit > und »» mit >> ersetzt.


<?php


    
/*
    ###############################################
    ####                                       ####
    ####    Author : Harish Chauhan            ####
    ####    Date   : 27 Sep,2004               ####
    ####    Updated:                           ####
    ####                                       ####
    ###############################################

    */
// Original class script obtained from http://www.phpclasses.org/browse/package/2012.html distributed as "Freeware"
// Modifications (Ver 1.0b) by GmBowen so that script useable with wikka wiki to support a "messanger" action developed for the wiki.
// Throughout this class "?page" was changed to "&page" as well as other minor modifications throughout the script.

    
class Page
    
{
      var 
$total_records=1;   ///Total Records returned by sql query
      
var $records_per_page=1;    ///how many records would be displayed at a time
      
var $page_name=""///page name on which the class is called
      
var $start=0;
      var 
$page=0;
      var 
$total_page=1;
      var 
$current_page;
      var 
$remain_page;
      var 
$show_prev_next=true;
      var 
$show_scroll_prev_next=false;
      var 
$show_first_last=false;
      var 
$show_disabled_links=true;
      var 
$scroll_page=0;
      var 
$qry_str="";
      var 
$link_para="&";

      
/* returns boolean value if it is last page or not*/   
      
function is_last_page()
      {
       return 
$this->page>=$this->total_page-1?true:false;
      }
      
/* param : Void
        returns boolean value if it is first page or not*/   
      
function is_first_page()
      {
       return 
$this->page==0?true:false;
      }
      function 
current_page()
      {
       return 
$this->page+1;
      }
      function 
total_page()
      {
       return 
$this->total_page==0?1:$this->total_page;
      }
     
      
//@param : $show = if you want to show disabled links on navigation links.
      //
      
function show_disabled_links($show=TRUE)   
      {
          
$this->show_disabled_links=$show;
      }
      
//@param : $link_para = if you want to pass any parameter to link
      //
      
function set_link_parameter($link_para)
      {
          
$this->link_para=$link_para;
      }
      function 
set_page_name($page_name)
      {
       
$this->page_name=$page_name;
      }
      
//@param : str= query string you want to pass to links.
      
function set_qry_string($str="")
      {
       
$this->qry_str="&".$str;
      }
      function 
set_scroll_page($scroll_num=0)
      {
        if(
$scroll_num!=0)
            
$this->scroll_page=$scroll_num;
        else
            
$this->scroll_page=$this->total_records;

      }
      function 
set_total_records($total_records)
      {
       if(
$total_records<0)
          
$total_records=0;
       
$this->total_records=$total_records;
      }
      function 
set_records_per_page($records_per_page)
      {
        if(
$records_per_page<=0)
              
$records_per_page=$this->total_records;
        
$this->records_per_page=$records_per_page;
      }
      
/* @params
      *     $page_name = Page name on which class is integrated. i.e. $_SERVER['PHP_SELF']
      *      $total_records=Total records returnd by sql query.
      *     $records_per_page=How many projects would be displayed at a time
      *        $scroll_num= How many pages scrolled if we click on scroll page link.
      *                 i.e if we want to scroll 6 pages at a time then pass argument 6.
      *     $show_prev_next= boolean(true/false) to show prev Next Link
      *     $show_scroll_prev_next= boolean(true/false) to show scrolled prev Next Link
      *     $show_first_last= boolean(true/false) to show first last Link to move first and last page.
      */
     
      
function set_page_data($page_name,$total_records,$records_per_page=1,$scroll_num=0,$show_prev_next=true,$show_scroll_prev_next=false,$show_first_last=false)
      {
       
$this->set_total_records($total_records);
       
$this->set_records_per_page($records_per_page);
       
$this->set_scroll_page($scroll_num);
       
$this->set_page_name($page_name);
       
$this->show_prev_next=$show_prev_next;
       
$this->show_scroll_prev_next=$show_scroll_prev_next;
       
$this->show_first_last=$show_first_last;
      }
      
/* @params
      *  $user_link= if you want to display your link i.e if you want to user '>>' instead of [first] link then use
        Page::get_first_page_nav(">>") OR for image
        Page::get_first_page_nav("<img src='' alt='first'>")
        $link_para: link parameters i.e if you want ot use another parameters such as class.
        Page::get_first_page_nav(">>","class=myStyleSheetClass")
      */       
      
function get_first_page_nav($user_link="",$link_para="")
      {
        if(
$this->total_page<=1)
            return;
          if(
trim($user_link)=="")
            
$user_link="<<  ";
        if(!
$this->is_first_page()&& $this->show_first_last)
            echo 
' <a href="'.$this->page_name.'&page=0'.$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif(
$this->show_first_last && $this->show_disabled_links)
            echo 
$user_link;
      }
      function 
get_last_page_nav($user_link="",$link_para="")
      {
        if(
$this->total_page<=1)
            return;
          if(
trim($user_link)=="")
            
$user_link="  >>";
        if(!
$this->is_last_page()&& $this->show_first_last)
            echo 
' <a href="'.$this->page_name.'&page='.($this->total_page-1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif(
$this->show_first_last && $this->show_disabled_links)
            echo 
$user_link;
      }
      function 
get_next_page_nav($user_link="",$link_para="")
      {
        if(
$this->total_page<=1)
            return;
          if(
trim($user_link)=="")
            
$user_link=" >";
        if(!
$this->is_last_page()&& $this->show_prev_next)
            echo 
' <a href="'.$this->page_name.'&page='.($this->page+1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif(
$this->show_prev_next && $this->show_disabled_links)
            echo 
$user_link." ";
      }
      function 
get_prev_page_nav($user_link="",$link_para="")
      {
        if(
$this->total_page<=1)
            return;
          if(
trim($user_link)=="")
            
$user_link="< ";
        if(!
$this->is_first_page()&& $this->show_prev_next)
            echo 
' <a href="'.$this->page_name.'&page='.($this->page-1).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif(
$this->show_prev_next && $this->show_disabled_links)
            echo 
" ".$user_link;
      }
      function 
get_scroll_prev_page_nav($user_link="",$link_para="")
      {
         
        if(
$this->scroll_page>=$this->total_page)
            return;
        if(
trim($user_link)=="")
            
$user_link="[-$this->scroll_page]";
        if(
$this->page>$this->scroll_page &&$this->show_scroll_prev_next)
            echo 
' <a href="'.$this->page_name.'&page='.($this->page-$this->scroll_page).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif(
$this->show_scroll_prev_next && $this->show_disabled_links)
            echo 
$user_link;
      }
      function 
get_scroll_next_page_nav($user_link="",$link_para="")
      {
        if(
$this->scroll_page>=$this->total_page)
            return;
          if(
trim($user_link)=="")
            
$user_link="[+$this->scroll_page]";
        if(
$this->total_page>$this->page+$this->scroll_page &&$this->show_scroll_prev_next)
            echo 
' <a href="'.$this->page_name.'&page='.($this->page+$this->scroll_page).$this->qry_str.'" '.$link_para.'>'.$user_link.'</a> ';
        elseif(
$this->show_scroll_prev_next && $this->show_disabled_links)
            echo 
$user_link;
      }

      function 
get_number_page_nav($link_para="")
      {
        
$j=0;
        
$scroll_page=$this->scroll_page;
        if(
$this->page>($scroll_page/2))
          
$j=$this->page-intval($scroll_page/2);
        if(
$j+$scroll_page>$this->total_page)
          
$j=$this->total_page-$scroll_page;

        if(
$j<0)
            
$i=0;
        else
            
$i=$j;
       
        for(;
$i<$j+$scroll_page && $i<$this->total_records;$i++)
        {
        if(
$i==$this->page)
            echo (
$i+1);
        else
            echo 
' <a href="'.$this->page_name.'&page='.$i.$this->qry_str.'" '.$link_para.'>'.($i+1).'</a> ';
        }
      }

      function 
get_page_nav()
      {
          if(
$this->total_records<=0)
        {
            
//echo "No Records Found";
//            return false;
        
}   
      
$this->calculate();
      
$this->get_first_page_nav("",$this->link_para);
      
$this->get_scroll_prev_page_nav("",$this->link_para);
      
$this->get_prev_page_nav("",$this->link_para);
      
$this->get_number_page_nav($this->link_para);
      
$this->get_next_page_nav("",$this->link_para);
      
$this->get_scroll_next_page_nav("",$this->link_para);
      
$this->get_last_page_nav("",$this->link_para);
//        return true;
      
}
      function 
calculate()
      {
        
$this->page=$_REQUEST['page'];
        if(!
is_numeric($this->page))
          
$this->page=0;
        
$this->start=$this->page*$this->records_per_page;
        
$this->total_page=@intval($this->total_records/$this->records_per_page);
        if(
$this->total_records%$this->records_per_page!=0)
          
$this->total_page++;
      }
      function 
get_limit_query($qry="")
      {
        
$this->calculate();
        return 
$qry." LIMIT $this->start,$this->records_per_page";
      }
    }
?>


Die bestehende Wacko-MySQL-Datenbank muss um die folgenden 2 Tabellen erweitert werden. Den Präfix für die Tabellen entsprechend ändern falls erforderlich.


CREATE TABLE `wacko_messenger` (
  `UserTo` tinytext NOT NULL,
  `repliedto` tinyint(1default '0',
  `folder` tinytext NOT NULL,
  `UserFrom` tinytext NOT NULL,
  `urgent` tinyint(1default NULL,
  `Subject` mediumtext NOT NULL,
  `Message` longtext NOT NULL,
  `fltr1` tinyint(1default '0',
  `fltr2` tinyint(1default '0',
  `fltr3` tinyint(1default '0',
  `status` text NOT NULL,
  `DateSent` datetime default NULL,
  `viewrecipient` enum('Y','N') NOT NULL default 'Y',
  `message_id` int(80NOT NULL auto_increment,
  PRIMARY KEY  (`message_id`)
) TYPE=MyISAM;

CREATE TABLE `wacko_messengerinfo` (
  `owner` tinytext NOT NULL,
  `type` tinytext NOT NULL,
  `info` tinytext NOT NULL,
  `notes` tinytext,
  `id` int(80NOT NULL auto_increment,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM;

Notify there are messages in the Box


You might wish to have a little icon appearing besite your Username after loging in, if you have still messages in your inbox. Here is a codesnippet wo do this for you.
Just find yourself a suitable gif to be displayed.


<?php
$userbrief = $this->GetUserName();
  $query="SELECT * FROM ".$this->config["table_prefix"]."messanger where UserTo='$userbrief' and folder='inbox' and viewrecipient='Y' ORDER BY DateSent DESC";
  $result=mysql_query($query) or die ("kann nicht ausgeführt werden!");
  $total_records=mysql_num_rows($result);
  if ($total_records>0) {
  echo " <a href=\"/Messagebox\"><img border=\"0\" src=\"".$this->GetConfigValue("root_url")."images/newmessage.gif\" height=\"15\" title=\"Neue Nachricht in Inbox\" alt=\"Neue Nachricht in Inbox\"/></a> ";
  }
?>