Source for file History.class.php

Documentation is available at History.class.php

  1. <?php
  2. /**
  3.  * Class History, shows the history of the chatmessages
  4.  *
  5.  * LICENSE: CREATIVE COMMONS PUBLIC LICENSE  "Namensnennung — Nicht-kommerziell 2.0"
  6.  *
  7.  * @copyright  2009 <SEDesign />
  8.  * @license    http://creativecommons.org/licenses/by-nc/2.0/de/
  9.  * @version    $3.0.6$
  10.  * @link       http://www.sedesign.de/de_produkte_chat-v3.html
  11.  * @since      File available since Alpha 1.0
  12.  */
  13.  
  14. class History extends DbConectionMaker
  15. {
  16.  
  17.     /**
  18.     * Constructor
  19.     *
  20.     * @uses ConnectDB::sqlGet()
  21.     * @uses ConnectDB::close()
  22.     * @uses LangXml object creation
  23.     * @uses LangXml::getLang() parser method
  24.     * @uses StaticMethods::filtering()
  25.     * @uses RoomAllowed
  26.     * @uses RoomAllowed::$room_status if the room is open/closed/pw-protected
  27.     * @return void 
  28.     */
  29.     public function __construct ()
  30.         
  31.         // call parent Constructor from class DbConectionMaker
  32.         parent::__construct()
  33.  
  34.         session_start();
  35.  
  36.         header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0');
  37.         header('content-type: application/json; charset=utf-8');
  38.         
  39.         // create new LangXml Object
  40.         $langObj = new LangXml();
  41.         $lang=$langObj->getLang()->history_php[0];
  42.         
  43.         $privates=false;
  44.  
  45.         if(!empty($_POST['roomid'])) {
  46.             if ($_POST['roomid']!="priv")
  47.                 $raumauswahl "AND ({$this->_prefix}etchat_messages.etchat_fid_room = ".(int)$_POST['roomid']." OR {$this->_prefix}etchat_messages.etchat_fid_room = 0)";
  48.             else
  49.                 $privates=true;
  50.         }
  51.         else {
  52.             $raumauswahl = "AND ({$this->_prefix}etchat_messages.etchat_fid_room = 1 OR {$this->_prefix}etchat_messages.etchat_fid_room = 0)";
  53.             $_POST['roomid']=1;
  54.         }
  55.         
  56.         
  57.         if($privates)
  58.             $counted=$this->dbObj->sqlGet("
  59.             SELECT count(etchat_id)
  60.             FROM ({$this->_prefix}etchat_messages JOIN {$this->_prefix}etchat_rooms ON {$this->_prefix}etchat_messages.etchat_fid_room = {$this->_prefix}etchat_rooms.etchat_id_room) INNER JOIN {$this->_prefix}etchat_user ON {$this->_prefix}etchat_messages.etchat_user_fid = {$this->_prefix}etchat_user.etchat_user_id
  61.             WHERE ({$this->_prefix}etchat_messages.etchat_user_fid=".$_SESSION['etchat_'.$this->_prefix.'user_id']." AND {$this->_prefix}etchat_messages.etchat_privat>0) OR {$this->_prefix}etchat_messages.etchat_privat=".$_SESSION['etchat_'.$this->_prefix.'user_id']);
  62.         else
  63.             $counted=$this->dbObj->sqlGet("
  64.             SELECT count(etchat_id)
  65.             FROM ({$this->_prefix}etchat_messages LEFT JOIN {$this->_prefix}etchat_rooms ON {$this->_prefix}etchat_messages.etchat_fid_room = {$this->_prefix}etchat_rooms.etchat_id_room ".$raumauswahl.") INNER JOIN {$this->_prefix}etchat_user ON {$this->_prefix}etchat_messages.etchat_user_fid = {$this->_prefix}etchat_user.etchat_user_id
  66.             WHERE  {$this->_prefix}etchat_messages.etchat_privat=0 ".$raumauswahl);
  67.             
  68.         $pro_seite = 40;
  69.         $site=$_POST['site']-1;
  70.         $von = $site*$pro_seite;
  71.         
  72.         if ($this->_usedDatabase == "mysql"$limit "LIMIT $von$pro_seite";
  73.         if ($this->_usedDatabase == "pgsql"$limit "LIMIT $pro_seite OFFSET $von";
  74.  
  75.  
  76.         
  77.         if($privates)
  78.             $feld=$this->dbObj->sqlGet("
  79.             SELECT {$this->_prefix}etchat_messages.etchat_id, {$this->_prefix}etchat_user.etchat_username, {$this->_prefix}etchat_messages.etchat_text, {$this->_prefix}etchat_messages.etchat_timestamp, {$this->_prefix}etchat_rooms.etchat_roomname, {$this->_prefix}etchat_messages.etchat_privat, {$this->_prefix}etchat_messages.etchat_user_fid, {$this->_prefix}etchat_messages.etchat_text_css
  80.             FROM ({$this->_prefix}etchat_messages JOIN {$this->_prefix}etchat_rooms ON {$this->_prefix}etchat_messages.etchat_fid_room = {$this->_prefix}etchat_rooms.etchat_id_room) INNER JOIN {$this->_prefix}etchat_user ON {$this->_prefix}etchat_messages.etchat_user_fid = {$this->_prefix}etchat_user.etchat_user_id
  81.             WHERE ({$this->_prefix}etchat_messages.etchat_user_fid=".$_SESSION['etchat_'.$this->_prefix.'user_id']." AND {$this->_prefix}etchat_messages.etchat_privat>0) OR {$this->_prefix}etchat_messages.etchat_privat=".$_SESSION['etchat_'.$this->_prefix.'user_id']."
  82.             ORDER BY {$this->_prefix}etchat_messages.etchat_id DESC $limit");
  83.         else
  84.             $feld=$this->dbObj->sqlGet("
  85.             SELECT {$this->_prefix}etchat_messages.etchat_id, {$this->_prefix}etchat_user.etchat_username, {$this->_prefix}etchat_messages.etchat_text, {$this->_prefix}etchat_messages.etchat_timestamp, {$this->_prefix}etchat_rooms.etchat_roomname, {$this->_prefix}etchat_messages.etchat_privat, {$this->_prefix}etchat_messages.etchat_user_fid, {$this->_prefix}etchat_messages.etchat_text_css
  86.             FROM ({$this->_prefix}etchat_messages LEFT JOIN {$this->_prefix}etchat_rooms ON {$this->_prefix}etchat_messages.etchat_fid_room = {$this->_prefix}etchat_rooms.etchat_id_room ".$raumauswahl.") INNER JOIN {$this->_prefix}etchat_user ON {$this->_prefix}etchat_messages.etchat_user_fid = {$this->_prefix}etchat_user.etchat_user_id
  87.             WHERE  {$this->_prefix}etchat_messages.etchat_privat=0 ".$raumauswahl."
  88.             ORDER BY {$this->_prefix}etchat_messages.etchat_id DESC $limit");
  89.         
  90.  
  91.         
  92.         echo "<div id=\"history_seiten\" style=\"margin: 2px;\">";
  93.         
  94.         $sitemakerObj = new Sitemaker($pro_seite, $counted[0][0]);
  95.         $sitemakerObj->make($_POST['site']"historysite_#site#"$lang->site[0]->tagData$lang->site_of[0]->tagData);
  96.         $sitemakerObj->show();
  97.         
  98.         echo "
  99.         <form style=\"display:inline;\">
  100.         &nbsp;&nbsp;&nbsp; ".$lang->room[0]->tagData.": <select name=\"raum_in_history\" id=\"raum_in_history\" size=\"1\">
  101.         <option value=\"priv\">".$lang->priv[0]->tagData."</option>";
  102.  
  103.         $rooms=$this->dbObj->sqlGet("SELECT etchat_id_room, etchat_roomname, etchat_room_goup FROM {$this->_prefix}etchat_rooms");
  104.         
  105.         foreach($rooms as $each_room){
  106.  
  107.             $room_allowed=new RoomAllowed($each_room[2], $each_room[0]);
  108.  
  109.             if ($room_allowed->room_status==1){
  110.                 $selected =($_POST['roomid']==$each_room[0]) ? "selected" : "";
  111.                 echo "<option value=\"".$each_room[0]."\" ".$selected.">".$each_room[1]."</option>";
  112.             }
  113.         }
  114.  
  115.         echo"</select>";
  116.  
  117.         if ($_SESSION['etchat_'.$this->_prefix.'user_priv']=="admin" || $_SESSION['etchat_'.$this->_prefix.'user_priv']=="mod"echo"&nbsp;&nbsp;&nbsp;".$lang->export[0]->tagData." <a href=\"#\" id=\"export_excel\">Excel</a> | <a href=\"#\" id=\"export_csv\">CSV</a> | <a href=\"#\" id=\"export_xml\">XML</a>";
  118.  
  119.         echo"</form>
  120.         </div>
  121.         <table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" style=\"border:1px solid black;\" width=\"98%\">";
  122.         echo "<tr class=\"kopf\">
  123.  
  124.         <td style=\"padding:2px\"><b>ID</b></td>
  125.         <td style=\"padding:2px\"><b>".$lang->user[0]->tagData."</b></td>
  126.         <td style=\"padding:2px\"><b>".$lang->date[0]->tagData."</b></td>
  127.         <td style=\"padding:2px\"><b>".$lang->text[0]->tagData."</b></td>
  128.         <td style=\"padding:2px\"><b>".$lang->room[0]->tagData."</b></td>
  129.         </tr>";
  130.  
  131.         $sml $this->dbObj->sqlGet("SELECT etchat_smileys_sign, etchat_smileys_img FROM {$this->_prefix}etchat_smileys");
  132.  
  133.         if (is_array($feld)){
  134.             for ($a=0; $a < count($feld); $a++){
  135.                 if($feld[$a][5]==0){
  136.                     if($a%2==1) echo "<tr class=\"ungerade\" id=\"tr".$feld[$a][0]."\" >";
  137.                     else echo "<tr class=\"gerade\" id=\"tr".$feld[$a][0]."\"  >";
  138.                     }
  139.                 if ($feld[$a][5]!=0 && $feld[$a][6]==$_SESSION['etchat_'.$this->_prefix.'user_id']{
  140.                     echo "<tr class=\"privat_von\" id=\"tr".$feld[$a][0]."\"  >";
  141.                     $private_at=$this->dbObj->sqlGet("SELECT etchat_username from {$this->_prefix}etchat_user where etchat_user_id = ".(int)$feld[$a][5]);
  142.                     $private_at_user = (is_array($private_at)) ? "&nbsp;<span style=\"font-size: 1.2em;\"><b>>>></b></span>&nbsp;".$private_at[0][0] : "";
  143.                 }
  144.                 if ($feld[$a][5] == $_SESSION['etchat_'.$this->_prefix.'user_id']{
  145.                     echo "<tr class=\"privat_nach\" id=\"tr".$feld[$a][0]."\"  >";
  146.                     $private_at_user = "";
  147.                 }
  148.                 
  149.                 $message = StaticMethods::filtering($feld[$a][2], $sml, $this->_prefix);
  150.                 if (substr($message,0,8== "/window:")
  151.                     $message "<img src=\"./img/privat_win.png\" /> ".substr($message,8,strlen($message));
  152.                 
  153.                 echo "
  154.                 <td style=\"padding:2px\">".$feld[$a][0]."</td>
  155.                 <td style=\"padding:2px\">".$feld[$a][1].$private_at_user."</td>
  156.                 <td style=\"padding:2px\">".date("d.m.Y (H:i)",$feld[$a][3])."</td>
  157.                 <td style=\"padding:2px\">".$message."</td>
  158.                 <td style=\"padding:2px\">".$feld[$a][4]."</td>";
  159.                 echo "</tr>";
  160.             }
  161.         }
  162.         else echo "<tr><td colspan=\"5\">".$lang->empty[0]->tagData."</td></tr>";
  163.         echo "</table>";
  164.         
  165.         $this->dbObj->close();
  166.     }

Documentation generated on Thu, 05 May 2011 14:05:56 +0000 by phpDocumentor 1.4.3