source: trunk/phpgwapi/templates/default/login_default.php @ 6528

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

Ticket #2766 - Merge do branch das novas funcionalidaes para o trunk

  • 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                        $restConf = parse_ini_file( __DIR__ . '/../../../prototype/config/REST.ini', true );
186
187                        $param  = 'grant_type=password';
188                        $param .= '&client_id=' . $restConf['oauth']['client_id'];
189                        $param .= '&client_secret=' . $restConf['oauth']['client_secret'];
190                        $param .= '&username=' . $_POST['user'];
191                        $param .= '&password=' . $_POST['passwd'];
192
193                        // set URL and other appropriate options
194                        curl_setopt($ch, CURLOPT_URL, $restConf['oauth']['url_token']);
195                        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*'));
196                        curl_setopt($ch, CURLOPT_POST, TRUE);
197                        curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
198                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);  //configura para nao imprimir a saida na tela
199                        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.
200
201                        // grab URL and pass it to the browser
202                        $res = curl_exec($ch);
203                       
204                        // close cURL resource, and free up system resources
205                        curl_close($ch);
206                        $a = json_decode($res);
207       
208                        if ( isset($a->access_token) ) {
209                                $_SESSION['oauth']['access_token'] = $a->access_token;
210                                $_SESSION['oauth']['expires_in'] = $a->expires_in;
211                                $_SESSION['oauth']['token_type'] = $a->token_type;
212                                $_SESSION['oauth']['scope'] = $a->scope;
213                                $_SESSION['oauth']['refresh_token'] = $a->refresh_token;
214                               
215                        }
216                        else {
217                        }
218                        /**
219                         * ####################
220                         */
221
222                }
223                if(getenv('REQUEST_METHOD') != 'POST' && $_SERVER['REQUEST_METHOD'] != 'POST' &&
224                        !isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['SSL_CLIENT_S_DN']))
225                {
226                        if(!$_GET['cd'])
227                            {
228                                $_GET['cd'] = '5';
229                            }
230                }
231               
232                // don't get login data again when $submit is true
233                if($submit == false)
234                {
235                        $login = $_POST['login'];
236                }
237               
238                if(strstr($login,'@') === False && isset($_POST['logindomain']))
239                {
240                        $login .= '@' . $_POST['logindomain'];
241                }
242                elseif(!isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
243                {
244                        $login .= '@'.$GLOBALS['phpgw_info']['server']['default_domain'];
245                }
246               
247                If(!$_GET['cd'])
248                        $GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create(strtolower($login),$passwd,$passwd_type,'u');
249
250                if(!isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
251                {
252                        If(!$_GET['cd']) $_GET['cd'] = $GLOBALS['phpgw']->session->cd_reason;
253                }
254                else
255                {
256                        if ($_POST['lang'] && preg_match('/^[a-z]{2}(-[a-z]{2}){0,1}$/',$_POST['lang']) &&
257                            $_POST['lang'] != $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])
258                        {
259                                $GLOBALS['phpgw']->preferences->add('common','lang',$_POST['lang'],'session');
260                        }
261
262                        if(!$GLOBALS['phpgw_info']['server']['disable_autoload_langfiles'])
263                        {
264                                $GLOBALS['phpgw']->translation->autoload_changed_langfiles();
265                        }
266                        $forward = isset($_GET['phpgw_forward']) ? urldecode($_GET['phpgw_forward']) : @$_POST['phpgw_forward'];
267                        if (!$forward)
268                        {
269                                $extra_vars['cd'] = 'yes';
270                                $forward = '/home.php';
271                        }
272                        else
273                        {
274                                list($forward,$extra_vars) = explode('?',$forward,2);
275                        }
276                if ($GLOBALS['phpgw_info']['server']['use_https'] != 2)
277                        {
278                        //Modificacao feita para que o Expresso redirecione para o primeiro proxy caso haja um encadeamento de mais de um proxy.
279                        //$forward = 'http://'.$_SERVER['HTTP_HOST'].($GLOBALS['phpgw']->link($forward.'?cd=yes'));
280                        $forward = 'http://' . nearest_to_me() . $GLOBALS['phpgw']->link($forward.'?cd=yes');
281                        echo "<script language='Javascript1.3'>location.href='".$forward."'</script>";
282                        }
283                else
284                        {
285                        $GLOBALS['phpgw']->redirect_link($forward,$extra_vars);
286                        }
287                }
288        }
289        //else   // =================================================================================
290        //{
291            $valor_contador = $_SESSION['contador'];
292            $valor_contador = $valor_contador + 1;
293            $_SESSION['contador'] = $valor_contador;
294                // !!! DONT CHANGE THESE LINES !!!
295                // If there is something wrong with this code TELL ME!
296                // Commenting out the code will not fix it. (jengo)
297                if(isset($_COOKIE['last_loginid']))
298                {
299                        $accounts = CreateObject('phpgwapi.accounts');
300                        $prefs = CreateObject('phpgwapi.preferences', $accounts->name2id($_COOKIE['last_loginid']));
301
302                        if($prefs->account_id)
303                        {
304                                $GLOBALS['phpgw_info']['user']['preferences'] = $prefs->read_repository();
305                        }
306                }
307               
308                $_GET['lang'] = addslashes($_GET['lang']);
309                if ($_GET['lang'])
310                {
311                        $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $_GET['lang'];
312                }
313                elseif(!isset($_COOKIE['last_loginid']) || !$prefs->account_id)
314                {
315                        // If the lastloginid cookies isn't set, we will default to the first language,
316                        // the users browser accepts.
317                        list($lang) = explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);
318                        /*
319                        if(strlen($lang) > 2)
320                        {
321                                $lang = substr($lang,0,2);
322                        }
323                        */
324                        $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = $lang;
325
326                        if (!isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme']))
327                        {
328                                $prefs2 = CreateObject('phpgwapi.preferences');
329                                $temp_pref = $prefs2->read_repository();
330                                $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $temp_pref['common']['theme'];
331                        }
332                }
333                #print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '<br>';
334
335                $GLOBALS['phpgw']->translation->init(); // this will set the language according to the (new) set prefs
336                $GLOBALS['phpgw']->translation->add_app('login');
337                $GLOBALS['phpgw']->translation->add_app('loginscreen');
338                if(lang('loginscreen_message') == 'loginscreen_message*')
339                {
340                        $GLOBALS['phpgw']->translation->add_app('loginscreen','en');    // trying the en one
341                }
342                if(lang('loginscreen_message') != 'loginscreen_message*')
343                {
344                        $tmpl->set_var('lang_message',stripslashes(lang('loginscreen_message')));
345                }
346        //}
347
348        if($GLOBALS['phpgw_info']['server']['use_prefix_organization'])
349        {
350                $obj_organization = CreateObject('phpgwapi.sector_search_ldap');
351                $organizations = $obj_organization->organization_search($GLOBALS['phpgw_info']['server']['ldap_context']);
352               
353                for ($i=0; $i<count($organizations); $i++)
354                {
355                        $tmp_array[strtolower($organizations[$i])] = $organizations[$i];       
356                }
357               
358                $arrayOrganization = $tmp_array;               
359                ksort($arrayOrganization);
360               
361                foreach($arrayOrganization
362                         as $organization_name => $organization_vars)
363                {
364                        $organization_select .= '<option value="' . $organization_name . '"';
365
366                        if($organization_name == $_COOKIE['last_organization'])
367                        {
368                                $organization_select .= ' selected';
369                        }
370                        $organization_select .= '>' . $organization_vars . "</option>\n";
371                }
372                $organization_select =  '<div class="login_label"><label>'.lang("organization")
373                                                        .'</label><br><select name="organization">'
374                                                        .$organization_select.'</select></div>';
375                $tmpl->set_var('select_organization',$organization_select);
376        }
377               
378        $domain_select = '&nbsp;';
379        $last_loginid = $_COOKIE['last_loginid'];
380        if($GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
381        {
382                $domain_select = "<select name=\"logindomain\">\n";
383                foreach($GLOBALS['phpgw_domain'] as $domain_name => $domain_vars)
384                {
385                        $domain_select .= '<option value="' . $domain_name . '"';
386
387                        if($domain_name == $_COOKIE['last_domain'])
388                        {
389                                $domain_select .= ' selected';
390                        }
391                        $domain_select .= '>' . $domain_name . "</option>\n";
392                }
393                $domain_select .= "</select>\n";
394        }
395        elseif($last_loginid !== '')
396        {
397                reset($GLOBALS['phpgw_domain']);
398                list($default_domain) = each($GLOBALS['phpgw_domain']);
399
400                if($_COOKIE['last_domain'] != $default_domain && !empty($_COOKIE['last_domain']))
401                {
402                        $last_loginid .= '@' . $_COOKIE['last_domain'];
403                }
404        }
405        $tmpl->set_var('select_domain',$domain_select);
406
407        foreach($_GET as $name => $value)
408        {
409                if(preg_match('/phpgw_/',$name))
410                {
411                        $extra_vars .= '&' . $name . '=' . urlencode($value);
412                }
413        }
414
415        if ( is_string( $extra_vars ) )
416        {
417                $extra_vars = '?' . substr($extra_vars,1);
418        }
419
420        /********************************************************\
421        * Check is the registration app is installed, activated  *
422        * And if the register link must be placed                *
423        \********************************************************/
424       
425        $cnf_reg = createobject('phpgwapi.config','registration');
426        $cnf_reg->read_repository();
427        $config_reg = $cnf_reg->config_data;
428
429        if($config_reg[enable_registration]=='True' && $config_reg[register_link]=='True')
430        {
431                $reg_link='&nbsp;<a href="registration/">'.lang('Not a user yet? Register now').'</a><br/>';
432        }
433
434        $template = $GLOBALS['phpgw_info']['login_template_set'];
435        $GLOBALS['phpgw_info']['server']['template_set'] = $template;
436
437        $tmpl->set_var('register_link',$reg_link);
438        $tmpl->set_var('charset',$GLOBALS['phpgw']->translation->charset());
439        $tmpl->set_var('login_url', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
440        $tmpl->set_var('registration_url',$GLOBALS['phpgw_info']['server']['webserver_url'] . '/registration/');
441        $tmpl->set_var('version',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
442        $tmpl->set_var('cd',check_logoutcode($_GET['cd']));
443        $tmpl->set_var('cookie',$last_loginid);
444
445        $tmpl->set_var('lang_username',lang('username'));
446        $tmpl->set_var('lang_password',lang('password'));
447        $tmpl->set_var('lang_login',lang('login'));
448
449        $tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']);
450        $tmpl->set_var('template_set', $template);
451
452        // loads the template's login.css
453        // and then the theme's login.css (if any)
454        $template_dir = $GLOBALS['phpgw_info']['server']['webserver_url'] . '/phpgwapi/templates/' . $template;
455        $login_dir = $template_dir . '/login.css';
456        $login_css = "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />";
457        $login_dir = $template_dir . '/themes/' . $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] . '/login.css';
458        if(file_exists('./'.$login_dir))
459        {
460                $login_css .= "<link href='" . $login_dir . "' rel='stylesheet' type='text/css' />";
461        }
462        $tmpl->set_var('login_css',$login_css);
463
464        $GLOBALS['phpgw']->translation->add_app('loginhelp',$_GET['lang']);
465
466        if(lang('loginhelp_message') != 'loginhelp_message*' && trim(lang('loginhelp_message')) != ""){                                 
467                $tmpl->set_var('lang_help',lang("Help"));       
468        }
469        else
470                $tmpl->set_var('display_help','none');
471
472        $tmpl->set_var('bg_color',($GLOBALS['phpgw_info']['server']['login_bg_color']?$GLOBALS['phpgw_info']['server']['login_bg_color']:'FFFFFF'));
473        $tmpl->set_var('bg_color_title',($GLOBALS['phpgw_info']['server']['login_bg_color_title']?$GLOBALS['phpgw_info']['server']['login_bg_color_title']:'486591'));
474
475        if($GLOBALS['phpgw_info']['server']['use_frontend_name'])
476                $tmpl->set_var('frontend_name', " - ".$GLOBALS['phpgw_info']['server']['use_frontend_name']);
477
478        if (substr($GLOBALS['phpgw_info']['server']['login_logo_file'],0,4) == 'http')
479        {
480                $var['logo_file'] = $GLOBALS['phpgw_info']['server']['login_logo_file'];
481        }
482        else
483        {
484                $var['logo_file'] = $GLOBALS['phpgw']->common->image('phpgwapi',$GLOBALS['phpgw_info']['server']['login_logo_file']?$GLOBALS['phpgw_info']['server']['login_logo_file']:'logo');
485        }
486        $var['logo_url'] = $GLOBALS['phpgw_info']['server']['login_logo_url']?$GLOBALS['phpgw_info']['server']['login_logo_url']:'http://www.eGroupWare.org';
487        if (substr($var['logo_url'],0,4) != 'http')
488        {
489                $var['logo_url'] = 'http://'.$var['logo_url'];
490        }
491        $var['logo_title'] = $GLOBALS['phpgw_info']['server']['login_logo_title']?$GLOBALS['phpgw_info']['server']['login_logo_title']:'www.eGroupWare.org';
492        $tmpl->set_var($var);
493
494        if (!@$GLOBALS['phpgw_info']['server']['login_virtual_keyboard'])
495                $tmpl->set_var('show_kbd','none');
496
497        if (@$GLOBALS['phpgw_info']['server']['login_show_language_selection'])
498        {
499                $select_lang = '<select name="lang" onchange="'."location.href=location.href+(location.search?'&':'?')+'lang='+this.value".'">';
500                $langs = $GLOBALS['phpgw']->translation->get_installed_langs();
501                uasort($langs,'strcasecmp');
502                foreach ($langs as $key => $name)       // if we have a translation use it
503                {
504                        $select_lang .= "\n\t".'<option value="'.$key.'"'.($key == $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] ? ' selected="1"' : '').'>'.$name.'</option>';
505                }
506                $select_lang .= "\n</select>\n";
507                $tmpl->set_var(array(
508                        'lang_language' => lang('Language'),
509                        'select_language' => $select_lang,
510                ));
511        }
512        else
513        {
514                $tmpl->set_block('login_form','language_select');
515                $tmpl->set_var('language_select','');
516        }
517
518        $tmpl->set_var('autocomplete', ($GLOBALS['phpgw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
519
520        // soh mostra o captcha se for login sem certificado....
521        if($GLOBALS['phpgw_info']['server']['captcha'] && $_GET['cd']!='300' )
522        {
523                $aux_captcha = '<input type="hidden" name="' . session_name() . '"  value="' . session_id() . '" >';
524        //        setcookie(session_name(),base64_encode(session_convert($key_convert . session_id(),$key_convert)),0);
525                if($valor_contador > $GLOBALS['phpgw_info']['server']['num_badlogin'])
526                {
527                        $aux_captcha = '<div class="login_label" >
528                           <img id="id_captcha" src="./security/captcha.php?' . session_name() . '=' . session_id() . '" title="'.lang('Security code').'" alt="'.lang('Security code').'" style="position:static;">
529                           <input class="input" type="text" maxlength="50" size="20" name="codigo" id="codigo" value="" >
530                           <input type="hidden" name="' . session_name() . '"  value="' . session_id() . '" >
531                           </div>';
532                }
533        }
534        $tmpl->set_var('captcha',$aux_captcha);
535
536        // Testa se deve incluir applet para login com certificado......
537        if ($_GET['cd']=='300' && $GLOBALS['phpgw_info']['server']['certificado']==1)
538        {
539                //Zera o Cookie contador, responsavel pelo captcha
540                $_SESSION['contador'] = 0;
541                $valor_contador = 0;
542                $link_alterna_login = '<img src="phpgwapi/templates/default/images/warning.gif"/><a href="login.php">' . lang('Access without Digital Certificate') . '</a>';
543                $tmpl->set_var('show','none');
544                $tmpl->set_var('action','<div id="action"><img style="border:0px;margin:31px 0px 58px 0px;" src="phpgwapi/templates/default/images/acao.gif" /></div>');
545                // gera parametro com tokens suportados ....
546                $var_tokens = '';
547                for($ii = 1; $ii < 11; $ii++)
548                {
549                        if($GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'])
550                                $var_tokens .= $GLOBALS['phpgw_info']['server']['test_token' . $ii . '1'] . ',';
551                }
552
553                if(!$var_tokens)
554                {
555                        $var_tokens = 'ePass2000Lx;/usr/lib/libepsng_p11.so,ePass2000Win;c:/windows/system32/ngp11v211.dll';
556                }
557                $param1 = "
558                                                                                        '<param name=\"token\" value=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\"> ' +
559                                                                                   ";
560                $param2 = "
561                                                                                        'token=\"" . substr($var_tokens,0,strlen($var_tokens)) . "\" ' +
562                                                                                   ";
563
564                $cod_applet =
565
566/*    // com debug ativado
567            '<script type="text/javascript">
568                                        if (navigator.userAgent.match(\'MSIE\')){
569                                                document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' +
570                                                \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' +
571                                                \'<param name="type" value="application/x-java-applet;version=1.5"> \' +
572                                                \'<param name="code" value="LoginApplet.class"> \' +
573                                                \'<param name="locale" value="' . $lang . '"> \' +
574                                                \'<param name="mayscript" value="true"> \' + '
575                                                . $param1
576                                                . ' \'<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"> \' +
577                        \'<param name="debug" value="true"> \' +
578                                                \'</object>\');
579                                        }
580                                        else {
581                                                document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" code="LoginApplet.class" locale="' . $lang . '"\' +
582                                                \'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" \' + '
583                                                . $param2
584                                                . ' \'type="application/x-java-applet;version=1.5" debug= "true" mayscript > \' +
585                                                \'<noembed> \' +
586                                                \'No Java Support. \' +
587                                                \'</noembed> \' +
588                                                \'</embed> \');
589                                        }
590                                </script>';
591*/
592            // sem debug ativado
593            '<script type="text/javascript">
594                                        if (navigator.userAgent.match(\'MSIE\')){
595                                                document.write(\'<object style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" \' +
596                                                \'classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"> \' +
597                                                \'<param name="type" value="application/x-java-applet;version=1.5"> \' +
598                                                \'<param name="codebase" value="/security/">\' +
599                                                \'<param name="code" value="LoginApplet.class"> \' +
600                                                \'<param name="locale" value="' . $lang . '"> \' +
601                                                \'<param name="mayscript" value="true"> \' + '
602                                                . $param1
603                                                . ' \'<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"> \' +
604                                                \'</object>\');
605                                        }
606                                        else {
607                                                document.write(\'<embed style="display:yes;width:0;height:0;vertical-align:bottom;" id="login_applet" codebase="/security/" code="LoginApplet.class" locale="' . $lang . '"\' +
608                                                \'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" \' + '
609                                                . $param2 
610                                                . ' \'type="application/x-java-applet;version=1.5" mayscript > \' +
611                                                \'<noembed> \' +
612                                                \'No Java Support. \' +
613                                                \'</noembed> \' +
614                                                \'</embed> \');
615                                        }
616                                </script>';
617
618
619        }
620
621        else
622        {
623                if($GLOBALS['phpgw_info']['server']['certificado']==1)
624                {
625                        $tmpl->set_var('show','yes');
626                        $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>';
627                }
628                $tmpl->set_var('lang_username',lang('username'));
629                $tmpl->set_var('action','');
630                $cod_applet = '';
631
632        }
633
634        $tmpl->set_var('applet',$cod_applet);
635        $tmpl->set_var('link_alterna_login',$link_alterna_login);
636
637
638        $tmpl->set_var('dir_root', 'http://' . nearest_to_me() . '/');
639        if(is_file(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php'))
640        include_once(dirname( __FILE__ ) . '/../../../infodist/ultima-revisao-svn.php');
641        if(isset($ultima_revisao)) $tmpl->set_var('ultima_rev','<br>' . $ultima_revisao);
642
643        // Adiciona cï¿œdigo personalizado de outro template
644        // que esteja utilizando o login_default.php
645        if(is_file('.'.$template_dir.'/login.inc.php')) {
646                include_once('.'.$template_dir.'/login.inc.php');
647        }
648
649        $tmpl->pfp('loginout','login_form');
650        }
651
652?>
653
Note: See TracBrowser for help on using the repository browser.