Index: tags/instant_messenger/setup/phpgw_pt-br.lang
===================================================================
--- tags/instant_messenger/setup/phpgw_pt-br.lang (revision 318)
+++ tags/instant_messenger/setup/phpgw_pt-br.lang (revision 318)
@@ -0,0 +1,89 @@
+Add instant_messenger pt-br Adicionar
+Add Contatct instant_messenger pt-br Adicionar Contato
+add contact instant_messenger pt-br Adicionar Contato
+add new contact instant_messenger pt-br Adicionar Novo Contato
+add user instant_messenger pt-br Adicionar Usuário
+allow instant_messenger pt-br Adicionar
+Added information! instant_messenger pt-br Informações Adicionadas!
+Authorization instant_messenger pt-br Autorização
+available instant_messenger pt-br Disponível
+away instant_messenger pt-br Ausente
+Birthday instant_messenger pt-br Aniversário
+busy instant_messenger pt-br Ocupado
+change your Status instant_messenger pt-br Mude seu estado
+Choice Contact instant_messenger pt-br Escolha Contato
+Close instant_messenger pt-br Fechar
+Close this menu instant_messenger pt-br Fechar Menu
+Color instant_messenger pt-br Cor
+Contact instant_messenger pt-br Contato
+Contact Add instant_messenger pt-br Contato Adicionado
+Custom message... instant_messenger pt-br Mensagem ...
+Delete instant_messenger pt-br Remover
+Description instant_messenger pt-br Descrição
+dnd instant_messenger pt-br Não Perturbe
+deny instant_messenger pt-br Negar
+Error in the message! instant_messenger pt-br Erro na mensagem!
+E-mail instant_messenger pt-br E-mail
+Font instant_messenger pt-br Fonte
+Full Name instant_messenger pt-br Nome Completo
+Group instant_messenger pt-br Grupo
+instant_messenger common pt-br Mensageiro Instantâneo
+instant_messenger_t instant_messenger pt-br Mensageiro Instantâneo
+Information Contacts instant_messenger pt-br Informações do Contato
+Information instant_messenger pt-br Informações Adicionais
+Information User instant_messenger pt-br Informações Pessoais
+It requisition permission instant_messenger pt-br Requisitar Permissão
+Jid Contact instant_messenger pt-br Email Expresso
+List of Contacts instant_messenger pt-br Lista de Contatos
+Loading... instant_messenger pt-br Carregando...
+member of organization instant_messenger pt-br Usuários da Organização
+Maximize/Restore instant_messenger pt-br Maximizar/Restaurar Janela
+Minimize instant_messenger pt-br Minimizar Janela
+My Settings instant_messenger pt-br Minhas Configurações
+Name instant_messenger pt-br Nome
+Name Organization instant_messenger pt-br Nome Organização
+New Message! instant_messenger pt-br Nova Mensagem!
+Nick instant_messenger pt-br Apelido
+Nickname instant_messenger pt-br Apelido
+Not Auth instant_messenger pt-br Não Autorizado
+Organization Unit instant_messenger pt-br Selecione uma Organização
+Organization instant_messenger pt-br Organização
+online instant_messenger pt-br Online
+offline instant_messenger pt-br Offline
+Options instant_messenger pt-br Opções
+Photo instant_messenger pt-br Foto
+Problems in its register \n instant_messenger pt-br Problemas em seu registro
+Preferences instant_messenger pt-br Preferências
+Quick Contacts instant_messenger pt-br Contatos Rápidos
+Re-connect Expresso Messenger ? instant_messenger pt-br Reconectar Expresso Messenger ?
+Remove instant_messenger pt-br Remover
+Remove Contact instant_messenger pt-br Remover Contato
+Resize instant_messenger pt-br Redimensionar
+Role instant_messenger pt-br Função
+save instant_messenger pt-br Salvar
+says instant_messenger pt-br diz
+Sector instant_messenger pt-br Setor
+Search instant_messenger pt-br Pesquisar
+Search, add, or invite instant_messenger pt-br Procure, adicione ou convide
+See Info instant_messenger pt-br Ver Info
+Send instant_messenger pt-br Enviar
+Send File instant_messenger pt-br Enviar Arquivo
+Size instant_messenger pt-br Tamanho
+speak instant_messenger pt-br fala
+Successfully effected register! instant_messenger pt-br Registro efetuado com sucesso!
+Status instant_messenger pt-br Status
+Status of the Transference instant_messenger pt-br Status da Transferência
+Style instant_messenger pt-br Estilo
+Telephone instant_messenger pt-br Telefone
+to see preferences instant_messenger pt-br Ver Preferências
+To define user information instant_messenger pt-br Definir informações do usuário
+Update instant_messenger pt-br Atualizar
+Username instant_messenger pt-br Username
+unavailable instant_messenger pt-br Desconectado
+Vcard instant_messenger pt-br Vcard
+You desire to register in service IM? instant_messenger pt-br Você deseja registrar no serviço IM?
+your status instant_messenger pt-br Seu status
+Wait a moment !! pt-br instant_messenger Aguarde um momento !!
+waiting instant_messenger pt-br Aguardando
+without_group instant_messenger pt-br Sem Grupo
+Workgroup instant_messenger pt-br Setor
Index: tags/instant_messenger/setup/setup.inc.php
===================================================================
--- tags/instant_messenger/setup/setup.inc.php (revision 260)
+++ tags/instant_messenger/setup/setup.inc.php (revision 260)
@@ -0,0 +1,31 @@
+Coordenadores do Projeto : - Joao Alfredo Knopik Junior (jakjr@celepar.pr.gov.br) - Nilton Emilio Buhrer Neto (niltonneto@celepar.pr.gov.br) Desenvolvedores - Alexandre Correia (alexandrecorreia@celepar.pr.gov.br) - Rodrigo Souza Santos (rodsouza@celepar.pr.gov.br)';
+ $setup_info['instant_messenger']['maintainer'] = 'Os mesmos';
+ $setup_info['instant_messenger']['maintainer_email']= '';
+
+ $setup_info['instant_messenger']['license'] = 'GPL';
+ $setup_info['instant_messenger']['description'] = 'Módulo de IM com Jabber';
+
+ /* The hooks this app includes, needed for hooks registration */
+ $setup_info['instant_messenger']['hooks'][] = 'admin';
+
+ /* Dependencies for this app to work */
+ $setup_info['instant_messenger']['depends'][] = array(
+ 'appname' => 'phpgwapi',
+ 'versions' => Array('0.9.14','0.9.15','1.0.0')
+ );
+?>
Index: tags/instant_messenger/webjabber/webjabber.cfg
===================================================================
--- tags/instant_messenger/webjabber/webjabber.cfg (revision 262)
+++ tags/instant_messenger/webjabber/webjabber.cfg (revision 262)
@@ -0,0 +1,3 @@
+127.0.0.1
+10.15.20.202
+#Não tire esta linha#
Index: tags/instant_messenger/webjabber/webjabber.c
===================================================================
--- tags/instant_messenger/webjabber/webjabber.c (revision 305)
+++ tags/instant_messenger/webjabber/webjabber.c (revision 305)
@@ -0,0 +1,1202 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+/*
+#include
+#include
+#include
+*/
+#include
+
+// Buffer size, in bytes, used for copying in the Cat() function.
+const size_t BUF_SIZE = 4096;
+
+// Typedef for a signal handler function.
+typedef void (*signal_handler_t) (int);
+
+// Global variables
+char g_program_name[100]; // Initialised from argv[0] in ParseArgs()
+struct allowed_ip * allowed_ips = (struct allowed_ip *)NULL;
+int quantity_of_fd = 0; // quantity of file descriptor
+
+static struct connections * connections = (struct connections *)NULL;
+pthread_mutex_t mutexsum;
+
+// structs
+struct allowed_ip
+{
+ char * ip;
+ struct allowed_ip * next;
+};
+
+struct accept
+{
+ int * fd;
+ struct sockaddr_in sa;
+ struct in_addr jabber_addr;
+ unsigned short jabber_port;
+ pthread_t accept_thread;
+};
+
+struct client
+{
+ char * user,
+ * pass;
+ int * jabber_fd,
+ * read_fd;
+ time_t last_access;
+};
+
+struct connections
+{
+ struct client * client;
+ struct connections * next;
+};
+
+struct read_write
+{
+ int * jabber,
+ client,
+ type;
+ pthread_t read,
+ write;
+};
+
+void recursive (int, struct in_addr, unsigned short);
+int getPermission(char *);
+void ParseArgs (int, char **, struct in_addr *, unsigned short *, struct in_addr *, unsigned short *);
+void Initialise (void);
+void sig_child (int);
+int CreateServerSocket (struct in_addr, unsigned short);
+void Daemonise (void);
+void MainLoop (int, struct in_addr, unsigned short);
+void ClearList(void);
+struct accept * AcceptClientConnection (int);
+void VerifyClient(void *);
+struct client * Handshake (struct accept *, struct read_write *);
+void * withConnections(void * (*func)(), ...);
+//struct client * LookFor (char *, char *);
+//void * LookFor (struct connections *, char *, char *);
+void * LookFor (char *, char *);
+void Reading (void *);
+void Writing (void *);
+int ConnectToServer (struct in_addr, unsigned short);
+int NameToAddr (const char *, struct in_addr *);
+int NameToPort (const char *, unsigned short *, const char *);
+#ifdef __GNUC__
+ void quit (const char *, ...) __attribute__ ((format (printf, 1, 2)));
+ void pbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
+ void hbomb (const char *, ...) __attribute__ ((format (printf, 1, 2)));
+#else
+ void quit (const char *, ...);
+ void pbomb (const char *, ...);
+ void hbomb (const char *, ...);
+#endif
+void set_signal_handler (int, signal_handler_t);
+
+int main (int argc, char ** argv)
+{
+ struct in_addr remote_addr,
+ local_addr;
+ unsigned short remote_port,
+ local_port;
+ int listen_fd;
+
+ //pthread_t clear_list_thread;
+
+ ParseArgs (argc, argv, &remote_addr, &remote_port, &local_addr, &local_port);
+
+ Initialise ();
+
+ // Create server socket before becoming a daemon so
+ // there is still a chance to print an error message.
+ listen_fd = CreateServerSocket (local_addr, local_port);
+ if ( listen_fd < 0 )
+ pbomb ("Unable to create server socket");
+
+ //Daemonise ();
+
+ //pthread_mutex_init(&mutexsum, NULL);
+ //pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
+
+ //MainLoop (listen_fd, remote_addr, remote_port); // never returns
+ recursive(listen_fd, remote_addr, remote_port);
+
+ //pthread_mutex_destroy(&mutexsum);
+
+ exit (EXIT_SUCCESS);
+}
+
+void recursive (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
+{
+ //while ( 1 )
+ // sleep(1);
+ //exit(0);
+
+ pid_t helper_pid;
+
+ syslog (LOG_INFO, "recursive()");
+
+ signal (SIGCHLD, SIG_IGN);
+
+ helper_pid = fork ();
+ if ( helper_pid == -1 )
+ syslog (LOG_ERR, "fork() on recursive(): %m"), exit (EXIT_FAILURE);
+
+ if ( helper_pid ) /* parent */
+ {
+ //syslog (LOG_INFO, "Forked child pid %d to help with MainLoop", helper_pid);
+ wait(0); /* wait for helper to exit */
+ }
+ else /* child (helper) */
+ {
+ MainLoop (listen_fd, rem_addr, rem_port);
+
+ syslog (LOG_INFO, "exiting");
+ exit (0); /* helper exits here */
+ }
+ recursive(listen_fd, rem_addr, rem_port);
+}
+
+// ParseArgs()
+// Parse the command line arguments to extract the remote
+// and local adresses and port numbers, ra, rp, la & lp.
+// Exit the program gracefully upon error.
+void ParseArgs (int argc, char ** argv, struct in_addr * ra, unsigned short * rp, struct in_addr * la, unsigned short * lp)
+{
+ // argv[0] = program name
+ // argv[1] = remote_addr
+ // argv[2] = remote_port
+ // argv[3] = local_addr (optional)
+ // argv[4] = local_port (optional)
+
+ char * p = strrchr (argv[0], '/');
+
+ strncpy (g_program_name, (p == NULL) ? argv[0] : p + 1, sizeof (g_program_name) - 1);
+
+ if ( (argc < 3) || (argc > 5) )
+ {
+ fprintf (stderr, "usage: %s remote_addr remote_port [local_addr] [local_port]\n", argv[0]);
+ exit (EXIT_FAILURE);
+ }
+
+ if ( NameToAddr (argv[1], ra) )
+ hbomb ("Unable to resolve \"%s\" to an ip address", argv[1]);
+
+ if ( NameToPort (argv[2], rp, "tcp") )
+ quit ("Unable to resolve \"%s\" to a port number", argv[2]);
+
+ if ( argc < 4 )
+ la->s_addr = htonl (INADDR_ANY);
+ else
+ if ( NameToAddr (argv[3], la) )
+ hbomb ("Unable to resolve \"%s\" to an ip address", argv[3]);
+
+ if ( argc < 5 )
+ memcpy (lp, rp, sizeof (*lp));
+ else
+ if ( NameToPort (argv[4], lp, "tcp") )
+ quit ("Unable to resolve \"%s\" to a port number", argv[4]);
+}
+
+int getPermission(char * ip)
+{
+ struct allowed_ip * allow_ip = allowed_ips;
+ int allow = 0;
+
+ while ( !allow && allow_ip != (struct allowed_ip *)NULL )
+ {
+ //printf("strcmp(%s, %s)\n\n", ip, allow_ip->ip);
+ if ( strcmp(ip, allow_ip->ip) == 0 )
+ allow = 1;
+ else
+ allow_ip = allow_ip->next;
+ }
+
+ return allow;
+}
+
+// Initialise()
+// Setup syslog, signal handlers, and other intialisation.
+void Initialise (void)
+{
+ FILE * allowed_ips_fd;
+ struct allowed_ip * allow_ip;
+
+ if ( !(allowed_ips_fd = fopen("webjabber.cfg", "r")) )
+ syslog (LOG_ERR, "Impossivel abrir o arquivo 'webjabber.cfg'"), exit (EXIT_FAILURE);
+
+ while ( !feof(allowed_ips_fd) )
+ {
+ char * line = (char *) malloc(16 * sizeof(char));
+
+ bzero(line, 16);
+ fgets(line, 16, allowed_ips_fd);
+
+ if ( strlen(line) )
+ {
+ if ( line[strlen(line) - 1] == '\n' )
+ line[strlen(line) - 1] = '\0';
+
+ if ( allowed_ips == (struct allowed_ip *)NULL )
+ allow_ip = allowed_ips = (struct allowed_ip *) malloc(sizeof(struct allowed_ip));
+ else
+ {
+ allow_ip = allowed_ips;
+ while ( allow_ip->next != (struct allowed_ip *)NULL )
+ allow_ip = allow_ip->next;
+ allow_ip->next = (struct allowed_ip *) malloc(sizeof(struct allowed_ip));
+ allow_ip = allow_ip->next;
+ }
+ allow_ip->next = (struct allowed_ip *)NULL;
+ allow_ip->ip = line;
+ }
+ }
+
+ char * initial_path = (char *) malloc(128 * sizeof(char));
+ getcwd(initial_path, 128);
+
+ openlog (g_program_name, LOG_PID, LOG_USER);
+ syslog (LOG_INFO, "%s started in path [#%d] %s", g_program_name, strlen(initial_path), initial_path);
+
+ chdir ("/"); // Change working directory to the root.
+
+ umask (0); // Clear our file mode creation mask
+
+ set_signal_handler (SIGCHLD, sig_child);
+
+ signal (SIGPIPE, SIG_IGN);
+}
+
+// sig_child(): Handles SIGCHLD from exiting child processes.
+void sig_child (int signo)
+{
+ pid_t pid;
+
+ (void) signo; // suppress compiler warning
+
+ for ( ; ; )
+ {
+ pid = waitpid (WAIT_ANY, NULL, WNOHANG);
+
+ if (pid > 0)
+ syslog (LOG_INFO, "Caught SIGCHLD from pid %d", pid);
+ else
+ break;
+ }
+
+ if ((pid < 0) && (errno != ECHILD))
+ syslog (LOG_ERR, "waitpid(): %m"), exit (EXIT_FAILURE);
+
+ return;
+}
+
+// CreateServerSocket()
+// Create a socket, bind it to the specified address
+// and port, and set it to listen for client connections.
+// Returns < 0 on failure to bind, bombs on error otherwise,
+// returns the fd of the new socket on success.
+int CreateServerSocket (struct in_addr addr, unsigned short port)
+{
+ int err,
+ fd;
+ const int on = 1;
+ struct sockaddr_in sa;
+
+ // Create a socket and get its descriptor.
+ fd = socket (AF_INET, SOCK_STREAM, 0);
+ if ( fd < 0 )
+ syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
+
+ // Set SO_REUSEADDR socket option
+ if ( setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
+ syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", fd);
+
+ // Load a sa structure with the specified address and port
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons (port);
+ //sa.sin_addr = addr;
+ sa.sin_addr.s_addr = htonl(INADDR_ANY);
+ memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
+
+ // Bind our socket to the address and port specified
+ err = bind (fd, (struct sockaddr *) &sa, sizeof (sa));
+ if ( err < 0 )
+ {
+ syslog (LOG_ERR, "bind(): %m");
+ return err;
+ }
+
+ // Tell socket to listen and queue up to 5 incoming connections.
+ if ( listen (fd, 5) < 0 )
+ syslog (LOG_ERR, "listen(): %m"), exit (EXIT_FAILURE);
+
+ return fd;
+}
+
+// Daemonise(): Put the program in the background, set PPID=1, create a new
+// session and process group, without a controlling tty.
+void Daemonise (void)
+{
+ pid_t pid;
+
+ /* Close stdin, stdout & stderr */
+ /* TODO: open /dev/null and dup the fd to stdin, stdout & stderr
+ * close(STDIN_FILENO);
+ * close(STDOUT_FILENO);
+ * close(STDERR_FILENO);
+ * */
+
+ syslog (LOG_INFO, "%s daemonising", g_program_name);
+
+ /* Fork the process to put it in the background. */
+
+ pid = fork ();
+ if (pid == -1)
+ syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
+
+ /* parent terminates here, so shell thinks the command is done. */
+ if (pid)
+ exit (0);
+
+ syslog (LOG_INFO, "%s in background", g_program_name);
+
+ /* 1st child continues to run in the background with PPID=1 */
+
+ /* Become leader of a new session and a new process group,
+ * with no controlling tty. */
+ setsid ();
+
+ /* Fork again to guarantee the process will not be able to aquire a
+ * controlling tty. */
+
+ /*signal (SIGHUP, SIG_IGN); *//* required according to Stevens' UNP2 p333 */
+
+ pid = fork ();
+ if (pid == -1)
+ syslog (LOG_ERR, "fork(): %m"), exit (EXIT_FAILURE);
+
+ if (pid) /* 1st child terminates */
+ exit (0);
+
+ /* 2nd child continues, no longer a session or group leader */
+
+ syslog (LOG_INFO, "%s daemonised", g_program_name);
+}
+
+// MainLoop()
+// Classic concurrent server model.
+// Wait for a client to connect, fork a child process
+// to do the business with the client, parent process
+// continues to wait for the next connection.
+// This function does not return.
+void MainLoop (int listen_fd, struct in_addr rem_addr, unsigned short rem_port)
+{
+ //pid_t helper_pid;
+ pthread_t clear_list_thread;
+
+ syslog (LOG_INFO, "MainLoop :: listen_fd(fd%d)", listen_fd);
+ //signal (SIGCHLD, SIG_IGN);
+
+ pthread_mutex_init(&mutexsum, NULL);
+ pthread_create(&clear_list_thread, NULL, (void *) &ClearList, (void *)NULL );
+ while ( quantity_of_fd < 50 )
+ {
+ struct accept * client;
+
+ syslog (LOG_INFO, "[timestamp = %d] quantity_of_fd = %d", time(NULL), quantity_of_fd);
+
+ client = AcceptClientConnection (listen_fd);
+ client->jabber_addr = rem_addr;
+ client->jabber_port = rem_port;
+
+ pthread_create(&client->accept_thread, NULL, (void *) &VerifyClient, (void *) client);
+ }
+ pthread_mutex_destroy(&mutexsum);
+}
+
+void ClearList(void)
+{
+ for ( ; ; )
+ {
+ pthread_mutex_lock(&mutexsum);
+ struct connections * connection = connections;
+ while ( connection != (struct connections *)NULL )
+ {
+ if ( *(connection->client->jabber_fd) != (int)NULL && time(NULL) - connection->client->last_access > 70 )
+ {
+ shutdown(*(connection->client->jabber_fd), SHUT_RDWR);
+ close(*(connection->client->jabber_fd));
+ *(connection->client->jabber_fd) = (int)NULL;
+ }
+ connection = connection->next;
+ }
+ pthread_mutex_unlock(&mutexsum);
+ sleep(5);
+ }
+}
+
+// AcceptClientConnection()
+// waits for a tcp connect to the socket listen_fd, which
+// must already be bound and set to listen on a local port.
+// Bombs on error, returns the fd of the new socket on success.
+//int AcceptClientConnection (int listen_fd)
+struct accept * AcceptClientConnection (int listen_fd)
+{
+ int * newfd = (int *) malloc(sizeof(int));
+ if ( newfd == NULL )
+ {
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+ }
+
+ struct sockaddr_in sa;
+ socklen_t socklen;
+
+ syslog (LOG_INFO, "AcceptClientConnection(fd%d)", listen_fd);
+
+ // Accept the connection and create a new socket for it.
+ socklen = sizeof (sa);
+ memset (&sa, 0, socklen);
+ do
+ {
+ *(newfd) = accept (listen_fd, (struct sockaddr *) &sa, &socklen);
+ }
+ while ( (*(newfd) < 0) && (errno == EINTR) );
+
+ syslog (LOG_INFO, "Accepted client connection on new socket fd%d", *(newfd));
+
+ if ( *(newfd) < 0 )
+ syslog (LOG_ERR, "accept(): %m"), exit (EXIT_FAILURE);
+
+ if ( socklen != sizeof (sa) )
+ syslog (LOG_ERR, "accept() screwed up!"), exit (EXIT_FAILURE);
+
+ quantity_of_fd++;
+
+ const int on = 1;
+ if ( setsockopt (*(newfd), SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
+ syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR): %m", *(newfd));
+
+ struct accept * accepted = (struct accept *) malloc(sizeof(struct accept));
+ if ( accepted == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ accepted->fd = newfd;
+ accepted->sa = sa;
+
+ return (accepted);
+}
+
+void VerifyClient(void * accepted)
+{
+ //puts("\n\n:::::::::::::::: VERIFYCLIENT :::::::::::::::::::::\n");
+ unsigned int addr = 0;
+ char ip[250];
+ int * jabber_fd = (int *)NULL;
+ const int on = 1;
+
+ struct accept * accept = (struct accept *) accepted;
+ struct client * client = (struct client *)NULL;
+ struct read_write * read_write = (struct read_write *) malloc(sizeof(struct read_write));
+ if ( read_write == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ read_write->type = 0;
+
+ // ip from client
+ addr = ntohl(accept->sa.sin_addr.s_addr);
+ sprintf(ip, "%d.%d.%d.%d",
+ (addr >> 24), (addr >> 16) & 0xFF,
+ (addr >> 8) & 0xFF, addr & 0xFF);
+ //printf("\nNew connection [#%d]: %s\n", *(accept->fd), ip);
+
+ if ( getPermission(ip) )
+ if ( (client = Handshake(accept, read_write)) == (struct client *)NULL )
+ {
+ close(*(accept->fd));
+ pthread_kill(accept->accept_thread, 0);
+ }
+ else
+ {
+ jabber_fd = client->jabber_fd;
+ }
+ else
+ {
+ jabber_fd = (int *) malloc(sizeof(int));
+ if ( jabber_fd == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ *(jabber_fd) = (int)NULL;
+ }
+
+ //puts("\n\n:::::::::::::::: JABBER IN VERIFYCLIENT #1 :::::::::::::::::::::\n");
+ if ( *(jabber_fd) == (int)NULL )
+ *(jabber_fd) = ConnectToServer(accept->jabber_addr, accept->jabber_port);
+ //puts("\n\n:::::::::::::::: JABBER IN VERIFYCLIENT #2 :::::::::::::::::::::\n");
+
+ // Set SO_REUSEADDR socket option
+ //if ( setsockopt (*(jabber_fd), SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 )
+ // syslog (LOG_ERR, "setsockopt(fd%d, SO_REUSEADDR) #2: %m", *(jabber_fd));
+
+ //if ( client != (struct client *)NULL )
+ // client->jabber_fd = jabber_fd;
+
+ read_write->jabber = jabber_fd;
+ read_write->client = *(accept->fd);
+ //pthread_t cat_thread;
+ //fcntl(read_write->client, F_SETFL, fcntl(read_write->client, F_GETFL, 0) | O_NDELAY);
+
+ //puts("\n\n:::::::::::::::: THREADS :::::::::::::::::::::\n");
+ //pthread_create(&read_write->write, NULL, (void *) &Writing, (void *)read_write );
+ pthread_create(&read_write->read, NULL, (void *) &Reading, (void *)read_write );
+
+ //pthread_exit(0);
+ pthread_kill(accept->accept_thread, 0);
+}
+
+struct client * Handshake(struct accept * accept, struct read_write * read_write)
+{
+ //puts("\n\n:::::::::::::::: HANDSHAKE :::::::::::::::::::::\n");
+ struct client * client = (struct client *)NULL;
+ unsigned char * const buf = (char *) malloc (sizeof(char) * 5);
+ if ( buf == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ char * str = (char *) malloc(128 * sizeof(char)),
+ * user = (char *)NULL,
+ * pass = (char *)NULL,
+ * pass_pos = (char *)NULL,
+ * type = (char *)NULL,
+ * type_pos = (char *)NULL;
+ if ( str == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ int bytes_rcvd,
+ bytes_sent,
+ i;
+
+ bzero(str, 128);
+
+ if ( (bytes_rcvd = recv (*(accept->fd), str, 128, 0)) < 1 )
+ {
+ //puts("error :: str");
+ close(*(accept->fd));
+ return client;
+ }
+
+ pass_pos = strstr(str, "##") + 2;
+ i = strlen(str) - strlen(pass_pos) - 1;
+ user = (char *) malloc(i * sizeof(char));
+ if ( user == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ bzero(user, i);
+ strncpy(user, str, i - 1);
+
+ type_pos = strstr(pass_pos, "##") + 2;
+ i = strlen(pass_pos) - strlen(type_pos) - 1;
+ pass = (char *) malloc(i * sizeof(char));
+ if ( pass == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ bzero(pass, i);
+ strncpy(pass, pass_pos, i - 1);
+
+ i = strlen(type_pos) + 1;
+ type = (char *) malloc(i * sizeof(char));
+ if ( type == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ bzero(type, i);
+ strcpy(type, type_pos);
+
+ printf(" str[%2d]: %s\n", strlen(str), str);
+ printf("user[%2d]: %s\n", strlen(user), user);
+ printf("pass[%2d]: %s\n", strlen(pass), pass);
+ printf("type[%2d]: %s\n", strlen(type), type);
+ printf(" fd[%2d]: client\n", *(accept->fd));
+
+ //if ( (client = LookFor (user, pass)) != (struct client *)NULL )
+ if ( (client = (struct client *) withConnections(LookFor, user, pass)) != (struct client *)NULL )
+ {
+ //puts("\n\n:::::::::::::::: INFO #0 :::::::::::::::::::::\n");
+ bzero(buf, 5);
+
+ //if ( *(client->read_fd) != (int)NULL )
+ //{
+ // shutdown(*(client->read_fd), SHUT_RDWR);
+ // close(*(client->read_fd));
+ //}
+ //*(client->read_fd) = *(accept->fd);
+
+ //puts("\n\n:::::::::::::::: INFO #1 :::::::::::::::::::::\n");
+ if ( *(client->jabber_fd) == (int)NULL )
+ {
+ //puts("\n\n:::::::::::::::: JABBER IN HANDSHAKE #1 :::::::::::::::::::::\n");
+ *(client->jabber_fd) = ConnectToServer(accept->jabber_addr, accept->jabber_port);
+ sprintf(buf, "new ");
+ //puts("\n\n:::::::::::::::: JABBER IN HANDSHAKE #2 :::::::::::::::::::::\n");
+ }
+ else
+ sprintf(buf, "rec ");
+
+ //puts("\n\n:::::::::::::::: INFO #2 :::::::::::::::::::::\n");
+
+ //printf("connection: %s\n\n\n", buf);
+ for ( i = 0; i < sizeof(buf); i += bytes_sent )
+ {
+ bytes_sent = send (*(accept->fd), buf + i, sizeof(buf) - i, 0);
+
+ if ( bytes_sent < 0 )
+ break;
+ }
+
+ //puts("\n\n:::::::::::::::: INFO #3 :::::::::::::::::::::\n");
+
+ if ( strcmp(type, "read") == 0 )
+ read_write->type = 1;
+ else
+ if ( strcmp(type, "write") == 0 )
+ read_write->type = 2;
+ //puts("\n\n:::::::::::::::: INFO #4 :::::::::::::::::::::\n");
+
+ }
+ //free(str);
+ free(buf);
+
+ return client;
+}
+
+void * withConnections(void * (*func)(), ...)
+{
+ //static struct connections * connections = (struct connections *)NULL;
+ if ( (*func) == LookFor )
+ {
+ va_list ap;
+ char * user,
+ * pass;
+ void * _return;
+
+ va_start(ap, (*func));
+ user = va_arg(ap, char *);
+ pass = va_arg(ap, char *);
+ va_end(ap);
+
+ pthread_mutex_lock(&mutexsum);
+ _return = (*func)(user, pass);
+ pthread_mutex_unlock(&mutexsum);
+ return _return;
+ }
+ else
+ {
+ }
+}
+
+//struct client * LookFor (char * user, char * pass)
+//void * LookFor (struct connections * connections, char * user, char * pass)
+void * LookFor (char * user, char * pass)
+{
+ //puts("\n\n:::::::::::::::: LOOKFOR :::::::::::::::::::::\n");
+ //static struct connections * connections = (struct connections *)NULL;
+
+ //pthread_mutex_lock(&mutexsum);
+ if ( connections == (struct connections *)NULL )
+ {
+ //puts("\n\n:::::::::::::::: FIRST CONNECTION :::::::::::::::::::::\n");
+ connections = (struct connections *) malloc(sizeof(struct connections));
+ if ( connections == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ connections->client = (struct client *) malloc(sizeof(struct client));
+ if ( connections->client == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ connections->client->user = user;
+ connections->client->pass = pass;
+
+ connections->client->read_fd = (int *) malloc(sizeof(int));
+ if ( connections->client->read_fd == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ connections->client->jabber_fd = (int *) malloc(sizeof(int));
+ if ( connections->client->jabber_fd == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ *(connections->client->read_fd) = (int)NULL;
+ *(connections->client->jabber_fd) = (int)NULL;
+
+ connections->client->last_access = time(NULL);
+
+ connections->next = (struct connections *)NULL;
+
+ //pthread_mutex_unlock(&mutexsum);
+ return connections->client;
+ }
+ else
+ {
+ //puts("\n\n:::::::::::::::: HAS CONNECTION :::::::::::::::::::::\n");
+ struct connections * connection = connections,
+ * last;
+ while ( connection != (struct connections *)NULL )
+ {
+ //puts(":::::::::::::::: PROCURANDO :::::::::::::::::::::");
+ if ( strcmp(connection->client->user, user) == 0 )
+ if ( strcmp(connection->client->pass, pass) == 0 )
+ {
+ //pthread_mutex_unlock(&mutexsum);
+ //puts(":::::::::::::::: ACHOU #1 :::::::::::::::::::::");
+ connection->client->last_access = time(NULL);
+ return connection->client;
+ }
+ else
+ {
+ //pthread_mutex_unlock(&mutexsum);
+ //puts(":::::::::::::::: ACHOU #2 :::::::::::::::::::::");
+ return (struct client *)NULL;
+ }
+ last = connection;
+ connection = connection->next;
+ }
+ //puts(":::::::::::::::: ACHOU #3 :::::::::::::::::::::");
+
+ last->next = (struct connections *) malloc(sizeof(struct connections));
+ if ( last->next == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ connection = last->next;
+
+ connection->client = (struct client *) malloc(sizeof(struct client));
+ if ( connection->client == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ connection->client->user = user;
+ connection->client->pass = pass;
+ connection->client->jabber_fd = (int *) malloc(sizeof(int));
+ if ( connection->client->jabber_fd == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ *(connection->client->jabber_fd) = (int)NULL;
+ connection->client->last_access = time(NULL);
+
+ connection->next = (struct connections *)NULL;
+ //pthread_mutex_unlock(&mutexsum);
+ return connection->client;
+ }
+}
+
+void Reading (void * read_write)
+{
+ unsigned char * const buf_2_jabber = (char *) malloc (sizeof(char) * BUF_SIZE);
+ unsigned char * const buf_2_client = (char *) malloc (sizeof(char) * BUF_SIZE);
+ bzero(buf_2_jabber, BUF_SIZE);
+ bzero(buf_2_client, BUF_SIZE);
+
+ if ( buf_2_jabber == NULL || buf_2_client == NULL )
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ struct read_write * read = (struct read_write *) read_write;
+
+ int jabber_fd = *(read->jabber),
+ client_fd = read->client;
+
+ fcntl(jabber_fd, F_SETFL, fcntl(jabber_fd, F_GETFL, 0) | O_NDELAY);
+ fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NDELAY);
+
+ int bytes_rcvd_jabber = (int) NULL,
+ bytes_sent_jabber = (int) NULL,
+ bytes_rcvd_client = (int) NULL,
+ bytes_sent_client = (int) NULL,
+ i,
+ do_auth = 0;
+
+ // @TODO: verificar alocacao buffer
+ //if ( buf == NULL )
+ // syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ do
+ {
+ bzero(buf_2_jabber, BUF_SIZE);
+ bytes_rcvd_client = recv (client_fd, buf_2_jabber, BUF_SIZE, 0);
+ if ( (bytes_rcvd_client != 0) && (strlen(buf_2_client) > 0) )
+ {
+ for ( i = 0; i < bytes_rcvd_jabber; i += bytes_sent_client )
+ {
+ bytes_sent_client = send (client_fd, buf_2_client + i, bytes_rcvd_jabber - i, 0);
+
+ if ( bytes_sent_client < 0 )
+ break;
+ }
+ }
+ if ( strlen(buf_2_jabber) > 0 )
+ {
+ printf("(client/jabber[#%d])[%d]:\n{\n%s.......\n}\n", jabber_fd, strlen(buf_2_jabber), buf_2_jabber);
+ if ( strstr(buf_2_jabber, "type == 1 )
+ bytes_rcvd_jabber = recv (jabber_fd, buf_2_client, BUF_SIZE, 0);
+ else
+ bytes_rcvd_jabber = -1;
+ if ( (bytes_rcvd_jabber != 0) && (strlen(buf_2_jabber) > 0) )
+ {
+ for ( i = 0; i < bytes_rcvd_client; i += bytes_sent_jabber )
+ {
+ bytes_sent_jabber = send (jabber_fd, buf_2_jabber + i, bytes_rcvd_client - i, 0);
+
+ if ( bytes_sent_jabber < 0 )
+ break;
+ }
+ }
+ if ( strlen(buf_2_client) > 0 )
+ {
+ if ( do_auth && strstr(buf_2_jabber, "client, SHUT_RDWR);
+ close (read->client);
+}
+
+/*
+void Reading (void * read_write)
+{
+ struct read_write * read = (struct read_write *) read_write;
+
+ //printf("read->type: %d\n\n\n", read->type);
+ if ( !read->type || read->type == 1 )
+ {
+ unsigned char * const buf = (char *) malloc (sizeof(char) * BUF_SIZE);
+ if ( buf == NULL )
+ {
+ puts("\n\nmalloc() : buf #2\n\n\n");
+ exit (EXIT_FAILURE);
+ }
+ int bytes_rcvd,
+ bytes_sent = (int) NULL,
+ i;
+
+ int in_fd = *(read->jabber),
+ out_fd = read->client;
+
+ //syslog (LOG_INFO, "Reading(fd%d, fd%d)", in_fd, out_fd);
+
+ // @TODO: verificar alocacao buffer
+ //if ( buf == NULL )
+ // syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ do
+ {
+ //puts("\n\n:::::::::::::::: DO - READ :::::::::::::::::::::\n");
+ bzero(buf, BUF_SIZE);
+ bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
+
+ if ( strlen(buf) > 0 )
+ {
+ // descomentar para ver oq esta passado de informacao
+ printf("Reading(#%d/jabber,#%d/client)[%d]:\n{\n%s.......\n}\n", in_fd, out_fd, strlen(buf), buf);
+
+ for ( i = 0; i < bytes_rcvd && *(read->jabber) != (int)NULL; i += bytes_sent )
+ {
+ bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
+
+ if ( bytes_sent < 0 )
+ break;
+ }
+ }
+ }
+ while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
+
+ printf("\n[Reading] FINALIZANDO TREAD CLIENTE COM FD #%d\n\n", out_fd);
+ pthread_cancel(read->write);
+
+ //if ( bytes_rcvd < 1 )
+ // *(read->jabber) = (int)NULL;
+
+ printf("\n\nFIM Reading [#%d#%d]\nbytes_rcvd = %d : bytes_sent = %d\n\n\n", in_fd, out_fd, bytes_rcvd, bytes_sent);
+
+ free (buf);
+ }
+ else
+ while ( 1 ) usleep(500);
+
+ //pthread_kill(read->write, 0);
+
+ shutdown(read->client, SHUT_RDWR);
+ close (read->client);
+ //pthread_exit(0);
+}
+*/
+
+void Writing (void * read_write)
+{
+ struct read_write * write = (struct read_write *) read_write;
+
+ //printf("write->type: %d\n\n\n", write->type);
+ //if ( !write->type || write->type == 2 )
+ //{
+ unsigned char * const buf = (char *) malloc (sizeof(char) * (BUF_SIZE + 1));
+ if ( buf == NULL )
+ {
+ syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+ }
+ int bytes_rcvd,
+ bytes_sent = (int) NULL,
+ i;
+
+ int in_fd = write->client,
+ out_fd = *(write->jabber);
+
+ //syslog (LOG_INFO, "Writing(fd%d, fd%d)", in_fd, out_fd);
+
+ // @TODO: verificar alocacao buffer
+ //if ( buf == NULL )
+ // syslog (LOG_ERR, "malloc(): %m"), exit (EXIT_FAILURE);
+
+ do
+ {
+ //puts("\n\n:::::::::::::::: DO - WRITE :::::::::::::::::::::");
+ bzero(buf, BUF_SIZE + 1);
+ //puts(":::::::::::::::: WRITE - RECV :::::::::::::::::::::");
+ bytes_rcvd = recv (in_fd, buf, BUF_SIZE, 0);
+
+ //puts(":::::::::::::::: WRITE - IF #1 :::::::::::::::::::::");
+ if ( strlen(buf) > 0 )
+ {
+ // descomentar para ver oq esta passado de informacao
+ //printf("Writing(#%d/client,#%d/jabber)[%d]:\n{\n%s.......\n}\n", in_fd, out_fd, strlen(buf), buf);
+
+ for ( i = 0; i < bytes_rcvd && *(write->jabber) != (int)NULL; i += bytes_sent )
+ {
+ bytes_sent = send (out_fd, buf + i, bytes_rcvd - i, 0);
+
+ if ( bytes_sent < 0 )
+ break;
+ }
+ }
+ //puts(":::::::::::::::: WRITE - IF #2 :::::::::::::::::::::\n");
+ }
+ while ( (bytes_rcvd > 0) && (bytes_sent > 0) );
+
+ //printf("\n[Writing] FINALIZANDO TREAD CLIENTE COM FD #%d\n\n", in_fd);
+ pthread_cancel(write->read);
+
+ //if ( bytes_sent < 1 )
+ // *(write->jabber) = (int)NULL;
+
+ //printf("\n\nFIM Writing [#%d#%d]\nbytes_rcvd = %d : bytes_sent = %d\n\n\n", in_fd, out_fd, bytes_rcvd, bytes_sent);
+
+ free (buf);
+ //}
+ //else
+ // while ( 1 ) usleep(500);
+
+ //pthread_kill(write->read, 0);
+
+ shutdown(write->client, SHUT_RDWR);
+ close (write->client);
+ //pthread_exit(0);
+}
+
+// ConnectToServer()
+// attempts a tcp connect to the server specified
+// by addr and port. Bombs on failure to connect,
+// returns the fd of the new socket on success.
+int ConnectToServer (struct in_addr addr, unsigned short port)
+{
+ // TODO: have a timeout for connect() - see Unix socket FAQ 6.2
+
+ int fd, err;
+ struct sockaddr_in sa;
+
+ // Create a socket and get its descriptor.
+ fd = socket (AF_INET, SOCK_STREAM, 0);
+
+ if ( fd < 0 )
+ syslog (LOG_ERR, "socket(): %m"), exit (EXIT_FAILURE);
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons (port);
+ sa.sin_addr = addr;
+ memset (sa.sin_zero, 0, sizeof (sa.sin_zero));
+
+ err = connect (fd, (struct sockaddr *) &sa, sizeof (sa));
+ if (err < 0)
+ {
+ syslog (LOG_ERR, "Unable to connect socket fd%d to server: %m", fd);
+ exit (EXIT_FAILURE);
+ }
+
+ quantity_of_fd++;
+ syslog (LOG_INFO, "Connected socket fd%d to server", fd);
+
+ return fd;
+}
+
+// NameToAddress()
+// Convert name to an ip address.
+// Returns 0 on success, -1 on failure.
+int NameToAddr (const char * name, struct in_addr * p_inaddr)
+{
+ struct hostent * he;
+
+ // First, attempt to convert from string ip format
+ // TODO: use inet_aton() instead
+ p_inaddr->s_addr = inet_addr (name);
+ if ( p_inaddr->s_addr != -1U ) // Success
+ return 0;
+
+ // Next, attempt to read from /etc/hosts or do a DNS lookup
+ he = gethostbyname (name);
+ if ( he != NULL ) // Success
+ {
+ memcpy (p_inaddr, he->h_addr, sizeof (struct in_addr));
+ return 0;
+ }
+
+ return -1; // Failed to resolve name to an ip address
+}
+
+// NameToPort()
+// Convert name to a port number. Name can either be a port name
+// (in which case proto must also be set to either "tcp" or "udp")
+// or name can be the ascii representation of the port number.
+// Returns 0 on success, -1 on failure.
+int NameToPort (const char * name, unsigned short * port, const char * proto)
+{
+ unsigned long lport;
+ char * errpos;
+ struct servent * se;
+
+ // First, attempt to convert string to integer
+ lport = strtoul (name, &errpos, 0);
+ if ( (*errpos == 0) && (lport <= 65535) ) // Success
+ {
+ *port = lport;
+ return 0;
+ }
+
+ // Next, attempt to read the string from /etc/services
+ se = getservbyname (name, proto);
+ if ( se != NULL) // Success
+ {
+ *port = ntohs (se->s_port);
+ return 0;
+ }
+
+ return -1; // Failed to resolve port name to a number
+}
+
+// quit()
+// Print an error message to stderr
+// and syslog, then exit the program.
+void quit (const char * fmt, ...) // quit with msg
+{
+ va_list ap;
+
+ fflush (stdout);
+
+ fprintf (stderr, "%s: ", g_program_name);
+
+ va_start (ap, fmt);
+ vfprintf (stderr, fmt, ap);
+ va_end (ap);
+
+ fputc ('\n', stderr);
+
+ syslog (LOG_ERR, "I quit!");
+
+ exit (EXIT_FAILURE);
+}
+
+// pbomb()
+// Print an error message to stderr
+// and syslog, then exit the program.
+// pbomb() additionally include the
+// string representation of errno.
+void pbomb (const char * fmt, ...) // bomb with perror
+{
+ va_list ap;
+ int errno_save = errno;
+ char buf[100];
+
+ fflush (stdout);
+
+ fprintf (stderr, "%s: ", g_program_name);
+
+ va_start (ap, fmt);
+ vsnprintf (buf, sizeof (buf), fmt, ap);
+ va_end (ap);
+
+ errno = errno_save;
+ perror (buf);
+
+ syslog (LOG_ERR, "Bang!: %s: %m", buf);
+
+ exit (EXIT_FAILURE);
+}
+
+// hbomb()
+// Print an error message to stderr
+// and syslog, then exit the program.
+// hbomb() additionally include the
+// string representation of h_errno.
+void hbomb (const char * fmt, ...) // bomb with herror
+{
+ va_list ap;
+ int h_errno_save = h_errno;
+ char buf[100];
+
+ fflush (stdout);
+
+ fprintf (stderr, "%s: ", g_program_name);
+
+ va_start (ap, fmt);
+ vsnprintf (buf, sizeof (buf), fmt, ap);
+ va_end (ap);
+
+ h_errno = h_errno_save;
+ herror (buf);
+
+ syslog (LOG_ERR, "Bang!: %s: %s", buf, hstrerror (h_errno));
+
+ exit (EXIT_FAILURE);
+}
+
+// set_signal_handler(): Sets a signal handler function. Similar to signal()
+// but this method is more portable between platforms.
+void set_signal_handler (int signum, signal_handler_t sa_handler_func)
+{
+ struct sigaction act;
+
+ act.sa_handler = sa_handler_func;
+ sigemptyset (&(act.sa_mask));
+ act.sa_flags = 0;
+
+ if (sigaction (signum, &act, NULL) < 0)
+ {
+ syslog (LOG_ERR, "Error setting handler for signal %d: %m", signum);
+ exit (EXIT_FAILURE);
+ }
+}
Index: tags/instant_messenger/webjabber/Makefile
===================================================================
--- tags/instant_messenger/webjabber/Makefile (revision 260)
+++ tags/instant_messenger/webjabber/Makefile (revision 260)
@@ -0,0 +1,29 @@
+#Makefile webjabber
+#CC=gcc
+#
+#all: server client
+#
+#server: server.o
+# $(CC) -o server server.o -lpthread
+#server.o: server.c
+# $(CC) -g -c server.c
+#
+#client: client.o
+# $(CC) -o client client.o -lpthread
+#client.o: client.c
+# $(CC) -g -c client.c
+#
+#clean:
+# rm -f server client *.o *~
+
+CC=gcc
+
+all: webjabber
+
+webjabber: webjabber.o
+ $(CC) -o webjabber webjabber.o -lpthread
+webjabber.o: webjabber.c
+ $(CC) -g -c webjabber.c
+
+clean:
+ rm -f webjabber *.o *~
Index: tags/instant_messenger/client.php
===================================================================
--- tags/instant_messenger/client.php (revision 318)
+++ tags/instant_messenger/client.php (revision 318)
@@ -0,0 +1,46 @@
+ $val )
+ {
+ $val = array('act' => 'j.' . $val);
+ $script .= $controller->exec($val);
+ }
+
+?>
+
Index: tags/instant_messenger/xsl/layer.xsl
===================================================================
--- tags/instant_messenger/xsl/layer.xsl (revision 318)
+++ tags/instant_messenger/xsl/layer.xsl (revision 318)
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
:
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/contacts.xsl
===================================================================
--- tags/instant_messenger/xsl/contacts.xsl (revision 327)
+++ tags/instant_messenger/xsl/contacts.xsl (revision 327)
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/chat.xsl
===================================================================
--- tags/instant_messenger/xsl/chat.xsl (revision 305)
+++ tags/instant_messenger/xsl/chat.xsl (revision 305)
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/modelo.xsl
===================================================================
--- tags/instant_messenger/xsl/modelo.xsl (revision 260)
+++ tags/instant_messenger/xsl/modelo.xsl (revision 260)
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/subscribe.xsl
===================================================================
--- tags/instant_messenger/xsl/subscribe.xsl (revision 305)
+++ tags/instant_messenger/xsl/subscribe.xsl (revision 305)
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/fast_menu.xsl
===================================================================
--- tags/instant_messenger/xsl/fast_menu.xsl (revision 305)
+++ tags/instant_messenger/xsl/fast_menu.xsl (revision 305)
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/list_ldap_org.xsl
===================================================================
--- tags/instant_messenger/xsl/list_ldap_org.xsl (revision 305)
+++ tags/instant_messenger/xsl/list_ldap_org.xsl (revision 305)
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/message.xsl
===================================================================
--- tags/instant_messenger/xsl/message.xsl (revision 260)
+++ tags/instant_messenger/xsl/message.xsl (revision 260)
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/nickname.xsl
===================================================================
--- tags/instant_messenger/xsl/nickname.xsl (revision 260)
+++ tags/instant_messenger/xsl/nickname.xsl (revision 260)
@@ -0,0 +1,9 @@
+
+
+
+
+
+ ,
+
+
+
Index: tags/instant_messenger/xsl/add_user.xsl
===================================================================
--- tags/instant_messenger/xsl/add_user.xsl (revision 305)
+++ tags/instant_messenger/xsl/add_user.xsl (revision 305)
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+ :
+
+
+
+
+
+
+
+
+
+ Carregando .....
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/remove_user.xsl
===================================================================
--- tags/instant_messenger/xsl/remove_user.xsl (revision 260)
+++ tags/instant_messenger/xsl/remove_user.xsl (revision 260)
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/options.xsl
===================================================================
--- tags/instant_messenger/xsl/options.xsl (revision 305)
+++ tags/instant_messenger/xsl/options.xsl (revision 305)
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/smiles.xsl
===================================================================
--- tags/instant_messenger/xsl/smiles.xsl (revision 260)
+++ tags/instant_messenger/xsl/smiles.xsl (revision 260)
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/vcard_user.xsl
===================================================================
--- tags/instant_messenger/xsl/vcard_user.xsl (revision 260)
+++ tags/instant_messenger/xsl/vcard_user.xsl (revision 260)
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/vcard_contacts.xsl
===================================================================
--- tags/instant_messenger/xsl/vcard_contacts.xsl (revision 305)
+++ tags/instant_messenger/xsl/vcard_contacts.xsl (revision 305)
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+ :
+ :
+ :
+ :
+ :
+
+
+
Index: tags/instant_messenger/xsl/message_new.xsl
===================================================================
--- tags/instant_messenger/xsl/message_new.xsl (revision 318)
+++ tags/instant_messenger/xsl/message_new.xsl (revision 318)
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+ mensagem enviada em
+ /
+ /
+
+ as
+
+
+
+
+
+ [ ]
+ :
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/vcard.xsl
===================================================================
--- tags/instant_messenger/xsl/vcard.xsl (revision 260)
+++ tags/instant_messenger/xsl/vcard.xsl (revision 260)
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/preferences.xsl
===================================================================
--- tags/instant_messenger/xsl/preferences.xsl (revision 260)
+++ tags/instant_messenger/xsl/preferences.xsl (revision 260)
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/colors.xsl
===================================================================
--- tags/instant_messenger/xsl/colors.xsl (revision 260)
+++ tags/instant_messenger/xsl/colors.xsl (revision 260)
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/disconnected.xsl
===================================================================
--- tags/instant_messenger/xsl/disconnected.xsl (revision 305)
+++ tags/instant_messenger/xsl/disconnected.xsl (revision 305)
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
Expresso Messenger
+
+
+
Aviso :
+
+
+
+ Sua conexão com o
+
+ Servidor parou.
+
+ Tente novamente
+
+ ou entre em contato
+
+ com o Administrador.
+
+
+
+
+
Reconectar ...
+
+
+
+
Index: tags/instant_messenger/xsl/mysettings.xsl
===================================================================
--- tags/instant_messenger/xsl/mysettings.xsl (revision 327)
+++ tags/instant_messenger/xsl/mysettings.xsl (revision 327)
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/window.xsl
===================================================================
--- tags/instant_messenger/xsl/window.xsl (revision 311)
+++ tags/instant_messenger/xsl/window.xsl (revision 311)
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/xsl/list_ldap_contacts.xsl
===================================================================
--- tags/instant_messenger/xsl/list_ldap_contacts.xsl (revision 305)
+++ tags/instant_messenger/xsl/list_ldap_contacts.xsl (revision 305)
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/instant_messenger.define.php
===================================================================
--- tags/instant_messenger/instant_messenger.define.php (revision 327)
+++ tags/instant_messenger/instant_messenger.define.php (revision 327)
@@ -0,0 +1,9 @@
+
Index: tags/instant_messenger/css/window.css
===================================================================
--- tags/instant_messenger/css/window.css (revision 305)
+++ tags/instant_messenger/css/window.css (revision 305)
@@ -0,0 +1,81 @@
+/***** Cantos Arredondados *****/
+.corner { display: block; }
+.corner * { display: block; height: 1px; overflow: hidden; font-size: 0; }
+.corner1 { padding: 0 1px; margin: 0 3px; }
+.corner2 { padding: 0 1px; margin: 0 1px; }
+.corner3 { margin: 0 1px; }
+.blackcorner * { background: #b4cfe5; }
+/***** Cantos Arredondados *****/
+
+/***** Window *****/
+.window
+{
+ font: 10pt Verdana, Arial, Helvetica, sans-serif;
+ margin: 0px;
+ position: absolute;
+}
+
+#instant_messenger_content .body
+{
+ background: #b4cfe5;
+}
+
+#instant_messenger_content .titulo
+{
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+ background: #b4cfe5;
+ margin: 0px 0px;
+ padding: 0px 0px 0px 5px;
+ cursor: pointer;
+ height: 20px;
+}
+
+#instant_messenger_content .titulo div div
+{
+ cursor: pointer;
+ float: left;
+ margin-right: 2px;
+ position: relative;
+ width: 13px;
+ height:13px;
+}
+
+#instant_messenger_content .button_minimize
+{
+ background: #b4cfe5 url(../images/window_min.gif) no-repeat top center;
+}
+
+#instant_messenger_content .button_maximize1
+{
+ background: #b4cfe5 url(../images/window_max1.gif) no-repeat top center;
+}
+
+#instant_messenger_content .button_maximize
+{
+ background: #b4cfe5 url(../images/window_max.gif) no-repeat top center;
+}
+
+#instant_messenger_content .button_close
+{
+ background: #b4cfe5 url(../images/window_close.gif) no-repeat top center;
+ margin-right: 0px;
+}
+
+#instant_messenger_content .content
+{
+ font: 9pt Verdana, Arial, Helvetica, sans-serif;
+ background: #fff;
+ border: 1px solid;
+ border-color: #b3b3b3 #c1d6eb #c1d6eb #b3b3b3;
+ margin: 0px 5px;
+ overflow: auto;
+ cursor: default;
+}
+
+#instant_messenger_content .rodape
+{
+ background: #b4cfe5 url(../images/handle.gif) no-repeat bottom right;
+ height: 15px;
+}
+
+/***** Window - *****/
Index: tags/instant_messenger/controller.php
===================================================================
--- tags/instant_messenger/controller.php (revision 287)
+++ tags/instant_messenger/controller.php (revision 287)
@@ -0,0 +1,25 @@
+exec($$request_method));
+
+exit(0);
+?>
Index: tags/instant_messenger/inc/Socket.abstract.php
===================================================================
--- tags/instant_messenger/inc/Socket.abstract.php (revision 305)
+++ tags/instant_messenger/inc/Socket.abstract.php (revision 305)
@@ -0,0 +1,87 @@
+
Index: tags/instant_messenger/inc/controller.xml
===================================================================
--- tags/instant_messenger/inc/controller.xml (revision 327)
+++ tags/instant_messenger/inc/controller.xml (revision 327)
@@ -0,0 +1,67 @@
+
+
+
+ act
+ .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: tags/instant_messenger/inc/im_acl.inc.php
===================================================================
--- tags/instant_messenger/inc/im_acl.inc.php (revision 305)
+++ tags/instant_messenger/inc/im_acl.inc.php (revision 305)
@@ -0,0 +1,79 @@
+var path_im = "'.$webserver_url.'";';
+
+ #require_once dirname(__FILE__) . '/Controller.class.php';
+
+ #$controller = new Controller;
+ #$script = '';
+ #foreach ( $js as $key => $val )
+ #{
+ # $val = array('act' => 'j.' . $val);
+ # $script .= $controller->exec($val);
+ #}
+
+ //printf("", $script);
+
+ print ' ';
+ print ' ';
+ print ' ';
+
+ # trecho de código javascript utilizado para
+ # controle de possÃvel erro no load do script
+ # feito acima e está sendo inserido via PHP
+ # pois é um complemento do procedimento acima
+ #$init_client = '';
+ //printf("%s", $init_client);
+ echo '';
+}
+?>
Index: tags/instant_messenger/inc/im_sessions.inc.php
===================================================================
--- tags/instant_messenger/inc/im_sessions.inc.php (revision 318)
+++ tags/instant_messenger/inc/im_sessions.inc.php (revision 318)
@@ -0,0 +1,20 @@
+
Index: tags/instant_messenger/inc/class.FileDefine.inc.php
===================================================================
--- tags/instant_messenger/inc/class.FileDefine.inc.php (revision 318)
+++ tags/instant_messenger/inc/class.FileDefine.inc.php (revision 318)
@@ -0,0 +1,35 @@
+";
+
+ $this->writeFile($string);
+ }
+
+ private final function writeFile($pContent)
+ {
+ $log = $pContent;
+
+ if ( $fp = fopen (self::FILE, "w+") )
+ {
+ fwrite($fp, $log);
+ fclose($fp);
+ }
+ }
+
+}
+?>
Index: tags/instant_messenger/inc/Jabberd2.abstract.php
===================================================================
--- tags/instant_messenger/inc/Jabberd2.abstract.php (revision 327)
+++ tags/instant_messenger/inc/Jabberd2.abstract.php (revision 327)
@@ -0,0 +1,212 @@
+writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ function closeSocket()
+ {
+ $this->close($this->_socket);
+ }
+
+ function disconnect()
+ {
+ $this->_disconnect();
+ }
+
+ final function readSocket()
+ {
+ return $this->read();
+ }
+
+ final function writeSocket($pData)
+ {
+ return $this->write($pData);
+ }
+
+ /*
+ * Jabber - Functions
+ */
+
+ final function addRoster($pRoster)
+ {
+ if ( !$this->connected )
+ return "disconnected";
+
+ if ( trim($pRoster['uid']) )
+ {
+ $jid = $pRoster['uid'] . "@" . $this->_server;
+
+ $newroster = " ";
+
+ if ( $this->iq('set', "addroster_" . time(), NULL, NULL, "jabber:iq:roster", $newroster) )
+ {
+ $this->getContacts();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ final function addContact($pContact)
+ {
+ $this->addRoster($pContact);
+ $this->subscription($pContact['uid'] . "@" . $this->_server, 'subscribe');
+ }
+
+ final function getContacts()
+ {
+ if ( !$this->isConnected() )
+ return "disconnected";
+
+ $this->iq('get', 'contacts', NULL, NULL, 'jabber:iq:roster');
+ }
+
+ final function getVcard($pJid)
+ {
+ if ( is_array($pJid) )
+ {
+ $jid = ( trim($pJid['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pJid['jid'];
+ $vcard = (trim($pJid['jid']) == "this") ? 'vCard_user' : 'vCard';
+
+ if ( !$this->connected )
+ {
+ echo "disconnected";
+ }
+ else
+ {
+ $this->iq('get', $vcard, $jid, NULL, "vcard-temp", " ");
+ }
+ }
+ else
+ {
+ $this->iq('get', 'vCard', $pJid, NULL, "vcard-temp", " ");
+ }
+ }
+
+ final function newVcard($NewVcard)
+ {
+ $id = $this->_user;
+
+ if ( !$this->connected )
+ echo "disconnected";
+ else
+ {
+ $this->iq('set', $id, NULL, NULL, "vcard-temp", "".$NewVcard['vcard']." ");
+ echo "OK";
+ }
+ }
+
+ final function removeContact($pContact)
+ {
+ if ( !$this->isConnected() )
+ return "disconnected";
+
+ if ( $this->iq('set', 'delroster_' . time(), NULL, NULL, 'jabber:iq:roster'," ") )
+ {
+ $this->getContacts();
+ return true;
+ }
+ return false;
+ }
+
+ function allowContact($pRoster)
+ {
+ $this->addRoster($pRoster);
+ $jid = $pRoster['uid'] . "@" . $this->_server;
+ $this->subscription($jid, 'subscribed');
+ $this->subscription($jid, 'subscribe');
+ }
+
+ final function subscription($pTo, $pType = false)
+ {
+ $jid = (is_array($pTo)) ? $pTo['jid'] : $pTo ;
+ $type = (is_array($pTo)) ? $pTo['type'] : $pType ;
+
+ if ( !$this->connected )
+ return false;
+ else
+ {
+ $this->writeSocket(" ");
+ return true;
+ }
+ }
+
+ final function setPresence($pPresence = false)
+ {
+ if ( !$this->isConnected() )
+ return "disconnected";
+
+ if ( !$pPresence )
+ $this->presence();
+ else
+ {
+ $type = ( isset($pPresence['type']) ) ? $pPresence['type'] : NULL;
+ $to = ( isset($pPresence['to']) ) ? $pPresence['to'] : NULL;
+ $show = ( isset($pPresence['show']) ) ? $pPresence['show'] : NULL;
+ $status = ( isset($pPresence['status']) ) ? $pPresence['status'] : NULL;
+ $priority = ( isset($pPresence['priority']) ) ? $pPresence['priority'] : NULL;
+
+ $this->presence($type, $to, $show, $status, $priority);
+ }
+ }
+
+ final function get_last_access_user($pUser = array("jid" => "this"))
+ {
+ $id = "last_time_user";
+ $jid = ( trim($pUser['jid']) == "this" ) ? $this->_user . '@' . $this->_server : $pUser['jid'];
+ $this->iq('get', $id, $jid, NULL, "jabber:iq:last");
+ }
+
+ final function setStatus()
+ {
+ $this->setPresence(array("type" => "unavailable"));
+ $this->setPresence(array("type" => "available"));
+ }
+
+ final function updateContact($pContact)
+ {
+ $jid = $pContact['jid'];
+ $name = $pContact['name'];
+ $group = $pContact['group'];
+
+ if ( $jid )
+ {
+ $updatecontact = " ";
+ }
+
+ $upid = 'updateuser_' . time();
+ if ( !$this->connected )
+ echo "disconnected";
+ else
+ {
+ $this->iq('set', $upid, NULL, NULL, "jabber:iq:roster", $updatecontact);
+ $this->getContacts();
+ echo "OK";
+ }
+ }
+}
+?>
Index: tags/instant_messenger/inc/class.contacts_im.inc.php
===================================================================
--- tags/instant_messenger/inc/class.contacts_im.inc.php (revision 305)
+++ tags/instant_messenger/inc/class.contacts_im.inc.php (revision 305)
@@ -0,0 +1,120 @@
+ldap = new ldap_im();
+ $this->db_user = new db_im();
+ }
+
+ private function users_auth_im()
+ {
+ $db_acls = $this->db_user->get_accounts_acl();
+
+ $search_uids = "|";
+ if(count($db_acls) > 0)
+ foreach($db_acls as $tmp)
+ $search_uids .= "(uidNumber=".$tmp['acl_account'].")";
+
+ // Busca Usuarios
+ $uids = $this->ldap->list_users_ldap($search_uids);
+
+ $search_groups = "|";
+ if(count($db_acls) > 0)
+ foreach($db_acls as $tmp)
+ $search_groups .= "(gidNumber=".$tmp['acl_account'].")";
+
+ // Busca Grupos
+ $groups = $this->ldap->list_groups_ldap($search_groups);
+
+ $search_uids = "|";
+ if($groups)
+ {
+ foreach($groups as $tmp)
+ {
+ $members = $tmp['members'];
+ foreach($members as $mb)
+ $search_uids .= "(uid=".$mb.")";
+ }
+ }
+
+ if($uids)
+ {
+ foreach($uids as $tmp)
+ $search_uids .= "(uid=".$tmp['uid'].")";
+ }
+ $uids_members = $this->ldap->list_users_ldap($search_uids);
+
+ if(count($uids_members) > 0)
+ return $uids_members;
+ else
+ return 0;
+ }
+
+ function list_contacts($param)
+ {
+ $users = $this->users_auth_im();
+ $order = array();
+ $return = "";
+
+ foreach($users as $tmp)
+ $order[] = $tmp['cn'].";".$tmp['mail'].";".$tmp['uid'].";".$tmp['dn'];
+
+ natsort($order);
+ $uid_unique = @array_values(@array_unique($order));
+
+ foreach($uid_unique as $tmp)
+ {
+ $result = explode(";",$tmp);
+ if(strtolower($result[3]) == strtolower($param['ou']))
+ {
+ $return .= "";
+ $return .= "" . $result[0] . " ";
+ $return .= "" . $result[1] . " ";
+ $return .= "" . $result[2] . " ";
+ $return .= " ";
+ }
+ unset($result);
+ }
+
+ $return .= " ";
+ return $return;
+ }
+
+ function UserPermission($param)
+ {
+ $db_acls = $this->db_user->get_accounts_acl();
+ $members = array();
+ $search_uid = "";
+ $search_groups = "|";
+
+ $search_uid = $this->ldap->list_users_ldap("uid=".$param['uid']);
+
+ foreach($db_acls as $tmp)
+ if($tmp['acl_account'] == $search_uid[0]['uidnumber'])
+ return 1;
+ else
+ $search_groups .= "(gidNumber=".$tmp['acl_account'].")";
+
+ $groups = $this->ldap->list_groups_ldap($search_groups);
+
+ if($groups)
+ foreach($groups as $tmp){
+ $members = $tmp['members'];
+ foreach($members as $mb){
+ if(trim($mb) == trim($search_uid[0]['uid']))
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+}
+?>
Index: tags/instant_messenger/inc/hook_admin.inc.php
===================================================================
--- tags/instant_messenger/inc/hook_admin.inc.php (revision 260)
+++ tags/instant_messenger/inc/hook_admin.inc.php (revision 260)
@@ -0,0 +1,21 @@
+ *
+ * -------------------------------------------- *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU General Public License as published by the *
+ * Free Software Foundation; either version 2 of the License, or (at your *
+ * option) any later version. *
+ \**************************************************************************/
+
+// Only Modify the $file and $title variables.....
+ $title = 'instant_messenger';
+ $file = array(
+ 'Site Configuration' => $GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname)
+ );
+
+//Do not modify below this line
+ display_section($appname,$title,$file);
+?>
Index: tags/instant_messenger/inc/load_lang.php
===================================================================
--- tags/instant_messenger/inc/load_lang.php (revision 305)
+++ tags/instant_messenger/inc/load_lang.php (revision 305)
@@ -0,0 +1,25 @@
+
+
+if ( file_exists(($fn = dirname(__FILE__) . '/../setup/phpgw_pt-br.lang')) )
+ if ( ($fp = fopen($fn,'r')) )
+ {
+ while ($data = fgets($fp,16000))
+ {
+ list($message_id, $app_name, $null, $content) = explode("\t",substr($data,0,-1));
+ $LANG_IM[$message_id] = $content;
+ }
+ fclose($fp);
+ }
+
+$script = '";
+
+echo $script;
+
+unset($LANG_IM);
+?>
Index: tags/instant_messenger/inc/class.ldap_im.inc.php
===================================================================
--- tags/instant_messenger/inc/class.ldap_im.inc.php (revision 318)
+++ tags/instant_messenger/inc/class.ldap_im.inc.php (revision 318)
@@ -0,0 +1,212 @@
+ldap_host = constant('IM_SERVER_LDAP_JABBER');
+ $this->ldap_context = constant('IM_CONTEXT_LDAP_JABBER');
+ $this->user = constant('IM_USER_LDAP_JABBER');
+
+ session_start();
+ $this->password = $_SESSION['phpgw_info']['instant_messenger']['password_ldap_jabber'];
+ $this->jid = $_SESSION['phpgw_info']['instant_messenger']['user'];
+ session_write_close();
+
+ $this->connect_ldap(false);
+
+ }
+ catch(Exception $e)
+ {
+ echo $e->getMessage();
+ }
+ }
+
+ function __destruct()
+ {
+ ldap_close($this->conn);
+ }
+
+ function connect_ldap($refer)
+ {
+ $this->conn = ldap_connect($this->ldap_host);
+ ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, 3);
+ ldap_set_option($this->conn, LDAP_OPT_REFERRALS, $refer);
+ if(trim($this->user) != "")
+ @ldap_bind($this->conn,$this->user,$this->password);
+ else
+ @ldap_bind($this->conn);
+ }
+
+ function get_photo_ldap($pUser,$getPhoto)
+ {
+ $user = ( $pUser == "im_avatar" ) ? $this->jid : $pUser ;
+
+ if ($this->conn)
+ {
+ $filter="(&(uid=".$user.")(phpgwAccountType=u))";
+ $justthese = array("jpegphoto");
+ $search = @ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
+ $entry = @ldap_first_entry($this->conn, $search);
+ $jpeg_data = @ldap_get_values_len($this->conn, $entry, "jpegphoto");
+
+ if( count($jpeg_data) > 1)
+ {
+ $photo = imagecreatefromstring($jpeg_data[0]);
+ if($photo)
+ {
+ if($getPhoto)
+ {
+ header("Content-Type: image/jpeg");
+ $width = imagesx($photo);
+ $height = imagesy($photo);
+ $twidth = 49;
+ $theight = 65;
+ $small_photo = imagecreatetruecolor ($twidth, $theight);
+ imagecopyresampled($small_photo, $photo, 0, 0, 0, 0,$twidth, $theight, $width, $height);
+ imagejpeg($small_photo,'',100);
+ return;
+ }else{
+ return "true";
+ }
+ }else{
+ return "false";
+ }
+ }else{
+ return "false";
+ }
+ }
+ }
+
+ function photo_ldap($user)
+ {
+ $uid = ( $user['uid'] == "im_avatar" ) ? $this->jid : $user['uid'] ;
+ return $this->get_photo_ldap($uid,false);
+ }
+
+ function list_users_ldap($search)
+ {
+
+ if($this->conn){
+ $filter = "(&(".$search.")(phpgwAccountType=u))";
+ $justthese = array("uid","uidNumber","cn","mail","phpgwAccountVisible","dn");
+ $search = ldap_search($this->conn,$this->ldap_context,$filter,$justthese);
+ $entry = ldap_get_entries($this->conn,$search);
+ }
+
+ if( $entry['count'] > 0){
+ $i = 0;
+ $result_user = array();
+ foreach($entry as $tmp)
+ {
+ if($tmp['uidnumber'][0] != "" && $tmp['phpgwaccountvisible'][0] != "-1"){
+ $result_user[$i]['uidnumber'] = $tmp['uidnumber'][0];
+ $result_user[$i]['mail'] = $tmp['mail'][0];
+ $result_user[$i]['uid'] = $tmp['uid'][0];
+ $result_user[$i]['cn'] = $tmp['cn'][0];
+ $ou = explode("dc=",$tmp['dn']);
+ $ou = explode("ou=",$ou[0]);
+ $ou = array_pop($ou);
+ $result_user[$i]['dn'] = strtoupper(substr($ou,0,strlen($ou)-1));
+ $i++;
+ }
+ }
+ return $result_user;
+ }
+ return 0;
+ }
+
+ function list_groups_ldap($search)
+ {
+
+ if( $this->conn ){
+ $filter = "(&(".$search.")(objectClass=posixGroup))";
+ $justthese = array("gidnumber","cn","memberuid");
+ $search = ldap_search($this->conn,$this->ldap_context, $filter, $justthese);
+ $entry = ldap_get_entries($this->conn,$search);
+ }
+
+ if($entry['count'] > 0){
+ $i = 0;
+ $result_groups = array();
+ foreach($entry as $tmpg){
+ if($tmpg['gidnumber'] != ""){
+ if(array_key_exists("memberuid", $tmpg)){
+ $result_groups[$i]['gidnumber'] = $tmpg['gidnumber'][0];
+ @array_shift($tmpg['memberuid']);
+ foreach($tmpg['memberuid'] as $tmp)
+ $result_groups[$i]['members'][] = $tmp;
+ $i++;
+ }
+ }
+ }
+ }
+
+ if(count($result_groups) > 0 ){
+ return $result_groups;
+ }else{
+ return 0;
+ }
+ }
+
+ function list_organizations_ldap()
+ {
+ $result_org = "";
+
+ if ($this->conn)
+ {
+ $filter="ou=*";
+ $justthese = array("ou");
+ $search = ldap_list($this->conn,$this->ldap_context, $filter, $justthese);
+ $entry = ldap_get_entries($this->conn, $search);
+ }
+
+ foreach($entry as $tmp)
+ if($tmp['ou'][0] != "")
+ $result_org .= "" . $tmp['ou'][0] . " ";
+
+ $result_org .= " ";
+
+ return $result_org;
+ }
+
+ function info_user($user)
+ {
+ $uid = "uid=".$user['uid'];
+ $i= 0;
+
+ $entry = $this->list_users_ldap($uid);
+
+ if( count($entry) > 0 )
+ return $entry;
+ else
+ return false;
+ }
+}
+
+if(trim($_REQUEST['user']) != "")
+{
+ $obj_img = new ldap_im();
+ $obj_img->get_photo_ldap($_REQUEST['user'],true);
+}
+
+?>
Index: tags/instant_messenger/inc/class.download.inc.php
===================================================================
--- tags/instant_messenger/inc/class.download.inc.php (revision 260)
+++ tags/instant_messenger/inc/class.download.inc.php (revision 260)
@@ -0,0 +1,155 @@
+down_file($array_info['fileUp']);
+ }else{
+ $url = "http://".$array_info['server'].$array_info['path'].$array_info['filePhp'].$base64;
+ header("Location:" . $url);
+ }
+ }
+
+ function down_file($file)
+ {
+
+ ini_set("session.save_path","/php_sessions");
+ $size = filesize(ini_get("session.save_path").'/'. $file);
+ $NameFile = explode("_IM_SendFile_",$file);
+
+ if (!empty($file))
+ {
+ if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
+ $UserBrowser = "Opera";
+ elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
+ $UserBrowser = "IE";
+ else
+ $UserBrowser = '';
+
+ $strFileType = strrev(substr(strrev($NameFile),0,4));
+ $ContentType = "application/octet-stream";
+
+ if ($strFileType == ".asf")
+ $ContentType = "video/x-ms-asf";
+ if ($strFileType == ".avi")
+ $ContentType = "video/avi";
+ if ($strFileType == ".doc")
+ $ContentType = "application/msword";
+ if ($strFileType == ".zip")
+ $ContentType = "application/zip";
+ if ($strFileType == ".xls")
+ $ContentType = "application/vnd.ms-excel";
+ if ($strFileType == ".gif")
+ $ContentType = "image/gif";
+ if ($strFileType == ".jpg" || $strFileType == "jpeg")
+ $ContentType = "image/jpeg";
+ if ($strFileType == ".wav")
+ $ContentType = "audio/wav";
+ if ($strFileType == ".mp3")
+ $ContentType = "audio/mpeg3";
+ if ($strFileType == ".mpg" || $strFileType == "mpeg")
+ $ContentType = "video/mpeg";
+ if ($strFileType == ".rtf")
+ $ContentType = "application/rtf";
+ if ($strFileType == ".htm" || $strFileType == "html")
+ $ContentType = "text/html";
+ if ($strFileType == ".xml")
+ $ContentType = "text/xml";
+ if ($strFileType == ".xsl")
+ $ContentType = "text/xsl";
+ if ($strFileType == ".css")
+ $ContentType = "text/css";
+ if ($strFileType == ".php")
+ $ContentType = "text/php";
+ if ($strFileType == ".asp")
+ $ContentType = "text/asp";
+ if ($strFileType == ".pdf")
+ $ContentType = "application/pdf";
+ if ($strFileType == ".txt")
+ $ContentType = "text/plain";
+ if ($strFileType == ".log")
+ $ContentType = "text/plain";
+ if ($strFileType == ".wmv")
+ $ContentType = "video/x-ms-wmv";
+ if ($strFileType == ".sxc")
+ $ContentType = "application/vnd.sun.xml.calc";
+ if ($strFileType == ".odt")
+ $ContentType = "application/vnd.oasis.opendocument.text";
+ if ($strFileType == ".stc")
+ $ContentType = "application/vnd.sun.xml.calc.template";
+ if ($strFileType == ".sxd")
+ $ContentType = "application/vnd.sun.xml.draw";
+ if ($strFileType == ".std")
+ $ContentType = "application/vnd.sun.xml.draw.template";
+ if ($strFileType == ".sxi")
+ $ContentType = "application/vnd.sun.xml.impress";
+ if ($strFileType == ".sti")
+ $ContentType = "application/vnd.sun.xml.impress.template";
+ if ($strFileType == ".sxm")
+ $ContentType = "application/vnd.sun.xml.math";
+ if ($strFileType == ".sxw")
+ $ContentType = "application/vnd.sun.xml.writer";
+ if ($strFileType == ".sxq")
+ $ContentType = "application/vnd.sun.xml.writer.global";
+ if ($strFileType == ".stw")
+ $ContentType = "application/vnd.sun.xml.writer.template";
+ if ($strFileType == ".ps")
+ $ContentType = "application/postscript";
+ if ($strFileType == ".pps")
+ $ContentType = "application/vnd.ms-powerpoint";
+ if ($strFileType == ".odt")
+ $ContentType = "application/vnd.oasis.opendocument.text";
+ if ($strFileType == ".ott")
+ $ContentType = "application/vnd.oasis.opendocument.text-template";
+ if ($strFileType == ".oth")
+ $ContentType = "application/vnd.oasis.opendocument.text-web";
+ if ($strFileType == ".odm")
+ $ContentType = "application/vnd.oasis.opendocument.text-master";
+ if ($strFileType == ".odg")
+ $ContentType = "application/vnd.oasis.opendocument.graphics";
+ if ($strFileType == ".otg")
+ $ContentType = "application/vnd.oasis.opendocument.graphics-template";
+ if ($strFileType == ".odp")
+ $ContentType = "application/vnd.oasis.opendocument.presentation";
+ if ($strFileType == ".otp")
+ $ContentType = "application/vnd.oasis.opendocument.presentation-template";
+ if ($strFileType == ".ods")
+ $ContentType = "application/vnd.oasis.opendocument.spreadsheet";
+ if ($strFileType == ".ots")
+ $ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";
+ if ($strFileType == ".odc")
+ $ContentType = "application/vnd.oasis.opendocument.chart";
+ if ($strFileType == ".odf")
+ $ContentType = "application/vnd.oasis.opendocument.formula";
+ if ($strFileType == ".odi")
+ $ContentType = "application/vnd.oasis.opendocument.image";
+ if ($strFileType == ".ndl")
+ $ContentType = "application/vnd.lotus-notes";
+
+ $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
+
+ header("Content-Type: $ContentType");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+ header("Pragma: public");
+ header("Expires: 0");
+ header("Content-Disposition: attachment; filename=\"" . $NameFile[1] . "\"");
+ header("Content-length: " . $size);
+ readfile(ini_get("session.save_path") . "/" . $file);
+ die();
+ }
+ }
+}
+
+if(isset ($_REQUEST['file'])){
+ $obj_down = new download();
+ $obj_down->Decode_String($_REQUEST['file']);
+}
+
+?>
Index: tags/instant_messenger/inc/teste.php
===================================================================
--- tags/instant_messenger/inc/teste.php (revision 305)
+++ tags/instant_messenger/inc/teste.php (revision 305)
@@ -0,0 +1,89 @@
+";
+$xml .= " ";
+fwrite($fp, $xml);
+usleep(50000);
+echo fread($fp, 4096);
+echo "\n\n";
+
+stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+
+$xml = "";
+$xml .= "";
+fwrite($fp, $xml);
+usleep(50000);
+echo fread($fp, 4096);
+echo "\n\n";
+
+usleep(50000);
+echo fread($fp, 4096);
+echo "\n\n";
+
+$xml = "";
+$xml .= "teste9 ";
+$xml .= "teste99 ";
+$xml .= "IM ";
+$xml .= " ";
+fwrite($fp, $xml);
+usleep(50000);
+echo fread($fp, 4096);
+echo "\n\n";
+
+stream_set_blocking ($fp, false);
+$xml = " ";
+fwrite($fp, $xml);
+usleep(50000);
+//echo fread($fp, 4096);
+//echo "\n\n";
+
+//while(1)
+//{
+// echo fread($fp, 4096);
+// echo "\n\n";
+// sleep(1);
+//}
+
+echo "=================================================\n\n";
+
+$time = time();
+ do
+ {
+ $line = NULL;
+ $line = fread($fp, 4096);
+
+ if ( !empty($line) )
+ var_dump($line);
+ }
+ while ( time() - $time < 20 );
+fclose($fp);
+
+
+ exit(0);
+ session_start();
+
+ echo "";
+ print_r($_SESSION['debug']);
+ echo " ";
+
+ session_write_close();
+
+
+?>
Index: tags/instant_messenger/inc/class.Ujabber.inc.php
===================================================================
--- tags/instant_messenger/inc/class.Ujabber.inc.php (revision 327)
+++ tags/instant_messenger/inc/class.Ujabber.inc.php (revision 327)
@@ -0,0 +1,235 @@
+_server = constant('IM_NAME_JABBER');
+ $this->_resource = constant('IM_RESOURCE_JABBER');
+
+ $this->_port = constant('IM_PORT_JABBER');
+
+ session_start();
+ $this->_user = $_SESSION['phpgw_info']['instant_messenger']['user'];
+ $this->_pass = $_SESSION['phpgw_info']['instant_messenger']['passwd'];
+ session_write_close();
+
+ $access_string = $this->_user . '@' . $this->_server . '/' . $this->_resource . ':' . $this->_port;
+
+ $this->connected = false;
+ if ( $this->connect($access_string, $this->_pass, $pConnectionType, constant('IM_SERVER_WEBJABBER')) )
+ $this->connected = true;
+ }
+ catch(Exception $e)
+ {
+ echo $e->getMessage();
+ }
+ }
+
+ public final function __destruct()
+ {
+ $this->closeSocket();
+ ob_end_flush();
+ flush();
+ }
+
+ public final function isConnected()
+ {
+ return $this->connected;
+ }
+
+ public final function listen()
+ {
+ if ( !$this->isConnected() )
+ return "disconnected";
+
+ $this->get_last_access_user();
+
+ if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
+ {
+ sleep(1);
+ $xml = $this->readSocket();
+ printf("%s", $xml);
+ }
+ else
+ {
+ ob_end_clean();
+ ignore_user_abort(true);
+ ob_start();
+
+ $init = time();
+ $buffer = '';
+
+ $send_last_access = time();
+
+ while ( (connection_aborted() === 0) && (time() - $init < 50) )
+ {
+ if ( (time() - $send_last_access) > 15 )
+ {
+ $this->get_last_access_user();
+ $send_last_access = time();
+ }
+
+ # read from server and write in the client
+ $xml = $this->readSocket();
+ //var_dump($xml);
+ if ( strlen($xml) && $xml != ' ' )
+ {
+ if ( $xml[strlen($xml) - 1 ] != '>' )
+ {
+ $buffer .= $xml;
+ $xml = '';
+ }
+ else
+ {
+ $xml = $buffer . $xml;
+ $buffer = '';
+ //var_dump($xml);
+ //strlen($xml);
+ //exit;
+ }
+ }
+ $xml = ( strlen($xml) ) ? $xml : ' ';
+ printf("%s", $xml);
+ ob_flush();
+ flush();
+ usleep(6000);
+ }
+ }
+ }
+
+ public final function update()
+ {
+ $presence = $_COOKIE['IM_presence'];
+
+ if ( !$presence )
+ $presence = 'available';
+
+ switch ( $presence )
+ {
+ case 'away':
+ case 'dnd':
+ case 'xa':
+ $presence = array('show' => $presence);
+ break;
+ case 'available':
+ case 'unavailable':
+ $presence = array('type' => $presence);
+ break;
+ }
+
+ $this->getContacts();
+ $this->setPresence(array('type'=>'unavailable'));
+ $this->setPresence($presence);
+
+ print_r($presence);
+ }
+
+ public final function Composing($pJid)
+ {
+ $pJid = $pJid['jid'];
+ $id = 'chat' . "_" . time();
+ $xml = " ";
+ $this->writeSocket($xml);
+ }
+
+ public final function Paused($pJid)
+ {
+ $pJid = $pJid['jid'];
+ $id = 'chat' . "_" . time();
+ $xml = " ";
+ $this->writeSocket($xml);
+ }
+
+ public final function SendMessage($pSendMessage)
+ {
+ if ( !$this->isConnected() )
+ return "disconnected";
+
+ $pSendMessage['body'] = stripslashes($pSendMessage['body']);
+
+ $patterns = array('/ | +/i', '/ ]*>/i');
+ $replace = array(' ', ' ');
+ $pSendMessage['body'] = preg_replace($patterns, $replace, $pSendMessage['body']);
+
+ $_emotions = '/ ]+>/';
+ $_emotions = preg_match_all($_emotions, $pSendMessage['body'], $emotions);
+
+ foreach ( $emotions[0] as $key => $val )
+ $emotions[0][$key] = '/' . addcslashes($val, './()[]{}^$*&?') . '/i';
+
+ $pSendMessage['body'] = preg_replace($emotions[0], $emotions[1], $pSendMessage['body']);
+
+ $to = $pSendMessage['to'];
+ $type = "chat";
+ $id = "";
+ $content = array(
+ "subject" => $pSendMessage['subject'] ? $pSendMessage['subject'] : "",
+ "thread" => $pSendMessage['thread'] ? $pSendMessage['thread'] : "",
+ "body" => $pSendMessage['body'] ? $pSendMessage['body'] : ""
+ );
+
+ $payload = "";
+
+ if ($to && is_array($content))
+ {
+ if (!$id)
+ {
+ $id = $type . "_" . time();
+ }
+
+ $xml = "";
+
+ if ($content['subject'])
+ {
+ $xml .= "" . $content['subject'] . " ";
+ }
+
+ if ($content['thread'])
+ {
+ $xml .= "" . $content['thread'] . " ";
+ }
+
+ //Linha abaixo dentro do padrão xmpp, entretanto clientes como
+ //o PSI não seguem o padrão assim ocorre problemas de comunicação
+ //descomentar e retirar a seguinte para voltar ao padrão assim
+ //que possível
+ //24/10/2007 - problema verificado por usuários do SERPRO na
+ //plataforma Windows ocorrendo também no cliente Linux
+ //por Alexandre e Rodrigo
+
+ //$xml .= "" . $content['body'] . "";
+
+ //retirar a linha abaixo para voltar ao padrão conforme acima
+ $xml .= "";
+ $xml .= $payload;
+ $xml .= " ";
+ unset($id);
+
+ //echo $xml;
+ $this->writeSocket($xml);
+ $this->close();
+ }
+ else
+ {
+ //$this->writeLog("ERROR: SendMessage() #2");
+ return false;
+ }
+ }
+}
+?>
Index: tags/instant_messenger/inc/class.db_im.inc.php
===================================================================
--- tags/instant_messenger/inc/class.db_im.inc.php (revision 305)
+++ tags/instant_messenger/inc/class.db_im.inc.php (revision 305)
@@ -0,0 +1,105 @@
+db_name = $_SESSION['phpgw_info']['instant_messenger']['server']['db_name'];
+ $this->db_host = $_SESSION['phpgw_info']['instant_messenger']['server']['db_host'];
+ $this->db_port = $_SESSION['phpgw_info']['instant_messenger']['server']['db_port'];
+ $this->db_user = $_SESSION['phpgw_info']['instant_messenger']['server']['db_user'];
+ $this->db_pass = $_SESSION['phpgw_info']['instant_messenger']['server']['db_pass'];
+ $this->db_type = $_SESSION['phpgw_info']['instant_messenger']['server']['db_type'];
+ $this->user_id = $_SESSION['phpgw_info']['instant_messenger']['user_id'];
+ session_write_close();
+
+ $this->db = new db();
+ $this->db->connect($this->db_name,$this->db_host,$this->db_port,$this->db_user,$this->db_pass,$this->db_type);
+ }
+
+ function get_accounts_acl()
+ {
+ $result = array();
+ $query = "select acl_appname, acl_account from phpgw_acl where acl_appname = 'instant_messenger' order by acl_account";
+
+ if (!$this->db->query($query))
+ return null;
+
+ while($this->db->next_record())
+ $result[] = $this->db->row();
+
+ return $result;
+ }
+
+ function query_db($pQuery)
+ {
+ if (!$this->db->query($pQuery))
+ return false;
+ else
+ return true;
+ }
+
+ function set_preferences($param)
+ {
+ $preferences = $param['preferences'];
+ $user_id = $this->user_id;
+ $app_name = $this->name_app();
+
+ $query = "insert into phpgw_preferences values('".$user_id."','".$app_name."','".serialize($preferences)."')";
+
+ if($this->query_db($query))
+ {
+ return "true";
+ }
+ else
+ {
+ $query = "update phpgw_preferences set preference_value = '".serialize($preferences)."' where preference_app='".$app_name."' and preference_owner='".$user_id."'";
+ if($this->query_db($query))
+ return "true";
+ else
+ return "false";
+ }
+ }
+
+ function get_preferences()
+ {
+ $result = array();
+ $user_id = $this->user_id;
+ $app_name = $this->name_app();
+
+ $query = "select * from phpgw_preferences where preference_owner = '".$user_id."' and preference_app = '".$app_name."'";
+
+ if (!$this->db->query($query))
+ return NULL;
+
+ while($this->db->next_record())
+ $result[] = $this->db->row();
+
+ if(count($result) > 0)
+ return unserialize($result[0]['preference_value']);
+ else
+ return "ch_offline:true;time_xa_im:1;rd_nm:true;rd_ch:false";
+ }
+
+ function name_app()
+ {
+ return "instant_messenger";
+ }
+}
+?>
Index: tags/instant_messenger/inc/Controller.class.php
===================================================================
--- tags/instant_messenger/inc/Controller.class.php (revision 327)
+++ tags/instant_messenger/inc/Controller.class.php (revision 327)
@@ -0,0 +1,892 @@
+dom = new DOMDocument;
+ $this->dom->preserveWhiteSpace = FALSE;
+ $this->dom->load($controler_xml);
+
+ unset($controler_xml);
+
+ $this->controller_security = $this->dom->getElementsByTagName(self::__CONTROLLER_SECURITY__);
+ if ( $this->controller_security->length === (int)0 )
+ throw new Exception(__CLASS__ . ' [ ERROR #0 ] :: the tag "' . self::__CONTROLLER_SECURITY__ . '" does not exist');
+ if ( $this->controller_security->length !== (int)1 )
+ throw new Exception(__CLASS__ . ' [ ERROR #1 ] :: exists more of a tag "' . self::__CONTROLLER_SECURITY__ . '"');
+
+ $this->controller_contentes = $this->dom->getElementsByTagName(self::__CONTROLLER_CONTENTES__);
+ if ( $this->controller_contentes->length === (int)0 )
+ throw new Exception(__CLASS__ . ' [ ERROR #2 ] :: the tag "' . self::__CONTROLLER_CONTENTES__ . '" does not exist');
+ if ( $this->controller_contentes->length !== (int)1 )
+ throw new Exception(__CLASS__ . ' [ ERROR #3 ] :: exists more of a tag "' . self::__CONTROLLER_CONTENTES__ . '"');
+ $this->controller_contentes = $this->controller_contentes->item(0);
+
+ $this->controller_sections = $this->dom->getElementsByTagName("controller-sections");
+ if ( $this->controller_sections->length === (int)0 )
+ throw new Exception(__CLASS__ . ' [ ERROR #4 ] :: the tag "' . self::__CONTROLLER_SECTIONS__ . '" does not exist');
+ if ( $this->controller_sections->length !== (int)1 )
+ throw new Exception(__CLASS__ . ' [ ERROR #5 ] :: exists more of a tag "' . self::__CONTROLLER_SECTIONS__ . '"');
+ $this->controller_sections = $this->controller_sections->item(0);
+
+ $this->string_access = $this->controller_security->item(0)->getElementsByTagName(self::__STRING_ACCESS__);
+ if ( $this->string_access->length === (int)0 )
+ throw new Exception(__CLASS__ . ' [ ERROR #6 ] :: the tag "' . self::__STRING_ACCESS__ . '" does not exist');
+ if ( $this->string_access->length !== (int)1 )
+ throw new Exception(__CLASS__ . ' [ ERROR #7 ] :: exists more of a tag "' . self::__STRING_ACCESS__ . '"');
+ $this->string_access = $this->string_access->item(0)->nodeValue;
+
+ $this->string_delimiter = $this->controller_security->item(0)->getElementsByTagName(self::__STRING_DELIMITER__);
+ ( $this->string_delimiter->length === (int)0 )
+ and die(__CLASS__ . ' [ ERROR #8 ] :: the tag "' . self::__STRING_DELIMITER__ . '" does not exist');
+ if ( $this->string_delimiter->length !== (int)1 )
+ throw new Exception(__CLASS__ . ' [ ERROR #9 ] :: exists more of a tag "' . self::__STRING_DELIMITER__ . '"');
+ $this->string_delimiter = $this->string_delimiter->item(0)->nodeValue;
+ }
+ catch(Exception $e)
+ {
+ $this->fatalError = true;
+ return $e->getMessage();
+ }
+ }
+
+ public function __call($name, $arguments)
+ {
+ if ( !$this->fatalError )
+ switch ( $name )
+ {
+ case 'exec' :
+ return $this->_exec($arguments[0]);
+ break;
+ default : return "Method not avaible";
+ }
+ }
+
+ public function __toString()
+ {
+ return __CLASS__;
+ }
+
+ private final function _exec(array &$pRequest)
+ {
+ ( $pRequest[$this->string_access] )
+ or die(__CLASS__ . ' [ ERROR #10 ] :: bad string action argument');
+
+ list($section_name, $ref, $alias) = explode($this->string_delimiter, $pRequest[$this->string_access]);
+ unset($pRequest[$this->string_access]);
+
+ $contents_itens = $this->controller_contentes->getElementsByTagName(self::__CONTROLLER_CONTENTES_ITEM__);
+
+ for ( $i = 0; $i < $contents_itens->length && $contents_itens->item($i)->getAttribute(self::__CONTROLLER_CONTENTES_ITEM_PARAM__) != $section_name; $i++ );
+ ( !($i < $contents_itens->length) )
+ and die(__CLASS__ . ' [ ERROR #11 ] :: invalid section "' . $section_name . '"');
+
+ $section_name = $contents_itens->item($i)->getAttribute(self::__CONTROLLER_CONTENTES_ITEM_SECTION__);
+
+ $section = $this->controller_sections->getElementsByTagName($section_name);
+ ( $section->length === (int)0 )
+ and die(__CLASS__ . ' [ ERROR #12 ] :: the tag "' . $section_name . '" does not exist');
+ ( $section->length === (int)1 )
+ or die(__CLASS__ . ' [ ERROR #13 ] :: exists more of a tag "' . $section_name . '"');
+ $section = $section->item(0);
+
+ $section_itens = $section->getElementsByTagName(self::__CONTROLLER_SECTIONS_ITEM__);
+
+ if ( empty($alias) && $alias !== '0' )
+ for ( $i = 0; $i < $section_itens->length && $section_itens->item($i)->getAttribute('ref') != $ref; $i++ );
+ else
+ for ( $i = 0; $i < $section_itens->length && ( $section_itens->item($i)->getAttribute('ref') != $ref || $section_itens->item($i)->getAttribute('alias') !== $alias); $i++ );
+
+ ( !($i < $section_itens->length) )
+ and die(__CLASS__ . ' [ ERROR #14 ] :: invalid reference "' . $ref . '"');
+
+ $path = $section_itens->item($i)->getAttribute('path')
+ or $path = $section->getAttribute('path')
+ or die(__CLASS__ . ' [ ERROR #15 ] :: bad path argument');
+
+ $prefix = $section_itens->item($i)->getAttribute('prefix')
+ or $prefix = $section->getAttribute('prefix');
+
+ $suffix = $section_itens->item($i)->getAttribute('suffix')
+ or $suffix = $section->getAttribute('suffix')
+ or die(__CLASS__ . ' [ ERROR #16 ] :: bad suffix argument');
+
+ return $this->$section_name(array("pSectionItem" => $section_itens->item($i), "pPath" => $path, "pPrefix" => $prefix, "pSuffix" => $suffix, "pRequest" => $pRequest));
+ }
+
+ private final function php()
+ {
+ $params = func_get_args();
+ extract($params[0]);
+
+ $class = $pSectionItem->getAttribute('class')
+ and $method = $pSectionItem->getAttribute('method')
+ or die(__CLASS__ . ' [ ERROR #17 ] :: bad class or method argument');
+
+ $file = "{$pPath}/{$pPrefix}{$class}{$pSuffix}";
+
+ file_exists($file)
+ or die(__CLASS__ . ' [ ERROR #18 ] :: the file that has the class was not opened');
+
+ require_once $file;
+
+ $obj = new ReflectionClass($class);
+
+ if ( $pRequest['classCostructor'] )
+ {
+ $obj = $obj->newInstance($pRequest['classCostructor']);
+ unset($pRequest['classCostructor']);
+ }
+ else
+ $obj = $obj->newInstance();
+
+ $method = new ReflectionMethod($class, $method);
+ $result = $method->invoke($obj, $pRequest);
+
+ #$obj = new $class;
+
+ #if ( $pRequest )
+ # $result = $obj -> $method($pRequest);
+ #else
+ # $result = $obj -> $method();
+
+ return $result;
+ }
+
+ private final function js()
+ {
+ $params = func_get_args();
+ extract($params[0]);
+
+ $js = $pSectionItem->getAttribute('js')
+ or die(__CLASS__ . ' [ ERROR #18 ] :: bad js argument');
+
+ $file = "{$pPath}/{$pPrefix}{$js}{$pSuffix}";
+
+ file_exists($file)
+ or die(__CLASS__ . ' [ ERROR #19 ] :: the file that has the class was not opened');
+
+ $debug = $pSectionItem->parentNode->getAttribute('debug');
+ if ( $debug && ($debug === 'true') )
+ return file_get_contents($file);
+
+ $packed_file = "{$pPath}/.packer.{$pPrefix}{$js}{$pSuffix}";
+
+ (
+ file_exists($packed_file)
+ and filemtime($packed_file) > filemtime($file)
+ and $packed = file_get_contents($packed_file)
+ )
+ or
+ (
+ $packer = new JavaScriptPacker(file_get_contents($file), 'High ASCII', true, true)
+ and $packed = $packer->pack()
+ and file_put_contents($packed_file, $packed)
+ );
+
+ return $packed;
+ }
+}
+
+class JavaScriptPacker
+{
+ const IGNORE = '$1';
+
+ private $_script = '';
+ private $_encoding = 62;
+ private $_fastDecode = true;
+ private $_specialChars = false;
+
+ private $_parsers = array();
+
+ private $LITERAL_ENCODING = array(
+ 'None' => 0,
+ 'Numeric' => 10,
+ 'Normal' => 62,
+ 'High ASCII' => 95
+ );
+
+ public function __construct ($pScript, $pEncoding = 62, $pFastDecode = true, $pSpecialChars = false)
+ {
+ $this->_script = $pScript . "\n";
+ if ( array_key_exists($pEncoding, $this->LITERAL_ENCODING) )
+ $pEncoding = $this->LITERAL_ENCODING[$pEncoding];
+
+ $this->_encoding = min((int)$pEncoding, 95);
+ $this->_fastDecode = $pFastDecode;
+ $this->_specialChars = $pSpecialChars;
+ }
+
+ public function pack()
+ {
+ $this->_addParser('_basicCompression');
+
+ if ( $this->_specialChars )
+ $this->_addParser('_encodeSpecialChars');
+
+ if ( $this->_encoding )
+ $this->_addParser('_encodeKeywords');
+
+ return $this->_pack($this->_script);
+ }
+
+ private function _pack($script)
+ {
+ for ( $i = 0; isset($this->_parsers[$i]); $i++ )
+ $script = call_user_func(array(&$this,$this->_parsers[$i]), $script);
+
+ return $script;
+ }
+
+ // keep a list of parsing functions, they'll be executed all at once
+ private function _addParser($parser)
+ {
+ $this->_parsers[] = $parser;
+ }
+
+ // zero encoding - just removal of white space and comments
+ private function _basicCompression($script)
+ {
+ $parser = new ParseMaster();
+ // make safe
+ $parser->escapeChar = '\\';
+ // protect strings
+ $parser->add('/\'[^\'\\n\\r]*\'/', self::IGNORE);
+ $parser->add('/"[^"\\n\\r]*"/', self::IGNORE);
+ // remove comments
+ $parser->add('/\\/\\/[^\\n\\r]*[\\n\\r]/', ' ');
+ $parser->add('/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\//', ' ');
+ // protect regular expressions
+ $parser->add('/\\s+(\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?)/', '$2'); // IGNORE
+ $parser->add('/[^\\w\\x24\\/\'"*)\\?:]\\/[^\\/\\n\\r\\*][^\\/\\n\\r]*\\/g?i?/', self::IGNORE);
+ // remove: ;;; doSomething();
+ if ($this->_specialChars) $parser->add('/;;;[^\\n\\r]+[\\n\\r]/');
+ // remove redundant semi-colons
+ $parser->add('/\\(;;\\)/', self::IGNORE); // protect for (;;) loops
+ $parser->add('/;+\\s*([};])/', '$2');
+ // apply the above
+ $script = $parser->exec($script);
+
+ // remove white-space
+ $parser->add('/(\\b|\\x24)\\s+(\\b|\\x24)/', '$2 $3');
+ $parser->add('/([+\\-])\\s+([+\\-])/', '$2 $3');
+ $parser->add('/\\s+/', '');
+ // done
+ return $parser->exec($script);
+ }
+
+ private function _encodeSpecialChars($script)
+ {
+ $parser = new ParseMaster();
+ // replace: $name -> n, $$name -> na
+ $parser->add('/((\\x24+)([a-zA-Z$_]+))(\\d*)/',
+ array('fn' => '_replace_name')
+ );
+ // replace: _name -> _0, double-underscore (__name) is ignored
+ $regexp = '/\\b_[A-Za-z\\d]\\w*/';
+ // build the word list
+ $keywords = $this->_analyze($script, $regexp, '_encodePrivate');
+ // quick ref
+ $encoded = $keywords['encoded'];
+
+ $parser->add($regexp,
+ array(
+ 'fn' => '_replace_encoded',
+ 'data' => $encoded
+ )
+ );
+ return $parser->exec($script);
+ }
+
+ private function _encodeKeywords($script) {
+ // escape high-ascii values already in the script (i.e. in strings)
+ if ($this->_encoding > 62)
+ $script = $this->_escape95($script);
+ // create the parser
+ $parser = new ParseMaster();
+ $encode = $this->_getEncoder($this->_encoding);
+ // for high-ascii, don't encode single character low-ascii
+ $regexp = ($this->_encoding > 62) ? '/\\w\\w+/' : '/\\w+/';
+ // build the word list
+ $keywords = $this->_analyze($script, $regexp, $encode);
+ $encoded = $keywords['encoded'];
+
+ // encode
+ $parser->add($regexp,
+ array(
+ 'fn' => '_replace_encoded',
+ 'data' => $encoded
+ )
+ );
+ if (empty($script)) return $script;
+ else {
+ //$res = $parser->exec($script);
+ //$res = $this->_bootStrap($res, $keywords);
+ //return $res;
+ return $this->_bootStrap($parser->exec($script), $keywords);
+ }
+ }
+
+ private function _analyze($script, $regexp, $encode) {
+ // analyse
+ // retreive all words in the script
+ $all = array();
+ preg_match_all($regexp, $script, $all);
+ $_sorted = array(); // list of words sorted by frequency
+ $_encoded = array(); // dictionary of word->encoding
+ $_protected = array(); // instances of "protected" words
+ $all = $all[0]; // simulate the javascript comportement of global match
+ if (!empty($all)) {
+ $unsorted = array(); // same list, not sorted
+ $protected = array(); // "protected" words (dictionary of word->"word")
+ $value = array(); // dictionary of charCode->encoding (eg. 256->ff)
+ $this->_count = array(); // word->count
+ $i = count($all); $j = 0; //$word = null;
+ // count the occurrences - used for sorting later
+ do {
+ --$i;
+ $word = '$' . $all[$i];
+ if (!isset($this->_count[$word])) {
+ $this->_count[$word] = 0;
+ $unsorted[$j] = $word;
+ // make a dictionary of all of the protected words in this script
+ // these are words that might be mistaken for encoding
+ //if (is_string($encode) && method_exists($this, $encode))
+ $values[$j] = call_user_func(array(&$this, $encode), $j);
+ $protected['$' . $values[$j]] = $j++;
+ }
+ // increment the word counter
+ $this->_count[$word]++;
+ } while ($i > 0);
+ // prepare to sort the word list, first we must protect
+ // words that are also used as codes. we assign them a code
+ // equivalent to the word itself.
+ // e.g. if "do" falls within our encoding range
+ // then we store keywords["do"] = "do";
+ // this avoids problems when decoding
+ $i = count($unsorted);
+ do {
+ $word = $unsorted[--$i];
+ if (isset($protected[$word]) /*!= null*/) {
+ $_sorted[$protected[$word]] = substr($word, 1);
+ $_protected[$protected[$word]] = true;
+ $this->_count[$word] = 0;
+ }
+ } while ($i);
+
+ // sort the words by frequency
+ // Note: the javascript and php version of sort can be different :
+ // in php manual, usort :
+ // " If two members compare as equal,
+ // their order in the sorted array is undefined."
+ // so the final packed script is different of the Dean's javascript version
+ // but equivalent.
+ // the ECMAscript standard does not guarantee this behaviour,
+ // and thus not all browsers (e.g. Mozilla versions dating back to at
+ // least 2003) respect this.
+ usort($unsorted, array(&$this, '_sortWords'));
+ $j = 0;
+ // because there are "protected" words in the list
+ // we must add the sorted words around them
+ do {
+ if (!isset($_sorted[$i]))
+ $_sorted[$i] = substr($unsorted[$j++], 1);
+ $_encoded[$_sorted[$i]] = $values[$i];
+ } while (++$i < count($unsorted));
+ }
+ return array(
+ 'sorted' => $_sorted,
+ 'encoded' => $_encoded,
+ 'protected' => $_protected);
+ }
+
+ private $_count = array();
+ private function _sortWords($match1, $match2) {
+ return $this->_count[$match2] - $this->_count[$match1];
+ }
+
+ // build the boot function used for loading and decoding
+ private function _bootStrap($packed, $keywords) {
+ $ENCODE = $this->_safeRegExp('$encode\\($count\\)');
+
+ // $packed: the packed script
+ $packed = "'" . $this->_escape($packed) . "'";
+
+ // $ascii: base for encoding
+ $ascii = min(count($keywords['sorted']), $this->_encoding);
+ if ($ascii == 0) $ascii = 1;
+
+ // $count: number of words contained in the script
+ $count = count($keywords['sorted']);
+
+ // $keywords: list of words contained in the script
+ foreach ($keywords['protected'] as $i=>$value) {
+ $keywords['sorted'][$i] = '';
+ }
+ // convert from a string to an array
+ ksort($keywords['sorted']);
+ $keywords = "'" . implode('|',$keywords['sorted']) . "'.split('|')";
+
+ $encode = ($this->_encoding > 62) ? '_encode95' : $this->_getEncoder($ascii);
+ $encode = $this->_getJSFunction($encode);
+ $encode = preg_replace('/_encoding/','$ascii', $encode);
+ $encode = preg_replace('/arguments\\.callee/','$encode', $encode);
+ $inline = '\\$count' . ($ascii > 10 ? '.toString(\\$ascii)' : '');
+
+ // $decode: code snippet to speed up decoding
+ if ($this->_fastDecode) {
+ // create the decoder
+ $decode = $this->_getJSFunction('_decodeBody');
+ if ($this->_encoding > 62)
+ $decode = preg_replace('/\\\\w/', '[\\xa1-\\xff]', $decode);
+ // perform the encoding inline for lower ascii values
+ elseif ($ascii < 36)
+ $decode = preg_replace($ENCODE, $inline, $decode);
+ // special case: when $count==0 there are no keywords. I want to keep
+ // the basic shape of the unpacking funcion so i'll frig the code...
+ if ($count == 0)
+ $decode = preg_replace($this->_safeRegExp('($count)\\s*=\\s*1'), '$1=0', $decode, 1);
+ }
+
+ // boot function
+ $unpack = $this->_getJSFunction('_unpack');
+ if ($this->_fastDecode) {
+ // insert the decoder
+ $this->buffer = $decode;
+ $unpack = preg_replace_callback('/\\{/', array(&$this, '_insertFastDecode'), $unpack, 1);
+ }
+ $unpack = preg_replace('/"/', "'", $unpack);
+ if ($this->_encoding > 62) { // high-ascii
+ // get rid of the word-boundaries for regexp matches
+ $unpack = preg_replace('/\'\\\\\\\\b\'\s*\\+|\\+\s*\'\\\\\\\\b\'/', '', $unpack);
+ }
+ if ($ascii > 36 || $this->_encoding > 62 || $this->_fastDecode) {
+ // insert the encode function
+ $this->buffer = $encode;
+ $unpack = preg_replace_callback('/\\{/', array(&$this, '_insertFastEncode'), $unpack, 1);
+ } else {
+ // perform the encoding inline
+ $unpack = preg_replace($ENCODE, $inline, $unpack);
+ }
+ // pack the boot function too
+ $unpackPacker = new JavaScriptPacker($unpack, 0, false, true);
+ $unpack = $unpackPacker->pack();
+
+ // arguments
+ $params = array($packed, $ascii, $count, $keywords);
+ if ($this->_fastDecode) {
+ $params[] = 0;
+ $params[] = '{}';
+ }
+ $params = implode(',', $params);
+
+ // the whole thing
+ return 'eval(' . $unpack . '(' . $params . "))\n";
+ }
+
+ private $buffer;
+ private function _insertFastDecode($match) {
+ return '{' . $this->buffer . ';';
+ }
+ private function _insertFastEncode($match) {
+ return '{$encode=' . $this->buffer . ';';
+ }
+
+ // mmm.. ..which one do i need ??
+ private function _getEncoder($ascii) {
+ return $ascii > 10 ? $ascii > 36 ? $ascii > 62 ?
+ '_encode95' : '_encode62' : '_encode36' : '_encode10';
+ }
+
+ // zero encoding
+ // characters: 0123456789
+ private function _encode10($charCode) {
+ return $charCode;
+ }
+
+ // inherent base36 support
+ // characters: 0123456789abcdefghijklmnopqrstuvwxyz
+ private function _encode36($charCode) {
+ return base_convert($charCode, 10, 36);
+ }
+
+ // hitch a ride on base36 and add the upper case alpha characters
+ // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
+ private function _encode62($charCode) {
+ $res = '';
+ if ($charCode >= $this->_encoding) {
+ $res = $this->_encode62((int)($charCode / $this->_encoding));
+ }
+ $charCode = $charCode % $this->_encoding;
+
+ if ($charCode > 35)
+ return $res . chr($charCode + 29);
+ else
+ return $res . base_convert($charCode, 10, 36);
+ }
+
+ // use high-ascii values
+ // characters: ¡¢£€¥Š§š©ª«¬Â®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÃÃÃÃÃÃ
+ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃà áâãÀåÊçÚéêëìÃîïðñòóÎõö÷ÞùúûÌÜß
+ private function _encode95($charCode) {
+ $res = '';
+ if ($charCode >= $this->_encoding)
+ $res = $this->_encode95($charCode / $this->_encoding);
+
+ return $res . chr(($charCode % $this->_encoding) + 161);
+ }
+
+ private function _safeRegExp($string) {
+ return '/'.preg_replace('/\$/', '\\\$', $string).'/';
+ }
+
+ private function _encodePrivate($charCode) {
+ return "_" . $charCode;
+ }
+
+ // protect characters used by the parser
+ private function _escape($script) {
+ return preg_replace('/([\\\\\'])/', '\\\$1', $script);
+ }
+
+ // protect high-ascii characters already in the script
+ private function _escape95($script) {
+ return preg_replace_callback(
+ '/[\\xa1-\\xff]/',
+ array(&$this, '_escape95Bis'),
+ $script
+ );
+ }
+ private function _escape95Bis($match) {
+ return '\x'.((string)dechex(ord($match)));
+ }
+
+
+ private function _getJSFunction($aName) {
+ if (defined('self::JSFUNCTION'.$aName))
+ return constant('self::JSFUNCTION'.$aName);
+ else
+ return '';
+ }
+
+ // JavaScript Functions used.
+ // Note : In Dean's version, these functions are converted
+ // with 'String(aFunctionName);'.
+ // This internal conversion complete the original code, ex :
+ // 'while (aBool) anAction();' is converted to
+ // 'while (aBool) { anAction(); }'.
+ // The JavaScript functions below are corrected.
+
+ // unpacking function - this is the boot strap function
+ // data extracted from this packing routine is passed to
+ // this function when decoded in the target
+ // NOTE ! : without the ';' final.
+ const JSFUNCTION_unpack =
+
+'function($packed, $ascii, $count, $keywords, $encode, $decode) {
+ while ($count--) {
+ if ($keywords[$count]) {
+ $packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]);
+ }
+ }
+ return $packed;
+}';
+/*
+'function($packed, $ascii, $count, $keywords, $encode, $decode) {
+ while ($count--)
+ if ($keywords[$count])
+ $packed = $packed.replace(new RegExp(\'\\\\b\' + $encode($count) + \'\\\\b\', \'g\'), $keywords[$count]);
+ return $packed;
+}';
+*/
+
+ // code-snippet inserted into the unpacker to speed up decoding
+ const JSFUNCTION_decodeBody =
+//_decode = function() {
+// does the browser support String.replace where the
+// replacement value is a function?
+
+' if (!\'\'.replace(/^/, String)) {
+ // decode all the values we need
+ while ($count--) {
+ $decode[$encode($count)] = $keywords[$count] || $encode($count);
+ }
+ // global replacement function
+ $keywords = [function ($encoded) {return $decode[$encoded]}];
+ // generic match
+ $encode = function () {return \'\\\\w+\'};
+ // reset the loop counter - we are now doing a global replace
+ $count = 1;
+ }
+';
+//};
+/*
+' if (!\'\'.replace(/^/, String)) {
+ // decode all the values we need
+ while ($count--) $decode[$encode($count)] = $keywords[$count] || $encode($count);
+ // global replacement function
+ $keywords = [function ($encoded) {return $decode[$encoded]}];
+ // generic match
+ $encode = function () {return\'\\\\w+\'};
+ // reset the loop counter - we are now doing a global replace
+ $count = 1;
+ }';
+*/
+
+ // zero encoding
+ // characters: 0123456789
+ const JSFUNCTION_encode10 =
+'function($charCode) {
+ return $charCode;
+}';//;';
+
+ // inherent base36 support
+ // characters: 0123456789abcdefghijklmnopqrstuvwxyz
+ const JSFUNCTION_encode36 =
+'function($charCode) {
+ return $charCode.toString(36);
+}';//;';
+
+ // hitch a ride on base36 and add the upper case alpha characters
+ // characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
+ const JSFUNCTION_encode62 =
+'function($charCode) {
+ return ($charCode < _encoding ? \'\' : arguments.callee(parseInt($charCode / _encoding))) +
+ (($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36));
+}';
+
+ // use high-ascii values
+ // characters: ¡¢£€¥Š§š©ª«¬Â®¯°±²³Žµ¶·ž¹º»ŒœŸ¿ÃÃÃÃÃÃ
+ÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃà áâãÀåÊçÚéêëìÃîïðñòóÎõö÷ÞùúûÌÜß
+ const JSFUNCTION_encode95 =
+'function($charCode) {
+ return ($charCode < _encoding ? \'\' : arguments.callee($charCode / _encoding)) +
+ String.fromCharCode($charCode % _encoding + 161);
+}';
+
+}
+
+
+class ParseMaster {
+ public $ignoreCase = false;
+ public $escapeChar = '';
+
+ // constants
+ const EXPRESSION = 0;
+ const REPLACEMENT = 1;
+ const LENGTH = 2;
+
+ // used to determine nesting levels
+ private $GROUPS = '/\\(/';//g
+ private $SUB_REPLACE = '/\\$\\d/';
+ private $INDEXED = '/^\\$\\d+$/';
+ private $TRIM = '/([\'"])\\1\\.(.*)\\.\\1\\1$/';
+ private $ESCAPE = '/\\\./';//g
+ private $QUOTE = '/\'/';
+ private $DELETED = '/\\x01[^\\x01]*\\x01/';//g
+
+ public function add($expression, $replacement = '') {
+ // count the number of sub-expressions
+ // - add one because each pattern is itself a sub-expression
+ $length = 1 + preg_match_all($this->GROUPS, $this->_internalEscape((string)$expression), $out);
+
+ // treat only strings $replacement
+ if (is_string($replacement)) {
+ // does the pattern deal with sub-expressions?
+ if (preg_match($this->SUB_REPLACE, $replacement)) {
+ // a simple lookup? (e.g. "$2")
+ if (preg_match($this->INDEXED, $replacement)) {
+ // store the index (used for fast retrieval of matched strings)
+ $replacement = (int)(substr($replacement, 1)) - 1;
+ } else { // a complicated lookup (e.g. "Hello $2 $1")
+ // build a function to do the lookup
+ $quote = preg_match($this->QUOTE, $this->_internalEscape($replacement))
+ ? '"' : "'";
+ $replacement = array(
+ 'fn' => '_backReferences',
+ 'data' => array(
+ 'replacement' => $replacement,
+ 'length' => $length,
+ 'quote' => $quote
+ )
+ );
+ }
+ }
+ }
+ // pass the modified arguments
+ if (!empty($expression)) $this->_add($expression, $replacement, $length);
+ else $this->_add('/^$/', $replacement, $length);
+ }
+
+ public function exec($string) {
+ // execute the global replacement
+ $this->_escaped = array();
+
+ // simulate the _patterns.toSTring of Dean
+ $regexp = '/';
+ foreach ($this->_patterns as $reg) {
+ $regexp .= '(' . substr($reg[self::EXPRESSION], 1, -1) . ')|';
+ }
+ $regexp = substr($regexp, 0, -1) . '/';
+ $regexp .= ($this->ignoreCase) ? 'i' : '';
+
+ $string = $this->_escape($string, $this->escapeChar);
+ $string = preg_replace_callback(
+ $regexp,
+ array(
+ &$this,
+ '_replacement'
+ ),
+ $string
+ );
+ $string = $this->_unescape($string, $this->escapeChar);
+
+ return preg_replace($this->DELETED, '', $string);
+ }
+
+ public function reset() {
+ // clear the patterns collection so that this object may be re-used
+ $this->_patterns = array();
+ }
+
+ // private
+ private $_escaped = array(); // escaped characters
+ private $_patterns = array(); // patterns stored by index
+
+ // create and add a new pattern to the patterns collection
+ private function _add() {
+ $arguments = func_get_args();
+ $this->_patterns[] = $arguments;
+ }
+
+ // this is the global replace function (it's quite complicated)
+ private function _replacement($arguments) {
+ if (empty($arguments)) return '';
+
+ $i = 1; $j = 0;
+ // loop through the patterns
+ while (isset($this->_patterns[$j])) {
+ $pattern = $this->_patterns[$j++];
+ // do we have a result?
+ if (isset($arguments[$i]) && ($arguments[$i] != '')) {
+ $replacement = $pattern[self::REPLACEMENT];
+
+ if (is_array($replacement) && isset($replacement['fn'])) {
+
+ if (isset($replacement['data'])) $this->buffer = $replacement['data'];
+ return call_user_func(array(&$this, $replacement['fn']), $arguments, $i);
+
+ } elseif (is_int($replacement)) {
+ return $arguments[$replacement + $i];
+
+ }
+ $delete = ($this->escapeChar == '' ||
+ strpos($arguments[$i], $this->escapeChar) === false)
+ ? '' : "\x01" . $arguments[$i] . "\x01";
+ return $delete . $replacement;
+
+ // skip over references to sub-expressions
+ } else {
+ $i += $pattern[self::LENGTH];
+ }
+ }
+ }
+
+ private function _backReferences($match, $offset) {
+ $replacement = $this->buffer['replacement'];
+ $quote = $this->buffer['quote'];
+ $i = $this->buffer['length'];
+ while ($i) {
+ $replacement = str_replace('$'.$i--, $match[$offset + $i], $replacement);
+ }
+ return $replacement;
+ }
+
+ private function _replace_name($match, $offset){
+ $length = strlen($match[$offset + 2]);
+ $start = $length - max($length - strlen($match[$offset + 3]), 0);
+ return substr($match[$offset + 1], $start, $length) . $match[$offset + 4];
+ }
+
+ private function _replace_encoded($match, $offset) {
+ return $this->buffer[$match[$offset]];
+ }
+
+
+ // php : we cannot pass additional data to preg_replace_callback,
+ // and we cannot use &$this in create_function, so let's go to lower level
+ private $buffer;
+
+ // encode escaped characters
+ private function _escape($string, $escapeChar) {
+ if ($escapeChar) {
+ $this->buffer = $escapeChar;
+ return preg_replace_callback(
+ '/\\' . $escapeChar . '(.)' .'/',
+ array(&$this, '_escapeBis'),
+ $string
+ );
+
+ } else {
+ return $string;
+ }
+ }
+ private function _escapeBis($match) {
+ $this->_escaped[] = $match[1];
+ return $this->buffer;
+ }
+
+ // decode escaped characters
+ private function _unescape($string, $escapeChar) {
+ if ($escapeChar) {
+ $regexp = '/'.'\\'.$escapeChar.'/';
+ $this->buffer = array('escapeChar'=> $escapeChar, 'i' => 0);
+ return preg_replace_callback
+ (
+ $regexp,
+ array(&$this, '_unescapeBis'),
+ $string
+ );
+
+ } else {
+ return $string;
+ }
+ }
+ private function _unescapeBis() {
+ if (!empty($this->_escaped[$this->buffer['i']])) {
+ $temp = $this->_escaped[$this->buffer['i']];
+ } else {
+ $temp = '';
+ }
+ $this->buffer['i']++;
+ return $this->buffer['escapeChar'] . $temp;
+ }
+
+ private function _internalEscape($string) {
+ return preg_replace($this->ESCAPE, '', $string);
+ }
+}
+
+?>
Index: tags/instant_messenger/inc/Jabber.abstract.php
===================================================================
--- tags/instant_messenger/inc/Jabber.abstract.php (revision 305)
+++ tags/instant_messenger/inc/Jabber.abstract.php (revision 305)
@@ -0,0 +1,340 @@
+open('tcp://' . $pWebjabber . ':' . $PORT, 1, 1)) )
+ throw new Exception('[connect] #2 can\'t access tcp://' . $pWebjabber . ':' . $PORT . '. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ $this->_socket = $socket;
+
+ //stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+
+ fwrite($socket, "{$USER}@{$SERVER}##{$pPassword}##{$pConnectionType}");
+
+ $return = fread($socket, 3);
+
+ if ( $return == "new" )
+ {
+ $xml = "";
+ $xml .= "write($xml) === false )
+ throw new Exception('[connect] #4 it isn\'t possible connect in the server because exists a client connected with same user. File: ' . __FILE__ . ' :: ' . __LINE__);
+ }
+
+ $this->_server = $SERVER;
+ $this->_username = $USER;
+ $this->_password = $pPassword;
+ $this->_resource = $RESOURCE;
+
+ return $return;
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ protected function connect($pUser = false, $pPassword = false, $pConnectionType = false, $pWebjabber = false )
+ {
+ try
+ {
+ $_connect = $this->_connect($pUser, $pPassword, $pConnectionType, $pWebjabber);
+
+ if ( !$_connect )
+ throw new Exception('[connect] #0. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ if ( $_connect == "new" )
+ {
+ if ( ($xml = $this->read()) === false )
+ throw new Exception('[connect] #1 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+
+ if ( preg_match('/( <\/starttls>)/', $xml, $matches) )
+ {
+ if ( !$this->starttls() )
+ throw new Exception('[connect] #2 it isn\'t possible start tls. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ # $this->writeLog('NOTICE', 'Connected TLS');
+ }
+ else
+ {
+ if ( !$this->_plain() )
+ throw new Exception('[connect] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__);
+ }
+ }
+
+ return $_connect;
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ $this->_disconnect();
+ return false;
+ }
+ }
+
+ protected final function _disconnect()
+ {
+ try
+ {
+ $xml = " ";
+
+ #if ( $this->write($xml) === false )
+ # throw new Exception('[disconnect] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ #if ( ($xml = $this->read()) === false )
+ # throw new Exception('[disconnect] #2 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__);
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ private final function starttls()
+ {
+ try
+ {
+ $xml = " ";
+ if ( $this->write($xml) === false )
+ throw new Exception('[starttls] #1 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ usleep(50000);
+ fread($this->_socket, 4096);
+
+ stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
+
+ $xml = "";
+ $xml .= "write($xml) === false )
+ throw new Exception('[starttls] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ usleep(50000);
+
+ fread($this->_socket, 4096);
+
+ usleep(50000);
+
+ fread($this->_socket, 4096);
+
+ if ( !$this->_plain() )
+ throw new Exception('[starttls] #3 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ return true;
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ private final function _plain()
+ {
+ try
+ {
+ $this->blocking($this->_socket, 0);
+
+ if ( ($xml = $this->read()) === false )
+ throw new Exception('[_plain] #1 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ $xml = "_username . "]]> ";
+ $xml .= "_password . "]]> ";
+ $xml .= "_resource . "]]> ";
+
+ unset($this->_password);
+
+ if ( !$this->iq('set', 'auth_1', NULL, NULL, "jabber:iq:auth", $xml) )
+ throw new Exception('[_plain] #2 it isn\'t possible carry out the verification. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ while ( !preg_match("/read()), $matches) )
+ usleep(10000);
+
+ if($matches[1] == "error")
+ return false;
+
+ if ( ($xml = $this->read()) === false )
+ throw new Exception('[_plain] #3 it isn\'t possible read the socket. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ return true;
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ private final function _iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false )
+ {
+ $xml = "" . $pLoad . "" : "/>";
+ }
+
+ $xml .= " ";
+
+ return $xml;
+ }
+
+ protected final function iq($pType = false, $pId = false, $pTo = false, $pFrom = false, $pXmlns = false, $pLoad = false)
+ {
+ try
+ {
+ if ( !preg_match("/^(get|set|result|error)$/i", $pType, $matches) )
+ throw new Exception('[iq] #1 type must be GET, SET, RESULT or ERROR. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ if ( $this->write($this->_iq($pType, $pId, $pTo, $pFrom, $pXmlns, $pLoad)) === false )
+ throw new Exception('[iq] #2 Cannot write to socket (' . $this->_socket . '). File: ' . __FILE__ . ' :: ' . __LINE__);
+ else
+ return true;
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ protected final function presence($pType = false, $pTo = false, $pShow = false, $pStatus = false, $pPriority = false)
+ {
+ try
+ {
+ $xml = "" . $pStatus . "" : '';
+ $xml .= ($pShow) ? "" . $pShow . " " : '';
+ $xml .= ($pPriority) ? "" . $pPriority . " " : '';
+ $xml .= ($pStatus || $pShow || $pPriority) ? " " : '';
+ }
+
+ if ( $this->write($xml) === false )
+ throw new Exception('[presence] #1 it isn\'t possible send presence for ' . $this->_server . '. File: ' . __FILE__ . ' :: ' . __LINE__);
+
+ return true;
+ }
+ catch(Exception $e)
+ {
+ $this->writeLog('ERROR', $e->getMessage());
+ return false;
+ }
+ }
+
+ protected final function read()
+ {
+ $return = NULL;
+ do
+ {
+ $line = NULL;
+ $line = utf8_decode(parent::read($this->_socket, 4096));
+
+ if ( $line === false )
+ {
+ $return = false;
+ break;
+ }
+
+ if ( $line != NULL )
+ $return .= $line;// . "\n";
+ }
+ while ( $line != NULL );
+
+ return $return;
+ }
+
+ protected final function write($pData = false)
+ {
+ if ( !$pData )
+ return false;
+
+ return parent::write($this->_socket, utf8_encode($pData));
+ }
+
+ function __destruct()
+ {
+ $this->close($this->_socket);
+ }
+
+ protected final function writeLog($pType = false, $pLog = false)
+ {
+ if ( !defined('self::'.$pType) && !$pLog )
+ return false;
+
+ if ( !(bool)constant('self::J_'.$pType) && !(bool)constant('self::J_ALL') )
+ return false;
+
+ $log = date('m/d/Y H:i:s');
+ $log .= ' [' . constant('self::'.$pType) . '] :: ';
+ $log .= $pLog . "\n";
+ if ( $fp = fopen (self::J_FILE, "a+") )
+ {
+ fwrite($fp, $log);
+ fclose($fp);
+ }
+ }
+}
+?>
Index: tags/instant_messenger/iframe.htm
===================================================================
--- tags/instant_messenger/iframe.htm (revision 305)
+++ tags/instant_messenger/iframe.htm (revision 305)
@@ -0,0 +1,6 @@
+
+
+
+
+
+
Index: tags/instant_messenger/js/images.js
===================================================================
--- tags/instant_messenger/js/images.js (revision 318)
+++ tags/instant_messenger/js/images.js (revision 318)
@@ -0,0 +1,77 @@
+// Images IM
+ var im_available = new Image();
+ im_available.src = path_im + 'templates/default/images/available.gif';
+
+ var im_away = new Image();
+ im_away.src = path_im + 'templates/default/images/away.gif';
+
+ var im_chat = new Image();
+ im_chat.src = path_im + 'templates/default/images/chat.gif';
+
+ var im_dnd = new Image();
+ im_dnd.src = path_im + 'templates/default/images/dnd.gif';
+
+ var im_xa = new Image();
+ im_xa.src = path_im + 'templates/default/images/xa.gif';
+
+ var im_unavailable = new Image();
+ im_unavailable.src = path_im + 'templates/default/images/unavailable.gif';
+
+ var im_fast_menu = new Image();
+ im_fast_menu.src = path_im + 'templates/default/images/menuarwopen.gif';
+
+ var im_photo = new Image();
+ im_photo.src = path_im + 'templates/default/images/photo.png';
+
+ var im_photo_1 = new Image();
+ im_photo_1.src = path_im + 'templates/default/images/photo_1.png';
+
+ var im_group_open = new Image();
+ im_group_open.src = path_im + 'templates/default/images/group_open.gif';
+
+ var im_group_close = new Image();
+ im_group_close.src = path_im + 'templates/default/images/group_close.gif';
+
+ var im_console_prefs = new Image();
+ im_console_prefs.src = path_im + 'templates/default/images/console_prefs2.png';
+
+ var im_composing = new Image();
+ im_composing.src = path_im + 'templates/default/images/typing.gif';
+
+// Smiles
+
+ var smile_1 = new Image();
+ smile_1.src = path_im + "templates/default/images/smiles/1.gif";
+
+ var smile_2 = new Image();
+ smile_2.src = path_im + "templates/default/images/smiles/2.gif";
+
+ var smile_3 = new Image();
+ smile_3.src = path_im + "templates/default/images/smiles/3.gif";
+
+ var smile_4 = new Image();
+ smile_4.src = path_im + "templates/default/images/smiles/4.gif";
+
+ var smile_5 = new Image();
+ smile_5.src = path_im + "templates/default/images/smiles/5.gif";
+
+ var smile_6 = new Image();
+ smile_6.src = path_im + "templates/default/images/smiles/6.gif";
+
+ var smile_7 = new Image();
+ smile_7.src = path_im + "templates/default/images/smiles/7.gif";
+
+ var smile_8 = new Image();
+ smile_8.src = path_im + "templates/default/images/smiles/8.gif";
+
+ var smile_9 = new Image();
+ smile_9.src = path_im + "templates/default/images/smiles/9.gif";
+
+ var smile_10 = new Image();
+ smile_10.src = path_im + "templates/default/images/smiles/10.gif";
+
+ var smile_11 = new Image();
+ smile_11.src = path_im + "templates/default/images/smiles/11.gif";
+
+ var smile_12 = new Image();
+ smile_12.src = path_im + "templates/default/images/smiles/12.gif";
Index: tags/instant_messenger/js/jabber.js
===================================================================
--- tags/instant_messenger/js/jabber.js (revision 337)
+++ tags/instant_messenger/js/jabber.js (revision 337)
@@ -0,0 +1,841 @@
+(function()
+{
+ var _conn;
+ var _xtools;
+ var _window;
+ var _ldap;
+ var _menu;
+ var _cookies;
+
+ var _vcards = [];
+ var _info = [];
+ var _chats = [];
+
+ var _win_position = 0;
+
+ function _next_position()
+ {
+ if ( _win_position > 200 )
+ _win_position = 0;
+ return (_win_position += 30);
+ }
+
+ function _chat(_pJid)
+ {
+ if ( !_chats[_pJid] )
+ _chats[_pJid] = [];
+
+ var _win_pos = _next_position();
+ var _win_chat = _window.load('chat' + _pJid);
+ _win_chat.title('.::Expresso Messenger::.');
+ _win_chat.size(310);
+ _win_chat.content(_xtools.parse('chat.xsl'));
+ _win_chat.position(_win_pos, _win_pos);
+ _win_chat.wc.style.padding = "3px";
+ _win_chat.bz.style.display = 'none';
+
+ _ldap.photo(
+ _pJid.substr(0,_pJid.indexOf('@')),
+ _win_chat.wc.childNodes[2]
+ );
+
+ var _iframe = top.document.createElement('iframe');
+ _iframe.id = 'iframe_' + _pJid;
+
+ _win_chat.wc.childNodes[2].appendChild(_iframe);
+
+ _iframe.style.width = '250px';
+ _iframe.style.height = '100%';
+ _iframe.style.border = '0';
+ _iframe.style.margin = '0';
+
+ var _contentWindow = _iframe.contentWindow;
+
+ _iframe = _contentWindow.document;
+ _iframe.write('');
+ _iframe.close();
+ _iframe.designMode = "On";
+
+ _contentWindow.focus();
+
+ _config(
+ _win_chat.wc.childNodes[1].childNodes[5],
+ 'onclick',
+ function()
+ {
+ _info[_pJid] = true;
+ _vcard(_pJid);
+ }
+ );
+
+ _config(
+ _win_chat.wc.childNodes[1].lastChild.previousSibling,
+ 'onclick',
+ function()
+ {
+ _sendMessage(
+ _pJid,
+ _iframe,
+ _win_chat.wc.firstChild
+ );
+ _iframe.body.innerHTML = '';
+ _contentWindow.focus();
+ }
+ );
+
+ var _composing_paused = null;
+ function _execKeyAction(e)
+ {
+ if ( e.type.indexOf('keydown') != -1 )
+ {
+ if ( (e.keyCode > 48 && e.keyCode < 112) || e.keyCode > 186 )
+ {
+ if ( _chats[_pJid]['composing_paused'] )
+ {
+ clearTimeout(_chats[_pJid]['composing_paused']);
+ _chats[_pJid]['composing_paused'] = null;
+ }
+ else
+ _conn.go('t.composing','jid='+_pJid);
+
+ _chats[_pJid]['composing_paused'] = setTimeout(
+ function()
+ {
+ if ( _chats[_pJid]['composing_paused'] )
+ {
+ clearTimeout(_chats[_pJid]['composing_paused']);
+ _chats[_pJid]['composing_paused'] = null;
+ }
+ _conn.go('t.paused','jid='+_pJid);
+ }, 5000);
+ }
+ }
+ switch ( e.keyCode )
+ {
+ case 13 :
+ if ( !(e.shiftKey) )
+ {
+ if ( e.type.indexOf('keydown') != -1 )
+ {
+ if ( _chats[_pJid]['composing_paused'] )
+ {
+ clearTimeout(_chats[_pJid]['composing_paused']);
+ _chats[_pJid]['composing_paused'] = null;
+ }
+
+ _sendMessage(
+ _pJid,
+ _iframe,
+ _win_chat.wc.firstChild
+ );
+ }
+ else
+ _iframe.body.innerHTML = '';
+
+ return false;
+ }
+ break;
+ case 27 :
+ if ( e.type.indexOf('keyup') != -1 )
+ {
+ if ( _chats[_pJid]['composing_paused'] )
+ {
+ clearTimeout(_chats[_pJid]['composing_paused']);
+ _chats[_pJid]['composing_paused'] = null;
+ }
+ _win_chat.button(_win_chat.bc);
+ }
+ break;
+ }
+ }
+ _config(_contentWindow.document, 'onkeyup', _execKeyAction);
+ _config(_contentWindow.document, 'onkeydown', _execKeyAction);
+
+ if ( !(_vcards[_pJid]) )
+ _conn.go('$this.Ujabber.getVcard','jid='+_pJid);
+ else
+ _readVCard(_vcards[_pJid]);
+
+ return _win_chat;
+ }
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ function _openChat(el)
+ {
+ var id = el.getAttribute('jid');
+
+ if ( id.indexOf('/') > -1 )
+ id = id.substr(0, id.indexOf('/'));
+
+ var _win = _window.get('chat' + id);
+ if ( !_win )
+ {
+ _win = _chat(id);
+ _win.title(el.getAttribute('idname'));
+ if ( el.getAttribute('status') )
+ _win.icon(eval('im_' + el.getAttribute('status') + '.src'));
+ }
+ else
+ {
+ _win.wm.style.display = 'block';
+ _win.focus();
+ _win.wc.childNodes[2].firstChild.contentWindow.focus();
+ }
+ }
+
+ function _readContacts(_pContacts)
+ {
+ var _win_contact = _window.get('contact_list');
+ if ( !_win_contact )
+ {
+ _win_contact = _window.load('contact_list');
+ _win_contact.hidden();
+ _win_contact.title('.::Expresso Messenger::.');
+ _win_contact.size(170, 350);
+ _win_contact.position(30, 30, true);
+ _win_contact.icon(im_unavailable.src);
+ _win_contact.bc.style.display = 'none';
+ }
+
+ var _params = {
+ 'lang1':imGetLang('nickname'),
+ 'lang2':imGetLang('add contact'),
+ 'lang3':imGetLang('preferences'),
+ 'nickname':imGetLang('username')
+ };
+ _win_contact.content(
+ _xtools.parse(_xtools.xml('layer'),'layer.xsl', _params)
+ + _xtools.parse(_pContacts, 'contacts.xsl', {'path':path_im})
+ );
+
+ _config(_win_contact.wc.firstChild.childNodes[5], 'onclick', _ldap.add);
+
+ var _contact_list = top.document.getElementById('im_contact_list');
+ if ( _contact_list )
+ {
+ var _presence;
+ if ( !(_presence = _cookies.get('IM_presence')) )
+ _presence = 'available';
+
+ var _img_status = eval('im_' + _presence + '.src');
+
+ if ( _img_status )
+ {
+ _win_contact.icon(_img_status);
+
+ var _status = top.document.getElementById('im_status');
+ if ( _status )
+ _status.style.backgroundImage = 'url(' + _img_status + ')';
+ }
+
+ _ldap.photo('im_avatar', _win_contact.wc.firstChild);
+
+ function _click(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ if ( (e.button == 0 && !document.all) || (e.button == 1 && document.all) )
+ _openChat(el);
+ else
+ {
+ var _options = [
+ imGetLang("Nickname"),
+ imGetLang("Group"),
+ imGetLang("Remove"),
+ imGetLang("It requisition permission"),
+ imGetLang("See Info")
+ ];
+
+ var _style_text = 'background: no-repeat url(' + path_im
+ + 'templates/default/images/group_close.gif);'
+ + 'padding:2px 4px 2px 16px;';
+
+ var _xml = _xtools.xml('menu');
+ var _option;
+ var _item;
+ var _action;
+ var _style;
+
+ for ( var i in _options )
+ {
+ _option = _xml.createElement('option');
+
+ _item = _xml.createElement('item');
+ _item.appendChild(_xml.createTextNode(_options[i]));
+
+ _style = _xml.createElement('style');
+ _style.appendChild(_xml.createTextNode(_style_text));
+
+ _option.appendChild(_item);
+ _option.appendChild(_style);
+
+ _xml.documentElement.appendChild(_option);
+ }
+
+ var _sub_menu = top.document.getElementById('sub_' + el.getAttribute('jid'));
+ _sub_menu.innerHTML = _xtools.parse(_xml, 'options.xsl');
+
+ _menu.action('onmouseover', 'onmouseout', _sub_menu);
+
+ _sub_menu = _sub_menu.firstChild;
+ _sub_menu.childNodes[0].style.display = 'none';
+ _sub_menu.childNodes[1].style.display = 'none';
+ _sub_menu.childNodes[3].style.display = 'none';
+ _config(
+ _sub_menu.childNodes[2],
+ 'onclick',
+ function(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ var jid = el.parentNode.parentNode.id.substr(4);
+ var _contact = el.parentNode.parentNode.previousSibling;
+ _contact.parentNode.removeChild(_contact.nextSibling);
+ _contact.parentNode.removeChild(_contact);
+ _conn.go('$this.Ujabber.removeContact','jid='+jid);
+ }
+ );
+ _config(
+ _sub_menu.childNodes[4],
+ 'onclick',
+ function()
+ {
+ _info[el.getAttribute('jid')] = true;
+ _vcard(el.getAttribute('jid'));
+ }
+ );
+ }
+ }
+ function _show_hidden_group(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ var _display = "none";
+ var _image = im_group_close.src;
+
+ if ( el.style.backgroundImage.indexOf('group_open') < 0 )
+ {
+ _display = "block";
+ _image = im_group_open.src;
+ }
+
+ el.style.backgroundImage = 'url(' + _image + ')';
+
+ el = el.nextSibling;
+ while ( el.getAttribute('jid') )
+ {
+ if ( _display == 'block' )
+ {
+ var _show_all = _cookies.get('IM_unavailable');
+ if ( (el.style.backgroundImage.indexOf('unavailable') > -1) && (_show_all == 'hidden') )
+ _display = 'none';
+ }
+ el.style.display = _display;
+ el = el.nextSibling;
+ if ( el && el.nextSibling )
+ el = el.nextSibling;
+ }
+ }
+ function _hover(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ var color = "#fff";
+ if ( e.type.indexOf('mouseover') != -1 )
+ color = "#b4cfe5";
+ el.style.backgroundColor = color;
+ }
+ var _contact = _contact_list.firstChild;
+ var _show_all = _cookies.get('IM_unavailable');
+ while ( _contact )
+ {
+ if ( _contact.nodeName.toLowerCase() == 'div' )
+ {
+ _config(_contact, 'onmouseover', _hover);
+ _config(_contact, 'onmouseout', _hover);
+ // it is a group
+ if ( !(_contact.getAttribute('jid')) )
+ _config(_contact, 'onclick', _show_hidden_group);
+ // it is a contact
+ else
+ {
+ if ( _show_all != 'hidden' )
+ _contact.style.display = 'block';
+ _config(_contact, 'onmouseup', _click);
+ }
+ }
+ _contact = _contact.nextSibling;
+ }
+ }
+ }
+
+ function _setPresence()
+ {
+ if ( !(_cookies) )
+ return false;
+
+ var _presence = false;
+ var _pPresence;
+ if ( arguments.length == 0 )
+ {
+ if ( !(_pPresence = _cookies.get('IM_presence')) )
+ _pPresence = 'available';
+ }
+ else
+ _pPresence = arguments[0];
+
+ if ( _pPresence == 'auto' )
+ {
+ if ( _cookies.get('IM_presence') == 'available' )
+ _pPresence = 'xa';
+ }
+ else
+ _cookies.set('IM_presence', _pPresence);
+
+ switch ( _pPresence )
+ {
+ case 'away':
+ case 'dnd':
+ case 'xa':
+ _presence = 'show=' + _pPresence;
+ break;
+ case 'available':
+ case 'unavailable':
+ _presence = 'type=' + _pPresence;
+ break;
+ }
+
+ if ( _presence )
+ {
+ var _img_status = eval('im_' + _pPresence + '.src');
+
+ var _status = top.document.getElementById('im_status');
+ if ( _status )
+ _status.style.backgroundImage = 'url(' + _img_status + ')';
+
+ var _win_contacts = _window.get('contact_list');
+ if ( _win_contacts )
+ _win_contacts.icon(_img_status);
+
+ _conn.go('$this.Ujabber.setPresence', _presence);
+ }
+ }
+
+ function _vcard(_pJid)
+ {
+ var _win_vcard;
+ if ( !(_win_vcard = _window.get('vcard_' + _pJid)) )
+ {
+ var _win_pos = _next_position();
+
+ _win_vcard = _window.load('vcard_' + _pJid);
+ _win_vcard.title('.:: ' + imGetLang('Information Contacts') + ' ::.');
+ _win_vcard.size(300);
+ _win_vcard.position(_win_pos, _win_pos);
+
+ _win_vcard.wc.style.padding = "3px";
+ _win_vcard.bx.style.display = "none";
+ }
+ else
+ _win_vcard.focus();
+
+ if ( _vcards[_pJid] )
+ {
+ if ( _info[_pJid] )
+ delete _info[_pJid];
+
+ var _params = {
+ 'fullname' : imGetLang('Full Name'),
+ 'nickname' : imGetLang('Nickname'),
+ 'organization' : imGetLang('Organization'),
+ 'sector' : imGetLang('Sector'),
+ 'role' : imGetLang('Role'),
+ 'birthday' : imGetLang('Birthday')
+ };
+
+ _win_vcard.content(
+ _xtools.parse(
+ _vcards[_pJid],
+ 'vcard_contacts.xsl',
+ _params
+ )
+ );
+ }
+ else
+ {
+ _win_vcard.loading();
+ _conn.go('$this.Ujabber.getVcard', 'jid='+_pJid);
+ }
+ }
+
+ function _readVCard(_pVCard)
+ {
+ _vcards[_pVCard.getAttribute('from')] = _pVCard;
+
+ switch ( _pVCard.getAttribute('id') )
+ {
+ case "vCard_user" :
+ var _layer_nickname = top.document.getElementById('im_layer_nickname');
+ var _nickname = _pVCard.getElementsByTagName('NICKNAME');
+
+ if ( _nickname.length && _layer_nickname )
+ _layer_nickname.innerHTML = _nickname[0].firstChild.nodeValue;
+ break;
+ case "vCard" :
+ if ( _info[_pVCard.getAttribute('from')] )
+ _vcard(_pVCard.getAttribute('from'));
+ break;
+ }
+ }
+
+ function _readIq(pIq)
+ {
+ switch ( pIq.getAttribute('id') )
+ {
+ case 'contacts' :
+ _readContacts(pIq);
+ break;
+ case 'vCard' :
+ case 'vCard_user' :
+ _readVCard(pIq);
+ break;
+ case 'last_time_user' :
+ _readLastTimeUser(pIq);
+ break;
+ default : //alert('readIq : ' + pIq.getAttribute('id'));
+ }
+ }
+
+ function _readLastTimeUser(pIq)
+ {
+ if ( pIq.firstChild.getAttribute("seconds") != 0 )
+ _conn.go('t.update');
+ }
+
+ function _readMessage(_pMessage)
+ {
+ var _from = _pMessage.getAttribute('from');
+
+ if ( _from.indexOf('/') > -1 )
+ _from = _from.substr(0, _from.indexOf('/'));
+
+ var _contact_list = top.document.getElementById('contact_' + _from);
+
+ var _win = _window.get('chat' + _from);
+
+ if ( _contact_list && _pMessage.getElementsByTagName('composing').length > 0 )
+ {
+ _contact_list.style.backgroundImage = 'url(' + im_composing.src + ')';
+ setTimeout(function()
+ {
+ _contact_list.style.backgroundImage = 'url(' + eval('im_' + _contact_list.getAttribute('status') + '.src') + ')';
+ }, 10000);
+ }
+
+ if ( _win && _pMessage.getElementsByTagName('composing').length > 0 )
+ {
+ _win.wc.childNodes[1].lastChild.style.display = 'block';
+ setTimeout(function(){_win.wc.childNodes[1].lastChild.style.display = 'none';}, 10000);
+ }
+
+ if ( _pMessage.getElementsByTagName('body').length > 0 )
+ {
+ if ( !_win )
+ {
+ _win = _chat(_from);
+ var _st = top.document.getElementById('contact_' + _from);
+ if ( _st )
+ {
+ _st = eval('im_' + _st.getAttribute('status') + '.src');
+ _win.icon(_st);
+ }
+ }
+ _win.show();
+
+ var _nickname;
+ if ( _vcards[_from] )
+ {
+ _nickname = _vcards[_from].getElementsByTagName('NICKNAME');
+ if ( _nickname.length )
+ _nickname = _nickname[0].firstChild.nodeValue;
+ else
+ _nickname = _from;
+ }
+ else
+ _nickname = _from;
+
+ var _msg = _xtools.parse(_pMessage, 'message_new.xsl', {'nickname':_nickname,'time':Date().substr(16,5)});
+
+ var _history = _win.wc.firstChild;
+ if ( _history.scrollHeight == (_history.scrollTop + _history.clientHeight) )
+ {
+ _history.innerHTML += _msg;
+ _history.scrollTop = _history.scrollHeight;
+ }
+ else
+ // this "else" is to prevent the creation of a flag and the need to use another conditional
+ _history.innerHTML += _msg;
+
+ _win.wc.childNodes[1].lastChild.style.display = 'none';
+ if ( _contact_list )
+ _contact_list.style.backgroundImage = 'url(' + eval('im_' + _contact_list.getAttribute('status') + '.src') + ')';
+ }
+
+ if ( _contact_list && _pMessage.getElementsByTagName('paused').length > 0 )
+ _contact_list.style.backgroundImage = 'url(' + eval('im_' + _contact_list.getAttribute('status') + '.src') + ')';
+
+ if ( _win && _pMessage.getElementsByTagName('paused').length > 0 )
+ _win.wc.childNodes[1].lastChild.style.display = 'none';
+ }
+
+ function _readPresence(_pPresence)
+ {
+ var _from = _pPresence.getAttribute('from');
+ if ( _from.indexOf('/') > -1 )
+ _from = _from.substr(0, _from.indexOf('/'));
+
+ var _presence_type = _pPresence.getAttribute('type');
+ var _img_status_contact = top.document.getElementById('contact_' + _from);
+ var _mensagem_status_contact = top.document.getElementById('status_' + _from);
+ var _win_chat = _window.get('chat' + _from);
+
+ if ( _mensagem_status_contact )
+ {
+ _mensagem_status_contact.innerHTML = '';
+ _mensagem_status_contact.style.display = 'none';
+ }
+
+ if ( _presence_type )
+ {
+ switch( _presence_type )
+ {
+ case 'available' :
+ case 'unavailable' :
+ _img_status_contact.setAttribute('status', _presence_type);
+
+ if ( _img_status_contact )
+ _img_status_contact.style.backgroundImage = 'url(' + eval('im_' + _presence_type + '.src') + ')';
+ if ( _win_chat )
+ _win_chat.icon(eval('im_' + _presence_type + '.src'));
+ if ( _presence_type == 'unavailable' )
+ {
+ var _show_all = _cookies.get('IM_unavailable');
+ if ( _show_all == 'hidden' )
+ _img_status_contact.style.display = 'none';
+ }
+ else
+ _img_status_contact.style.display = 'block';
+ break;
+ case 'subscribe' :
+ if ( top.document.getElementById('contact_' + _from) )
+ {
+ _conn.go('$this.Ujabber.subscription', 'jid=' + _from + '&type=subscribed' );
+ }
+ else
+ {
+ if ( !_window.get('subscription' + _from) )
+ {
+ var _win_pos = _next_position();
+ var _win_subscription = _window.load('subscription' + _from);
+ _win_subscription.title('.::Expresso Messenger::.');
+ _win_subscription.position(_win_pos, _win_pos);
+ _win_subscription.size(200);
+ _win_subscription.wc.style.padding = "3px";
+ _win_subscription.bc.style.display = 'none';
+ _win_subscription.bx.style.display = 'none';
+ _win_subscription.bz.style.display = 'none';
+
+ var _params = {
+ 'jid' : _from,
+ 'lang1' : 'deseja adiciona-lo como contato.',
+ 'lang2' : imGetLang('nickname'),
+ 'lang3' : imGetLang('group'),
+ 'lang4' : imGetLang('allow'),
+ 'lang5' : imGetLang('deny')
+ };
+
+ _win_subscription.content(
+ _xtools.parse(_xtools.xml('subscribe'), 'subscribe.xsl', _params)
+ );
+
+ _win_subscription.wc.childNodes[2].style.margin = '5px';
+ _win_subscription.wc.childNodes[3].style.margin = '5px';
+
+ _config(
+ _win_subscription.wc.childNodes[2],
+ 'onclick',
+ function()
+ {
+ _win_subscription.wc.childNodes[1].style.display = 'block';
+ _win_subscription.size(450);
+ _config(
+ _win_subscription.wc.childNodes[2],
+ 'onclick',
+ function()
+ {
+
+ var _status = top.document.getElementById('im_status_add_' + _from);
+ var _name = top.document.getElementById('im_name_' + _from);
+ var _group = top.document.getElementById('im_group_' + _from);
+
+ _name.value = _name.value.replace(/^( )*|( )*$/g, '');
+ _group.value = _group.value.replace(/^( )*|( )*$/g, '');
+
+ if ( !(_name.value) || !(_group.value) )
+ {
+ _status.innerHTML = ' O campo destacado em vermelho é obrigatório! ';
+
+ if ( !(_name.value) )
+ {
+ _name.previousSibling.style.color = "#f00";
+ _status.innerHTML += ' ** Informe um "NOME" para o contato.';
+ }
+
+ if ( !(_group.value) )
+ {
+ _group.previousSibling.style.color = "#f00";
+ _status.innerHTML += ' ** Informe um "GRUPO" para o contato.';
+ }
+ }
+ else
+ {
+ _status.innerHTML = ' Adicionado contanto, aguarde. ';
+
+ _conn.go(
+ '$this.Ujabber.allowContact',
+ function()
+ {
+ _status.innerHTML = ' Contato autorizado com "SUCESSO"! ';
+ _win_subscription.button(_win_subscription.bc);
+ },
+ 'uid='+_from.substr(0,_from.indexOf('@'))+'&name='+_name.value+'&group='+_group.value
+ );
+
+ _name.value = '';
+ _group.value = '';
+ }
+ }
+ );
+ }
+ );
+ }
+ }
+ break;
+ case 'unsubscribe' :
+ case 'unsubscribed' :
+ _conn.go('$this.Ujabber.removeContact','jid=' + _from);
+ break;
+ default : //alert('readPresence : ' + _presence_type);
+ }
+ }
+ else
+ {
+ var _node = _pPresence.firstChild;
+ while( _node )
+ {
+ if ( _node.hasChildNodes() )
+ {
+ _img_status_contact.style.display = 'block';
+ switch ( _node.nodeName )
+ {
+ case "show" :
+ var _show = _node.firstChild.nodeValue;
+ _img_status_contact.setAttribute('status', _show);
+ if ( _img_status_contact )
+ _img_status_contact.style.backgroundImage = 'url(' + eval('im_' + _show + '.src') + ')';
+ if ( _win_chat )
+ _win_chat.icon(eval('im_' + _show + '.src'));
+ break;
+ case "status" :
+ if ( _mensagem_status_contact )
+ {
+ if ( _node.firstChild.nodeValue )
+ _mensagem_status_contact.innerHTML = _node.firstChild.nodeValue;
+ _mensagem_status_contact.style.display = 'block';
+ }
+ break;
+ default :
+ _img_status_contact.setAttribute('status', 'available');
+ if ( _img_status_contact )
+ _img_status_contact.style.backgroundImage = 'url(' + im_available.src + ')';
+ if ( _win_chat )
+ _win_chat.icon(im_available.src);
+ }
+ }
+ _node = _node.nextSibling;
+ }
+ }
+ }
+
+ function _sendMessage(_pJid, _pMessage, _pHistory)
+ {
+ var m1 = _pMessage = _pMessage.body.innerHTML;
+ var m2 = _pMessage = _pMessage.replace(/( )+|( )+/ig, ' ');
+ var m3 = _pMessage = _pMessage.replace(/( ]*>)+/ig, ' ');
+ var m4 = _pMessage = _pMessage.replace(/^( )+|( )+$|^( )|( )$/g, '');
+
+ //_pMessage = _pMessage.replace(/( )+( ]*>)+/g, ' ');
+ //_pMessage = _pMessage.replace(/( ]*>)*( )+( ]*>)+/g, '');
+ //_pMessage = _pMessage.replace(/^( ]*>)*|( ]*>)*$/g, '');
+
+ if ( _pMessage != '' )
+ {
+ _conn.go('$this.Ujabber.sendMessage', "to=" + _pJid + "&body=" + escape(_pMessage));
+
+ if ( _pHistory.scrollHeight == (_pHistory.scrollTop + _pHistory.clientHeight) )
+ {
+ _pHistory.innerHTML += '' + imGetLang('says') + ': ' + _pMessage + ' ';
+ _pHistory.scrollTop = _pHistory.scrollHeight;
+ }
+ else
+ // this "else" is to prevent the creation of a flag and the need to use another conditional
+ _pHistory.innerHTML += '' + imGetLang('says') + ': ' + _pMessage + ' ';
+ }
+ }
+
+ function _action(_pAction)
+ {
+ //alert ( typeof pAction + "\n\n" + pAction.nodeName )
+ if ( typeof _pAction == 'object' && _pAction.nodeName )
+ {
+ switch ( _pAction.nodeName )
+ {
+ case 'iq' :
+ _readIq(_pAction);
+ break;
+ case 'message' :
+ _readMessage(_pAction);
+ break;
+ case 'presence' :
+ _readPresence(_pAction);
+ break;
+ //default : alert('action : ' + _pAction.nodeName);
+ }
+ }
+ }
+
+ function Jabber()
+ {
+ _conn = arguments[0];
+ _xtools = arguments[1];
+ _window = arguments[2];
+ _ldap = arguments[3];
+ _menu = arguments[4];
+ _cookies = arguments[5];
+ }
+
+ Jabber.prototype.action = _action;
+ Jabber.prototype.setPresence = _setPresence;
+ window.Jabber = Jabber;
+ window.InstantMessengerPresence = _setPresence;
+}
+)();
Index: tags/instant_messenger/js/xtools.js
===================================================================
--- tags/instant_messenger/js/xtools.js (revision 305)
+++ tags/instant_messenger/js/xtools.js (revision 305)
@@ -0,0 +1,151 @@
+(function()
+{
+ var _FILES = [];
+
+ function _convert(pString)
+ {
+ if ( typeof pString != 'string' )
+ return false;
+
+ if ( window.ActiveXObject )
+ {
+ var _xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
+ _xmlDoc.async = "false";
+ _xmlDoc.loadXML(pString);
+ }
+ else
+ {
+ var parser = new DOMParser();
+ var _xmlDoc = parser.parseFromString(pString, "text/xml");
+ }
+
+ return _xmlDoc;
+ }
+
+ function _load(pFile)
+ {
+ pFile = this._PATH + 'xsl/' + pFile;
+ if ( !(_FILES[pFile]) )
+ {
+ var _data = null;
+ if ( document.implementation.createDocument )
+ _data = document.implementation.createDocument("", "", null);
+ else
+ _data = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
+
+ _data.async = false;
+ _data.load(pFile + '?' + Date.parse(new Date));
+ _FILES[pFile] = _data;
+ }
+ return _FILES[pFile];
+ }
+
+ function _parse()
+ {
+ if ( arguments.length == 1 )
+ {
+ pXML = _xml('root');
+ pXSL = arguments[0];
+ }
+ else
+ {
+ pXML = arguments[0];
+ pXSL = arguments[1];
+ }
+ switch ( typeof pXML )
+ {
+ case 'object' :
+ break;
+ case 'string' :
+ if ( pXML.indexOf('<') == 0 )
+ pXML = _convert(pXML);
+ else
+ pXML = _load.call(this, pXML);
+ break;
+ default :
+ return {'error':'invalid xml'}
+ }
+ switch ( typeof pXSL )
+ {
+ case 'object' :
+ break;
+ case 'string' :
+ pXSL = _load.call(this, pXSL);
+ break;
+ default :
+ return {'error':'invalid xsl'}
+ }
+
+ var fragment = null;
+ if ( window.XSLTProcessor )
+ {
+ var xslProc = new XSLTProcessor();
+ xslProc.importStylesheet(pXSL);
+
+ if ( (arguments.length == 3) && (typeof arguments[2] == 'object') )
+ {
+ var params = arguments[2];
+ for (var i in params )
+ xslProc.setParameter(null, i, params[i]);
+ }
+
+ fragment = xslProc.transformToFragment(pXML, document);
+
+ // para retornar valor igual ao ie.
+ var aux = document.createElement("div");
+ aux.appendChild(fragment);
+ fragment = aux.innerHTML;
+ }
+ else
+ {
+ var xslTemplate = new ActiveXObject("MSXML2.XSLTemplate");
+ xslTemplate.stylesheet = pXSL;
+
+ var xslProc = xslTemplate.createProcessor();
+ xslProc.input = pXML;
+
+ if ( (arguments.length == 3) && (typeof arguments[2] == 'object') )
+ {
+ var params = arguments[2];
+ for (var i in params )
+ xslProc.addParameter(i, params[i], '');
+ }
+
+ xslProc.transform();
+ fragment = xslProc.output;
+ }
+ return fragment;
+ }
+
+ function _xml()
+ {
+ var a = false;
+ if ( document.implementation.createDocument )
+ a = document.implementation.createDocument("", "", null);
+ else if ( ActiveXObject )
+ a = new ActiveXObject("Msxml2.DOMDocument");
+
+ if ( arguments.length == 1 && typeof arguments[0] == 'string' )
+ a.appendChild(a.createElement(arguments[0]));
+ //with ( a )
+ // appendChild(createProcessingInstruction("xml", "version='1.0'"));
+
+ return a;
+ }
+
+ function XTools()
+ {
+ var _argv = arguments;
+ this._PATH = ( _argv.length > 0 ) ?
+ _argv[0] : '';
+ if ( this._PATH != '' && this._PATH.lastIndexOf('/') != (this._PATH.length - 1) )
+ this._PATH += '/';
+ }
+
+ XTools.prototype.convert = _convert;
+ XTools.prototype.load = _load;
+ XTools.prototype.parse = _parse;
+ XTools.prototype.xml = _xml;
+ window.XTools = XTools;
+}
+)();
Index: tags/instant_messenger/js/connector.js
===================================================================
--- tags/instant_messenger/js/connector.js (revision 327)
+++ tags/instant_messenger/js/connector.js (revision 327)
@@ -0,0 +1,295 @@
+(function()
+{
+ var _THREADS = [];
+ var _ie;
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ // xhr = XMLHttpRequest
+ function _xhr()
+ {
+ try
+ {
+ return new XMLHttpRequest();
+ }
+ catch (_e)
+ {
+ _ie = true;
+ try
+ {
+ return new ActiveXObject('Msxml2.XMLHTTP');
+ }
+ catch (_e1)
+ {
+ try
+ {
+ return new ActiveXObject('Microsoft.XMLHTTP');
+ }
+ catch (_e2)
+ {
+ return false;
+ }
+ }
+ }
+ }
+
+ function _HANDLER()
+ {
+ var _ID = arguments[0];
+
+ if ( _THREADS[_ID] )
+ {
+ if ( _ie && _THREADS[_ID]._XHR.readyState != 4 )
+ return false;
+
+ switch ( _THREADS[_ID]._XHR.readyState )
+ {
+ case 3 :
+ if ( _THREADS[_ID]._HANDLER.stream )
+ {
+ var _data = _THREADS[_ID]._XHR.responseText.substr(_THREADS[_ID]._index).replace(/^ +| +$/g, '');
+ //alert(_data);
+ _THREADS[_ID]._rtlen = _THREADS[_ID]._XHR.responseText.length;
+
+ if ( _THREADS[_ID]._index < _THREADS[_ID]._rtlen && _data.length )
+ try
+ {
+ _THREADS[_ID]._HANDLER.stream(_data);
+ }
+ catch(_e)
+ {
+ //alert("#stream\n\n" + _e + "\n\n" + _e.description);
+ }
+
+ if ( _THREADS[_ID] )
+ _THREADS[_ID]._index = _THREADS[_ID]._rtlen;
+ }
+ break;
+ case 4 :
+ try
+ {
+ switch ( _THREADS[_ID]._XHR.status )
+ {
+ case 200:
+ var _data = ( _THREADS[_ID]._MODE == 'XML' ) ?
+ _THREADS[_ID]._XHR.responseXML :
+ _THREADS[_ID]._XHR.responseText;
+
+ if ( _ie && _THREADS[_ID]._HANDLER.stream )
+ _THREADS[_ID]._HANDLER.stream(_data);
+
+ var _request = ( _THREADS[_ID]._HANDLER.request ) ?
+ _THREADS[_ID]._HANDLER.request : false;
+
+ delete _THREADS[_ID];
+
+ if ( _request )
+ try
+ {
+ _request(_data);
+ }
+ catch(_e)
+ {
+ //alert("#request\n\n" + _e + "\n\n" + _e.description);
+ }
+
+ break; // [case : status 200]
+ case 404:
+ delete _THREADS[_ID];
+ alert('Page Not Found!');
+ break; // [case : status 404]
+ default:
+ delete _THREADS[_ID];
+ }
+ }
+ catch(e)
+ {
+ }
+ break;
+ default :
+ }
+ }
+ }
+
+ function _execute()
+ {
+ var _ID = arguments[0];
+ var _ACTION = 'act=' + _ID;
+ var _TARGET = this._PATH;
+ var _SEND = null;
+
+ if ( _TARGET != '' && _TARGET.lastIndexOf('/') != (_TARGET.length - 1) )
+ _TARGET += '/';
+
+ _TARGET += ( this._CONTROLLER ) ?
+ this._CONTROLLER : 'controller.php';
+
+ if ( _THREADS[_ID]._METHOD == 'GET' )
+ _TARGET += '?' + _ACTION;
+
+ _THREADS[_ID]._XHR.open(_THREADS[_ID]._METHOD, _TARGET, true);
+
+ if ( _THREADS[_ID]._METHOD == 'POST' )
+ {
+ _THREADS[_ID]._XHR.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
+ _THREADS[_ID]._XHR.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
+ _THREADS[_ID]._XHR.setRequestHeader('Cache-Control', 'post-check=0, pre-check=0');
+ _THREADS[_ID]._XHR.setRequestHeader('Pragma', 'no-cache');
+ _SEND = _ACTION + '&' + arguments[1];
+ }
+
+ _THREADS[_ID]._XHR.onreadystatechange = function(){_HANDLER(_ID);};
+ _THREADS[_ID]._XHR.send(_SEND);
+ }
+
+ function usage()
+ {
+ return ""+
+ "Description:\n"+
+ "\t.go(string access, [mixed handler[, mixed post]])\n\n"+
+ "Parameters:\n"+
+ "\taccess : assinatura de acesso à camada de controle.\n"+
+ "\thandler : uma função a ser executada no fim da requisição\n"+
+ "\t\tou um objeto que poderá conter dois Ãndices sendo\n"+
+ "\t\tque ambos deverão ser uma função que será executada\n"+
+ "\t\tconforme o status do objeto xhr, sendo que na posição\n"+
+ "\t\t'stream' será a função a ser executada a cada iteração\n"+
+ "\t\tdo objeto xhr e na posição 'request' será a função\n"+
+ "\t\ta ser executada no fim da requisição.\n"+
+ "\tpost : se especificado deverá ser uma query string ou um\n"+
+ "\tXML bem formatado.\n\n";
+ }
+
+ // @PARAM arguments[0] string :
+ // assinatura de acesso à camada de controle
+ //
+ // @PARAM arguments[1] object :
+ // OBS : neste caso a conexão assumirá que se trata de uma stream
+ // objeto contendo dois duas funções, sendo,
+ // no Ãndice stream deverá conter uma função que será execultada
+ // a cada mudança de status do objeto xhr
+ // or
+ // @PARAM arguments[1] function : funcão a ser executada no retorno da
+ // requisição
+ // OBS : neste caso a conexão assumirá que se trata de uma
+ // requisição função que será execultada no final da requisição
+ //
+ // @PARAM arguments[2] string :
+ // este parâmetro define se a conexão é via GET ou POST
+ // caso o parâmetro não esteja presente a conexão será execultada
+ // via GET, por outro lado, caso ele exista deverá ser uma query
+ // string válida ou um xml bem formatado
+ //
+ function go()
+ {
+ var _argv = arguments;
+ var _argc = _argv.length;
+ var _ID = _argv[0];
+ var _POST;
+ if ( _argc < 1 || _argc > 3 )
+ return {'error' : "#0\n\n" + usage()};
+
+ if ( typeof _ID != 'string' )
+ return {'error' : "#1\n\n" + usage()};
+
+ //if ( _THREADS[_ID] )
+ // return {'error' : '#2 - there is a equal request running'};
+
+ _THREADS[_ID] = {
+ '_HANDLER' : {},
+ '_METHOD' : ( _argv[2] ) ? 'POST' : 'GET', // [GET | POST]
+ '_MODE' : null, // [XML | TEXT]
+ '_TYPE' : null, // [4 for request | 3 for stream]
+ '_XHR' : null // [4 for request | 3 for stream]
+ };
+
+ if ( _argv[2] )
+ _POST = _argv[2];
+
+ if ( _argv[1] )
+ switch ( typeof _argv[1] )
+ {
+ case 'function' :
+ _THREADS[_ID]._HANDLER = {'request' : _argv[1]};
+ break;
+ case 'object' :
+ for ( var i in _argv[1] )
+ if ( i != 'stream' && i != 'request' )
+ {
+ delete _THREADS[_ID];
+ return {'error' : "#3\n\n" + usage()};
+ }
+ else if ( i == 'stream' )
+ {
+ _THREADS[_ID]._index = 0;
+ _THREADS[_ID]._rtlen = 0;
+ }
+ _THREADS[_ID]._HANDLER = _argv[1];
+ break;
+ case 'string' :
+ if ( _argc == 2 )
+ {
+ _THREADS[_ID]._METHOD = 'POST';
+ _POST = _argv[1];
+ }
+ break;
+ default :
+ //delete _THREADS[_ID];
+ //return {'error' : "#4\n\n" + usage()};
+ }
+
+ if ( !(_THREADS[_ID]._XHR = _xhr()) )
+ return {'error' : "#4 it cannot make a xhr object"};
+
+ ( _THREADS[_ID]._METHOD == 'GET' ) ?
+ _execute.call(this, _ID) : _execute.call(this, _ID, _POST);
+ return {'success' : "your thread is running and the response "+
+ "will be manipulated by the handler"};
+ }
+
+ function _abort()
+ {
+ for ( var _ID in _THREADS )
+ {
+ // @TODO
+ // try/catch for unknown error of IE.
+ // Check, store and retrieve the try/catch.
+ try
+ {
+ if ( _THREADS[_ID] && _THREADS[_ID]._XHR && _THREADS[_ID]._XHR.abort )
+ _THREADS[_ID]._XHR.abort();
+
+ delete _THREADS[_ID];
+ }
+ catch(e){}
+ }
+ }
+
+ function Connector()
+ {
+ var _argv = arguments;
+ this._PATH = ( _argv.length > 0 ) ?
+ _argv[0] : '';
+ this._CONTROLLER = ( _argv.length == 2 ) ?
+ _argv[1] : false;
+ }
+
+ Connector.prototype.go = go;
+ Connector.prototype.abort = _abort;
+ window.IMConnector = Connector;
+
+ _config(window, 'onbeforeunload', _abort);
+}
+)();
Index: tags/instant_messenger/js/windows.js
===================================================================
--- tags/instant_messenger/js/windows.js (revision 321)
+++ tags/instant_messenger/js/windows.js (revision 321)
@@ -0,0 +1,339 @@
+(function()
+{
+ var _drag_drop = new DragDrop();
+
+ var _xtools;
+ var index = 10000;
+ var _all_windows = [];
+
+ function _load(pId)
+ {
+ if ( !(top.document.getElementById(pId + '__window_master')) )
+ {
+ var xml = _xtools.xml('window');
+
+ var name = xml.createElement('name');
+ name.appendChild(xml.createTextNode(pId));
+ xml.documentElement.appendChild(name);
+
+ var _window = top.document.createElement("div");
+ _window.innerHTML = _xtools.parse(xml, 'window.xsl');
+ _window.setAttribute('id', pId + '__window_master');
+ _window.setAttribute('class', 'window');
+ _window.setAttribute('className', 'window');
+
+ _window = this._TARGET.appendChild(_window);
+
+ _focus(_window);
+
+ function _click(e)
+ {
+ _focus(e);
+ _window.oncontextmenu = new Function("return false");
+ return false;
+ }
+
+ _config(_window, 'onmousedown', _click);
+
+ _drag_drop.drag(_window);
+ _window.childNodes[1].setAttribute('dragdrop_child','true');
+ _window.childNodes[1].childNodes[0].setAttribute('dragdrop_child','true');
+ _window.childNodes[1].childNodes[1].setAttribute('dragdrop_child','true');
+
+ _config(_window.childNodes[1].childNodes[2].childNodes[0], 'onclick', _button);
+ _config(_window.childNodes[1].childNodes[2].childNodes[1], 'onclick', _button);
+ _config(_window.childNodes[1].childNodes[2].childNodes[2], 'onclick', _button);
+
+ _all_windows[pId + '__window_master'] = {
+ 'id' : pId,
+ 'wm' : _window, // wm - window master
+ 'ic' : _window.childNodes[1].firstChild, // wt - window title
+ 'wt' : _window.childNodes[1].childNodes[1], // wt - window title
+ 'bc' : _window.childNodes[1].childNodes[2].childNodes[0], // bc - button close
+ 'bx' : _window.childNodes[1].childNodes[2].childNodes[1], // bx - button maximize
+ 'bz' : _window.childNodes[1].childNodes[2].childNodes[2], // bz - button minimize
+ 'wc' : _window.childNodes[2].firstChild, // wc - window content
+ 'wf' : _window.childNodes[3], // wf - window footer
+ 'button' : _button,
+ 'content' : _content,
+ 'close' : function()
+ {
+ _button(_window.childNodes[1].childNodes[2].childNodes[0]);
+ },
+ 'focus' : _focus,
+ 'hidden' : function()
+ {
+ _button(_window.childNodes[1].childNodes[2].childNodes[2]);
+ },
+ 'icon' : _icon,
+ 'loading' : function()
+ {
+ var _information = top.document.createElement('span');
+ _information.appendChild(
+ top.document.createTextNode(imGetLang('Loading'))
+ );
+
+ var _loading = top.document.createElement('div');
+ _loading.className = 'loading';
+ _loading.appendChild(_information);
+
+ _content.call(this, _loading);
+ },
+ 'position' : _position,
+ 'show' : function()
+ {
+ _window.style.display = 'block';
+ },
+ 'size' : _size,
+ 'title' : _title
+ };
+
+ }
+ return _all_windows[pId + '__window_master'];
+ }
+
+ function _browser()
+ {
+ var _width = 0, _height = 0;
+ if ( typeof( window.innerWidth ) == 'number' )
+ {
+ //Non-IE
+ _width = top.window.innerWidth;
+ _height = top.window.innerHeight;
+ }
+ else if ( top.document.documentElement && ( top.document.documentElement.clientWidth || top.document.documentElement.clientHeight ) )
+ {
+ //IE 6+ in 'standards compliant mode'
+ _width = top.document.documentElement.clientWidth;
+ _height = top.document.documentElement.clientHeight;
+ }
+ else if( top.document.body && ( top.document.body.clientWidth || top.document.body.clientHeight ) )
+ {
+ //IE 4 compatible
+ _width = top.document.body.clientWidth;
+ _height = top.document.body.clientHeight;
+ }
+
+ return {'width' : _width, 'height' : _height}
+ }
+
+ function _button()
+ {
+ var b = arguments[0];
+ b = ( !b.type ) ?
+ b : ( b.target ) ?
+ b.target : b.srcElement;
+
+ var w = b.parentNode.parentNode.parentNode;
+ switch ( b.title )
+ {
+ case 'close' :
+ w.parentNode.removeChild(w);
+ delete _all_windows[w.id];
+ break;
+ case 'minimize' :
+ w.style.display = 'none';
+ break;
+ case 'maximize' :
+ if ( !w.getAttribute('wParams') )
+ {
+ var _wParams = (parseFloat(w.style.width) - 13);
+ _wParams += ':' + parseFloat(w.childNodes[2].firstChild.style.maxHeight);
+ _wParams += ':' + parseFloat(w.style.left);
+ _wParams += ':' + parseFloat(w.style.right);
+ _wParams += ':' + parseFloat(w.style.top);
+ _wParams += ':' + parseFloat(w.style.bottom);
+ w.setAttribute('wParams', _wParams);
+
+ var _bwr = _browser();
+ w.style.top = "0px";
+ w.style.left = "0px";
+ w.style.height = "100%";
+ w.style.width = "100%";
+
+ var _style = w.childNodes[2].firstChild.getAttribute('style');
+ if ( typeof _style == 'object' && _style.cssText )
+ _style = _style.cssText;
+
+ if ( w.childNodes[2].firstChild.style.cssText )
+ w.childNodes[2].firstChild.style.cssText = '';
+
+ _style = _style.replace(/max-height: ?\d+;?/i, '');
+
+ w.childNodes[2].firstChild.setAttribute('style', _style);
+
+ w.childNodes[2].firstChild.style.height = (_bwr.height - 41) + "px";
+ }
+ else
+ {
+ var _wParams = w.getAttribute('wParams').split(':');
+ w.removeAttribute('wParams');
+
+ var _style = w.getAttribute('style');
+ if ( typeof _style == 'object' && _style.cssText )
+ _style = _style.cssText;
+
+ _style = _style.replace(/height: ?100%;?/i, '').replace(/width: ?100%;?/i, '');
+ _style = _style.replace(/left: ?0px;?/i, '').replace(/top: ?0px;?/i, '');
+
+ // for IE
+ if ( w.style.cssText )
+ w.style.cssText = '';
+
+ w.setAttribute('style', _style);
+
+ w = _all_windows[w.id];
+
+ _style = w.wc.getAttribute('style');
+ if ( typeof _style == 'object' && _style.cssText )
+ _style = _style.cssText;
+
+ _style = _style.replace(/height: ?\d+px;?/i, '');
+
+ // for IE
+ if ( w.wc.style.cssText )
+ w.wc.style.cssText = '';
+
+ w.wc.setAttribute('style', _style);
+
+ w.size(parseFloat(_wParams[0]), parseFloat(_wParams[1]));
+
+ var x = '';
+ var _right = false;
+ if ( !isNaN(_wParams[2]) )
+ x = parseFloat(_wParams[2]);
+ else if ( !isNaN(_wParams[3]) )
+ {
+ x = parseFloat(_wParams[3]);
+ _right = true;
+ }
+
+ var y = '';
+ var _bottom = false;
+ if ( !isNaN(_wParams[4]) )
+ y = parseFloat(_wParams[4]);
+ else if ( !isNaN(_wParams[5]) )
+ {
+ y = parseFloat(_wParams[5]);
+ _bottom = true;
+ }
+
+ w.position(x, y, _right, _bottom);
+ }
+ break;
+ }
+ }
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ function _content()
+ {
+ var _content = this.wc;
+ while ( _content.hasChildNodes() )
+ _content.removeChild(_content.firstChild);
+ var l = arguments.length;
+ for ( var i = 0; i < l; i++ )
+ if ( typeof arguments[i] == 'object' )
+ _content.appendChild(arguments[i]);
+ else if ( typeof arguments[i] == 'string' )
+ _content.innerHTML += arguments[i];
+ }
+
+ function _focus()
+ {
+ var w;
+ if ( arguments.length )
+ w = arguments[0];
+ else
+ w = this.wm;
+
+ w = ( !w.type ) ?
+ w : ( w.target ) ?
+ w.target : w.srcElement;
+
+ while ( w.id.indexOf('__window_master') == -1 )
+ w = w.parentNode;
+
+ index += 10;
+ w.style.zIndex = index;
+ }
+
+ function _get(_pId)
+ {
+ var _win = false;
+ if ( _all_windows[_pId + '__window_master'] )
+ _win = _all_windows[_pId + '__window_master'];
+ return _win;
+ }
+
+ function _icon(_pIcon)
+ {
+ if ( typeof _pIcon == 'string' )
+ this.ic.style.backgroundImage = 'url(' + _pIcon + ')';
+ }
+
+ function _position(pX, pY)
+ {
+ // for IE
+ //if ( window.ActiveXObject )
+ // this.wm.style.position = 'absolute';
+
+ if ( typeof pX == 'number' )
+ if ( arguments[2] === true )
+ this.wm.style.right = pX + 'px';
+ else
+ this.wm.style.left = pX + 'px';
+
+ if ( typeof pY == 'number' )
+ if ( arguments[3] === true )
+ this.wm.style.bottom = pY + 'px';
+ else
+ this.wm.style.top = pY + 'px';
+ }
+
+ function _size(pWidth, pHeight)
+ {
+ if ( typeof pWidth == 'number' && !isNaN(pWidth) )
+ this.wm.style.width = (13 + pWidth) + 'px';
+
+ if ( typeof pHeight == 'number' && !isNaN(pHeight) )
+ this.wc.style.maxHeight = pHeight + 'px';
+ }
+
+ function _title(pTitle)
+ {
+ var _title = this.wt;
+ while ( _title.hasChildNodes() )
+ _title.removeChild(_title.firstChild);
+ _title.appendChild(top.document.createTextNode(pTitle));
+ }
+
+ function Windows()
+ {
+ var _argv = arguments;
+ var _argc = _argv.length;
+ if ( (_argv[_argc - 1] != null) && (_argv[_argc - 1]).id )
+ this._TARGET = _argv[_argc - 1];
+ else
+ this._TARGET = top.document.body;
+
+ _xtools = arguments[0];
+ }
+
+ Windows.prototype.load = _load;
+ Windows.prototype.get = _get;
+ window.Windows = Windows;
+}
+)();
Index: tags/instant_messenger/js/show_hidden.js
===================================================================
--- tags/instant_messenger/js/show_hidden.js (revision 305)
+++ tags/instant_messenger/js/show_hidden.js (revision 305)
@@ -0,0 +1,112 @@
+(function()
+{
+ var _dalay;
+
+ var _last_displayed;
+ var _timeout = false;
+
+ var _event_show = false;
+ var _event_hidden = false;
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ function _hidden()
+ {
+ _show(_last_displayed);
+ }
+
+ function _wait(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ if ( e.type.indexOf('mouseover') != -1 )
+ clearTimeout(_timeout);
+ else
+ _timeout = setTimeout(_hidden, _dalay);
+ }
+
+ function _show(_element)
+ {
+ if ( _last_displayed )
+ _last_displayed.style.display = 'none';
+
+ if ( _timeout )
+ clearTimeout(_timeout);
+
+ if ( _element != _last_displayed )
+ {
+ _last_displayed = _element;
+ _element.style.display = 'block';
+ _config(_element,_event_show,_wait);
+ _config(_element,_event_hidden,_wait);
+ }
+ else
+ _last_displayed = false;
+ }
+
+ function _view()
+ {
+ if ( arguments.length == 3 )
+ {
+ var _event = [
+ 'onclick',
+ 'onmousedown',
+ 'onmouseout',
+ 'onmouseover',
+ 'onmouseup'
+ ];
+
+ _event_show = false;
+ _event_hidden = false;
+
+ for ( var i in _event )
+ {
+ if ( _event[i] == arguments[0] )
+ _event_show = arguments[0];
+
+ if ( _event[i] == arguments[1] )
+ _event_hidden = arguments[1];
+ }
+
+ if ( _event_show && _event_hidden )
+ {
+ var _element = false;
+ switch ( typeof arguments[2] )
+ {
+ case 'object' :
+ _element = arguments[2];
+ break;
+ case 'string' :
+ _element = top.document.getElementById(arguments[2]);
+ break;
+ }
+
+ if ( _element )
+ {
+ _show(_element);
+ _timeout = setTimeout(_hidden, _dalay);
+ }
+ }
+ }
+ }
+
+ function ShowHidden()
+ {
+ _dalay = ( (arguments.length > 0) && !isNaN(arguments[0]) ) ? arguments[0] : 3000;
+ }
+
+ ShowHidden.prototype.action = _view;
+ window.ShowHidden = ShowHidden;
+}
+)();
Index: tags/instant_messenger/js/cookies.js
===================================================================
--- tags/instant_messenger/js/cookies.js (revision 318)
+++ tags/instant_messenger/js/cookies.js (revision 318)
@@ -0,0 +1,53 @@
+(function()
+{
+ function _clear()
+ {
+ if ( arguments.length == 1 )
+ _set(arguments[0], '', -1440);
+ }
+
+ function _get()
+ {
+ if ( (arguments.length == 1) && (document.cookie.length > 0) )
+ {
+ var _start = document.cookie.indexOf(arguments[0] + "=");
+ if ( _start != -1 )
+ {
+ _start = _start + arguments[0].length + 1;
+ var _end = document.cookie.indexOf(';', _start);
+
+ if ( _end == -1)
+ _end = document.cookie.length;
+
+ return unescape(document.cookie.substring(_start, _end));
+ }
+ }
+ return false;
+ }
+
+ function _set()
+ {
+ var _argc = arguments.length;
+ if ( _argc > 1 && _argc < 4 )
+ {
+ var _value = arguments[0] + '=' + escape(arguments[1]);
+ if ( _argc == 3 )
+ {
+ var dt = new Date;
+ dt.setTime((dt.getTime() - 10800000) + (arguments[2] * 60000));
+ _value += ';expires=' + dt.toGMTString();
+ }
+ document.cookie = _value;
+ }
+ }
+
+ function Cookies()
+ {
+ }
+
+ Cookies.prototype.clear = _clear;
+ Cookies.prototype.get = _get;
+ Cookies.prototype.set = _set;
+ window.IMCookies = Cookies;
+}
+)();
Index: tags/instant_messenger/js/client.js
===================================================================
--- tags/instant_messenger/js/client.js (revision 337)
+++ tags/instant_messenger/js/client.js (revision 337)
@@ -0,0 +1,311 @@
+(function()
+{
+
+ var _cookies = new IMCookies;
+ var _running = _cookies.get('IM_running');
+ if ( !_running )
+ {
+ _cookies.set('IM_running', 'true', 5);
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ _config(window, 'onbeforeunload',
+ function()
+ {
+ var _running = _cookies.get('IM_running');
+ _cookies.clear('IM_running');
+ }
+ );
+
+ if ( !(top.document.getElementById('instant_messenger_content')) )
+ {
+ var _im_content = top.document.createElement('div');
+ _im_content.setAttribute('id', 'instant_messenger_content');
+ _im_content = top.document.body.appendChild(_im_content);
+ }
+
+ var buffer = '';
+ var _disconnected = false;
+
+ var _conn = new IMConnector(path_im);
+ var _xtools = new XTools(path_im);
+ var _window = new Windows(_xtools, _im_content);
+ var _ldap = new InstantMessengerLDAP(_conn, _xtools, _window);
+ var _showhidden = new ShowHidden(1500);
+ var _jabber = new Jabber(_conn, _xtools, _window, _ldap, _showhidden, _cookies);
+
+ // XSL preload
+ var _xsl_preload = [
+ 'window.xsl',
+ 'layer.xsl',
+ 'contacts.xsl',
+ 'chat.xsl',
+ 'options.xsl'
+ ];
+ var _xsl_preload_legth = _xsl_preload.length;
+ for ( var i = 0; i < _xsl_preload_legth; i++ )
+ _xtools.load(_xsl_preload[i]);
+
+ function _stream(data)
+ {
+ data = data.replace(/^ | $/, '');
+
+ if ( !(data.length) )
+ return false;
+
+ if ( data.indexOf('disconnected') != -1 || data.indexOf(' ') != -1 )
+ _disconnect();
+ else
+ {
+ if ( data.lastIndexOf('>') != data.length - 1)
+ buffer += data + ' ';
+ else
+ {
+ if ( buffer.length )
+ {
+ data = buffer + data;
+ buffer = '';
+ }
+
+ // with xmlns, occurs problems during parse between
+ // xml and xsl, and for that reason it was removed
+ data = data.replace(/ xmlns='.*?'/g, '');
+ data = '' + data + ' ';
+
+ var _xml = _xtools.convert(data);
+
+ if ( _xml )
+ {
+ var _node = _xml.documentElement.firstChild;
+
+ while ( _node )
+ {
+ if ( _node.nodeType == 1 )
+ _jabber.action(_node);
+ //else
+ // alert('name : ' + _node.nodeName +
+ // "\n\nhas children:" + _node.hasChildNodes() +
+ // "\nvalue\n\n" + _node.nodeValue);
+
+ _node = _node.nextSibling;
+ }
+ }
+ }
+ }
+ }
+
+ var _count_reconnect = 0;
+ function _request()
+ {
+ if ( !_disconnected )
+ return _conn.go(
+ '$this.Ujabber.listen',
+ {'stream':_stream, 'request':_wait},
+ 'classCostructor=read'
+ );
+ else
+ setTimeout(_reconnect, (++_count_reconnect * 2000));
+ }
+
+ function _wait()
+ {
+ setTimeout(_request, 3000);
+ }
+
+ function _reconnect()
+ {
+ _disconnected = false;
+ _request();
+ }
+
+ function _disconnect()
+ {
+ _disconnected = true;
+ _conn.abort();
+ _loading();
+ var _status = top.document.getElementById('im_status');
+ if ( _status )
+ _status.style.backgroundImage = 'url(' + im_unavailable.src + ')';
+
+ var _win_contacts = _window.get('contact_list');
+ if ( _win_contacts )
+ _win_contacts.icon(im_unavailable.src);
+ }
+
+ function _contacts()
+ {
+ if ( !_disconnected )
+ {
+ _conn.go('t.update');
+
+ setTimeout(function()
+ {
+ var _contact_list = top.document.getElementById('im_contact_list');
+ if ( !_contact_list )
+ _contacts();
+ }, 5000);
+ }
+ }
+
+ function _loading()
+ {
+ var _win_contact = _window.get('contact_list');
+ if ( !_win_contact )
+ {
+ _win_contact = _window.load('contact_list');
+ _win_contact.hidden();
+ _win_contact.title('.::Expresso Messenger::.');
+ _win_contact.size(170, 350);
+ _win_contact.position(30, 30, true);
+ _win_contact.icon(im_unavailable.src);
+ _win_contact.bc.style.display = 'none';
+ }
+
+ _win_contact.loading();
+ }
+
+ function _showContacts()
+ {
+ var _win = _window.get('contact_list');
+ if ( _win )
+ if ( _win.wm.style.display == 'none' )
+ _win.wm.style.display = 'block';
+ else
+ _win.wm.style.display = 'none';
+ }
+
+ _loading();
+
+ var local;
+ if ( (local = top.document.getElementById('divStatusBar')) )
+ {
+ // tentando colocar os icones em local que não seja mexido.
+ // VERIFICAR
+ var _div = top.document.createElement('div');
+ _div.appendChild(local.parentNode.removeChild(local.previousSibling));
+ local.parentNode.insertBefore(_div, local);
+ //_div.appendChild(local);
+
+ //local = _div;
+
+ local.style.paddingLeft = '30px';
+
+ var _status = top.document.createElement('div');
+ _status.setAttribute('id', 'im_status');
+ _status.style.background = 'no-repeat';
+ _status.style.backgroundImage = 'url(' + im_unavailable.src + ')';
+ _status.style.float = 'left';
+ _status.style.height = '15px';
+ _status.style.left = '20px';
+ _status.style.margin = '0 0 0 10px';
+ _status.style.padding = '0px';
+ _status.style.position = 'absolute';
+ _status.style.width = '15px';
+
+ local.insertBefore(_status, local.firstChild);
+
+ _config(_status, 'onclick', _showContacts);
+
+ var _menu;
+ _menu = top.document.createElement('span');
+ _menu.setAttribute('id','fast_menu_im');
+ _menu.style.backgroundColor = 'b4cfe5';
+ _menu.style.display = 'none';
+ _menu.style.margin = '15px 0 0 -15px';
+ _menu.style.position = 'absolute';
+ _menu.style.zIndex = '99999';
+ local.insertBefore(_menu, local.firstChild);
+
+ var _menu_img = top.document.createElement('div');
+ _menu_img.style.background = 'no-repeat';
+ _menu_img.style.backgroundImage = 'url(' + im_fast_menu.src + ')';
+ _menu_img.style.float = 'left';
+ _menu_img.style.height = '10px';
+ _menu_img.style.left = '23px';
+ _menu_img.style.margin = '0px';
+ _menu_img.style.padding = '0px';
+ _menu_img.style.position = 'absolute';
+ _menu_img.style.width = '10px';
+ local.insertBefore(_menu_img, local.firstChild);
+
+ _config(
+ _menu_img,
+ 'onclick',
+ function()
+ {
+ var _options = [
+ 'available',
+ 'away',
+ 'dnd',
+ 'unavailable'
+ ];
+
+ var _style_text = 'cursor: pointer; padding:2px 4px 2px 20px; background: no-repeat ';
+
+ var _xml = _xtools.xml('menu');
+ var _option;
+ var _item;
+ var _action;
+ var _style;
+
+ for ( var i in _options )
+ {
+ _option = _xml.createElement('option');
+
+ _item = _xml.createElement('item');
+ _item.appendChild(_xml.createTextNode(imGetLang(_options[i])));
+
+ _style = _xml.createElement('style');
+ _style.appendChild(_xml.createTextNode(_style_text + 'url(' + eval('im_' + _options[i] + '.src') + ')'));
+
+ _option.appendChild(_item);
+ _option.appendChild(_style);
+
+ _xml.documentElement.appendChild(_option);
+ }
+
+ _menu.innerHTML = _xtools.parse(_xml, 'options.xsl');
+ _showhidden.action('onmouseover', 'onmouseout', _menu);
+
+ _item = _menu.firstChild;
+
+ for ( var i in _options )
+ {
+ _item.childNodes[i].setAttribute('presence', _options[i]);
+ _config(
+ _item.childNodes[i],
+ 'onclick',
+ function(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ var _presence = el.getAttribute('presence');
+ _jabber.setPresence(_presence);
+ }
+ );
+ }
+ }
+ );
+ }
+
+ function Client()
+ {
+ _request();
+ setTimeout(_contacts, 3000);
+ }
+
+ window.InstantMessengerClient = Client;
+ }
+}
+)();
Index: tags/instant_messenger/js/ldap.js
===================================================================
--- tags/instant_messenger/js/ldap.js (revision 311)
+++ tags/instant_messenger/js/ldap.js (revision 311)
@@ -0,0 +1,238 @@
+(function()
+{
+ var _conn;
+ var _xtools;
+ var _window;
+
+ function _add_user()
+ {
+ var _win_add = _window.load('add_user_im');
+ _win_add.title('.:: Adicionar Novos Contatos ::.');
+ _win_add.size(600);
+ _win_add.position(30, 30);
+ _win_add.wc.style.padding = "3px";
+ var _params = {
+ 'lang1':imGetLang('organization unit'),
+ 'lang2':imGetLang('member of organization'),
+ 'lang3':imGetLang('nickname'),
+ 'lang4':imGetLang('group'),
+ 'lang5':imGetLang('add'),
+ 'lang6':imGetLang('close')
+ };
+
+ _win_add.content(_xtools.parse(_xtools.xml('adduser'), 'add_user.xsl', _params));
+
+ function _handler(_data)
+ {
+ var _target = top.document.getElementById('im_ldap_ou');
+ _target.innerHTML = _xtools.parse(_data, 'list_ldap_org.xsl');
+ var _organization_unit = _target.firstChild;
+ while ( _organization_unit )
+ {
+ _config(_organization_unit, 'onclick', _members);
+ _config(_organization_unit, 'onmouseover', _highlight);
+ _config(_organization_unit, 'onmouseout', _highlight);
+ _organization_unit = _organization_unit.nextSibling;
+ }
+
+ _config(_win_add.wc.childNodes[2].childNodes[0],
+ 'onclick',
+ function()
+ {
+ var _name = top.document.getElementById('im_name');
+ var _group = top.document.getElementById('im_group');
+ var _jid = top.document.getElementById('im_jid').value;
+ var _status = top.document.getElementById('im_status_add');
+
+ _status.innerHTML = '';
+ _name.previousSibling.style.color = "#000";
+ _group.previousSibling.style.color = "#000";
+
+ if ( !_jid )
+ {
+ _status.innerHTML = 'Selecione uma organização no campo da esquerda e em '
+ + ' seguida, no campo da direita, um membro da organização '
+ + ' para adicionar como contato';
+ }
+ else
+ {
+ _name.value = _name.value.replace(/^( )*|( )*$/g, '');
+ _group.value = _group.value.replace(/^( )*|( )*$/g, '');
+
+ if ( !(_name.value) || !(_group.value) )
+ {
+ _status.innerHTML = ' O campo destacado em vermelho é obrigatório! ';
+
+ if ( !(_name.value) )
+ {
+ _name.previousSibling.style.color = "#f00";
+ _status.innerHTML += ' ** Informe um "NOME" para o contato.';
+ }
+
+ if ( !(_group.value) )
+ {
+ _group.previousSibling.style.color = "#f00";
+ _status.innerHTML += ' ** Informe um "GRUPO" para o contato.';
+ }
+ }
+ else
+ {
+ var _uid;
+
+ if ( (_uid = top.document.getElementById('im_uid')) )
+ _uid = _uid.value;
+ else
+ _uid = _jid.substr(0, (_jid.indexOf('@') - 1));
+
+ _name.parentNode.style.display = 'none';
+ _name.parentNode.nextSibling.style.display = 'none';
+ _status.innerHTML = ' Adicionado contanto, aguarde. ';
+
+ _conn.go(
+ '$this.Ujabber.addContact',
+ function()
+ {
+ _status.innerHTML = ' Contato adicionado com "SUCESSO"! ';
+ },
+ 'uid='+_uid+'&name='+_name.value+'&group='+_group.value
+ );
+
+ _name.value = '';
+ _group.value = '';
+ }
+ }
+ }
+ );
+
+ _config(_win_add.wc.childNodes[2].childNodes[1],
+ 'onclick',
+ function()
+ {
+ _win_add.button(_win_add.bc);
+ }
+ );
+ }
+ _organizations(_handler);
+ }
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ function _highlight(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ var color = "#fff";
+ if ( e.type.indexOf('mouseover') != -1 )
+ color = "#b4cfe5";
+ el.style.backgroundColor = color;
+ }
+
+ function _organizations(_handler)
+ {
+ _conn.go('$this.ldap_im.list_organizations_ldap', _handler);
+ }
+
+ function _photo(_pId, _target)
+ {
+ if ( _pId.indexOf('/') > -1 )
+ _pId = _pId.substr(0, _pId.indexOf('/'));
+
+ function _handler(_thereIsUserPhoto)
+ {
+ if ( _thereIsUserPhoto == "true" )
+ _target.style.backgroundImage = 'url(' + path_im + 'inc/class.ldap_im.inc.php?user=' + _pId + ')';
+ }
+ _conn.go('$this.ldap_im.photo_ldap', _handler,'uid='+_pId);
+ }
+
+ function _members(e)
+ {
+ var el = ( e.target ) ? e.target : e.srcElement;
+ var _organization = false;
+ var _target = false;
+ var _action = false;
+ var _over = false;
+ var _out = false;
+ switch ( el.nodeName.toLowerCase() )
+ {
+ case 'span' :
+ _organization = el.firstChild.nodeValue;
+ _target = top.document.getElementById('im_ldap_user');
+ function _show(m)
+ {
+ m = ( m.target ) ? m.target : m.srcElement;
+ m = m.getAttribute('value');
+
+ top.document.getElementById('im_jid').value = m.substr(0, m.indexOf(';'));
+ top.document.getElementById('im_uid').value = m.substr((m.indexOf(';')+1));
+
+ var _name = top.document.getElementById('im_name');
+ _name.value = m.substr(0, m.indexOf('@'));
+ _name.previousSibling.style.color = "#000";
+
+ _name.parentNode.style.display = 'block';
+ _name.parentNode.nextSibling.style.display = 'block';
+ _name.parentNode.nextSibling.nextSibling.innerHTML = '';
+
+ var _group = top.document.getElementById('im_group');
+ _group.value = '';
+ _group.focus();
+ }
+ _action = _show;
+ _over = _out = _highlight;
+ break;
+ }
+ if ( _organization )
+ {
+ var _loading = top.document.getElementById('__span_load_im');
+ _loading.style.display = "block";
+ _conn.go(
+ '$this.contacts_im.list_contacts',
+ function(_data)
+ {
+ _target.innerHTML = _xtools.parse(_data,'list_ldap_contacts.xsl');
+
+ var _member = _target.firstChild;
+ while ( _member )
+ {
+ if ( _action )
+ _config(_member, 'onclick', _action);
+
+ if ( _over )
+ _config(_member, 'onmouseover', _over);
+
+ if ( _out )
+ _config(_member, 'onmouseout', _out);
+
+ _member = _member.nextSibling;
+ }
+ _loading.style.display = "none";
+ },
+ 'ou='+_organization
+ );
+ }
+ }
+
+ function LDAP()
+ {
+ _conn = arguments[0];
+ _xtools = arguments[1];
+ _window = arguments[2];
+ }
+
+ LDAP.prototype.photo = _photo;
+ LDAP.prototype.add = _add_user;
+ window.InstantMessengerLDAP = LDAP;
+}
+)();
Index: tags/instant_messenger/js/preferences.js
===================================================================
--- tags/instant_messenger/js/preferences.js (revision 347)
+++ tags/instant_messenger/js/preferences.js (revision 347)
@@ -0,0 +1,237 @@
+(function(){
+
+ // Conector, Xtools , Janelas
+ var _conn = new IMConnector(path_im);
+ var _xtools = new XTools(path_im);
+ var _im_content = top.document.getElementById('instant_messenger_content');
+ var _window = new Windows(_xtools, _im_content);
+ var _cookies = new IMCookies;
+ var Timeout = "";
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ }
+
+ function _load_window()
+ {
+ var _win_preferences = "";
+
+ _win_preferences = _window.load('preferences_window');
+ _win_preferences.title('.:: Expresso Messenger - ' + imGetLang('Preferences') + ' ::.');
+ _win_preferences.size(400, 350);
+ _win_preferences.position(150, 70, false);
+ _win_preferences.icon(im_console_prefs.src);
+
+ _win_preferences.bz.style.display = 'none';
+ _win_preferences.bx.style.display = 'none';
+ _win_preferences.wc.style.padding = '5px';
+
+ var _params = {
+ 'lang1':imGetLang('Options'),
+ 'lang2':imGetLang('Show users offline'),
+ 'lang3':imGetLang('Away'),
+ 'lang4':imGetLang('Ficar ausente depois de'),
+ 'lang5':imGetLang('Minutes'),
+ 'lang6':imGetLang('Ativar aviso de mensagem recebida'),
+ 'lang7':imGetLang('Normal'),
+ 'lang8':imGetLang('Treme Tela'),
+ 'lang9':imGetLang('Save'),
+ 'lang10':imGetLang('Close')
+ };
+
+ _win_preferences.content(_xtools.parse(_xtools.xml('settings'), 'mysettings.xsl', _params));
+
+ _config(_win_preferences.wc.childNodes[2], 'onclick', setPreferences);
+ _config(_win_preferences.wc.childNodes[3], 'onclick',
+ function()
+ {
+ _win_preferences.button(_win_preferences.bc);
+ }
+ );
+
+ // Carrega as preferências;
+ getPreferences();
+ }
+
+ function focus_select()
+ {
+ arguments[0].focus();
+ arguments[0].select();
+ }
+
+ function _preferences()
+ {
+ _cookies.set('preferences_im', arguments[0]);
+ var preferences = arguments[0].split(';');
+ preferences.pop();
+
+ for(var i in preferences)
+ {
+ var field = preferences[i].substring(0,preferences[i].indexOf(':'));
+ var value = preferences[i].substring(preferences[i].indexOf(':') + 1, preferences[i].length);
+
+ if( value === 'true' || value === 'false')
+ {
+ if(top.document.getElementById(field))
+ top.document.getElementById(field).checked = eval(value);
+ else if( field === 'ch_offline')
+ if(eval(value))
+ _cookies.set('IM_unavailable', 'show');
+ else
+ _cookies.set('IM_unavailable', 'hidden');
+ }
+ else
+ {
+ Timeout = ( parseInt(value) > 0 ) ? value : "1";
+ if( top.document.getElementById(field) )
+ top.document.getElementById(field).value = Timeout;
+ }
+ }
+ }
+
+ function getPreferences()
+ {
+ var preferences = "";
+
+ if((preferences = _cookies.get('preferences_im')))
+ _preferences(preferences);
+ else
+ _conn.go('$this.db_im.get_preferences', _preferences);
+ }
+
+ function setPreferences()
+ {
+ _win_preferences = _window.get('preferences_window');
+
+ var preferences = "";
+ var numbers = /^\d+$/;
+
+ // Offline
+ if (top.document.getElementById('ch_offline').checked)
+ {
+ preferences = 'ch_offline:true;';
+ _cookies.set('IM_unavailable', 'show');
+ }
+ else
+ {
+ preferences = 'ch_offline:false;';
+ _cookies.set('IM_unavailable', 'hidden');
+ }
+
+ // TimeOut
+ if(numbers.test(top.document.getElementById('time_xa_im').value) && top.document.getElementById('time_xa_im').value != "0")
+ {
+ preferences += "time_xa_im:" + top.document.getElementById('time_xa_im').value + ";";
+ Timeout = top.document.getElementById('time_xa_im').value;
+ }
+ else
+ {
+ preferences += "time_xa_im:1;";
+ Timeout = 1;
+ }
+
+ // New Message
+ /*
+ if(top.document.getElementById('rd_nm').checked)
+ {
+ preferences += 'rd_nm:true;';
+ _cookies.set('IM_screen','nm');
+ }
+ else
+ preferences += 'rd_nm:false;';
+
+ if(top.document.getElementById('rd_ch').checked)
+ {
+ preferences += 'rd_ch:true;';
+ _cookies.set('IM_screen','rd');
+ }
+ else
+ preferences += 'rd_ch:false;';
+ */
+
+ // Write Cookie
+ _cookies.set('preferences_im', preferences );
+
+ _conn.go('$this.db_im.set_preferences',
+ function(dataString)
+ {
+ if( !eval(dataString))
+ alert('Erro : Preferências não foram salvas !');
+ },
+ 'preferences='+preferences
+ );
+
+ if ( _win_preferences )
+ _win_preferences.button(_win_preferences.bc);
+ }
+
+ var _changed = false;
+ var _id_timeout = "";
+ function _setTimeOut()
+ {
+ _changed = true;
+ InstantMessengerPresence('auto');
+ }
+
+ function _timeOut()
+ {
+ if ( _id_timeout )
+ clearTimeout(_id_timeout);
+
+ if ( _changed )
+ {
+ _changed = false;
+ InstantMessengerPresence();
+ }
+
+ _id_timeout = setTimeout(_setTimeOut, parseInt(Timeout) * 60000);
+ }
+
+ function _show_hidden_group()
+ {
+ if ( !(arguments[0]) )
+ return false;
+
+ var show = 'block';
+ if ( !(arguments[0].checked) )
+ show = 'none';
+
+ var el = top.document.getElementById('im_contact_list');
+ if ( el && (el = el.firstChild) )
+ while ( el )
+ {
+ // it is a contact
+ if ( (el.nodeName.toLowerCase() == 'div') && el.getAttribute('jid') )
+ if ( el.style.backgroundImage.indexOf('unavailable') > -1 )
+ el.style.display = show;
+ el = el.nextSibling;
+ }
+ }
+
+ function Preferences()
+ {
+ getPreferences();
+ //_timeOut();
+ }
+
+ Preferences.prototype._setTimeOut = _setTimeOut;
+ Preferences.prototype.timeOut = _timeOut;
+ Preferences.prototype.load = _load_window;
+ Preferences.prototype.getfocus = focus_select;
+
+ Preferences.prototype.showHiddenGroup = _show_hidden_group;
+
+ top.window.im_preferences = new Preferences;
+ //_config(top.window.document, 'onmousemove', _timeOut);
+
+})();
Index: tags/instant_messenger/js/dragdrop.js
===================================================================
--- tags/instant_messenger/js/dragdrop.js (revision 321)
+++ tags/instant_messenger/js/dragdrop.js (revision 321)
@@ -0,0 +1,166 @@
+(function()
+{
+ var _element = null;
+
+ function _config(pObj, pEvent, pHandler)
+ {
+ if ( typeof pObj == 'object' )
+ {
+ if ( pEvent.substring(0, 2) == 'on' )
+ pEvent = pEvent.substring(2, pEvent.length);
+
+ if ( arguments.length == 3 )
+ {
+ if ( pObj.addEventListener )
+ pObj.addEventListener(pEvent, pHandler, false);
+ else if ( pObj.attachEvent )
+ pObj.attachEvent('on' + pEvent, pHandler);
+ }
+ else if ( arguments.length == 4 )
+ {
+ if ( pObj.removeEventListener )
+ pObj.removeEventListener(pEvent, pHandler, false);
+ else if ( pObj.detachEvent )
+ pObj.detachEvent('on' + pEvent, pHandler);
+ }
+ }
+ }
+
+ function _getMouseOffset(e, el)
+ {
+ var docPos = _getPosition(el);
+ var mousePos = _mouseCoords(e);
+ return {
+ 'x' : mousePos.x - docPos.x,
+ 'y' : mousePos.y - docPos.y
+ };
+ }
+
+ function _getPosition(_pObject)
+ {
+ var left = 0;
+ var top = 0;
+
+ while ( _pObject.offsetParent )
+ {
+ left += _pObject.offsetLeft;
+ top += _pObject.offsetTop;
+ _pObject = _pObject.offsetParent;
+ }
+
+ left += _pObject.offsetLeft;
+ top += _pObject.offsetTop;
+
+ return {
+ 'x' : left,
+ 'y' : top
+ };
+ }
+
+ function _mouseCoords(ev)
+ {
+ var CoordX = "";
+ var CoordY = "";
+
+ if ( ev.pageX || ev.pageY )
+ return {
+ 'x' : ev.pageX,
+ 'y' : ev.pageY
+ };
+
+ CoordX = ev.clientX + document.body.scrollLeft - document.body.clientLeft;
+ CoordY = ev.clientY + document.body.scrollTop - document.body.clientTop;
+ return {
+ 'x' : CoordX,
+ 'y' : CoordY
+ };
+ }
+
+ function _mouseMove(e)
+ {
+ if ( _element )
+ {
+ if ( _element.mouseOffset == null )
+ _element.mouseOffset = _getMouseOffset(e, _element);
+
+ var mousePos = _mouseCoords(e);
+
+ var x = mousePos.x - _element.mouseOffset.x;
+ var y = mousePos.y - _element.mouseOffset.y;
+ _element.style.left = (( x < 0 ) ? 0 : x) + 'px';
+ _element.style.top = (( y < 0 ) ? 0 : y) + 'px';
+ }
+ }
+
+ function _mouseUp()
+ {
+ if ( _element )
+ {
+ _config(_element, 'onmousemove', _mouseMove, 'remove');
+ _config(top.document, 'onmousemove', _mouseMove, 'remove');
+
+ _config(_element, 'onmouseup', _mouseUp, 'remove');
+ _config(top.document, 'onmouseup', _mouseUp, 'remove');
+
+ _element.mouseOffset = null;
+ _element = null;
+ }
+ }
+
+ function _toDrag(el)
+ {
+ if ( el.getAttribute('dragdrop_parent') == null )
+ {
+ if ( el.getAttribute('dragdrop_child') != null )
+ {
+ var children = 0;
+ while ( (++children < 5) && (el.getAttribute('dragdrop_parent') == null) )
+ el = el.parentNode;
+ }
+ if ( el.getAttribute('dragdrop_parent') == null )
+ el = false;
+ }
+ return el;
+ }
+
+ function _drag(e)
+ {
+ if (typeof e.preventDefault != 'undefined')
+ e.preventDefault();
+ else
+ e.onselectstart = new Function("return false;");
+
+ var el = ( e.target ) ? e.target : e.srcElement;
+
+ el = _toDrag(el);
+
+ if ( el )
+ {
+ _element = el;
+
+ _config(el, 'onmousemove', _mouseMove);
+ _config(top.document, 'onmousemove', _mouseMove);
+
+ _config(el, 'onmouseup', _mouseUp);
+ _config(top.document, 'onmouseup', _mouseUp);
+ }
+ }
+
+ function _set(_pObject)
+ {
+ if ( typeof _pObject != 'object' )
+ return false;
+
+ _pObject.setAttribute('dragdrop_parent', 'true');
+
+ _config(_pObject, 'onmousedown', _drag);
+ }
+
+ function DragDrop()
+ {
+ }
+
+ DragDrop.prototype.drag = _set;
+ window.DragDrop = DragDrop;
+}
+)();
Index: tags/instant_messenger/index.php
===================================================================
--- tags/instant_messenger/index.php (revision 265)
+++ tags/instant_messenger/index.php (revision 265)
@@ -0,0 +1,42 @@
+set_file(Array('instant_messenger' => 'index.tpl'));
+ $template_1->set_block('instant_messenger','index');
+ $template_1->pfp('out','index');
+
+ require_once PHPGW_SERVER_ROOT . '/instant_messenger/inc/im_sessions.inc.php';
+
+ $webserver_url = $GLOBALS['phpgw_info']['server']['webserver_url'];
+ $webserver_url = ( !empty($webserver_url) ) ? $webserver_url : '/';
+ if ( strrpos($webserver_url, '/') === false || strrpos($webserver_url, '/') != (strlen($webserver_url)-1) )
+ $webserver_url .= '/';
+
+ $webserver_url = $webserver_url . 'instant_messenger/';
+
+ print '';
+
+ // Footer
+ $GLOBALS['phpgw']->common->phpgw_footer();
+
+ if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') )
+ exit;
+
+?>
+
+
+
+
+ IM
+
Index: tags/instant_messenger/templates/default/config.tpl
===================================================================
--- tags/instant_messenger/templates/default/config.tpl (revision 318)
+++ tags/instant_messenger/templates/default/config.tpl (revision 318)
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
Index: tags/instant_messenger/templates/default/index.tpl
===================================================================
--- tags/instant_messenger/templates/default/index.tpl (revision 260)
+++ tags/instant_messenger/templates/default/index.tpl (revision 260)
@@ -0,0 +1,165 @@
+
+ Como Utilizar o Expresso Messenger
+
+
+ Introdução
+ Acessando o Expresso Messenger pela Primeira Vez
+ Browsers Suportados
+ Menu Opções
+ Lista de Contatos
+
+ Indicador de Status
+ Adicionando um novo contato
+ Removendo um contato
+
+ Preferências Avançadas
+ Vcard - Informações Adicionais
+ Preferências
+ Troca de Mensagens
+ Troca de Status
+
+
+
+
+ O Expresso Messenger é uma aplicação que permite o envio e recebimento de mensagens instantaneamente. Através da sua lista de contatos, você pode trocar mensagens e arquivos com seus contatos. Através da lista também é possível saber se seus contatos estão Online ou Offline. Para a troca de mensagens basta clicar em cima do nome do seu contato, se o mesmo estiver online ( verifique a sessão Indicador de Status ) abrirá uma janela onde você poderá enviar/receber as mensagens. O Expresso Messenger está associado
+ a um serviço de mensagens instantâneas Jabber, este serviço é responsável pelo armazenamento dos seus contatos, preferências e mensagens.
+
+
+
+ ( figura 1 )
+
+
+
+
+
+
+ Para o acessar o Expresso Messenger, basta clicar em cima da figura ("bolinha verde"), abrirá uma uma janela igual a figura 2. A lista de contatos aparecerá com a seguinte frase : "Nenhum Contato", atá que sejam cadastrados novos contatos.
+
+
+
+ ( figura 2 )
+
+
+
+
+
+
+
+ Windows XP/2000/ME/98/95:
+
+
+ Mozilla Firefox desde a versão 1.5
+
+
+
+ Linux:
+
+ Mozilla Firefox desde a versão 1.5
+
+
+
+
+ ( figura 3 )
+
+
+
+
+ Para acessar o menu "Opções" ( conforme figura 3 ), basta dar um clique com o mouse e abrirá um menu com as opções de Adicionar Contato ( veja Adicionando um novo contato ), Remover Contato ( veja Removendo um contato ),
+ Vcard - Informações Adicionais ( veja Vcard - Informações Adicionais ) e Preferências ( veja Preferências ).
+
+
+ ( figura 4 )
+
+
+
+
+ Na lista de contato ( conforme figura 4 ), você visualizará seus contatos.
+
+
+ - Contato Online
+ - Contato Ausente
+ - Contato Ocupado
+ - Contato Offline
+
+
+ ( figura 4.1 )
+
+
+
+
+
+ Para adicinar um novo contato, clique na imagem e abrirá uma janela ( conforme figura 4.1 ) selecione uma organização e automaticamente carregará os usuários que tem permissão para usar o Mensageiro Instantâneo Expresso.
+ Para escolher seu novo contato basta apenas dar um clique em cima do nome desejado. Logo abaixo, três campos são necessários para adicionar o novo contato, sendo que o campo "Email Expresso" e
+ "Nickname" são preenchidos no momento da escolha do novo contato e o campo grupo terá que ser definido. Tendo os três campos preenchidos basta clicar no Botão Adicionar ( ) .
+
+
+ ( figura 4.2 )
+
+
+
+
+
+ Para remover um contato da sua lista ( conforme figura 4.2 ), selecione na lista e clique no botao Botï¿œo Remover ( ) .
+
+
+ ( figura 4.3 )
+
+
+
+
+
+ Clicando com o botão direito do mouse, você tera acesso a um menu ( conforme figura 3.3 ), com as seguintes funcionalidades :
+
+
+ Apelido: Renomeia o Apelido ( Nickname ) do seu contato
+ Grupo: Muda seu contato para um novo grupo
+ Remover: Exclui o contato
+ (Re)-requisitar Autorização: Requisitar autorização
+ Ver Info: Visualize as informações dos seus contatos
+
+
+
+ ( figura 5 )
+
+
+
+
+ Efetuando o cadastro ( conforme figura 5 ) com seus dados, os contatos que você adicionou em sua lista poderão ver essas informações. Cada contato cadastrado em sua lista
+ também possui esta opção ( veja Preferências Avançadas , opção Ver Info).
+
+
+ ( figura 6 )
+
+
+
+
+ Personalize seu tempo para ficar ausente, se em sua lista de contato aparecerá seus contatos offline e um tipo de aviso para uma nova mensagem.
+
+
+ ( figura 7 )
+
+
+
+
+ Clicando com o mouse em cima do nome do contato escolhido, abrirá uma janela ( conforme figura 7 ), para a troca de mensagens. Nessa mesma janela existe um menu, o qual é possível
+ configurar o formato da Fonte como : Negrito , Itálico e a cor. Você também pode enviar os Smiles, clicando em
+ e acessar as informações do contato clicando em .
+
+
+ ( figura 8 )
+
+
+
+
+ Para mudar o seu status basta dar um click em cima do status desejado.
+
+
+
+ - Online
+ - Ausente
+ - Ocupado
+ - Offline - Não recebe mensagem
+ - Mensagem - Personalize sua mensagem
+
+
+
Index: tags/instant_messenger/templates/default/css/common.css
===================================================================
--- tags/instant_messenger/templates/default/css/common.css (revision 318)
+++ tags/instant_messenger/templates/default/css/common.css (revision 318)
@@ -0,0 +1,144 @@
+/* IM:WINDOW - ADD USER */
+
+div.add_organization_members
+{
+ margin-bottom: 10px;
+}
+
+div.add_organization_members span
+{
+ border-bottom: 1px solid #809aa9;
+ float:left;
+ font-size: 8pt !important;
+ font-family: Arial, Verdana, helvetica, sans-serif !important;
+ font-weight: bold;
+ position:aboslute;
+ width: 200px;
+}
+
+div.add_organization_members div
+{
+ font-weight: normal;
+ margin: 2px;
+ padding: 3px;
+ height: 150px;
+ overflow: auto;
+}
+
+div.add_organization_members div span
+{
+ border-bottom: 1px dashed #809aa9;
+ clear:both;
+ float:left;
+ font-weight: normal;
+ letter-spacing: 0.2em;
+ padding: 4px 0;
+ width: 98%
+}
+
+div.add_organization_members div#im_ldap_ou
+{
+ float: left;
+ width: 200px;
+}
+
+div.add_member_info
+{
+ margin: 10px 0;
+ display: none;
+}
+
+div.add_member_info span
+{
+ float: left;
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ margin-right: 3px;
+ text-align: right;
+ width: 80px;
+}
+
+div.add_action
+{
+ padding-bottom: 30px;
+ margin-left: 83px;
+ display: none;
+}
+
+div.add_action span
+{
+ background: #b4cfe5;
+ border: 1px solid;
+ float: left;
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ letter-spacing: 1px;
+ margin-right: 5px;
+ padding: 0 15px;
+ text-align: center;
+ line-height: 1.5em;
+}
+
+span.im_button
+{
+ background: #b4cfe5;
+ border: 1px solid;
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+ font-weight: bold;
+ letter-spacing: 1px;
+ padding: 0 15px;
+ text-align: center;
+ line-height: 1.5em;
+}
+
+div.loading
+{
+ background: #fdd url(../images/loading.gif) no-repeat 1px 1px;
+ border: 1px dashed #f00;
+ margin: 2px;
+ padding: 3px 3px 3px 20px;
+ text-align: center;
+}
+
+span.message_time
+{
+ color: #aaa;
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+}
+
+.font_menu
+{
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+}
+
+.layer
+{
+ background: url(../images/photo.png) no-repeat 2px 2px;
+ border: 1px solid #b4cfe5;
+ height: 65px;
+ margin: 2px;
+ padding: 2px 0px 2px 54px;
+}
+
+/* Disconnected */
+
+.disconnected
+{
+ font: 9pt Verdana, Arial, Helvetica, sans-serif;
+ border: 1px solid #b4cfe5;
+ margin: 2px;
+}
+
+/* Vcard */
+
+.vcard_user
+{
+ font: 9pt Verdana, Arial, Helvetica, sans-serif;
+ margin:10px;
+}
+
+.vcard_contact
+{
+ font: 9pt Verdana, Arial, Helvetica, sans-serif;
+ margin:10px;
+}
Index: tags/instant_messenger/templates/default/css/bkp.chat.css
===================================================================
--- tags/instant_messenger/templates/default/css/bkp.chat.css (revision 305)
+++ tags/instant_messenger/templates/default/css/bkp.chat.css (revision 305)
@@ -0,0 +1,129 @@
+/***** Chat *****/
+
+.avatar
+{
+ width: 49px;
+ height: 65px;
+ margin: 2px;
+ border: 1px solid;
+ border-color: #cecece;
+}
+
+.button_bold
+{
+ background: url(../images/bold.gif) no-repeat top center;
+ height: 20px;
+ width: 25px;
+ float: left;
+ position: relative;
+ margin-top: 2px;
+ margin-right: 2px;
+ cursor: pointer;
+}
+
+.button_italic
+{
+ background: url(../images/italicize.gif) no-repeat top center;
+ height: 20px;
+ width: 25px;
+ float: left;
+ position: relative;
+ margin-top: 2px;
+ margin-right: 2px;
+ cursor: pointer;
+}
+
+.button_underline
+{
+ background: url(../images/underline.gif) no-repeat top center;
+ height: 20px;
+ width: 25px;
+ float: left;
+ margin-top: 2px;
+ margin-right: 2px;
+ position: relative;
+ cursor: pointer;
+}
+
+.button_color
+{
+ background: url(../images/color.gif) no-repeat top center;
+ height: 20px;
+ width: 25px;
+ float: left;
+ position: relative;
+ margin-top: 2px;
+ margin-right: 2px;
+ cursor: pointer;
+}
+
+.button_emoticons
+{
+ background: url(../images/emoticonlabel.gif) no-repeat top center;
+ height: 19px;
+ width: 21px;
+ float: left;
+ position: relative;
+ margin-top: 2px;
+ cursor: pointer;
+}
+
+.button_profile
+{
+ background: url(../images/profileBuddy.gif) no-repeat top center;
+ height: 20px;
+ width: 25px;
+ float: left;
+ position: relative;
+ margin-top: 2px;
+ margin-left: 2px;
+ cursor: pointer;
+}
+
+.button_sendMessage
+{
+ background: url(../images/barn.gif) repeat top center;
+ height: 20px;
+ width: 50px;
+ color: #fff !important;
+ font: 9pt Verdana, arial, helvetica, serif;
+ font-weight: bold;
+ cursor: pointer;
+}
+
+.div_sendMessage
+{
+ float:right;
+ position: relative;
+ margin-top: 3px;
+ margin-left: 60px;
+}
+
+.history
+{
+ background: #fff;
+ border: 1px solid;
+ border-color: #b3b3b3 #cecece #cecece #b3b3b3;
+ width: 289px;
+ height: 180px;
+ cursor: text;
+ overflow: auto;
+}
+
+.messages
+{
+ background: #fff;
+ border: 1px solid;
+ border-color: #b3b3b3 #cecece #cecece #b3b3b3;
+ width: auto; /*289px;*/
+ height: 46px;
+ cursor: text;
+}
+
+.toolbar_buttons
+{
+ width:289px;
+ height:29px;
+}
+
+/***** Chat *****/
Index: tags/instant_messenger/templates/default/css/chat.css
===================================================================
--- tags/instant_messenger/templates/default/css/chat.css (revision 305)
+++ tags/instant_messenger/templates/default/css/chat.css (revision 305)
@@ -0,0 +1,101 @@
+/***** Chat *****/
+
+.chat_buttons
+{
+ cursor: pointer;
+ float: left;
+ height: 20px;
+ margin: 2px 2px 0 0;
+ position: relative;
+ width: 25px;
+}
+
+.button_bold
+{
+ background: url(../images/bold.gif) no-repeat top center;
+ display: none;
+}
+
+.button_italic
+{
+ background: url(../images/italicize.gif) no-repeat top center;
+ display: none;
+}
+
+.button_underline
+{
+ background: url(../images/underline.gif) no-repeat top center;
+ display: none;
+}
+
+.button_color
+{
+ background: url(../images/color.gif) no-repeat top center;
+ display: none;
+}
+
+.button_emoticons
+{
+ background: url(../images/emoticonlabel.gif) no-repeat top center;
+ display: none;
+}
+
+.button_profile
+{
+ background: url(../images/profileBuddy.gif) no-repeat top center;
+}
+
+.composing
+{
+ background: url(../images/typing.gif) no-repeat top center;
+ display: none;
+ float:right;
+ position: relative;
+}
+
+.sendMessage
+{
+ background: url(../images/barn.gif) repeat top center;
+ border: 1px solid #cecece;
+ color: #fff !important;
+ cursor: pointer;
+ float:right;
+ font: 12px Verdana, arial, helvetica, serif;
+ font-weight: bold;
+ height: 20px;
+ margin-top: 3px;
+ position: relative;
+ overflow: hidden;
+ text-align: center;
+ width: 50px;
+}
+
+.history
+{
+ background: #fff;
+ border: 1px solid;
+ border-color: #b3b3b3 #cecece #cecece #b3b3b3;
+ height: 180px;
+ cursor: text;
+ overflow: auto;
+}
+
+.messages
+{
+ background-color: #fff;
+ background-position:right !important;
+ background-repeat: no-repeat !important;
+ background-image: url(../images/photo.png);
+ border: 1px solid;
+ border-color: #b3b3b3 #cecece #cecece #b3b3b3;
+ cursor: text;
+ height: 65px;
+ padding-right:50px !important;
+}
+
+.toolbar_buttons
+{
+ height:29px;
+}
+
+/***** Chat *****/
Index: tags/instant_messenger/templates/default/css/window.css
===================================================================
--- tags/instant_messenger/templates/default/css/window.css (revision 321)
+++ tags/instant_messenger/templates/default/css/window.css (revision 321)
@@ -0,0 +1,108 @@
+/***** Cantos Arredondados *****/
+.corner { display: block; }
+.corner * { display: block; height: 1px; overflow: hidden; font-size: 0; }
+.corner1 { padding: 0 1px; margin: 0 3px; }
+.corner2 { padding: 0 1px; margin: 0 1px; }
+.corner3 { margin: 0 1px; }
+.blackcorner *{ background: #b4cfe5; }
+/***** Cantos Arredondados *****/
+
+/***** Window *****/
+.window
+{
+ font: 10pt Verdana, Arial, Helvetica, sans-serif;
+ margin: 0px;
+ position:fixed;
+}
+
+* html .window
+{
+ position:absolute;
+}
+
+#instant_messenger_content .body
+{
+ background: #b4cfe5;
+}
+
+#instant_messenger_content .titulo
+{
+ background: #b4cfe5;
+ cursor: pointer;
+ font: 8pt Verdana, Arial, Helvetica, sans-serif;
+ height: 20px;
+ line-height: 1.5em;
+ margin: 0 0;
+ overflow: hidden;
+ padding: 0 0 0 5px;
+}
+
+#instant_messenger_content .titulo .icon
+{
+ float:left;
+ height: 15px;
+ width: 15px;
+}
+
+#instant_messenger_content .titulo span
+{
+ float:left;
+ margin-left: 2px;
+}
+
+#instant_messenger_content .buttons
+{
+ position:absolute !important;
+ right:3px !important;
+ width:50px !important;
+}
+
+#instant_messenger_content .titulo .buttons div
+{
+ cursor: pointer;
+ float: right;
+ margin-right: 2px;
+ position: relative;
+ width: 13px;
+ height:13px;
+}
+
+#instant_messenger_content .button_minimize
+{
+ background: #b4cfe5 url(../images/window_min.gif) no-repeat top center;
+}
+
+#instant_messenger_content .button_maximize1
+{
+ background: #b4cfe5 url(../images/window_max1.gif) no-repeat top center;
+}
+
+#instant_messenger_content .button_maximize
+{
+ background: #b4cfe5 url(../images/window_max.gif) no-repeat top center;
+}
+
+#instant_messenger_content .button_close
+{
+ background: #b4cfe5 url(../images/window_close.gif) no-repeat top center;
+ margin-right: 0px;
+}
+
+#instant_messenger_content .content
+{
+ font: 9pt Verdana, Arial, Helvetica, sans-serif;
+ background: #fff;
+ border: 1px solid;
+ border-color: #b3b3b3 #c1d6eb #c1d6eb #b3b3b3;
+ margin: 0px 5px;
+ cursor: default;
+ overflow: auto;
+}
+
+#instant_messenger_content .rodape
+{
+ background: #b4cfe5 url(../images/handle.gif) no-repeat bottom right;
+ height: 15px;
+}
+
+/***** Window - *****/
Index: tags/instant_messenger/templates/default/setup.js
===================================================================
--- tags/instant_messenger/templates/default/setup.js (revision 318)
+++ tags/instant_messenger/templates/default/setup.js (revision 318)
@@ -0,0 +1,58 @@
+(function()
+{
+ // Envio para o PHP
+ var connection = new IMConnector('instant_messenger/');
+
+ function getInputs(pDocument)
+ {
+ var form = pDocument.forms[0];
+ var values = "";
+ var field_blank = false;
+
+ for( var i = 0 ; i < form.elements.length; i++ )
+ {
+
+ switch(form.elements[i].type)
+ {
+ case "text" :
+ if ( form.elements[i].value != "" )
+ values += form.elements[i].id.toUpperCase() + ";" + escape(form.elements[i].value) + "\n";
+ else
+ field_blank = true;
+ break;
+
+ case "password" :
+ if ( form.elements[i].value == "" )
+ field_blank = true;
+ break;
+ }
+ }
+
+ if(!field_blank)
+ {
+ values = values.substring(0,(values.length - 1 ));
+ connection.go("$this.FileDefine.getParams", "val=" + values);
+ pDocument.forms[0].submit();
+ }
+ else
+ {
+ alert('Informe todos os campos!');
+ return false;
+ }
+ }
+
+ function sendf()
+ {
+ var doc = ( arguments.length == 1) ? arguments[0] : false;
+
+ if( doc )
+ getInputs(doc);
+ }
+
+ function constructScript(){}
+
+ // Dando acesso externo as funções;
+ constructScript.prototype.sendf = sendf;
+ window.constructScript = constructScript;
+}
+)();