source: trunk/expressoMail1_2/inc/class.functions.inc.php @ 1036

Revision 1036, 4.1 KB checked in by amuller, 15 years ago (diff)

Ticket #559 - Atualização de segurança

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2        $GLOBALS['phpgw_info']['flags'] = array(
3                'currentapp' => 'expressoMail1_2',
4                'nonavbar'   => true,
5                'noheader'   => true
6        );
7
8        require_once $_SERVER[ 'DOCUMENT_ROOT' ] . '/header.inc.php';
9        class Functions{
10               
11               
12                function CallVoipConnect($params){
13                        $fromNumber = $_SESSION['phpgw_info']['user']['preferences']['expressoMail']['telephone_number'];
14                        if(!$fromNumber)
15                                return false;
16                        $fromNumber = substr($fromNumber,strlen($fromNumber) - 4, strlen($fromNumber) - 1);
17                        $toNumber       = $params['to'] ? substr($params['to'],strlen($params['to']) - 4, strlen($params['to']) - 1) : 0;
18                       
19                        $voipServer     = $_SESSION['phpgw_info']['expressomail']['server']['voip_server'];
20                        $voipUrl        = $_SESSION['phpgw_info']['expressomail']['server']['voip_url'];
21                        $voipPort       = $_SESSION['phpgw_info']['expressomail']['server']['voip_port'];
22                       
23                        // Se for celular, passa os digitos do número e conecta com outro VoIP Server.....
24                        if($params['typePhone'] == 'mob'){
25                                $toNumber       = $params['to'];
26                                $voipServer     = $_SESSION['phpgw_info']['expressomail']['server']['voip_server'];
27                                $voipUrl        = $_SESSION['phpgw_info']['expressomail']['server']['voip_url'];
28                                $voipPort       = $_SESSION['phpgw_info']['expressomail']['server']['voip_port'];                               
29                        }       
30                               
31                        if(!$voipServer || !$voipUrl || !$voipPort)
32                                return false;
33                        $url            = "http://".$voipServer.":".$voipPort.$voipUrl."?magic=1333&acao=liga&ramal=".$fromNumber."&numero=".$toNumber;                 
34                        $sMethod = 'GET ';
35            $crlf = "\r\n";
36            $sRequest = " HTTP/1.1" . $crlf;
37            $sRequest .= "Host: localhost" . $crlf;
38            $sRequest .= "Accept: */* " . $crlf;
39            $sRequest .= "Connection: Close" . $crlf . $crlf;           
40            $sRequest = $sMethod . $url . $sRequest;   
41            $sockHttp = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);           
42            if (!$sockHttp)  {
43                return false;
44            }
45            $resSocketConnect = socket_connect($sockHttp, $voipServer, $voipPort);
46            if (!$resSocketConnect) {
47                return false;
48            }
49            $resSocketWrite = socket_write($sockHttp, $sRequest, strlen($sRequest));
50            if (!$resSocketWrite) {
51                return false;
52            }   
53            $sResponse = '';   
54            while ($sRead = socket_read($sockHttp, 512)) {
55                $sResponse .= $sRead;
56            }           
57           
58            socket_close($sockHttp);           
59            $pos = strpos($sResponse, $crlf . $crlf);
60            return substr($sResponse, $pos + 2 * strlen($crlf));                                                                       
61                }
62
63                function getDirContents($dir){
64                        //$dir = dirname($dir);
65       
66                        if (!is_dir($dir))      {
67                                        return 'Error: Cannot load files in :'. $dir.' !';
68                        }
69                       
70                        if ($root=@opendir($dir))       {
71                       
72                       while ($file=readdir($root))     {                 
73                           if($file!="." && $file!="..")
74                                   $files[]=$dir."/".$file;           
75                       }
76                       
77                        }
78                       
79                   return $files;
80                }
81                               
82                function getFilesJs($includeFiles = '', $update_version = ''){
83                       
84                        $files = $this -> getDirContents('js');
85                        $str_files = '';
86                       
87                        if($includeFiles) {
88                                $includeFiles = explode(",",trim($includeFiles));
89                                // Bug fixed for array_search function
90                                $includeFiles[count($includeFiles)] = $includeFiles[0];
91                                $includeFiles[0] = null;
92                                // End Bug fixed.
93                        }                                                                                                               
94                        for($i = 0; $i < count($files); $i++) {                         
95                                if(count(explode('.js',$files[$i])) > 1) {
96                                        if($includeFiles  && array_search(trim($files[$i]),$includeFiles)){     
97                                                $str_files .= "<script src='".$files[$i]."?".$update_version."' type='text/javascript'></script>";                                             
98                                        }
99                                }
100                        }
101                       
102                        return $str_files;
103                }                                                               
104
105                function getReturnExecuteForm(){
106                        $response = $_SESSION['response'];
107                        $_SESSION['response'] = null;
108                        return $response;
109                }
110               
111                function getLang($key){
112                        if ($_SESSION['phpgw_info']['expressomail']['lang'][$key])
113                        return $_SESSION['phpgw_info']['expressomail']['lang'][$key];                   
114                        else
115                                return ($key . '*');
116                }
117
118                function get_preferences()      {
119                        return $_SESSION['phpgw_info']['user']['preferences']['expressoMail'];
120                }
121        }
122?>
Note: See TracBrowser for help on using the repository browser.