示例#1
0
 function parse_message($admin, $chatid, $message, $x, $allowpush = '')
 {
     $this->push = '';
     $this->message = $message;
     //$this->message = preg_replace("/&#(\d+);/me", "chr('\\1')", $this->message);
     //$this->message = htmlspecialchars($this->message, ENT_NOQUOTES);
     // do admin parsing if the person receiving this message is a guest
     if ($x == 'o') {
         $this->message .= ' ';
         $this->message = preg_replace("/%%user%%/i", char_to_html($_SESSION['hcl_' . $chatid]['guest']), $this->message);
         $this->message = preg_replace("/&#117;&#114;&#108;&#58;(.*?)&#32;/ie", "'<a href=\"'.html_to_char('\\1').'\" target=\"_blank\">\\1</a>&#32;'", $this->message);
         $this->message = preg_replace("/&#105;&#109;&#97;&#103;&#101;&#58;(.*?)&#32;/ie", "'<img src=\"'.html_to_char('\\1').'\" alt=\"\" />&#32;'", $this->message);
         $this->message = preg_replace("/&#101;&#109;&#97;&#105;&#108;&#58;(.*?)&#32;/ie", "'<a href=\"mailto:'.html_to_char('\\1').'\">\\1</a>&#32;'", $this->message);
         if ($admin == 'false' && $allowpush == '') {
             $matches = '';
             if (preg_match("/&#112;&#117;&#115;&#104;&#58;(.*?)&#32;/i", $this->message, $matches)) {
                 $this->push = html_to_char($matches[1]);
             }
         }
         $this->message = preg_replace("/&#112;&#117;&#115;&#104;&#58;(.*?)&#32;/ie", "'<i>" . $GLOBALS['lang']['pushed_page'] . ": <a href=\"'.html_to_char('\\1').'\" target=\"_blank\">\\1</a></i>&#32;'", $this->message);
     }
     return $this->message;
 }
 function setforms($chatid, $type, $name, $value, $admin)
 {
     $name = char_to_html($name);
     $value = char_to_html($value);
     if ($admin == 'true') {
         if ($GLOBALS['db']->query('INSERT INTO `coforms` (`chatid`, `receivedo`, `type`, `name`, `value`) VALUES ("' . $chatid . '", "1", "' . $type . '", "' . $name . '", "' . $value . '")')) {
             return true;
         } else {
             return false;
         }
     } else {
         if ($GLOBALS['db']->query('INSERT INTO `coforms` (`chatid`, `receivedg`, `type`, `name`, `value`) VALUES ("' . $chatid . '", "1", "' . $type . '", "' . $name . '", "' . $value . '")')) {
             return true;
         } else {
             return false;
         }
     }
 }
 function get($chatid = '', $id = '', $admin = '')
 {
     if ($chatid == '' && $id == '') {
         $this->transcripts = array();
         if ($GLOBALS['auth']->admin() && $admin == 'admin') {
             if ($this->result = $GLOBALS['db']->query('SELECT * FROM `departments` WHERE 1')) {
                 foreach ($this->result as $key => $val) {
                     if ($this->result2 = $GLOBALS['db']->query('SELECT * FROM `transcripts` WHERE `departmentid`="' . $this->result[$key]['id'] . '" ORDER BY `timestamp` DESC')) {
                         foreach ($this->result2 as $key2 => $val2) {
                             $this->result2[$key2]['time'] = gmdate('G:i:s D jS F Y', $this->result2[$key2]['timestamp'] + 3600 * $GLOBALS['conf']['offset']);
                         }
                         $this->transcripts = array_merge($this->transcripts, array(array('name' => $GLOBALS['department']->name($this->result[$key]['id']), 'transcript' => $this->result2)));
                     }
                 }
             }
         } else {
             if ($this->result = $GLOBALS['db']->query('SELECT * FROM `assigns` WHERE `operatorid`="' . $GLOBALS['operator']->id() . '"')) {
                 foreach ($this->result as $key => $val) {
                     if ($this->result2 = $GLOBALS['db']->query('SELECT * FROM `transcripts` WHERE `departmentid`="' . $this->result[$key]['departmentid'] . '" AND `operatorid`="' . $GLOBALS['operator']->id() . '" ORDER BY `timestamp` DESC')) {
                         foreach ($this->result2 as $key2 => $val2) {
                             $this->result2[$key2]['time'] = gmdate('G:i:s D jS F Y', $this->result2[$key2]['timestamp'] + 3600 * $GLOBALS['conf']['offset']);
                         }
                         $this->transcripts = array_merge($this->transcripts, array(array('name' => $GLOBALS['department']->name($this->result[$key]['departmentid']), 'transcript' => $this->result2)));
                     }
                 }
             }
         }
         return $this->transcripts;
     } elseif ($id !== '') {
         $this->transcripts = array();
         if ($this->result = $GLOBALS['db']->query('SELECT * FROM `transcripts` WHERE `id`="' . $id . '"')) {
             if ($GLOBALS['auth']->admin() && $admin == 'admin') {
                 $this->transcripts['id'] = $this->result[0]['id'];
                 $this->transcripts['nick'] = $this->result[0]['guest'];
                 $this->transcripts['operator'] = $GLOBALS['operator']->name($this->result[0]['operatorid']);
                 $this->transcripts['department'] = $GLOBALS['department']->name($this->result[0]['departmentid']);
                 $this->transcripts['email'] = $GLOBALS['department']->email($this->result[0]['departmentid']);
                 $this->transcripts['time'] = gmdate('G:i:s D jS F Y', $this->result[0]['timestamp'] + 3600 * $GLOBALS['conf']['offset']);
                 $this->transcripts['chat'] = rawurldecode($this->result[0]['transcript']);
                 return $this->transcripts;
             } elseif ($this->result2 = $GLOBALS['db']->query('SELECT * FROM `assigns` WHERE `operatorid`="' . $GLOBALS['operator']->id() . '"')) {
                 foreach ($this->result2 as $key => $val) {
                     if ($this->result2[$key]['departmentid'] == $this->result[0]['departmentid']) {
                         $this->transcripts['id'] = $this->result[0]['id'];
                         $this->transcripts['nick'] = $this->result[0]['guest'];
                         $this->transcripts['operator'] = $GLOBALS['operator']->name($this->result[0]['operatorid']);
                         $this->transcripts['department'] = $GLOBALS['department']->name($this->result[0]['departmentid']);
                         $this->transcripts['email'] = $GLOBALS['department']->email($this->result[0]['departmentid']);
                         $this->transcripts['time'] = gmdate('G:i:s D jS F Y', $this->result[0]['timestamp'] + 3600 * $GLOBALS['conf']['offset']);
                         $this->transcripts['chat'] = rawurldecode($this->result[0]['transcript']);
                         return $this->transcripts;
                     }
                 }
             }
         } else {
             return false;
         }
     } else {
         $this->chat = '';
         $this->result = $GLOBALS['db']->query('SELECT * FROM `traffic` WHERE `id`="' . $chatid . '"');
         if ($this->result2 = $GLOBALS['db']->query('SELECT * FROM `chat` WHERE `chatid`="' . $chatid . '" ORDER BY `timestamp` ASC')) {
             foreach ($this->result2 as $key => $val) {
                 $this->timestamp = gmdate('G:i:s', $this->result2[$key]['timestamp'] + 3600 * $GLOBALS['conf']['offset']);
                 if ($this->result2[$key]['x'] == 'o') {
                     $this->text = html_to_char(rawurldecode($this->result2[$key]['message'])) . ' ';
                     $this->text = preg_replace("/%%user%%/i", $_SESSION['hcl_' . $chatid]['guest'], $this->text);
                     $this->text = preg_replace("/url:(.*?) /i", "<a href=\"\\1\" target=\"_blank\">\\1</a> ", $this->text);
                     $this->text = preg_replace("/image:(.*?) /i", "<img src=\"\\1\" alt=\"image\" /> ", $this->text);
                     $this->text = preg_replace("/email:(.*?) /i", "<a href=\"\\1\">\\1</a> ", $this->text);
                     $this->text = preg_replace("/push:(.*?) /i", "<i>Pushed Page: \\1</i> ", $this->text);
                     $this->text = substr($this->text, 0, -1);
                     $this->text = '<span class="operator"><i>(' . $this->timestamp . ')</i> <b>' . $_SESSION['hcl_' . $chatid]['operator'] . ':</b> ' . char_to_html($this->text) . '</span><br />';
                 } else {
                     $this->text = '<span class="guest"><i>(' . $this->timestamp . ')</i> <b>' . $_SESSION['hcl_' . $chatid]['guest'] . ':</b> ' . rawurldecode($this->result2[$key]['message']) . '</span><br />';
                 }
                 $this->chat = $this->chat . $this->text;
             }
             return $this->chat;
         } else {
             return 'Error';
         }
     }
 }