source: sandbox/2.4.1-3/phpgwapi/templates/default/login_default.php @ 6352

Revision 6352, 24.9 KB checked in by gustavo, 12 years ago (diff)

Ticket #2768 - Melhorias na inserção de destinatários na criacao de mensagem

  • Property svn:executable set to *
Line 
1<?php
2        /**************************************************************************\
3        * eGroupWare login                                                         *
4        * http://www.egroupware.org                                                *
5        * Originaly written by Dan Kuykendall <seek3r@phpgroupware.org>            *
6        *                      Joseph Engo    <jengo@phpgroupware.org>             *
7        * Updated by Nilton Emilio Buhrer Neto <niltonneto@celepar.pr.gov.br>      *
8        *  This program is free software; you can redistribute it and/or modify it *
9        *  under the terms of the GNU General Public License as published by the   *
10        *  Free Software Foundation; either version 2 of the License, or (at your  *
11        *  option) any later version.                                              *
12        \**************************************************************************/
13
14function check_logoutcode($code)
15        {
16                switch($code)
17                {
18                        case 1:
19                                return lang('You have been successfully logged out');
20                               
21                        case 2:
22                                return lang('Sorry, your login has expired');
23                               
24                        case 4:
25                                return lang('Cookies are required to login to this site.');
26                               
27                        case 5:
28                                return '<font color="FF0000">' . lang('Bad login or password') . '</font>';
29
30                        case 6:
31                                return '<font color="FF0000">' . lang('Your password has expired, and you do not have access to change it') . '</font>';
32                               
33                        case 98:
34                                return '<font color="FF0000">' . lang('Account is expired') . '</font>';
35                               
36                        case 99:
37                                return '<font color="FF0000">' . lang('Blocked, too many attempts(%1)! Retry in %2 minute(s)',$GLOBALS['phpgw_info']['server']['num_unsuccessful_id'],$GLOBALS['phpgw_info']['server']['block_time']) . '</font>';
38                        case 200:
39                            //return '<font color="FF0000">' . lang('Invalid code') . '</font>';
40                return '<font color="FF0000">' . lang('Bad login or password') . '</font>';
41                            break;
42                        case 10:
43                                $GLOBALS['phpgw']->session->phpgw_setcookie('sessionid');
44                                $GLOBALS['phpgw']->session->phpgw_setcookie('kp3');
45                                $GLOBALS['phpgw']->session->phpgw_setcookie('domain');
46
47                                //fix for bug php4 expired sessions bug
48                                if($GLOBALS['phpgw_info']['server']['sessions_type'] == 'php4')
49                                {
50                                        $GLOBALS['phpgw']->session->phpgw_setcookie(PHPGW_PHPSESSID);
51                                }
52
53                                return '<font color="#FF0000">' . lang('Your session could not be verified.') . '</font>';
54                               
55                        default:
56                                return '';
57                }
58        }
59        function troca_espaco_por_mais($pem_data)
60        {
61            $begin = "CERTIFICATE-----";
62            $end   = "-----END";
63            $aux = substr($pem_data, strpos($pem_data, $begin)+strlen($begin));
64            $aux = substr($aux, 0, strpos($aux, $end));
65            $aux = strtr($aux,' ','+');
66            $aux = '-----BEGIN CERTIFICATE-----'.$aux.'-----END CERTIFICATE-----';
67            return $aux;
68        }
69        $ifMobile = false;
70        $browser = CreateObject('phpgwapi.browser');
71        switch ( $browser->get_platform() )
72        {
73                case browser::PLATFORM_IPHONE:
74                case browser::PLATFORM_IPOD:
75                case browser::PLATFORM_IPAD:
76                case browser::PLATFORM_BLACKBERRY:
77                case browser::PLATFORM_NOKIA:
78                case browser::PLATFORM_ANDROID:
79                        $ifMobile = true;
80                        break;
81        }
82       
83        if( $ifMobile && $_GET['dont_redirect_if_moble'] != 1 )
84        {
85                $GLOBALS['phpgw']->redirect_link('/mobile/login.php');
86        }
87        else
88        {
89        /* Program starts here */
90       
91        if($GLOBALS['phpgw_info']['server']['auth_type'] == 'http' && isset($_SERVER['PHP_AUTH_USER']))
92        {
93                $submit = True;
94                $login  = $_SERVER['PHP_AUTH_USER'];
95                $passwd = $_SERVER['PHP_AUTH_PW'];
96                $passwd_type = 'text';
97        }
98        else
99        {
100                $passwd = $_POST['passwd'];
101                $passwd_type = $_POST['passwd_type'];
102        }
103
104        # Apache + mod_ssl style SSL certificate authentication
105        # Certificate (chain) verification occurs inside mod_ssl
106        if($GLOBALS['phpgw_info']['server']['auth_type'] == 'sqlssl' && isset($_SERVER['SSL_CLIENT_S_DN']) && !isset($_GET['cd']))
107        {
108                # an X.509 subject looks like:
109                # /CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/
110                # the username is deliberately lowercase, to ease LDAP integration
111                $sslattribs = explode('/',$_SERVER['SSL_CLIENT_S_DN']);
112                # skip the part in front of the first '/' (nothing)
113                while($sslattrib = next($sslattribs))
114                {
115                        list($key,$val) = explode('=',$sslattrib);
116                        $sslattributes[$key] = $val;
117                }
118
119                if(isset($sslattributes['Email']))
120                {
121                        $submit = True;
122
123                        # login will be set here if the user logged out and uses a different username with
124                        # the same SSL-certificate.
125                        if(!isset($_POST['login'])&&isset($sslattributes['Email']))
126                        {
127                                $login = $sslattributes['Email'];
128                                # not checked against the database, but delivered to authentication module
129                                $passwd = $_SERVER['SSL_CLIENT_S_DN'];
130                        }
131                }
132                unset($key);
133                unset($val);
134                unset($sslattributes);
135        }
136        if(isset($_POST['certificado']) && $_POST['certificado'])
137        {
138
139            $_SESSION['login_certificado'] = troca_espaco_por_mais(str_replace(chr(0x0D).chr(0x0A),chr(0x0A),str_replace(chr(0x0A).chr(0x0A),chr(0x0A),$_POST['certificado'])));
140        }
141    if( isset( $_GET[ 'cd' ] ) && ( $_GET['cd']=='1' || $_GET['cd'] == 10 ) )
142        {
143            $_SESSION['contador'] = 0;
144        }
145
146        if(isset($passwd_type) || $_POST['submitit_x'] || $_POST['submitit_y'] || $submit)
147        {
148       
149            // Primeiro testa o captcha....se houver......
150            if($GLOBALS['phpgw_info']['server']['captcha']==1)
151              {
152                if($_SESSION['contador'] > $GLOBALS['phpgw_info']['server']['num_badlogin'])
153                    {
154                        if ($_SESSION['CAPTCHAString'] != trim(strtoupper($_POST['codigo'])))
155                                {
156                                        if(!$_GET['cd'])
157                                        {
158                                            $_GET['cd'] = '200';
159                                        }
160                                }
161                        unset($_SESSION['CAPTCHAString']);
162                    }
163              }
164                if($_POST['user']) {
165                        if($GLOBALS['phpgw_info']['server']['use_prefix_organization']) {
166                                $common = CreateObject('phpgwapi.common');
167                                $ldap_conn = $common->ldapConnect();
168                                $justthese = array("uid");
169                                $filter="(&(phpgwAccountType=u)(uid=".$_POST['user']."))";
170                                $ldap_search = ldap_search($ldap_conn, $GLOBALS['phpgw_info']['server']['ldap_context'], $filter, $justthese);
171                                $ldap_info       = ldap_get_entries($ldap_conn, $ldap_search);
172                                ldap_close($ldap_conn);
173                                if ($ldap_info['count'] != 0) {
174                                        $_POST['login'] = $_POST['user'];
175                                }
176                        }
177                        else
178                                $_POST['login'] = $_POST['user'];
179
180                        /**
181                         * LOGIN OAUTH POR CURL
182                         */
183                        $ch = curl_init();
184
185                        $param  = 'grant_type=password';
186                        $param .= '&client_id=' . $GLOBALS['oauth']['client_id'];
187                        $param .= '&client_secret=' . $GLOBALS['oauth']['client_secret'];
188                        $param .= '&username=' . $_POST['user'];
189                        $param .= '&password=' . $_POST['passwd'];
190
191                        // set URL and other appropriate options
192                        curl_setopt($ch, CURLOPT_URL, $GLOBALS['oauth']['url_token']);
193                        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*'));
194                        curl_setopt($ch, CURLOPT_POST, TRUE);
195                        curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
196                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  //configura para nao imprimir a saida na tela
197                        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);//Passe um nï¿œmero long como parï¿œmetro que contï¿œm o limite de tempo, em segundos, que vocï¿œ permite as funᅵᅵes CURL levar.
198
199                        // grab URL and pass it to the browser
200                        $res = curl_exec($ch);
201                       
202                        // close cURL resource, and free up system resources
203                        curl_close($ch);
204                        $a = json_decode($res);
205       
206                        if ( isset($a->access_token) ) {
207                                $_SESSION['oauth']['access_token'] = $a->access_token;
208                                $_SESSION['oauth']['expires_in'] = $a->expires_in;
209                                $_SESSION['oauth']['token_type'] = $a->token_type;
210                                $_SESSION['oauth']['scope'] = $a->scope;
211                                $_SESSION['oauth']['refresh_token'] = $a->refresh_token;
212                               
213                               
214                        }
215                        else {
216                        }
217                        /**
218                         * ####################
219                         */
220
221                }
222                if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' &&
223                        !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN']))
224                {
225                        if(!$_GET['cd'])
226                            {
227                                $_GET['cd'] = '5';
228                            }
229                }
230               
231                // don't get login data again when $submit is true
232                if($submit == false)
233                {
234                        $login = $_POST['login'];
235                }
236               
237                if(strstr($login,'@') === False && isset($_POST['logindomain']))
238                {
239                        $login .= '@' . $_POST['logindomain'];
240                }
241                elseif(!isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
242                {
243                        $login .= '@'.$GLOBALS['phpgw_info']['server']['default_domain'];
244                }
245               
246                If(!$_GET['cd'])
247                        $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create(strtolower($login),$passwd,$passwd_type,'u');
248
249                if(!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
250                {
251                        If(!$_GET['cd']) $_GET['cd'] = $GLOBALS['phpgw']->session->cd_reason;
252                }
253                else
254                {
255                        if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2}){0,1}$/',$_POST['lang']) &&
256                            $_POST['lang'] != $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])
257                        {
258                                $GLOBALS['phpgw']->preferences->add('common','lang',$_POST['lang'],'session');
259                        }
260
261                        if(!$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles'])
262                        {
263                                $GLOBALS['phpgw']->translation->autoload_changed_langfiles();
264                        }
265                        $forward = isset($_GET['phpgw_forward']) ? urldecode($_GET['phpgw_forward']) : @$_POST['phpgw_forward'];
266                        if (!$forward)
267                        {
268                                $extra_vars['cd'] = 'yes';
269                                $forward = '/home.php';
270                        }
271                        else
272                        {
273                                list($forward,$extra_vars) = explode('?',$forward,2);
274                        }
275                if ($GLOBALS['phpgw_info']['server']['use_https'] != 2)
276                        {
277                        //Modificacao feita para que o Expresso redirecione para o primeiro proxy caso haja um encadeamento de mais de um proxy.
278                        //$forward = 'http://'.$_SERVER['HTTP_HOST'].($GLOBALS['phpgw']->link($forward.'?cd=yes'));
279                        $forward = 'http://' . nearest_to_me() . $GLOBALS['phpgw']->link($forward.'?cd=yes');
280                        echo "<script language='Javascript1.3'>location.href='".$forward."'</script>";
281                        }
282                else
283                        {
284                        $GLOBALS['phpgw']->redirect_link($forward,$extra_vars);
285                        }
286                }
287        }
288        //else   // =================================================================================
289        //{
290            $valor_contador = $_SESSION['contador'];
291            $valor_contador = $valor_contador + 1;
292            $_SESSION['contador'] = $valor_contador;
293                // !!! DONT CHANGE THESE LINES !!!
294                // If there is something wrong with this code TELL ME!
295                // Commenting out the code will not fix it. (jengo)
296                if(isset($_COOKIE['last_loginid']))
297                {
298                        $accounts = CreateObject('phpgwapi.accounts');
299                        $prefs = CreateObject('phpgwapi.preferences', $accounts->name2id($_COOKIE['last_loginid']));
300
301                        if($prefs->account_id)
302                        {
303                                $GLOBALS['phpgw_info']['user']['preferences'] = $prefs->read_repository();
304                        }
305                }
306               
307                $_GET['lang'] = addslashes($_GET['lang']);
308                if ($_GET['lang'])
309                {
310                        $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $_GET['lang'];
311                }
312                elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id)
313                {
314                        // If the lastloginid cookies isn't set, we will default to the first language,
315                        // the users browser accepts.
316                        list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
317                        /*
318                        if(strlen($lang) > 2)
319                        {
320                                $lang = substr($lang,0,2);
321                        }
322                        */
323                        $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang;
324
325                        if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme']))
326                        {
327                                $prefs2 = CreateObject('phpgwapi.preferences');
328                                $temp_pref = $prefs2->read_repository();
329                                $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $temp_pref['common']['theme'];
330                        }
331                }
332                #print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '<br>';
333
334                $GLOBALS['phpgw']->translation->init(); // this will set the language according to the (new) set prefs
335                $GLOBALS['phpgw']->translation->add_app('login');
336                $GLOBALS['phpgw']->translation->add_app('loginscreen');
337                if(lang('loginscreen_message') == 'loginscreen_message*')
338                {
339                        $GLOBALS['phpgw']->translation->add_app('loginscreen','en');    // trying the en one
340                }
341                if(lang('loginscreen_message') != 'loginscreen_message*')
342                {
343                        $tmpl->set_var('lang_message',stripslashes(lang('loginscreen_message')));
344                }
345        //}
346
347        if($GLOBALS['phpgw_info']['server']['use_prefix_organization'])
348        {
349                $obj_organization = CreateObject('phpgwapi.sector_search_ldap');
350                $organizations = $obj_organization->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']);
351               
352                for ($i=0; $i<count($organizations); $i++)
353                {
354                        $tmp_array[strtolower($organizations[$i])] = $organizations[$i];       
355                }
356               
357                $arrayOrganization = $tmp_array;               
358                ksort($arrayOrganization);
359               
360                foreach($arrayOrganization
361                         as $organization_name => $organization_vars)
362                {
363                        $organization_select .= '<option value="' . $organization_name . '"';
364
365                        if($organization_name == $_COOKIE['last_organization'])
366                        {
367                                $organization_select .= ' selected';
368                        }
369                        $organization_select .= '>' . $organization_vars . "</option>\n";
370                }
371                $organization_select =  '<div class="login_label"><label>'.lang("organization")
372                                                        .'</label><br><select name="organization">'
373                                                        .$organization_select.'</select></div>';
374                $tmpl->set_var('select_organization',$organization_select);
375        }
376               
377        $domain_select = '&nbsp;';
378        $last_loginid = $_COOKIE['last_loginid'];
379        if($GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
380        {
381                $domain_select = "<select name=\"logindomain\">\n";
382                foreach($GLOBALS['phpgw_domain'] as $domain_name => $domain_vars)
383                {
384                        $domain_select .= '<option value="' . $domain_name . '"';
385
386                        if($domain_name == $_COOKIE['last_domain'])
387                        {
388                                $domain_select .= ' selected';
389                        }
390                        $domain_select .= '>' . $domain_name . "</option>\n";
391                }
392                $domain_select .= "</select>\n";
393        }
394        elseif($last_loginid !== '')
395        {
396                reset($GLOBALS['phpgw_domain']);
397                list($default_domain) = each($GLOBALS['phpgw_domain']);
398
399                if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain']))
400                {
401                        $last_loginid .= '@' . $_COOKIE['last_domain'];
402                }
403        }
404        $tmpl->set_var('select_domain',$domain_select);
405
406        foreach($_GET as $name => $value)
407        {
408                if(preg_match('/phpgw_/',$name))
409                {
410                        $extra_vars .= '&' . $name . '=' . urlencode($value);
411                }
412        }
413
414        if ( is_string( $extra_vars ) )
415        {
416                $extra_vars = '?' . substr($extra_vars,1);
417        }
418
419        /********************************************************\
420        * Check is the registration app is installed, activated  *
421        * And if the register link must be placed                *
422        \********************************************************/
423       
424        $cnf_reg = createobject('phpgwapi.config','registration');
425        $cnf_reg->read_repository();
426        $config_reg = $cnf_reg->config_data;
427
428        if($config_reg[enable_registration]=='True' && $config_reg[register_link]=='True')
429        {
430                $reg_link='&nbsp;<a href="registration/">'.lang('Not a user yet? Register now').'</a><br/>';
431        }
432
433        $template = $GLOBALS['phpgw_info']['login_template_set'];
434        $GLOBALS['phpgw_info']['server']['template_set'] = $template;
435
436        $tmpl->set_var('register_link',$reg_link);
437        $tmpl->set_var('charset',$GLOBALS['phpgw']->translation->charset());
438        $tmpl->set_var('login_url', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
439        $tmpl->set_var('registration_url',$GLOBALS['phpgw_info']['server']['webserver_url'] . '/registration/');
440        $tmpl->set_var('version',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
441        $tmpl->set_var('cd',check_logoutcode($_GET['cd']));
442        $tmpl->set_var('cookie',$last_loginid);
443
444        $tmpl->set_var('lang_username',lang('username'));
445        $tmpl->set_var('lang_password',lang('password'));
446        $tmpl->set_var('lang_login',lang('login'));
447
448        $tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']);
449        $tmpl->set_var('template_set', $template);
450
451        // loads the template's login.css
452        // and then the theme's login.css (if any)
453        $template_dir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/' . $template;
454        $login_dir = $template_dir . '/login.css';
455        $login_css = "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />";
456        $login_dir = $template_dir . '/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '/login.css';
457        if(file_exists('./'.$login_dir))
458        {
459                $login_css .= "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />";
460        }
461        $tmpl->set_var('login_css',$login_css);
462
463        $GLOBALS['phpgw']->translation->add_app('loginhelp',$_GET['lang']);
464
465        if(lang('loginhelp_message') != 'loginhelp_message*' && trim(lang('loginhelp_message')) != ""){                                 
466                $tmpl->set_var('lang_help',lang("Help"));       
467        }
468        else
469                $tmpl->set_var('display_help','none');
470
471        $tmpl->set_var('bg_color',($GLOBALS['phpgw_info']['server']['login_bg_color']?$GLOBALS['phpgw_info']['server']['login_bg_color']:'FFFFFF'));
472        $tmpl->set_var('bg_color_title',($GLOBALS['phpgw_info']['server']['login_bg_color_title']?$GLOBALS['phpgw_info']['server']['login_bg_color_title']:'486591'));
473
474        if($GLOBALS['phpgw_info']['server']['use_frontend_name'])
475                $tmpl->set_var('frontend_name', " - ".$GLOBALS['phpgw_info']['server']['use_frontend_name']);
476
477        if (substr($GLOBALS['phpgw_info']['server']['login_logo_file'],0,4) == 'http')
478        {
479                $var['logo_file'] = $GLOBALS['phpgw_info']['server']['login_logo_file'];
480        }
481        else
482        {
483                $var['logo_file'] = $GLOBALS['phpgw']->common->image('phpgwapi',$GLOBALS['phpgw_info']['server']['login_logo_file']?$GLOBALS['phpgw_info']['server']['login_logo_file']:'logo');
484        }
485        $var['logo_url'] = $GLOBALS['phpgw_info']['server']['login_logo_url']?$GLOBALS['phpgw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
486        if (substr($var['logo_url'],0,4) != 'http')
487        {
488                $var['logo_url'] = 'http://'.$var['logo_url'];
489        }
490        $var['logo_title'] = $GLOBALS['phpgw_info']['server']['login_logo_title']?$GLOBALS['phpgw_info']['server']['login_logo_title']:'www.eGroupWare.org';
491        $tmpl->set_var($var);
492
493        if (!@$GLOBALS['phpgw_info']['server']['login_virtual_keyboard'])
494                $tmpl->set_var('show_kbd','none');
495
496        if (@$GLOBALS['phpgw_info']['server']['login_show_language_selection'])
497        {
498                $select_lang = '<select name="lang" onchange="'."location.href=location.href+(location.search?'&':'?')+'lang='+this.value".'">';
499                $langs = $GLOBALS['phpgw']->translation->get_installed_langs();
500                uasort($langs,'strcasecmp');
501                foreach ($langs as $key => $name)       // if we have a translation use it
502                {
503                        $select_lang .= "\n\t".'<option value="'.$key.'"'.($key == $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] ? ' selected="1"' : '').'>'.$name.'</option>';
504                }
505                $select_lang .= "\n</select>\n";
506                $tmpl->set_var(array(
507                        'lang_language' => lang('Language'),
508                        'select_language' => $select_lang,
509                ));
510        }
511        else
512        {
513                $tmpl->set_block('login_form','language_select');
514                $tmpl->set_var('language_select','');
515        }
516
517        $tmpl->set_var('autocomplete', ($GLOBALS['phpgw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
518
519        // soh mostra o captcha se for login sem certificado....
520        if($GLOBALS['phpgw_info']['server']['captcha'] && $_GET['cd']!='300' )
521        {
522                $aux_captcha = '<input type="hidden" name="' . session_name() . '"  value="' . session_id() . '" >';
523        //        setcookie(session_name(),base64_encode(session_convert($key_convert . session_id(),$key_convert)),0);
524                if($valor_contador > $GLOBALS['phpgw_info']['server']['num_badlogin'])
525                {
526                        $aux_captcha = '<div class="login_label" >
527                           <img id="id_captcha" src="./security/captcha.php?' . session_name() . '=' . session_id() . '" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="position:static;">
528                           <input class="input" type="text" maxlength="50" size="20" name="codigo" id="codigo" value="" >
529                           <input type="hidden" name="' . session_name() . '"  value="' . session_id() . '" >
530                           </div>';
531                }
532        }
533        $tmpl->set_var('captcha',$aux_captcha);
534
535        // Testa se deve incluir applet para login com certificado......
536        if ($_GET['cd']=='300' && $GLOBALS['phpgw_info']['server']['certificado']==1)
537        {
538                //Zera o Cookie contador, responsavel pelo captcha
539                $_SESSION['contador'] = 0;
540                $valor_contador = 0;
541                $link_alterna_login = '<img src="phpgwapi/templates/default/images/warning.gif"/><a href="login.php">' . lang('Access without Digital Certificate') . '</a>';
542                $tmpl->set_var('show','none');
543                $tmpl->set_var('action','<div id="action"><img style="border:0px;margin:31px 0px 58px 0px;" src="phpgwapi/templates/default/images/acao.gif" /></div>');
544                // gera parametro com tokens suportados ....
545                $var_tokens = '';
546                for($ii = 1; $ii < 11; $ii++)
547                {
548                        if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'])
549                                $var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ',';
550                }
551
552                if(!$var_tokens)
553                {
554                        $var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll';
555                }
556                $param1 = "
557                                                                                        '<param name=\"token\" value=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\"> ' +
558                                                                                   ";
559                $param2 = "
560                                                                                        'token=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\" ' +
561                                                                                   ";
562
563                $cod_applet =
564
565/*    // com debug ativado
566            '<script type="text/javascript">
567                                        if (navigator.userAgent.match(\'MSIE\')){
568                                                document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' +
569                                                \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' +
570                                                \'<param name="type" value="application/x-java-applet;version=1.5"> \' +
571                                                \'<param name="code" value="LoginApplet.class"> \' +
572                                                \'<param name="locale" value="' . $lang . '"> \' +
573                                                \'<param name="mayscript" value="true"> \' + '
574                                                . $param1
575                                                . ' \'<param name="archive" value="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar"> \' +
576                        \'<param name="debug" value="true"> \' +
577                                                \'</object>\');
578                                        }
579                                        else {
580                                                document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" code="LoginApplet.class" locale="' . $lang . '"\' +
581                                                \'archive="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar" \' + '
582                                                . $param2
583                                                . ' \'type="application/x-java-applet;version=1.5" debug= "true" mayscript > \' +
584                                                \'<noembed> \' +
585                                                \'No Java Support. \' +
586                                                \'</noembed> \' +
587                                                \'</embed> \');
588                                        }
589                                </script>';
590*/
591            // sem debug ativado
592            '<script type="text/javascript">
593                                        if (navigator.userAgent.match(\'MSIE\')){
594                                                document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' +
595                                                \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' +
596                                                \'<param name="type" value="application/x-java-applet;version=1.5"> \' +
597                                                \'<param name="codebase" value="/security/">\' +
598                                                \'<param name="code" value="LoginApplet.class"> \' +
599                                                \'<param name="locale" value="' . $lang . '"> \' +
600                                                \'<param name="mayscript" value="true"> \' + '
601                                                . $param1
602                                                . ' \'<param name="archive" value="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar"> \' +
603                                                \'</object>\');
604                                        }
605                                        else {
606                                                document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" codebase="/security/" code="LoginApplet.class" locale="' . $lang . '"\' +
607                                                \'archive="ExpressoCertLogin.jar,ExpressoCert.jar,commons-httpclient-3.1.jar,commons-logging-1.1.1.jar,commons-codec-1.3.jar,bcmail-jdk15-142.jar,mail.jar,activation.jar,bcprov-jdk15-142.jar" \' + '
608                                                . $param2 
609                                                . ' \'type="application/x-java-applet;version=1.5" mayscript > \' +
610                                                \'<noembed> \' +
611                                                \'No Java Support. \' +
612                                                \'</noembed> \' +
613                                                \'</embed> \');
614                                        }
615                                </script>';
616
617
618        }
619
620        else
621        {
622                if($GLOBALS['phpgw_info']['server']['certificado']==1)
623                {
624                        $tmpl->set_var('show','yes');
625                        $link_alterna_login = '<img src="phpgwapi/templates/default/images/lock1_icon.gif"/><a title="' . lang('Link to use digital certificate') . '" href="login.php?cd=300">' . lang('Logon with my digital certificate') . '</a>';
626                }
627                $tmpl->set_var('lang_username',lang('username'));
628                $tmpl->set_var('action','');
629                $cod_applet = '';
630
631        }
632
633        $tmpl->set_var('applet',$cod_applet);
634        $tmpl->set_var('link_alterna_login',$link_alterna_login);
635
636
637        $tmpl->set_var('dir_root', 'http://' . nearest_to_me() . '/');
638        if(is_file(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php'))
639        include_once(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php');
640        if(isset($ultima_revisao)) $tmpl->set_var('ultima_rev','<br>' . $ultima_revisao);
641
642        // Adiciona cï¿œdigo personalizado de outro template
643        // que esteja utilizando o login_default.php
644        if(is_file('.'.$template_dir.'/login.inc.php')) {
645                include_once('.'.$template_dir.'/login.inc.php');
646        }
647
648        $tmpl->pfp('loginout','login_form');
649        }
650
651?>
652
Note: See TracBrowser for help on using the repository browser.