Beispiel #1
0
 /**
  * Returns all messages in the given time frame between two parties.
  *
  * @return array Returns messages array
  * @author  
  */
 public function GetMsgs()
 {
     global $_;
     try {
         $sth = DB::prep("SELECT TIME_FORMAT(m1.time, '%k:%i') as time,IF(m1.type = 'admin', m3.username, m2.nick) as user_nick, m1.to_user as admin, m1.user as user_id, m1.type, m1.msg\r\n             FROM messaging AS m1 \r\n             LEFT JOIN messaging_users AS m2 ON m1.user = m2.user_id \r\n             LEFT JOIN messaging_admin m3 ON m1.to_user = m3.id \r\n             WHERE m1.user = :curr_user\r\n             ORDER BY m1.time");
         $sth->bindParam(":curr_user", $_SESSION['visitor_chat_user'], PDO::PARAM_INT);
         $result = DB::getAll($sth);
         foreach ($result as $key => $val) {
             $keys = $key ? $key - 1 : $key;
             $result[$key]['before'] = $result[$keys]['user_id'];
             $result[$key]['admin_before'] = $result[$keys]['admin'];
             $result[$key]['type_before'] = $result[$keys]['type'];
             $result[$key]['msg'] = $this->UploadReplace($val['msg']);
             $result[$key]['msg'] = $this->makeClickableLinks($result[$key]['msg']);
             $result[$key]['msg'] = nl2br($result[$key]['msg']);
             $smiley = new Smiley();
             $actions = $smiley->ListSmiley();
             foreach ($actions as $val) {
                 $search[] = $val->sign;
                 $replace[] = '<img src="' . $_['MAIN_FOLDER'] . '/admin/images/smiley/' . $val->filename . '" />';
             }
             $result[$key]['msg'] = str_replace($search, $replace, $result[$key]['msg']);
             $result[$key]['msg'] = stripslashes($result[$key]['msg']);
         }
         $_SESSION['msg_update'] = time();
         return $result;
     } catch (Exception $e) {
         die($e->getMessage());
     }
 }
Beispiel #2
0
<?php

$smiley = new Smiley();
echo json_encode($smiley->ListSmiley());