Changeset 287


Ignore:
Timestamp:
05/26/08 11:45:16 (16 years ago)
Author:
niltonneto
Message:

Verificar Wiki/Trac? do módulo.

Location:
trunk/instant_messenger
Files:
8 added
14 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/instant_messenger/controller.php

    r261 r287  
    11<?php 
    2  
    3 class Controller 
    4 { 
    5         const __CONTROLLER_SECURITY__                           = 'controller-security'; 
    6         const __CONTROLLER_CONTENTES__                          = 'controller-contentes'; 
    7         const __CONTROLLER_SECTIONS__                           = 'controller-sections'; 
    8  
    9         const __STRING_ACCESS__                                         = 'string-access'; 
    10         const __STRING_DELIMITER__                                      = 'string-delimiter'; 
    11  
    12         const __CONTROLLER_CONTENTES_ITEM__                     = 'item'; 
    13         const __CONTROLLER_CONTENTES_ITEM_PARAM__       = 'param'; 
    14         const __CONTROLLER_CONTENTES_ITEM_SECTION__     = 'section'; 
    15  
    16         const __CONTROLLER_SECTIONS_ITEM__                      = 'item'; 
    17  
    18         public function __construct() 
    19         { 
    20                 $this->dom = new DOMDocument; 
    21                 $this->dom->preserveWhiteSpace = FALSE; 
    22                 $this->dom->load('controller.xml'); 
    23  
    24                 $this->controller_security = $this->dom->getElementsByTagName(self::__CONTROLLER_SECURITY__); 
    25                 ( $this->controller_security->length === (int)0 ) 
    26                         and die(__CLASS__ . ' [ ERROR #0 ] :: the tag "' . self::__CONTROLLER_SECURITY__ . '" does not exist'); 
    27                 ( $this->controller_security->length === (int)1 ) 
    28                         or die(__CLASS__ . ' [ ERROR #1 ] :: exists more of a tag "' . self::__CONTROLLER_SECURITY__ . '"'); 
    29  
    30                 $this->controller_contentes = $this->dom->getElementsByTagName(self::__CONTROLLER_CONTENTES__); 
    31                 ( $this->controller_contentes->length === (int)0 ) 
    32                         and die(__CLASS__ . ' [ ERROR #2 ] :: the tag "' . self::__CONTROLLER_CONTENTES__ . '" does not exist'); 
    33                 ( $this->controller_contentes->length === (int)1 ) 
    34                         or die(__CLASS__ . ' [ ERROR #3 ] :: exists more of a tag "' . self::__CONTROLLER_CONTENTES__ . '"'); 
    35                 $this->controller_contentes = $this->controller_contentes->item(0); 
    36  
    37                 $this->controller_sections = $this->dom->getElementsByTagName("controller-sections"); 
    38                 ( $this->controller_sections->length === (int)0 ) 
    39                         and die(__CLASS__ . ' [ ERROR #4 ] :: the tag "' . self::__CONTROLLER_SECTIONS__ . '" does not exist'); 
    40                 ( $this->controller_sections->length === (int)1 ) 
    41                         or die(__CLASS__ . ' [ ERROR #5 ] :: exists more of a tag "' . self::__CONTROLLER_SECTIONS__ . '"'); 
    42                 $this->controller_sections = $this->controller_sections->item(0); 
    43  
    44                 $this->string_access = $this->controller_security->item(0)->getElementsByTagName(self::__STRING_ACCESS__); 
    45                 ( $this->string_access->length === (int)0 ) 
    46                         and die(__CLASS__ . ' [ ERROR #6 ] :: the tag "' . self::__STRING_ACCESS__ . '" does not exist'); 
    47                 ( $this->string_access->length === (int)1 ) 
    48                         or die(__CLASS__ . ' [ ERROR #7 ] :: exists more of a tag "' . self::__STRING_ACCESS__ . '"'); 
    49                 $this->string_access = $this->string_access->item(0)->nodeValue; 
    50  
    51                 $this->string_delimiter = $this->controller_security->item(0)->getElementsByTagName(self::__STRING_DELIMITER__); 
    52                 ( $this->string_delimiter->length === (int)0 ) 
    53                         and die(__CLASS__ . ' [ ERROR #8 ] :: the tag "' . self::__STRING_DELIMITER__ . '" does not exist'); 
    54                 ( $this->string_delimiter->length === (int)1 ) 
    55                         or die(__CLASS__ . ' [ ERROR #9 ] :: exists more of a tag "' . self::__STRING_DELIMITER__ . '"'); 
    56                 $this->string_delimiter = $this->string_delimiter->item(0)->nodeValue; 
    57         } 
    58  
    59         public function exec(array &$pRequest) 
    60         { 
    61                 ( $pRequest[$this->string_access] ) 
    62                         or die(__CLASS__ . ' [ ERROR #10 ] :: bad string action argument'); 
    63  
    64                 list($section_name, $ref, $alias) = explode($this->string_delimiter, $pRequest[$this->string_access]); 
    65                 unset($pRequest[$this->string_access]); 
    66  
    67                 $contents_itens = $this->controller_contentes->getElementsByTagName(self::__CONTROLLER_CONTENTES_ITEM__); 
    68  
    69                 for ( $i = 0; $i < $contents_itens->length && $contents_itens->item($i)->getAttribute(self::__CONTROLLER_CONTENTES_ITEM_PARAM__) != $section_name; $i++ ); 
    70                 ( !($i < $contents_itens->length) ) 
    71                         and die(__CLASS__ . ' [ ERROR #11 ] :: invalid section "' . $section_name . '"'); 
    72  
    73                 $section_name = $contents_itens->item($i)->getAttribute(self::__CONTROLLER_CONTENTES_ITEM_SECTION__); 
    74  
    75                 $section = $this->controller_sections->getElementsByTagName($section_name); 
    76                 ( $section->length === (int)0 ) 
    77                         and die(__CLASS__ . ' [ ERROR #12 ] :: the tag "' . $section_name . '" does not exist'); 
    78                 ( $section->length === (int)1 ) 
    79                         or die(__CLASS__ . ' [ ERROR #13 ] :: exists more of a tag "' . $section_name . '"'); 
    80                 $section = $section->item(0); 
    81  
    82                 $section_itens = $section->getElementsByTagName(self::__CONTROLLER_SECTIONS_ITEM__); 
    83  
    84                 if ( empty($alias) && $alias !== '0' ) 
    85                         for ( $i = 0; $i < $section_itens->length && $section_itens->item($i)->getAttribute('ref') != $ref; $i++ ); 
    86                 else 
    87                         for ( $i = 0; $i < $section_itens->length && ( $section_itens->item($i)->getAttribute('ref') != $ref || $section_itens->item($i)->getAttribute('alias') !== $alias); $i++ ); 
    88  
    89                 ( !($i < $section_itens->length) ) 
    90                         and die(__CLASS__ . ' [ ERROR #14 ] :: invalid reference "' . $ref . '"'); 
    91  
    92                 $path = $section_itens->item($i)->getAttribute('path') 
    93                         or $path = $section->getAttribute('path') 
    94                         or die(__CLASS__ . ' [ ERROR #15 ] :: bad path argument'); 
    95  
    96                 $prefix = $section_itens->item($i)->getAttribute('prefix') 
    97                         or $prefix = $section->getAttribute('prefix'); 
    98  
    99                 $suffix = $section_itens->item($i)->getAttribute('suffix') 
    100                         or $suffix = $section->getAttribute('suffix') 
    101                         or die(__CLASS__ . ' [ ERROR #16 ] :: bad suffix argument'); 
    102  
    103                 $this->$section_name(array("pSectionItem" => $section_itens->item($i), "pPath" => $path, "pPrefix" => $prefix, "pSuffix" => $suffix, "pRequest" => $pRequest)); 
    104         } 
    105  
    106         private final function php() 
    107         { 
    108                 $params = func_get_args(); 
    109                 extract($params[0]); 
    110  
    111                 $class = $pSectionItem->getAttribute('class') 
    112                         and $method = $pSectionItem->getAttribute('method') 
    113                         or die(__CLASS__ . ' [ ERROR #17 ] :: bad class or method argument'); 
    114  
    115                 $file = "{$pPath}/{$pPrefix}{$class}{$pSuffix}"; 
    116  
    117                 file_exists($file) 
    118                         or die(__CLASS__ . ' [ ERROR #18 ] :: the file that has the class was not opened'); 
    119  
    120                 require_once $file; 
    121  
    122                 $obj = new $class; 
    123  
    124                 if ( $pRequest ) 
    125                         $result = $obj -> $method($pRequest); 
    126                 else 
    127                         $result = $obj -> $method(); 
    128  
    129                 printf("%s", $result); 
    130         } 
    131  
    132         private final function js() 
    133         { 
    134                 $params = func_get_args(); 
    135                 extract($params[0]); 
    136  
    137                 $js = $pSectionItem->getAttribute('js') 
    138                         or die(__CLASS__ . ' [ ERROR #18 ] :: bad js argument'); 
    139  
    140                 $file = "{$pPath}/{$pPrefix}{$js}{$pSuffix}"; 
    141  
    142                 file_exists($file) 
    143                         or die(__CLASS__ . ' [ ERROR #19 ] :: the file that has the class was not opened'); 
    144  
    145                 $packed_file = "{$pPath}/{$pPrefix}{$js}.packer{$pSuffix}"; 
    146  
    147                 ( 
    148                         file_exists($packed_file) 
    149                         and filemtime($packed_file) > filemtime($file) 
    150                         and $packed = file_get_contents($packed_file) 
    151                 ) 
    152                 or 
    153                 ( 
    154                         $packer = new JavaScriptPacker(file_get_contents($file), 'High ASCII', true, true) 
    155                         and $packed = $packer->pack() 
    156                         and file_put_contents($packed_file, $packed) 
    157                 ); 
    158  
    159                 printf("%s", $packed); 
    160         } 
    161 } 
    162  
    163 class JavaScriptPacker 
    164 { 
    165         const IGNORE = '$1'; 
    166  
    167         private $_script = ''; 
    168         private $_encoding = 62; 
    169         private $_fastDecode = true; 
    170         private $_specialChars = false; 
    171  
    172         private $_parsers = array(); 
    173  
    174         private $LITERAL_ENCODING = array( 
    175                 'None' => 0, 
    176                 'Numeric' => 10, 
    177                 'Normal' => 62, 
    178                 'High ASCII' => 95 
    179         ); 
    180  
    181         public function __construct ($pScript, $pEncoding = 62, $pFastDecode = true, $pSpecialChars = false) 
    182         { 
    183                 $this->_script = $pScript . "\n"; 
    184                 if ( array_key_exists($pEncoding, $this->LITERAL_ENCODING) ) 
    185                         $pEncoding = $this->LITERAL_ENCODING[$pEncoding]; 
    186  
    187                 $this->_encoding = min((int)$pEncoding, 95); 
    188                 $this->_fastDecode = $pFastDecode; 
    189                 $this->_specialChars = $pSpecialChars; 
    190         } 
    191  
    192         public function pack() 
    193         { 
    194                 $this->_addParser('_basicCompression'); 
    195  
    196                 if ( $this->_specialChars ) 
    197                         $this->_addParser('_encodeSpecialChars'); 
    198  
    199                 if ( $this->_encoding ) 
    200                         $this->_addParser('_encodeKeywords'); 
    201  
    202                 return $this->_pack($this->_script); 
    203         } 
    204  
    205         private function _pack($script) 
    206         { 
    207                 for ( $i = 0; isset($this->_parsers[$i]); $i++ ) 
    208                         $script = call_user_func(array(&$this,$this->_parsers[$i]), $script); 
    209  
    210                 return $script; 
    211         } 
    212  
    213         // keep a list of parsing functions, they'll be executed all at once 
    214         private function _addParser($parser) 
    215         { 
    216                 $this->_parsers[] = $parser; 
    217         } 
    218  
    219         // zero encoding - just removal of white space and comments 
    220         private function _basicCompression($script) 
    221         { 
    222                 $parser = new ParseMaster(); 
    223                 // make safe 
    224                 $parser->escapeChar = '\\'; 
    225                 // protect strings 
    226                 $parser->add('/\'[^\'\\n\\r]*\'/', self::IGNORE); 
    227                 $parser->add('/"[^"\\n\\r]*"/', self::IGNORE); 
    228                 // remove comments 
    229                 $parser->add('/\\/\\/[^\\n\\r]*[\\n\\r]/', ' '); 
    230                 $parser->add('/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\//', ' '); 
    231                 // protect regular expressions 
    232                 $parser->add('/\\s+(\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?)/', '$2'); // IGNORE 
    233                 $parser->add('/[^\\w\\x24\\/\'"*)\\?:]\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?/', self::IGNORE); 
    234                 // remove: ;;; doSomething(); 
    235                 if ($this->_specialChars) $parser->add('/;;;[^\\n\\r]+[\\n\\r]/'); 
    236                 // remove redundant semi-colons 
    237                 $parser->add('/\\(;;\\)/', self::IGNORE); // protect for (;;) loops 
    238                 $parser->add('/;+\\s*([};])/', '$2'); 
    239                 // apply the above 
    240                 $script = $parser->exec($script); 
    241  
    242                 // remove white-space 
    243                 $parser->add('/(\\b|\\x24)\\s+(\\b|\\x24)/', '$2 $3'); 
    244                 $parser->add('/([+\\-])\\s+([+\\-])/', '$2 $3'); 
    245                 $parser->add('/\\s+/', ''); 
    246                 // done 
    247                 return $parser->exec($script); 
    248         } 
    249  
    250         private function _encodeSpecialChars($script) 
    251         { 
    252                 $parser = new ParseMaster(); 
    253                 // replace: $name -> n, $$name -> na 
    254                 $parser->add('/((\\x24+)([a-zA-Z$_]+))(\\d*)/', 
    255                                          array('fn' => '_replace_name') 
    256                 ); 
    257                 // replace: _name -> _0, double-underscore (__name) is ignored 
    258                 $regexp = '/\\b_[A-Za-z\\d]\\w*/'; 
    259                 // build the word list 
    260                 $keywords = $this->_analyze($script, $regexp, '_encodePrivate'); 
    261                 // quick ref 
    262                 $encoded = $keywords['encoded']; 
    263  
    264                 $parser->add($regexp, 
    265                         array( 
    266                                 'fn' => '_replace_encoded', 
    267                                 'data' => $encoded 
    268                         ) 
    269                 ); 
    270                 return $parser->exec($script); 
    271         } 
    272  
    273         private function _encodeKeywords($script) { 
    274                 // escape high-ascii values already in the script (i.e. in strings) 
    275                 if ($this->_encoding > 62) 
    276                         $script = $this->_escape95($script); 
    277                 // create the parser 
    278                 $parser = new ParseMaster(); 
    279                 $encode = $this->_getEncoder($this->_encoding); 
    280                 // for high-ascii, don't encode single character low-ascii 
    281                 $regexp = ($this->_encoding > 62) ? '/\\w\\w+/' : '/\\w+/'; 
    282                 // build the word list 
    283                 $keywords = $this->_analyze($script, $regexp, $encode); 
    284                 $encoded = $keywords['encoded']; 
    285  
    286                 // encode 
    287                 $parser->add($regexp, 
    288                         array( 
    289                                 'fn' => '_replace_encoded', 
    290                                 'data' => $encoded 
    291                         ) 
    292                 ); 
    293                 if (empty($script)) return $script; 
    294                 else { 
    295                         //$res = $parser->exec($script); 
    296                         //$res = $this->_bootStrap($res, $keywords); 
    297                         //return $res; 
    298                         return $this->_bootStrap($parser->exec($script), $keywords); 
    299                 } 
    300         } 
    301  
    302         private function _analyze($script, $regexp, $encode) { 
    303                 // analyse 
    304                 // retreive all words in the script 
    305                 $all = array(); 
    306                 preg_match_all($regexp, $script, $all); 
    307                 $_sorted = array(); // list of words sorted by frequency 
    308                 $_encoded = array(); // dictionary of word->encoding 
    309                 $_protected = array(); // instances of "protected" words 
    310                 $all = $all[0]; // simulate the javascript comportement of global match 
    311                 if (!empty($all)) { 
    312                         $unsorted = array(); // same list, not sorted 
    313                         $protected = array(); // "protected" words (dictionary of word->"word") 
    314                         $value = array(); // dictionary of charCode->encoding (eg. 256->ff) 
    315                         $this->_count = array(); // word->count 
    316                         $i = count($all); $j = 0; //$word = null; 
    317                         // count the occurrences - used for sorting later 
    318                         do { 
    319                                 --$i; 
    320                                 $word = '$' . $all[$i]; 
    321                                 if (!isset($this->_count[$word])) { 
    322                                         $this->_count[$word] = 0; 
    323                                         $unsorted[$j] = $word; 
    324                                         // make a dictionary of all of the protected words in this script 
    325                                         //  these are words that might be mistaken for encoding 
    326                                         //if (is_string($encode) && method_exists($this, $encode)) 
    327                                         $values[$j] = call_user_func(array(&$this, $encode), $j); 
    328                                         $protected['$' . $values[$j]] = $j++; 
    329                                 } 
    330                                 // increment the word counter 
    331                                 $this->_count[$word]++; 
    332                         } while ($i > 0); 
    333                         // prepare to sort the word list, first we must protect 
    334                         //  words that are also used as codes. we assign them a code 
    335                         //  equivalent to the word itself. 
    336                         // e.g. if "do" falls within our encoding range 
    337                         //      then we store keywords["do"] = "do"; 
    338                         // this avoids problems when decoding 
    339                         $i = count($unsorted); 
    340                         do { 
    341                                 $word = $unsorted[--$i]; 
    342                                 if (isset($protected[$word]) /*!= null*/) { 
    343                                         $_sorted[$protected[$word]] = substr($word, 1); 
    344                                         $_protected[$protected[$word]] = true; 
    345                                         $this->_count[$word] = 0; 
    346                                 } 
    347                         } while ($i); 
    348  
    349                         // sort the words by frequency 
    350                         // Note: the javascript and php version of sort can be different : 
    351                         // in php manual, usort : 
    352                         // " If two members compare as equal, 
    353                         // their order in the sorted array is undefined." 
    354                         // so the final packed script is different of the Dean's javascript version 
    355                         // but equivalent. 
    356                         // the ECMAscript standard does not guarantee this behaviour, 
    357                         // and thus not all browsers (e.g. Mozilla versions dating back to at 
    358                         // least 2003) respect this. 
    359                         usort($unsorted, array(&$this, '_sortWords')); 
    360                         $j = 0; 
    361                         // because there are "protected" words in the list 
    362                         //  we must add the sorted words around them 
    363                         do { 
    364                                 if (!isset($_sorted[$i])) 
    365                                         $_sorted[$i] = substr($unsorted[$j++], 1); 
    366                                 $_encoded[$_sorted[$i]] = $values[$i]; 
    367                         } while (++$i < count($unsorted)); 
    368                 } 
    369                 return array( 
    370                         'sorted'  => $_sorted, 
    371                         'encoded' => $_encoded, 
    372                         'protected' => $_protected); 
    373         } 
    374  
    375         private $_count = array(); 
    376         private function _sortWords($match1, $match2) { 
    377                 return $this->_count[$match2] - $this->_count[$match1]; 
    378         } 
    379  
    380         // build the boot function used for loading and decoding 
    381         private function _bootStrap($packed, $keywords) { 
    382                 $ENCODE = $this->_safeRegExp('$encode\\($count\\)'); 
    383  
    384                 // $packed: the packed script 
    385                 $packed = "'" . $this->_escape($packed) . "'"; 
    386  
    387                 // $ascii: base for encoding 
    388                 $ascii = min(count($keywords['sorted']), $this->_encoding); 
    389                 if ($ascii == 0) $ascii = 1; 
    390  
    391                 // $count: number of words contained in the script 
    392                 $count = count($keywords['sorted']); 
    393  
    394                 // $keywords: list of words contained in the script 
    395                 foreach ($keywords['protected'] as $i=>$value) { 
    396                         $keywords['sorted'][$i] = ''; 
    397                 } 
    398                 // convert from a string to an array 
    399                 ksort($keywords['sorted']); 
    400                 $keywords = "'" . implode('|',$keywords['sorted']) . "'.split('|')"; 
    401  
    402                 $encode = ($this->_encoding > 62) ? '_encode95' : $this->_getEncoder($ascii); 
    403                 $encode = $this->_getJSFunction($encode); 
    404                 $encode = preg_replace('/_encoding/','$ascii', $encode); 
    405                 $encode = preg_replace('/arguments\\.callee/','$encode', $encode); 
    406                 $inline = '\\$count' . ($ascii > 10 ? '.toString(\\$ascii)' : ''); 
    407  
    408                 // $decode: code snippet to speed up decoding 
    409                 if ($this->_fastDecode) { 
    410                         // create the decoder 
    411                         $decode = $this->_getJSFunction('_decodeBody'); 
    412                         if ($this->_encoding > 62) 
    413                                 $decode = preg_replace('/\\\\w/', '[\\xa1-\\xff]', $decode); 
    414                         // perform the encoding inline for lower ascii values 
    415                         elseif ($ascii < 36) 
    416                                 $decode = preg_replace($ENCODE, $inline, $decode); 
    417                         // special case: when $count==0 there are no keywords. I want to keep 
    418                         //  the basic shape of the unpacking funcion so i'll frig the code... 
    419                         if ($count == 0) 
    420                                 $decode = preg_replace($this->_safeRegExp('($count)\\s*=\\s*1'), '$1=0', $decode, 1); 
    421                 } 
    422  
    423                 // boot function 
    424                 $unpack = $this->_getJSFunction('_unpack'); 
    425                 if ($this->_fastDecode) { 
    426                         // insert the decoder 
    427                         $this->buffer = $decode; 
    428                         $unpack = preg_replace_callback('/\\{/', array(&$this, '_insertFastDecode'), $unpack, 1); 
    429                 } 
    430                 $unpack = preg_replace('/"/', "'", $unpack); 
    431                 if ($this->_encoding > 62) { // high-ascii 
    432                         // get rid of the word-boundaries for regexp matches 
    433                         $unpack = preg_replace('/\'\\\\\\\\b\'\s*\\+|\\+\s*\'\\\\\\\\b\'/', '', $unpack); 
    434                 } 
    435                 if ($ascii > 36 || $this->_encoding > 62 || $this->_fastDecode) { 
    436                         // insert the encode function 
    437                         $this->buffer = $encode; 
    438                         $unpack = preg_replace_callback('/\\{/', array(&$this, '_insertFastEncode'), $unpack, 1); 
    439                 } else { 
    440                         // perform the encoding inline 
    441                         $unpack = preg_replace($ENCODE, $inline, $unpack); 
    442                 } 
    443                 // pack the boot function too 
    444                 $unpackPacker = new JavaScriptPacker($unpack, 0, false, true); 
    445                 $unpack = $unpackPacker->pack(); 
    446  
    447                 // arguments 
    448                 $params = array($packed, $ascii, $count, $keywords); 
    449                 if ($this->_fastDecode) { 
    450                         $params[] = 0; 
    451                         $params[] = '{}'; 
    452                 } 
    453                 $params = implode(',', $params); 
    454  
    455                 // the whole thing 
    456                 return 'eval(' . $unpack . '(' . $params . "))\n"; 
    457         } 
    458  
    459         private $buffer; 
    460         private function _insertFastDecode($match) { 
    461                 return '{' . $this->buffer . ';'; 
    462         } 
    463         private function _insertFastEncode($match) { 
    464                 return '{$encode=' . $this->buffer . ';'; 
    465         } 
    466  
    467         // mmm.. ..which one do i need ?? 
    468         private function _getEncoder($ascii) { 
    469                 return $ascii > 10 ? $ascii > 36 ? $ascii > 62 ? 
    470                        '_encode95' : '_encode62' : '_encode36' : '_encode10'; 
    471         } 
    472  
    473         // zero encoding 
    474         // characters: 0123456789 
    475         private function _encode10($charCode) { 
    476                 return $charCode; 
    477         } 
    478  
    479         // inherent base36 support 
    480         // characters: 0123456789abcdefghijklmnopqrstuvwxyz 
    481         private function _encode36($charCode) { 
    482                 return base_convert($charCode, 10, 36); 
    483         } 
    484  
    485         // hitch a ride on base36 and add the upper case alpha characters 
    486         // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 
    487         private function _encode62($charCode) { 
    488                 $res = ''; 
    489                 if ($charCode >= $this->_encoding) { 
    490                         $res = $this->_encode62((int)($charCode / $this->_encoding)); 
    491                 } 
    492                 $charCode = $charCode % $this->_encoding; 
    493  
    494                 if ($charCode > 35) 
    495                         return $res . chr($charCode + 29); 
    496                 else 
    497                         return $res . base_convert($charCode, 10, 36); 
    498         } 
    499  
    500         // use high-ascii values 
    501         // characters: ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄà
    502 Ã†Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃÃŽÃÃÃ‘ÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãÀåÊçÚéêëìíîïðñòóÎõö÷ÞùúûÌÜß 
    503         private function _encode95($charCode) { 
    504                 $res = ''; 
    505                 if ($charCode >= $this->_encoding) 
    506                         $res = $this->_encode95($charCode / $this->_encoding); 
    507  
    508                 return $res . chr(($charCode % $this->_encoding) + 161); 
    509         } 
    510  
    511         private function _safeRegExp($string) { 
    512                 return '/'.preg_replace('/\$/', '\\\$', $string).'/'; 
    513         } 
    514  
    515         private function _encodePrivate($charCode) { 
    516                 return "_" . $charCode; 
    517         } 
    518  
    519         // protect characters used by the parser 
    520         private function _escape($script) { 
    521                 return preg_replace('/([\\\\\'])/', '\\\$1', $script); 
    522         } 
    523  
    524         // protect high-ascii characters already in the script 
    525         private function _escape95($script) { 
    526                 return preg_replace_callback( 
    527                         '/[\\xa1-\\xff]/', 
    528                         array(&$this, '_escape95Bis'), 
    529                         $script 
    530                 ); 
    531         } 
    532         private function _escape95Bis($match) { 
    533                 return '\x'.((string)dechex(ord($match))); 
    534         } 
    535  
    536  
    537         private function _getJSFunction($aName) { 
    538                 if (defined('self::JSFUNCTION'.$aName)) 
    539                         return constant('self::JSFUNCTION'.$aName); 
    540                 else 
    541                         return ''; 
    542         } 
    543  
    544         // JavaScript Functions used. 
    545         // Note : In Dean's version, these functions are converted 
    546         // with 'String(aFunctionName);'. 
    547         // This internal conversion complete the original code, ex : 
    548         // 'while (aBool) anAction();' is converted to 
    549         // 'while (aBool) { anAction(); }'. 
    550         // The JavaScript functions below are corrected. 
    551  
    552         // unpacking function - this is the boot strap function 
    553         //  data extracted from this packing routine is passed to 
    554         //  this function when decoded in the target 
    555         // NOTE ! : without the ';' final. 
    556         const JSFUNCTION_unpack = 
    557  
    558 'function($packed, $ascii, $count, $keywords, $encode, $decode) { 
    559     while ($count--) { 
    560         if ($keywords[$count]) { 
    561             $packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]); 
    562         } 
    563     } 
    564     return $packed; 
    565 }'; 
    566 /* 
    567 'function($packed, $ascii, $count, $keywords, $encode, $decode) { 
    568     while ($count--) 
    569         if ($keywords[$count]) 
    570             $packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]); 
    571     return $packed; 
    572 }'; 
    573 */ 
    574  
    575         // code-snippet inserted into the unpacker to speed up decoding 
    576         const JSFUNCTION_decodeBody = 
    577 //_decode = function() { 
    578 // does the browser support String.replace where the 
    579 //  replacement value is a function? 
    580  
    581 '    if (!\'\'.replace(/^/, String)) { 
    582         // decode all the values we need 
    583         while ($count--) { 
    584             $decode[$encode($count)] = $keywords[$count] || $encode($count); 
    585         } 
    586         // global replacement function 
    587         $keywords = [function ($encoded) {return $decode[$encoded]}]; 
    588         // generic match 
    589         $encode = function () {return \'\\\\w+\'}; 
    590         // reset the loop counter -  we are now doing a global replace 
    591         $count = 1; 
    592     } 
    593 '; 
    594 //}; 
    595 /* 
    596 '       if (!\'\'.replace(/^/, String)) { 
    597         // decode all the values we need 
    598         while ($count--) $decode[$encode($count)] = $keywords[$count] || $encode($count); 
    599         // global replacement function 
    600         $keywords = [function ($encoded) {return $decode[$encoded]}]; 
    601         // generic match 
    602         $encode = function () {return\'\\\\w+\'}; 
    603         // reset the loop counter -  we are now doing a global replace 
    604         $count = 1; 
    605     }'; 
    606 */ 
    607  
    608          // zero encoding 
    609          // characters: 0123456789 
    610          const JSFUNCTION_encode10 = 
    611 'function($charCode) { 
    612     return $charCode; 
    613 }';//;'; 
    614  
    615          // inherent base36 support 
    616          // characters: 0123456789abcdefghijklmnopqrstuvwxyz 
    617          const JSFUNCTION_encode36 = 
    618 'function($charCode) { 
    619     return $charCode.toString(36); 
    620 }';//;'; 
    621  
    622         // hitch a ride on base36 and add the upper case alpha characters 
    623         // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 
    624         const JSFUNCTION_encode62 = 
    625 'function($charCode) { 
    626     return ($charCode < _encoding ? \'\' : arguments.callee(parseInt($charCode / _encoding))) + 
    627     (($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36)); 
    628 }'; 
    629  
    630         // use high-ascii values 
    631         // characters: ¡¢£€¥Š§š©ª«¬­®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÀÁÂÃÄà
    632 Ã†Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃÃŽÃÃÃ‘ÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãÀåÊçÚéêëìíîïðñòóÎõö÷ÞùúûÌÜß 
    633         const JSFUNCTION_encode95 = 
    634 'function($charCode) { 
    635     return ($charCode < _encoding ? \'\' : arguments.callee($charCode / _encoding)) + 
    636         String.fromCharCode($charCode % _encoding + 161); 
    637 }'; 
    638  
    639 } 
    640  
    641  
    642 class ParseMaster { 
    643         public $ignoreCase = false; 
    644         public $escapeChar = ''; 
    645  
    646         // constants 
    647         const EXPRESSION = 0; 
    648         const REPLACEMENT = 1; 
    649         const LENGTH = 2; 
    650  
    651         // used to determine nesting levels 
    652         private $GROUPS = '/\\(/';//g 
    653         private $SUB_REPLACE = '/\\$\\d/'; 
    654         private $INDEXED = '/^\\$\\d+$/'; 
    655         private $TRIM = '/([\'"])\\1\\.(.*)\\.\\1\\1$/'; 
    656         private $ESCAPE = '/\\\./';//g 
    657         private $QUOTE = '/\'/'; 
    658         private $DELETED = '/\\x01[^\\x01]*\\x01/';//g 
    659  
    660         public function add($expression, $replacement = '') { 
    661                 // count the number of sub-expressions 
    662                 //  - add one because each pattern is itself a sub-expression 
    663                 $length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string)$expression), $out); 
    664  
    665                 // treat only strings $replacement 
    666                 if (is_string($replacement)) { 
    667                         // does the pattern deal with sub-expressions? 
    668                         if (preg_match($this->SUB_REPLACE, $replacement)) { 
    669                                 // a simple lookup? (e.g. "$2") 
    670                                 if (preg_match($this->INDEXED, $replacement)) { 
    671                                         // store the index (used for fast retrieval of matched strings) 
    672                                         $replacement = (int)(substr($replacement, 1)) - 1; 
    673                                 } else { // a complicated lookup (e.g. "Hello $2 $1") 
    674                                         // build a function to do the lookup 
    675                                         $quote = preg_match($this->QUOTE, $this->_internalEscape($replacement)) 
    676                                                  ? '"' : "'"; 
    677                                         $replacement = array( 
    678                                                 'fn' => '_backReferences', 
    679                                                 'data' => array( 
    680                                                         'replacement' => $replacement, 
    681                                                         'length' => $length, 
    682                                                         'quote' => $quote 
    683                                                 ) 
    684                                         ); 
    685                                 } 
    686                         } 
    687                 } 
    688                 // pass the modified arguments 
    689                 if (!empty($expression)) $this->_add($expression, $replacement, $length); 
    690                 else $this->_add('/^$/', $replacement, $length); 
    691         } 
    692  
    693         public function exec($string) { 
    694                 // execute the global replacement 
    695                 $this->_escaped = array(); 
    696  
    697                 // simulate the _patterns.toSTring of Dean 
    698                 $regexp = '/'; 
    699                 foreach ($this->_patterns as $reg) { 
    700                         $regexp .= '(' . substr($reg[self::EXPRESSION], 1, -1) . ')|'; 
    701                 } 
    702                 $regexp = substr($regexp, 0, -1) . '/'; 
    703                 $regexp .= ($this->ignoreCase) ? 'i' : ''; 
    704  
    705                 $string = $this->_escape($string, $this->escapeChar); 
    706                 $string = preg_replace_callback( 
    707                         $regexp, 
    708                         array( 
    709                                 &$this, 
    710                                 '_replacement' 
    711                         ), 
    712                         $string 
    713                 ); 
    714                 $string = $this->_unescape($string, $this->escapeChar); 
    715  
    716                 return preg_replace($this->DELETED, '', $string); 
    717         } 
    718  
    719         public function reset() { 
    720                 // clear the patterns collection so that this object may be re-used 
    721                 $this->_patterns = array(); 
    722         } 
    723  
    724         // private 
    725         private $_escaped = array();  // escaped characters 
    726         private $_patterns = array(); // patterns stored by index 
    727  
    728         // create and add a new pattern to the patterns collection 
    729         private function _add() { 
    730                 $arguments = func_get_args(); 
    731                 $this->_patterns[] = $arguments; 
    732         } 
    733  
    734         // this is the global replace function (it's quite complicated) 
    735         private function _replacement($arguments) { 
    736                 if (empty($arguments)) return ''; 
    737  
    738                 $i = 1; $j = 0; 
    739                 // loop through the patterns 
    740                 while (isset($this->_patterns[$j])) { 
    741                         $pattern = $this->_patterns[$j++]; 
    742                         // do we have a result? 
    743                         if (isset($arguments[$i]) && ($arguments[$i] != '')) { 
    744                                 $replacement = $pattern[self::REPLACEMENT]; 
    745  
    746                                 if (is_array($replacement) && isset($replacement['fn'])) { 
    747  
    748                                         if (isset($replacement['data'])) $this->buffer = $replacement['data']; 
    749                                         return call_user_func(array(&$this, $replacement['fn']), $arguments, $i); 
    750  
    751                                 } elseif (is_int($replacement)) { 
    752                                         return $arguments[$replacement + $i]; 
    753  
    754                                 } 
    755                                 $delete = ($this->escapeChar == '' || 
    756                                            strpos($arguments[$i], $this->escapeChar) === false) 
    757                                         ? '' : "\x01" . $arguments[$i] . "\x01"; 
    758                                 return $delete . $replacement; 
    759  
    760                         // skip over references to sub-expressions 
    761                         } else { 
    762                                 $i += $pattern[self::LENGTH]; 
    763                         } 
    764                 } 
    765         } 
    766  
    767         private function _backReferences($match, $offset) { 
    768                 $replacement = $this->buffer['replacement']; 
    769                 $quote = $this->buffer['quote']; 
    770                 $i = $this->buffer['length']; 
    771                 while ($i) { 
    772                         $replacement = str_replace('$'.$i--, $match[$offset + $i], $replacement); 
    773                 } 
    774                 return $replacement; 
    775         } 
    776  
    777         private function _replace_name($match, $offset){ 
    778                 $length = strlen($match[$offset + 2]); 
    779                 $start = $length - max($length - strlen($match[$offset + 3]), 0); 
    780                 return substr($match[$offset + 1], $start, $length) . $match[$offset + 4]; 
    781         } 
    782  
    783         private function _replace_encoded($match, $offset) { 
    784                 return $this->buffer[$match[$offset]]; 
    785         } 
    786  
    787  
    788         // php : we cannot pass additional data to preg_replace_callback, 
    789         // and we cannot use &$this in create_function, so let's go to lower level 
    790         private $buffer; 
    791  
    792         // encode escaped characters 
    793         private function _escape($string, $escapeChar) { 
    794                 if ($escapeChar) { 
    795                         $this->buffer = $escapeChar; 
    796                         return preg_replace_callback( 
    797                                 '/\\' . $escapeChar . '(.)' .'/', 
    798                                 array(&$this, '_escapeBis'), 
    799                                 $string 
    800                         ); 
    801  
    802                 } else { 
    803                         return $string; 
    804                 } 
    805         } 
    806         private function _escapeBis($match) { 
    807                 $this->_escaped[] = $match[1]; 
    808                 return $this->buffer; 
    809         } 
    810  
    811         // decode escaped characters 
    812         private function _unescape($string, $escapeChar) { 
    813                 if ($escapeChar) { 
    814                         $regexp = '/'.'\\'.$escapeChar.'/'; 
    815                         $this->buffer = array('escapeChar'=> $escapeChar, 'i' => 0); 
    816                         return preg_replace_callback 
    817                         ( 
    818                                 $regexp, 
    819                                 array(&$this, '_unescapeBis'), 
    820                                 $string 
    821                         ); 
    822  
    823                 } else { 
    824                         return $string; 
    825                 } 
    826         } 
    827         private function _unescapeBis() { 
    828                 if (!empty($this->_escaped[$this->buffer['i']])) { 
    829                          $temp = $this->_escaped[$this->buffer['i']]; 
    830                 } else { 
    831                         $temp = ''; 
    832                 } 
    833                 $this->buffer['i']++; 
    834                 return $this->buffer['escapeChar'] . $temp; 
    835         } 
    836  
    837         private function _internalEscape($string) { 
    838                 return preg_replace($this->ESCAPE, '', $string); 
    839         } 
    840 } 
    8412 
    8423$request_method = '_' . $_SERVER['REQUEST_METHOD']; 
     
    85516                return false; 
    85617} 
     18 
     19require_once dirname(__FILE__) . '/inc/Controller.class.php'; 
     20 
    85721$controller = new Controller; 
    858 $controller->exec($$request_method); 
     22printf("%s", $controller->exec($$request_method)); 
    85923 
    86024exit(0); 
  • trunk/instant_messenger/inc/Jabber.abstract.php

    r265 r287  
    7979        } 
    8080 
    81         protected function connect($pUser = false, $pPassword = false, $pConnectionType = false) 
     81        protected function connect($pUser = false, $pPassword = false, $pConnectionType = false, $pWebjabber = false ) 
    8282        {  
    8383                try 
    8484                { 
    85                         $_connect = $this->_connect($pUser, $pPassword, $pConnectionType); 
     85                        $_connect = $this->_connect($pUser, $pPassword, $pConnectionType, $pWebjabber ); 
    8686 
    8787                        if ( !$_connect ) 
  • trunk/instant_messenger/inc/Jabberd2.abstract.php

    r275 r287  
    6969                else 
    7070                { 
    71                         if ( $this->writeSocket($this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact)) ) 
     71                        if ( $this->iq('set', $addid, NULL, NULL, "jabber:iq:roster", $newcontact) ) 
    7272                                $this->getContacts(); 
    73                                 echo "OK"; 
     73                        echo "OK"; 
    7474                } 
    7575        } 
     
    9696                        else 
    9797                        { 
    98                                 $this->writeSocket($this->iq('get', $vcard, $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>")); 
     98                                $this->iq('get', $vcard, $jid, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'/>"); 
    9999                        } 
    100100                } 
     
    113113                else 
    114114                { 
    115                         $this->writeSocket($this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>")); 
     115                        $this->iq('set', $id, NULL, NULL, "vcard-temp", "<vCard xmlns='vcard-temp'>".$NewVcard['vcard']."</vCard>"); 
    116116                        echo "OK"; 
    117117                } 
     
    124124                        return "disconnected"; 
    125125                         
    126                 if ( $this->writeSocket($this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>")) ) 
     126                if ( $this->iq('set',$delid,NULL,NULL,"jabber:iq:roster","<item jid='".$pContact['jid']."' subscription='remove'/>") ) 
    127127                        if ( $this->subscription($pContact['jid'],"unsubscribed") ) 
    128128                                echo "OK"; 
     
    141141                        return true; 
    142142                } 
     143        } 
     144 
     145        final function compression() 
     146        { 
     147                $compress = "<compress xmlns='http://jabber.org/protocol/compress'><method>zlib</method></compress>";    
     148                $this->writeSocket($compress); 
    143149        } 
    144150 
     
    164170                $id = "last_time_user"; 
    165171                $jid = ( trim($pUser['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pUser['jid']; 
    166                 $this->writeSocket($this->iq('get', $id, $jid, NULL, "jabber:iq:last")); 
     172                $this->iq('get', $id, $jid, NULL, "jabber:iq:last"); 
    167173        } 
    168174 
     
    191197                else 
    192198                { 
    193                         $this->writeSocket($this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact)); 
     199                        $this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact); 
    194200                        $this->getContacts(); 
    195201                        echo "OK"; 
  • trunk/instant_messenger/inc/Socket.abstract.php

    r260 r287  
    5252                set_magic_quotes_runtime(0); 
    5353                $return = @fread($pSocket, $pLength); 
     54 
    5455                set_magic_quotes_runtime(get_magic_quotes_gpc()); 
    55  
    5656 
    5757                if ( $php_errormsg ) 
  • trunk/instant_messenger/inc/class.Ujabber.inc.php

    r275 r287  
    77        private $set_presence; 
    88         
    9         public final function __construct() 
     9        public final function __construct($pConnectionType = 'write') 
    1010        {        
    1111                session_start(); 
    12  
    1312                $this->_user     = $_SESSION['phpgw_info']['instant_messenger']['user']; 
    1413                $this->_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 
     
    1716                $this->_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']; 
    1817                $webjabber       = $_SESSION['phpgw_info']['instant_messenger']['webjabber']; 
    19  
    2018                session_write_close(); 
    2119 
    22                 if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, 'read/write', $webjabber) ) 
     20                if ( $this->connect($this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port, $this->_pass, $pConnectionType, $webjabber) ) 
    2321                        $this->connected = true; 
    2422                else 
     
    6159                        while ( ( connection_aborted() === 0 ) && time() - $init < 50 ) 
    6260                        { 
    63                                  
     61                                if( isset($xml) )        
     62                                        unset($xml); 
     63                         
    6464                                # read from server and write in the client 
    6565                                $xml = $this->readSocket(); 
    66                                 //var_dump($xml); 
    6766                                $xml = ( strlen($xml) ) ? $xml : ' '; 
     67                                //$xml = ( strlen($xml) ) ? $xml : '_##_'; 
    6868                                printf("%s", $xml); 
    6969                                ob_flush(); 
     
    7474        } 
    7575 
    76     public final function SendMessage($pSendMessage) 
    77     { 
     76        public final function SendMessage($pSendMessage) 
     77        { 
    7878                if ( !$this->isConnected() ) 
    7979                        return "disconnected"; 
     
    8585                $pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']); 
    8686 
    87                 $_emotions  = '/<img emotion="(\S+)?"[^>]+>/'; 
     87                $_emotions  = '/<img[^>]*emotion="(\S+)?"[^>]*>/';  
    8888                $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions); 
    8989 
     
    134134 
    135135                        //retirar a linha abaixo para voltar ao padrão conforme acima 
    136                         $xml .= "<body>" . $content['body'] . "</body>"; 
     136                        $xml .= "<body><![CDATA[" . htmlentities($content['body']) . "]]></body>"; 
    137137                        $xml .= $payload; 
    138138                        $xml .= "</message>"; 
  • trunk/instant_messenger/inc/class.db_im.inc.php

    r260 r287  
    1919        function db_im() 
    2020        { 
    21                  
    2221                session_start();                 
    2322                $this->db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name']; 
  • trunk/instant_messenger/inc/class.ldap_im.inc.php

    r275 r287  
    1313                session_start(); 
    1414                $this->ldap_host                = $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']; 
    15                 $this->ldap_context     = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 
     15                $this->ldap_context             = $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']; 
    1616                $this->user                     = $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']; 
    1717                $this->password                 = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']; 
    18                 $this->jid                              = $_SESSION['phpgw_info']['instant_messenger']['user']; 
     18                $this->jid                      = $_SESSION['phpgw_info']['instant_messenger']['user']; 
    1919                $this->connect_ldap(true); 
    2020                session_write_close(); 
  • trunk/instant_messenger/inc/im_acl.inc.php

    r262 r287  
    11<?php 
    22 
    3 $size_of_ACL = sizeof($GLOBALS['phpgw_info']['user']['acl']); 
     3$size_of_acl = sizeof($GLOBALS['phpgw_info']['user']['acl']); 
    44 
    5 for ( $i = 0; $i < sizeof($GLOBALS['phpgw_info']['user']['acl']); $i++ ) 
     5# percorre a ACL até o fim ou até encontrar a entrada para o módulo de mensagem instantânea 
     6for ( $i = 0; $i < $size_of_acl && $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] != 'instant_messenger'; $i++ ); 
     7 
     8# verifica se foi encontrada a permissão para o módulo de mensagem instantânea 
     9if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger' ) 
    610{ 
    7       if ( $GLOBALS['phpgw_info']['user']['acl'][$i]['appname'] == 'instant_messenger') 
    8       { 
    9                         $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url']; 
    10                         $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/'; 
    11                          
    12                         if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) ) 
    13                                 $webserver_url .= '/'; 
    14                          
    15                         $webserver_url = $webserver_url . 'instant_messenger/'; 
    16                          
    17                         session_start(); 
    18                         require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php'; 
    19                         require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php'; 
    20                         $_user     = $_SESSION['phpgw_info']['instant_messenger']['user']; 
    21                         $_pass     = $_SESSION['phpgw_info']['instant_messenger']['passwd']; 
    22                         $_server   = $_SESSION['phpgw_info']['instant_messenger']['name_jabber']; 
    23                         $_port     = $_SESSION['phpgw_info']['instant_messenger']['port_jabber']; 
    24                         $_resource = $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']; 
    25                         session_write_close(); 
    26                          
    27                         $js = array( 
    28                                 'connector', 
    29                                 'xtools', 
    30                                 'jabber', 
    31                                 'client', 
    32                                 'images', 
    33                                 'dragdrop', 
    34                                 'build_win', 
    35                                 'templates', 
    36                                 'fcommon', 
    37                                 'menu_action', 
    38                                 'functions', 
    39                                 'images', 
    40                                 'cookies_im', 
    41                                 'load', 
    42                         ); 
    43                          
    44                         print '<script type="text/javascript">var path_im = "'.$webserver_url.'";</script>'; 
    45                          
    46                         foreach ( $js as $key => $val ) 
    47                                 print '<script src="' . $webserver_url . 'controller.php?act=j.' . $val . '"></script>'; 
    48                          
    49                         print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/window.css">'; 
    50                         print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/chat.css">'; 
    51                         print '<link rel="stylesheet" type="text/css" href="' . $webserver_url . 'templates/default/css/common.css">'; 
    52                          
    53                         print '<script type="text/javascript">setTimeout("client()",2000);</script>'; 
    54       } 
     11        $webserver_url_im = $GLOBALS['phpgw_info']['server']['webserver_url']; 
     12        $webserver_url_im = ( !empty($webserver_url_im) ) ? $webserver_url_im : '/'; 
     13 
     14        if ( strrpos($webserver_url_im, '/') === false || strrpos($webserver_url_im, '/') != (strlen($webserver_url_im) - 1) ) 
     15                $webserver_url_im .= '/'; 
     16 
     17        $webserver_url_im = $webserver_url_im . 'instant_messenger/'; 
     18 
     19        require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php'; 
     20        require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/load_lang.php'; 
     21 
     22        $js = array( 
     23                'connector', 
     24                'jabber', 
     25                'xtools', 
     26                'client', 
     27                'images', 
     28                'dragdrop', 
     29                'build_win', 
     30                'templates', 
     31                'fcommon', 
     32                'menu_action', 
     33                'functions', 
     34                'images', 
     35                'cookies_im', 
     36                'load', 
     37        ); 
     38 
     39        print '<script type="text/javascript">var path_im = "'.$webserver_url_im.'";</script>'; 
     40 
     41 
     42        require_once dirname(__FILE__) . '/Controller.class.php'; 
     43 
     44        $controller = new Controller; 
     45        $script = ''; 
     46        foreach ( $js as $key => $val ) 
     47        { 
     48                $val = array('act' => 'j.' . $val); 
     49                $script .= $controller->exec($val); 
     50        } 
     51 
     52        printf("<script type=\"text/javascript\">%s</script>", $script); 
     53 
     54        print '<link rel="stylesheet" type="text/css" href="' . $webserver_url_im . 'templates/default/css/window.css">'; 
     55        print '<link rel="stylesheet" type="text/css" href="' . $webserver_url_im . 'templates/default/css/chat.css">'; 
     56        print '<link rel="stylesheet" type="text/css" href="' . $webserver_url_im . 'templates/default/css/common.css">'; 
     57 
     58        # trecho de código javascript utilizado para 
     59        # controle de possí­vel erro no load do script 
     60        # feito acima e está sendo inserido via PHP 
     61        # pois é um complemento do procedimento acima 
     62        $init_client  = '<script type="text/javascript">'; 
     63        $init_client .= '       function im_init(pTimes)'; 
     64        $init_client .= '       {'; 
     65        $init_client .= '               if ( !pTimes )'; 
     66        $init_client .= '                       pTimes = 0;'; 
     67        $init_client .= '               if ( pTimes == 5 )'; 
     68        $init_client .= '                       return false;'; 
     69        $init_client .= '               if ( window.client )'; 
     70        $init_client .= '                       client();'; 
     71        $init_client .= '               else'; 
     72        $init_client .= '                       setTimeout("im_init("+(++pTimes)+")", (pTimes + 1) * 2000);'; 
     73        $init_client .= '       }'; 
     74        $init_client .= '       im_init();'; 
     75        $init_client .= '</script>'; 
     76        printf("%s", $init_client); 
    5577} 
    5678?> 
  • trunk/instant_messenger/inc/im_sessions.inc.php

    r265 r287  
    11<?php 
    2  
     2         
    33                $_SESSION['phpgw_info']['instant_messenger']['user']             = $GLOBALS['phpgw_info']['user']['account_lid']; 
    4                 $_SESSION['phpgw_info']['instant_messenger']['user_id']                 = $GLOBALS['phpgw_info']['user']['account_id'];                 
     4                $_SESSION['phpgw_info']['instant_messenger']['user_id']          = $GLOBALS['phpgw_info']['user']['account_id'];                 
    55                $_SESSION['phpgw_info']['instant_messenger']['passwd']           = $GLOBALS['phpgw_info']['user']['passwd']; 
    66                $_SESSION['phpgw_info']['instant_messenger']['name_jabber']      = $GLOBALS['phpgw_info']['server']['name_jabber']; 
    77                $_SESSION['phpgw_info']['instant_messenger']['port_jabber']      = $GLOBALS['phpgw_info']['server']['port_jabber']; 
    88                $_SESSION['phpgw_info']['instant_messenger']['resource_jabber']  = $GLOBALS['phpgw_info']['server']['resource_jabber']; 
    9                 $_SESSION['phpgw_info']['instant_messenger']['tls_jabber']       = $GLOBALS['phpgw_info']['server']['tls_jabber']; 
    109                 
    11                 $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']   = $GLOBALS['phpgw_info']['server']['server_ldap_jabber']; 
    12                 $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']  = $GLOBALS['phpgw_info']['server']['context_ldap_jabber']; 
    13                 $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']     = $GLOBALS['phpgw_info']['server']['user_ldap_jabber']; 
    14                 $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'] = $GLOBALS['phpgw_info']['server']['password_ldap_jabber']; 
    15                 $_SESSION['phpgw_info']['instant_messenger']['webjabber']                        = $GLOBALS['phpgw_info']['server']['wejabber'];                 
     10                $_SESSION['phpgw_info']['instant_messenger']['server_ldap_jabber']      = $GLOBALS['phpgw_info']['server']['server_ldap_jabber']; 
     11                $_SESSION['phpgw_info']['instant_messenger']['context_ldap_jabber']     = $GLOBALS['phpgw_info']['server']['context_ldap_jabber']; 
     12                $_SESSION['phpgw_info']['instant_messenger']['user_ldap_jabber']        = $GLOBALS['phpgw_info']['server']['user_ldap_jabber']; 
     13                $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber']    = $GLOBALS['phpgw_info']['server']['password_ldap_jabber']; 
     14                $_SESSION['phpgw_info']['instant_messenger']['webjabber']               = $GLOBALS['phpgw_info']['server']['webjabber'];                 
    1615                 
    1716                $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'] = $GLOBALS['phpgw_info']['server']['db_name']; 
     
    2120                $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'] = $GLOBALS['phpgw_info']['server']['db_pass']; 
    2221                $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'] = $GLOBALS['phpgw_info']['server']['db_type']; 
    23  
     22                 
    2423?> 
  • trunk/instant_messenger/inc/load_lang.php

    r260 r287  
    11<? 
    2 if ( !isset($_SESSION['phpgw_info']['instant_messenger']['lang']) || !is_array($_SESSION['phpgw_info']['instant_messenger']['lang']) ) 
    3    if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) ) 
    4       if ( ($fp = fopen($fn,'r')) ) 
    5       { 
    6          while ($data = fgets($fp,16000)) 
    7          { 
    8             list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1)); 
    9             $_SESSION['phpgw_info']['instant_messenger']['lang'][$message_id] = $content; 
    10          } 
    11          fclose($fp); 
    12       } 
     2 
     3if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) ) 
     4        if ( ($fp = fopen($fn,'r')) ) 
     5        { 
     6                while ($data = fgets($fp,16000)) 
     7                { 
     8                        list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1)); 
     9                        $LANG_IM[$message_id] = $content; 
     10                } 
     11                fclose($fp); 
     12        } 
    1313 
    1414$script  = '<script>'; 
    1515$script .= 'var lang_im = [];'; 
    1616 
    17 foreach ( $_SESSION['phpgw_info']['instant_messenger']['lang'] as $key => $value ) 
     17foreach ( $LANG_IM as $key => $value ) 
    1818   $script .= "lang_im['" . strtolower(addslashes($key)) . "'] = '" . addslashes($value) . "';"; 
    19  
    20    #$_key = str_replace("'","\'",strtolower($key)); 
    21    #$_val = str_replace("'","\'",$value); 
    2219 
    2320$script .= '</script>'; 
    2421 
    2522echo $script; 
     23 
     24unset($LANG_IM); 
    2625?> 
  • trunk/instant_messenger/js/build_win.js

    r260 r287  
    8787        "window_focus" :  function(pElement) 
    8888        { 
    89                 pElement.style.zIndex = ++this.focus; 
     89                if (! templates.dontFocus) 
     90                        pElement.style.zIndex = ++this.focus; 
     91                else 
     92                        templates.dontFocus = false; 
    9093        }, 
    9194 
     
    103106                this.elementM(pId).style.width = window.screen.availWidth - 24; 
    104107                this.elementM(pId).style.height = window.screen.availHeight - 60; 
     108                 
    105109 
    106110                // _window_body 
     
    110114                // _window_body_content 
    111115                this.elementC(pId).style.height = '100%'; 
     116                var windowType = this.elementC(pId).firstChild.firstChild.className; 
     117 
     118                if (windowType == 'history') // message window 
     119                { 
     120                        this.elementC(pId).firstChild.childNodes[0].style.height = '60%'; 
     121                        this.elementC(pId).firstChild.childNodes[0].style.width = '100%'; 
     122                        this.elementC(pId).firstChild.childNodes[1].style.width = '100%'; 
     123                        this.elementC(pId).firstChild.childNodes[2].firstChild.style.width = '100%'; 
     124                } 
     125                else if (windowType == 'font_menu') // contacts window 
     126                { 
     127                        this.elementC(pId).childNodes[1].style.height = '70%'; 
     128                } 
     129 
    112130        }, 
    113131 
  • trunk/instant_messenger/js/client.js

    r275 r287  
    1 var con = new IMConnector; 
     1var conn_im = new IMConnector; 
    22var disconnected = false; 
     3var validate_data = false; 
     4var buffer_im = ''; 
     5var xtools_im = null; 
     6var count_im = 0; 
     7var activate_timeOut = ''; 
     8 
     9function clientConnectionIm() 
     10{ 
     11        if( count_im < 2 ) 
     12        { 
     13                if( buffer_im.length > 0 ) 
     14                        activate_timeOut = setTimeout('clientConnectionIm()', 5000); 
     15         
     16                count_im++; 
     17        } 
     18        else 
     19        { 
     20                count_im = 0; 
     21                buffer_im = 0; 
     22                clientDisconnectIm(); 
     23                clearTimeout(activate_timeOut); 
     24                killConnIm(); 
     25        } 
     26} 
     27 
     28function clientDisconnectIm() 
     29{ 
     30        if( xtools_im == null ) 
     31                 xtools_im = new XTools; 
     32 
     33        disconnected = true; 
     34        var XmlDoc = "<disconnected>" + 
     35                        "<path>" + path_im + "</path>" + 
     36                     "</disconnected>"; 
     37         
     38        im_window.load('__contacts_im_','instant_messenger_content','<title>.::Expresso Messenger::.</title>','window.xsl','190',true,true,false); 
     39        im_window.elementC('__contacts_im_').innerHTML  = xtools_im.parse(XmlDoc,'disconnected.xsl'); 
     40        func.byId('im_status_src').src = im_unavailable.src; 
     41        im.status = 'type=unavailable'; 
     42        im.statusFlag = 'unavailable';                                                                                                   
     43         
     44        function handler_presence_disconnected() 
     45        { 
     46        } 
     47        conn_im.go('$this.Ujabber.setPresence', {'request' : handler_presence_disconnected }, im.status); 
     48} 
     49 
     50function killConnIm() 
     51{ 
     52        var i; 
     53        disconnected = true; 
     54         
     55        for ( i in conn_im.__HTTP__ ) 
     56                conn_im.__HTTP__[i].abort(); 
     57} 
    358 
    459function client() 
    560{ 
    6         var jabber = new Jabber; 
    7         var buffer = ''; 
    8         var xtools = new XTools; 
     61        if( jabber == null ) 
     62                var jabber = new Jabber; 
     63         
     64        if( xtools_im == null ) 
     65                xtools_im = new XTools; 
    966 
    1067        function request(data) 
     
    1269                if ( !disconnected ) 
    1370                { 
    14                         con.go('$this.Ujabber.listen', {'stream':stream, 'request':request}); 
     71                        conn_im.go('$this.Ujabber.listen', {'stream':stream, 'request':request}, 'classConstructor=read'); 
     72                } 
     73                else 
     74                { 
     75                        clientDisconnectIm(); 
     76                        return false; 
    1577                } 
    1678        } 
     
    2284                        return pData.replace(/^ +| +$/g, ''); 
    2385                } 
     86 
     87                function retrim(pData) 
     88                { 
     89                        return pData.replace(/(_##_)+\b/g, ''); 
     90                } 
     91                 
    2492                data = trim(data); 
    25                 if ( data == 'disconnected' || data == '</stream:stream>') 
     93                 
     94                if ( data == 'disconnected' || data == '</stream:stream>' ) 
    2695                { 
    27                         disconnected = true; 
    28                         var XmlDoc = "<disconnected>" + 
    29                                                         "<path>" + path_im + "</path>" + 
    30                                                  "</disconnected>"; 
    31  
    32                         im_window.load('__contacts_im_','instant_messenger_content','<title>.::Expresso Messenger::.</title>','window.xsl','',true,true,false); 
    33                         im_window.elementC('__contacts_im_').innerHTML  = xtools.parse(XmlDoc,'disconnected.xsl'); 
    34                         func.byId('img_status_im').src = im_unavailable.src; 
    35                         im.status = 'type=unavailable'; 
    36                         im.statusFlag = 'unavailable';                                   
    37  
     96                        clientDisconnectIm(); 
     97                        return false; 
    3898                } 
    39                 else if ( data.lastIndexOf('>') == data.length - 1) 
     99                else if ( data.lastIndexOf('>') == data.length - 1 && data.length > 0 ) 
    40100                { 
    41                         if ( buffer.length ) 
     101                        if ( buffer_im.length ) 
    42102                        { 
    43                                 data = buffer + data; 
    44                                 buffer = ''; 
     103                                data = buffer_im + data; 
     104                                buffer_im = ""; 
    45105                        } 
    46106 
     
    62122 
    63123                        var node = xmlDoc.documentElement.firstChild; 
    64  
     124                         
    65125                        while ( node ) 
    66126                        { 
    67127                                try 
    68128                                { 
    69                                         with ( node ) 
    70                                         { 
    71                                                 jabber.doIt(nodeName, node); 
    72                                         } 
     129                                        jabber.doIt(node.nodeName, node); 
    73130                                        node = node.nextSibling; 
    74131                                } 
    75132                                catch(e) 
    76133                                { 
     134                                        alert('erro : ' + e + "\n\n" + e.description); 
    77135                                        node = node.nextSibling; 
    78136                                } 
     
    81139                else 
    82140                { 
    83                         buffer += data; 
     141                        data = data.replace(/^ +| +$/g, ''); 
     142                        buffer_im +=  data + " "; 
    84143                } 
    85144        } 
     
    87146        function contacts(data) 
    88147        { 
     148                setTimeout('clientConnectionIm()', 3000); 
    89149        } 
    90150        request(); 
    91         setTimeout("con.go('$this.Ujabber.getContacts', {'request':"+contacts+"})", 3000); 
     151        setTimeout("conn_im.go('$this.Ujabber.getContacts', {'request':"+contacts+"})", 3000); 
    92152} 
    93153 
     
    99159                _bkp_onbeforeunload(); 
    100160 
    101         disconnected = true; 
    102         var i; 
    103         for ( i in con.__HTTP__ ) 
    104                 con.__HTTP__[i].abort(); 
     161        killConnIm(); 
    105162}; 
  • trunk/instant_messenger/js/functions.js

    r275 r287  
    2727                var content = get_Element(pJid); 
    2828                content.innerHTML += "" + this.insertEmoticons(pEmotion); 
     29                var smileWindow = document.getElementById(pJid+"__button_dest"); 
     30                if (smileWindow.firstChild) 
     31                        smileWindow.removeChild(smileWindow.firstChild); 
    2932        }, 
    3033 
     
    8891                } 
    8992                var content = get_Element(pJid); 
    90                  
     93                 
     94                var colorWindow = document.getElementById(pJid+"__button_dest"); 
     95                if (colorWindow.firstChild)  
     96                        colorWindow.removeChild(colorWindow.firstChild); 
     97 
    9198                if( _font_color = _document.contentWindow.document.getElementById('colors_'+pJid) ) 
    9299                        content.innerHTML = "<span id='colors_"+pJid+"'style='color:"+pColor+"'>"+_font_color.innerHTML+"</span>"; 
     
    346353                        { 
    347354                                var data = eval(XmlData); 
     355 
    348356                                if( data ) 
    349357                                { 
    350358                                        if( document.getElementById(pAvatar) != null ) 
    351359                                        { 
    352                                                 var photo_img = document.getElementById(pAvatar); 
    353                                                 photo_img.src = ( path_im + "inc/class.ldap_im.inc.php?user="+uid ) ? path_im + "inc/class.ldap_im.inc.php?user="+uid : im_photo.src ; 
     360                                                if( document.getElementById(pAvatar).src ) 
     361                                                { 
     362                                                        var photo_img = document.getElementById(pAvatar); 
     363                                                        photo_img.src = ( path_im + "inc/class.ldap_im.inc.php?user="+uid ) ? path_im + "inc/class.ldap_im.inc.php?user="+uid : im_photo.src ; 
     364                                                } 
     365                                                else 
     366                                                { 
     367                                                        var photo_img = document.getElementById(pAvatar); 
     368                                                        photo_img.style.backgroundImage = 'url(' + path_im + 'inc/class.ldap_im.inc.php?user='+uid+')'; 
     369                                                } 
    354370                                        }                
    355371                                } 
     
    361377        }, 
    362378         
    363         "newMessageNotification" : function() 
    364         { 
     379      "newMessageNotification" : function() 
     380      { 
    365381      if ( !focusFlag ) 
    366382      { 
     
    455471                { 
    456472                        if(imgStatus != null) 
    457                                 func.byId('im_status_src').src = eval('im_' + imgStatus + '.src'); 
     473                        { 
     474                                var img_status =  document.getElementById('im_status_src'); 
     475                                img_status.src = eval('im_' + imgStatus + '.src'); 
     476                        } 
    458477                } 
    459478                this.conn.go('$this.Ujabber.setPresence', {'request' : handler_presence}, this.status); 
     
    462481        "remove" : function(pJid) 
    463482        { 
     483                if (pJid == -1) 
     484                        return false; 
    464485                if(confirm('Deseja excluir o contato ' + pJid + ' ?')) 
    465486                { 
     
    488509                                if( func.byId(pElement).options[i].selected == true ) 
    489510                                         Jid = func.byId(pElement).options[i].value; 
    490                                           
    491                 if(confirm('Deseja excluir o contato ' + Jid + ' ?')) 
    492                 { 
    493                         if( Jid && Jid != -1 ) 
    494                         { 
     511                if (Jid == -1) 
     512                        return false; 
     513                else 
     514                        if(confirm('Deseja excluir o contato ' + Jid + ' ?')) 
     515                        { 
     516                                if( Jid && Jid != -1 ) 
     517                                { 
    495518                                function handler_remove(XmlData) 
    496519                                { 
     
    535558                { 
    536559                        if( XmlData != "OK" ) 
    537                                 alert('Vcard não cadastrado/atualizado !'); 
     560                                alert('Erro: Vcard não cadastrado/atualizado !'); 
    538561                        else 
    539562                                alert('Vcard cadastrado/atualizado !'); 
     563                        im_window.window_close('vcard_user_im'); 
    540564                } 
    541565                this.conn.go('$this.Ujabber.newVcard',{'request':handler_savevcard},"vcard="+xmlVcard); 
     
    571595                                im.off_line(); 
    572596                                alert('Preferências Salvas !'); 
     597                                im_window.window_close('my_settings_im'); 
    573598                        } 
    574599                } 
  • trunk/instant_messenger/js/images.js

    r260 r287  
    2929        var im_group_open = new Image(); 
    3030        im_group_open.src = path_im + 'templates/default/images/group_open.gif'; 
    31          
     31 
    3232// Smiles 
    3333 
  • trunk/instant_messenger/js/jabber.js

    r280 r287  
    121121                                var iframe = func.byId('iframe_' + from); 
    122122 
    123                                 //if(func.byId('iframe_' + from) != null) 
    124                                         //func.byId('iframe_' + from).parentNode.removeChild(func.byId('iframe_' + from)); 
    125  
    126123                                var win; 
    127124 
     
    142139                                        var iframe = document.createElement('iframe'); 
    143140                                        iframe.id = 'iframe_' + from; 
    144                                         iframe.style.width = '290px'; 
    145                                         iframe.style.height = '46px'; 
     141                                        iframe.style.width = '240px'; 
     142                                        iframe.style.height = '65px'; 
    146143                                        iframe.style.border = '0'; 
    147144                                        iframe.style.margin = '0'; 
     
    154151                                        iframe.contentWindow.document.close(); 
    155152                                        iframe.contentWindow.document.designMode = "On"; 
     153 
     154                                        function getEnter(e) 
     155                                        { 
     156                                                if ( !(e.shiftKey) && (e.keyCode == 13) ) 
     157                                                { 
     158                                                        if ( e.type.indexOf('keydown') != -1 ) 
     159                                                                im.SendMessage(from); 
     160                                                        else 
     161                                                                iframe.contentWindow.document.body.innerHTML = ''; 
     162                                                        return false; 
     163                                                } 
     164                                        } 
     165 
     166                                        func.attachEvent(iframe.contentWindow, 'onkeydown', getEnter); 
     167                                        func.attachEvent(iframe.contentWindow, 'onkeyup', getEnter); 
    156168 
    157169                                } 
     
    327339                function readVcard(pVcard) 
    328340                { 
     341                         
    329342                        switch(pVcard.getAttribute('id')) 
    330343                        { 
     
    338351                                                { 
    339352                                                        if(cc.firstChild.nodeValue) 
    340                                                                 func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue;                                                              
     353                                                                func.byId('im_layer_nickname').innerHTML = cc.firstChild.nodeValue; 
    341354                                                } 
    342355                                                cc = cc.nextSibling; 
  • trunk/instant_messenger/js/templates.js

    r275 r287  
    55        this.documentMousedown = null; 
    66        this.jabber     = new Jabber; 
     7        this.dontFocus = false; 
    78} 
    89 
     
    7374                        document.getElementById('fast_menu_im').style.position = "absolute"; 
    7475                } 
    75                 else 
    76                         alert('Aguarde carregando lista de contatos ....'); 
    7776                                         
    7877        }, 
     
    123122         
    124123        "options_button_left" : function(pJid) 
    125         {   
     124        {        
    126125                var _this = this; 
    127                  
     126         
    128127                if(!(im.nickname_contacts[pJid])) 
    129128                        im.request_vcard(pJid, false); 
     
    133132                        im_window.load(pJid, 'instant_messenger_content', '<title>.:: Expresso Messenger ::.</title>', 'chat.xsl','310',true,true,true); 
    134133                 
    135                         func.byId(pJid + '__avatar').src = path_im + "/templates/default/images/photo.png"; 
    136134 
    137135                        if(func.byId('iframe_' + pJid) != null) 
     
    142140                        var iframe = document.createElement('iframe'); 
    143141                        iframe.id = 'iframe_' + pJid; 
    144                         iframe.style.width = '290px'; 
    145                         iframe.style.height = '46px'; 
     142                        iframe.style.width = '240px'; 
     143                        iframe.style.height = '65px'; 
    146144                        iframe.style.border = '0'; 
    147145                        iframe.style.margin = '0'; 
     
    153151                        iframe.contentWindow.document.write('<html><body id="' + pJid + '" style="margin:0px;padding:0px"></body></html>'); 
    154152                        iframe.contentWindow.document.close(); 
     153 
    155154                        iframe.contentWindow.document.designMode = "On"; 
    156155                        iframe.contentWindow.focus(); 
     156                        this.dontFocus = true; 
     157 
     158                        function getEnter(e) 
     159                        { 
     160                                if ( !(e.shiftKey) && (e.keyCode == 13) ) 
     161                                { 
     162                                        if ( e.type.indexOf('keydown') != -1 ) 
     163                                                im.SendMessage(pJid); 
     164                                        else 
     165                                                iframe.contentWindow.document.body.innerHTML = ''; 
     166                                        return false; 
     167                                } 
     168                        } 
     169                        func.attachEvent(iframe.contentWindow, 'onkeydown', getEnter); 
     170                        func.attachEvent(iframe.contentWindow, 'onkeyup', getEnter); 
    157171 
    158172                        im.ldap_photo(pJid + "__avatar"); 
  • trunk/instant_messenger/templates/default/css/chat.css

    r268 r287  
    113113.messages 
    114114{ 
    115         background: #fff; 
     115        background-color: #fff; 
     116        background-position:right !important; 
     117        background-repeat: no-repeat !important; 
     118        background-image: url(../images/photo.png); 
    116119        border: 1px solid; 
    117120        border-color: #b3b3b3 #cecece #cecece #b3b3b3; 
    118         width:  auto;   /*289px;*/  
    119         height: 46px;  
    120121        cursor: text; 
     122        height: 65px;  
     123        padding-right:50px; 
     124        width:  auto; 
    121125} 
    122126 
  • trunk/instant_messenger/webjabber/webjabber.c

    r268 r287  
    817817                bytes_rcvd_client = (int) NULL, 
    818818                bytes_sent_client = (int) NULL, 
    819                 i; 
    820  
    821         //syslog (LOG_INFO, "Reading(fd%d, fd%d)", in_fd, out_fd); 
     819                i, 
     820                do_auth = 0; 
    822821 
    823822        // @TODO: verificar alocacao buffer 
     
    828827        { 
    829828                bzero(buf_2_jabber, BUF_SIZE); 
    830                 if ( (bytes_rcvd_client = recv (client_fd, buf_2_jabber, BUF_SIZE, 0)) != 0 && strlen(buf_2_client) > 0 ) 
    831                 { 
    832                         // descomentar para ver oq esta passado de informacao 
    833                         //printf("(jabber/client[#%d])[%d]:\n{\n%s.......\n}\n", client_fd, strlen(buf_2_client), buf_2_client); 
     829                bytes_rcvd_client = recv (client_fd, buf_2_jabber, BUF_SIZE, 0); 
     830                if ( (bytes_rcvd_client != 0) && (strlen(buf_2_client) > 0) ) 
     831                { 
    834832                        for ( i = 0; i < bytes_rcvd_jabber; i += bytes_sent_client ) 
    835833                        { 
     
    840838                        } 
    841839                } 
     840                if ( strlen(buf_2_jabber) > 0 ) 
     841                { 
     842                        //printf("(client/jabber[#%d])[%d]:\n{\n%s.......\n}\n", jabber_fd, strlen(buf_2_jabber), buf_2_jabber); 
     843                        if ( strstr(buf_2_jabber, "<?xml") != NULL ) 
     844                                do_auth = 1; 
     845                } 
    842846 
    843847                bzero(buf_2_client, BUF_SIZE); 
    844                 if ( (bytes_rcvd_jabber = recv (jabber_fd, buf_2_client, BUF_SIZE, 0)) != 0 && strlen(buf_2_jabber) > 0 ) 
    845                 { 
    846                         // descomentar para ver oq esta passado de informacao 
    847                         //printf("(client/jabber[#%d])[%d]:\n{\n%s.......\n}\n", jabber_fd, strlen(buf_2_jabber), buf_2_jabber); 
     848                if ( do_auth || read->type == 1 ) 
     849                        bytes_rcvd_jabber = recv (jabber_fd, buf_2_client, BUF_SIZE, 0); 
     850                else 
     851                        bytes_rcvd_jabber = -1; 
     852                if ( (bytes_rcvd_jabber != 0) && (strlen(buf_2_jabber) > 0) ) 
     853                { 
    848854                        for ( i = 0; i < bytes_rcvd_client; i += bytes_sent_jabber ) 
    849855                        { 
     
    854860                        } 
    855861                } 
     862                if ( strlen(buf_2_client) > 0 ) 
     863                { 
     864                        //printf("(jabber/client[#%d])[%d]:\n{\n%s.......\n}\n", client_fd, strlen(buf_2_client), buf_2_client); 
     865                        if ( do_auth && strstr(buf_2_jabber, "<iq xmlns='jabber:client'") != NULL ) 
     866                                do_auth = 0; 
     867                } 
    856868 
    857869                usleep(500); 
    858                 //sleep(2); 
    859870        } 
    860871        while ( (bytes_rcvd_client != 0) && (bytes_rcvd_jabber != 0) ); 
  • trunk/instant_messenger/xsl/chat.xsl

    r268 r287  
    2525                        <div id="{name}__window_body_content" class="content"> 
    2626                                <div style="margin:3px 3px;"> 
    27                                         <div class="history"> 
    28                                         <div class="avatar" style="margin: 2px; position: absolute; right: 30px; top: 30px;"> 
    29                                                 <img id="{name}__avatar"/> 
    30                                         </div> 
    31                                         </div> 
     27                                        <div class="history"></div> 
    3228                                        <div class="toolbar_buttons"> 
    3329                                                <div id="{name}__button_bold" class="button_bold" onclick="javascript:im.conf_font('{name}','button_bold');"></div> 
     
    4036                                                <div id="{name}__button_dest"></div>                                             
    4137                                        </div> 
    42                                         <div class="messages"></div> 
     38                                        <div id="{name}__avatar" class="messages"></div> 
    4339                                </div> 
    4440                        </div> 
  • trunk/instant_messenger/xsl/disconnected.xsl

    r260 r287  
    55<xsl:template match="/disconnected"> 
    66        <div class="disconnected"> 
    7                 <img src="{path}templates/default/images/logo.png" align="bottom" style="margin:2px"/> 
    8                 <font style="font-weight:bold;margin:5px">Expresso Messenger</font> 
    9                 <br/> 
    10                 <br/> 
    11                 <font style="font-weight:bold;margin:5px"> Aviso : </font> 
    12                 <br/> 
    13                 <br/> 
    14                 <div style="margin:5px">  
    15                         Sua conexão com o  
     7                <div style="background:url('{path}templates/default/images/logo.png');width:32px;height:32px;margin:2px"></div> 
     8                <font style="font-weight:bold;margin:5px"><center>Aviso</center> </font> 
     9                <div style="margin:5px; font-size: 8pt; font-family: Arial, Verdana, helvetica, sans;"> 
     10                        Sua conexão com o Servidor parou. 
    1611                        <br/> 
    17                         Servidor parou. 
     12                        Tente novamente ou entre em   
    1813                        <br/> 
    19                         Tente novamente  
    20                         <br/> 
    21                         ou entre em contato 
    22                         <br/> 
    23                         com o Administrador. 
     14                        contato com o Administrador. 
    2415                </div> 
    2516                <br/> 
    26                 <br/> 
    27                 <img src="{path}templates/default/images/available.gif" /> 
    28                 <a href="javascript:disconnected = false; client();"><font style="font-size:7pt;margin:2px">Reconectar ...</font></a> 
     17                <div onclick="disconnected = false; client();" style="background:url('{path}templates/default/images/server_connect.png') no-repeat;padding-left:16px;height:16px;margin:3px;cursor:pointer"> 
     18                        <font style="font-size:7pt;margin:2px">Reconectar ...</font> 
     19                </div> 
    2920        </div> 
    3021</xsl:template> 
Note: See TracChangeset for help on using the changeset viewer.